From fea2ace548a3b6386e8a00527bbde2f67f7dd83d Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 13 Sep 2022 01:39:44 +0200 Subject: [PATCH 001/374] OpenXR - Initial work on Vulkan support --- Common/GPU/Vulkan/VulkanLoader.cpp | 6 ---- Common/VR/PPSSPPVR.cpp | 4 ++- Common/VR/VRBase.cpp | 57 ++++++++++++++++++----------- Common/VR/VRBase.h | 4 ++- Common/VR/VRFramebuffer.cpp | 26 ++++++++++++-- Common/VR/VRFramebuffer.h | 1 + Common/VR/VRRenderer.cpp | 58 +++++++----------------------- 7 files changed, 80 insertions(+), 76 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanLoader.cpp b/Common/GPU/Vulkan/VulkanLoader.cpp index b0c2ab370b..2ead5cb95d 100644 --- a/Common/GPU/Vulkan/VulkanLoader.cpp +++ b/Common/GPU/Vulkan/VulkanLoader.cpp @@ -23,7 +23,6 @@ #include "Common/GPU/Vulkan/VulkanLoader.h" #include "Common/Log.h" #include "Common/System/System.h" -#include "Common/VR/PPSSPPVR.h" #if !PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(SWITCH) #include @@ -309,11 +308,6 @@ void VulkanSetAvailable(bool available) { bool VulkanMayBeAvailable() { - //unsupported in VR at the moment - if (IsVRBuild()) { - return false; - } - if (g_vulkanAvailabilityChecked) { return g_vulkanMayBeAvailable; } diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 71b4919bf1..23712db954 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -97,12 +97,14 @@ bool IsVRBuild() { } void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { + bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN; + ovrJava java; java.Vm = (JavaVM*)vm; java.ActivityObject = (jobject)activity; java.AppVersion = version; strcpy(java.AppName, name); - VR_Init(java); + VR_Init(java, useVulkan); __DisplaySetFramerate(72); } diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index 9932d09553..bedc6b1e0c 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -4,21 +4,12 @@ #include #include #include +#include static engine_t vr_engine; int vr_initialized = 0; -const char* const requiredExtensionNames[] = { - XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME, -#ifdef OPENXR_HAS_PERFORMANCE_EXTENSION - XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME, - XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME, -#endif - XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME}; -const uint32_t numRequiredExtensions = - sizeof(requiredExtensionNames) / sizeof(requiredExtensionNames[0]); - -void VR_Init( ovrJava java ) { +void VR_Init( ovrJava java, bool useVulkan ) { if (vr_initialized) return; @@ -37,6 +28,18 @@ void VR_Init( ovrJava java ) { xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid); } + std::vector extensions; + if (useVulkan) { + extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); + } else { + extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME); + } + extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME); +#ifdef OPENXR_HAS_PERFORMANCE_EXTENSION + extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); + extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME); +#endif + // Create the OpenXR instance. XrApplicationInfo appInfo; memset(&appInfo, 0, sizeof(appInfo)); @@ -54,8 +57,8 @@ void VR_Init( ovrJava java ) { instanceCreateInfo.applicationInfo = appInfo; instanceCreateInfo.enabledApiLayerCount = 0; instanceCreateInfo.enabledApiLayerNames = NULL; - instanceCreateInfo.enabledExtensionCount = numRequiredExtensions; - instanceCreateInfo.enabledExtensionNames = requiredExtensionNames; + instanceCreateInfo.enabledExtensionCount = extensions.size(); + instanceCreateInfo.enabledExtensionNames = extensions.data(); XrResult initResult; OXR(initResult = xrCreateInstance(&instanceCreateInfo, &vr_engine.appState.Instance)); @@ -89,15 +92,27 @@ void VR_Init( ovrJava java ) { } // Get the graphics requirements. - PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL; - OXR(xrGetInstanceProcAddr( - vr_engine.appState.Instance, - "xrGetOpenGLESGraphicsRequirementsKHR", - (PFN_xrVoidFunction*)(&pfnGetOpenGLESGraphicsRequirementsKHR))); + if (useVulkan) { + PFN_xrGetVulkanGraphicsRequirementsKHR pfnGetVulkanGraphicsRequirementsKHR = NULL; + OXR(xrGetInstanceProcAddr( + vr_engine.appState.Instance, + "xrGetVulkanGraphicsRequirementsKHR", + (PFN_xrVoidFunction*)(&pfnGetVulkanGraphicsRequirementsKHR))); - XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {}; - graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR; - OXR(pfnGetOpenGLESGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements)); + XrGraphicsRequirementsVulkanKHR graphicsRequirements = {}; + graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR; + OXR(pfnGetVulkanGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements)); + } else { + PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL; + OXR(xrGetInstanceProcAddr( + vr_engine.appState.Instance, + "xrGetOpenGLESGraphicsRequirementsKHR", + (PFN_xrVoidFunction*)(&pfnGetOpenGLESGraphicsRequirementsKHR))); + + XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {}; + graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR; + OXR(pfnGetOpenGLESGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements)); + } vr_engine.appState.MainThreadTid = gettid(); vr_engine.appState.SystemId = systemId; diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index fffd234868..4d5138e40f 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -12,10 +12,12 @@ //OpenXR #define XR_USE_PLATFORM_ANDROID 1 #define XR_USE_GRAPHICS_API_OPENGL_ES 1 +#define XR_USE_GRAPHICS_API_VULKAN 1 #include #include #include #include +#include #include #include #include @@ -146,7 +148,7 @@ typedef struct { float predictedDisplayTime; } engine_t; -void VR_Init( ovrJava java ); +void VR_Init( ovrJava java, bool useVulkan ); void VR_Destroy( engine_t* engine ); void VR_EnterVR( engine_t* engine ); void VR_LeaveVR( engine_t* engine ); diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 70f2ad02aa..007a21cee8 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -9,8 +9,6 @@ #include #include #include -#include -#include double FromXrTime(const XrTime time) { return (time * 1e-9); @@ -178,6 +176,15 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { waitInfo.timeout * (1E-9)); } frameBuffer->Acquired = res == XR_SUCCESS; + + ovrFramebuffer_SetCurrent(frameBuffer); + GL(glEnable( GL_SCISSOR_TEST )); + GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); + GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); + GL(glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height )); + GL(glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )); + GL(glScissor( 0, 0, 0, 0 )); + GL(glDisable( GL_SCISSOR_TEST )); } void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { @@ -185,6 +192,12 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { XrSwapchainImageReleaseInfo releaseInfo = {XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO, NULL}; OXR(xrReleaseSwapchainImage(frameBuffer->ColorSwapChain.Handle, &releaseInfo)); frameBuffer->Acquired = false; + + // Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully + GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); + GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); + GL(glClear(GL_COLOR_BUFFER_BIT)); + GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)); } } @@ -217,6 +230,15 @@ void ovrRenderer_Destroy(ovrRenderer* renderer) { } } +void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { + GL(glEnable(GL_SCISSOR_TEST)); + GL(glScissor(x, y, size, size)); + GL(glViewport(x, y, size, size)); + GL(glClearColor(1.0f, 1.0f, 1.0f, 1.0f)); + GL(glClear(GL_COLOR_BUFFER_BIT)); + GL(glDisable(GL_SCISSOR_TEST)); +} + /* ================================================================================ diff --git a/Common/VR/VRFramebuffer.h b/Common/VR/VRFramebuffer.h index dcedad580f..20b9004190 100644 --- a/Common/VR/VRFramebuffer.h +++ b/Common/VR/VRFramebuffer.h @@ -14,3 +14,4 @@ void ovrFramebuffer_SetNone(); void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, bool multiview); void ovrRenderer_Destroy(ovrRenderer* renderer); +void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 79e6114a61..1d421c2fa3 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -6,14 +6,11 @@ #include #include -#include -#include - XrView* projections; XrPosef invViewTransform[2]; XrFrameState frameState = {}; -GLboolean initialized = GL_FALSE; -GLboolean stageSupported = GL_FALSE; +bool initialized = false; +bool stageSupported = false; int vrConfig[VR_CONFIG_MAX] = {}; XrVector3f hmdorientation; @@ -194,7 +191,7 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { for (uint32_t i = 0; i < numOutputSpaces; i++) { if (referenceSpaces[i] == XR_REFERENCE_SPACE_TYPE_STAGE) { - stageSupported = GL_TRUE; + stageSupported = true; break; } } @@ -213,40 +210,27 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { engine->appState.ViewConfigurationView[0].recommendedImageRectWidth, engine->appState.ViewConfigurationView[0].recommendedImageRectHeight, multiview); - initialized = GL_TRUE; + initialized = true; } void VR_DestroyRenderer( engine_t* engine ) { ovrRenderer_Destroy(&engine->appState.Renderer); free(projections); - initialized = GL_FALSE; -} - -void VR_ClearFrameBuffer( int width, int height) { - glEnable( GL_SCISSOR_TEST ); - glViewport( 0, 0, width, height ); - - glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - - glScissor( 0, 0, width, height ); - glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - - glScissor( 0, 0, 0, 0 ); - glDisable( GL_SCISSOR_TEST ); + initialized = false; } bool VR_InitFrame( engine_t* engine ) { - GLboolean stageBoundsDirty = GL_TRUE; + bool stageBoundsDirty = true; if (ovrApp_HandleXrEvents(&engine->appState)) { VR_Recenter(engine); } - if (engine->appState.SessionActive == GL_FALSE) { + if (engine->appState.SessionActive == false) { return false; } if (stageBoundsDirty) { VR_UpdateStageBounds(&engine->appState); - stageBoundsDirty = GL_FALSE; + stageBoundsDirty = false; } // NOTE: OpenXR does not use the concept of frame indices. Instead, @@ -309,32 +293,19 @@ bool VR_InitFrame( engine_t* engine ) { void VR_BeginFrame( engine_t* engine, int fboIndex ) { vrConfig[VR_CONFIG_CURRENT_FBO] = fboIndex; - ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer[fboIndex]; - ovrFramebuffer_Acquire(frameBuffer); - ovrFramebuffer_SetCurrent(frameBuffer); - VR_ClearFrameBuffer(frameBuffer->ColorSwapChain.Width, frameBuffer->ColorSwapChain.Height); + ovrFramebuffer_Acquire(&engine->appState.Renderer.FrameBuffer[fboIndex]); } void VR_EndFrame( engine_t* engine ) { - int fboIndex = vrConfig[VR_CONFIG_CURRENT_FBO]; - - // Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully VR_BindFramebuffer(engine); - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); - glClearColor(0.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // Show mouse cursor int size = vrConfig[VR_CONFIG_MOUSE_SIZE]; if ((vrConfig[VR_CONFIG_MODE] == VR_MODE_FLAT_SCREEN) && (size > 0)) { - glEnable(GL_SCISSOR_TEST); - glScissor(vrConfig[VR_CONFIG_MOUSE_X], vrConfig[VR_CONFIG_MOUSE_Y], size, size); - glViewport(vrConfig[VR_CONFIG_MOUSE_X], vrConfig[VR_CONFIG_MOUSE_Y], size, size); - glClearColor(1, 1, 1, 1); - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); + int x = vrConfig[VR_CONFIG_MOUSE_X]; + int y = vrConfig[VR_CONFIG_MOUSE_Y]; + ovrRenderer_MouseCursor(&engine->appState.Renderer, x, y, size); } ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer[fboIndex]; @@ -454,10 +425,7 @@ void VR_SetConfig( VRConfig config, int value) { void VR_BindFramebuffer(engine_t *engine) { if (!initialized) return; int fboIndex = vrConfig[VR_CONFIG_CURRENT_FBO]; - ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer[fboIndex]; - unsigned int swapchainIndex = frameBuffer->TextureSwapChainIndex; - unsigned int glFramebuffer = frameBuffer->FrameBuffers[swapchainIndex]; - GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, glFramebuffer)); + ovrFramebuffer_SetCurrent(&engine->appState.Renderer.FrameBuffer[fboIndex]); } ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) { From d8fbc7ce56e426d7bdd65318d4a3f009e8c55974 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 14 Sep 2022 19:53:55 +0200 Subject: [PATCH 002/374] OpenXR - Vulkan support in progress --- Common/VR/PPSSPPVR.cpp | 22 ++++- Common/VR/PPSSPPVR.h | 4 +- Common/VR/VRBase.cpp | 22 +++-- Common/VR/VRBase.h | 23 ++++- Common/VR/VRFramebuffer.cpp | 181 ++++++++++++++++++++++++++++-------- Common/VR/VRFramebuffer.h | 4 +- Common/VR/VRRenderer.cpp | 12 ++- android/jni/app-android.cpp | 2 +- 8 files changed, 204 insertions(+), 66 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 23712db954..ef0d6f7c03 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -1,3 +1,4 @@ +#include "Common/GPU/Vulkan/VulkanContext.h" #include "Common/VR/PPSSPPVR.h" #include "Common/VR/VRBase.h" #include "Common/VR/VRInput.h" @@ -109,10 +110,25 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { __DisplaySetFramerate(72); } -void EnterVR(bool firstStart) { +void EnterVR(bool firstStart, void* vulkanContext) { if (firstStart) { - VR_EnterVR(VR_GetEngine()); - IN_VRInit(VR_GetEngine()); + engine_t* engine = VR_GetEngine(); + bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN; + if (useVulkan) { + auto* context = (VulkanContext*)vulkanContext; + engine->graphicsBindingVulkan = {}; + engine->graphicsBindingVulkan.type = XR_TYPE_GRAPHICS_BINDING_VULKAN_KHR; + engine->graphicsBindingVulkan.next = NULL; + engine->graphicsBindingVulkan.device = context->GetDevice(); + engine->graphicsBindingVulkan.instance = context->GetInstance(); + engine->graphicsBindingVulkan.physicalDevice = context->GetCurrentPhysicalDevice(); + engine->graphicsBindingVulkan.queueFamilyIndex = context->GetGraphicsQueueFamilyIndex(); + engine->graphicsBindingVulkan.queueIndex = 0; + VR_EnterVR(engine, &engine->graphicsBindingVulkan); + } else { + VR_EnterVR(engine, nullptr); + } + IN_VRInit(engine); } VR_SetConfig(VR_CONFIG_VIEWPORT_VALID, false); } diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index e7151130ea..7ff1338eea 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -8,7 +8,7 @@ // VR app flow integration bool IsVRBuild(); void InitVROnAndroid(void* vm, void* activity, int version, const char* name); -void EnterVR(bool firstStart); +void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); void UpdateVRScreenKey(const KeyInput &key); @@ -31,7 +31,7 @@ void UpdateVRView(float* leftEye, float* rightEye); // VR app flow integration inline bool IsVRBuild() { return false; } inline void InitVROnAndroid(void* vm, void* activity, int version, const char* name) {} -inline void EnterVR(bool firstTime) {} +inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} inline void UpdateVRScreenKey(const KeyInput &key) {} diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index bedc6b1e0c..e146967b42 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -118,6 +118,7 @@ void VR_Init( ovrJava java, bool useVulkan ) { vr_engine.appState.SystemId = systemId; vr_engine.java = java; + vr_engine.useVulkan = useVulkan; vr_initialized = 1; } @@ -128,7 +129,7 @@ void VR_Destroy( engine_t* engine ) { } } -void VR_EnterVR( engine_t* engine ) { +void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ) { if (engine->appState.Session) { ALOGE("VR_EnterVR called with existing session"); @@ -136,17 +137,20 @@ void VR_EnterVR( engine_t* engine ) { } // Create the OpenXR Session. - XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {}; - graphicsBindingAndroidGLES.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; - graphicsBindingAndroidGLES.next = NULL; - graphicsBindingAndroidGLES.display = eglGetCurrentDisplay(); - graphicsBindingAndroidGLES.config = eglGetCurrentSurface(EGL_DRAW); - graphicsBindingAndroidGLES.context = eglGetCurrentContext(); - XrSessionCreateInfo sessionCreateInfo = {}; + XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {}; memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo)); + if (engine->useVulkan) { + sessionCreateInfo.next = graphicsBindingVulkan; + } else { + graphicsBindingAndroidGLES.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; + graphicsBindingAndroidGLES.next = NULL; + graphicsBindingAndroidGLES.display = eglGetCurrentDisplay(); + graphicsBindingAndroidGLES.config = eglGetCurrentSurface(EGL_DRAW); + graphicsBindingAndroidGLES.context = eglGetCurrentContext(); + sessionCreateInfo.next = &graphicsBindingAndroidGLES; + } sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO; - sessionCreateInfo.next = &graphicsBindingAndroidGLES; sessionCreateInfo.createFlags = 0; sessionCreateInfo.systemId = engine->appState.SystemId; diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 4d5138e40f..89bec2b3dd 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -9,6 +9,14 @@ #define ALOGV(...) printf(__VA_ARGS__) #endif +//Vulkan +#ifdef VK_USE_NATIVE_LIB +#include +#else +#include "Common/GPU/Vulkan/VulkanLoader.h" +using namespace PPSSPP_VK; +#endif + //OpenXR #define XR_USE_PLATFORM_ANDROID 1 #define XR_USE_GRAPHICS_API_OPENGL_ES 1 @@ -17,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -98,10 +105,14 @@ typedef struct { uint32_t TextureSwapChainIndex; ovrSwapChain ColorSwapChain; ovrSwapChain DepthSwapChain; - XrSwapchainImageOpenGLESKHR* ColorSwapChainImage; - XrSwapchainImageOpenGLESKHR* DepthSwapChainImage; - unsigned int* FrameBuffers; + void* ColorSwapChainImage; + void* DepthSwapChainImage; + unsigned int* GLFrameBuffers; + VkFramebuffer* VKFrameBuffers; + bool Acquired; + bool UseVulkan; + XrGraphicsBindingVulkanKHR* VKContext; } ovrFramebuffer; typedef struct { @@ -146,11 +157,13 @@ typedef struct { ovrApp appState; ovrJava java; float predictedDisplayTime; + bool useVulkan; + XrGraphicsBindingVulkanKHR graphicsBindingVulkan; } engine_t; void VR_Init( ovrJava java, bool useVulkan ); void VR_Destroy( engine_t* engine ); -void VR_EnterVR( engine_t* engine ); +void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ); void VR_LeaveVR( engine_t* engine ); engine_t* VR_GetEngine( void ); diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 007a21cee8..4a71cb5cd8 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -37,14 +37,15 @@ void ovrFramebuffer_Clear(ovrFramebuffer* frameBuffer) { frameBuffer->DepthSwapChain.Height = 0; frameBuffer->DepthSwapChainImage = NULL; - frameBuffer->FrameBuffers = NULL; + frameBuffer->GLFrameBuffers = NULL; frameBuffer->Acquired = false; } -bool ovrFramebuffer_Create(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview) { +bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview) { frameBuffer->Width = width; frameBuffer->Height = height; + frameBuffer->UseVulkan = false; if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OVR_multiview2") == nullptr) { @@ -78,20 +79,20 @@ bool ovrFramebuffer_Create(XrSession session, ovrFramebuffer* frameBuffer, int w swapChainCreateInfo.usageFlags = XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT; OXR(xrCreateSwapchain(session, &swapChainCreateInfo, &frameBuffer->ColorSwapChain.Handle)); OXR(xrEnumerateSwapchainImages(frameBuffer->ColorSwapChain.Handle, 0, &frameBuffer->TextureSwapChainLength, NULL)); - frameBuffer->ColorSwapChainImage = (XrSwapchainImageOpenGLESKHR*)malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageOpenGLESKHR)); + frameBuffer->ColorSwapChainImage = malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageOpenGLESKHR)); // Create the depth swapchain. swapChainCreateInfo.format = GL_DEPTH24_STENCIL8; swapChainCreateInfo.usageFlags = XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; OXR(xrCreateSwapchain(session, &swapChainCreateInfo, &frameBuffer->DepthSwapChain.Handle)); - frameBuffer->DepthSwapChainImage = (XrSwapchainImageOpenGLESKHR*)malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageOpenGLESKHR)); + frameBuffer->DepthSwapChainImage = malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageOpenGLESKHR)); // Populate the swapchain image array. for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) { - frameBuffer->ColorSwapChainImage[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR; - frameBuffer->ColorSwapChainImage[i].next = NULL; - frameBuffer->DepthSwapChainImage[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR; - frameBuffer->DepthSwapChainImage[i].next = NULL; + ((XrSwapchainImageOpenGLESKHR*)frameBuffer->ColorSwapChainImage)[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR; + ((XrSwapchainImageOpenGLESKHR*)frameBuffer->ColorSwapChainImage)[i].next = NULL; + ((XrSwapchainImageOpenGLESKHR*)frameBuffer->DepthSwapChainImage)[i].type = XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR; + ((XrSwapchainImageOpenGLESKHR*)frameBuffer->DepthSwapChainImage)[i].next = NULL; } OXR(xrEnumerateSwapchainImages( frameBuffer->ColorSwapChain.Handle, @@ -104,14 +105,14 @@ bool ovrFramebuffer_Create(XrSession session, ovrFramebuffer* frameBuffer, int w &frameBuffer->TextureSwapChainLength, (XrSwapchainImageBaseHeader*)frameBuffer->DepthSwapChainImage)); - frameBuffer->FrameBuffers = (GLuint*)malloc(frameBuffer->TextureSwapChainLength * sizeof(GLuint)); + frameBuffer->GLFrameBuffers = (GLuint*)malloc(frameBuffer->TextureSwapChainLength * sizeof(GLuint)); for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) { - const GLuint colorTexture = frameBuffer->ColorSwapChainImage[i].image; - const GLuint depthTexture = frameBuffer->DepthSwapChainImage[i].image; + const GLuint colorTexture = ((XrSwapchainImageOpenGLESKHR*)frameBuffer->ColorSwapChainImage)[i].image; + const GLuint depthTexture = ((XrSwapchainImageOpenGLESKHR*)frameBuffer->DepthSwapChainImage)[i].image; // Create the frame buffer. - GL(glGenFramebuffers(1, &frameBuffer->FrameBuffers[i])); - GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->FrameBuffers[i])); + GL(glGenFramebuffers(1, &frameBuffer->GLFrameBuffers[i])); + GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[i])); if (multiview) { GL(glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, depthTexture, 0, 0, 2)); GL(glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthTexture, 0, 0, 2)); @@ -132,29 +133,114 @@ bool ovrFramebuffer_Create(XrSession session, ovrFramebuffer* frameBuffer, int w return true; } +bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, + bool multiview, void* context) { + + frameBuffer->Width = width; + frameBuffer->Height = height; + frameBuffer->UseVulkan = true; + frameBuffer->VKContext = (XrGraphicsBindingVulkanKHR*)context; + + XrSwapchainCreateInfo swapChainCreateInfo; + memset(&swapChainCreateInfo, 0, sizeof(swapChainCreateInfo)); + swapChainCreateInfo.type = XR_TYPE_SWAPCHAIN_CREATE_INFO; + swapChainCreateInfo.sampleCount = 1; + swapChainCreateInfo.width = width; + swapChainCreateInfo.height = height; + swapChainCreateInfo.faceCount = 1; + swapChainCreateInfo.mipCount = 1; + swapChainCreateInfo.arraySize = multiview ? 2 : 1; + + frameBuffer->ColorSwapChain.Width = swapChainCreateInfo.width; + frameBuffer->ColorSwapChain.Height = swapChainCreateInfo.height; + frameBuffer->DepthSwapChain.Width = swapChainCreateInfo.width; + frameBuffer->DepthSwapChain.Height = swapChainCreateInfo.height; + + // Create the color swapchain. + swapChainCreateInfo.format = VK_FORMAT_R8G8B8A8_UNORM; + swapChainCreateInfo.usageFlags = XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT; + OXR(xrCreateSwapchain(session, &swapChainCreateInfo, &frameBuffer->ColorSwapChain.Handle)); + OXR(xrEnumerateSwapchainImages(frameBuffer->ColorSwapChain.Handle, 0, &frameBuffer->TextureSwapChainLength, NULL)); + frameBuffer->ColorSwapChainImage = malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageVulkanKHR)); + + // Create the depth swapchain. + swapChainCreateInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; + swapChainCreateInfo.usageFlags = XR_SWAPCHAIN_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; + OXR(xrCreateSwapchain(session, &swapChainCreateInfo, &frameBuffer->DepthSwapChain.Handle)); + frameBuffer->DepthSwapChainImage = malloc(frameBuffer->TextureSwapChainLength * sizeof(XrSwapchainImageVulkanKHR)); + + // Populate the swapchain image array. + for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) { + ((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR; + ((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].next = NULL; + ((XrSwapchainImageVulkanKHR*)frameBuffer->DepthSwapChainImage)[i].type = XR_TYPE_SWAPCHAIN_IMAGE_VULKAN_KHR; + ((XrSwapchainImageVulkanKHR*)frameBuffer->DepthSwapChainImage)[i].next = NULL; + } + OXR(xrEnumerateSwapchainImages( + frameBuffer->ColorSwapChain.Handle, + frameBuffer->TextureSwapChainLength, + &frameBuffer->TextureSwapChainLength, + (XrSwapchainImageBaseHeader*)frameBuffer->ColorSwapChainImage)); + OXR(xrEnumerateSwapchainImages( + frameBuffer->DepthSwapChain.Handle, + frameBuffer->TextureSwapChainLength, + &frameBuffer->TextureSwapChainLength, + (XrSwapchainImageBaseHeader*)frameBuffer->DepthSwapChainImage)); + + frameBuffer->VKFrameBuffers = (VkFramebuffer*)malloc(frameBuffer->TextureSwapChainLength * sizeof(VkFramebuffer)); + for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) { + VkImage colorTexture = ((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].image; + VkImage depthTexture = ((XrSwapchainImageVulkanKHR*)frameBuffer->DepthSwapChainImage)[i].image; + + // Create the frame buffer. + //TODO:implement framebuffer creation + } + + return true; +} + void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { - GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->FrameBuffers)); + if (frameBuffer->UseVulkan) { + for (int i = 0; i < frameBuffer->TextureSwapChainLength; i++) { + vkDestroyFramebuffer(frameBuffer->VKContext->device, frameBuffer->VKFrameBuffers[i], nullptr); + } + free(frameBuffer->VKFrameBuffers); + } else { + GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers)); + free(frameBuffer->GLFrameBuffers); + } OXR(xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle)); OXR(xrDestroySwapchain(frameBuffer->DepthSwapChain.Handle)); free(frameBuffer->ColorSwapChainImage); free(frameBuffer->DepthSwapChainImage); - free(frameBuffer->FrameBuffers); ovrFramebuffer_Clear(frameBuffer); } void ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { - GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->FrameBuffers[frameBuffer->TextureSwapChainIndex])); + if (frameBuffer->UseVulkan) { + //TODO:bind framebuffer + } else { + GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); + } } -void ovrFramebuffer_SetNone() { - GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)); +void ovrFramebuffer_SetNone(ovrFramebuffer* frameBuffer) { + if (frameBuffer->UseVulkan) { + //TODO:unbind framebuffer + } else { + GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)); + } } void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer) { // Discard the depth buffer, so the tiler won't need to write it back out to memory. - const GLenum depthAttachment[1] = {GL_DEPTH_ATTACHMENT}; - glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, 1, depthAttachment); + if (frameBuffer->UseVulkan) { + //TODO:implement + } else { + const GLenum depthAttachment[1] = {GL_DEPTH_ATTACHMENT}; + glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, 1, depthAttachment); + } } void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { @@ -178,13 +264,18 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = res == XR_SUCCESS; ovrFramebuffer_SetCurrent(frameBuffer); - GL(glEnable( GL_SCISSOR_TEST )); - GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); - GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); - GL(glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height )); - GL(glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )); - GL(glScissor( 0, 0, 0, 0 )); - GL(glDisable( GL_SCISSOR_TEST )); + + if (frameBuffer->UseVulkan) { + //TODO:implement + } else { + GL(glEnable( GL_SCISSOR_TEST )); + GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); + GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); + GL(glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height )); + GL(glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )); + GL(glScissor( 0, 0, 0, 0 )); + GL(glDisable( GL_SCISSOR_TEST )); + } } void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { @@ -194,10 +285,14 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = false; // Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully - GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); - GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); - GL(glClear(GL_COLOR_BUFFER_BIT)); - GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)); + if (frameBuffer->UseVulkan) { + //TODO:implement + } else { + GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); + GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); + GL(glClear(GL_COLOR_BUFFER_BIT)); + GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)); + } } } @@ -215,11 +310,15 @@ void ovrRenderer_Clear(ovrRenderer* renderer) { } } -void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, bool multiview) { +void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, bool multiview, void* vulkanContext) { renderer->Multiview = multiview; int instances = renderer->Multiview ? 1 : ovrMaxNumEyes; for (int i = 0; i < instances; i++) { - ovrFramebuffer_Create(session, &renderer->FrameBuffer[i], width, height, multiview); + if (vulkanContext) { + ovrFramebuffer_CreateVK(session, &renderer->FrameBuffer[i], width, height, multiview, vulkanContext); + } else { + ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height, multiview); + } } } @@ -231,12 +330,16 @@ void ovrRenderer_Destroy(ovrRenderer* renderer) { } void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { - GL(glEnable(GL_SCISSOR_TEST)); - GL(glScissor(x, y, size, size)); - GL(glViewport(x, y, size, size)); - GL(glClearColor(1.0f, 1.0f, 1.0f, 1.0f)); - GL(glClear(GL_COLOR_BUFFER_BIT)); - GL(glDisable(GL_SCISSOR_TEST)); + if (renderer->FrameBuffer[0].UseVulkan) { + //TODO:implement + } else { + GL(glEnable(GL_SCISSOR_TEST)); + GL(glScissor(x, y, size, size)); + GL(glViewport(x, y, size, size)); + GL(glClearColor(1.0f, 1.0f, 1.0f, 1.0f)); + GL(glClear(GL_COLOR_BUFFER_BIT)); + GL(glDisable(GL_SCISSOR_TEST)); + } } /* diff --git a/Common/VR/VRFramebuffer.h b/Common/VR/VRFramebuffer.h index 20b9004190..12eb162980 100644 --- a/Common/VR/VRFramebuffer.h +++ b/Common/VR/VRFramebuffer.h @@ -10,8 +10,8 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer); void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer); void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer); void ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer); -void ovrFramebuffer_SetNone(); +void ovrFramebuffer_SetNone(ovrFramebuffer* frameBuffer); -void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, bool multiview); +void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, bool multiview, void* vulkanContext); void ovrRenderer_Destroy(ovrRenderer* renderer); void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 1d421c2fa3..f9a8e5ce53 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -204,12 +204,14 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView))); - ovrRenderer_Create( - engine->appState.Session, - &engine->appState.Renderer, + void* vulkanContext = nullptr; + if (engine->useVulkan) { + vulkanContext = &engine->graphicsBindingVulkan; + } + ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer, engine->appState.ViewConfigurationView[0].recommendedImageRectWidth, engine->appState.ViewConfigurationView[0].recommendedImageRectHeight, - multiview); + multiview, vulkanContext); initialized = true; } @@ -311,7 +313,7 @@ void VR_EndFrame( engine_t* engine ) { ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer[fboIndex]; //ovrFramebuffer_Resolve(frameBuffer); ovrFramebuffer_Release(frameBuffer); - ovrFramebuffer_SetNone(); + ovrFramebuffer_SetNone(frameBuffer); } void VR_FinishFrame( engine_t* engine ) { diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 482b864ea5..d430322afc 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -940,7 +940,7 @@ extern "C" bool Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env, NativeMessageReceived("recreateviews", ""); if (IsVRBuild()) { - EnterVR(firstStart); + EnterVR(firstStart, graphicsContext->GetAPIContext()); } return true; From e9cb37993fe36629ab8acdaf64c96e2f34a41d96 Mon Sep 17 00:00:00 2001 From: ANR2ME Date: Fri, 23 Sep 2022 20:12:16 +0700 Subject: [PATCH 003/374] Fix assertion issue when playing Cars over public adhoc server. --- Core/HLE/sceNetAdhoc.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceNetAdhoc.cpp b/Core/HLE/sceNetAdhoc.cpp index 5e5da07fd1..73fb8f3d13 100644 --- a/Core/HLE/sceNetAdhoc.cpp +++ b/Core/HLE/sceNetAdhoc.cpp @@ -5063,7 +5063,8 @@ static int sceNetAdhocMatchingStart(int matchingId, int evthPri, int evthStack, int retval = NetAdhocMatching_Start(matchingId, evthPri, USER_PARTITION_ID, evthStack, inthPri, USER_PARTITION_ID, inthStack, optLen, optDataAddr); // Give a little time to make sure matching Threads are ready before the game use the next sceNet functions, should've checked for status instead of guessing the time? - return hleDelayResult(retval, "give some time", adhocMatchingEventDelay); + hleEatMicro(adhocMatchingEventDelay); + return retval; } // With params for Partition ID for the event & input handler stack @@ -5074,7 +5075,8 @@ static int sceNetAdhocMatchingStart2(int matchingId, int evthPri, int evthPartit int retval = NetAdhocMatching_Start(matchingId, evthPri, evthPartitionId, evthStack, inthPri, inthPartitionId, inthStack, optLen, optDataAddr); // Give a little time to make sure matching Threads are ready before the game use the next sceNet functions, should've checked for status instead of guessing the time? - return hleDelayResult(retval, "give some time", adhocMatchingEventDelay); + hleEatMicro(adhocMatchingEventDelay); + return retval; } From 282505c70f1806b3b007126c6fdd0416b754d49c Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 25 Sep 2022 23:00:03 +0800 Subject: [PATCH 004/374] Trying to improve sceMpegAvcDecodeYCbCr Fix #11060 --- Core/HLE/sceMpeg.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 8aa429ba1d..9d829a9039 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -36,6 +36,8 @@ #include "GPU/GPUState.h" #include "Core/HLE/sceKernelMemory.h" #include "Core/Core.h" +#include "Core/System.h" +#include "Core/FileSystems/MetaFileSystem.h" // MPEG AVC elementary stream. static const int MPEG_AVC_ES_SIZE = 2048; // MPEG packet size. @@ -1361,8 +1363,15 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA // Flush structs back to memory avcAu.write(auAddr); - // Save the current frame's status to initAddr - Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr); + // Save the current frame's status to initAddr + PSPFileInfo fileInfo = pspFileSystem.GetFileInfo("disc0:\\PSP_GAME\\USRDIR\\module\\mpeg.prx"); + if (fileInfo.exists) { + Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr); + } + else { + // Sunday Vs Magazine Shuuketsu! Choujou Daikessen expcect, issue #11060 + Memory::Write_U32(1, initAddr); + } ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS; DEBUG_LOG(ME, "sceMpegAvcDecodeYCbCr(%08x, %08x, %08x, %08x)", mpeg, auAddr, bufferAddr, initAddr); From f37d0622e2dde1219c57795bb356a5aa0716dea6 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 27 Sep 2022 21:07:02 +0800 Subject: [PATCH 005/374] Change to mpegLibVersion --- Core/HLE/sceMpeg.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 9d829a9039..8fc374ec29 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1363,15 +1363,14 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA // Flush structs back to memory avcAu.write(auAddr); - // Save the current frame's status to initAddr - PSPFileInfo fileInfo = pspFileSystem.GetFileInfo("disc0:\\PSP_GAME\\USRDIR\\module\\mpeg.prx"); - if (fileInfo.exists) { - Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr); - } - else { - // Sunday Vs Magazine Shuuketsu! Choujou Daikessen expcect, issue #11060 + if (mpegLibVersion >= 0x010A) { + // Sunday Vs Magazine Shuuketsu! Choujou Daikessen expect, issue #11060 Memory::Write_U32(1, initAddr); } + else { + // Save the current frame's status to initAddr + Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr); + } ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS; DEBUG_LOG(ME, "sceMpegAvcDecodeYCbCr(%08x, %08x, %08x, %08x)", mpeg, auAddr, bufferAddr, initAddr); From 117ce25de0d5abdc1e1d44452b035863752ff2e4 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 27 Sep 2022 21:08:56 +0800 Subject: [PATCH 006/374] Forget remove unused include --- Core/HLE/sceMpeg.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 8fc374ec29..fa46628c54 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -36,8 +36,6 @@ #include "GPU/GPUState.h" #include "Core/HLE/sceKernelMemory.h" #include "Core/Core.h" -#include "Core/System.h" -#include "Core/FileSystems/MetaFileSystem.h" // MPEG AVC elementary stream. static const int MPEG_AVC_ES_SIZE = 2048; // MPEG packet size. From fec708489a9f15a7c08b4fb52eb3d3f20015be62 Mon Sep 17 00:00:00 2001 From: lainon Date: Fri, 30 Sep 2022 12:26:30 +0300 Subject: [PATCH 007/374] Correct cleaning string and remove unused vars --- Common/Data/Encoding/Compression.cpp | 1 - Common/File/Path.cpp | 1 - Common/GPU/D3D9/D3D9ShaderCompiler.cpp | 2 +- Common/GPU/ShaderTranslation.cpp | 2 +- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 4 ---- Core/Config.cpp | 8 ++++---- Core/Core.cpp | 6 +++--- Core/Debugger/DisassemblyManager.cpp | 8 ++++---- Core/Debugger/WebSocket/WebSocketUtils.cpp | 2 +- Core/Dialog/SavedataParam.cpp | 2 +- Core/FileSystems/ISOFileSystem.cpp | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 1 - Core/Loaders.cpp | 2 +- Core/MIPS/MIPSAsm.cpp | 2 +- Core/System.cpp | 2 +- Core/Util/GameManager.cpp | 2 +- Core/WebServer.cpp | 2 +- GPU/Common/PostShader.cpp | 4 ++-- GPU/Common/TextureCacheCommon.cpp | 2 -- UI/CwCheatScreen.cpp | 1 - UI/EmuScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- UI/Store.cpp | 2 +- UI/TextureUtil.cpp | 4 ++-- Windows/Debugger/CtrlDisAsmView.cpp | 2 +- Windows/Debugger/CtrlMemView.cpp | 2 +- Windows/InputBox.cpp | 4 ++-- Windows/MainWindowMenu.cpp | 2 +- Windows/main.cpp | 2 +- android/jni/TestRunner.cpp | 4 ++-- headless/Headless.cpp | 2 +- unittest/UnitTest.cpp | 2 +- 32 files changed, 38 insertions(+), 48 deletions(-) diff --git a/Common/Data/Encoding/Compression.cpp b/Common/Data/Encoding/Compression.cpp index 751a9595cf..3e2e499a18 100644 --- a/Common/Data/Encoding/Compression.cpp +++ b/Common/Data/Encoding/Compression.cpp @@ -95,7 +95,6 @@ bool decompress_string(const std::string& str, std::string *dest) { inflateEnd(&zs); if (ret != Z_STREAM_END) { // an error occurred that was not EOF - std::ostringstream oss; ERROR_LOG(IO, "Exception during zlib decompression: (%i) %s", ret, zs.msg); return false; } diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index ba3372e78a..dd01ac26a7 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -357,7 +357,6 @@ bool Path::ComputePathTo(const Path &other, std::string &path) const { return true; } - std::string diff; if (type_ == PathType::CONTENT_URI) { AndroidContentURI a(path_); AndroidContentURI b(other.path_); diff --git a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp index f41ea3911d..5a647196fe 100644 --- a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp +++ b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp @@ -47,7 +47,7 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std: pShaderCode = nullptr; } } else { - *errorMessage = ""; + (*errorMessage).clear(); } return pShaderCode; diff --git a/Common/GPU/ShaderTranslation.cpp b/Common/GPU/ShaderTranslation.cpp index 34de213451..84cd69afe5 100644 --- a/Common/GPU/ShaderTranslation.cpp +++ b/Common/GPU/ShaderTranslation.cpp @@ -233,7 +233,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan return false; #endif - *errorMessage = ""; + (*errorMessage).clear(); glslang::TProgram program; const char *shaderStrings[1]{}; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 428d66e2cc..3eee8f7ad7 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1348,7 +1348,6 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c int n = 0; int stage = 0; - VkImageMemoryBarrier barriers[2]{}; if (step.render.framebuffer->color.layout == VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { recordBarrier_.TransitionImage( step.render.framebuffer->color.image, @@ -1758,9 +1757,6 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { // The barrier code doesn't handle this case. We'd need to transition to GENERAL to do an intra-image copy. _dbg_assert_(step.blit.src != step.blit.dst); - VkImageMemoryBarrier srcBarriers[2]{}; - VkImageMemoryBarrier dstBarriers[2]{}; - VKRFramebuffer *src = step.blit.src; VKRFramebuffer *dst = step.blit.dst; diff --git a/Core/Config.cpp b/Core/Config.cpp index 45e396c9b7..248bcb2852 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1424,7 +1424,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { // build of PPSSPP, receive an upgrade notice, then start a newer version, and still receive the upgrade notice, // even if said newer version is >= the upgrade found online. if ((dismissedVersion == upgradeVersion) || (versionsValid && (installed >= upgrade))) { - upgradeMessage = ""; + upgradeMessage.clear(); } // Check for new version on every 10 runs. @@ -1636,16 +1636,16 @@ void Config::DownloadCompletedCallback(http::Download &download) { if (installed >= upgrade) { INFO_LOG(LOADER, "Version check: Already up to date, erasing any upgrade message"); - g_Config.upgradeMessage = ""; + g_Config.upgradeMessage.clear(); g_Config.upgradeVersion = upgrade.ToString(); - g_Config.dismissedVersion = ""; + g_Config.dismissedVersion.clear(); return; } if (installed < upgrade && dismissed != upgrade) { g_Config.upgradeMessage = "New version of PPSSPP available!"; g_Config.upgradeVersion = upgrade.ToString(); - g_Config.dismissedVersion = ""; + g_Config.dismissedVersion.clear(); } } diff --git a/Core/Core.cpp b/Core/Core.cpp index 52a1df8f4c..c1bb28cefd 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -447,7 +447,7 @@ void Core_MemoryException(u32 address, u32 pc, MemoryExceptionType type) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::MEMORY; - e.info = ""; + e.info.clear(); e.memory_type = type; e.address = address; e.pc = pc; @@ -483,7 +483,7 @@ void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::BAD_EXEC_ADDR; - e.info = ""; + e.info.clear(); e.exec_type = type; e.address = address; e.pc = pc; @@ -498,7 +498,7 @@ void Core_Break(u32 pc) { ExceptionInfo &e = g_exceptionInfo; e = {}; e.type = ExceptionType::BREAK; - e.info = ""; + e.info.clear(); e.pc = pc; if (!g_Config.bIgnoreBadMemAccess) { diff --git a/Core/Debugger/DisassemblyManager.cpp b/Core/Debugger/DisassemblyManager.cpp index 511aeee82a..ab0e10aa9b 100644 --- a/Core/Debugger/DisassemblyManager.cpp +++ b/Core/Debugger/DisassemblyManager.cpp @@ -316,7 +316,7 @@ void DisassemblyManager::getLine(u32 address, bool insertSymbols, DisassemblyLin dest.params = "Disassembly failure"; } else { dest.name = "-"; - dest.params = ""; + dest.params.clear(); } } @@ -1003,7 +1003,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = pos-1; inString = false; } @@ -1028,7 +1028,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = pos-1; inString = false; } @@ -1099,7 +1099,7 @@ void DisassemblyData::createLines() lines[currentLineStart] = entry; lineAddresses.push_back(currentLineStart); - currentLine = ""; + currentLine.clear(); currentLineStart = currentPos; } diff --git a/Core/Debugger/WebSocket/WebSocketUtils.cpp b/Core/Debugger/WebSocket/WebSocketUtils.cpp index cc49e33336..8d6be87b9e 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.cpp +++ b/Core/Debugger/WebSocket/WebSocketUtils.cpp @@ -262,7 +262,7 @@ bool DebuggerRequest::ParamString(const char *name, std::string *out, DebuggerPa return true; } else if (tag == JSON_NULL) { if (required) { - *out = ""; + (*out).clear(); } return true; } else if (tag == JSON_NUMBER) { diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 5a04ebc882..a4f437d40c 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -258,7 +258,7 @@ std::string SavedataParam::GetSaveFilePath(const SceUtilitySavedataParam *param, inline static std::string FixedToString(const char *str, size_t n) { if (!str) { - return std::string(""); + return std::string(); } else { return std::string(str, strnlen(str, n)); } diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index a873f3f19b..0d57bf2848 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -148,7 +148,7 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, BlockDevice *_blockDevic if (!blockDevice->ReadBlock(16, (u8*)&desc)) blockDevice->NotifyReadError(); - entireISO.name = ""; + entireISO.name.clear(); entireISO.isDirectory = false; entireISO.startingPosition = 0; entireISO.size = _blockDevice->GetNumBlocks(); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index dd41e95855..c3a339172d 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -81,7 +81,6 @@ void VirtualDiscFileSystem::LoadFileListIndex() { return; } - std::string buf; static const int MAX_LINE_SIZE = 2048; char linebuf[MAX_LINE_SIZE]{}; while (fgets(linebuf, MAX_LINE_SIZE, f)) { diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 09ac48f47f..02625a16c5 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -60,7 +60,7 @@ FileLoader *ConstructFileLoader(const Path &filename) { // TODO : improve, look in the file more IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) { - *errorString = ""; + (*errorString).clear(); if (fileLoader == nullptr) { *errorString = "Invalid fileLoader"; return IdentifiedFileType::ERROR_IDENTIFYING; diff --git a/Core/MIPS/MIPSAsm.cpp b/Core/MIPS/MIPSAsm.cpp index 97d34a4f18..f95d0d1fc0 100644 --- a/Core/MIPS/MIPSAsm.cpp +++ b/Core/MIPS/MIPSAsm.cpp @@ -79,7 +79,7 @@ bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address) g_symbolMap->GetLabels(args.labels); } - errorText = L""; + errorText.clear(); if (!runArmips(args)) { for (size_t i = 0; i < errors.size(); i++) diff --git a/Core/System.cpp b/Core/System.cpp index 9c7519edd6..7f96ffb7c5 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -426,7 +426,7 @@ bool PSP_InitStart(const CoreParameter &coreParam, std::string *error_string) { if (g_CoreParameter.graphicsContext == nullptr) { g_CoreParameter.graphicsContext = temp; } - g_CoreParameter.errorString = ""; + g_CoreParameter.errorString.clear(); pspIsIniting = true; PSP_SetLoading("Loading game..."); diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index b6f4ccbd65..e808f07b6c 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -674,7 +674,7 @@ bool GameManager::InstallRawISO(const Path &file, const std::string &originalNam void GameManager::ResetInstallError() { if (!installInProgress_) { - installError_ = ""; + installError_.clear(); } } diff --git a/Core/WebServer.cpp b/Core/WebServer.cpp index 3d6d9b37cb..4aff212eba 100644 --- a/Core/WebServer.cpp +++ b/Core/WebServer.cpp @@ -297,7 +297,7 @@ static void ForwardDebuggerRequest(const http::Request &request) { // Check if this is a websocket request... std::string upgrade; if (!request.GetHeader("upgrade", &upgrade)) { - upgrade = ""; + upgrade.clear(); } // Yes - proceed with the socket. diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index ed86397521..ad02d603b4 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -55,7 +55,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct off.name = "Off"; off.section = "Off"; for (size_t i = 0; i < ARRAY_SIZE(off.settings); ++i) { - off.settings[i].name = ""; + off.settings[i].name.clear(); off.settings[i].value = 0.0f; off.settings[i].minValue = -1.0f; off.settings[i].maxValue = 1.0f; @@ -174,7 +174,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct section.Get("UsePreviousFrame", &info.usePreviousFrame, false); if (info.parent == "Off") - info.parent = ""; + info.parent.clear(); for (size_t i = 0; i < ARRAY_SIZE(info.settings); ++i) { auto &setting = info.settings[i]; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 1b7d8d5986..d30a82d7b8 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -867,8 +867,6 @@ void TextureCacheCommon::NotifyFramebuffer(VirtualFramebuffer *framebuffer, Fram // Try to match the new framebuffer to existing textures. // Backwards from the "usual" texturing case so can't share a utility function. - std::vector candidates; - u64 cacheKey = (u64)fb_addr << 32; // If it has a clut, those are the low 32 bits, so it'll be inside this range. // Also, if it's a subsample of the buffer, it'll also be within the FBO. diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 8b4ba9d146..dee7a11166 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -199,7 +199,6 @@ UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) { WARN_LOG(COMMON, "CWCHEAT: Incorrect ID(%s) - can't import cheats.", gameID_.c_str()); return UI::EVENT_DONE; } - std::string line; std::vector title; std::vector newList; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 14ee1ced6c..7ed519f7c0 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1049,7 +1049,7 @@ void EmuScreen::update() { errLoadingFile.append(err->T(errorMessage_.c_str())); screenManager()->push(new PromptScreen(errLoadingFile, "OK", "")); - errorMessage_ = ""; + errorMessage_.clear(); quit_ = true; return; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0c1c0d009e..d58e23c704 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1488,7 +1488,7 @@ void GameSettingsScreen::TriggerRestart(const char *why) { std::string param = "--gamesettings"; if (editThenRestore_) { // We won't pass the gameID, so don't resume back into settings. - param = ""; + param.clear(); } else if (!gamePath_.empty()) { param += " \"" + ReplaceAll(ReplaceAll(gamePath_.ToString(), "\\", "\\\\"), "\"", "\\\"") + "\""; } diff --git a/UI/Store.cpp b/UI/Store.cpp index 8329ed22d9..86a084da95 100644 --- a/UI/Store.cpp +++ b/UI/Store.cpp @@ -502,7 +502,7 @@ void StoreScreen::CreateViews() { selectedItem->Press(); } else { - lastSelectedName_ = ""; + lastSelectedName_.clear(); } } root_->Add(content); diff --git a/UI/TextureUtil.cpp b/UI/TextureUtil.cpp index 9a5b377a90..80dfb59e1a 100644 --- a/UI/TextureUtil.cpp +++ b/UI/TextureUtil.cpp @@ -151,7 +151,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ size_t fileSize; uint8_t *buffer = VFSReadFile(filename.c_str(), &fileSize); if (!buffer) { - filename_ = ""; + filename_.clear(); ERROR_LOG(IO, "Failed to read file '%s'", filename.c_str()); return false; } @@ -159,7 +159,7 @@ bool ManagedTexture::LoadFromFile(const std::string &filename, ImageFileType typ if (retval) { filename_ = filename; } else { - filename_ = ""; + filename_.clear(); ERROR_LOG(IO, "Failed to load texture '%s'", filename.c_str()); } delete[] buffer; diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 5aca43fbcf..242fb60af5 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -191,7 +191,7 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) matchAddress = -1; searching = false; - searchQuery = ""; + searchQuery.clear(); windowStart = curAddress; whiteBackground = false; displaySymbols = true; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index c8f8a3f8df..e5af6aaa8d 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -49,7 +49,7 @@ CtrlMemView::CtrlMemView(HWND _wnd) curAddress = 0; debugger = 0; - searchQuery = ""; + searchQuery.clear(); matchAddress = -1; searching = false; diff --git a/Windows/InputBox.cpp b/Windows/InputBox.cpp index 1d4fd02e7e..632a8134fe 100644 --- a/Windows/InputBox.cpp +++ b/Windows/InputBox.cpp @@ -49,12 +49,12 @@ bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, con if (defaultValue.size() < 255) textBoxContents = ConvertUTF8ToWString(defaultValue); else - textBoxContents = L""; + textBoxContents.clear(); if (title != NULL) windowTitle = title; else - windowTitle = L""; + windowTitle.clear(); if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) { outvalue = ConvertWStringToUTF8(out); diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 6aba9d275a..384bb9a0f7 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -911,7 +911,7 @@ namespace MainWindow { if (lastSlash) { fn = lastSlash + 1; } else { - fn = ""; + fn.clear(); } PSPFileInfo info = pspFileSystem.GetFileInfo(filename); diff --git a/Windows/main.cpp b/Windows/main.cpp index e3888dfe4c..90e216f283 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -211,7 +211,7 @@ std::string System_GetProperty(SystemProperty prop) { if (wstr) retval = ConvertWStringToUTF8(wstr); else - retval = ""; + retval.clear(); GlobalUnlock(handle); CloseClipboard(); } diff --git a/android/jni/TestRunner.cpp b/android/jni/TestRunner.cpp index d032a9db75..64e6f7761c 100644 --- a/android/jni/TestRunner.cpp +++ b/android/jni/TestRunner.cpp @@ -107,7 +107,7 @@ bool RunTests() { // Never report from tests. std::string savedReportHost = g_Config.sReportHost; - g_Config.sReportHost = ""; + g_Config.sReportHost.clear(); for (size_t i = 0; i < ARRAY_SIZE(testsToRun); i++) { std::string testName = testsToRun[i]; @@ -116,7 +116,7 @@ bool RunTests() { INFO_LOG(SYSTEM, "Preparing to execute '%s'", testName.c_str()); std::string error_string; - output = ""; + output.clear(); if (!PSP_Init(coreParam, &error_string)) { ERROR_LOG(SYSTEM, "Failed to init unittest %s : %s", testsToRun[i], error_string.c_str()); PSP_CoreParameter().pixelWidth = pixel_xres; diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 1deebd95cd..dcfad07e8d 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -411,7 +411,7 @@ int main(int argc, const char* argv[]) g_Config.bFirstRun = false; g_Config.bIgnoreBadMemAccess = true; // Never report from tests. - g_Config.sReportHost = ""; + g_Config.sReportHost.clear(); g_Config.bAutoSaveSymbolMap = false; g_Config.iRenderingMode = FB_BUFFERED_MODE; g_Config.bHardwareTransform = true; diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 4f8239a11b..bb3d9d112b 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -634,7 +634,7 @@ static bool TestPath() { Path path3 = path2 / "foo/bar"; EXPECT_EQ_STR(path3.WithExtraExtension(".txt").ToString(), std::string("/asdf/jkl/foo/bar.txt")); - EXPECT_EQ_STR(Path("foo.bar/hello").GetFileExtension(), std::string("")); + EXPECT_EQ_STR(Path("foo.bar/hello").GetFileExtension(), std::string()); EXPECT_EQ_STR(Path("foo.bar/hello.txt").WithReplacedExtension(".txt", ".html").ToString(), std::string("foo.bar/hello.html")); EXPECT_EQ_STR(Path("C:\\Yo").NavigateUp().ToString(), std::string("C:")); From b304551747e391113c5fd2bea4e63713f995a3f6 Mon Sep 17 00:00:00 2001 From: lainon Date: Fri, 30 Sep 2022 12:31:32 +0300 Subject: [PATCH 008/374] Code readability, vec reserve() and remove excess c_str() --- Common/Data/Text/I18n.cpp | 2 +- Common/File/Path.cpp | 2 +- Common/GPU/OpenGL/thin3d_gl.cpp | 1 + Core/Debugger/WebSocket/WebSocketUtils.cpp | 2 +- Core/Dialog/PSPNetconfDialog.cpp | 12 ++++++------ Core/Dialog/PSPNpSigninDialog.cpp | 12 ++++++------ Core/Dialog/SavedataParam.cpp | 13 ++++++------- Core/ELF/ParamSFO.cpp | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 2 +- Core/HLE/proAdhoc.cpp | 3 ++- Core/HLE/sceNet.cpp | 2 +- Core/MIPS/MIPSAnalyst.cpp | 1 + GPU/GLES/ShaderManagerGLES.cpp | 2 ++ GPU/Software/DrawPixelX86.cpp | 1 + UI/ChatScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 4 ++-- UI/MemStickScreen.cpp | 2 +- UI/RemoteISOScreen.cpp | 2 +- UI/Theme.cpp | 2 +- Windows/Debugger/CtrlMemView.cpp | 2 ++ Windows/Debugger/Debugger_MemoryDlg.cpp | 2 +- Windows/W32Util/ShellUtil.cpp | 2 +- 22 files changed, 41 insertions(+), 34 deletions(-) diff --git a/Common/Data/Text/I18n.cpp b/Common/Data/Text/I18n.cpp index 0ede4c516d..00771fe119 100644 --- a/Common/Data/Text/I18n.cpp +++ b/Common/Data/Text/I18n.cpp @@ -39,7 +39,7 @@ const char *I18NCategory::T(const char *key, const char *def) { if (def) missedKeyLog_[key] = def; else - missedKeyLog_[key] = modifiedKey.c_str(); + missedKeyLog_[key] = modifiedKey; // INFO_LOG(SYSTEM, "Missed translation key in %s: %s", name_.c_str(), key); return def ? def : key; } diff --git a/Common/File/Path.cpp b/Common/File/Path.cpp index dd01ac26a7..39a31e164e 100644 --- a/Common/File/Path.cpp +++ b/Common/File/Path.cpp @@ -271,7 +271,7 @@ bool Path::CanNavigateUp() const { if (type_ == PathType::CONTENT_URI) { return AndroidContentURI(path_).CanNavigateUp(); } - if (path_ == "/" || path_ == "") { + if (path_ == "/" || path_.empty()) { return false; } if (type_ == PathType::HTTP) { diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 02decfe05c..3ecd1695c6 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -1203,6 +1203,7 @@ bool OpenGLPipeline::LinkShaders() { } std::vector semantics; + semantics.reserve(8); // Bind all the common vertex data points. Mismatching ones will be ignored. semantics.push_back({ SEM_POSITION, "Position" }); semantics.push_back({ SEM_COLOR0, "Color0" }); diff --git a/Core/Debugger/WebSocket/WebSocketUtils.cpp b/Core/Debugger/WebSocket/WebSocketUtils.cpp index 8d6be87b9e..be1a1371a9 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.cpp +++ b/Core/Debugger/WebSocket/WebSocketUtils.cpp @@ -216,7 +216,7 @@ bool DebuggerRequest::ParamBool(const char *name, bool *out, DebuggerParamType t *out = true; return true; } - if (s == "0" || s == "false" || (s == "" && allowLoose)) { + if (s == "0" || s == "false" || (s.empty() && allowLoose)) { *out = false; return true; } diff --git a/Core/Dialog/PSPNetconfDialog.cpp b/Core/Dialog/PSPNetconfDialog.cpp index 1e0535f301..079ff28358 100644 --- a/Core/Dialog/PSPNetconfDialog.cpp +++ b/Core/Dialog/PSPNetconfDialog.cpp @@ -194,21 +194,21 @@ void PSPNetconfDialog::DisplayMessage(std::string text1, std::string text2a, std PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2)); PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle); - if (text2a != "") { - if (text2b != "") + if (!text2a.empty()) { + if (!text2b.empty()) PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text2a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text2b != "") + if (!text2b.empty()) PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); - if (text3a != "") { - if (text3b != "") + if (!text3a.empty()) { + if (!text3b.empty()) PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text3a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text3b != "") + if (!text3b.empty()) PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); PPGeScissorReset(); diff --git a/Core/Dialog/PSPNpSigninDialog.cpp b/Core/Dialog/PSPNpSigninDialog.cpp index 3c015046db..48245c2008 100644 --- a/Core/Dialog/PSPNpSigninDialog.cpp +++ b/Core/Dialog/PSPNpSigninDialog.cpp @@ -191,21 +191,21 @@ void PSPNpSigninDialog::DisplayMessage(std::string text1, std::string text2a, st PPGeScissor(0, (int)(centerY - h2 - 2), 480, (int)(centerY + h2 + 2)); PPGeDrawTextWrapped(text1.c_str(), 240.0f, centerY - h2 - scrollPos_, WRAP_WIDTH, 0, messageStyle); - if (text2a != "") { - if (text2b != "") + if (!text2a.empty()) { + if (!text2b.empty()) PPGeDrawTextWrapped(text2a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text2a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text2b != "") + if (!text2b.empty()) PPGeDrawTextWrapped(text2b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); - if (text3a != "") { - if (text3b != "") + if (!text3a.empty()) { + if (!text3b.empty()) PPGeDrawTextWrapped(text3a.c_str(), 240.0f - 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleRight); else PPGeDrawTextWrapped(text3a.c_str(), 240.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyle); } - if (text3b != "") + if (!text3b.empty()) PPGeDrawTextWrapped(text3b.c_str(), 240.0f + 5.0f, centerY - h2 - scrollPos_ + totalHeight1 + totalHeight2 + marginTop, WRAP_WIDTH, 0, messageStyleLeft); PPGeScissorReset(); diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index a4f437d40c..67ef655ccf 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -353,11 +353,11 @@ int SavedataParam::DeleteData(SceUtilitySavedataParam* param) { if (!pspFileSystem.GetFileInfo(sfoPath).exists) return SCE_UTILITY_SAVEDATA_ERROR_RW_DATA_BROKEN; - if (fileName != "" && !pspFileSystem.GetFileInfo(filePath).exists) { + if (!fileName.empty() && !pspFileSystem.GetFileInfo(filePath).exists) { return SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND; } - if (fileName == "") { + if (fileName.empty()) { return 0; } @@ -533,7 +533,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD // copy back save name in request strncpy(param->saveName, saveDirName.c_str(), 20); - if (fileName == "") { + if (fileName.empty()) { delete[] cryptedData; } else { if (!WritePSPFile(filePath, data_, saveSize)) { @@ -583,13 +583,12 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); std::string fileName = GetFileName(param); std::string filePath = dirPath + "/" + fileName; - std::string sfoPath = dirPath + "/" + SFO_FILENAME; if (!pspFileSystem.GetFileInfo(dirPath).exists) { return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA : SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA; } - if (fileName != "" && !pspFileSystem.GetFileInfo(filePath).exists) { + if (!fileName.empty() && !pspFileSystem.GetFileInfo(filePath).exists) { return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND : SCE_UTILITY_SAVEDATA_ERROR_LOAD_FILE_NOT_FOUND; } @@ -637,7 +636,7 @@ int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::strin std::string filename = GetFileName(param); std::string filePath = dirPath + "/" + filename; // Blank filename always means success, if secureVersion was correct. - if (filename == "") + if (filename.empty()) return 0; s64 readSize; @@ -1576,7 +1575,7 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std:: saveInfo.idx = 0; saveInfo.modif_time = info.mtime; - std::string saveDir = savrDir == "" ? GetGameName(pspParam) + saveName : savrDir; + std::string saveDir = savrDir.empty() ? GetGameName(pspParam) + saveName : savrDir; saveInfo.saveDir = saveDir; // Start with a blank slate. diff --git a/Core/ELF/ParamSFO.cpp b/Core/ELF/ParamSFO.cpp index 71d07dcaca..a2c002f46e 100644 --- a/Core/ELF/ParamSFO.cpp +++ b/Core/ELF/ParamSFO.cpp @@ -283,7 +283,7 @@ std::string ParamSFOData::GenerateFakeID(std::string filename) { // Generates fake gameID for homebrew based on it's folder name. // Should probably not be a part of ParamSFO, but it'll be called in same places. std::string file = PSP_CoreParameter().fileToStart.ToString(); - if (filename != "") + if (!filename.empty()) file = filename; std::size_t lslash = file.find_last_of("/"); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index c3a339172d..9a9e0f8c8b 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -329,7 +329,7 @@ int VirtualDiscFileSystem::OpenFile(std::string filename, FileAccess access, con entry.size = 0; entry.startOffset = 0; - if (filename == "") + if (filename.empty()) { entry.type = VFILETYPE_ISO; entry.fileIndex = -1; diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index dcacbcc5bd..8959b337b2 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1325,7 +1325,7 @@ void sendChat(std::string chatString) { if (IsSocketReady((int)metasocket, false, true) > 0) { int chatResult = send((int)metasocket, (const char*)&chat, sizeof(chat), MSG_NOSIGNAL); NOTICE_LOG(SCENET, "Send Chat %s to Adhoc Server", chat.message); - std::string name = g_Config.sNickName.c_str(); + std::string name = g_Config.sNickName; std::lock_guard guard(chatLogLock); chatLog.push_back(name.substr(0, 8) + ": " + chat.message); @@ -1891,6 +1891,7 @@ uint32_t getLocalIp(int sock) { static std::vector> InitPrivateIPRanges() { struct sockaddr_in saNet {}, saMask{}; std::vector> ip_ranges; + ip_ranges.reserve(5); if (1 == inet_pton(AF_INET, "192.168.0.0", &(saNet.sin_addr)) && 1 == inet_pton(AF_INET, "255.255.0.0", &(saMask.sin_addr))) ip_ranges.push_back({saNet.sin_addr.s_addr, saMask.sin_addr.s_addr}); diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index c2a8987408..13b87f6b6b 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -691,7 +691,7 @@ static u32 sceWlanGetEtherAddr(u32 addrAddr) { addr[0] &= 0xfc; } else { // Read MAC Address from config - if (!ParseMacAddress(g_Config.sMACAddress.c_str(), addr)) { + if (!ParseMacAddress(g_Config.sMACAddress, addr)) { ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.sMACAddress.c_str()); Memory::Memset(addrAddr, 0, 6); } diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 2c4e11bea4..2b047a42b0 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -1420,6 +1420,7 @@ skip: std::vector GetOutputRegs(MIPSOpcode op) { std::vector vec; + vec.reserve(3); MIPSInfo info = MIPSGetInfo(op); if (info & OUT_RD) vec.push_back(MIPS_GET_RD(op)); if (info & OUT_RT) vec.push_back(MIPS_GET_RT(op)); diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index ccf15e9268..3a620a4d91 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -84,6 +84,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, std::vector semantics; + semantics.reserve(7); semantics.push_back({ ATTR_POSITION, "position" }); semantics.push_back({ ATTR_TEXCOORD, "texcoord" }); if (useHWTransform_) @@ -185,6 +186,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, availableUniforms = vs->GetUniformMask() | fs->GetUniformMask(); std::vector initialize; + initialize.reserve(7); initialize.push_back({ &u_tex, 0, TEX_SLOT_PSP_TEXTURE }); initialize.push_back({ &u_fbotex, 0, TEX_SLOT_SHADERBLEND_SRC }); initialize.push_back({ &u_testtex, 0, TEX_SLOT_ALPHATEST }); diff --git a/GPU/Software/DrawPixelX86.cpp b/GPU/Software/DrawPixelX86.cpp index 32e6aeb835..53f9c94279 100644 --- a/GPU/Software/DrawPixelX86.cpp +++ b/GPU/Software/DrawPixelX86.cpp @@ -1737,6 +1737,7 @@ bool PixelJitCache::Jit_ApplyLogicOp(const PixelFuncID &id, RegCache::Reg colorR } std::vector finishes; + finishes.reserve(11); FixupBranch skipTable = J(true); const u8 *tableValues[16]{}; diff --git a/UI/ChatScreen.cpp b/UI/ChatScreen.cpp index 01421ee733..3a12597d11 100644 --- a/UI/ChatScreen.cpp +++ b/UI/ChatScreen.cpp @@ -138,7 +138,7 @@ void ChatMenu::UpdateChat() { uint32_t textcolor = 0xFFFFFF; uint32_t infocolor = 0xFDD835; - std::string name = g_Config.sNickName.c_str(); + std::string name = g_Config.sNickName; std::string displayname = i.substr(0, i.find(':')); std::string chattext = i.substr(displayname.length()); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index d58e23c704..486d502d4d 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -256,7 +256,7 @@ void GameSettingsScreen::CreateViews() { root_->Add(settingInfo_); // Show it again if we recreated the view - if (oldSettingInfo_ != "") { + if (!oldSettingInfo_.empty()) { settingInfo_->Show(oldSettingInfo_, nullptr); } @@ -1222,7 +1222,7 @@ UI::EventReturn GameSettingsScreen::OnChangeMemStickDir(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnOpenMemStick(UI::EventParams &e) { - OpenDirectory(File::ResolvePath(g_Config.memStickDirectory.ToString().c_str()).c_str()); + OpenDirectory(File::ResolvePath(g_Config.memStickDirectory.ToString()).c_str()); return UI::EVENT_DONE; } diff --git a/UI/MemStickScreen.cpp b/UI/MemStickScreen.cpp index ba61ad193a..78c4cf24fd 100644 --- a/UI/MemStickScreen.cpp +++ b/UI/MemStickScreen.cpp @@ -259,7 +259,7 @@ void MemStickScreen::CreateViews() { privateString = StringFromFormat("%s (%s)", iz->T("Skip for now"), privateString.c_str()); } - leftColumn->Add(new RadioButton(&choice_, CHOICE_PRIVATE_DIRECTORY, privateString.c_str()))->OnClick.Handle(this, &MemStickScreen::OnChoiceClick); + leftColumn->Add(new RadioButton(&choice_, CHOICE_PRIVATE_DIRECTORY, privateString))->OnClick.Handle(this, &MemStickScreen::OnChoiceClick); if (choice_ == CHOICE_PRIVATE_DIRECTORY) { AddExplanation(leftColumn, (MemStickScreen::Choice)choice_); } diff --git a/UI/RemoteISOScreen.cpp b/UI/RemoteISOScreen.cpp index 4497f169db..7d60e507a4 100644 --- a/UI/RemoteISOScreen.cpp +++ b/UI/RemoteISOScreen.cpp @@ -176,7 +176,7 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort }; // Try last server first, if it is set - if (g_Config.iLastRemoteISOPort && g_Config.sLastRemoteISOServer != "") { + if (g_Config.iLastRemoteISOPort && !g_Config.sLastRemoteISOServer.empty()) { if (TryServer(g_Config.sLastRemoteISOServer.c_str(), g_Config.iLastRemoteISOPort)) { return true; } diff --git a/UI/Theme.cpp b/UI/Theme.cpp index 978eeb3d0b..464c4ab2db 100644 --- a/UI/Theme.cpp +++ b/UI/Theme.cpp @@ -139,7 +139,7 @@ static void LoadThemeInfo(const std::vector &directories) { std::string tmpPath; section.Get("UIAtlas", &tmpPath, ""); - if (tmpPath != "") { + if (!tmpPath.empty()) { tmpPath = (path / tmpPath).ToString(); File::FileInfo tmpInfo; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index e5af6aaa8d..220ad0a99e 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -768,6 +768,7 @@ std::vector CtrlMemView::searchString(const std::string &searchQuery) { std::vector> memoryAreas; memoryAreas.push_back(std::pair(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd())); + memoryAreas.reserve(3); // Ignore the video memory mirrors. memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); @@ -821,6 +822,7 @@ void CtrlMemView::search(bool continueSearch) } std::vector> memoryAreas; + memoryAreas.reserve(3); // Ignore the video memory mirrors. memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); diff --git a/Windows/Debugger/Debugger_MemoryDlg.cpp b/Windows/Debugger/Debugger_MemoryDlg.cpp index d5358ab1bc..d016afaafa 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.cpp +++ b/Windows/Debugger/Debugger_MemoryDlg.cpp @@ -195,7 +195,7 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (HIWORD(wParam)) { case BN_CLICKED: GetWindowText(searchBoxHdl, temp, 255); - std::vector results = memView->searchString(ConvertWStringToUTF8(temp).c_str()); + std::vector results = memView->searchString(ConvertWStringToUTF8(temp)); if (results.size() > 0){ searchBoxRedraw(results); } diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index c6d3a2bc49..151cd643ce 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -199,7 +199,7 @@ namespace W32Util switch (type_) { case DIR: filename_ = BrowseForFolder(parent_, title_.c_str()); - result_ = filename_ != ""; + result_ = !filename_.empty(); complete_ = true; break; From c953bf7fc7cfa30c175fb60cb46c2ac348f87cc9 Mon Sep 17 00:00:00 2001 From: lainon Date: Fri, 30 Sep 2022 12:32:49 +0300 Subject: [PATCH 009/374] Fixed bug and memleaks --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 1 + Core/HLE/proAdhoc.cpp | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 1 + GPU/Common/ShaderId.cpp | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 111cea1d2b..e45c148851 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1079,6 +1079,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char gDesc.fragmentShader = vkshader->Get(); } else { ERROR_LOG(G3D, "Bad stage"); + delete pipeline; return nullptr; } } diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 8959b337b2..5996197bda 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1929,7 +1929,7 @@ void getLocalMac(SceNetEtherAddr * addr){ mac[0] &= 0xfc; } else - if (!ParseMacAddress(g_Config.sMACAddress.c_str(), mac)) { + if (!ParseMacAddress(g_Config.sMACAddress, mac)) { ERROR_LOG(SCENET, "Error parsing mac address %s", g_Config.sMACAddress.c_str()); memset(&mac, 0, sizeof(mac)); } diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f97f2e91c0..8f74dd2103 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1958,6 +1958,7 @@ VirtualFramebuffer *FramebufferManagerCommon::FindDownloadTempBuffer(VirtualFram nvfb->fbo = draw_->CreateFramebuffer({ nvfb->bufferWidth, nvfb->bufferHeight, 1, 1, channel == RASTER_DEPTH ? true : false, name }); if (!nvfb->fbo) { ERROR_LOG(FRAMEBUF, "Error creating FBO! %d x %d", nvfb->renderWidth, nvfb->renderHeight); + delete nvfb; return nullptr; } bvfbs_.push_back(nvfb); diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index bb8dd54237..6849ba759e 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -227,7 +227,7 @@ std::string FragmentShaderDesc(const FShaderID &id) { case STENCIL_VALUE_INCR_4: desc << "StenIncr4 "; break; case STENCIL_VALUE_INCR_8: desc << "StenIncr8 "; break; case STENCIL_VALUE_DECR_4: desc << "StenDecr4 "; break; - case STENCIL_VALUE_DECR_8: desc << "StenDecr4 "; break; + case STENCIL_VALUE_DECR_8: desc << "StenDecr8 "; break; default: desc << "StenUnknown "; break; } } else if (id.Bit(FS_BIT_REPLACE_ALPHA_WITH_STENCIL_TYPE)) { From 3cdf72b68b92eca8585b91e9496b67e956c91ddc Mon Sep 17 00:00:00 2001 From: lainon Date: Fri, 30 Sep 2022 12:35:28 +0300 Subject: [PATCH 010/374] Better readability and optimization insertion into container by replacing 'insert' -> 'emplace', 'push_back' -> 'emplace_back' --- Common/Data/Format/IniFile.cpp | 4 ++-- Common/File/DirListing.cpp | 4 ++-- Common/GPU/OpenGL/GLFeatures.cpp | 4 ++-- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- Common/LogReporting.cpp | 2 +- Common/StringUtils.cpp | 6 ++--- Core/Debugger/SymbolMap.cpp | 32 +++++++++++++-------------- Core/HLE/proAdhoc.cpp | 2 +- Core/HLE/sceKernelMemory.cpp | 4 ++-- Core/HLE/sceKernelMutex.cpp | 2 +- Core/HLE/sceKernelThread.cpp | 2 +- Core/HW/Display.cpp | 2 +- Core/MIPS/JitCommon/JitBlockCache.cpp | 4 ++-- Core/MIPS/MIPSAnalyst.cpp | 2 +- GPU/Common/PostShader.cpp | 2 +- GPU/Debugger/Breakpoints.cpp | 2 +- GPU/Debugger/Debugger.cpp | 6 ++--- GPU/GLES/ShaderManagerGLES.cpp | 2 +- Windows/Debugger/CtrlMemView.cpp | 12 +++++----- Windows/W32Util/ShellUtil.cpp | 2 +- 20 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Common/Data/Format/IniFile.cpp b/Common/Data/Format/IniFile.cpp index 32fcf43b68..cd2a658e5c 100644 --- a/Common/Data/Format/IniFile.cpp +++ b/Common/Data/Format/IniFile.cpp @@ -206,7 +206,7 @@ void Section::Set(const char* key, const char* newValue) else { // The key did not already exist in this section - let's add it. - lines.push_back(std::string(key) + " = " + EscapeComments(newValue)); + lines.emplace_back(std::string(key) + " = " + EscapeComments(newValue)); } } @@ -272,7 +272,7 @@ void Section::Set(const char* key, const std::vector& newValues) } void Section::AddComment(const std::string &comment) { - lines.push_back("# " + comment); + lines.emplace_back("# " + comment); } bool Section::Get(const char* key, std::vector& values) diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index abe5ff3af8..2f7178847b 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -148,7 +148,7 @@ std::vector ApplyFilter(std::vector files, const std::string tmp; while (*filter) { if (*filter == ':') { - filters.insert("." + tmp); + filters.emplace("." + tmp); tmp.clear(); } else { tmp.push_back(*filter); @@ -156,7 +156,7 @@ std::vector ApplyFilter(std::vector files, const filter++; } if (!tmp.empty()) - filters.insert("." + tmp); + filters.emplace("." + tmp); } auto pred = [&](const File::FileInfo &info) { diff --git a/Common/GPU/OpenGL/GLFeatures.cpp b/Common/GPU/OpenGL/GLFeatures.cpp index bf9a639e67..aa79ac5941 100644 --- a/Common/GPU/OpenGL/GLFeatures.cpp +++ b/Common/GPU/OpenGL/GLFeatures.cpp @@ -51,7 +51,7 @@ static void ParseExtensionsString(const std::string& str, std::set size_t next = 0; for (size_t pos = 0, len = str.length(); pos < len; ++pos) { if (str[pos] == ' ') { - output.insert(str.substr(next, pos - next)); + output.emplace(str.substr(next, pos - next)); // Skip the delimiter itself. next = pos + 1; } @@ -60,7 +60,7 @@ static void ParseExtensionsString(const std::string& str, std::set if (next == 0 && str.length() != 0) { output.insert(str); } else if (next < str.length()) { - output.insert(str.substr(next)); + output.emplace(str.substr(next)); } } diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index e45c148851..4fddf1252e 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1432,7 +1432,7 @@ std::vector VKContext::GetFeatureList() const { AddFeature(features, "occlusionQueryPrecise", available.occlusionQueryPrecise, enabled.occlusionQueryPrecise); AddFeature(features, "multiDrawIndirect", available.multiDrawIndirect, enabled.multiDrawIndirect); - features.push_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat)); + features.emplace_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat)); return features; } diff --git a/Common/LogReporting.cpp b/Common/LogReporting.cpp index 2189b1c7e2..0fcc78d0ad 100644 --- a/Common/LogReporting.cpp +++ b/Common/LogReporting.cpp @@ -35,7 +35,7 @@ bool ShouldLogNTimes(const char *identifier, int count) { std::lock_guard lock(logNTimesLock); auto iter = logNTimes.find(identifier); if (iter == logNTimes.end()) { - logNTimes.insert(std::pair(identifier, 1)); + logNTimes.emplace(identifier, 1); return true; } else { if (iter->second >= count) { diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index f88f6194ab..3a9e29c61a 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -273,7 +273,7 @@ void SplitString(const std::string& str, const char delim, std::vector& output) if (str[pos] == '\"' || str[pos] == '\'') { if (even) { //quoted text - output.push_back(str.substr(next, pos - next)); + output.emplace_back(str.substr(next, pos - next)); even = 0; } else { //non quoted text diff --git a/Core/Debugger/SymbolMap.cpp b/Core/Debugger/SymbolMap.cpp index e276e9be27..b215a92ab4 100644 --- a/Core/Debugger/SymbolMap.cpp +++ b/Core/Debugger/SymbolMap.cpp @@ -439,7 +439,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) { // Just reactivate that one. it->start = address; it->size = size; - activeModuleEnds.insert(std::make_pair(it->start + it->size, *it)); + activeModuleEnds.emplace(it->start + it->size, *it); activeNeedUpdate_ = true; return; } @@ -452,7 +452,7 @@ void SymbolMap::AddModule(const char *name, u32 address, u32 size) { mod.index = (int)modules.size() + 1; modules.push_back(mod); - activeModuleEnds.insert(std::make_pair(mod.start + mod.size, mod)); + activeModuleEnds.emplace(mod.start + mod.size, mod); activeNeedUpdate_ = true; } @@ -559,7 +559,7 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI auto active = activeFunctions.find(address); if (active != activeFunctions.end() && active->second.module == moduleIndex) { activeFunctions.erase(active); - activeFunctions.insert(std::make_pair(address, existing->second)); + activeFunctions.emplace(address, existing->second); } } else { FunctionEntry func; @@ -570,7 +570,7 @@ void SymbolMap::AddFunction(const char* name, u32 address, u32 size, int moduleI functions[symbolKey] = func; if (IsModuleActive(moduleIndex)) { - activeFunctions.insert(std::make_pair(address, func)); + activeFunctions.emplace(address, func); } } @@ -716,27 +716,27 @@ void SymbolMap::UpdateActiveSymbols() { for (auto it = functions.begin(), end = functions.end(); it != end; ++it) { const auto mod = activeModuleIndexes.find(it->second.module); if (it->second.module == 0) { - activeFunctions.insert(std::make_pair(it->second.start, it->second)); + activeFunctions.emplace(it->second.start, it->second); } else if (mod != activeModuleIndexes.end()) { - activeFunctions.insert(std::make_pair(mod->second + it->second.start, it->second)); + activeFunctions.emplace(mod->second + it->second.start, it->second); } } for (auto it = labels.begin(), end = labels.end(); it != end; ++it) { const auto mod = activeModuleIndexes.find(it->second.module); if (it->second.module == 0) { - activeLabels.insert(std::make_pair(it->second.addr, it->second)); + activeLabels.emplace(it->second.addr, it->second); } else if (mod != activeModuleIndexes.end()) { - activeLabels.insert(std::make_pair(mod->second + it->second.addr, it->second)); + activeLabels.emplace(mod->second + it->second.addr, it->second); } } for (auto it = data.begin(), end = data.end(); it != end; ++it) { const auto mod = activeModuleIndexes.find(it->second.module); if (it->second.module == 0) { - activeData.insert(std::make_pair(it->second.start, it->second)); + activeData.emplace(it->second.start, it->second); } else if (mod != activeModuleIndexes.end()) { - activeData.insert(std::make_pair(mod->second + it->second.start, it->second)); + activeData.emplace(mod->second + it->second.start, it->second); } } @@ -757,7 +757,7 @@ bool SymbolMap::SetFunctionSize(u32 startAddress, u32 newSize) { if (func != functions.end()) { func->second.size = newSize; activeFunctions.erase(funcInfo); - activeFunctions.insert(std::make_pair(startAddress, func->second)); + activeFunctions.emplace(startAddress, func->second); } } @@ -829,7 +829,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) { auto active = activeLabels.find(address); if (active != activeLabels.end() && active->second.module == moduleIndex) { activeLabels.erase(active); - activeLabels.insert(std::make_pair(address, label)); + activeLabels.emplace(address, label); } } } else { @@ -840,7 +840,7 @@ void SymbolMap::AddLabel(const char* name, u32 address, int moduleIndex) { labels[symbolKey] = label; if (IsModuleActive(moduleIndex)) { - activeLabels.insert(std::make_pair(address, label)); + activeLabels.emplace(address, label); } } } @@ -864,7 +864,7 @@ void SymbolMap::SetLabelName(const char* name, u32 address) { auto active = activeLabels.find(address); if (active != activeLabels.end() && active->second.module == label->second.module) { activeLabels.erase(active); - activeLabels.insert(std::make_pair(address, label->second)); + activeLabels.emplace(address, label->second); } } } @@ -947,7 +947,7 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) { auto active = activeData.find(address); if (active != activeData.end() && active->second.module == moduleIndex) { activeData.erase(active); - activeData.insert(std::make_pair(address, existing->second)); + activeData.emplace(address, existing->second); } } else { DataEntry entry; @@ -958,7 +958,7 @@ void SymbolMap::AddData(u32 address, u32 size, DataType type, int moduleIndex) { data[symbolKey] = entry; if (IsModuleActive(moduleIndex)) { - activeData.insert(std::make_pair(address, entry)); + activeData.emplace(address, entry); } } } diff --git a/Core/HLE/proAdhoc.cpp b/Core/HLE/proAdhoc.cpp index 5996197bda..dfcc535df0 100644 --- a/Core/HLE/proAdhoc.cpp +++ b/Core/HLE/proAdhoc.cpp @@ -1328,7 +1328,7 @@ void sendChat(std::string chatString) { std::string name = g_Config.sNickName; std::lock_guard guard(chatLogLock); - chatLog.push_back(name.substr(0, 8) + ": " + chat.message); + chatLog.emplace_back(name.substr(0, 8) + ": " + chat.message); chatMessageGeneration++; } } diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 318cae7d0c..55b7ff7044 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2007,7 +2007,7 @@ int __KernelFreeTls(TLSPL *tls, SceUID threadID) __KernelResumeThreadFromWait(waitingThreadID, freedAddress); // Gotta watch the thread to quit as well, since they've allocated now. - tlsplThreadEndChecks.insert(std::make_pair(waitingThreadID, uid)); + tlsplThreadEndChecks.emplace(waitingThreadID, uid); // No need to continue or free it, we're done. return 0; @@ -2234,7 +2234,7 @@ int sceKernelGetTlsAddr(SceUID uid) { if (allocBlock != -1) { tls->usage[allocBlock] = threadID; - tlsplThreadEndChecks.insert(std::make_pair(threadID, uid)); + tlsplThreadEndChecks.emplace(threadID, uid); --tls->ntls.freeBlocks; needsClear = true; } diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 2cba7b5ca5..6921ffdf26 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -213,7 +213,7 @@ static void __KernelMutexAcquireLock(PSPMutex *mutex, int count, SceUID thread) _dbg_assert_msg_((*iter).second != mutex->GetUID(), "Thread %d / mutex %d wasn't removed from mutexHeldLocks properly.", thread, mutex->GetUID()); #endif - mutexHeldLocks.insert(std::make_pair(thread, mutex->GetUID())); + mutexHeldLocks.emplace(thread, mutex->GetUID()); mutex->nm.lockLevel = count; mutex->nm.lockThread = thread; diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index ea9caaba1e..f717cd5a3e 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -230,7 +230,7 @@ public: MipsCallManager() : idGen_(0) {} u32 add(MipsCall *call) { u32 id = genId(); - calls_.insert(std::pair(id, call)); + calls_.emplace(id, call); return id; } MipsCall *get(u32 id) { diff --git a/Core/HW/Display.cpp b/Core/HW/Display.cpp index ebabb647d0..1dcb51e18c 100644 --- a/Core/HW/Display.cpp +++ b/Core/HW/Display.cpp @@ -265,7 +265,7 @@ void __DisplayListenVblank(VblankCallback callback) { void __DisplayListenFlip(FlipCallback callback, void *userdata) { std::lock_guard guard(listenersLock); - flipListeners.push_back(std::make_pair(callback, userdata)); + flipListeners.emplace_back(callback, userdata); } void __DisplayForgetFlip(FlipCallback callback, void *userdata) { diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index b85b336fcd..f5b11ca4a5 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -198,7 +198,7 @@ void JitBlockCache::ProxyBlock(u32 rootAddress, u32 startAddress, u32 size, cons // Make binary searches and stuff work ok b.normalEntry = codePtr; b.checkedEntry = codePtr; - proxyBlockMap_.insert(std::make_pair(startAddress, num_blocks_)); + proxyBlockMap_.emplace(startAddress, num_blocks_); AddBlockMap(num_blocks_); num_blocks_++; //commit the current block @@ -253,7 +253,7 @@ void JitBlockCache::FinalizeBlock(int block_num, bool block_link) { if (block_link) { for (int i = 0; i < MAX_JIT_BLOCK_EXITS; i++) { if (b.exitAddress[i] != INVALID_EXIT) { - links_to_.insert(std::make_pair(b.exitAddress[i], block_num)); + links_to_.emplace(b.exitAddress[i], block_num); } } diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 2b047a42b0..81f87da663 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -771,7 +771,7 @@ namespace MIPSAnalyst { for (auto iter = functions.begin(); iter != functions.end(); iter++) { AnalyzedFunction &f = *iter; if (f.hasHash && f.size > 16) { - hashToFunction.insert(std::make_pair(f.hash, &f)); + hashToFunction.emplace(f.hash, &f); } } } diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index ad02d603b4..2d8529f356 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -187,7 +187,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct // Populate the default setting value. std::string section = StringFromFormat("%sSettingValue%d", info.section.c_str(), i + 1); if (!setting.name.empty() && g_Config.mPostShaderSetting.find(section) == g_Config.mPostShaderSetting.end()) { - g_Config.mPostShaderSetting.insert(std::pair(section, setting.value)); + g_Config.mPostShaderSetting.emplace(section, setting.value); } } diff --git a/GPU/Debugger/Breakpoints.cpp b/GPU/Debugger/Breakpoints.cpp index 97fbca57ee..6da92e41ae 100644 --- a/GPU/Debugger/Breakpoints.cpp +++ b/GPU/Debugger/Breakpoints.cpp @@ -339,7 +339,7 @@ void AddAddressBreakpoint(u32 addr, bool temp) { } else { // Remove the temporary marking. breakPCsTemp.erase(addr); - breakPCs.insert(std::make_pair(addr, BreakpointInfo{})); + breakPCs.emplace(addr, BreakpointInfo{}); } breakPCsCount = breakPCs.size(); diff --git a/GPU/Debugger/Debugger.cpp b/GPU/Debugger/Debugger.cpp index b505521631..fa55ec6b8e 100644 --- a/GPU/Debugger/Debugger.cpp +++ b/GPU/Debugger/Debugger.cpp @@ -219,9 +219,9 @@ bool SetRestrictPrims(const char *rule) { // If there's nothing yet, add everything else. if (updated.empty()) { if (range.first > 0) - updated.push_back(std::make_pair(0, range.first - 1)); + updated.emplace_back(0, range.first - 1); if (range.second < MAX_PRIMS) - updated.push_back(std::make_pair(range.second + 1, MAX_PRIMS)); + updated.emplace_back(range.second + 1, MAX_PRIMS); continue; } @@ -240,7 +240,7 @@ bool SetRestrictPrims(const char *rule) { // We're slicing a hole in this subrange. int next = sub.second; sub.second = range.first - 1; - updated.push_back(std::make_pair(range.second + 1, next)); + updated.emplace_back(range.second + 1, next); continue; } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 3a620a4d91..6868b5d988 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -995,7 +995,7 @@ void ShaderManagerGLES::Load(const Path &filename) { if (!f.ReadArray(&fsid, 1)) { return; } - diskCachePending_.link.push_back(std::make_pair(vsid, fsid)); + diskCachePending_.link.emplace_back(vsid, fsid); } // Actual compilation happens in ContinuePrecompile(), called by GPU_GLES's IsReady. diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index 220ad0a99e..d40bdaf483 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -767,11 +767,11 @@ std::vector CtrlMemView::searchString(const std::string &searchQuery) { return searchResAddrs; std::vector> memoryAreas; - memoryAreas.push_back(std::pair(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd())); memoryAreas.reserve(3); + memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd()); // Ignore the video memory mirrors. - memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); - memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); + memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000); + memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd()); for (const auto &area : memoryAreas) { const u32 segmentStart = area.first; @@ -824,9 +824,9 @@ void CtrlMemView::search(bool continueSearch) std::vector> memoryAreas; memoryAreas.reserve(3); // Ignore the video memory mirrors. - memoryAreas.push_back(std::pair(PSP_GetVidMemBase(), 0x04200000)); - memoryAreas.push_back(std::pair(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd())); - memoryAreas.push_back(std::pair(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd())); + memoryAreas.emplace_back(PSP_GetVidMemBase(), 0x04200000); + memoryAreas.emplace_back(PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd()); + memoryAreas.emplace_back(PSP_GetScratchpadMemoryBase(), PSP_GetScratchpadMemoryEnd()); searching = true; redraw(); // so the cursor is disabled diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index 151cd643ce..bd53935d27 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -144,7 +144,7 @@ namespace W32Util files.push_back(directory); } else { while (*temp) { - files.push_back(directory + "\\" + ConvertWStringToUTF8(temp)); + files.emplace_back(directory + "\\" + ConvertWStringToUTF8(temp)); temp += wcslen(temp) + 1; } } From 878a049f602d95fb287bd00586481b37f5c4cb3c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Oct 2022 19:22:16 -0700 Subject: [PATCH 011/374] GPU: Add dirtying for geo shader state. Not yet used, but dirtied at the right times. --- GPU/Common/ShaderCommon.h | 3 ++- GPU/GPUCommon.cpp | 20 ++++++++++---------- GPU/GPUCommon.h | 4 ++-- GPU/Vulkan/DrawEngineVulkan.cpp | 4 ++-- GPU/Vulkan/ShaderManagerVulkan.cpp | 8 ++++---- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/GPU/Common/ShaderCommon.h b/GPU/Common/ShaderCommon.h index d6dfbbc3f8..63e3116014 100644 --- a/GPU/Common/ShaderCommon.h +++ b/GPU/Common/ShaderCommon.h @@ -109,10 +109,11 @@ enum : uint64_t { DIRTY_VIEWPORTSCISSOR_STATE = 1ULL << 46, DIRTY_VERTEXSHADER_STATE = 1ULL << 47, DIRTY_FRAGMENTSHADER_STATE = 1ULL << 48, + DIRTY_GEOMETRYSHADER_STATE = 1ULL << 49, // Everything that's not uniforms. Use this after using thin3d. // TODO: Should we also add DIRTY_FRAMEBUF here? It kinda generally takes care of itself. - DIRTY_ALL_RENDER_STATE = DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS, + DIRTY_ALL_RENDER_STATE = DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS, // Note that the top 8 bits (54-63) cannot be dirtied through the commonCommandTable due to packing of other flags. diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 2ebdf3ab05..a44fb47572 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -87,8 +87,8 @@ const CommonCommandTableEntry commonCommandTable[] = { { GE_CMD_FOG2, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOEF }, // These affect the fragment shader so need flushing. - { GE_CMD_CLEARMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_CULLRANGE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE }, - { GE_CMD_TEXTUREMAPENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE }, + { GE_CMD_CLEARMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_CULLRANGE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE }, + { GE_CMD_TEXTUREMAPENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE }, { GE_CMD_FOGENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAGMENTSHADER_STATE }, { GE_CMD_TEXMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS | DIRTY_FRAGMENTSHADER_STATE }, { GE_CMD_TEXSHADELS, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE }, @@ -102,7 +102,7 @@ const CommonCommandTableEntry commonCommandTable[] = { // These change the vertex shader so need flushing. { GE_CMD_REVERSENORMAL, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE }, - { GE_CMD_LIGHTINGENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE }, + { GE_CMD_LIGHTINGENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE }, { GE_CMD_LIGHTENABLE0, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE }, { GE_CMD_LIGHTENABLE1, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE }, { GE_CMD_LIGHTENABLE2, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE }, @@ -114,7 +114,7 @@ const CommonCommandTableEntry commonCommandTable[] = { { GE_CMD_MATERIALUPDATE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE }, // These change both shaders so need flushing. - { GE_CMD_LIGHTMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE }, + { GE_CMD_LIGHTMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE }, { GE_CMD_TEXFILTER, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS }, { GE_CMD_TEXWRAP, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS | DIRTY_FRAGMENTSHADER_STATE }, @@ -1683,7 +1683,7 @@ void GPUCommon::Execute_VertexType(u32 op, u32 diff) { if (diff & (GE_VTYPE_TC_MASK | GE_VTYPE_THROUGH_MASK)) { gstate_c.Dirty(DIRTY_UVSCALEOFFSET); if (diff & GE_VTYPE_THROUGH_MASK) - gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_CULLRANGE); + gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_CULLRANGE); } } @@ -1710,7 +1710,7 @@ void GPUCommon::Execute_VertexTypeSkinning(u32 op, u32 diff) { gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); } if (diff & GE_VTYPE_THROUGH_MASK) - gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_CULLRANGE); + gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_CULLRANGE); } void GPUCommon::CheckDepthUsage(VirtualFramebuffer *vfb) { @@ -2044,8 +2044,8 @@ void GPUCommon::Execute_Bezier(u32 op, u32 diff) { SetDrawType(DRAW_BEZIER, PatchPrimToPrim(surface.primType)); + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); if (drawEngineCommon_->CanUseHardwareTessellation(surface.primType)) { - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); gstate_c.submitType = SubmitType::HW_BEZIER; if (gstate_c.spline_num_points_u != surface.num_points_u) { gstate_c.Dirty(DIRTY_BEZIERSPLINE); @@ -2059,7 +2059,7 @@ void GPUCommon::Execute_Bezier(u32 op, u32 diff) { UpdateUVScaleOffset(); drawEngineCommon_->SubmitCurve(control_points, indices, surface, gstate.vertType, &bytesRead, "bezier"); - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); gstate_c.submitType = SubmitType::DRAW; // After drawing, we advance pointers - see SubmitPrim which does the same. @@ -2119,8 +2119,8 @@ void GPUCommon::Execute_Spline(u32 op, u32 diff) { SetDrawType(DRAW_SPLINE, PatchPrimToPrim(surface.primType)); + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); if (drawEngineCommon_->CanUseHardwareTessellation(surface.primType)) { - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); gstate_c.submitType = SubmitType::HW_SPLINE; if (gstate_c.spline_num_points_u != surface.num_points_u) { gstate_c.Dirty(DIRTY_BEZIERSPLINE); @@ -2134,7 +2134,7 @@ void GPUCommon::Execute_Spline(u32 op, u32 diff) { UpdateUVScaleOffset(); drawEngineCommon_->SubmitCurve(control_points, indices, surface, gstate.vertType, &bytesRead, "spline"); - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE); + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); gstate_c.submitType = SubmitType::DRAW; // After drawing, we advance pointers - see SubmitPrim which does the same. diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 1b4eb0494d..78f7b15cef 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -269,14 +269,14 @@ protected: void SetDrawType(DrawType type, GEPrimitiveType prim) { if (type != lastDraw_) { // We always flush when drawing splines/beziers so no need to do so here - gstate_c.Dirty(DIRTY_UVSCALEOFFSET | DIRTY_VERTEXSHADER_STATE); + gstate_c.Dirty(DIRTY_UVSCALEOFFSET | DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); lastDraw_ = type; } // Prim == RECTANGLES can cause CanUseHardwareTransform to flip, so we need to dirty. // Also, culling may be affected so dirty the raster state. if (IsTrianglePrim(prim) != IsTrianglePrim(lastPrim_)) { Flush(); - gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VERTEXSHADER_STATE); + gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); lastPrim_ = prim; } } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index d086b60921..703ada14b4 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -770,7 +770,7 @@ void DrawEngineVulkan::DoFlush() { sampler = nullSampler_; } - if (!lastPipeline_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE) || prim != lastPrim_) { + if (!lastPipeline_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE) || prim != lastPrim_) { if (prim != lastPrim_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE)) { ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey_, dynState_); } @@ -901,7 +901,7 @@ void DrawEngineVulkan::DoFlush() { if (sampler == VK_NULL_HANDLE) sampler = nullSampler_; } - if (!lastPipeline_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE) || prim != lastPrim_) { + if (!lastPipeline_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE) || prim != lastPrim_) { if (prim != lastPrim_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE)) { ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey_, dynState_); } diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 6c39280a82..7633159154 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -128,7 +128,7 @@ std::string VulkanFragmentShader::GetShaderString(DebugShaderStringType type) co VulkanVertexShader::VulkanVertexShader(VulkanContext *vulkan, VShaderID id, const char *code, bool useHWTransform) : vulkan_(vulkan), useHWTransform_(useHWTransform), id_(id) { source_ = code; - module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_VERTEX_BIT, source_.c_str(), new std::string(VertexShaderDesc(id).c_str())); + module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_VERTEX_BIT, source_.c_str(), new std::string(VertexShaderDesc(id))); if (!module_) { failed_ = true; } else { @@ -195,13 +195,13 @@ void ShaderManagerVulkan::Clear() { vsCache_.Clear(); lastFSID_.set_invalid(); lastVSID_.set_invalid(); - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE); + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); } void ShaderManagerVulkan::ClearShaders() { Clear(); DirtyShader(); - gstate_c.Dirty(DIRTY_ALL_UNIFORMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE); + gstate_c.Dirty(DIRTY_ALL_UNIFORMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); } void ShaderManagerVulkan::DirtyShader() { @@ -214,7 +214,7 @@ void ShaderManagerVulkan::DirtyShader() { void ShaderManagerVulkan::DirtyLastShader() { lastVShader_ = nullptr; lastFShader_ = nullptr; - gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE); + gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); } uint64_t ShaderManagerVulkan::UpdateUniforms(bool useBufferedRendering) { From 38e16324f0014549f148fd13102ff9f7d0d64ffb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Oct 2022 14:57:00 -0700 Subject: [PATCH 012/374] Vulkan: Clean up shader module tag. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- GPU/Vulkan/ShaderManagerVulkan.cpp | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 35d620be3c..413057b288 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -177,9 +177,9 @@ VkShaderStageFlagBits StageToVulkan(ShaderStage stage) { case ShaderStage::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; case ShaderStage::Geometry: return VK_SHADER_STAGE_GEOMETRY_BIT; case ShaderStage::Compute: return VK_SHADER_STAGE_COMPUTE_BIT; - default: case ShaderStage::Fragment: return VK_SHADER_STAGE_FRAGMENT_BIT; } + return VK_SHADER_STAGE_FRAGMENT_BIT; } // Not registering this as a resource holder, instead the pipeline is registered. It will diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 7633159154..bfb5547b6a 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -73,14 +73,22 @@ static Promise *CompileShaderModuleAsync(VulkanContext *vulkan, VkShaderModule shaderModule = VK_NULL_HANDLE; if (success) { - success = vulkan->CreateShaderModule(spirv, &shaderModule, stage == VK_SHADER_STAGE_VERTEX_BIT ? "game_vertex" : "game_fragment"); + const char *createTag = tag ? tag->c_str() : nullptr; + if (!createTag) { + switch (stage) { + case VK_SHADER_STAGE_VERTEX_BIT: createTag = "game_vertex"; break; + case VK_SHADER_STAGE_FRAGMENT_BIT: createTag = "game_fragment"; break; + case VK_SHADER_STAGE_GEOMETRY_BIT: createTag = "game_geometry"; break; + case VK_SHADER_STAGE_COMPUTE_BIT: createTag = "game_compute"; break; + } + } + + success = vulkan->CreateShaderModule(spirv, &shaderModule, createTag); #ifdef SHADERLOG OutputDebugStringA("OK"); #endif - if (tag) { - vulkan->SetDebugName(shaderModule, VK_OBJECT_TYPE_SHADER_MODULE, tag->c_str()); + if (tag) delete tag; - } } return shaderModule; From d16caa71af444ee089a9ac74ce76fa3176eb3867 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Oct 2022 20:01:23 -0700 Subject: [PATCH 013/374] Vulkan: Add geometry shader ID tracking. We're still not generating them, yet. But this tracks the objects and IDs through the pipeline. --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 11 ++- Common/GPU/Vulkan/VulkanRenderManager.h | 1 + GPU/Common/ShaderId.cpp | 39 ++++++++++ GPU/Common/ShaderId.h | 39 ++++++++++ GPU/GPUState.h | 3 +- GPU/Vulkan/DrawEngineVulkan.cpp | 13 ++-- GPU/Vulkan/DrawEngineVulkan.h | 4 +- GPU/Vulkan/GPU_Vulkan.cpp | 1 + GPU/Vulkan/PipelineManagerVulkan.cpp | 21 +++-- GPU/Vulkan/PipelineManagerVulkan.h | 4 +- GPU/Vulkan/ShaderManagerVulkan.cpp | 95 +++++++++++++++++++++-- GPU/Vulkan/ShaderManagerVulkan.h | 32 +++++++- UI/DevScreens.cpp | 2 +- 13 files changed, 241 insertions(+), 24 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 4e047bf64e..344b059bbc 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -30,8 +30,9 @@ bool VKRGraphicsPipeline::Create(VulkanContext *vulkan, VkRenderPass compatibleR // Fill in the last part of the desc since now it's time to block. VkShaderModule vs = desc->vertexShader->BlockUntilReady(); VkShaderModule fs = desc->fragmentShader->BlockUntilReady(); + VkShaderModule gs = desc->geometryShader ? desc->geometryShader->BlockUntilReady() : VK_NULL_HANDLE; - if (!vs || !fs) { + if (!vs || !fs || (!gs && desc->geometryShader)) { ERROR_LOG(G3D, "Failed creating graphics pipeline - missing shader modules"); // We're kinda screwed here? return false; @@ -49,6 +50,14 @@ bool VKRGraphicsPipeline::Create(VulkanContext *vulkan, VkRenderPass compatibleR ss[1].pSpecializationInfo = nullptr; ss[1].module = fs; ss[1].pName = "main"; + if (gs) { + stageCount++; + ss[2].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + ss[2].stage = VK_SHADER_STAGE_GEOMETRY_BIT; + ss[2].pSpecializationInfo = nullptr; + ss[2].module = gs; + ss[2].pName = "main"; + } VkGraphicsPipelineCreateInfo pipe{ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO }; pipe.pStages = ss; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 66692d99a7..7fd45e2246 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -128,6 +128,7 @@ struct VKRGraphicsPipelineDesc { // Replaced the ShaderStageInfo with promises here so we can wait for compiles to finish. Promise *vertexShader = nullptr; Promise *fragmentShader = nullptr; + Promise *geometryShader = nullptr; VkPipelineInputAssemblyStateCreateInfo inputAssembly{ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; VkVertexInputAttributeDescription attrs[8]{}; diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index bb8dd54237..eccd5d158f 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -366,3 +366,42 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip *id_out = id; } + +std::string GeometryShaderDesc(const GShaderID &id) { + std::stringstream desc; + desc << StringFromFormat("%08x:%08x ", id.d[1], id.d[0]); + if (id.Bit(GS_BIT_ENABLED)) desc << "ENABLED "; + if (id.Bit(GS_BIT_DO_TEXTURE)) desc << "TEX "; + if (id.Bit(GS_BIT_LMODE)) desc << "LMODE "; + return desc.str(); +} + +void ComputeGeometryShaderID(GShaderID *id_out, const Draw::Bugs &bugs, int prim) { + GShaderID id; + + bool vertexRangeCulling = + !gstate.isModeThrough() && gstate_c.submitType == SubmitType::DRAW; // neither hw nor sw spline/bezier. See #11692 + + // If we're not using GS culling, return a zero ID. + // Also, only use this for triangle primitives. + if (!vertexRangeCulling || !gstate_c.Supports(GPU_SUPPORTS_GS_CULLING) || (prim != GE_PRIM_TRIANGLES && prim != GE_PRIM_TRIANGLE_FAN && prim != GE_PRIM_TRIANGLE_STRIP)) { + *id_out = id; + return; + } + + id.SetBit(GS_BIT_ENABLED, true); + + if (gstate.isModeClear()) { + // No attribute bits. + } else { + bool isModeThrough = gstate.isModeThrough(); + bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough; + + id.SetBit(GS_BIT_LMODE, lmode); + if (gstate.isTextureMapEnabled()) { + id.SetBit(GS_BIT_DO_TEXTURE); + } + } + + *id_out = id; +} diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 20a6cfda48..ec25abb4d3 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -104,6 +104,17 @@ static inline FShaderBit operator +(FShaderBit bit, int i) { return FShaderBit((int)bit + i); } +// Some of these bits are straight from FShaderBit, since they essentially enable attributes directly. +enum GShaderBit : uint8_t { + GS_BIT_ENABLED = 0, // If not set, we don't use a geo shader. + GS_BIT_DO_TEXTURE = 1, // presence of texcoords + GS_BIT_LMODE = 2, // presence of specular color (regular color always present) +}; + +static inline GShaderBit operator +(GShaderBit bit, int i) { + return GShaderBit((int)bit + i); +} + struct ShaderID { ShaderID() { clear(); @@ -232,6 +243,31 @@ struct FShaderID : ShaderID { } }; +struct GShaderID : ShaderID { + GShaderID() : ShaderID() { + } + + explicit GShaderID(ShaderID &src) { + memcpy(d, src.d, sizeof(d)); + } + + bool Bit(GShaderBit bit) const { + return ShaderID::Bit((int)bit); + } + + int Bits(GShaderBit bit, int count) const { + return ShaderID::Bits((int)bit, count); + } + + void SetBit(GShaderBit bit, bool value = true) { + ShaderID::SetBit((int)bit, value); + } + + void SetBits(GShaderBit bit, int count, int value) { + ShaderID::SetBits((int)bit, count, value); + } +}; + namespace Draw { class Bugs; } @@ -244,3 +280,6 @@ std::string VertexShaderDesc(const VShaderID &id); struct ComputedPipelineState; void ComputeFragmentShaderID(FShaderID *id, const ComputedPipelineState &pipelineState, const Draw::Bugs &bugs); std::string FragmentShaderDesc(const FShaderID &id); + +void ComputeGeometryShaderID(GShaderID *id, const Draw::Bugs &bugs, int prim); +std::string GeometryShaderDesc(const GShaderID &id); diff --git a/GPU/GPUState.h b/GPU/GPUState.h index a10cfe790e..e5d5662845 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -486,7 +486,8 @@ enum { // Free bit: 15 GPU_SUPPORTS_DEPTH_TEXTURE = FLAG_BIT(16), GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17), - // Free bits: 18-19 + GPU_SUPPORTS_GS_CULLING = FLAG_BIT(18), // Geometry shader + // Free bit: 19 GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH = FLAG_BIT(20), GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT = FLAG_BIT(21), GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT = FLAG_BIT(22), diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 703ada14b4..2c50795472 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -89,8 +89,6 @@ DrawEngineVulkan::DrawEngineVulkan(Draw::DrawContext *draw) decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE, MEM_PROT_READ | MEM_PROT_WRITE); indexGen.Setup(decIndex); - - InitDeviceObjects(); } void DrawEngineVulkan::InitDeviceObjects() { @@ -114,6 +112,8 @@ void DrawEngineVulkan::InitDeviceObjects() { bindings[3].descriptorCount = 1; bindings[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; bindings[3].stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; + if (gstate_c.Supports(GPU_SUPPORTS_GS_CULLING)) + bindings[3].stageFlags |= VK_SHADER_STAGE_GEOMETRY_BIT; bindings[3].binding = DRAW_BINDING_DYNUBO_BASE; bindings[4].descriptorCount = 1; bindings[4].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; @@ -581,6 +581,7 @@ void DrawEngineVulkan::DoFlush() { VulkanVertexShader *vshader = nullptr; VulkanFragmentShader *fshader = nullptr; + VulkanGeometryShader *gshader = nullptr; uint32_t ibOffset; uint32_t vbOffset; @@ -775,14 +776,14 @@ void DrawEngineVulkan::DoFlush() { ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey_, dynState_); } - shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, pipelineState_, true, useHWTessellation_, decOptions_.expandAllWeightsToFloat); // usehwtransform + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, true, useHWTessellation_, decOptions_.expandAllWeightsToFloat); // usehwtransform if (!vshader) { // We're screwed. return; } _dbg_assert_msg_(vshader->UseHWTransform(), "Bad vshader"); - VulkanPipeline *pipeline = pipelineManager_->GetOrCreatePipeline(renderManager, pipelineLayout_, pipelineKey_, &dec_->decFmt, vshader, fshader, true, 0); + VulkanPipeline *pipeline = pipelineManager_->GetOrCreatePipeline(renderManager, pipelineLayout_, pipelineKey_, &dec_->decFmt, vshader, fshader, gshader, true, 0); if (!pipeline || !pipeline->pipeline) { // Already logged, let's bail out. return; @@ -905,9 +906,9 @@ void DrawEngineVulkan::DoFlush() { if (prim != lastPrim_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE)) { ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey_, dynState_); } - shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat); // usehwtransform + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat); // usehwtransform _dbg_assert_msg_(!vshader->UseHWTransform(), "Bad vshader"); - VulkanPipeline *pipeline = pipelineManager_->GetOrCreatePipeline(renderManager, pipelineLayout_, pipelineKey_, &dec_->decFmt, vshader, fshader, false, 0); + VulkanPipeline *pipeline = pipelineManager_->GetOrCreatePipeline(renderManager, pipelineLayout_, pipelineKey_, &dec_->decFmt, vshader, fshader, gshader, false, 0); if (!pipeline || !pipeline->pipeline) { // Already logged, let's bail out. decodedVerts_ = 0; diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 50df67b136..ebf50e33b5 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -127,6 +127,9 @@ public: DrawEngineVulkan(Draw::DrawContext *draw); virtual ~DrawEngineVulkan(); + // We reference feature flags, so this is called after construction. + void InitDeviceObjects(); + void SetShaderManager(ShaderManagerVulkan *shaderManager) { shaderManager_ = shaderManager; } @@ -196,7 +199,6 @@ private: void ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManager, ShaderManagerVulkan *shaderManager, int prim, VulkanPipelineRasterStateKey &key, VulkanDynamicState &dynState); void BindShaderBlendTex(); - void InitDeviceObjects(); void DestroyDeviceObjects(); void DecodeVertsToPushBuffer(VulkanPushBuffer *push, uint32_t *bindOffset, VkBuffer *vkbuf); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 5bf6b0a2ac..aa31c93be4 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -53,6 +53,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), drawEngine_(draw) { gstate_c.featureFlags = CheckGPUFeatures(); + drawEngine_.InitDeviceObjects(); VulkanContext *vulkan = (VulkanContext *)gfxCtx->GetAPIContext(); diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 2ea530d25a..f25b0cb269 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -171,7 +171,7 @@ static std::string CutFromMain(std::string str) { static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager, VkPipelineCache pipelineCache, VkPipelineLayout layout, PipelineFlags pipelineFlags, const VulkanPipelineRasterStateKey &key, - const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, bool useHwTransform, u32 variantBitmask) { + const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, VulkanGeometryShader *gs, bool useHwTransform, u32 variantBitmask) { VulkanPipeline *vulkanPipeline = new VulkanPipeline(); VKRGraphicsPipelineDesc *desc = &vulkanPipeline->desc; desc->pipelineCache = pipelineCache; @@ -254,6 +254,7 @@ static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager, desc->fragmentShader = fs->GetModule(); desc->vertexShader = vs->GetModule(); + desc->geometryShader = gs ? gs->GetModule() : nullptr; VkPipelineInputAssemblyStateCreateInfo &inputAssembly = desc->inputAssembly; inputAssembly.flags = 0; @@ -301,6 +302,9 @@ static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager, if (useBlendConstant) { pipelineFlags |= PipelineFlags::USES_BLEND_CONSTANT; } + if (gs) { + pipelineFlags |= PipelineFlags::USES_GEOMETRY_SHADER; + } if (dss.depthTestEnable || dss.stencilTestEnable) { pipelineFlags |= PipelineFlags::USES_DEPTH_STENCIL; } @@ -308,7 +312,7 @@ static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager, return vulkanPipeline; } -VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VulkanRenderManager *renderManager, VkPipelineLayout layout, const VulkanPipelineRasterStateKey &rasterKey, const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, bool useHwTransform, u32 variantBitmask) { +VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VulkanRenderManager *renderManager, VkPipelineLayout layout, const VulkanPipelineRasterStateKey &rasterKey, const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, VulkanGeometryShader *gs, bool useHwTransform, u32 variantBitmask) { if (!pipelineCache_) { VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; VkResult res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_); @@ -321,6 +325,7 @@ VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VulkanRenderManager * key.useHWTransform = useHwTransform; key.vShader = vs->GetModule(); key.fShader = fs->GetModule(); + key.gShader = gs ? gs->GetModule() : VK_NULL_HANDLE; key.vtxFmtId = useHwTransform ? decFmt->id : 0; auto iter = pipelines_.Get(key); @@ -334,7 +339,7 @@ VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VulkanRenderManager * VulkanPipeline *pipeline = CreateVulkanPipeline( renderManager, pipelineCache_, layout, pipelineFlags, - rasterKey, decFmt, vs, fs, useHwTransform, variantBitmask); + rasterKey, decFmt, vs, fs, gs, useHwTransform, variantBitmask); pipelines_.Insert(key, pipeline); // Don't return placeholder null pipelines. @@ -589,7 +594,13 @@ void PipelineManagerVulkan::SaveCache(FILE *file, bool saveRawPipelineCache, Sha return; VulkanVertexShader *vshader = shaderManager->GetVertexShaderFromModule(pkey.vShader->BlockUntilReady()); VulkanFragmentShader *fshader = shaderManager->GetFragmentShaderFromModule(pkey.fShader->BlockUntilReady()); - if (!vshader || !fshader) { + VulkanGeometryShader *gshader = nullptr; + if (pkey.gShader) { + gshader = shaderManager->GetGeometryShaderFromModule(pkey.gShader->BlockUntilReady()); + if (!gshader) + failed = true; + } + if (!vshader || !fshader || failed) { failed = true; return; } @@ -710,7 +721,7 @@ bool PipelineManagerVulkan::LoadCache(FILE *file, bool loadRawPipelineCache, Sha DecVtxFormat fmt; fmt.InitializeFromID(key.vtxFmtId); - VulkanPipeline *pipeline = GetOrCreatePipeline(rm, layout, key.raster, key.useHWTransform ? &fmt : 0, vs, fs, key.useHWTransform, key.variants); + VulkanPipeline *pipeline = GetOrCreatePipeline(rm, layout, key.raster, key.useHWTransform ? &fmt : 0, vs, fs, nullptr, key.useHWTransform, key.variants); if (!pipeline) { pipelineCreateFailCount += 1; } diff --git a/GPU/Vulkan/PipelineManagerVulkan.h b/GPU/Vulkan/PipelineManagerVulkan.h index e72f53a800..32e45c3faf 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.h +++ b/GPU/Vulkan/PipelineManagerVulkan.h @@ -38,6 +38,7 @@ struct VulkanPipelineKey { VKRRenderPass *renderPass; Promise *vShader; Promise *fShader; + Promise *gShader; uint32_t vtxFmtId; bool useHWTransform; @@ -68,6 +69,7 @@ struct VulkanPipeline { class VulkanContext; class VulkanVertexShader; class VulkanFragmentShader; +class VulkanGeometryShader; class ShaderManagerVulkan; class DrawEngineCommon; @@ -77,7 +79,7 @@ public: ~PipelineManagerVulkan(); // variantMask is only used when loading pipelines from cache. - VulkanPipeline *GetOrCreatePipeline(VulkanRenderManager *renderManager, VkPipelineLayout layout, const VulkanPipelineRasterStateKey &rasterKey, const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, bool useHwTransform, u32 variantMask); + VulkanPipeline *GetOrCreatePipeline(VulkanRenderManager *renderManager, VkPipelineLayout layout, const VulkanPipelineRasterStateKey &rasterKey, const DecVtxFormat *decFmt, VulkanVertexShader *vs, VulkanFragmentShader *fs, VulkanGeometryShader *gs, bool useHwTransform, u32 variantMask); int GetNumPipelines() const { return (int)pipelines_.size(); } void Clear(); diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index bfb5547b6a..769c258993 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -163,8 +163,38 @@ std::string VulkanVertexShader::GetShaderString(DebugShaderStringType type) cons } } +VulkanGeometryShader::VulkanGeometryShader(VulkanContext *vulkan, GShaderID id, const char *code) + : vulkan_(vulkan), id_(id) { + source_ = code; + module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_GEOMETRY_BIT, source_.c_str(), new std::string(GeometryShaderDesc(id).c_str())); + if (!module_) { + failed_ = true; + } else { + VERBOSE_LOG(G3D, "Compiled geometry shader:\n%s\n", (const char *)code); + } +} + +VulkanGeometryShader::~VulkanGeometryShader() { + if (module_) { + VkShaderModule shaderModule = module_->BlockUntilReady(); + vulkan_->Delete().QueueDeleteShaderModule(shaderModule); + delete module_; + } +} + +std::string VulkanGeometryShader::GetShaderString(DebugShaderStringType type) const { + switch (type) { + case SHADER_STRING_SOURCE_CODE: + return source_; + case SHADER_STRING_SHORT_DESC: + return GeometryShaderDesc(id_); + default: + return "N/A"; + } +} + ShaderManagerVulkan::ShaderManagerVulkan(Draw::DrawContext *draw) - : ShaderManagerCommon(draw), compat_(GLSL_VULKAN), fsCache_(16), vsCache_(16) { + : ShaderManagerCommon(draw), compat_(GLSL_VULKAN), fsCache_(16), vsCache_(16), gsCache_(16) { codeBuffer_ = new char[16384]; VulkanContext *vulkan = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT); uboAlignment_ = vulkan->GetPhysicalDeviceProperties().properties.limits.minUniformBufferOffsetAlignment; @@ -199,10 +229,15 @@ void ShaderManagerVulkan::Clear() { vsCache_.Iterate([&](const VShaderID &key, VulkanVertexShader *shader) { delete shader; }); + gsCache_.Iterate([&](const GShaderID &key, VulkanGeometryShader *shader) { + delete shader; + }); fsCache_.Clear(); vsCache_.Clear(); + gsCache_.Clear(); lastFSID_.set_invalid(); lastVSID_.set_invalid(); + lastGSID_.set_invalid(); gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); } @@ -216,12 +251,14 @@ void ShaderManagerVulkan::DirtyShader() { // Forget the last shader ID lastFSID_.set_invalid(); lastVSID_.set_invalid(); + lastGSID_.set_invalid(); DirtyLastShader(); } void ShaderManagerVulkan::DirtyLastShader() { lastVShader_ = nullptr; lastFShader_ = nullptr; + lastGShader_ = nullptr; gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE); } @@ -239,7 +276,7 @@ uint64_t ShaderManagerVulkan::UpdateUniforms(bool useBufferedRendering) { return dirty; } -void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat) { +void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, VulkanGeometryShader **gshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat) { VShaderID VSID; if (gstate_c.IsDirty(DIRTY_VERTEXSHADER_STATE)) { gstate_c.Clean(DIRTY_VERTEXSHADER_STATE); @@ -256,14 +293,23 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader FSID = lastFSID_; } + GShaderID GSID; + if (gstate_c.IsDirty(DIRTY_GEOMETRYSHADER_STATE)) { + gstate_c.Clean(DIRTY_GEOMETRYSHADER_STATE); + ComputeGeometryShaderID(&GSID, draw_->GetBugs(), prim); + } else { + GSID = lastGSID_; + } + _dbg_assert_(FSID.Bit(FS_BIT_LMODE) == VSID.Bit(VS_BIT_LMODE)); _dbg_assert_(FSID.Bit(FS_BIT_DO_TEXTURE) == VSID.Bit(VS_BIT_DO_TEXTURE)); _dbg_assert_(FSID.Bit(FS_BIT_FLATSHADE) == VSID.Bit(VS_BIT_FLATSHADE)); // Just update uniforms if this is the same shader as last time. - if (lastVShader_ != nullptr && lastFShader_ != nullptr && VSID == lastVSID_ && FSID == lastFSID_) { + if (lastVShader_ != nullptr && lastFShader_ != nullptr && VSID == lastVSID_ && FSID == lastFSID_ && GSID == lastGSID_) { *vshader = lastVShader_; *fshader = lastFShader_; + *gshader = lastGShader_; _dbg_assert_msg_((*vshader)->UseHWTransform() == useHWTransform, "Bad vshader was cached"); // Already all set, no need to look up in shader maps. return; @@ -281,11 +327,9 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader vs = new VulkanVertexShader(vulkan, VSID, codeBuffer_, useHWTransform); vsCache_.Insert(VSID, vs); } - lastVSID_ = VSID; VulkanFragmentShader *fs = fsCache_.Get(FSID); if (!fs) { - // uint32_t vendorID = vulkan->GetPhysicalDeviceProperties().properties.vendorID; // Fragment shader not in cache. Let's compile it. std::string genErrorString; uint64_t uniformMask = 0; // Not used @@ -296,13 +340,28 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader fsCache_.Insert(FSID, fs); } + VulkanGeometryShader *gs; + if (GSID.Bit(GS_BIT_ENABLED)) { + gs = gsCache_.Get(GSID); + if (!gs) { + // Geometry shader not in cache. Let's compile it. + // TODO + } + } else { + gs = nullptr; + } + + lastVSID_ = VSID; lastFSID_ = FSID; + lastGSID_ = GSID; lastVShader_ = vs; lastFShader_ = fs; + lastGShader_ = gs; *vshader = vs; *fshader = fs; + *gshader = gs; _dbg_assert_msg_((*vshader)->UseHWTransform() == useHWTransform, "Bad vshader was computed"); } @@ -327,6 +386,15 @@ std::vector ShaderManagerVulkan::DebugGetShaderIDs(DebugShaderType }); break; } + case SHADER_TYPE_GEOMETRY: + { + gsCache_.Iterate([&](const GShaderID &id, VulkanGeometryShader *shader) { + std::string idstr; + id.ToString(&idstr); + ids.push_back(idstr); + }); + break; + } default: break; } @@ -342,12 +410,16 @@ std::string ShaderManagerVulkan::DebugGetShaderString(std::string id, DebugShade VulkanVertexShader *vs = vsCache_.Get(VShaderID(shaderId)); return vs ? vs->GetShaderString(stringType) : ""; } - case SHADER_TYPE_FRAGMENT: { VulkanFragmentShader *fs = fsCache_.Get(FShaderID(shaderId)); return fs ? fs->GetShaderString(stringType) : ""; } + case SHADER_TYPE_GEOMETRY: + { + VulkanGeometryShader *gs = gsCache_.Get(GShaderID(shaderId)); + return gs ? gs->GetShaderString(stringType) : ""; + } default: return "N/A"; } @@ -375,6 +447,17 @@ VulkanFragmentShader *ShaderManagerVulkan::GetFragmentShaderFromModule(VkShaderM return fs; } +VulkanGeometryShader *ShaderManagerVulkan::GetGeometryShaderFromModule(VkShaderModule module) { + VulkanGeometryShader *gs = nullptr; + gsCache_.Iterate([&](const GShaderID &id, VulkanGeometryShader *shader) { + Promise *p = shader->GetModule(); + VkShaderModule m = p->BlockUntilReady(); + if (m == module) + gs = shader; + }); + return gs; +} + // Shader cache. // // We simply store the IDs of the shaders used during gameplay. On next startup of diff --git a/GPU/Vulkan/ShaderManagerVulkan.h b/GPU/Vulkan/ShaderManagerVulkan.h index 6593a366f4..4c89f91ef5 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.h +++ b/GPU/Vulkan/ShaderManagerVulkan.h @@ -83,7 +83,27 @@ protected: VShaderID id_; }; -class VulkanPushBuffer; +class VulkanGeometryShader { +public: + VulkanGeometryShader(VulkanContext *vulkan, GShaderID id, const char *code); + ~VulkanGeometryShader(); + + const std::string &source() const { return source_; } + + bool Failed() const { return failed_; } + + std::string GetShaderString(DebugShaderStringType type) const; + Promise *GetModule() const { return module_; } + const GShaderID &GetID() { return id_; } + +protected: + Promise *module_ = nullptr; + + VulkanContext *vulkan_; + std::string source_; + bool failed_ = false; + GShaderID id_; +}; class ShaderManagerVulkan : public ShaderManagerCommon { public: @@ -93,19 +113,22 @@ public: void DeviceLost(); void DeviceRestore(Draw::DrawContext *draw); - void GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat); + void GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, VulkanGeometryShader **gshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat); void ClearShaders(); void DirtyShader(); void DirtyLastShader() override; int GetNumVertexShaders() const { return (int)vsCache_.size(); } int GetNumFragmentShaders() const { return (int)fsCache_.size(); } + int GetNumGeometryShaders() const { return (int)gsCache_.size(); } // Used for saving/loading the cache. Don't need to be particularly fast. VulkanVertexShader *GetVertexShaderFromID(VShaderID id) { return vsCache_.Get(id); } VulkanFragmentShader *GetFragmentShaderFromID(FShaderID id) { return fsCache_.Get(id); } + VulkanGeometryShader *GetGeometryShaderFromID(GShaderID id) { return gsCache_.Get(id); } VulkanVertexShader *GetVertexShaderFromModule(VkShaderModule module); VulkanFragmentShader *GetFragmentShaderFromModule(VkShaderModule module); + VulkanGeometryShader *GetGeometryShaderFromModule(VkShaderModule module); std::vector DebugGetShaderIDs(DebugShaderType type); std::string DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType); @@ -143,6 +166,9 @@ private: typedef DenseHashMap VSCache; VSCache vsCache_; + typedef DenseHashMap GSCache; + GSCache gsCache_; + char *codeBuffer_; uint64_t uboAlignment_; @@ -153,7 +179,9 @@ private: VulkanFragmentShader *lastFShader_ = nullptr; VulkanVertexShader *lastVShader_ = nullptr; + VulkanGeometryShader *lastGShader_ = nullptr; FShaderID lastFSID_; VShaderID lastVSID_; + GShaderID lastGSID_; }; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index e85f1d3adc..5dea5e0921 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -1156,7 +1156,7 @@ int ShaderListScreen::ListShaders(DebugShaderType shaderType, UI::LinearLayout * struct { DebugShaderType type; const char *name; } shaderTypes[] = { { SHADER_TYPE_VERTEX, "Vertex" }, { SHADER_TYPE_FRAGMENT, "Fragment" }, - // { SHADER_TYPE_GEOMETRY, "Geometry" }, + { SHADER_TYPE_GEOMETRY, "Geometry" }, { SHADER_TYPE_VERTEXLOADER, "VertexLoader" }, { SHADER_TYPE_PIPELINE, "Pipeline" }, { SHADER_TYPE_TEXTURE, "Texture" }, From fbdb2781688a997f630cd33bb7d1d5f70613dfc3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Oct 2022 20:13:30 -0700 Subject: [PATCH 014/374] Vulkan: Update shader cache format for geo shaders. --- GPU/Vulkan/PipelineManagerVulkan.cpp | 5 ++++- GPU/Vulkan/ShaderManagerVulkan.cpp | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index f25b0cb269..4b9ff1e4b3 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -544,6 +544,7 @@ struct StoredVulkanPipelineKey { VulkanPipelineRasterStateKey raster; VShaderID vShaderID; FShaderID fShaderID; + GShaderID gShaderID; uint32_t vtxFmtId; uint32_t variants; bool useHWTransform; // TODO: Still needed? @@ -609,6 +610,7 @@ void PipelineManagerVulkan::SaveCache(FILE *file, bool saveRawPipelineCache, Sha key.useHWTransform = pkey.useHWTransform; key.fShaderID = fshader->GetID(); key.vShaderID = vshader->GetID(); + key.gShaderID = gshader ? gshader->GetID() : GShaderID(); key.variants = value->GetVariantsBitmask(); if (key.useHWTransform) { // NOTE: This is not a vtype, but a decoded vertex format. @@ -713,6 +715,7 @@ bool PipelineManagerVulkan::LoadCache(FILE *file, bool loadRawPipelineCache, Sha } VulkanVertexShader *vs = shaderManager->GetVertexShaderFromID(key.vShaderID); VulkanFragmentShader *fs = shaderManager->GetFragmentShaderFromID(key.fShaderID); + VulkanGeometryShader *gs = shaderManager->GetGeometryShaderFromID(key.gShaderID); if (!vs || !fs) { failed = true; ERROR_LOG(G3D, "Failed to find vs or fs in of pipeline %d in cache", (int)i); @@ -721,7 +724,7 @@ bool PipelineManagerVulkan::LoadCache(FILE *file, bool loadRawPipelineCache, Sha DecVtxFormat fmt; fmt.InitializeFromID(key.vtxFmtId); - VulkanPipeline *pipeline = GetOrCreatePipeline(rm, layout, key.raster, key.useHWTransform ? &fmt : 0, vs, fs, nullptr, key.useHWTransform, key.variants); + VulkanPipeline *pipeline = GetOrCreatePipeline(rm, layout, key.raster, key.useHWTransform ? &fmt : 0, vs, fs, gs, key.useHWTransform, key.variants); if (!pipeline) { pipelineCreateFailCount += 1; } diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 769c258993..07d9603322 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -467,7 +467,7 @@ VulkanGeometryShader *ShaderManagerVulkan::GetGeometryShaderFromModule(VkShaderM // instantaneous. #define CACHE_HEADER_MAGIC 0xff51f420 -#define CACHE_VERSION 28 +#define CACHE_VERSION 29 struct VulkanCacheHeader { uint32_t magic; uint32_t version; @@ -475,6 +475,7 @@ struct VulkanCacheHeader { uint32_t reserved; int numVertexShaders; int numFragmentShaders; + int numGeometryShaders; }; bool ShaderManagerVulkan::LoadCache(FILE *f) { @@ -522,6 +523,15 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { fsCache_.Insert(id, fs); } + for (int i = 0; i < header.numGeometryShaders; i++) { + GShaderID id; + if (fread(&id, sizeof(id), 1, f) != 1) { + ERROR_LOG(G3D, "Vulkan shader cache truncated"); + break; + } + // TODO: Actually generate geometry shaders. + } + NOTICE_LOG(G3D, "Loaded %d vertex and %d fragment shaders", header.numVertexShaders, header.numFragmentShaders); return true; } @@ -534,6 +544,7 @@ void ShaderManagerVulkan::SaveCache(FILE *f) { header.reserved = 0; header.numVertexShaders = (int)vsCache_.size(); header.numFragmentShaders = (int)fsCache_.size(); + header.numGeometryShaders = (int)gsCache_.size(); bool writeFailed = fwrite(&header, sizeof(header), 1, f) != 1; vsCache_.Iterate([&](const VShaderID &id, VulkanVertexShader *vs) { writeFailed = writeFailed || fwrite(&id, sizeof(id), 1, f) != 1; @@ -541,6 +552,9 @@ void ShaderManagerVulkan::SaveCache(FILE *f) { fsCache_.Iterate([&](const FShaderID &id, VulkanFragmentShader *fs) { writeFailed = writeFailed || fwrite(&id, sizeof(id), 1, f) != 1; }); + gsCache_.Iterate([&](const GShaderID &id, VulkanGeometryShader *gs) { + writeFailed = writeFailed || fwrite(&id, sizeof(id), 1, f) != 1; + }); if (writeFailed) { ERROR_LOG(G3D, "Failed to write Vulkan shader cache, disk full?"); } else { From cdee10fe86ddeffbfc643715586c12cec0d571e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 26 Oct 2021 09:56:14 +0200 Subject: [PATCH 015/374] Vulkan: Basic geoshader code generation. --- CMakeLists.txt | 2 + Common/GPU/Vulkan/VulkanContext.cpp | 2 - GPU/Common/GeometryShaderGenerator.cpp | 79 ++++++++++++++++++++++ GPU/Common/GeometryShaderGenerator.h | 5 ++ GPU/GPU.vcxproj | 2 + GPU/GPU.vcxproj.filters | 6 ++ GPU/Vulkan/GPU_Vulkan.cpp | 8 +++ GPU/Vulkan/PipelineManagerVulkan.cpp | 2 +- GPU/Vulkan/ShaderManagerVulkan.cpp | 19 +++++- UWP/GPU_UWP/GPU_UWP.vcxproj | 2 + UWP/GPU_UWP/GPU_UWP.vcxproj.filters | 2 + android/jni/Android.mk | 1 + libretro/Makefile.common | 1 + unittest/TestShaderGenerators.cpp | 91 ++++++++++++++++++++++++++ 14 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 GPU/Common/GeometryShaderGenerator.cpp create mode 100644 GPU/Common/GeometryShaderGenerator.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8cec0f281d..52fb7e40c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1562,6 +1562,8 @@ set(GPU_SOURCES GPU/Common/FragmentShaderGenerator.h GPU/Common/VertexShaderGenerator.cpp GPU/Common/VertexShaderGenerator.h + GPU/Common/GeometryShaderGenerator.cpp + GPU/Common/GeometryShaderGenerator.h GPU/Common/FramebufferManagerCommon.cpp GPU/Common/FramebufferManagerCommon.h GPU/Common/GPUDebugInterface.cpp diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index 1379cb9f21..c2140c5663 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -600,8 +600,6 @@ void VulkanContext::ChooseDevice(int physical_device) { deviceFeatures_.enabled.samplerAnisotropy = deviceFeatures_.available.samplerAnisotropy; deviceFeatures_.enabled.shaderClipDistance = deviceFeatures_.available.shaderClipDistance; deviceFeatures_.enabled.shaderCullDistance = deviceFeatures_.available.shaderCullDistance; - // For easy wireframe mode, someday. - deviceFeatures_.enabled.fillModeNonSolid = deviceFeatures_.available.fillModeNonSolid; deviceFeatures_.enabled.geometryShader = deviceFeatures_.available.geometryShader; GetDeviceLayerExtensionList(nullptr, device_extension_properties_); diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp new file mode 100644 index 0000000000..fdd64c8077 --- /dev/null +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -0,0 +1,79 @@ +// Copyright (c) 2012- PPSSPP Project. + +// 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, version 2.0 or later versions. + +// 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 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official git repository and contact information can be found at +// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. + +#include +#include +#include + +#include "Common/StringUtils.h" +#include "Common/GPU/OpenGL/GLFeatures.h" +#include "Common/GPU/ShaderWriter.h" +#include "Common/GPU/thin3d.h" +#include "Core/Config.h" +#include "GPU/ge_constants.h" +#include "GPU/GPUState.h" +#include "GPU/Common/ShaderId.h" +#include "GPU/Common/ShaderUniforms.h" +#include "GPU/Common/GeometryShaderGenerator.h" + +#undef WRITE + +#define WRITE(p, ...) p.F(__VA_ARGS__) + +bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLanguageDesc &compat, const Draw::Bugs bugs, std::string *errorString) { + std::vector gl_exts; + if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { + if (gl_extensions.EXT_gpu_shader4) { + gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); + } + } + + ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); + p.C("layout(triangles) in;\n"); + p.C("layout(triangle_strip, max_vertices = 3) out;\n"); + + std::vector varyings, outVaryings; + + if (id.Bit(GS_BIT_DO_TEXTURE)) { + varyings.push_back(VaryingDef{ "vec3", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" }); + outVaryings.push_back(VaryingDef{ "vec3", "v_texcoordOut", Draw::SEM_TEXCOORD0, 0, "highp" }); + } + varyings.push_back(VaryingDef{ "vec4", "v_color0", Draw::SEM_COLOR0, 1, "lowp" }); + outVaryings.push_back(VaryingDef{ "vec4", "v_color0Out", Draw::SEM_COLOR0, 1, "lowp" }); + if (id.Bit(GS_BIT_LMODE)) { + varyings.push_back(VaryingDef{ "vec3", "v_color1", Draw::SEM_COLOR1, 2, "lowp" }); + outVaryings.push_back(VaryingDef{ "vec3", "v_color1Out", Draw::SEM_COLOR1, 2, "lowp" }); + } + varyings.push_back(VaryingDef{ "float", "v_fogdepth", Draw::SEM_TEXCOORD1, 3, "highp" }); + outVaryings.push_back(VaryingDef{ "float", "v_fogdepthOut", Draw::SEM_TEXCOORD1, 3, "highp" }); + + p.BeginGSMain(varyings, outVaryings); + + p.C(" for (int i = 0; i < gl_in.length(); i++) {\n"); + p.C(" gl_Position = gl_in[i].gl_Position;\n"); // copy attributes + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" }\n"); + + p.EndGSMain(); + + return true; +} diff --git a/GPU/Common/GeometryShaderGenerator.h b/GPU/Common/GeometryShaderGenerator.h new file mode 100644 index 0000000000..9848ffde18 --- /dev/null +++ b/GPU/Common/GeometryShaderGenerator.h @@ -0,0 +1,5 @@ +#pragma once + +#include "GPU/Common/ShaderId.h" + +bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLanguageDesc &compat, const Draw::Bugs bugs, std::string *errorString); diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index 0480b490d7..808ce53635 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -340,6 +340,7 @@ + @@ -455,6 +456,7 @@ + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index bd28a45e97..e110c20b8b 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -261,6 +261,9 @@ Debugger + + Common + @@ -512,6 +515,9 @@ Debugger + + Common + diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index aa31c93be4..79a2db00d6 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -232,6 +232,14 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_SUPPORTS_DEPTH_CLAMP; } + if (!draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) { + const bool disabled = PSP_CoreParameter().compat.flags().DisableRangeCulling; + // Fall back to geometry shader culling. + if (enabledFeatures.geometryShader && !disabled && (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0) { + features |= GPU_SUPPORTS_GS_CULLING; + } + } + // These are VULKAN_4444_FORMAT and friends. uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16); uint32_t fmt1555 = draw_->GetDataFormatSupport(Draw::DataFormat::A1R5G5B5_UNORM_PACK16); diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 4b9ff1e4b3..3d7745b452 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -716,7 +716,7 @@ bool PipelineManagerVulkan::LoadCache(FILE *file, bool loadRawPipelineCache, Sha VulkanVertexShader *vs = shaderManager->GetVertexShaderFromID(key.vShaderID); VulkanFragmentShader *fs = shaderManager->GetFragmentShaderFromID(key.fShaderID); VulkanGeometryShader *gs = shaderManager->GetGeometryShaderFromID(key.gShaderID); - if (!vs || !fs) { + if (!vs || !fs || (!gs && key.gShaderID.Bit(GS_BIT_ENABLED))) { failed = true; ERROR_LOG(G3D, "Failed to find vs or fs in of pipeline %d in cache", (int)i); continue; diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 07d9603322..00649a6be1 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -38,6 +38,7 @@ #include "GPU/ge_constants.h" #include "GPU/Common/FragmentShaderGenerator.h" #include "GPU/Common/VertexShaderGenerator.h" +#include "GPU/Common/GeometryShaderGenerator.h" #include "GPU/Vulkan/ShaderManagerVulkan.h" #include "GPU/Vulkan/DrawEngineVulkan.h" #include "GPU/Vulkan/FramebufferManagerVulkan.h" @@ -305,6 +306,11 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader _dbg_assert_(FSID.Bit(FS_BIT_DO_TEXTURE) == VSID.Bit(VS_BIT_DO_TEXTURE)); _dbg_assert_(FSID.Bit(FS_BIT_FLATSHADE) == VSID.Bit(VS_BIT_FLATSHADE)); + if (GSID.Bit(GS_BIT_ENABLED)) { + _dbg_assert_(GSID.Bit(GS_BIT_LMODE) == VSID.Bit(VS_BIT_LMODE)); + _dbg_assert_(GSID.Bit(GS_BIT_DO_TEXTURE) == VSID.Bit(VS_BIT_DO_TEXTURE)); + } + // Just update uniforms if this is the same shader as last time. if (lastVShader_ != nullptr && lastFShader_ != nullptr && VSID == lastVSID_ && FSID == lastFSID_ && GSID == lastGSID_) { *vshader = lastVShader_; @@ -345,7 +351,11 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader gs = gsCache_.Get(GSID); if (!gs) { // Geometry shader not in cache. Let's compile it. - // TODO + std::string genErrorString; + bool success = GenerateGeometryShader(GSID, codeBuffer_, compat_, draw_->GetBugs(), &genErrorString); + _assert_msg_(success, "GS gen error: %s", genErrorString.c_str()); + gs = new VulkanGeometryShader(vulkan, GSID, codeBuffer_); + gsCache_.Insert(GSID, gs); } } else { gs = nullptr; @@ -529,7 +539,12 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { ERROR_LOG(G3D, "Vulkan shader cache truncated"); break; } - // TODO: Actually generate geometry shaders. + std::string genErrorString; + if (!GenerateGeometryShader(id, codeBuffer_, compat_, draw_->GetBugs(), &genErrorString)) { + return false; + } + VulkanGeometryShader *gs = new VulkanGeometryShader(vulkan, id, codeBuffer_); + gsCache_.Insert(id, gs); } NOTICE_LOG(G3D, "Loaded %d vertex and %d fragment shaders", header.numVertexShaders, header.numFragmentShaders); diff --git a/UWP/GPU_UWP/GPU_UWP.vcxproj b/UWP/GPU_UWP/GPU_UWP.vcxproj index 87aac4d38b..05b7839736 100644 --- a/UWP/GPU_UWP/GPU_UWP.vcxproj +++ b/UWP/GPU_UWP/GPU_UWP.vcxproj @@ -385,6 +385,7 @@ + @@ -446,6 +447,7 @@ + diff --git a/UWP/GPU_UWP/GPU_UWP.vcxproj.filters b/UWP/GPU_UWP/GPU_UWP.vcxproj.filters index dbce632981..2296b16a16 100644 --- a/UWP/GPU_UWP/GPU_UWP.vcxproj.filters +++ b/UWP/GPU_UWP/GPU_UWP.vcxproj.filters @@ -55,6 +55,7 @@ + @@ -116,6 +117,7 @@ + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 2f86711855..42cae5cb28 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -350,6 +350,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/GPU/Common/PostShader.cpp \ $(SRC)/GPU/Common/ShaderUniforms.cpp \ $(SRC)/GPU/Common/VertexShaderGenerator.cpp \ + $(SRC)/GPU/Common/GeometryShaderGenerator.cpp \ $(SRC)/GPU/Debugger/Breakpoints.cpp \ $(SRC)/GPU/Debugger/Debugger.cpp \ $(SRC)/GPU/Debugger/GECommandTable.cpp \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index e7dd40be35..8eed277932 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -342,6 +342,7 @@ SOURCES_CXX += \ $(GPUDIR)/Debugger/Stepping.cpp \ $(GPUDIR)/Common/FragmentShaderGenerator.cpp \ $(GPUDIR)/Common/VertexShaderGenerator.cpp \ + $(GPUDIR)/Common/GeometryShaderGenerator.cpp \ $(GPUDIR)/Common/TextureCacheCommon.cpp \ $(GPUDIR)/Common/TextureScalerCommon.cpp \ $(GPUDIR)/Common/SoftwareTransformCommon.cpp \ diff --git a/unittest/TestShaderGenerators.cpp b/unittest/TestShaderGenerators.cpp index 810de85b9e..346fadf643 100644 --- a/unittest/TestShaderGenerators.cpp +++ b/unittest/TestShaderGenerators.cpp @@ -12,6 +12,7 @@ #include "GPU/Common/FragmentShaderGenerator.h" #include "GPU/Common/VertexShaderGenerator.h" +#include "GPU/Common/GeometryShaderGenerator.h" #include "GPU/Common/ReinterpretFramebuffer.h" #include "GPU/Common/StencilCommon.h" #include "GPU/Common/DepalettizeShaderCommon.h" @@ -91,6 +92,32 @@ bool GenerateVShader(VShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs } } +bool GenerateGShader(GShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs bugs, std::string *errorString) { + errorString->clear(); + + switch (lang) { + case ShaderLanguage::GLSL_VULKAN: + { + ShaderLanguageDesc compat(ShaderLanguage::GLSL_VULKAN); + return GenerateGeometryShader(id, buffer, compat, bugs, errorString); + } + /* + case ShaderLanguage::GLSL_3xx: + { + ShaderLanguageDesc compat(ShaderLanguage::GLSL_3xx); + return GenerateGeometryShader(id, buffer, compat, bugs, errorString); + } + case ShaderLanguage::HLSL_D3D11: + { + ShaderLanguageDesc compat(ShaderLanguage::HLSL_D3D11); + return GenerateGeometryShader(id, buffer, compat, bugs, errorString); + } + */ + default: + return false; + } +} + static VkShaderStageFlagBits StageToVulkan(ShaderStage stage) { switch (stage) { case ShaderStage::Vertex: return VK_SHADER_STAGE_VERTEX_BIT; @@ -369,6 +396,9 @@ bool TestVertexShaders() { if (!id.Bit(VS_BIT_USE_HW_TRANSFORM)) { id.SetBit(VS_BIT_ENABLE_BONES, 0); } + if (id.Bit(VS_BIT_VERTEX_RANGE_CULLING)) { + continue; + } bool generateSuccess[numLanguages]{}; std::string genErrorString[numLanguages]; @@ -463,6 +493,63 @@ bool TestFragmentShaders() { return true; } + +bool TestGeometryShaders() { + char *buffer[numLanguages]; + + for (int i = 0; i < numLanguages; i++) { + buffer[i] = new char[65536]; + } + GMRng rng; + int successes = 0; + int count = 30; + + Draw::Bugs bugs; + + // Generate a bunch of random fragment shader IDs, try to generate shader source. + // Then compile it and check that it's ok. + for (int i = 0; i < count; i++) { + uint32_t bottom = i << 1; + GShaderID id; + id.d[0] = bottom; + id.d[1] = 0; + + id.SetBit(GS_BIT_ENABLED, true); + + bool generateSuccess[numLanguages]{}; + std::string genErrorString[numLanguages]; + + for (int j = 0; j < numLanguages; j++) { + generateSuccess[j] = GenerateGShader(id, buffer[j], languages[j], bugs, &genErrorString[j]); + if (!genErrorString[j].empty()) { + printf("%s\n", genErrorString[j].c_str()); + } + // We ignore the contents of the error string here, not even gonna try to compile if it errors. + } + + // Now that we have the strings ready for easy comparison (buffer,4 in the watch window), + // let's try to compile them. + for (int j = 0; j < numLanguages; j++) { + if (generateSuccess[j]) { + std::string errorMessage; + if (!TestCompileShader(buffer[j], languages[j], ShaderStage::Geometry, &errorMessage)) { + printf("Error compiling geometry shader:\n\n%s\n\n%s\n", LineNumberString(buffer[j]).c_str(), errorMessage.c_str()); + return false; + } + successes++; + } + } + } + + printf("%d/%d geometry shaders generated (it's normal that it's not all, there are invalid bit combos)\n", successes, count * numLanguages); + + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } + return true; +} + + bool TestShaderGenerators() { #if PPSSPP_PLATFORM(WINDOWS) LoadD3D11(); @@ -476,6 +563,10 @@ bool TestShaderGenerators() { return false; } + if (!TestGeometryShaders()) { + return false; + } + if (!TestReinterpretShaders()) { return false; } From ac248338be64161eb47ac88ce3892e9538731112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 27 Oct 2021 09:28:07 +0200 Subject: [PATCH 016/374] Vulkan: Cull in geoshader, hack to on for now. --- GPU/Common/GeometryShaderGenerator.cpp | 54 +++++++++++++++++++++++++- GPU/Common/VertexShaderGenerator.cpp | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 6 +++ 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index fdd64c8077..5ec7875e5c 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -34,6 +34,10 @@ #define WRITE(p, ...) p.F(__VA_ARGS__) +// TODO: Could support VK_NV_geometry_shader_passthrough, though the hardware that supports +// it is already pretty fast at geometry shaders.. + + bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLanguageDesc &compat, const Draw::Bugs bugs, std::string *errorString) { std::vector gl_exts; if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { @@ -46,6 +50,13 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C("layout(triangles) in;\n"); p.C("layout(triangle_strip, max_vertices = 3) out;\n"); + if (compat.shaderLanguage == GLSL_VULKAN) { + WRITE(p, "\n"); + WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); + } else if (compat.shaderLanguage == HLSL_D3D11) { + WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr); + } + std::vector varyings, outVaryings; if (id.Bit(GS_BIT_DO_TEXTURE)) { @@ -63,13 +74,52 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.BeginGSMain(varyings, outVaryings); - p.C(" for (int i = 0; i < gl_in.length(); i++) {\n"); - p.C(" gl_Position = gl_in[i].gl_Position;\n"); // copy attributes + // Apply culling + p.C(" bool anyInside = false;\n"); // TODO: 3 or gl_in.length()? which will be faster? + + p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? + p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); + p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); + p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); + // Vertex range culling doesn't happen when Z clips, note sign of w is important. + p.C(" if (u_cullRangeMin.w <= 0.0 || projZ * outPos.w > -outPos.w) {\n"); + const char *outMin = "projPos.x < u_cullRangeMin.x || projPos.y < u_cullRangeMin.y"; + const char *outMax = "projPos.x > u_cullRangeMax.x || projPos.y > u_cullRangeMax.y"; + p.F(" if ((%s) || (%s)) {\n", outMin, outMax); + p.C(" return;\n"); // Cull! + p.C(" }\n"); + p.C(" }\n"); + p.C(" if (u_cullRangeMin.w <= 0.0) {\n"); + p.C(" if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); + p.C(" return;\n"); // Cull! + p.C(" }\n"); + p.C(" } else {\n"); + p.C(" if (projPos.z >= u_cullRangeMin.z && projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); + p.C(" }\n"); + p.C(" } // for\n"); + + // Cull any triangle fully outside in the same direction when depth clamp enabled. + // Basically simulate cull distances. + p.C(" if (!anyInside) { return; }\n"); + + const char *clip0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]"; + + p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? + p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); + p.C(" gl_Position = outPos;\n"); + p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); + p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); + // TODO: Not rectangles... + // TODO: Check feature flag. + //p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clip0); + for (size_t i = 0; i < varyings.size(); i++) { VaryingDef &in = varyings[i]; VaryingDef &out = outVaryings[i]; p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); } + // Debug - null the red channel + p.C(" if (i == 0) v_color0Out.x = 0.0;\n"); p.C(" EmitVertex();\n"); p.C(" }\n"); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 797a6e0e50..d6f356c6d4 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -1299,7 +1299,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " if (u_cullRangeMin.w <= 0.0 || projZ * outPos.w > -outPos.w) {\n"); const char *outMin = "projPos.x < u_cullRangeMin.x || projPos.y < u_cullRangeMin.y"; const char *outMax = "projPos.x > u_cullRangeMax.x || projPos.y > u_cullRangeMax.y"; - WRITE(p, " if (%s || %s) {\n", outMin, outMax); + WRITE(p, " if ((%s) || (%s)) {\n", outMin, outMax); WRITE(p, " outPos.xyzw = u_cullRangeMax.wwww;\n"); WRITE(p, " }\n"); WRITE(p, " }\n"); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 79a2db00d6..67ed9ae299 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -232,6 +232,11 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_SUPPORTS_DEPTH_CLAMP; } + // Force geo shader culling for debugging. +#if 1 + features |= GPU_SUPPORTS_GS_CULLING; + features &= ~GPU_SUPPORTS_VS_RANGE_CULLING; +#else if (!draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) { const bool disabled = PSP_CoreParameter().compat.flags().DisableRangeCulling; // Fall back to geometry shader culling. @@ -239,6 +244,7 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_SUPPORTS_GS_CULLING; } } +#endif // These are VULKAN_4444_FORMAT and friends. uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16); From bfaa304461e99b1b088db08ecec4f78d10f6adc2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 27 Oct 2021 21:22:45 -0700 Subject: [PATCH 017/374] Vulkan: Correct geometry shader culling. --- GPU/Common/GeometryShaderGenerator.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 5ec7875e5c..2c2906d100 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -75,7 +75,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.BeginGSMain(varyings, outVaryings); // Apply culling - p.C(" bool anyInside = false;\n"); // TODO: 3 or gl_in.length()? which will be faster? + p.C(" bool anyInside = false;\n"); p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); @@ -91,16 +91,20 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); p.C(" if (u_cullRangeMin.w <= 0.0) {\n"); p.C(" if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); - p.C(" return;\n"); // Cull! + // When not clamping depth, cull the triangle of Z is outside the valid range (not based on clip Z.) + p.C(" return;\n"); p.C(" }\n"); p.C(" } else {\n"); - p.C(" if (projPos.z >= u_cullRangeMin.z && projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); + p.C(" if (projPos.z >= u_cullRangeMin.z) { anyInside = true; }\n"); + p.C(" if (projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); p.C(" }\n"); p.C(" } // for\n"); // Cull any triangle fully outside in the same direction when depth clamp enabled. // Basically simulate cull distances. - p.C(" if (!anyInside) { return; }\n"); + p.C(" if (u_cullRangeMin.w > 0.0 && !anyInside) {\n"); + p.C(" return;\n"); + p.C(" }\n"); const char *clip0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]"; @@ -119,7 +123,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); } // Debug - null the red channel - p.C(" if (i == 0) v_color0Out.x = 0.0;\n"); + //p.C(" if (i == 0) v_color0Out.x = 0.0;\n"); p.C(" EmitVertex();\n"); p.C(" }\n"); From 2ce0cda333c945de63ad32179026b42fc9307dc8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Oct 2022 20:39:22 -0700 Subject: [PATCH 018/374] Vulkan: Enable geo shader for culling. The compat setting was really for some previously buggy cases that couldn't work without cull. --- GPU/Vulkan/GPU_Vulkan.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 67ed9ae299..6376fc0620 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -232,19 +232,15 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_SUPPORTS_DEPTH_CLAMP; } - // Force geo shader culling for debugging. -#if 1 - features |= GPU_SUPPORTS_GS_CULLING; - features &= ~GPU_SUPPORTS_VS_RANGE_CULLING; -#else - if (!draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) { - const bool disabled = PSP_CoreParameter().compat.flags().DisableRangeCulling; - // Fall back to geometry shader culling. - if (enabledFeatures.geometryShader && !disabled && (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0) { + // Fall back to geometry shader culling if we can't do vertex range culling. + if (enabledFeatures.geometryShader) { + const bool vertexSupported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; + if (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0) { + // Switch to culling via the geometry shader if not fully supported in vertex. features |= GPU_SUPPORTS_GS_CULLING; + features &= ~GPU_SUPPORTS_VS_RANGE_CULLING; } } -#endif // These are VULKAN_4444_FORMAT and friends. uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::B4G4R4A4_UNORM_PACK16); From 36eb0d9ad5994fe4e4ad9f02e4732efc397fc631 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 1 Oct 2022 20:42:00 -0700 Subject: [PATCH 019/374] Vulkan: Use geo clip distance only where supported. It might be supported without cull or GS. Otherwise we may need to clip the triangles manually. --- GPU/Common/GeometryShaderGenerator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 2c2906d100..0121d7748a 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -114,8 +114,9 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); // TODO: Not rectangles... - // TODO: Check feature flag. - //p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clip0); + if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clip0); + } for (size_t i = 0; i < varyings.size(); i++) { VaryingDef &in = varyings[i]; From 8df956b03639acbaf0e14b483295cdb7c23cac05 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 07:32:31 -0700 Subject: [PATCH 020/374] Vulkan: Block geometry shaders on older Mali. They're too slow to be usable. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 5 +++++ Common/GPU/thin3d.h | 3 +++ GPU/Vulkan/GPU_Vulkan.cpp | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 413057b288..06e026d35c 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -846,6 +846,11 @@ VKContext::VKContext(VulkanContext *vulkan) if (majorVersion >= 32) { bugs_.Infest(Bugs::MALI_CONSTANT_LOAD_BUG); // See issue #15661 } + + // Older ARM devices have very slow geometry shaders, not worth using. At least before 15. + if (majorVersion <= 15) { + bugs_.Infest(Bugs::GEOMETRY_SHADERS_SLOW); + } } // Limited, through input attachments and self-dependencies. diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index f0c562b2f3..c04b7119cd 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -333,11 +333,14 @@ public: RASPBERRY_SHADER_COMP_HANG = 8, MALI_CONSTANT_LOAD_BUG = 9, SUBPASS_FEEDBACK_BROKEN = 10, + GEOMETRY_SHADERS_SLOW = 11, MAX_BUG, }; protected: uint32_t flags_ = 0; + + static_assert(sizeof(flags_) * 8 > MAX_BUG, "Ran out of space for bugs."); }; class RefCountedObject { diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 6376fc0620..6d91a3b20e 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -233,7 +233,7 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { } // Fall back to geometry shader culling if we can't do vertex range culling. - if (enabledFeatures.geometryShader) { + if (enabledFeatures.geometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW)) { const bool vertexSupported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; if (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0) { // Switch to culling via the geometry shader if not fully supported in vertex. From 2832edcc3791f05227e4fa534aaab7e69021d14c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 07:41:36 -0700 Subject: [PATCH 021/374] Vulkan: Allow configuring geometry shaders on/off. --- Core/Config.cpp | 1 + Core/Config.h | 1 + GPU/Vulkan/GPU_Vulkan.cpp | 5 +++-- UI/GameSettingsScreen.cpp | 9 +++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 45e396c9b7..dee26c3793 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -874,6 +874,7 @@ static ConfigSetting graphicsSettings[] = { #endif ConfigSetting("CameraDevice", &g_Config.sCameraDevice, "", true, false), ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), + ConfigSetting("UseGeometryShader", &g_Config.bUseGeometryShader, true, true, true), ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ConfigSetting("SoftwareRendererJit", &g_Config.bSoftwareRenderingJit, true, true, true), diff --git a/Core/Config.h b/Core/Config.h index 8a7f519621..65eaf74099 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -164,6 +164,7 @@ public: bool bHardwareTransform; // only used in the GLES backend bool bSoftwareSkinning; // may speed up some games bool bVendorBugChecksEnabled; + bool bUseGeometryShader; int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering int iTexFiltering; // 1 = auto , 2 = nearest , 3 = linear , 4 = auto max quality diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 6d91a3b20e..f285af82d0 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -233,9 +233,10 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { } // Fall back to geometry shader culling if we can't do vertex range culling. - if (enabledFeatures.geometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW)) { + if (enabledFeatures.geometryShader) { + const bool useGeometry = g_Config.bUseGeometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW); const bool vertexSupported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; - if (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0) { + if (useGeometry && (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0)) { // Switch to culling via the geometry shader if not fully supported in vertex. features |= GPU_SUPPORTS_GS_CULLING; features &= ~GPU_SUPPORTS_VS_RANGE_CULLING; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 0c1c0d009e..876db2773e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -473,6 +473,15 @@ void GameSettingsScreen::CreateViews() { inflightChoice->OnChoice.Handle(this, &GameSettingsScreen::OnInflightFramesChoice); } + if (GetGPUBackend() == GPUBackend::VULKAN) { + const bool usable = !draw->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW); + const bool vertexSupported = draw->GetDeviceCaps().clipDistanceSupported && draw->GetDeviceCaps().cullDistanceSupported; + if (usable && !vertexSupported) { + CheckBox *geometryCulling = graphicsSettings->Add(new CheckBox(&g_Config.bUseGeometryShader, gr->T("Geometry shader culling"))); + geometryCulling->SetDisabledPtr(&g_Config.bSoftwareRendering); + } + } + if (deviceType != DEVICE_TYPE_VR) { CheckBox *hwTransform = graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTransform, gr->T("Hardware Transform"))); hwTransform->SetDisabledPtr(&g_Config.bSoftwareRendering); From 4df7a8f3578a77f029879e25960686fdeaad96b3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 07:43:35 -0700 Subject: [PATCH 022/374] Vulkan: Cleanup unused geometry shader vars. Without clipping, these aren't used (but could be in the future with manual clipping.) --- GPU/Common/GeometryShaderGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 0121d7748a..b701bb547c 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -111,10 +111,10 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); p.C(" gl_Position = outPos;\n"); - p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); - p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); // TODO: Not rectangles... if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); + p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clip0); } From b9b59f7806d1b90b19f3d2b8192077ea97808cb2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 20:44:35 -0700 Subject: [PATCH 023/374] GPU: Mask away unused bits in framebuf/zbuf ptr. Lower 4 bits are ignored during rendering, and mirrors (even even the 8 bit at the top) are ignored. --- GPU/D3D11/DrawEngineD3D11.cpp | 2 +- GPU/D3D11/StateMappingD3D11.cpp | 2 +- GPU/Directx9/DrawEngineDX9.cpp | 2 +- GPU/GLES/DrawEngineGLES.cpp | 2 +- GPU/GPUState.h | 5 +++-- GPU/Vulkan/DrawEngineVulkan.cpp | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index bc3c67da1d..eff16b543b 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -340,7 +340,7 @@ void DrawEngineD3D11::DoFlush() { textureCache_->SetTexture(); gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); textureNeedsApply = true; - } else if (gstate.getTextureAddress(0) == ((gstate.getFrameBufRawAddress() | 0x04000000) & 0x3FFFFFFF)) { + } else if (gstate.getTextureAddress(0) == (gstate.getFrameBufRawAddress() | 0x04000000)) { // This catches the case of clearing a texture. (#10957) gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index f4ce888f7b..2f86aa9914 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -433,7 +433,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) { textureCache_->SetTexture(); gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); - } else if (gstate.getTextureAddress(0) == ((gstate.getFrameBufRawAddress() | 0x04000000) & 0x3FFFFFFF)) { + } else if (gstate.getTextureAddress(0) == (gstate.getFrameBufRawAddress() | 0x04000000)) { // This catches the case of clearing a texture. gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index e05df6c98c..b8d4bfa0fb 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -327,7 +327,7 @@ void DrawEngineDX9::DoFlush() { textureCache_->SetTexture(); gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); textureNeedsApply = true; - } else if (gstate.getTextureAddress(0) == ((gstate.getFrameBufRawAddress() | 0x04000000) & 0x3FFFFFFF)) { + } else if (gstate.getTextureAddress(0) == (gstate.getFrameBufRawAddress() | 0x04000000)) { // This catches the case of clearing a texture. (#10957) gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 47b10722ef..2102e46095 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -259,7 +259,7 @@ void DrawEngineGLES::DoFlush() { textureCache_->SetTexture(); gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); textureNeedsApply = true; - } else if (gstate.getTextureAddress(0) == ((gstate.getFrameBufRawAddress() | 0x04000000) & 0x3FFFFFFF)) { + } else if (gstate.getTextureAddress(0) == (gstate.getFrameBufRawAddress() | 0x04000000)) { // This catches the case of clearing a texture. (#10957) gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } diff --git a/GPU/GPUState.h b/GPU/GPUState.h index e5d5662845..2cc899c11e 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -206,12 +206,13 @@ struct GPUgstate { float boneMatrix[12 * 8]; // Eight 4x3 bone matrices. // We ignore the high bits of the framebuffer in fbwidth - even 0x08000000 renders to vRAM. - u32 getFrameBufRawAddress() const { return (fbptr & 0xFFFFFF); } + // The top bits of mirroring are also not respected, so we mask them away. + u32 getFrameBufRawAddress() const { return fbptr & 0x1FFFF0; } // 0x44000000 is uncached VRAM. u32 getFrameBufAddress() const { return 0x44000000 | getFrameBufRawAddress(); } GEBufferFormat FrameBufFormat() const { return static_cast(framebufpixformat & 3); } int FrameBufStride() const { return fbwidth&0x7FC; } - u32 getDepthBufRawAddress() const { return (zbptr & 0xFFFFFF); } + u32 getDepthBufRawAddress() const { return zbptr & 0x1FFFF0; } u32 getDepthBufAddress() const { return 0x44000000 | getDepthBufRawAddress(); } int DepthBufStride() const { return zbwidth&0x7FC; } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 2c50795472..b0e88aa0f2 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -569,7 +569,7 @@ void DrawEngineVulkan::DoFlush() { textureCache_->SetTexture(); gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); textureNeedsApply = true; - } else if (gstate.getTextureAddress(0) == ((gstate.getFrameBufRawAddress() | 0x04000000) & 0x3FFFFFFF)) { + } else if (gstate.getTextureAddress(0) == (gstate.getFrameBufRawAddress() | 0x04000000)) { // This catches the case of clearing a texture. gstate_c.Dirty(DIRTY_TEXTURE_IMAGE); } From 4a17ab8070d948b5639a55dfcf0f2321d68d0027 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 20:47:12 -0700 Subject: [PATCH 024/374] GE Debugger: Correct mask in target breakpoints. --- GPU/Debugger/Breakpoints.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GPU/Debugger/Breakpoints.cpp b/GPU/Debugger/Breakpoints.cpp index 97fbca57ee..a512980c6a 100644 --- a/GPU/Debugger/Breakpoints.cpp +++ b/GPU/Debugger/Breakpoints.cpp @@ -122,7 +122,7 @@ u32 GetAdjustedRenderTargetAddress(u32 op) { switch (cmd) { case GE_CMD_FRAMEBUFPTR: case GE_CMD_ZBUFPTR: - return op & 0x003FFFF0; + return op & 0x001FFFF0; } return (u32)-1; @@ -278,7 +278,7 @@ bool IsRenderTargetBreakpoint(u32 addr, bool &temp) { return false; } - addr &= 0x003FFFF0; + addr &= 0x001FFFF0; std::lock_guard guard(breaksLock); temp = breakRenderTargetsTemp.find(addr) != breakRenderTargetsTemp.end(); @@ -290,7 +290,7 @@ bool IsRenderTargetBreakpoint(u32 addr) { return false; } - addr &= 0x003FFFF0; + addr &= 0x001FFFF0; std::lock_guard guard(breaksLock); return breakRenderTargets.find(addr) != breakRenderTargets.end(); @@ -385,7 +385,7 @@ void AddTextureBreakpoint(u32 addr, bool temp) { void AddRenderTargetBreakpoint(u32 addr, bool temp) { std::lock_guard guard(breaksLock); - addr &= 0x003FFFF0; + addr &= 0x001FFFF0; if (temp) { if (breakRenderTargets.find(addr) == breakRenderTargets.end()) { @@ -444,7 +444,7 @@ void RemoveTextureBreakpoint(u32 addr) { void RemoveRenderTargetBreakpoint(u32 addr) { std::lock_guard guard(breaksLock); - addr &= 0x003FFFF0; + addr &= 0x001FFFF0; breakRenderTargetsTemp.erase(addr); breakRenderTargets.erase(addr); From 73040ebb8fb97f441a8a81f70e4c318071716ba5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 20:48:28 -0700 Subject: [PATCH 025/374] GE Debugger: Ignore mirrors for target in record. --- GPU/Debugger/Record.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index 56cc164c63..9947519b5e 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -322,6 +322,7 @@ static Command EmitCommandWithRAM(CommandType t, const void *p, u32 sz, u32 alig } static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) { + addr &= 0x041FFFFF; const bool isTarget = lastRenderTargets.find(addr) != lastRenderTargets.end(); bool isDirtyVRAM = false; From 58a43769988b8b02fee49716a8584039be708176 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 21:28:53 -0700 Subject: [PATCH 026/374] GPU: Normalize framebuf addresses. In VRAM, always store without mirror. In RAM, always store without cache/kernel bits. --- Core/Debugger/MemBlockInfo.cpp | 14 +++++--- GPU/Common/FramebufferManagerCommon.cpp | 44 ++++++++++++++++++------- GPU/Common/FramebufferManagerCommon.h | 4 ++- GPU/Common/TextureCacheCommon.cpp | 20 +++++------ GPU/Directx9/FramebufferManagerDX9.cpp | 2 +- GPU/GPUState.h | 2 +- GPU/Software/BinManager.cpp | 6 ++-- 7 files changed, 59 insertions(+), 33 deletions(-) diff --git a/Core/Debugger/MemBlockInfo.cpp b/Core/Debugger/MemBlockInfo.cpp index e38b6861b7..e361b63014 100644 --- a/Core/Debugger/MemBlockInfo.cpp +++ b/Core/Debugger/MemBlockInfo.cpp @@ -399,12 +399,18 @@ void FlushPendingMemInfo() { pendingNotifyMaxAddr2 = 0; } +static inline uint32_t NormalizeAddress(uint32_t addr) { + if ((addr & 0x3F000000) == 0x04000000) + return addr & 0x041FFFFF; + return addr & 0x3FFFFFFF; +} + void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const char *tagStr, size_t strLength) { if (size == 0) { return; } // Clear the uncached and kernel bits. - start &= ~0xC0000000; + start = NormalizeAddress(start); bool needFlush = false; // When the setting is off, we skip smaller info to keep things fast. @@ -450,7 +456,7 @@ void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const cha } std::vector FindMemInfo(uint32_t start, uint32_t size) { - start &= ~0xC0000000; + start = NormalizeAddress(start); if (pendingNotifyMinAddr1 < start + size && pendingNotifyMaxAddr1 >= start) FlushPendingMemInfo(); @@ -466,7 +472,7 @@ std::vector FindMemInfo(uint32_t start, uint32_t size) { } std::vector FindMemInfoByFlag(MemBlockFlags flags, uint32_t start, uint32_t size) { - start &= ~0xC0000000; + start = NormalizeAddress(start); if (pendingNotifyMinAddr1 < start + size && pendingNotifyMaxAddr1 >= start) FlushPendingMemInfo(); @@ -486,7 +492,7 @@ std::vector FindMemInfoByFlag(MemBlockFlags flags, uint32_t start, } static const char *FindWriteTagByFlag(MemBlockFlags flags, uint32_t start, uint32_t size) { - start &= ~0xC0000000; + start = NormalizeAddress(start); if (pendingNotifyMinAddr1 < start + size && pendingNotifyMaxAddr1 >= start) FlushPendingMemInfo(); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index edd7cbb9fa..f31d8c79d1 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -112,7 +112,9 @@ void FramebufferManagerCommon::BeginFrame() { } void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) { - displayFramebufPtr_ = framebuf; + displayFramebufPtr_ = framebuf & 0x3FFFFFFF; + if (Memory::IsVRAMAddress(displayFramebufPtr_)) + displayFramebufPtr_ = framebuf & 0x041FFFFF; displayStride_ = stride; displayFormat_ = format; GPUDebug::NotifyDisplay(framebuf, stride, format); @@ -121,6 +123,8 @@ void FramebufferManagerCommon::SetDisplayFramebuffer(u32 framebuf, u32 stride, G VirtualFramebuffer *FramebufferManagerCommon::GetVFBAt(u32 addr) const { addr &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(addr)) + addr &= 0x041FFFFF; VirtualFramebuffer *match = nullptr; for (auto vfb : vfbs_) { if (vfb->fb_address == addr) { @@ -134,6 +138,9 @@ VirtualFramebuffer *FramebufferManagerCommon::GetVFBAt(u32 addr) const { } VirtualFramebuffer *FramebufferManagerCommon::GetExactVFB(u32 addr, int stride, GEBufferFormat format) const { + addr &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(addr)) + addr &= 0x041FFFFF; VirtualFramebuffer *newest = nullptr; for (auto vfb : vfbs_) { if (vfb->fb_address == addr && vfb->fb_stride == stride && vfb->fb_format == format) { @@ -150,6 +157,9 @@ VirtualFramebuffer *FramebufferManagerCommon::GetExactVFB(u32 addr, int stride, } VirtualFramebuffer *FramebufferManagerCommon::ResolveVFB(u32 addr, int stride, GEBufferFormat format) { + addr &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(addr)) + addr &= 0x041FFFFF; // Find the newest one matching addr and stride. VirtualFramebuffer *newest = nullptr; for (auto vfb : vfbs_) { @@ -235,7 +245,7 @@ void FramebufferManagerCommon::EstimateDrawingSize(u32 fb_address, int fb_stride // The majority of the time, these are equal. If not, let's check what we know. u32 nearest_address = 0xFFFFFFFF; for (auto vfb : vfbs_) { - const u32 other_address = vfb->fb_address & 0x3FFFFFFF; + const u32 other_address = vfb->fb_address; if (other_address > fb_address && other_address < nearest_address) { nearest_address = other_address; } @@ -296,10 +306,11 @@ void FramebufferManagerCommon::EstimateDrawingSize(u32 fb_address, int fb_stride } void GetFramebufferHeuristicInputs(FramebufferHeuristicParams *params, const GPUgstate &gstate) { - params->fb_address = (gstate.getFrameBufRawAddress() & 0x3FFFFFFF) | 0x04000000; // GetFramebufferHeuristicInputs is only called from rendering, and thus, it's VRAM. + // GetFramebufferHeuristicInputs is only called from rendering, and thus, it's VRAM. + params->fb_address = gstate.getFrameBufRawAddress() | 0x04000000; params->fb_stride = gstate.FrameBufStride(); - params->z_address = (gstate.getDepthBufRawAddress() & 0x3FFFFFFF) | 0x04000000; + params->z_address = gstate.getDepthBufRawAddress() | 0x04000000; params->z_stride = gstate.DepthBufStride(); if (params->z_address == params->fb_address) { @@ -555,7 +566,7 @@ void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) { bool newlyUsingDepth = (currentRenderVfb_->usageFlags & FB_USAGE_RENDER_DEPTH) == 0; currentRenderVfb_->usageFlags |= FB_USAGE_RENDER_DEPTH; - uint32_t boundDepthBuffer = gstate.getDepthBufAddress() & 0x3FFFFFFF; + uint32_t boundDepthBuffer = gstate.getDepthBufRawAddress(); if (currentRenderVfb_->z_address != boundDepthBuffer) { WARN_LOG_N_TIMES(z_reassign, 5, G3D, "Framebuffer at %08x/%d has switched associated depth buffer from %08x to %08x, updating.", currentRenderVfb_->fb_address, currentRenderVfb_->fb_stride, currentRenderVfb_->z_address, boundDepthBuffer); @@ -1034,6 +1045,8 @@ void FramebufferManagerCommon::NotifyVideoUpload(u32 addr, int size, int stride, void FramebufferManagerCommon::UpdateFromMemory(u32 addr, int size) { // Take off the uncached flag from the address. Not to be confused with the start of VRAM. addr &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(addr)) + addr &= 0x041FFFFF; // TODO: Could go through all FBOs, but probably not important? // TODO: Could also check for inner changes, but video is most important. // TODO: This shouldn't care if it's a display framebuf or not, should work exactly the same. @@ -1354,9 +1367,9 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) { // Let's search for a framebuf within this range. Note that we also look for // "framebuffers" sitting in RAM (created from block transfer or similar) so we only take off the kernel // and uncached bits of the address when comparing. - const u32 addr = fbaddr & 0x3FFFFFFF; + const u32 addr = fbaddr; for (auto v : vfbs_) { - const u32 v_addr = v->fb_address & 0x3FFFFFFF; + const u32 v_addr = v->fb_address; const u32 v_size = ColorBufferByteSize(v); if (v->fb_format != displayFormat_ || v->fb_stride != displayStride_) { @@ -1628,6 +1641,10 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, dst &= 0x3FFFFFFF; src &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(dst)) + dst &= 0x041FFFFF; + if (Memory::IsVRAMAddress(src)) + src &= 0x041FFFFF; // TODO: Merge the below into FindTransferFramebuffer. // Or at least this should be like the other ones, gathering possible candidates @@ -1645,7 +1662,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, } // We only remove the kernel and uncached bits when comparing. - const u32 vfb_address = vfb->fb_address & 0x3FFFFFFF; + const u32 vfb_address = vfb->fb_address; const u32 vfb_size = ColorBufferByteSize(vfb); const u32 vfb_bpp = BufferFormatBytesPerPixel(vfb->fb_format); const u32 vfb_byteStride = vfb->fb_stride * vfb_bpp; @@ -1758,6 +1775,8 @@ std::string BlockTransferRect::ToString() const { // for depth data yet. bool FramebufferManagerCommon::FindTransferFramebuffer(u32 basePtr, int stride_pixels, int x_pixels, int y, int w_pixels, int h, int bpp, bool destination, BlockTransferRect *rect) { basePtr &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(basePtr)) + basePtr &= 0x041FFFFF; rect->vfb = nullptr; if (!stride_pixels) { @@ -1781,11 +1800,11 @@ bool FramebufferManagerCommon::FindTransferFramebuffer(u32 basePtr, int stride_p // Check for easily detected depth copies for logging purposes. // Depth copies are not that useful though because you manually need to account for swizzle, so // not sure if games will use them. - if ((vfb->z_address & 0x3FFFFFFF) == basePtr) { + if (vfb->z_address == basePtr) { WARN_LOG_N_TIMES(z_xfer, 5, G3D, "FindTransferFramebuffer: found matching depth buffer, %08x (dest=%d, bpp=%d)", basePtr, (int)destination, bpp); } - const u32 vfb_address = vfb->fb_address & 0x3FFFFFFF; + const u32 vfb_address = vfb->fb_address; const u32 vfb_size = ColorBufferByteSize(vfb); if (basePtr < vfb_address || basePtr >= vfb_address + vfb_size) { @@ -1898,7 +1917,8 @@ VirtualFramebuffer *FramebufferManagerCommon::CreateRAMFramebuffer(uint32_t fbAd // create a new one each frame. VirtualFramebuffer *vfb = new VirtualFramebuffer{}; vfb->fbo = nullptr; - vfb->fb_address = fbAddress; // NOTE - not necessarily in VRAM! + uint32_t mask = Memory::IsVRAMAddress(fbAddress) ? 0x041FFFFF : 0x3FFFFFFF; + vfb->fb_address = fbAddress & mask; // NOTE - not necessarily in VRAM! vfb->fb_stride = stride; vfb->z_address = 0; // marks that if anyone tries to render to this framebuffer, it should be dropped and recreated. vfb->z_stride = 0; @@ -2543,7 +2563,7 @@ void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int return; } - const u32 fb_address = vfb->fb_address & 0x3FFFFFFF; + const u32 fb_address = vfb->fb_address; Draw::DataFormat destFormat = channel == RASTER_COLOR ? GEFormatToThin3D(vfb->fb_format) : GEFormatToThin3D(GE_FORMAT_DEPTH16); const int dstBpp = (int)DataFormatSizeInBytes(destFormat); diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 20fd15f87a..d4bd905f0d 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -355,7 +355,9 @@ public: bool MayIntersectFramebuffer(u32 start) const { // Clear the cache/kernel bits. - start = start & 0x3FFFFFFF; + start &= 0x3FFFFFFF; + if (Memory::IsVRAMAddress(start)) + start &= 0x041FFFFF; // Most games only have two framebuffers at the start. if (start >= framebufRangeEnd_ || start < PSP_GetVidMemBase()) { return false; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index d55f890f64..f0c0d4145c 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -688,7 +688,7 @@ bool TextureCacheCommon::GetBestFramebufferCandidate(const TextureDefinition &en // Should avoid problems when pingponging two nearby buffers, like in Wipeout Pure in #15927. if (candidate.channel == RASTER_COLOR && (candidate.match.yOffset != 0 || candidate.match.xOffset != 0) && - (candidate.fb->fb_address & 0x1FFFFF) == (gstate.getFrameBufAddress() & 0x1FFFFF)) { + candidate.fb->fb_address == (gstate.getFrameBufRawAddress() | 0x04000000)) { relevancy -= 2; } @@ -845,10 +845,8 @@ void TextureCacheCommon::HandleTextureChange(TexCacheEntry *const entry, const c } void TextureCacheCommon::NotifyFramebuffer(VirtualFramebuffer *framebuffer, FramebufferNotification msg) { - const u32 mirrorMask = 0x00600000; const u32 fb_addr = framebuffer->fb_address; - - const u32 z_addr = framebuffer->z_address & ~mirrorMask; // Probably unnecessary. + const u32 z_addr = framebuffer->z_address; const u32 fb_bpp = BufferFormatBytesPerPixel(framebuffer->fb_format); const u32 z_bpp = 2; // No other format exists. @@ -931,7 +929,7 @@ bool TextureCacheCommon::MatchFramebuffer( uint32_t fb_stride_in_bytes = fb_stride * BufferFormatBytesPerPixel(fb_format); uint32_t tex_stride_in_bytes = entry.bufw * textureBitsPerPixel[entry.format] / 8; // Note, we're looking up bits here so need to divide by 8. - u32 addr = fb_address & 0x3FFFFFFF; + u32 addr = fb_address; u32 texaddr = entry.addr + texaddrOffset; bool texInVRAM = Memory::IsVRAMAddress(texaddr); @@ -943,10 +941,10 @@ bool TextureCacheCommon::MatchFramebuffer( } if (texInVRAM) { - const u32 mirrorMask = 0x00600000; + const u32 mirrorMask = 0x041FFFFF; - addr &= ~mirrorMask; - texaddr &= ~mirrorMask; + addr &= mirrorMask; + texaddr &= mirrorMask; } const bool noOffset = texaddr == addr; @@ -1205,8 +1203,8 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) { if (Memory::IsValidAddress(clutAddr)) { if (Memory::IsVRAMAddress(clutAddr)) { - // Clear the uncached bit, etc. to match framebuffers. - const u32 clutLoadAddr = clutAddr & 0x3FFFFFFF; + // Clear the uncached and mirror bits, etc. to match framebuffers. + const u32 clutLoadAddr = clutAddr & 0x041FFFFF; const u32 clutLoadEnd = clutLoadAddr + loadBytes; static const u32 MAX_CLUT_OFFSET = 4096; @@ -1217,7 +1215,7 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) { VirtualFramebuffer *chosenFramebuffer = nullptr; for (VirtualFramebuffer *framebuffer : framebuffers) { - const u32 fb_address = framebuffer->fb_address & 0x3FFFFFFF; + const u32 fb_address = framebuffer->fb_address; const u32 fb_bpp = BufferFormatBytesPerPixel(framebuffer->fb_format); int offset = clutLoadAddr - fb_address; diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index c3d9489b93..f0281c400e 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -140,7 +140,7 @@ return; } - const u32 fb_address = vfb->fb_address & 0x3FFFFFFF; + const u32 fb_address = vfb->fb_address; const int dstBpp = vfb->fb_format == GE_FORMAT_8888 ? 4 : 2; // We always need to convert from the framebuffer native format. diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 2cc899c11e..fa9d4b575c 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -213,7 +213,7 @@ struct GPUgstate { GEBufferFormat FrameBufFormat() const { return static_cast(framebufpixformat & 3); } int FrameBufStride() const { return fbwidth&0x7FC; } u32 getDepthBufRawAddress() const { return zbptr & 0x1FFFF0; } - u32 getDepthBufAddress() const { return 0x44000000 | getDepthBufRawAddress(); } + u32 getDepthBufAddress() const { return 0x44600000 | getDepthBufRawAddress(); } int DepthBufStride() const { return zbwidth&0x7FC; } // Pixel Pipeline diff --git a/GPU/Software/BinManager.cpp b/GPU/Software/BinManager.cpp index d36c8137b3..9a008e6658 100644 --- a/GPU/Software/BinManager.cpp +++ b/GPU/Software/BinManager.cpp @@ -286,7 +286,7 @@ void BinManager::MarkPendingWrites(const Rasterizer::RasterizerState &state) { DrawingCoords scissorTL(gstate.getScissorX1(), gstate.getScissorY1()); DrawingCoords scissorBR(std::min(gstate.getScissorX2(), gstate.getRegionX2()), std::min(gstate.getScissorY2(), gstate.getRegionY2())); - constexpr uint32_t mirrorMask = 0x0FFFFFFF & ~0x00600000; + constexpr uint32_t mirrorMask = 0x041FFFFF; const uint32_t bpp = state.pixelID.FBFormat() == GE_FORMAT_8888 ? 4 : 2; pendingWrites_[0].Expand(gstate.getFrameBufAddress() & mirrorMask, bpp, gstate.FrameBufStride(), scissorTL, scissorBR); if (state.pixelID.depthWrite) @@ -538,7 +538,7 @@ bool BinManager::HasPendingWrite(uint32_t start, uint32_t stride, uint32_t w, ui if (!Memory::IsVRAMAddress(start)) return false; // Ignore mirrors for overlap detection. - start &= 0x0FFFFFFF & ~0x00600000; + start &= 0x041FFFFF; uint32_t size = stride * (h - 1) + w; for (const auto &range : pendingWrites_) { @@ -569,7 +569,7 @@ bool BinManager::HasPendingWrite(uint32_t start, uint32_t stride, uint32_t w, ui bool BinManager::HasPendingRead(uint32_t start, uint32_t stride, uint32_t w, uint32_t h) { if (Memory::IsVRAMAddress(start)) { // Ignore VRAM mirrors. - start &= 0x0FFFFFFF & ~0x00600000; + start &= 0x041FFFFF; } else { // Ignore only regular RAM mirrors. start &= 0x3FFFFFFF; From 0be891c7ff830f1bdc68af5b99e9baa916f27c5a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Oct 2022 21:31:07 -0700 Subject: [PATCH 027/374] softgpu: Minor opt, ignore unused z_stride. --- GPU/Software/FuncId.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Software/FuncId.cpp b/GPU/Software/FuncId.cpp index 90a51778ae..e1520b8d72 100644 --- a/GPU/Software/FuncId.cpp +++ b/GPU/Software/FuncId.cpp @@ -56,7 +56,7 @@ void ComputePixelFuncID(PixelFuncID *id) { // Dither happens even in clear mode. id->dithering = gstate.isDitherEnabled(); id->fbFormat = gstate.FrameBufFormat(); - id->useStandardStride = gstate.FrameBufStride() == 512 && gstate.DepthBufStride() == 512; + id->useStandardStride = gstate.FrameBufStride() == 512; id->applyColorWriteMask = gstate.getColorMask() != 0; id->clearMode = gstate.isModeClear(); @@ -187,6 +187,9 @@ void ComputePixelFuncID(PixelFuncID *id) { } } + if (id->useStandardStride && (id->depthTestFunc != GE_COMP_ALWAYS || id->depthWrite)) + id->useStandardStride = gstate.DepthBufStride() == 512; + // Cache some values for later convenience. if (id->dithering) { for (int y = 0; y < 4; ++y) { From 09f0c0c8fd04584a565c3a7ded92416583a6a2fa Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 3 Oct 2022 10:47:55 +0300 Subject: [PATCH 028/374] Fixed syntax accessing method reviewed by Unknown W. Brackets Signed-off-by: lainon --- Common/GPU/D3D9/D3D9ShaderCompiler.cpp | 2 +- Common/GPU/ShaderTranslation.cpp | 2 +- Core/Debugger/WebSocket/WebSocketUtils.cpp | 2 +- Core/Loaders.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp index 5a647196fe..d3821066aa 100644 --- a/Common/GPU/D3D9/D3D9ShaderCompiler.cpp +++ b/Common/GPU/D3D9/D3D9ShaderCompiler.cpp @@ -47,7 +47,7 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std: pShaderCode = nullptr; } } else { - (*errorMessage).clear(); + errorMessage->clear(); } return pShaderCode; diff --git a/Common/GPU/ShaderTranslation.cpp b/Common/GPU/ShaderTranslation.cpp index 84cd69afe5..42e540a40f 100644 --- a/Common/GPU/ShaderTranslation.cpp +++ b/Common/GPU/ShaderTranslation.cpp @@ -233,7 +233,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, const ShaderLan return false; #endif - (*errorMessage).clear(); + errorMessage->clear(); glslang::TProgram program; const char *shaderStrings[1]{}; diff --git a/Core/Debugger/WebSocket/WebSocketUtils.cpp b/Core/Debugger/WebSocket/WebSocketUtils.cpp index be1a1371a9..3ba5984f4b 100644 --- a/Core/Debugger/WebSocket/WebSocketUtils.cpp +++ b/Core/Debugger/WebSocket/WebSocketUtils.cpp @@ -262,7 +262,7 @@ bool DebuggerRequest::ParamString(const char *name, std::string *out, DebuggerPa return true; } else if (tag == JSON_NULL) { if (required) { - (*out).clear(); + out->clear(); } return true; } else if (tag == JSON_NUMBER) { diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index 02625a16c5..37722fe0cf 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -60,7 +60,7 @@ FileLoader *ConstructFileLoader(const Path &filename) { // TODO : improve, look in the file more IdentifiedFileType Identify_File(FileLoader *fileLoader, std::string *errorString) { - (*errorString).clear(); + errorString->clear(); if (fileLoader == nullptr) { *errorString = "Invalid fileLoader"; return IdentifiedFileType::ERROR_IDENTIFYING; From ba78854759f96bebfc9c5875146e19af26f304a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Oct 2022 11:20:36 +0200 Subject: [PATCH 029/374] Improve Vulkan profiler (show framebuffer tag for render passes) --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 428d66e2cc..9ac19c7051 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -889,7 +889,7 @@ std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { case RP_TYPE_COLOR_DEPTH_INPUT: renderCmd = "RENDER_DEPTH_INPUT"; break; default: renderCmd = "N/A"; } - snprintf(buffer, sizeof(buffer), "%s %s (draws: %d, %dx%d/%dx%d, fb: %p, )", renderCmd, step.tag, step.render.numDraws, actual_w, actual_h, w, h, step.render.framebuffer); + snprintf(buffer, sizeof(buffer), "%s %s %s (draws: %d, %dx%d/%dx%d)", renderCmd, step.tag, step.render.framebuffer ? step.render.framebuffer->Tag() : "", step.render.numDraws, actual_w, actual_h, w, h); break; } case VKRStepType::COPY: @@ -899,7 +899,7 @@ std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { snprintf(buffer, sizeof(buffer), "BLIT '%s' %s -> %s (%dx%d->%dx%d, %s)", step.tag, step.copy.src->Tag(), step.copy.dst->Tag(), step.blit.srcRect.extent.width, step.blit.srcRect.extent.height, step.blit.dstRect.extent.width, step.blit.dstRect.extent.height, AspectToString(step.blit.aspectMask)); break; case VKRStepType::READBACK: - snprintf(buffer, sizeof(buffer), "READBACK '%s' %s (%dx%d, %s)", step.tag, step.readback.src->Tag(), step.readback.srcRect.extent.width, step.readback.srcRect.extent.height, AspectToString(step.readback.aspectMask)); + snprintf(buffer, sizeof(buffer), "READBACK '%s' %s (%dx%d, %s)", step.tag, step.readback.src ? step.readback.src->Tag() : "(backbuffer)", step.readback.srcRect.extent.width, step.readback.srcRect.extent.height, AspectToString(step.readback.aspectMask)); break; case VKRStepType::READBACK_IMAGE: snprintf(buffer, sizeof(buffer), "READBACK_IMAGE '%s' (%dx%d)", step.tag, step.readback_image.srcRect.extent.width, step.readback_image.srcRect.extent.height); From 2207c1271a0f8f37df1dbf353514494ce0d0d5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Oct 2022 12:13:11 +0200 Subject: [PATCH 030/374] Fix validation error with the GPU profiler --- Common/GPU/Vulkan/VulkanFrameData.cpp | 5 +++++ Common/GPU/Vulkan/VulkanFrameData.h | 2 ++ Common/GPU/Vulkan/VulkanRenderManager.cpp | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanFrameData.cpp b/Common/GPU/Vulkan/VulkanFrameData.cpp index 447630e0af..ab74478396 100644 --- a/Common/GPU/Vulkan/VulkanFrameData.cpp +++ b/Common/GPU/Vulkan/VulkanFrameData.cpp @@ -110,6 +110,11 @@ VkCommandBuffer FrameData::GetInitCmd(VulkanContext *vulkan) { if (res != VK_SUCCESS) { return VK_NULL_HANDLE; } + + // Good spot to reset the query pool. + vkCmdResetQueryPool(initCmd, profile.queryPool, 0, MAX_TIMESTAMP_QUERIES); + vkCmdWriteTimestamp(initCmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, profile.queryPool, 0); + hasInitCommands = true; } return initCmd; diff --git a/Common/GPU/Vulkan/VulkanFrameData.h b/Common/GPU/Vulkan/VulkanFrameData.h index 049f8d765c..88d4c185d2 100644 --- a/Common/GPU/Vulkan/VulkanFrameData.h +++ b/Common/GPU/Vulkan/VulkanFrameData.h @@ -80,6 +80,8 @@ struct FrameData { void AcquireNextImage(VulkanContext *vulkan, FrameDataShared &shared); VkResult QueuePresent(VulkanContext *vulkan, FrameDataShared &shared); + + // Generally called from the main thread, unlike most of the rest. VkCommandBuffer GetInitCmd(VulkanContext *vulkan); // This will only submit if we are actually recording init commands. diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 344b059bbc..3343bd889f 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -609,8 +609,6 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile frameData.profile.timestampDescriptions.push_back("initCmd Begin"); frameData.profile.timestampDescriptions.push_back("initCmd"); VkCommandBuffer initCmd = GetInitCmd(); - vkCmdResetQueryPool(initCmd, frameData.profile.queryPool, 0, MAX_TIMESTAMP_QUERIES); - vkCmdWriteTimestamp(initCmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, frameData.profile.queryPool, 0); } } From e025629d4bd7d690db1441518ee00d2f7e027960 Mon Sep 17 00:00:00 2001 From: Kingcom Date: Mon, 3 Oct 2022 15:50:33 +0200 Subject: [PATCH 031/374] Attempt to fix libretro build --- .gitlab-ci.yml | 2 +- libretro/Makefile | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8648726fd7..32ee69b692 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ # Core definitions variables: - GIT_SUBMODULE_STRATEGY: normal + GIT_SUBMODULE_STRATEGY: recursive .core-defs: variables: diff --git a/libretro/Makefile b/libretro/Makefile index 1fd4f48632..088ad22267 100644 --- a/libretro/Makefile +++ b/libretro/Makefile @@ -332,7 +332,7 @@ else ifneq (,$(findstring windows_msvc2017,$(platform))) endif CFLAGS += $(MSVC2017CompileFlags) -nologo - CXXFLAGS += $(MSVC2017CompileFlags) -nologo -EHsc + CXXFLAGS += $(MSVC2017CompileFlags) -nologo -EHsc -DARMIPS_USE_STD_FILESYSTEM TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix)) @@ -443,7 +443,7 @@ else ifneq (,$(findstring windows_msvc2019,$(platform))) endif CFLAGS += $(MSVC2019CompileFlags) -nologo - CXXFLAGS += $(MSVC2019CompileFlags) -nologo -EHsc + CXXFLAGS += $(MSVC2019CompileFlags) -nologo -EHsc -DARMIPS_USE_STD_FILESYSTEM TargetArchMoniker = $(subst $(WinPartition)_,,$(PlatformSuffix)) @@ -537,7 +537,7 @@ else ifneq (,$(findstring windows_msvc2019,$(platform))) else ifneq (,$(findstring win,$(platform))) TARGET := $(TARGET_NAME)_libretro.dll CFLAGS += -D_UNICODE -DUNICODE - CXXFLAGS += -fpermissive -Wno-multichar -D_UNICODE -DUNICODE + CXXFLAGS += -fpermissive -Wno-multichar -D_UNICODE -DUNICODE -DARMIPS_USE_STD_FILESYSTEM LDFLAGS += -shared -Wl,--no-undefined -static-libgcc -static-libstdc++ -Wl,--version-script=link.T -lwinmm -lgdi32 -lwsock32 -lws2_32 -ld3d9 -ld3dx9 GL_LIB := -lopengl32 PLATFORM_EXT = win32 @@ -578,6 +578,8 @@ endif ifeq (,$(findstring msvc,$(platform))) CXXFLAGS += -std=c++17 +else + CXXFLAGS += -std:c++17 endif ### Finalize ### From 49097d359b8964adf476ad3425d6efe40619b290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Oct 2022 16:36:03 +0200 Subject: [PATCH 032/374] More libretro buildfix, thanks stuken --- libretro/Makefile.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 8eed277932..56c748b52a 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -210,6 +210,9 @@ SOURCES_CXX += \ SOURCES_CXX += $(EXTDIR)/cityhash/city.cpp +SOURCES_CXX += \ + $(EXTDIR)/armips/Core/Types.cpp + SOURCES_CXX += \ $(COMMONDIR)/Crypto/md5.cpp \ $(COMMONDIR)/Crypto/sha1.cpp \ From 973d0435c1e38b44430bd5a0c54bb5ee4f3a5f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Oct 2022 19:02:16 +0200 Subject: [PATCH 033/374] Fix another crash with non-buffered rendering --- GPU/Common/FramebufferManagerCommon.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index aa2bafe54a..109dcfe675 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -574,9 +574,12 @@ void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) { // Technically, here we should copy away the depth buffer to another framebuffer that uses that z_address, or maybe // even write it back to RAM. However, this is rare. Silent Hill is one example, see #16126. currentRenderVfb_->z_address = boundDepthBuffer; - char tag[128]; - FormatFramebufferName(currentRenderVfb_, tag, sizeof(tag)); - currentRenderVfb_->fbo->UpdateTag(tag); + + if (currentRenderVfb_->fbo) { + char tag[128]; + FormatFramebufferName(currentRenderVfb_, tag, sizeof(tag)); + currentRenderVfb_->fbo->UpdateTag(tag); + } } // If this first draw call is anything other than a clear, "resolve" the depth buffer, From 1469a32a9da3ee94f0cb6cb14fb96410918287ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Oct 2022 19:06:02 +0200 Subject: [PATCH 034/374] Vertex decoder: Add fallback for non-SSE4.1 See #16157 --- GPU/Common/VertexDecoderX86.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/GPU/Common/VertexDecoderX86.cpp b/GPU/Common/VertexDecoderX86.cpp index 13aabe2df3..3618071c76 100644 --- a/GPU/Common/VertexDecoderX86.cpp +++ b/GPU/Common/VertexDecoderX86.cpp @@ -1391,7 +1391,13 @@ void VertexDecoderJitCache::Jit_PosFloatThrough() { CVTTPS2DQ(fpScratchReg, R(fpScratchReg)); // Use pack to saturate to 0,65535. - PACKUSDW(fpScratchReg, R(fpScratchReg)); + if (cpu_info.bSSE4_1) { + PACKUSDW(fpScratchReg, R(fpScratchReg)); + } else { + PSLLD(fpScratchReg, 16); + PSRAD(fpScratchReg, 16); + PACKSSDW(fpScratchReg, R(fpScratchReg)); + } PUNPCKLWD(fpScratchReg, R(fpScratchReg2)); CVTDQ2PS(fpScratchReg, R(fpScratchReg)); From 95e6eaa6019ec530e0399ebb3670a23c1b91ece4 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 4 Oct 2022 08:29:23 +0800 Subject: [PATCH 035/374] Add crc calculation in loading module --- Core/HLE/sceKernelModule.cpp | 6 +++++- UI/GameScreen.cpp | 11 +++++------ UI/GameScreen.h | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index a32604e928..5029e22ade 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -67,6 +67,7 @@ #include "GPU/GPU.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" +#include "UI/GameScreen.h" enum { PSP_THREAD_ATTR_KERNEL = 0x00001000, @@ -1144,6 +1145,9 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) { } static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) { + u32 crc = crc32(0, Z_NULL, 0); + crc = crc32(crc, ptr, elfSize); + const std::string crcstring = int2hexstr(crc); PSPModule *module = new PSPModule(); kernelObjects.Create(module); loadedModules.insert(module->GetUID()); @@ -1170,7 +1174,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load if (IsHLEVersionedModule(head->modname)) { int ver = (head->module_ver_hi << 8) | head->module_ver_lo; - INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x", head->modname, ver, head->devkitversion); + INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x, crc %s", head->modname, ver, head->devkitversion, crcstring.c_str()); reportedModule = true; if (!strcmp(head->modname, "sceMpeg_library")) { diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index edf519f46b..114b6e7a35 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -44,6 +44,7 @@ #include "UI/MainScreen.h" #include "UI/BackgroundAudio.h" #include "Core/Reporting.h" +#include GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { g_BackgroundAudio.SetGame(gamePath); @@ -55,12 +56,10 @@ GameScreen::~GameScreen() { } } -template std::string int2hexstr(I w, size_t hex_len = sizeof(I) << 1) { - static const char* digits = "0123456789ABCDEF"; - std::string rc(hex_len, '0'); - for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4) - rc[i] = digits[(w >> j) & 0x0f]; - return rc; +std::string int2hexstr(const int a) { + std::stringstream stream; + stream << std::hex << a; + return stream.str(); } void GameScreen::update() { diff --git a/UI/GameScreen.h b/UI/GameScreen.h index cff0c48366..1018acbf10 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -29,6 +29,8 @@ // Uses GameInfoCache heavily to implement the functionality. // Should possibly merge this with the PauseScreen. +std::string int2hexstr(const int a); + class GameScreen : public UIDialogScreenWithGameBackground { public: GameScreen(const Path &gamePath); From bbe9c410989b37059b6cba8a72886bb890472a2f Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 4 Oct 2022 09:21:11 +0800 Subject: [PATCH 036/374] Add crc record into mpeg module --- Core/HLE/sceKernelModule.cpp | 4 ++-- Core/HLE/sceMpeg.cpp | 17 +++++++++++++---- Core/HLE/sceMpeg.h | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 5029e22ade..c53811c752 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1178,7 +1178,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load reportedModule = true; if (!strcmp(head->modname, "sceMpeg_library")) { - __MpegLoadModule(ver); + __MpegLoadModule(ver, crcstring); } if (!strcmp(head->modname, "scePsmfP_library") || !strcmp(head->modname, "scePsmfPlayer")) { __PsmfPlayerLoadModule(head->devkitversion); @@ -1614,7 +1614,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x", modinfo->name, modinfo->moduleVersion, devkitVersion); if (!strcmp(modinfo->name, "sceMpeg_library")) { - __MpegLoadModule(modinfo->moduleVersion); + __MpegLoadModule(modinfo->moduleVersion, crcstring); } if (!strcmp(modinfo->name, "scePsmfP_library") || !strcmp(modinfo->name, "scePsmfPlayer")) { __PsmfPlayerLoadModule(devkitVersion); diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 0d7a81b758..cb9fd9aba1 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -258,7 +258,8 @@ struct MpegContext { }; static bool isMpegInit; -static int mpegLibVersion; +static int mpegLibVersion = 0; +static std::string mpegLibCrcstring = "null"; static u32 streamIdGen; static int actionPostPut; static std::map mpegMap; @@ -403,7 +404,7 @@ void __MpegInit() { } void __MpegDoState(PointerWrap &p) { - auto s = p.Section("sceMpeg", 1, 3); + auto s = p.Section("sceMpeg", 1, 4); if (!s) return; @@ -421,7 +422,14 @@ void __MpegDoState(PointerWrap &p) { ringbufferPutPacketsAdded = 0; } else { Do(p, ringbufferPutPacketsAdded); + } + if (s < 4) { + mpegLibCrcstring = "null"; } + else { + Do(p, mpegLibCrcstring); + } + Do(p, streamIdGen); Do(p, mpegLibVersion); } @@ -440,8 +448,9 @@ void __MpegShutdown() { mpegMap.clear(); } -void __MpegLoadModule(int version) { +void __MpegLoadModule(int version,std::string crcstr) { mpegLibVersion = version; + mpegLibCrcstring = crcstr; } static u32 sceMpegInit() { @@ -450,7 +459,7 @@ static u32 sceMpegInit() { // TODO: Need to properly hook module load/unload for this to work right. //return ERROR_MPEG_ALREADY_INIT; } else { - INFO_LOG(ME, "sceMpegInit()"); + INFO_LOG(ME, "sceMpegInit(), mpegLibVersion 0x%0x, mpegLibcrc %s", mpegLibVersion, mpegLibCrcstring.c_str()); } isMpegInit = true; return hleDelayResult(0, "mpeg init", 750); diff --git a/Core/HLE/sceMpeg.h b/Core/HLE/sceMpeg.h index aded1238cc..538c60c9a8 100644 --- a/Core/HLE/sceMpeg.h +++ b/Core/HLE/sceMpeg.h @@ -79,7 +79,7 @@ void __MpegInit(); void __MpegDoState(PointerWrap &p); void __MpegShutdown(); -void __MpegLoadModule(int version); +void __MpegLoadModule(int version,std::string crcstr); void Register_sceMpeg(); From af93a7185bb02a677deca4496df83c7e98542c9b Mon Sep 17 00:00:00 2001 From: sum2012 Date: Tue, 4 Oct 2022 09:50:33 +0800 Subject: [PATCH 037/374] Add crc record to psmfplayer --- Core/HLE/sceKernelModule.cpp | 4 ++-- Core/HLE/scePsmf.cpp | 14 +++++++++++--- Core/HLE/scePsmf.h | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index c53811c752..f542354805 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1181,7 +1181,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load __MpegLoadModule(ver, crcstring); } if (!strcmp(head->modname, "scePsmfP_library") || !strcmp(head->modname, "scePsmfPlayer")) { - __PsmfPlayerLoadModule(head->devkitversion); + __PsmfPlayerLoadModule(head->devkitversion, crcstring); } } @@ -1617,7 +1617,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load __MpegLoadModule(modinfo->moduleVersion, crcstring); } if (!strcmp(modinfo->name, "scePsmfP_library") || !strcmp(modinfo->name, "scePsmfPlayer")) { - __PsmfPlayerLoadModule(devkitVersion); + __PsmfPlayerLoadModule(devkitVersion, crcstring); } } diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 393469f029..9b81e83a96 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -59,6 +59,7 @@ static const int audioSamplesBytes = audioSamples * 4; static int videoPixelMode = GE_CMODE_32BIT_ABGR8888; static int videoLoopStatus = PSMF_PLAYER_CONFIG_NO_LOOP; static int psmfPlayerLibVersion = 0; +static std::string psmfPlayerLibcrcstring = "null"; int eventPsmfPlayerStatusChange = -1; @@ -696,8 +697,9 @@ void __PsmfInit() { eventPsmfPlayerStatusChange = CoreTiming::RegisterEvent("PsmfPlayerStatusChange", &__PsmfPlayerStatusChange); } -void __PsmfPlayerLoadModule(int devkitVersion) { +void __PsmfPlayerLoadModule(int devkitVersion, std::string crcstr) { psmfPlayerLibVersion = devkitVersion; + psmfPlayerLibcrcstring = crcstr; } void __PsmfDoState(PointerWrap &p) { @@ -722,6 +724,11 @@ void __PsmfPlayerDoState(PointerWrap &p) { Do(p, eventPsmfPlayerStatusChange); } CoreTiming::RestoreRegisterEvent(eventPsmfPlayerStatusChange, "PsmfPlayerStatusChangeEvent", &__PsmfPlayerStatusChange); + if (s < 3) { + psmfPlayerLibcrcstring = "null"; + } else { + Do(p, psmfPlayerLibcrcstring); + } if (s < 2) { // Assume the latest, which is what we were emulating before. psmfPlayerLibVersion = 0x06060010; @@ -1157,7 +1164,8 @@ static int scePsmfPlayerCreate(u32 psmfPlayer, u32 dataPtr) { int delayUs = 20000; DelayPsmfStateChange(psmfPlayer, PSMF_PLAYER_STATUS_INIT, delayUs); - return hleLogSuccessInfoI(ME, hleDelayResult(0, "player create", delayUs)); + INFO_LOG(ME, "psmfplayer create, psmfPlayerLibVersion 0x%0x, psmfPlayerLibcrcstring %s", psmfPlayerLibVersion, psmfPlayerLibcrcstring.c_str()); + return hleDelayResult(0, "player create", delayUs); } static int scePsmfPlayerStop(u32 psmfPlayer) { @@ -1427,7 +1435,7 @@ static int scePsmfPlayerStart(u32 psmfPlayer, u32 psmfPlayerData, int initPts) psmfplayer->playMode = playerData->playMode; psmfplayer->playSpeed = playerData->playSpeed; - WARN_LOG(ME, "scePsmfPlayerStart(%08x, %08x, %d,(mode %d, speed %d)", psmfPlayer, psmfPlayerData, initPts, playerData->playMode, playerData->playSpeed); + WARN_LOG(ME, "scePsmfPlayerStart(%08x, %08x, %d (mode %d, speed %d)", psmfPlayer, psmfPlayerData, initPts, playerData->playMode, playerData->playSpeed); // Does not alter current pts, it just catches up when Update()/etc. get there. diff --git a/Core/HLE/scePsmf.h b/Core/HLE/scePsmf.h index 3248962470..8e201adade 100644 --- a/Core/HLE/scePsmf.h +++ b/Core/HLE/scePsmf.h @@ -21,7 +21,7 @@ void Register_scePsmf(); void Register_scePsmfPlayer(); void __PsmfInit(); -void __PsmfPlayerLoadModule(int devkitVersion); +void __PsmfPlayerLoadModule(int devkitVersion,std::string crcstr); void __PsmfDoState(PointerWrap &p); void __PsmfPlayerDoState(PointerWrap &p); void __PsmfShutdown(); From a1efed31b9dee4a477506b45cf5ccced06a0b12d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 3 Oct 2022 20:17:25 -0700 Subject: [PATCH 038/374] GPU: Use flags to fix triggered upload/download. No longer using mirror hacks. --- GPU/Common/FramebufferManagerCommon.cpp | 8 ++++---- GPU/Common/FramebufferManagerCommon.h | 2 +- GPU/Debugger/Record.cpp | 7 ++++--- GPU/GPUCommon.cpp | 17 +++++++---------- GPU/GPUCommon.h | 2 +- GPU/GPUInterface.h | 12 +++++++++++- GPU/Software/SoftGpu.cpp | 6 +++--- GPU/Software/SoftGpu.h | 2 +- 8 files changed, 32 insertions(+), 24 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f31d8c79d1..878b677466 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1634,7 +1634,7 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, // This is called from detected memcopies and framebuffer initialization from VRAM. Not block transfers. // MotoGP goes this path so we need to catch those copies here. -bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, bool isMemset, u32 skipDrawReason) { +bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, GPUCopyFlag flags, u32 skipDrawReason) { if (size == 0) { return false; } @@ -1728,7 +1728,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, dstBuffer->last_frame_used = gpuStats.numFlips; } - if (dstBuffer && srcBuffer && !isMemset) { + if (dstBuffer && srcBuffer && !(flags & GPUCopyFlag::MEMSET) && !(flags & GPUCopyFlag::FORCE_SRC_MEM) && !(flags & GPUCopyFlag::FORCE_DST_MEM)) { if (srcBuffer == dstBuffer) { WARN_LOG_ONCE(dstsrccpy, G3D, "Intra-buffer memcpy (not supported) %08x -> %08x (size: %x)", src, dst, size); } else { @@ -1739,8 +1739,8 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, RebindFramebuffer("RebindFramebuffer - Inter-buffer memcpy"); } return false; - } else if (dstBuffer) { - if (isMemset) { + } else if (dstBuffer && !(flags & GPUCopyFlag::FORCE_DST_MEM)) { + if (flags & GPUCopyFlag::MEMSET) { gpuStats.numClears++; } WARN_LOG_ONCE(btucpy, G3D, "Memcpy fbo upload %08x -> %08x (size: %x)", src, dst, size); diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index d4bd905f0d..b3bd21d7c9 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -306,7 +306,7 @@ public: void CopyDisplayToOutput(bool reallyDirty); - bool NotifyFramebufferCopy(u32 src, u32 dest, int size, bool isMemset, u32 skipDrawReason); + bool NotifyFramebufferCopy(u32 src, u32 dest, int size, GPUCopyFlag flags, u32 skipDrawReason); void NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt); void UpdateFromMemory(u32 addr, int size); void ApplyClearToMemory(int x1, int y1, int x2, int y2, u32 clearColor); diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index 9947519b5e..6058546b0f 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -691,10 +691,11 @@ void NotifyUpload(u32 dest, u32 sz) { return; } - CheckEdramTrans(); - NotifyMemcpy(dest, dest, sz); - if (Memory::IsVRAMAddress(dest)) + if (Memory::IsVRAMAddress(dest)) { + // This also checks the edram translation value. + NotifyMemcpy(dest, dest, sz); DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); + } } static bool HasDrawCommands() { diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index a44fb47572..4c43b0a992 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3046,10 +3046,10 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) { cyclesExecuted += ((height * width * bpp) * 16) / 10; } -bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) { +bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags) { // Track stray copies of a framebuffer in RAM. MotoGP does this. if (framebufferManager_->MayIntersectFramebuffer(src) || framebufferManager_->MayIntersectFramebuffer(dest)) { - if (!framebufferManager_->NotifyFramebufferCopy(src, dest, size, false, gstate_c.skipDrawReason)) { + if (!framebufferManager_->NotifyFramebufferCopy(src, dest, size, flags, gstate_c.skipDrawReason)) { // We use a little hack for PerformMemoryDownload/PerformMemoryUpload using a VRAM mirror. // Since they're identical we don't need to copy. if (!Memory::IsVRAMAddress(dest) || (dest ^ 0x00400000) != src) { @@ -3071,7 +3071,8 @@ bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) { NotifyMemInfo(MemBlockFlags::WRITE, dest, size, tag.c_str(), tag.size()); } InvalidateCache(dest, size, GPU_INVALIDATE_HINT); - GPURecord::NotifyMemcpy(dest, src, size); + if (!(flags & GPUCopyFlag::DEBUG_NOTIFIED)) + GPURecord::NotifyMemcpy(dest, src, size); return false; } @@ -3079,7 +3080,7 @@ bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) { // This may indicate a memset, usually to 0, of a framebuffer. if (framebufferManager_->MayIntersectFramebuffer(dest)) { Memory::Memset(dest, v, size, "GPUMemset"); - if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, true, gstate_c.skipDrawReason)) { + if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, GPUCopyFlag::MEMSET, gstate_c.skipDrawReason)) { InvalidateCache(dest, size, GPU_INVALIDATE_HINT); } return true; @@ -3093,20 +3094,16 @@ bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) { } bool GPUCommon::PerformMemoryDownload(u32 dest, int size) { - // Cheat a bit to force a download of the framebuffer. - // VRAM + 0x00400000 is simply a VRAM mirror. if (Memory::IsVRAMAddress(dest)) { - return PerformMemoryCopy(dest ^ 0x00400000, dest, size); + return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_DST_MEM); } return false; } bool GPUCommon::PerformMemoryUpload(u32 dest, int size) { - // Cheat a bit to force an upload of the framebuffer. - // VRAM + 0x00400000 is simply a VRAM mirror. if (Memory::IsVRAMAddress(dest)) { GPURecord::NotifyUpload(dest, size); - return PerformMemoryCopy(dest, dest ^ 0x00400000, size); + return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_SRC_MEM | GPUCopyFlag::DEBUG_NOTIFIED); } return false; } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 78f7b15cef..3c478e2cec 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -124,7 +124,7 @@ public: void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override; void CopyDisplayToOutput(bool reallyDirty) override = 0; void InitClear() override = 0; - bool PerformMemoryCopy(u32 dest, u32 src, int size) override; + bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; bool PerformMemoryDownload(u32 dest, int size) override; bool PerformMemoryUpload(u32 dest, int size) override; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index e0c5931326..e7cf2f9af6 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -114,6 +114,16 @@ enum class StencilUpload { }; ENUM_CLASS_BITOPS(StencilUpload); +enum class GPUCopyFlag { + NONE = 0, + FORCE_SRC_MEM = 1, + FORCE_DST_MEM = 2, + // Note: implies src == dst and FORCE_SRC_MEM. + MEMSET = 4, + DEBUG_NOTIFIED = 8, +}; +ENUM_CLASS_BITOPS(GPUCopyFlag); + // Used for debug struct FramebufferInfo { u32 fb_address; @@ -222,7 +232,7 @@ public: virtual void InvalidateCache(u32 addr, int size, GPUInvalidationType type) = 0; virtual void NotifyVideoUpload(u32 addr, int size, int width, int format) = 0; // Update either RAM from VRAM, or VRAM from RAM... or even VRAM from VRAM. - virtual bool PerformMemoryCopy(u32 dest, u32 src, int size) = 0; + virtual bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) = 0; virtual bool PerformMemorySet(u32 dest, u8 v, int size) = 0; virtual bool PerformMemoryDownload(u32 dest, int size) = 0; virtual bool PerformMemoryUpload(u32 dest, int size) = 0; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index cddfa557d9..28fe4041fb 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1265,11 +1265,11 @@ void SoftGPU::NotifyVideoUpload(u32 addr, int size, int width, int format) // Ignore. } -bool SoftGPU::PerformMemoryCopy(u32 dest, u32 src, int size) -{ +bool SoftGPU::PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags) { // Nothing to update. InvalidateCache(dest, size, GPU_INVALIDATE_HINT); - GPURecord::NotifyMemcpy(dest, src, size); + if (!(flags & GPUCopyFlag::DEBUG_NOTIFIED)) + GPURecord::NotifyMemcpy(dest, src, size); // Let's just be safe. MarkDirty(dest, size, SoftGPUVRAMDirty::DIRTY | SoftGPUVRAMDirty::REALLY_DIRTY); return false; diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 29ce1e5934..84732eb43a 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -139,7 +139,7 @@ public: void GetStats(char *buffer, size_t bufsize) override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; void NotifyVideoUpload(u32 addr, int size, int width, int format) override; - bool PerformMemoryCopy(u32 dest, u32 src, int size) override; + bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; bool PerformMemoryDownload(u32 dest, int size) override; bool PerformMemoryUpload(u32 dest, int size) override; From 9ac4523fd2238d910d6756d80217e8088ad39d0b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 3 Oct 2022 20:22:27 -0700 Subject: [PATCH 039/374] GPU: Skip matching a framebuf for RAM. --- GPU/Common/FramebufferManagerCommon.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 878b677466..b688355706 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1650,8 +1650,11 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, // Or at least this should be like the other ones, gathering possible candidates // with the ability to list them out for debugging. - VirtualFramebuffer *dstBuffer = 0; - VirtualFramebuffer *srcBuffer = 0; + VirtualFramebuffer *dstBuffer = nullptr; + VirtualFramebuffer *srcBuffer = nullptr; + bool ignoreDstBuffer = flags & GPUCopyFlag::FORCE_DST_MEM; + bool ignoreSrcBuffer = flags & (GPUCopyFlag::FORCE_SRC_MEM | GPUCopyFlag::MEMSET); + u32 dstY = (u32)-1; u32 dstH = 0; u32 srcY = (u32)-1; @@ -1669,14 +1672,14 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, const int vfb_byteWidth = vfb->width * vfb_bpp; // Heuristic to try to prevent potential glitches with video playback. - if (vfb_address == dst && (size == 0x44000 && vfb_size == 0x88000 || size == 0x88000 && vfb_size == 0x44000)) { + if (!ignoreDstBuffer && vfb_address == dst && (size == 0x44000 && vfb_size == 0x88000 || size == 0x88000 && vfb_size == 0x44000)) { // Not likely to be a correct color format copy for this buffer. Ignore it, there will either be RAM // that can be displayed from, or another matching buffer with the right format if rendering is going on. WARN_LOG_N_TIMES(notify_copy_2x, 5, G3D, "Framebuffer size %08x conspicuously not matching copy size %08x in NotifyFramebufferCopy. Ignoring.", size, vfb_size); continue; } - if (dst >= vfb_address && (dst + size <= vfb_address + vfb_size || dst == vfb_address)) { + if (!ignoreDstBuffer && dst >= vfb_address && (dst + size <= vfb_address + vfb_size || dst == vfb_address)) { const u32 offset = dst - vfb_address; const u32 yOffset = offset / vfb_byteStride; if ((offset % vfb_byteStride) == 0 && (size == vfb_byteWidth || (size % vfb_byteStride) == 0) && yOffset < dstY) { @@ -1686,7 +1689,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, } } - if (src >= vfb_address && (src + size <= vfb_address + vfb_size || src == vfb_address)) { + if (!ignoreSrcBuffer && src >= vfb_address && (src + size <= vfb_address + vfb_size || src == vfb_address)) { const u32 offset = src - vfb_address; const u32 yOffset = offset / vfb_byteStride; if ((offset % vfb_byteStride) == 0 && (size == vfb_byteWidth || (size % vfb_byteStride) == 0) && yOffset < srcY) { @@ -1728,7 +1731,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, dstBuffer->last_frame_used = gpuStats.numFlips; } - if (dstBuffer && srcBuffer && !(flags & GPUCopyFlag::MEMSET) && !(flags & GPUCopyFlag::FORCE_SRC_MEM) && !(flags & GPUCopyFlag::FORCE_DST_MEM)) { + if (dstBuffer && srcBuffer) { if (srcBuffer == dstBuffer) { WARN_LOG_ONCE(dstsrccpy, G3D, "Intra-buffer memcpy (not supported) %08x -> %08x (size: %x)", src, dst, size); } else { @@ -1739,7 +1742,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, RebindFramebuffer("RebindFramebuffer - Inter-buffer memcpy"); } return false; - } else if (dstBuffer && !(flags & GPUCopyFlag::FORCE_DST_MEM)) { + } else if (dstBuffer) { if (flags & GPUCopyFlag::MEMSET) { gpuStats.numClears++; } From 362391b9d88ad819fc862f96ff6640087acf7765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 4 Oct 2022 20:56:41 +0200 Subject: [PATCH 040/374] Fix Kurohyou again. See #9576 --- GPU/Common/FramebufferManagerCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index a72b1ca2bf..df0342724a 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -566,7 +566,7 @@ void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) { bool newlyUsingDepth = (currentRenderVfb_->usageFlags & FB_USAGE_RENDER_DEPTH) == 0; currentRenderVfb_->usageFlags |= FB_USAGE_RENDER_DEPTH; - uint32_t boundDepthBuffer = gstate.getDepthBufRawAddress(); + uint32_t boundDepthBuffer = gstate.getDepthBufRawAddress() | 0x04000000; if (currentRenderVfb_->z_address != boundDepthBuffer) { WARN_LOG_N_TIMES(z_reassign, 5, G3D, "Framebuffer at %08x/%d has switched associated depth buffer from %08x to %08x, updating.", currentRenderVfb_->fb_address, currentRenderVfb_->fb_stride, currentRenderVfb_->z_address, boundDepthBuffer); From 09e9488de8a3343aeec4361d8cdc18e6659747fd Mon Sep 17 00:00:00 2001 From: sum2012 Date: Wed, 5 Oct 2022 06:22:40 +0800 Subject: [PATCH 041/374] Try to build fix --- UI/GameScreen.cpp | 5 +++-- UI/GameScreen.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 114b6e7a35..89490193df 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -56,10 +56,11 @@ GameScreen::~GameScreen() { } } -std::string int2hexstr(const int a) { +const char* int2hexstr(const int a) { std::stringstream stream; stream << std::hex << a; - return stream.str(); + auto s = stream.str(); + return s.c_str(); } void GameScreen::update() { diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 1018acbf10..43671ec272 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -29,7 +29,7 @@ // Uses GameInfoCache heavily to implement the functionality. // Should possibly merge this with the PauseScreen. -std::string int2hexstr(const int a); +const char* int2hexstr(const int a); class GameScreen : public UIDialogScreenWithGameBackground { public: From 32f5a7e95fe98e7976c4ac3efac64a86ea965dce Mon Sep 17 00:00:00 2001 From: GITNE Date: Fri, 30 Sep 2022 23:59:59 +0000 Subject: [PATCH 042/374] Improve Freedesktop integration * Move scalable icon install from `${prefix}/share/pixmaps` (`pixmaps` has been deprecated long time ago) to `${prefix}/share/icons/hicolor/scalable/apps` * Add `Keywords`, `Categories`, and `MimeType` keys to `.desktop` file * Add shared MIME-info on [`application/x-compressed-iso`](https://en.wikipedia.org/wiki/.CSO "Compressed ISO") MIME type --- CMakeLists.txt | 10 ++++++++-- assets/mime/ppsspp.xml | 14 ++++++++++++++ ppsspp.desktop.in | 4 +++- 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 assets/mime/ppsspp.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 52fb7e40c9..6cb38fb017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2513,6 +2513,8 @@ if(UNIX AND NOT ANDROID AND NOT APPLE) DIRECTORY "${CMAKE_BINARY_DIR}/assets" DESTINATION "${CMAKE_INSTALL_DATADIR}/ppsspp" PATTERN ".git*" EXCLUDE + PATTERN "mime" EXCLUDE + PATTERN "lang/README.md" EXCLUDE ) install( FILES "${CMAKE_BINARY_DIR}/ppsspp.desktop" @@ -2525,7 +2527,11 @@ if(UNIX AND NOT ANDROID AND NOT APPLE) ) install( FILES "${CMAKE_SOURCE_DIR}/icons/icon-512.svg" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pixmaps" - RENAME ppsspp.svg + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps" + RENAME "ppsspp.svg" + ) + install( + FILES "${CMAKE_SOURCE_DIR}/assets/mime/ppsspp.xml" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/mime/packages" ) endif() diff --git a/assets/mime/ppsspp.xml b/assets/mime/ppsspp.xml new file mode 100644 index 0000000000..26b62e56e9 --- /dev/null +++ b/assets/mime/ppsspp.xml @@ -0,0 +1,14 @@ + + + + + + + + Compressed ISO Image + Komprimiertes ISO‑Abbild + Skomprymowany obraz ISO + CSO + + + diff --git a/ppsspp.desktop.in b/ppsspp.desktop.in index 05fd1e7348..fd8ffc35b8 100644 --- a/ppsspp.desktop.in +++ b/ppsspp.desktop.in @@ -4,4 +4,6 @@ Exec=@TargetBin@ Icon=ppsspp Type=Application Comment=ppsspp (fast and portable PSP emulator) -Categories=Game;Emulator +Keywords=Sony;PlayStation;Portable;PSP;handheld;console; +Categories=Game;Emulator; +MimeType=application/x-cd-image;application/x-iso9660-image;application/x-compressed-iso;application/zip; From 8025def8d25e8df32719ecfbf6d93069685ab182 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 4 Oct 2022 22:10:24 -0700 Subject: [PATCH 043/374] Vulkan: Clip to neg z in the geometry shader. This is only used when clip distance is unsupported, such as on Mali. --- GPU/Common/GeometryShaderGenerator.cpp | 150 ++++++++++++++++++++++--- GPU/Common/VertexShaderGenerator.cpp | 2 +- 2 files changed, 134 insertions(+), 18 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index b701bb547c..786fd25734 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -48,7 +48,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - p.C("layout(triangle_strip, max_vertices = 3) out;\n"); + p.C("layout(triangle_strip, max_vertices = 6) out;\n"); if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); @@ -76,6 +76,10 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu // Apply culling p.C(" bool anyInside = false;\n"); + // And apply manual clipping if necessary. + if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + p.C(" float clip0[3];\n"); + } p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); @@ -98,6 +102,13 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" if (projPos.z >= u_cullRangeMin.z) { anyInside = true; }\n"); p.C(" if (projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); p.C(" }\n"); + + if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + // This is basically the same value as gl_ClipDistance would take, z + w. + // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. + p.F(" clip0[i] = projZ * outPos.w + outPos.w;\n"); + } + p.C(" } // for\n"); // Cull any triangle fully outside in the same direction when depth clamp enabled. @@ -106,27 +117,132 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" return;\n"); p.C(" }\n"); - const char *clip0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]"; + if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + // Clipping against one half-space cuts a triangle (17/27), culls (7/27), or creates two triangles (3/27). + p.C(" int emitted = 0;\n"); + p.C(" for (int i = 0; i < 3; i++) {\n"); + // First, emit this vertex if it doesn't need clipping + p.C(" if (clip0[i] >= 0.0) {\n"); - p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? - p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); - p.C(" gl_Position = outPos;\n"); - // TODO: Not rectangles... - if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + // But before we emit that, is this the second triangle? We'll need extra verts. + p.C(" if (emitted == 3) {\n"); + p.C(" EndPrimitive();\n"); + // In this case, it can only be +/-/+, we must emit vert 0 and then mix(1, 2) again first. + p.C(" gl_Position = gl_in[0].gl_Position;\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[0];\n", outVaryings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + // Next, it can only be the interpolated between 1 and 2 (before this one, direct 2.) + p.C(" float t = clip0[1] / (clip0[1] - clip0[2]);\n"); + p.C(" gl_Position = mix(gl_in[1].gl_Position, gl_in[2].gl_Position, t);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[1], %s[2], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + p.C(" }\n"); + + // Now emit the regular vertex itself. + p.C(" gl_Position = gl_in[i].gl_Position;\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + p.C(" }\n"); + + // Next, we generate an interpolated vertex if signs differ. + p.C(" int inext = i == 2 ? 0 : i + 1;\n"); + p.C(" if (clip0[i] * clip0[inext] < 0.0) {\n"); + + // There are two cases here: +/+/- and -/+/+. + p.C(" if (emitted == 3 && clip0[i] < 0.0) {\n"); + p.C(" EndPrimitive();\n"); + // In this case, it can only be +/-/+, we must emit vert 0 and then mix(1, 2) again first. + p.C(" gl_Position = gl_in[0].gl_Position;\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[0];\n", outVaryings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + // Next, it can only be the interpolated between 1 and 2 (before this one, direct 2.) + p.C(" float t = 1.0 - (clip0[2] / (clip0[2] - clip0[1]));\n"); + p.C(" gl_Position = mix(gl_in[1].gl_Position, gl_in[2].gl_Position, t);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[1], %s[2], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + p.C(" } else if (emitted == 3) {\n"); + p.C(" EndPrimitive();\n"); + // Now we emit mix(0, 1) first, then vert 2 again. + p.C(" float t = clip0[0] / (clip0[0] - clip0[1]);\n"); + p.C(" gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, t);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[0], %s[1], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + // Then here's vert 2. + p.C(" gl_Position = gl_in[2].gl_Position;\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[2];\n", outVaryings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + p.C(" }\n"); + + // Finally, the actual interpolated vertex. + p.C(" float t = clip0[i] < 0.0 ? clip0[i] / (clip0[i] - clip0[inext]) : 1.0 - (clip0[inext] / (clip0[inext] - clip0[i]));\n"); + p.C(" gl_Position = mix(gl_in[i].gl_Position, gl_in[inext].gl_Position, t);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[i], %s[inext], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" emitted++;\n"); + p.C(" }\n"); + p.C(" }\n"); + } else { + const char *clipSuffix0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]"; + + p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? + p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); - p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clip0); - } + // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. + p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); + p.C(" gl_Position = outPos;\n"); + if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + } - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); + } + // Debug - null the red channel + //p.C(" if (i == 0) v_color0Out.x = 0.0;\n"); + p.C(" EmitVertex();\n"); + p.C(" }\n"); } - // Debug - null the red channel - //p.C(" if (i == 0) v_color0Out.x = 0.0;\n"); - p.C(" EmitVertex();\n"); - p.C(" }\n"); p.EndGSMain(); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index d6f356c6d4..928aa3f6dd 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -1312,7 +1312,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag const char *cull0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; const char *cull1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { - // TODO: Not rectangles... + // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. WRITE(p, " %sgl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", compat.vsOutPrefix, vertexRangeClipSuffix); } if (gstate_c.Supports(GPU_SUPPORTS_CULL_DISTANCE)) { From f24edbe8a81dd4d708a23a49f7dd0d00d9d8db37 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 4 Oct 2022 22:19:40 -0700 Subject: [PATCH 044/374] Compat: Remove DisableRangeCulling. This hack was used because culling previously incorrectly handled Z, which was fixed in #14833. --- Core/Compatibility.cpp | 1 - Core/Compatibility.h | 1 - GPU/GPUCommon.cpp | 6 +-- assets/compat.ini | 83 ------------------------------------------ 4 files changed, 1 insertion(+), 90 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 94b4279a39..861e926429 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -97,7 +97,6 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "DateLimited", &flags_.DateLimited); CheckSetting(iniFile, gameID, "ShaderColorBitmask", &flags_.ShaderColorBitmask); CheckSetting(iniFile, gameID, "DisableFirstFrameReadback", &flags_.DisableFirstFrameReadback); - CheckSetting(iniFile, gameID, "DisableRangeCulling", &flags_.DisableRangeCulling); CheckSetting(iniFile, gameID, "MpegAvcWarmUp", &flags_.MpegAvcWarmUp); CheckSetting(iniFile, gameID, "BlueToAlpha", &flags_.BlueToAlpha); CheckSetting(iniFile, gameID, "CenteredLines", &flags_.CenteredLines); diff --git a/Core/Compatibility.h b/Core/Compatibility.h index bd824b916d..8bbdc52ebd 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -77,7 +77,6 @@ struct CompatFlags { bool DateLimited; bool ShaderColorBitmask; bool DisableFirstFrameReadback; - bool DisableRangeCulling; bool MpegAvcWarmUp; bool BlueToAlpha; bool CenteredLines; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index a44fb47572..9445ab894a 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3309,11 +3309,7 @@ u32 GPUCommon::CheckGPUFeatures() const { } if (!draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) { - // Ignore the compat setting if clip and cull are both enabled. - // When supported, we can do the depth side of range culling more correctly. - const bool supported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; - const bool disabled = PSP_CoreParameter().compat.flags().DisableRangeCulling; - if (supported || !disabled) { + if (draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported) { features |= GPU_SUPPORTS_VS_RANGE_CULLING; } } diff --git a/assets/compat.ini b/assets/compat.ini index 6df16cff48..2fbe053168 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -156,89 +156,6 @@ NPJH90062 = true # Phantasy Star Portable Infinity Demo NPJH90157 = true # Infinity demo -[DisableRangeCulling] -# Phantasy Star games also have range culling issues. -# Phantasy Star Portable 2 and Infinity -ULJM05309 = true -ULUS10410 = true -ULES01218 = true -ULJM08023 = true -ULES01218 = true -# Phantasy Star Portable 1 Demo -NPUH90023 = true -# Phantasy Star Portable 2 -ULES01439 = true -ULUS10529 = true -ULJM05493 = true -NPJH50043 = true -ULJM08030 = true -NPUH90023 = true -ULJM91014 = true -NPJH90002 = true -ULJM05732 = true -NPJH50332 = true -# Phantasy Star Portable 2 JP Demo -ULJM91018 = true -NPJH90062 = true -# Phantasy Star Portable Infinity Demo -NPJH90157 = true # Infinity demo - -# Test Drive Unlimited -ULET00386 = true -ULES00637 = true -ULKS46126 = true -ULUS10249 = true - -# Metal Gear Solid : Peace Walker (see issue #12348) -ULUS10509 = true -ULES01372 = true -ULJM08038 = true -NPJH50045 = true -ULJM05630 = true -NPJH90082 = true -NPJH90063 = true - -# Metal Gear Solid : Peace Walker Demo Ops (see issue #12348) -NPUH90066 = true -NPHH00145 = true -NPEH90023 = true - -# Metal Gear Solid: Portable Ops (see issue #12348) -ULES00645 = true -ULJM05193 = true -ULJM05227 = true -ULUS10202 = true -ULES01003 = true -ULJM05261 = true -ULUS10290 = true -ULED90040 = true -ULJM05284 = true -ULES00645 = true - -# Splinter Cell Essentials (#13035) -ULES00281 = true -ULUS10070 = true - -# Asphalt 2 (#14299) -ULES00719 = true -# No US release, it seems - -# Star Wars: Lethal Alliance (#11551) -ULES00599 = true -ULUS10188 = true - -# Digimon World Re:Digitize -ULJS00496 = true -NPJH50588 = true -ULAS42319 = true - -# NOVA: Near Orbit Vanguard Alliance -NPUZ00179 = true -NPEZ00222 = true - -# Street Riders (only region found. See #14746) -ULES00276 = true - [ClearToRAM] # SOCOM Navy Seals games require this. See issue #8973. # Navy Seals : Tactical Strike From 5d88e50201aa40c356766329713dba899391af3d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 4 Oct 2022 23:04:25 -0700 Subject: [PATCH 045/374] Vulkan: Generate indices in clipping. --- GPU/Common/GeometryShaderGenerator.cpp | 158 +++++++++++-------------- 1 file changed, 70 insertions(+), 88 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 786fd25734..6d1b7bdcd9 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -119,106 +119,88 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { // Clipping against one half-space cuts a triangle (17/27), culls (7/27), or creates two triangles (3/27). - p.C(" int emitted = 0;\n"); + p.C(" int indices[4];\n"); + p.C(" float factors[4];\n"); + p.C(" int ind = 0;\n"); + + // Pass 1 - clip against first half-space. p.C(" for (int i = 0; i < 3; i++) {\n"); - // First, emit this vertex if it doesn't need clipping + // First, use this vertex if it doesn't need clipping. p.C(" if (clip0[i] >= 0.0) {\n"); - - // But before we emit that, is this the second triangle? We'll need extra verts. - p.C(" if (emitted == 3) {\n"); - p.C(" EndPrimitive();\n"); - // In this case, it can only be +/-/+, we must emit vert 0 and then mix(1, 2) again first. - p.C(" gl_Position = gl_in[0].gl_Position;\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = %s[0];\n", outVaryings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - // Next, it can only be the interpolated between 1 and 2 (before this one, direct 2.) - p.C(" float t = clip0[1] / (clip0[1] - clip0[2]);\n"); - p.C(" gl_Position = mix(gl_in[1].gl_Position, gl_in[2].gl_Position, t);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[1], %s[2], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - p.C(" }\n"); - - // Now emit the regular vertex itself. - p.C(" gl_Position = gl_in[i].gl_Position;\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); + p.C(" indices[ind] = i;\n"); + p.C(" factors[ind] = 0.0;\n"); + p.C(" ind++;\n"); p.C(" }\n"); // Next, we generate an interpolated vertex if signs differ. p.C(" int inext = i == 2 ? 0 : i + 1;\n"); p.C(" if (clip0[i] * clip0[inext] < 0.0) {\n"); - - // There are two cases here: +/+/- and -/+/+. - p.C(" if (emitted == 3 && clip0[i] < 0.0) {\n"); - p.C(" EndPrimitive();\n"); - // In this case, it can only be +/-/+, we must emit vert 0 and then mix(1, 2) again first. - p.C(" gl_Position = gl_in[0].gl_Position;\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = %s[0];\n", outVaryings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - // Next, it can only be the interpolated between 1 and 2 (before this one, direct 2.) - p.C(" float t = 1.0 - (clip0[2] / (clip0[2] - clip0[1]));\n"); - p.C(" gl_Position = mix(gl_in[1].gl_Position, gl_in[2].gl_Position, t);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[1], %s[2], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - p.C(" } else if (emitted == 3) {\n"); - p.C(" EndPrimitive();\n"); - // Now we emit mix(0, 1) first, then vert 2 again. - p.C(" float t = clip0[0] / (clip0[0] - clip0[1]);\n"); - p.C(" gl_Position = mix(gl_in[0].gl_Position, gl_in[1].gl_Position, t);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[0], %s[1], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - // Then here's vert 2. - p.C(" gl_Position = gl_in[2].gl_Position;\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = %s[2];\n", outVaryings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - p.C(" }\n"); - - // Finally, the actual interpolated vertex. p.C(" float t = clip0[i] < 0.0 ? clip0[i] / (clip0[i] - clip0[inext]) : 1.0 - (clip0[inext] / (clip0[inext] - clip0[i]));\n"); - p.C(" gl_Position = mix(gl_in[i].gl_Position, gl_in[inext].gl_Position, t);\n"); + p.C(" indices[ind] = i;\n"); + p.C(" factors[ind] = t;\n"); + p.C(" ind++;\n"); + p.C(" }\n"); + + p.C(" }\n"); + + p.C(" if (ind < 3) {\n"); + p.C(" return;\n"); + p.C(" }\n"); + + // Alright, time to actually emit the first triangle. + p.C(" for (int i = 0; i < 3; i++) {\n"); + p.C(" int idx = indices[i];\n"); + p.C(" float factor = factors[i];\n"); + p.C(" int next = idx == 2 ? 0 : idx + 1;\n"); + p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); for (size_t i = 0; i < varyings.size(); i++) { VaryingDef &in = varyings[i]; VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[i], %s[inext], t);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); } - p.C(" EmitVertex();\n"); - p.C(" emitted++;\n"); - p.C(" }\n"); + p.C(" EmitVertex();\n"); + p.C(" }\n"); + + // Did we end up with additional triangles? We'll do three points each for the rest. + p.C(" for (int i = 3; i < ind; i++) {\n"); + p.C(" EndPrimitive();\n"); + + // Point one, always index zero. + p.C(" int idx = indices[0];\n"); + p.C(" float factor = factors[0];\n"); + p.C(" int next = idx == 2 ? 0 : idx + 1;\n"); + p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + + // After that, one less than i (basically a triangle fan.) + p.C(" idx = indices[i - 1];\n"); + p.C(" factor = factors[i - 1];\n"); + p.C(" next = idx == 2 ? 0 : idx + 1;\n"); + p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + + // And the new vertex itself. + p.C(" idx = indices[i];\n"); + p.C(" factor = factors[i];\n"); + p.C(" next = idx == 2 ? 0 : idx + 1;\n"); + p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + VaryingDef &in = varyings[i]; + VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); + } + p.C(" EmitVertex();\n"); + p.C(" }\n"); } else { const char *clipSuffix0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]"; From c33ff58980c4e6cf7f7a69534bba4d8266d2768c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 4 Oct 2022 23:46:25 -0700 Subject: [PATCH 046/374] Reporting: Avoid accessing ticks before start. --- Core/Reporting.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/Reporting.cpp b/Core/Reporting.cpp index f344e1bac9..4f15062e3c 100644 --- a/Core/Reporting.cpp +++ b/Core/Reporting.cpp @@ -434,7 +434,8 @@ namespace Reporting void AddGameplayInfo(UrlEncoder &postdata) { // Just to get an idea of how long they played. - postdata.Add("ticks", (const uint64_t)CoreTiming::GetTicks()); + if (PSP_IsInited()) + postdata.Add("ticks", (const uint64_t)CoreTiming::GetTicks()); float vps, fps; __DisplayGetAveragedFPS(&vps, &fps); From c735d10021db49d5f2bf63bb2fe04124bd263363 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 4 Oct 2022 23:48:57 -0700 Subject: [PATCH 047/374] Reporting: Always report hleReportDebug. Even if debug logging is not enabled. --- Core/HLE/HLE.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/HLE.h b/Core/HLE/HLE.h index d2a74f9d43..0331fb7b9b 100644 --- a/Core/HLE/HLE.h +++ b/Core/HLE/HLE.h @@ -189,7 +189,7 @@ T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char * template T hleDoLog(LogTypes::LOG_TYPE t, LogTypes::LOG_LEVELS level, T res, const char *file, int line, const char *reportTag, char retmask) { - if (level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) { + if ((level > MAX_LOGLEVEL || !GenericLogEnabled(level, t)) && !reportTag) { return res; } From de6d747cf0423de74ebb41084584e35ac6e32a0c Mon Sep 17 00:00:00 2001 From: sum2012 Date: Wed, 5 Oct 2022 20:36:01 +0800 Subject: [PATCH 048/374] Store crc change to u32 Should build fixed --- Core/HLE/sceKernelModule.cpp | 11 +++++------ Core/HLE/sceMpeg.cpp | 12 ++++++------ Core/HLE/sceMpeg.h | 2 +- Core/HLE/scePsmf.cpp | 12 ++++++------ Core/HLE/scePsmf.h | 2 +- UI/GameScreen.cpp | 12 ++++++------ UI/GameScreen.h | 2 -- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index f542354805..f74a78e0d0 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1147,7 +1147,6 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) { static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) { u32 crc = crc32(0, Z_NULL, 0); crc = crc32(crc, ptr, elfSize); - const std::string crcstring = int2hexstr(crc); PSPModule *module = new PSPModule(); kernelObjects.Create(module); loadedModules.insert(module->GetUID()); @@ -1174,14 +1173,14 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load if (IsHLEVersionedModule(head->modname)) { int ver = (head->module_ver_hi << 8) | head->module_ver_lo; - INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x, crc %s", head->modname, ver, head->devkitversion, crcstring.c_str()); + INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x, crc %x", head->modname, ver, head->devkitversion, crc); reportedModule = true; if (!strcmp(head->modname, "sceMpeg_library")) { - __MpegLoadModule(ver, crcstring); + __MpegLoadModule(ver, crc); } if (!strcmp(head->modname, "scePsmfP_library") || !strcmp(head->modname, "scePsmfPlayer")) { - __PsmfPlayerLoadModule(head->devkitversion, crcstring); + __PsmfPlayerLoadModule(head->devkitversion, crc); } } @@ -1614,10 +1613,10 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load INFO_LOG(SCEMODULE, "Loading module %s with version %04x, devkit %08x", modinfo->name, modinfo->moduleVersion, devkitVersion); if (!strcmp(modinfo->name, "sceMpeg_library")) { - __MpegLoadModule(modinfo->moduleVersion, crcstring); + __MpegLoadModule(modinfo->moduleVersion, crc); } if (!strcmp(modinfo->name, "scePsmfP_library") || !strcmp(modinfo->name, "scePsmfPlayer")) { - __PsmfPlayerLoadModule(devkitVersion, crcstring); + __PsmfPlayerLoadModule(devkitVersion, crc); } } diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index cb9fd9aba1..929e782d0c 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -259,7 +259,7 @@ struct MpegContext { static bool isMpegInit; static int mpegLibVersion = 0; -static std::string mpegLibCrcstring = "null"; +static u32 mpegLibCrc = 0; static u32 streamIdGen; static int actionPostPut; static std::map mpegMap; @@ -424,10 +424,10 @@ void __MpegDoState(PointerWrap &p) { Do(p, ringbufferPutPacketsAdded); } if (s < 4) { - mpegLibCrcstring = "null"; + mpegLibCrc = 0; } else { - Do(p, mpegLibCrcstring); + Do(p, mpegLibCrc); } Do(p, streamIdGen); @@ -448,9 +448,9 @@ void __MpegShutdown() { mpegMap.clear(); } -void __MpegLoadModule(int version,std::string crcstr) { +void __MpegLoadModule(int version,u32 crc) { mpegLibVersion = version; - mpegLibCrcstring = crcstr; + mpegLibCrc = crc; } static u32 sceMpegInit() { @@ -459,7 +459,7 @@ static u32 sceMpegInit() { // TODO: Need to properly hook module load/unload for this to work right. //return ERROR_MPEG_ALREADY_INIT; } else { - INFO_LOG(ME, "sceMpegInit(), mpegLibVersion 0x%0x, mpegLibcrc %s", mpegLibVersion, mpegLibCrcstring.c_str()); + INFO_LOG(ME, "sceMpegInit(), mpegLibVersion 0x%0x, mpegLibcrc %x", mpegLibVersion, mpegLibCrc); } isMpegInit = true; return hleDelayResult(0, "mpeg init", 750); diff --git a/Core/HLE/sceMpeg.h b/Core/HLE/sceMpeg.h index 538c60c9a8..925a2b005b 100644 --- a/Core/HLE/sceMpeg.h +++ b/Core/HLE/sceMpeg.h @@ -79,7 +79,7 @@ void __MpegInit(); void __MpegDoState(PointerWrap &p); void __MpegShutdown(); -void __MpegLoadModule(int version,std::string crcstr); +void __MpegLoadModule(int version,u32 crc); void Register_sceMpeg(); diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 9b81e83a96..cf01260f2c 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -59,7 +59,7 @@ static const int audioSamplesBytes = audioSamples * 4; static int videoPixelMode = GE_CMODE_32BIT_ABGR8888; static int videoLoopStatus = PSMF_PLAYER_CONFIG_NO_LOOP; static int psmfPlayerLibVersion = 0; -static std::string psmfPlayerLibcrcstring = "null"; +static u32 psmfPlayerLibcrc = 0; int eventPsmfPlayerStatusChange = -1; @@ -697,9 +697,9 @@ void __PsmfInit() { eventPsmfPlayerStatusChange = CoreTiming::RegisterEvent("PsmfPlayerStatusChange", &__PsmfPlayerStatusChange); } -void __PsmfPlayerLoadModule(int devkitVersion, std::string crcstr) { +void __PsmfPlayerLoadModule(int devkitVersion, u32 crc) { psmfPlayerLibVersion = devkitVersion; - psmfPlayerLibcrcstring = crcstr; + psmfPlayerLibcrc = crc; } void __PsmfDoState(PointerWrap &p) { @@ -725,9 +725,9 @@ void __PsmfPlayerDoState(PointerWrap &p) { } CoreTiming::RestoreRegisterEvent(eventPsmfPlayerStatusChange, "PsmfPlayerStatusChangeEvent", &__PsmfPlayerStatusChange); if (s < 3) { - psmfPlayerLibcrcstring = "null"; + psmfPlayerLibcrc = 0; } else { - Do(p, psmfPlayerLibcrcstring); + Do(p, psmfPlayerLibcrc); } if (s < 2) { // Assume the latest, which is what we were emulating before. @@ -1164,7 +1164,7 @@ static int scePsmfPlayerCreate(u32 psmfPlayer, u32 dataPtr) { int delayUs = 20000; DelayPsmfStateChange(psmfPlayer, PSMF_PLAYER_STATUS_INIT, delayUs); - INFO_LOG(ME, "psmfplayer create, psmfPlayerLibVersion 0x%0x, psmfPlayerLibcrcstring %s", psmfPlayerLibVersion, psmfPlayerLibcrcstring.c_str()); + INFO_LOG(ME, "psmfplayer create, psmfPlayerLibVersion 0x%0x, psmfPlayerLibcrc %x", psmfPlayerLibVersion, psmfPlayerLibcrc); return hleDelayResult(0, "player create", delayUs); } diff --git a/Core/HLE/scePsmf.h b/Core/HLE/scePsmf.h index 8e201adade..ae143fce04 100644 --- a/Core/HLE/scePsmf.h +++ b/Core/HLE/scePsmf.h @@ -21,7 +21,7 @@ void Register_scePsmf(); void Register_scePsmfPlayer(); void __PsmfInit(); -void __PsmfPlayerLoadModule(int devkitVersion,std::string crcstr); +void __PsmfPlayerLoadModule(int devkitVersion,u32 crc); void __PsmfDoState(PointerWrap &p); void __PsmfPlayerDoState(PointerWrap &p); void __PsmfShutdown(); diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 89490193df..edf519f46b 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -44,7 +44,6 @@ #include "UI/MainScreen.h" #include "UI/BackgroundAudio.h" #include "Core/Reporting.h" -#include GameScreen::GameScreen(const Path &gamePath) : UIDialogScreenWithGameBackground(gamePath) { g_BackgroundAudio.SetGame(gamePath); @@ -56,11 +55,12 @@ GameScreen::~GameScreen() { } } -const char* int2hexstr(const int a) { - std::stringstream stream; - stream << std::hex << a; - auto s = stream.str(); - return s.c_str(); +template std::string int2hexstr(I w, size_t hex_len = sizeof(I) << 1) { + static const char* digits = "0123456789ABCDEF"; + std::string rc(hex_len, '0'); + for (size_t i = 0, j = (hex_len - 1) * 4; i < hex_len; ++i, j -= 4) + rc[i] = digits[(w >> j) & 0x0f]; + return rc; } void GameScreen::update() { diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 43671ec272..cff0c48366 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -29,8 +29,6 @@ // Uses GameInfoCache heavily to implement the functionality. // Should possibly merge this with the PauseScreen. -const char* int2hexstr(const int a); - class GameScreen : public UIDialogScreenWithGameBackground { public: GameScreen(const Path &gamePath); From 776e72715fedf37de6fd166cbdf1be97086bbca0 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Wed, 5 Oct 2022 20:52:47 +0800 Subject: [PATCH 049/374] Forget remove the include --- Core/HLE/sceKernelModule.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index f74a78e0d0..5cd5dedbf7 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -67,7 +67,6 @@ #include "GPU/GPU.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" -#include "UI/GameScreen.h" enum { PSP_THREAD_ATTR_KERNEL = 0x00001000, From 3e5c09d432a9135711031bf264b4d95c1ffd1bde Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Oct 2022 19:41:59 -0700 Subject: [PATCH 050/374] Vulkan: Clip clamped depth in geometry shader. This corrects deformed geometry on Mali devices which don't support user-space clipping but do support depth clamp. --- GPU/Common/GeometryShaderGenerator.cpp | 211 ++++++++++++++++--------- GPU/Common/ShaderId.cpp | 13 +- GPU/Common/ShaderId.h | 1 + 3 files changed, 149 insertions(+), 76 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 6d1b7bdcd9..525dc1f0f5 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -48,7 +48,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - p.C("layout(triangle_strip, max_vertices = 6) out;\n"); + p.C("layout(triangle_strip, max_vertices = 12) out;\n"); if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); @@ -58,6 +58,8 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } std::vector varyings, outVaryings; + bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); + bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); if (id.Bit(GS_BIT_DO_TEXTURE)) { varyings.push_back(VaryingDef{ "vec3", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" }); @@ -74,53 +76,87 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.BeginGSMain(varyings, outVaryings); - // Apply culling - p.C(" bool anyInside = false;\n"); + // Apply culling. + if (vertexRangeCulling) { + p.C(" bool anyInside = false;\n"); + } // And apply manual clipping if necessary. if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { p.C(" float clip0[3];\n"); + if (clipClampedDepth) { + p.C(" float clip1[3];\n"); + } } p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); - p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); - // Vertex range culling doesn't happen when Z clips, note sign of w is important. - p.C(" if (u_cullRangeMin.w <= 0.0 || projZ * outPos.w > -outPos.w) {\n"); - const char *outMin = "projPos.x < u_cullRangeMin.x || projPos.y < u_cullRangeMin.y"; - const char *outMax = "projPos.x > u_cullRangeMax.x || projPos.y > u_cullRangeMax.y"; - p.F(" if ((%s) || (%s)) {\n", outMin, outMax); - p.C(" return;\n"); // Cull! - p.C(" }\n"); - p.C(" }\n"); - p.C(" if (u_cullRangeMin.w <= 0.0) {\n"); - p.C(" if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); - // When not clamping depth, cull the triangle of Z is outside the valid range (not based on clip Z.) - p.C(" return;\n"); - p.C(" }\n"); - p.C(" } else {\n"); - p.C(" if (projPos.z >= u_cullRangeMin.z) { anyInside = true; }\n"); - p.C(" if (projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); - p.C(" }\n"); + + if (vertexRangeCulling) { + p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); + // Vertex range culling doesn't happen when Z clips, note sign of w is important. + p.C(" if (u_cullRangeMin.w <= 0.0 || projZ * outPos.w > -outPos.w) {\n"); + const char *outMin = "projPos.x < u_cullRangeMin.x || projPos.y < u_cullRangeMin.y"; + const char *outMax = "projPos.x > u_cullRangeMax.x || projPos.y > u_cullRangeMax.y"; + p.F(" if ((%s) || (%s)) {\n", outMin, outMax); + p.C(" return;\n"); // Cull! + p.C(" }\n"); + p.C(" }\n"); + p.C(" if (u_cullRangeMin.w <= 0.0) {\n"); + p.C(" if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); + // When not clamping depth, cull the triangle of Z is outside the valid range (not based on clip Z.) + p.C(" return;\n"); + p.C(" }\n"); + p.C(" } else {\n"); + p.C(" if (projPos.z >= u_cullRangeMin.z) { anyInside = true; }\n"); + p.C(" if (projPos.z <= u_cullRangeMax.z) { anyInside = true; }\n"); + p.C(" }\n"); + } if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { // This is basically the same value as gl_ClipDistance would take, z + w. - // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. - p.F(" clip0[i] = projZ * outPos.w + outPos.w;\n"); + if (vertexRangeCulling) { + p.C(" clip0[i] = projZ * outPos.w + outPos.w;\n"); + } else { + // Let's not complicate the code overly for this case. We'll clipClampedDepth. + p.C(" clip0[i] = 0.0;\n"); + } + + // This one does happen for rectangles. + if (clipClampedDepth) { + if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { + // On OpenGL/GLES, these values account for the -1 -> 1 range. + p.C(" if (u_depthRange.y - u_depthRange.x >= 1.0) {\n"); + p.C(" clip1[i] = outPos.w + outPos.z;\n"); + } else { + // Everywhere else, it's 0 -> 1, simpler. + p.C(" if (u_depthRange.y >= 1.0) {\n"); + p.C(" clip1[i] = outPos.z;\n"); + } + // This is similar, but for maxz when it's below 65535.0. -1/0 don't matter here. + p.C(" } else if (u_depthRange.x + u_depthRange.y <= 65534.0) {\n"); + p.C(" clip1[i] = outPos.w - outPos.z;\n"); + p.C(" } else {\n"); + p.C(" clip1[i] = 0.0;\n"); + p.C(" }\n"); + } } p.C(" } // for\n"); // Cull any triangle fully outside in the same direction when depth clamp enabled. // Basically simulate cull distances. - p.C(" if (u_cullRangeMin.w > 0.0 && !anyInside) {\n"); - p.C(" return;\n"); - p.C(" }\n"); + if (vertexRangeCulling) { + p.C(" if (u_cullRangeMin.w > 0.0 && !anyInside) {\n"); + p.C(" return;\n"); + p.C(" }\n"); + } if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { // Clipping against one half-space cuts a triangle (17/27), culls (7/27), or creates two triangles (3/27). - p.C(" int indices[4];\n"); - p.C(" float factors[4];\n"); + // We clip against two, so we can generate up to 4 triangles, a polygon with 6 points. + p.C(" int indices[6];\n"); + p.C(" float factors[6];\n"); p.C(" int ind = 0;\n"); // Pass 1 - clip against first half-space. @@ -143,22 +179,80 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); + // Pass 2 - further clip against clamped Z. + if (clipClampedDepth) { + p.C(" int count0 = ind;\n"); + p.C(" int indices1[6];\n"); + p.C(" float factors1[6];\n"); + p.C(" ind = 0;\n"); + + // Let's start by interpolating the clip values. + p.C(" float clip1after[4];\n"); + p.C(" for (int i = 0; i < count0; i++) {\n"); + p.C(" int idx = indices[i];\n"); + p.C(" float factor = factors[i];\n"); + p.C(" int next = idx == 2 ? 0 : idx + 1;\n"); + p.C(" clip1after[i] = mix(clip1[idx], clip1[next], factor);\n"); + p.C(" }\n"); + + // Alright, now time to clip, again. + p.C(" for (int i = 0; i < count0; i++) {\n"); + // First, use this vertex if it doesn't need clipping. + p.C(" if (clip1after[i] >= 0.0) {\n"); + p.C(" indices1[ind] = i;\n"); + p.C(" factors1[ind] = 0.0;\n"); + p.C(" ind++;\n"); + p.C(" }\n"); + + // Next, we generate an interpolated vertex if signs differ. + p.C(" int inext = i == count0 - 1 ? 0 : i + 1;\n"); + p.C(" if (clip1after[i] * clip1after[inext] < 0.0) {\n"); + p.C(" float t = clip1after[i] < 0.0 ? clip1after[i] / (clip1after[i] - clip1after[inext]) : 1.0 - (clip1after[inext] / (clip1after[inext] - clip1after[i]));\n"); + p.C(" indices1[ind] = i;\n"); + p.C(" factors1[ind] = t;\n"); + p.C(" ind++;\n"); + p.C(" }\n"); + + p.C(" }\n"); + } + p.C(" if (ind < 3) {\n"); p.C(" return;\n"); p.C(" }\n"); + p.C(" int idx;\n"); + p.C(" int next;\n"); + p.C(" float factor;\n"); + + auto emitIndex = [&](const char *which) { + if (clipClampedDepth) { + // We have to interpolate between four vertices. + p.F(" idx = indices1[%s];\n", which); + p.F(" factor = factors1[%s];\n", which); + p.C(" next = idx == count0 - 1 ? 0 : idx + 1;\n"); + p.C(" gl_Position = mix(mix(gl_in[indices[idx]].gl_Position, gl_in[(indices[idx] + 1) % 3].gl_Position, factors[idx]), mix(gl_in[indices[next]].gl_Position, gl_in[(indices[next] + 1) % 3].gl_Position, factors[next]), factor);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + const VaryingDef &in = varyings[i]; + const VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(mix(%s[indices[idx]], %s[(indices[idx] + 1) % 3], factors[idx]), mix(%s[indices[next]], %s[(indices[next] + 1) % 3], factors[next]), factor);\n", out.name, in.name, in.name, in.name, in.name); + } + } else { + p.F(" idx = indices[%s];\n", which); + p.F(" factor = factors[%s];\n", which); + p.C(" next = idx == 2 ? 0 : idx + 1;\n"); + p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); + for (size_t i = 0; i < varyings.size(); i++) { + const VaryingDef &in = varyings[i]; + const VaryingDef &out = outVaryings[i]; + p.F(" %s = mix(%s[idx], %s[next], factor);\n", out.name, in.name, in.name); + } + } + p.C(" EmitVertex();\n"); + }; + // Alright, time to actually emit the first triangle. p.C(" for (int i = 0; i < 3; i++) {\n"); - p.C(" int idx = indices[i];\n"); - p.C(" float factor = factors[i];\n"); - p.C(" int next = idx == 2 ? 0 : idx + 1;\n"); - p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); + emitIndex("i"); p.C(" }\n"); // Did we end up with additional triangles? We'll do three points each for the rest. @@ -166,40 +260,13 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" EndPrimitive();\n"); // Point one, always index zero. - p.C(" int idx = indices[0];\n"); - p.C(" float factor = factors[0];\n"); - p.C(" int next = idx == 2 ? 0 : idx + 1;\n"); - p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); + emitIndex("0"); // After that, one less than i (basically a triangle fan.) - p.C(" idx = indices[i - 1];\n"); - p.C(" factor = factors[i - 1];\n"); - p.C(" next = idx == 2 ? 0 : idx + 1;\n"); - p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); + emitIndex("(i - 1)"); // And the new vertex itself. - p.C(" idx = indices[i];\n"); - p.C(" factor = factors[i];\n"); - p.C(" next = idx == 2 ? 0 : idx + 1;\n"); - p.C(" gl_Position = mix(gl_in[idx].gl_Position, gl_in[next].gl_Position, factor);\n"); - for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = mix(%s[idx], %s[next], factor);\n", outVaryings[i].name, varyings[i].name, varyings[i].name); - } - p.C(" EmitVertex();\n"); + emitIndex("i"); p.C(" }\n"); } else { @@ -209,16 +276,16 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); - // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. + // We shouldn't need to worry about rectangles-as-triangles here, since we don't use geometry shaders for that. p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); p.C(" gl_Position = outPos;\n"); if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { } for (size_t i = 0; i < varyings.size(); i++) { - VaryingDef &in = varyings[i]; - VaryingDef &out = outVaryings[i]; - p.F(" %s = %s[i];\n", outVaryings[i].name, varyings[i].name); + const VaryingDef &in = varyings[i]; + const VaryingDef &out = outVaryings[i]; + p.F(" %s = %s[i];\n", out.name, in.name); } // Debug - null the red channel //p.C(" if (i == 0) v_color0Out.x = 0.0;\n"); diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 9c8cb3905b..94ade2fd26 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -379,22 +379,27 @@ std::string GeometryShaderDesc(const GShaderID &id) { void ComputeGeometryShaderID(GShaderID *id_out, const Draw::Bugs &bugs, int prim) { GShaderID id; - bool vertexRangeCulling = - !gstate.isModeThrough() && gstate_c.submitType == SubmitType::DRAW; // neither hw nor sw spline/bezier. See #11692 + bool isModeThrough = gstate.isModeThrough(); + bool isCurve = gstate_c.submitType != SubmitType::DRAW; + bool isTriangle = prim == GE_PRIM_TRIANGLES || prim == GE_PRIM_TRIANGLE_FAN || prim == GE_PRIM_TRIANGLE_STRIP; + + bool vertexRangeCulling = !isCurve; + bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); // If we're not using GS culling, return a zero ID. // Also, only use this for triangle primitives. - if (!vertexRangeCulling || !gstate_c.Supports(GPU_SUPPORTS_GS_CULLING) || (prim != GE_PRIM_TRIANGLES && prim != GE_PRIM_TRIANGLE_FAN && prim != GE_PRIM_TRIANGLE_STRIP)) { + if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle || !gstate_c.Supports(GPU_SUPPORTS_GS_CULLING)) { *id_out = id; return; } id.SetBit(GS_BIT_ENABLED, true); + // Vertex range culling doesn't seem tno happen for spline/bezier, see #11692. + id.SetBit(GS_BIT_CURVE, isCurve); if (gstate.isModeClear()) { // No attribute bits. } else { - bool isModeThrough = gstate.isModeThrough(); bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough; id.SetBit(GS_BIT_LMODE, lmode); diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index ec25abb4d3..560b8a873a 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -109,6 +109,7 @@ enum GShaderBit : uint8_t { GS_BIT_ENABLED = 0, // If not set, we don't use a geo shader. GS_BIT_DO_TEXTURE = 1, // presence of texcoords GS_BIT_LMODE = 2, // presence of specular color (regular color always present) + GS_BIT_CURVE = 3, // curve, which means don't do range culling. }; static inline GShaderBit operator +(GShaderBit bit, int i) { From 8663541403cb89ca113e744d2d359eb5573d4994 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Oct 2022 20:11:10 -0700 Subject: [PATCH 051/374] Vulkan: Avoid max_vertices=12 if unnecessary. --- GPU/Common/GeometryShaderGenerator.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 525dc1f0f5..d9e8c8c22a 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -45,10 +45,16 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); } } + bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); + bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - p.C("layout(triangle_strip, max_vertices = 12) out;\n"); + if (clipClampedDepth && vertexRangeCulling) { + p.C("layout(triangle_strip, max_vertices = 12) out;\n"); + } else { + p.C("layout(triangle_strip, max_vertices = 6) out;\n"); + } if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); @@ -58,8 +64,6 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } std::vector varyings, outVaryings; - bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); - bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); if (id.Bit(GS_BIT_DO_TEXTURE)) { varyings.push_back(VaryingDef{ "vec3", "v_texcoord", Draw::SEM_TEXCOORD0, 0, "highp" }); From 14bf9d1923fe3edbfa8c5f93731e9c9be8dd1803 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Oct 2022 20:23:10 -0700 Subject: [PATCH 052/374] Vulkan: Correct clamped Z clip when clipping neg Z. In the geometry shader, if used, we need to output the clip distance from the clamped Z clip or it gets lost. --- GPU/Common/GeometryShaderGenerator.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index d9e8c8c22a..f6bc7fae5d 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -46,11 +46,11 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } } bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); - bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP); ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - if (clipClampedDepth && vertexRangeCulling) { + if (clipClampedDepth && vertexRangeCulling && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { p.C("layout(triangle_strip, max_vertices = 12) out;\n"); } else { p.C("layout(triangle_strip, max_vertices = 6) out;\n"); @@ -274,14 +274,23 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); } else { - const char *clipSuffix0 = compat.shaderLanguage == HLSL_D3D11 ? "" : "[0]"; + const char *clipSuffix0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; + const char *clipSuffix1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; + const char *clipSuffix2 = compat.shaderLanguage == HLSL_D3D11 ? ".z" : "[2]"; p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); p.C(" vec3 projPos = outPos.xyz / outPos.w;\n"); p.C(" float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); - // We shouldn't need to worry about rectangles-as-triangles here, since we don't use geometry shaders for that. - p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); + if (clipClampedDepth) { + // Copy the clip distance from the vertex shader. + p.F(" gl_ClipDistance%s = gl_in[i].gl_ClipDistance%s;\n", clipSuffix0, clipSuffix0); + p.F(" gl_ClipDistance%s = gl_in[i].gl_ClipDistance%s;\n", clipSuffix1, clipSuffix1); + p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix2); + } else { + // We shouldn't need to worry about rectangles-as-triangles here, since we don't use geometry shaders for that. + p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); + } p.C(" gl_Position = outPos;\n"); if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { } From bc3d3cf9fb8ebecca7e7ab34c6630b45ee4eebbe Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Oct 2022 21:17:17 -0700 Subject: [PATCH 053/374] GPU: Optimize clip distances needed. We only need to write one clip distance to clip clamped depth, since we don't clamp when it needs clipping on both sides. --- GPU/Common/GeometryShaderGenerator.cpp | 4 +--- GPU/Common/VertexShaderGenerator.cpp | 30 ++++++++++---------------- GPU/GLES/ShaderManagerGLES.cpp | 3 +-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index f6bc7fae5d..a814a345da 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -276,7 +276,6 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } else { const char *clipSuffix0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; const char *clipSuffix1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; - const char *clipSuffix2 = compat.shaderLanguage == HLSL_D3D11 ? ".z" : "[2]"; p.C(" for (int i = 0; i < 3; i++) {\n"); // TODO: 3 or gl_in.length()? which will be faster? p.C(" vec4 outPos = gl_in[i].gl_Position;\n"); @@ -285,8 +284,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu if (clipClampedDepth) { // Copy the clip distance from the vertex shader. p.F(" gl_ClipDistance%s = gl_in[i].gl_ClipDistance%s;\n", clipSuffix0, clipSuffix0); - p.F(" gl_ClipDistance%s = gl_in[i].gl_ClipDistance%s;\n", clipSuffix1, clipSuffix1); - p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix2); + p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix1); } else { // We shouldn't need to worry about rectangles-as-triangles here, since we don't use geometry shaders for that. p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 928aa3f6dd..658cbb27f6 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -231,9 +231,8 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag bool vertexRangeCulling = id.Bit(VS_BIT_VERTEX_RANGE_CULLING) && !isModeThrough; bool clipClampedDepth = !isModeThrough && gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); - const char *vertexRangeClipSuffix = "[0]"; - if (vertexRangeCulling && clipClampedDepth) - vertexRangeClipSuffix = "[2]"; + const char *clipClampedDepthSuffix = "[0]"; + const char *vertexRangeClipSuffix = clipClampedDepth ? "[1]" : "[0]"; if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); @@ -419,12 +418,12 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " vec4 gl_Position : SV_Position;\n"); bool clipRange = vertexRangeCulling && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); if (clipClampedDepth && clipRange) { - WRITE(p, " float3 gl_ClipDistance : SV_ClipDistance;\n"); - vertexRangeClipSuffix = ".z"; - } else if (clipClampedDepth) { WRITE(p, " float2 gl_ClipDistance : SV_ClipDistance;\n"); - } else if (clipRange) { + clipClampedDepthSuffix = ".x"; + vertexRangeClipSuffix = ".y"; + } else if (clipClampedDepth || clipRange) { WRITE(p, " float gl_ClipDistance : SV_ClipDistance;\n"); + clipClampedDepthSuffix = ""; vertexRangeClipSuffix = ""; } if (vertexRangeCulling && gstate_c.Supports(GPU_SUPPORTS_CULL_DISTANCE)) { @@ -1267,28 +1266,21 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag } if (clipClampedDepth) { - const char *clip0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; - const char *clip1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; - // This should clip against minz, but only when it's above zero. if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { // On OpenGL/GLES, these values account for the -1 -> 1 range. WRITE(p, " if (u_depthRange.y - u_depthRange.x >= 1.0) {\n"); - WRITE(p, " %sgl_ClipDistance%s = outPos.w + outPos.z;\n", compat.vsOutPrefix, clip0); + WRITE(p, " %sgl_ClipDistance%s = outPos.w + outPos.z;\n", compat.vsOutPrefix, clipClampedDepthSuffix); } else { // Everywhere else, it's 0 -> 1, simpler. WRITE(p, " if (u_depthRange.y >= 1.0) {\n"); - WRITE(p, " %sgl_ClipDistance%s = outPos.z;\n", compat.vsOutPrefix, clip0); + WRITE(p, " %sgl_ClipDistance%s = outPos.z;\n", compat.vsOutPrefix, clipClampedDepthSuffix); } - WRITE(p, " } else {\n"); - WRITE(p, " %sgl_ClipDistance%s = 0.0;\n", compat.vsOutPrefix, clip0); - WRITE(p, " }\n"); - // This is similar, but for maxz when it's below 65535.0. -1/0 don't matter here. - WRITE(p, " if (u_depthRange.x + u_depthRange.y <= 65534.0) {\n"); - WRITE(p, " %sgl_ClipDistance%s = outPos.w - outPos.z;\n", compat.vsOutPrefix, clip1); + WRITE(p, " } else if (u_depthRange.x + u_depthRange.y <= 65534.0) {\n"); + WRITE(p, " %sgl_ClipDistance%s = outPos.w - outPos.z;\n", compat.vsOutPrefix, clipClampedDepthSuffix); WRITE(p, " } else {\n"); - WRITE(p, " %sgl_ClipDistance%s = 0.0;\n", compat.vsOutPrefix, clip1); + WRITE(p, " %sgl_ClipDistance%s = 0.0;\n", compat.vsOutPrefix, clipClampedDepthSuffix); WRITE(p, " }\n"); } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 6868b5d988..50cba0328e 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -199,9 +199,8 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, flags.supportDualSource = (gstate_c.featureFlags & GPU_SUPPORTS_DUALSOURCE_BLEND) != 0; if (!VSID.Bit(VS_BIT_IS_THROUGH) && gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP)) { flags.useClipDistance0 = true; - flags.useClipDistance1 = true; if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) - flags.useClipDistance2 = true; + flags.useClipDistance1 = true; } else if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { flags.useClipDistance0 = true; } From aee2ad46a2cba6409c582e503e69004d4bcf2a55 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 5 Oct 2022 21:41:09 -0700 Subject: [PATCH 054/374] GPU: Verify generated shader buffer length. Hardware tessellation + uberlighting + clamp was exceeding the buffer, causing memory corruption. Let's try to catch it, but also increase buffers to be safe. --- GPU/Common/Draw2D.cpp | 6 ++- GPU/Common/StencilCommon.cpp | 7 ++- GPU/Common/TextureShaderCommon.cpp | 2 - GPU/D3D11/ShaderManagerD3D11.cpp | 6 ++- GPU/GLES/ShaderManagerGLES.cpp | 6 ++- GPU/Vulkan/ShaderManagerVulkan.cpp | 10 ++++- unittest/TestShaderGenerators.cpp | 69 ++++++++++++++++++++++++++---- 7 files changed, 89 insertions(+), 17 deletions(-) diff --git a/GPU/Common/Draw2D.cpp b/GPU/Common/Draw2D.cpp index 83df3ee34d..05bead52e4 100644 --- a/GPU/Common/Draw2D.cpp +++ b/GPU/Common/Draw2D.cpp @@ -178,9 +178,10 @@ void Draw2D::Ensure2DResources() { const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); if (!draw2DVs_) { - char *vsCode = new char[4000]; + char *vsCode = new char[8192]; ShaderWriter writer(vsCode, shaderLanguageDesc, ShaderStage::Vertex); GenerateDraw2DVS(writer); + _assert_msg_(strlen(vsCode) < 8192, "Draw2D VS length error: %d", (int)strlen(vsCode)); draw2DVs_ = draw_->CreateShaderModule(ShaderStage::Vertex, shaderLanguageDesc.shaderLanguage, (const uint8_t *)vsCode, strlen(vsCode), "draw2d_vs"); _assert_(draw2DVs_); delete[] vsCode; @@ -215,9 +216,10 @@ Draw2DPipeline *Draw2D::Create2DPipeline(std::functionGetShaderLanguageDesc(); - char *fsCode = new char[4000]; + char *fsCode = new char[8192]; ShaderWriter writer(fsCode, shaderLanguageDesc, ShaderStage::Fragment); Draw2DPipelineInfo info = generate(writer); + _assert_msg_(strlen(fsCode) < 8192, "Draw2D FS length error: %d", (int)strlen(fsCode)); ShaderModule *fs = draw_->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)fsCode, strlen(fsCode), info.tag); diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index 86a5508b80..d30327df93 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -199,11 +199,14 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU if (!stencilUploadPipeline_) { const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); - char *fsCode = new char[4000]; - char *vsCode = new char[4000]; + char *fsCode = new char[8192]; + char *vsCode = new char[8192]; GenerateStencilFs(fsCode, shaderLanguageDesc, draw_->GetBugs()); GenerateStencilVs(vsCode, shaderLanguageDesc); + _assert_msg_(strlen(fsCode) < 8192, "StenFS length error: %d", (int)strlen(fsCode)); + _assert_msg_(strlen(vsCode) < 8192, "StenVS length error: %d", (int)strlen(vsCode)); + ShaderModule *stencilUploadFs = draw_->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)fsCode, strlen(fsCode), "stencil_fs"); ShaderModule *stencilUploadVs = draw_->CreateShaderModule(ShaderStage::Vertex, shaderLanguageDesc.shaderLanguage, (const uint8_t *)vsCode, strlen(vsCode), "stencil_vs"); diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index 1c67818a85..2860389fc2 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -209,7 +209,6 @@ Draw2DPipeline *TextureShaderCache::GetDepalettizeShader(uint32_t clutMode, GETe config.smoothedDepal = smoothedDepal; config.depthUpperBits = depthUpperBits; - char *buffer = new char[4096]; Draw2DPipeline *ts = draw2D_->Create2DPipeline([=](ShaderWriter &writer) -> Draw2DPipelineInfo { GenerateDepalFs(writer, config); return Draw2DPipelineInfo{ @@ -219,7 +218,6 @@ Draw2DPipeline *TextureShaderCache::GetDepalettizeShader(uint32_t clutMode, GETe samplers }; }); - delete[] buffer; depalCache_[id] = ts; diff --git a/GPU/D3D11/ShaderManagerD3D11.cpp b/GPU/D3D11/ShaderManagerD3D11.cpp index a8537c8545..0560b52941 100644 --- a/GPU/D3D11/ShaderManagerD3D11.cpp +++ b/GPU/D3D11/ShaderManagerD3D11.cpp @@ -88,9 +88,11 @@ std::string D3D11VertexShader::GetShaderString(DebugShaderStringType type) const } } +static constexpr size_t CODE_BUFFER_SIZE = 32768; + ShaderManagerD3D11::ShaderManagerD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context, D3D_FEATURE_LEVEL featureLevel) : ShaderManagerCommon(draw), device_(device), context_(context), featureLevel_(featureLevel) { - codeBuffer_ = new char[16384]; + codeBuffer_ = new char[CODE_BUFFER_SIZE]; memset(&ub_base, 0, sizeof(ub_base)); memset(&ub_lights, 0, sizeof(ub_lights)); memset(&ub_bones, 0, sizeof(ub_bones)); @@ -211,6 +213,7 @@ void ShaderManagerD3D11::GetShaders(int prim, u32 vertType, D3D11VertexShader ** uint32_t attrMask; uint64_t uniformMask; GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, &genErrorString); + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); vs = new D3D11VertexShader(device_, featureLevel_, VSID, codeBuffer_, vertType, useHWTransform); vsCache_[VSID] = vs; } else { @@ -225,6 +228,7 @@ void ShaderManagerD3D11::GetShaders(int prim, u32 vertType, D3D11VertexShader ** std::string genErrorString; uint64_t uniformMask; GenerateFragmentShader(FSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &uniformMask, nullptr, &genErrorString); + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "FS length error: %d", (int)strlen(codeBuffer_)); fs = new D3D11FragmentShader(device_, featureLevel_, FSID, codeBuffer_, useHWTransform); fsCache_[FSID] = fs; } else { diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 6868b5d988..6e2bcd3c63 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -662,10 +662,12 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu } } +static constexpr size_t CODE_BUFFER_SIZE = 32768; + ShaderManagerGLES::ShaderManagerGLES(Draw::DrawContext *draw) : ShaderManagerCommon(draw), fsCache_(16), vsCache_(16) { render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); - codeBuffer_ = new char[16384]; + codeBuffer_ = new char[CODE_BUFFER_SIZE]; lastFSID_.set_invalid(); lastVSID_.set_invalid(); } @@ -728,6 +730,7 @@ Shader *ShaderManagerGLES::CompileFragmentShader(FShaderID FSID) { ERROR_LOG(G3D, "Shader gen error: %s", errorString.c_str()); return nullptr; } + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "FS length error: %d", (int)strlen(codeBuffer_)); std::string desc = FragmentShaderDesc(FSID); ShaderDescGLES params{ GL_FRAGMENT_SHADER, 0, uniformMask }; return new Shader(render_, codeBuffer_, desc, params); @@ -742,6 +745,7 @@ Shader *ShaderManagerGLES::CompileVertexShader(VShaderID VSID) { ERROR_LOG(G3D, "Shader gen error: %s", errorString.c_str()); return nullptr; } + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); std::string desc = VertexShaderDesc(VSID); ShaderDescGLES params{ GL_VERTEX_SHADER, attrMask, uniformMask }; params.useHWTransform = useHWTransform; diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 00649a6be1..c7724da670 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -194,9 +194,11 @@ std::string VulkanGeometryShader::GetShaderString(DebugShaderStringType type) co } } +static constexpr size_t CODE_BUFFER_SIZE = 32768; + ShaderManagerVulkan::ShaderManagerVulkan(Draw::DrawContext *draw) : ShaderManagerCommon(draw), compat_(GLSL_VULKAN), fsCache_(16), vsCache_(16), gsCache_(16) { - codeBuffer_ = new char[16384]; + codeBuffer_ = new char[CODE_BUFFER_SIZE]; VulkanContext *vulkan = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT); uboAlignment_ = vulkan->GetPhysicalDeviceProperties().properties.limits.minUniformBufferOffsetAlignment; memset(&ub_base, 0, sizeof(ub_base)); @@ -330,6 +332,7 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader uint32_t attributeMask = 0; // Not used bool success = GenerateVertexShader(VSID, codeBuffer_, compat_, draw_->GetBugs(), &attributeMask, &uniformMask, &genErrorString); _assert_msg_(success, "VS gen error: %s", genErrorString.c_str()); + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); vs = new VulkanVertexShader(vulkan, VSID, codeBuffer_, useHWTransform); vsCache_.Insert(VSID, vs); } @@ -342,6 +345,7 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader FragmentShaderFlags flags; bool success = GenerateFragmentShader(FSID, codeBuffer_, compat_, draw_->GetBugs(), &uniformMask, &flags, &genErrorString); _assert_msg_(success, "FS gen error: %s", genErrorString.c_str()); + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "FS length error: %d", (int)strlen(codeBuffer_)); fs = new VulkanFragmentShader(vulkan, FSID, flags, codeBuffer_); fsCache_.Insert(FSID, fs); } @@ -354,6 +358,7 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader std::string genErrorString; bool success = GenerateGeometryShader(GSID, codeBuffer_, compat_, draw_->GetBugs(), &genErrorString); _assert_msg_(success, "GS gen error: %s", genErrorString.c_str()); + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "GS length error: %d", (int)strlen(codeBuffer_)); gs = new VulkanGeometryShader(vulkan, GSID, codeBuffer_); gsCache_.Insert(GSID, gs); } @@ -512,6 +517,7 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { if (!GenerateVertexShader(id, codeBuffer_, compat_, draw_->GetBugs(), &attributeMask, &uniformMask, &genErrorString)) { return false; } + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); VulkanVertexShader *vs = new VulkanVertexShader(vulkan, id, codeBuffer_, useHWTransform); vsCache_.Insert(id, vs); } @@ -529,6 +535,7 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { if (!GenerateFragmentShader(id, codeBuffer_, compat_, draw_->GetBugs(), &uniformMask, &flags, &genErrorString)) { return false; } + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "FS length error: %d", (int)strlen(codeBuffer_)); VulkanFragmentShader *fs = new VulkanFragmentShader(vulkan, id, flags, codeBuffer_); fsCache_.Insert(id, fs); } @@ -543,6 +550,7 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { if (!GenerateGeometryShader(id, codeBuffer_, compat_, draw_->GetBugs(), &genErrorString)) { return false; } + _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "GS length error: %d", (int)strlen(codeBuffer_)); VulkanGeometryShader *gs = new VulkanGeometryShader(vulkan, id, codeBuffer_); gsCache_.Insert(id, gs); } diff --git a/unittest/TestShaderGenerators.cpp b/unittest/TestShaderGenerators.cpp index 346fadf643..fa5fd1eb7c 100644 --- a/unittest/TestShaderGenerators.cpp +++ b/unittest/TestShaderGenerators.cpp @@ -25,6 +25,8 @@ #include "GPU/D3D9/D3D9ShaderCompiler.h" #endif +static constexpr size_t CODE_BUFFER_SIZE = 32768; + bool GenerateFShader(FShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs bugs, std::string *errorString) { uint64_t uniformMask; switch (lang) { @@ -243,10 +245,13 @@ bool TestReinterpretShaders() { continue; // useless shader! ShaderWriter writer(buffer, desc, ShaderStage::Fragment, nullptr, 0); GenerateReinterpretFragmentShader(writer, fmts[i], fmts[j]); + if (strlen(buffer) >= 8192) { + printf("Reinterpret fragment shader %d exceeded buffer:\n\n%s\n", (int)j, LineNumberString(buffer).c_str()); + failed = true; + } if (!TestCompileShader(buffer, languages[k], ShaderStage::Fragment, &errorMessage)) { - printf("Error compiling fragment shader %d:\n\n%s\n\n%s\n", (int)j, LineNumberString(buffer).c_str(), errorMessage.c_str()); + printf("Error compiling reinterpret fragment shader %d:\n\n%s\n\n%s\n", (int)j, LineNumberString(buffer).c_str(), errorMessage.c_str()); failed = true; - return false; } else { printf("===\n%s\n===\n", buffer); } @@ -282,19 +287,25 @@ bool TestStencilShaders() { // Generate all despite failures - it's only 6. GenerateStencilFs(buffer, desc, bugs); + if (strlen(buffer) >= 8192) { + printf("Stencil fragment shader exceeded buffer:\n\n%s\n", LineNumberString(buffer).c_str()); + failed = true; + } if (!TestCompileShader(buffer, languages[k], ShaderStage::Fragment, &errorMessage)) { printf("Error compiling stencil shader:\n\n%s\n\n%s\n", LineNumberString(buffer).c_str(), errorMessage.c_str()); failed = true; - return false; } else { printf("===\n%s\n===\n", buffer); } GenerateStencilVs(buffer, desc); + if (strlen(buffer) >= 8192) { + printf("Stencil vertex shader exceeded buffer:\n\n%s\n", LineNumberString(buffer).c_str()); + failed = true; + } if (!TestCompileShader(buffer, languages[k], ShaderStage::Vertex, &errorMessage)) { printf("Error compiling stencil shader:\n\n%s\n\n%s\n", LineNumberString(buffer).c_str(), errorMessage.c_str()); failed = true; - return false; } else { printf("===\n%s\n===\n", buffer); } @@ -319,8 +330,6 @@ bool TestDepalShaders() { char *buffer = new char[65536]; - bool failed = false; - for (int k = 0; k < ARRAY_SIZE(languages); k++) { printf("=== %s ===\n\n", ShaderLanguageToString(languages[k])); @@ -340,9 +349,14 @@ bool TestDepalShaders() { ShaderWriter writer(buffer, desc, ShaderStage::Fragment); GenerateDepalFs(writer, config); + if (strlen(buffer) >= 8192) { + printf("Depal shader exceeded buffer:\n\n%s\n", LineNumberString(buffer).c_str()); + delete[] buffer; + return false; + } if (!TestCompileShader(buffer, languages[k], ShaderStage::Fragment, &errorMessage)) { printf("Error compiling depal shader:\n\n%s\n\n%s\n", LineNumberString(buffer).c_str(), errorMessage.c_str()); - failed = true; + delete[] buffer; return false; } else { printf("===\n%s\n===\n", buffer); @@ -350,7 +364,7 @@ bool TestDepalShaders() { } delete[] buffer; - return !failed; + return true; } const ShaderLanguage languages[] = { @@ -410,6 +424,16 @@ bool TestVertexShaders() { } } + for (int j = 0; j < numLanguages; j++) { + if (strlen(buffer[j]) >= CODE_BUFFER_SIZE) { + printf("Vertex shader exceeded buffer:\n\n%s\n", LineNumberString(buffer[j]).c_str()); + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } + return false; + } + } + // Now that we have the strings ready for easy comparison (buffer,4 in the watch window), // let's try to compile them. for (int j = 0; j < numLanguages; j++) { @@ -417,6 +441,9 @@ bool TestVertexShaders() { std::string errorMessage; if (!TestCompileShader(buffer[j], languages[j], ShaderStage::Vertex, &errorMessage)) { printf("Error compiling vertex shader %d:\n\n%s\n\n%s\n", (int)j, LineNumberString(buffer[j]).c_str(), errorMessage.c_str()); + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } return false; } successes++; @@ -471,6 +498,16 @@ bool TestFragmentShaders() { // We ignore the contents of the error string here, not even gonna try to compile if it errors. } + for (int j = 0; j < numLanguages; j++) { + if (strlen(buffer[j]) >= CODE_BUFFER_SIZE) { + printf("Fragment shader exceeded buffer:\n\n%s\n", LineNumberString(buffer[j]).c_str()); + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } + return false; + } + } + // Now that we have the strings ready for easy comparison (buffer,4 in the watch window), // let's try to compile them. for (int j = 0; j < numLanguages; j++) { @@ -478,6 +515,9 @@ bool TestFragmentShaders() { std::string errorMessage; if (!TestCompileShader(buffer[j], languages[j], ShaderStage::Fragment, &errorMessage)) { printf("Error compiling fragment shader:\n\n%s\n\n%s\n", LineNumberString(buffer[j]).c_str(), errorMessage.c_str()); + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } return false; } successes++; @@ -527,6 +567,16 @@ bool TestGeometryShaders() { // We ignore the contents of the error string here, not even gonna try to compile if it errors. } + for (int j = 0; j < numLanguages; j++) { + if (strlen(buffer[j]) >= CODE_BUFFER_SIZE) { + printf("Geoemtry shader exceeded buffer:\n\n%s\n", LineNumberString(buffer[j]).c_str()); + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } + return false; + } + } + // Now that we have the strings ready for easy comparison (buffer,4 in the watch window), // let's try to compile them. for (int j = 0; j < numLanguages; j++) { @@ -534,6 +584,9 @@ bool TestGeometryShaders() { std::string errorMessage; if (!TestCompileShader(buffer[j], languages[j], ShaderStage::Geometry, &errorMessage)) { printf("Error compiling geometry shader:\n\n%s\n\n%s\n", LineNumberString(buffer[j]).c_str(), errorMessage.c_str()); + for (int i = 0; i < numLanguages; i++) { + delete[] buffer[i]; + } return false; } successes++; From 3aa863ec4141955eb5d0b1bffe64dfe00b127cde Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 6 Oct 2022 00:34:02 -0700 Subject: [PATCH 055/374] GPU: Clip against neg Z even w/o cull support. This should fix rendering issues on Apple devices. --- GPU/Common/VertexShaderGenerator.cpp | 29 +++++++++++++++------------- GPU/GPUCommon.cpp | 9 +++++---- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 658cbb27f6..24f118603f 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -1287,19 +1287,22 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (vertexRangeCulling && !IsVRBuild()) { WRITE(p, " vec3 projPos = outPos.xyz / outPos.w;\n"); WRITE(p, " float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); - // Vertex range culling doesn't happen when Z clips, note sign of w is important. - WRITE(p, " if (u_cullRangeMin.w <= 0.0 || projZ * outPos.w > -outPos.w) {\n"); - const char *outMin = "projPos.x < u_cullRangeMin.x || projPos.y < u_cullRangeMin.y"; - const char *outMax = "projPos.x > u_cullRangeMax.x || projPos.y > u_cullRangeMax.y"; - WRITE(p, " if ((%s) || (%s)) {\n", outMin, outMax); - WRITE(p, " outPos.xyzw = u_cullRangeMax.wwww;\n"); - WRITE(p, " }\n"); - WRITE(p, " }\n"); - WRITE(p, " if (u_cullRangeMin.w <= 0.0) {\n"); - WRITE(p, " if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); - WRITE(p, " outPos.xyzw = u_cullRangeMax.wwww;\n"); - WRITE(p, " }\n"); - WRITE(p, " }\n"); + + if (!bugs.Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) { + // Vertex range culling doesn't happen when Z clips, note sign of w is important. + WRITE(p, " if (u_cullRangeMin.w <= 0.0 || projZ * outPos.w > -outPos.w) {\n"); + const char *outMin = "projPos.x < u_cullRangeMin.x || projPos.y < u_cullRangeMin.y"; + const char *outMax = "projPos.x > u_cullRangeMax.x || projPos.y > u_cullRangeMax.y"; + WRITE(p, " if ((%s) || (%s)) {\n", outMin, outMax); + WRITE(p, " outPos.xyzw = u_cullRangeMax.wwww;\n"); + WRITE(p, " }\n"); + WRITE(p, " }\n"); + WRITE(p, " if (u_cullRangeMin.w <= 0.0) {\n"); + WRITE(p, " if (projPos.z < u_cullRangeMin.z || projPos.z > u_cullRangeMax.z) {\n"); + WRITE(p, " outPos.xyzw = u_cullRangeMax.wwww;\n"); + WRITE(p, " }\n"); + WRITE(p, " }\n"); + } const char *cull0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; const char *cull1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 7c6e7620eb..9830984739 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3305,10 +3305,11 @@ u32 GPUCommon::CheckGPUFeatures() const { features |= GPU_SUPPORTS_DEPTH_TEXTURE; } - if (!draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL)) { - if (draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported) { - features |= GPU_SUPPORTS_VS_RANGE_CULLING; - } + bool canClipOrCull = draw_->GetDeviceCaps().clipDistanceSupported || draw_->GetDeviceCaps().cullDistanceSupported; + bool canDiscardVertex = draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL); + if (canClipOrCull || canDiscardVertex) { + // We'll dynamically use the parts that are supported, to reduce artifacts as much as possible. + features |= GPU_SUPPORTS_VS_RANGE_CULLING; } if (draw_->GetDeviceCaps().framebufferFetchSupported) { From bf25f4b283fd04c24f54f3d055caca9c981b5ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Oct 2022 10:40:58 +0200 Subject: [PATCH 056/374] Shader uniforms (VK/D3D11): Fix issue where we could overwrite the fourth component padding. --- Common/Data/Convert/SmallDataConvert.h | 14 ++++++++++++++ GPU/Common/ShaderUniforms.cpp | 10 ++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Common/Data/Convert/SmallDataConvert.h b/Common/Data/Convert/SmallDataConvert.h index a877295918..e130596a3f 100644 --- a/Common/Data/Convert/SmallDataConvert.h +++ b/Common/Data/Convert/SmallDataConvert.h @@ -82,6 +82,20 @@ inline void Uint8x3ToFloat4(float f[4], uint32_t u) { #endif } +inline void Uint8x3ToFloat3(float f[4], uint32_t u) { +#if defined(_M_SSE) || PPSSPP_ARCH(ARM_NEON) + float temp[3]; + Uint8x4ToFloat4(temp, u & 0xFFFFFF); + f[0] = temp[0]; + f[1] = temp[1]; + f[2] = temp[2]; +#else + f[0] = ((u >> 0) & 0xFF) * (1.0f / 255.0f); + f[1] = ((u >> 8) & 0xFF) * (1.0f / 255.0f); + f[2] = ((u >> 16) & 0xFF) * (1.0f / 255.0f); +#endif +} + inline void Uint8x3ToInt4(int i[4], uint32_t u) { i[0] = ((u >> 0) & 0xFF); i[1] = ((u >> 8) & 0xFF); diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index 05683e5040..b276f7f094 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -74,7 +74,7 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering) { if (dirtyUniforms & DIRTY_TEXENV) { - Uint8x3ToFloat4(ub->texEnvColor, gstate.texenvcolor); + Uint8x3ToFloat3(ub->texEnvColor, gstate.texenvcolor); } if (dirtyUniforms & DIRTY_ALPHACOLORREF) { Uint8x3ToInt4_Alpha(ub->alphaColorRef, gstate.getColorTestRef(), gstate.getAlphaTestRef() & gstate.getAlphaTestMask()); @@ -86,8 +86,8 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView Uint8x3ToFloat4(ub->fogColor, gstate.fogcolor); } if (dirtyUniforms & DIRTY_SHADERBLEND) { - Uint8x3ToFloat4(ub->blendFixA, gstate.getFixA()); - Uint8x3ToFloat4(ub->blendFixB, gstate.getFixB()); + Uint8x3ToFloat3(ub->blendFixA, gstate.getFixA()); + Uint8x3ToFloat3(ub->blendFixB, gstate.getFixB()); } if (dirtyUniforms & DIRTY_TEXCLAMP) { const float invW = 1.0f / (float)gstate_c.curTextureWidth; @@ -303,9 +303,7 @@ void LightUpdateUniforms(UB_VS_Lights *ub, uint64_t dirtyUniforms) { } if (dirtyUniforms & DIRTY_MATEMISSIVE) { // We're not touching the fourth f32 here, because we store an u32 of control bits in it. - float temp[4]; - Uint8x3ToFloat4(temp, gstate.materialemissive); - memcpy(ub->materialEmissive, temp, 12); + Uint8x3ToFloat3(ub->materialEmissive, gstate.materialemissive); } if (dirtyUniforms & DIRTY_LIGHT_CONTROL) { ub->lightControl = PackLightControlBits(); From 131c1ca79e33a0ab169b0c20aa24a6b0c288fd1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 6 Oct 2022 20:46:57 +0200 Subject: [PATCH 057/374] Typo fix, thanks iota97 --- Common/Data/Convert/SmallDataConvert.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/Data/Convert/SmallDataConvert.h b/Common/Data/Convert/SmallDataConvert.h index e130596a3f..95558a17df 100644 --- a/Common/Data/Convert/SmallDataConvert.h +++ b/Common/Data/Convert/SmallDataConvert.h @@ -84,7 +84,7 @@ inline void Uint8x3ToFloat4(float f[4], uint32_t u) { inline void Uint8x3ToFloat3(float f[4], uint32_t u) { #if defined(_M_SSE) || PPSSPP_ARCH(ARM_NEON) - float temp[3]; + float temp[4]; Uint8x4ToFloat4(temp, u & 0xFFFFFF); f[0] = temp[0]; f[1] = temp[1]; From d716b74480c020a9452e18cf1dc897934ee2a91f Mon Sep 17 00:00:00 2001 From: sum2012 Date: Fri, 7 Oct 2022 06:01:53 +0800 Subject: [PATCH 058/374] Fix as @hrydgard suggest --- Core/HLE/sceKernelModule.cpp | 3 +-- Core/HLE/sceMpeg.h | 2 +- Core/HLE/scePsmf.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 5cd5dedbf7..cb1e9d091d 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1144,8 +1144,7 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) { } static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) { - u32 crc = crc32(0, Z_NULL, 0); - crc = crc32(crc, ptr, elfSize); + u32 crc = crc32(0, ptr, elfSize); PSPModule *module = new PSPModule(); kernelObjects.Create(module); loadedModules.insert(module->GetUID()); diff --git a/Core/HLE/sceMpeg.h b/Core/HLE/sceMpeg.h index 925a2b005b..e8bde2da34 100644 --- a/Core/HLE/sceMpeg.h +++ b/Core/HLE/sceMpeg.h @@ -79,7 +79,7 @@ void __MpegInit(); void __MpegDoState(PointerWrap &p); void __MpegShutdown(); -void __MpegLoadModule(int version,u32 crc); +void __MpegLoadModule(int version, u32 crc); void Register_sceMpeg(); diff --git a/Core/HLE/scePsmf.h b/Core/HLE/scePsmf.h index ae143fce04..bb0e53c411 100644 --- a/Core/HLE/scePsmf.h +++ b/Core/HLE/scePsmf.h @@ -21,7 +21,7 @@ void Register_scePsmf(); void Register_scePsmfPlayer(); void __PsmfInit(); -void __PsmfPlayerLoadModule(int devkitVersion,u32 crc); +void __PsmfPlayerLoadModule(int devkitVersion, u32 crc); void __PsmfDoState(PointerWrap &p); void __PsmfPlayerDoState(PointerWrap &p); void __PsmfShutdown(); From 62fe178608d4c3b9cbd9a8144185551f218ef8a2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 6 Oct 2022 22:45:18 -0700 Subject: [PATCH 059/374] Jpeg: Cleanup Init/Finish error checks. --- Core/HLE/sceJpeg.cpp | 58 +++++++++++++++++++++++++++++++++----------- Core/HLE/sceMpeg.h | 1 - 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index e7f3011bdc..c0b6a3087c 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -24,7 +24,6 @@ #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/HLE/sceJpeg.h" -#include "Core/HLE/sceMpeg.h" #include "GPU/GPUCommon.h" #include "Core/MemMap.h" #include "Core/Reporting.h" @@ -43,20 +42,33 @@ struct u24_be { } }; +static int mjpegInited = 0; static int mjpegWidth, mjpegHeight; void __JpegInit() { + mjpegInited = 0; mjpegWidth = 0; mjpegHeight = 0; } +enum : uint32_t { + ERROR_JPEG_CANNOT_FINISH = 0x80650039, + ERROR_JPEG_ALREADY_INIT = 0x80650042, + ERROR_JPEG_INVALID_VALUE = 0x80650051, +}; + void __JpegDoState(PointerWrap &p) { - auto s = p.Section("sceJpeg", 1); + auto s = p.Section("sceJpeg", 1, 2); if (!s) return; Do(p, mjpegWidth); Do(p, mjpegHeight); + if (s >= 2) { + Do(p, mjpegInited); + } else { + mjpegInited = -1; + } } static int getWidthHeight(int width, int height) { @@ -181,11 +193,6 @@ static int sceJpegDecodeMJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr, int dht return __DecodeJpeg(jpegAddr, jpegSize, imageAddr); } -static int sceJpegDeleteMJpeg() { - WARN_LOG(ME, "sceJpegDeleteMJpeg()"); - return 0; -} - static int sceJpegDecodeMJpegSuccessively(u32 jpegAddr, int jpegSize, u32 imageAddr, int dhtMode) { if (!Memory::IsValidAddress(jpegAddr)) { ERROR_LOG(ME, "sceJpegDecodeMJpegSuccessively: Bad JPEG address 0x%08x", jpegAddr); @@ -208,11 +215,6 @@ static int sceJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferW return 0; } -static int sceJpegFinishMJpeg() { - WARN_LOG(ME, "sceJpegFinishMJpeg()"); - return 0; -} - static int getYCbCrBufferSize(int w, int h) { // Return necessary buffer size for conversion: 12 bits per pixel return ((w * h) >> 1) * 3; @@ -378,6 +380,9 @@ static int sceJpeg_9B36444C() { } static int sceJpegCreateMJpeg(int width, int height) { + // Assume valid usage in an old save state. + if (mjpegInited == -1) + mjpegInited = 1; mjpegWidth = width; mjpegHeight = height; @@ -385,11 +390,36 @@ static int sceJpegCreateMJpeg(int width, int height) { return 0; } -static int sceJpegInitMJpeg() { - WARN_LOG(ME, "sceJpegInitMJpeg()"); +static int sceJpegDeleteMJpeg() { + WARN_LOG(ME, "sceJpegDeleteMJpeg()"); + if (mjpegInited == -1) + mjpegInited = 1; + mjpegWidth = 0; + mjpegHeight = 0; return 0; } +static int sceJpegInitMJpeg() { + if (mjpegInited == 1) + return hleLogError(ME, ERROR_JPEG_ALREADY_INIT, "already inited"); + + // If it was -1, it's from an old save state, avoid double init error but assume inited. + if (mjpegInited == 0) + mjpegInited = 1; + return hleLogDebug(ME, hleDelayResult(0, "mjpeg init", 130)); +} + +static int sceJpegFinishMJpeg() { + if (mjpegInited == 0) + return hleLogError(ME, ERROR_JPEG_CANNOT_FINISH, "already inited"); + if (mjpegInited != -1 && (mjpegWidth != 0 || mjpegHeight != 0)) + return hleLogError(ME, ERROR_JPEG_CANNOT_FINISH, "mjpeg not deleted"); + + // Even from an old save state, if we see this we leave compat mode. + mjpegInited = 0; + return hleLogDebug(ME, hleDelayResult(0, "mjpeg finish", 120)); +} + static int sceJpegMJpegCscWithColorOption() { ERROR_LOG_REPORT(ME, "UNIMPL sceJpegMJpegCscWithColorOption()"); return 0; diff --git a/Core/HLE/sceMpeg.h b/Core/HLE/sceMpeg.h index e8bde2da34..c423419e99 100644 --- a/Core/HLE/sceMpeg.h +++ b/Core/HLE/sceMpeg.h @@ -32,7 +32,6 @@ enum { ERROR_MPEG_NOT_YET_INIT = 0x80618009, ERROR_MPEG_AVC_INVALID_VALUE = 0x806201fe, ERROR_MPEG_AVC_DECODE_FATAL = 0x80628002, - ERROR_JPEG_INVALID_VALUE = 0x80650051, }; // MPEG statics. From 0931b343c242b47456c9dc3d594ed6359ce53ada Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 6 Oct 2022 23:07:33 -0700 Subject: [PATCH 060/374] Jpeg: Validate CreateMJpeg() parameters. --- Core/HLE/sceJpeg.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index c0b6a3087c..176741dfca 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -43,16 +43,18 @@ struct u24_be { }; static int mjpegInited = 0; -static int mjpegWidth, mjpegHeight; +static int mjpegWidth = 0x7FFFFFFF; +static int mjpegHeight = 0x7FFFFFFF; void __JpegInit() { mjpegInited = 0; - mjpegWidth = 0; - mjpegHeight = 0; + mjpegWidth = 0x7FFFFFFF; + mjpegHeight = 0x7FFFFFFF; } enum : uint32_t { - ERROR_JPEG_CANNOT_FINISH = 0x80650039, + ERROR_JPEG_INVALID_SIZE = 0x80650020, + ERROR_JPEG_INVALID_STATE = 0x80650039, ERROR_JPEG_ALREADY_INIT = 0x80650042, ERROR_JPEG_INVALID_VALUE = 0x80650051, }; @@ -380,23 +382,33 @@ static int sceJpeg_9B36444C() { } static int sceJpegCreateMJpeg(int width, int height) { + if (mjpegInited == 0) + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "not yet inited"); + if (mjpegInited == 1 && mjpegWidth != 0x7FFFFFFF) + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "already created"); + if (width > 1024) + return hleLogError(ME, ERROR_JPEG_INVALID_SIZE, "width outside bounds"); + // Assume valid usage in an old save state. if (mjpegInited == -1) mjpegInited = 1; mjpegWidth = width; mjpegHeight = height; - INFO_LOG(ME, "sceJpegCreateMJpeg(%i, %i)", width, height); - return 0; + return hleLogSuccessInfoI(ME, 0); } static int sceJpegDeleteMJpeg() { - WARN_LOG(ME, "sceJpegDeleteMJpeg()"); + if (mjpegInited == 0) + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "not yet inited"); + if (mjpegInited == 1 && mjpegWidth == 0x7FFFFFFF) + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "nto yet created"); + if (mjpegInited == -1) mjpegInited = 1; - mjpegWidth = 0; - mjpegHeight = 0; - return 0; + mjpegWidth = 0x7FFFFFFF; + mjpegHeight = 0x7FFFFFFF; + return hleLogSuccessInfoI(ME, 0); } static int sceJpegInitMJpeg() { @@ -411,9 +423,9 @@ static int sceJpegInitMJpeg() { static int sceJpegFinishMJpeg() { if (mjpegInited == 0) - return hleLogError(ME, ERROR_JPEG_CANNOT_FINISH, "already inited"); - if (mjpegInited != -1 && (mjpegWidth != 0 || mjpegHeight != 0)) - return hleLogError(ME, ERROR_JPEG_CANNOT_FINISH, "mjpeg not deleted"); + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "already inited"); + if (mjpegInited != -1 && (mjpegWidth != 0x7FFFFFFF || mjpegHeight != 0x7FFFFFFF)) + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "mjpeg not deleted"); // Even from an old save state, if we see this we leave compat mode. mjpegInited = 0; From 7f87cd077a04456cd380c394225c6054c9fe3012 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 7 Oct 2022 00:24:19 -0700 Subject: [PATCH 061/374] Jpeg: Play it safe with load/unload handling. --- Core/HLE/sceJpeg.cpp | 7 +++++++ Core/HLE/sceJpeg.h | 2 ++ Core/HLE/sceUtility.cpp | 22 +++++++++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index 176741dfca..3e8ecc406e 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -442,6 +442,13 @@ static int sceJpegDecompressAllImage() { return 0; } +void JpegNotifyLoadStatus(int state) { + if (state == -1) { + // Reset our state on unload. + __JpegInit(); + } +} + const HLEFunction sceJpeg[] = { {0X0425B986, &WrapI_V, "sceJpegDecompressAllImage", 'i', "" }, diff --git a/Core/HLE/sceJpeg.h b/Core/HLE/sceJpeg.h index b2decf1ddc..e7a7797d29 100644 --- a/Core/HLE/sceJpeg.h +++ b/Core/HLE/sceJpeg.h @@ -19,6 +19,8 @@ class PointerWrap; +void JpegNotifyLoadStatus(int state); + void Register_sceJpeg(); void __JpegInit(); void __JpegDoState(PointerWrap &p); diff --git a/Core/HLE/sceUtility.cpp b/Core/HLE/sceUtility.cpp index f1d7f73d0b..b205ed956d 100644 --- a/Core/HLE/sceUtility.cpp +++ b/Core/HLE/sceUtility.cpp @@ -34,6 +34,7 @@ #include "Core/Reporting.h" #include "Core/System.h" +#include "Core/HLE/sceJpeg.h" #include "Core/HLE/sceKernel.h" #include "Core/HLE/sceKernelInterrupt.h" #include "Core/HLE/sceKernelMemory.h" @@ -79,16 +80,21 @@ static const int mpegBaseModuleDeps[] = {0x0300, 0}; static const int mp4ModuleDeps[] = {0x0300, 0}; struct ModuleLoadInfo { - ModuleLoadInfo(int m, u32 s) : mod(m), size(s), dependencies(noDeps) { + ModuleLoadInfo(int m, u32 s, void(*n)(int) = nullptr) : mod(m), size(s), dependencies(noDeps), notify(n) { } - ModuleLoadInfo(int m, u32 s, const int *d) : mod(m), size(s), dependencies(d) { + ModuleLoadInfo(int m, u32 s, const int *d, void(*n)(int) = nullptr) : mod(m), size(s), dependencies(d), notify(n) { } const int mod; const u32 size; const int *const dependencies; + void (*notify)(int state); }; +static void NotifyLoadStatusAvcodec(int state) { + JpegNotifyLoadStatus(state); +} + static const ModuleLoadInfo moduleLoadInfo[] = { ModuleLoadInfo(0x0100, 0x00014000), ModuleLoadInfo(0x0101, 0x00020000), @@ -104,7 +110,7 @@ static const ModuleLoadInfo moduleLoadInfo[] = { ModuleLoadInfo(0x0202, 0x00000000), ModuleLoadInfo(0x0203, 0x00000000), ModuleLoadInfo(0x02ff, 0x00000000), - ModuleLoadInfo(0x0300, 0x00000000), + ModuleLoadInfo(0x0300, 0x00000000, &NotifyLoadStatusAvcodec), ModuleLoadInfo(0x0301, 0x00000000), ModuleLoadInfo(0x0302, 0x00008000, atrac3PlusModuleDeps), ModuleLoadInfo(0x0303, 0x0000c000, mpegBaseModuleDeps), @@ -470,12 +476,16 @@ static u32 sceUtilityLoadAvModule(u32 module) } INFO_LOG(SCEUTILITY, "0=sceUtilityLoadAvModule(%i)", module); + if (module == 0) + JpegNotifyLoadStatus(1); return hleDelayResult(0, "utility av module loaded", 25000); } static u32 sceUtilityUnloadAvModule(u32 module) { INFO_LOG(SCEUTILITY,"0=sceUtilityUnloadAvModule(%i)", module); + if (module == 0) + JpegNotifyLoadStatus(-1); return hleDelayResult(0, "utility av module unloaded", 800); } @@ -516,6 +526,9 @@ static u32 sceUtilityLoadModule(u32 module) { currentlyLoadedModules[module] = 0; } + if (info->notify) + info->notify(1); + // TODO: Each module has its own timing, technically, but this is a low-end. if (module == 0x3FF) return hleDelayResult(hleLogSuccessInfoI(SCEUTILITY, 0), "utility module loaded", 130); @@ -537,6 +550,9 @@ static u32 sceUtilityUnloadModule(u32 module) { } currentlyLoadedModules.erase(module); + if (info->notify) + info->notify(-1); + // TODO: Each module has its own timing, technically, but this is a low-end. if (module == 0x3FF) return hleDelayResult(hleLogSuccessInfoI(SCEUTILITY, 0), "utility module unloaded", 110); From 3af8a667e12e25d814f401f4af08ad774022f95f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 7 Oct 2022 07:03:29 -0700 Subject: [PATCH 062/374] Psmf: Fix save states. --- Core/HLE/sceKernelModule.cpp | 2 +- Core/HLE/scePsmf.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index cb1e9d091d..4f3d586672 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1144,7 +1144,7 @@ static int gzipDecompress(u8 *OutBuffer, int OutBufferLength, u8 *InBuffer) { } static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 loadAddress, bool fromTop, std::string *error_string, u32 *magic, u32 &error) { - u32 crc = crc32(0, ptr, elfSize); + u32 crc = crc32(0, ptr, (uInt)elfSize); PSPModule *module = new PSPModule(); kernelObjects.Create(module); loadedModules.insert(module->GetUID()); diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index cf01260f2c..06fc172c53 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -711,7 +711,7 @@ void __PsmfDoState(PointerWrap &p) { } void __PsmfPlayerDoState(PointerWrap &p) { - auto s = p.Section("scePsmfPlayer", 1, 3); + auto s = p.Section("scePsmfPlayer", 1, 4); if (!s) return; @@ -724,7 +724,7 @@ void __PsmfPlayerDoState(PointerWrap &p) { Do(p, eventPsmfPlayerStatusChange); } CoreTiming::RestoreRegisterEvent(eventPsmfPlayerStatusChange, "PsmfPlayerStatusChangeEvent", &__PsmfPlayerStatusChange); - if (s < 3) { + if (s < 4) { psmfPlayerLibcrc = 0; } else { Do(p, psmfPlayerLibcrc); From bcee6c0310cf61862ec4dd5e5978ab000230a104 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 7 Oct 2022 07:02:21 -0700 Subject: [PATCH 063/374] Jpeg: Improve timing/errors for GetOutputInfo. --- Core/HLE/sceJpeg.cpp | 49 +++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index 3e8ecc406e..c233eafde6 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -21,9 +21,11 @@ #include "Common/CommonTypes.h" #include "Common/Serialize/Serializer.h" #include "Common/Serialize/SerializeFuncs.h" +#include "Core/Debugger/MemBlockInfo.h" #include "Core/HLE/HLE.h" #include "Core/HLE/FunctionWrappers.h" #include "Core/HLE/sceJpeg.h" +#include "Core/HLE/sceKernel.h" #include "GPU/GPUCommon.h" #include "Core/MemMap.h" #include "Core/Reporting.h" @@ -53,7 +55,9 @@ void __JpegInit() { } enum : uint32_t { + ERROR_JPEG_INVALID_DATA = 0x80650004, ERROR_JPEG_INVALID_SIZE = 0x80650020, + ERROR_JPEG_NO_SOI = 0x80650023, ERROR_JPEG_INVALID_STATE = 0x80650039, ERROR_JPEG_ALREADY_INIT = 0x80650042, ERROR_JPEG_INVALID_VALUE = 0x80650051, @@ -222,21 +226,30 @@ static int getYCbCrBufferSize(int w, int h) { return ((w * h) >> 1) * 3; } -static int __JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) { - const u8 *buf = Memory::GetPointer(jpegAddr); +static int JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) { + if (!Memory::IsValidRange(jpegAddr, jpegSize)) + return hleLogError(ME, ERROR_JPEG_NO_SOI, "invalid jpeg address"); + if (jpegSize == 0) + return hleLogError(ME, ERROR_JPEG_INVALID_DATA, "invalid jpeg data"); + + NotifyMemInfo(MemBlockFlags::READ, jpegAddr, jpegSize, "JpegGetOutputInfo"); + + const u8 *buf = Memory::GetPointerUnchecked(jpegAddr); + if (jpegSize < 2 || buf[0] != 0xFF || buf[1] != 0xD8) + return hleLogError(ME, ERROR_JPEG_NO_SOI, "no SOI found, invalid data"); + int width, height, actual_components; unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, 3); - if (actual_components != 3) { - // The assumption that the image was RGB was wrong... - // Try again. + if (actual_components != 3 && actual_components != 1) { + // The assumption that the image was RGB was wrong... + // Try again. int components = actual_components; jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, components); } - if (jpegBuf == NULL) { - ERROR_LOG(ME, "sceJpegGetOutputInfo: Bad JPEG data"); - return getYCbCrBufferSize(0, 0); + if (jpegBuf == nullptr) { + return hleLogError(ME, ERROR_JPEG_INVALID_DATA, "unable to decompress jpeg"); } free(jpegBuf); @@ -247,12 +260,14 @@ static int __JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) { // - Bits 8 to 16 (Vertical chroma subsampling value): 0x00, 0x01 or 0x02 // - Bits 0 to 8 (Horizontal chroma subsampling value): 0x00, 0x01 or 0x02 if (Memory::IsValidAddress(colourInfoAddr)) { + // Note: can't actually seem to get any other subsampling values or color modes to work on a PSP. Memory::Write_U32(0x00020202, colourInfoAddr); + NotifyMemInfo(MemBlockFlags::WRITE, colourInfoAddr, 4, "JpegGetOutputInfo"); } #ifdef JPEG_DEBUG char jpeg_fname[256]; - u8 *jpegDumpBuf = Memory::GetPointer(jpegAddr); + const u8 *jpegDumpBuf = Memory::GetPointer(jpegAddr); u32 jpeg_xxhash = XXH32((const char *)jpegDumpBuf, jpegSize, 0xC0108888); sprintf(jpeg_fname, "Jpeg\\%X.jpg", jpeg_xxhash); FILE *wfp = fopen(jpeg_fname, "wb"); @@ -264,17 +279,17 @@ static int __JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) { fclose(wfp); #endif //JPEG_DEBUG - return getYCbCrBufferSize(width, height); + return hleLogSuccessI(ME, getYCbCrBufferSize(width, height)); } static int sceJpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr, int dhtMode) { - if (!Memory::IsValidAddress(jpegAddr)) { - ERROR_LOG(ME, "sceJpegGetOutputInfo: Bad JPEG address 0x%08x", jpegAddr); - return getYCbCrBufferSize(0, 0); - } + if ((jpegAddr | jpegSize | (jpegAddr + jpegSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid jpeg address"); - DEBUG_LOG(ME, "sceJpegGetOutputInfo(%08x, %i, %08x, %i)", jpegAddr, jpegSize, colourInfoAddr, dhtMode); - return __JpegGetOutputInfo(jpegAddr, jpegSize, colourInfoAddr); + int result = JpegGetOutputInfo(jpegAddr, jpegSize, colourInfoAddr); + // Time taken varies a bit, this is the low end. Depends on data. + // Note that errors delay as well. + return hleDelayResult(result, "jpeg get output info", 250); } static u32 convertRGBToYCbCr(u32 rgb) { @@ -459,7 +474,7 @@ const HLEFunction sceJpeg[] = {0X64B6F978, &WrapI_UIUI, "sceJpegDecodeMJpegSuccessively", 'i', "xixi" }, {0X67F0ED84, &WrapI_UUIII, "sceJpegCsc", 'i', "xxiii"}, {0X7D2F3D7F, &WrapI_V, "sceJpegFinishMJpeg", 'i', "" }, - {0X8F2BB012, &WrapI_UIUI, "sceJpegGetOutputInfo", 'i', "xixi" }, + {0X8F2BB012, &WrapI_UIUI, "sceJpegGetOutputInfo", 'x', "xipi" }, {0X91EED83C, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCr", 'i', "xixii"}, {0X9B36444C, &WrapI_V, "sceJpeg_9B36444C", 'i', "" }, {0X9D47469C, &WrapI_II, "sceJpegCreateMJpeg", 'i', "ii" }, From bf14ca84d3180ce8b2bbf6c2345e4145027393aa Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 8 Oct 2022 14:38:49 +0200 Subject: [PATCH 064/374] OpenXR - Revision of VR rendering --- Common/GPU/OpenGL/GLRenderManager.cpp | 16 ---- Common/GPU/OpenGL/GLRenderManager.h | 1 - Common/VR/VRRenderer.cpp | 110 +++++++++++++------------- Common/VR/VRRenderer.h | 9 ++- android/jni/app-android.cpp | 8 +- 5 files changed, 68 insertions(+), 76 deletions(-) diff --git a/Common/GPU/OpenGL/GLRenderManager.cpp b/Common/GPU/OpenGL/GLRenderManager.cpp index 01a94fb8b4..01cccb8874 100644 --- a/Common/GPU/OpenGL/GLRenderManager.cpp +++ b/Common/GPU/OpenGL/GLRenderManager.cpp @@ -236,28 +236,12 @@ bool GLRenderManager::ThreadFrame() { firstFrame = false; } - // Start of an OpenXR frame. This updates user's head pose and VR timestamps. - // For fluent rendering, delay between StartVRRender and FinishVRRender must be very short. - if (IsVRBuild() && !vrRenderStarted) { - if (StartVRRender()) { - vrRenderStarted = true; - } else { - return false; - } - } - // Render the scene. Run(threadFrame_); VLOG("PULL: Finished frame %d", threadFrame_); } while (!nextFrame); - // Post OpenXR frame on a screen. - if (IsVRBuild() && vrRenderStarted) { - FinishVRRender(); - vrRenderStarted = false; - } - return true; } diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index 089c588aeb..51d7e1e9eb 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -1051,7 +1051,6 @@ private: bool nextFrame = false; bool firstFrame = true; - bool vrRenderStarted = false; GLDeleter deleter_; bool skipGLCalls_ = false; diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 2ad0014c10..22668fb3f3 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -16,6 +16,7 @@ XrFrameState frameState = {}; GLboolean initialized = GL_FALSE; GLboolean stageSupported = GL_FALSE; int vrConfig[VR_CONFIG_MAX] = {}; +ovrMatrix4f vrMatrix[VR_MATRIX_COUNT]; XrVector3f hmdorientation; XrVector3f hmdposition; @@ -310,6 +311,61 @@ bool VR_InitFrame( engine_t* engine ) { engine->appState.LayerCount = 0; memset(engine->appState.Layers, 0, sizeof(ovrCompositorLayer_Union) * ovrMaxLayerCount); + + // Update matrices + for (int matrix = 0; matrix < VR_MATRIX_COUNT; matrix++) { + if ((matrix == VR_PROJECTION_MATRIX_LEFT_EYE) || (matrix == VR_PROJECTION_MATRIX_RIGHT_EYE)) { + float near = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; + vrMatrix[matrix] = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, near, 0.0f ); + } else if ((matrix == VR_VIEW_MATRIX_LEFT_EYE) || (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { + XrPosef invView = invViewTransform[0]; + + // get axis mirroring configuration + float mx = vrConfig[VR_CONFIG_MIRROR_PITCH] ? -1 : 1; + float my = vrConfig[VR_CONFIG_MIRROR_YAW] ? -1 : 1; + float mz = vrConfig[VR_CONFIG_MIRROR_ROLL] ? -1 : 1; + + // ensure there is maximally one axis to mirror rotation + if (mx + my + mz < 0) { + mx *= -1.0f; + my *= -1.0f; + mz *= -1.0f; + } else { + invView = XrPosef_Inverse(invView); + } + + // create updated quaternion + if (mx + my + mz < 3 - EPSILON) { + XrVector3f rotation = XrQuaternionf_ToEulerAngles(invView.orientation); + XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, mx * ToRadians(rotation.x)); + XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, my * ToRadians(rotation.y)); + XrQuaternionf roll = XrQuaternionf_CreateFromVectorAngle({0, 0, 1}, mz * ToRadians(rotation.z)); + invView.orientation = XrQuaternionf_Multiply(roll, XrQuaternionf_Multiply(pitch, yaw)); + } + + vrMatrix[matrix] = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); + float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.000001f; + if (vrConfig[VR_CONFIG_6DOF_ENABLED]) { + vrMatrix[matrix].M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; + vrMatrix[matrix].M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; + vrMatrix[matrix].M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; + } + if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { + float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); + float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); + float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); + float ipd = sqrt(dx * dx + dy * dy + dz * dz); + XrVector3f separation = {ipd * scale, 0.0f, 0.0f}; + separation = XrQuaternionf_Rotate(invView.orientation, separation); + separation = XrVector3f_ScalarMultiply(separation, vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f); + vrMatrix[matrix].M[0][3] -= separation.x; + vrMatrix[matrix].M[1][3] -= separation.y; + vrMatrix[matrix].M[2][3] -= separation.z; + } + } else { + assert(false); + } + } return true; } @@ -468,57 +524,5 @@ void VR_BindFramebuffer(engine_t *engine) { } ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) { - ovrMatrix4f output; - if ((matrix == VR_PROJECTION_MATRIX_LEFT_EYE) || (matrix == VR_PROJECTION_MATRIX_RIGHT_EYE)) { - float near = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; - output = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, near, 0.0f ); - } else if ((matrix == VR_VIEW_MATRIX_LEFT_EYE) || (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { - XrPosef invView = invViewTransform[0]; - - // get axis mirroring configuration - float mx = vrConfig[VR_CONFIG_MIRROR_PITCH] ? -1 : 1; - float my = vrConfig[VR_CONFIG_MIRROR_YAW] ? -1 : 1; - float mz = vrConfig[VR_CONFIG_MIRROR_ROLL] ? -1 : 1; - - // ensure there is maximally one axis to mirror rotation - if (mx + my + mz < 0) { - mx *= -1.0f; - my *= -1.0f; - mz *= -1.0f; - } else { - invView = XrPosef_Inverse(invView); - } - - // create updated quaternion - if (mx + my + mz < 3 - EPSILON) { - XrVector3f rotation = XrQuaternionf_ToEulerAngles(invView.orientation); - XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, mx * ToRadians(rotation.x)); - XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, my * ToRadians(rotation.y)); - XrQuaternionf roll = XrQuaternionf_CreateFromVectorAngle({0, 0, 1}, mz * ToRadians(rotation.z)); - invView.orientation = XrQuaternionf_Multiply(roll, XrQuaternionf_Multiply(pitch, yaw)); - } - - output = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); - float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.000001f; - if (vrConfig[VR_CONFIG_6DOF_ENABLED]) { - output.M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; - output.M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; - output.M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; - } - if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { - float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); - float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); - float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); - float ipd = sqrt(dx * dx + dy * dy + dz * dz); - XrVector3f separation = {ipd * scale, 0.0f, 0.0f}; - separation = XrQuaternionf_Rotate(invView.orientation, separation); - separation = XrVector3f_ScalarMultiply(separation, vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f); - output.M[0][3] -= separation.x; - output.M[1][3] -= separation.y; - output.M[2][3] -= separation.z; - } - } else { - assert(false); - } - return output; + return vrMatrix[matrix]; } diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 9375370cad..e19a0e82a5 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -26,10 +26,11 @@ enum VRConfig { }; enum VRMatrix { - VR_PROJECTION_MATRIX_LEFT_EYE = 0, - VR_PROJECTION_MATRIX_RIGHT_EYE = 1, - VR_VIEW_MATRIX_LEFT_EYE = 2, - VR_VIEW_MATRIX_RIGHT_EYE = 3 + VR_PROJECTION_MATRIX_LEFT_EYE, + VR_PROJECTION_MATRIX_RIGHT_EYE, + VR_VIEW_MATRIX_LEFT_EYE, + VR_VIEW_MATRIX_RIGHT_EYE, + VR_MATRIX_COUNT }; enum VRMode { diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 482b864ea5..98e1ca6052 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -1057,16 +1057,20 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, SetCurrentThreadName("AndroidRender"); } + if (IsVRBuild() && !StartVRRender()) + return; + if (useCPUThread) { // This is the "GPU thread". - if (graphicsContext) - graphicsContext->ThreadFrame(); + if (!graphicsContext || !graphicsContext->ThreadFrame()) + return; } else { UpdateRunLoopAndroid(env); } if (IsVRBuild()) { UpdateVRInput(NativeKey, NativeTouch, g_Config.bHapticFeedback, dp_xscale, dp_yscale); + FinishVRRender(); } } From 95d40cc09f86152b6ef6f00a09bc062cd3f5de67 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 7 Oct 2022 23:24:09 -0700 Subject: [PATCH 065/374] Jpeg: Retain previous width/height. Seems to be reused even after Delete, strangely. --- Core/HLE/sceJpeg.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index c233eafde6..3d91508aaf 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -45,13 +45,13 @@ struct u24_be { }; static int mjpegInited = 0; -static int mjpegWidth = 0x7FFFFFFF; -static int mjpegHeight = 0x7FFFFFFF; +static int mjpegWidth = 0; +static int mjpegHeight = 0; void __JpegInit() { mjpegInited = 0; - mjpegWidth = 0x7FFFFFFF; - mjpegHeight = 0x7FFFFFFF; + mjpegWidth = 0; + mjpegHeight = 0; } enum : uint32_t { @@ -399,14 +399,12 @@ static int sceJpeg_9B36444C() { static int sceJpegCreateMJpeg(int width, int height) { if (mjpegInited == 0) return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "not yet inited"); - if (mjpegInited == 1 && mjpegWidth != 0x7FFFFFFF) + if (mjpegInited == 2) return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "already created"); if (width > 1024) return hleLogError(ME, ERROR_JPEG_INVALID_SIZE, "width outside bounds"); - // Assume valid usage in an old save state. - if (mjpegInited == -1) - mjpegInited = 1; + mjpegInited = 2; mjpegWidth = width; mjpegHeight = height; @@ -416,35 +414,32 @@ static int sceJpegCreateMJpeg(int width, int height) { static int sceJpegDeleteMJpeg() { if (mjpegInited == 0) return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "not yet inited"); - if (mjpegInited == 1 && mjpegWidth == 0x7FFFFFFF) - return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "nto yet created"); + if (mjpegInited == 1) + return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "not yet created"); - if (mjpegInited == -1) - mjpegInited = 1; - mjpegWidth = 0x7FFFFFFF; - mjpegHeight = 0x7FFFFFFF; + mjpegInited = 1; return hleLogSuccessInfoI(ME, 0); } static int sceJpegInitMJpeg() { - if (mjpegInited == 1) + if (mjpegInited == 1 || mjpegInited == 2) return hleLogError(ME, ERROR_JPEG_ALREADY_INIT, "already inited"); // If it was -1, it's from an old save state, avoid double init error but assume inited. if (mjpegInited == 0) mjpegInited = 1; - return hleLogDebug(ME, hleDelayResult(0, "mjpeg init", 130)); + return hleLogSuccessI(ME, hleDelayResult(0, "mjpeg init", 130)); } static int sceJpegFinishMJpeg() { if (mjpegInited == 0) return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "already inited"); - if (mjpegInited != -1 && (mjpegWidth != 0x7FFFFFFF || mjpegHeight != 0x7FFFFFFF)) + if (mjpegInited == 2) return hleLogError(ME, ERROR_JPEG_INVALID_STATE, "mjpeg not deleted"); // Even from an old save state, if we see this we leave compat mode. mjpegInited = 0; - return hleLogDebug(ME, hleDelayResult(0, "mjpeg finish", 120)); + return hleLogSuccessI(ME, hleDelayResult(0, "mjpeg finish", 120)); } static int sceJpegMJpegCscWithColorOption() { From dc18b6cf803b197d616d4d1cca585a676aeca6a6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 7 Oct 2022 23:26:37 -0700 Subject: [PATCH 066/374] Jpeg: Improve error handling for YCbCr decode. This also fixes a crash on invalid output pointer. --- Core/HLE/sceJpeg.cpp | 79 +++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 26 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index 3d91508aaf..59060830bb 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -59,6 +59,7 @@ enum : uint32_t { ERROR_JPEG_INVALID_SIZE = 0x80650020, ERROR_JPEG_NO_SOI = 0x80650023, ERROR_JPEG_INVALID_STATE = 0x80650039, + ERROR_JPEG_OUT_OF_MEMORY = 0x80650041, ERROR_JPEG_ALREADY_INIT = 0x80650042, ERROR_JPEG_INVALID_VALUE = 0x80650051, }; @@ -309,11 +310,11 @@ static u32 convertRGBToYCbCr(u32 rgb) { return (y << 16) | (cb << 8) | cr; } -static int __JpegConvertRGBToYCbCr (const void *data, u32 bufferOutputAddr, int width, int height) { - u24_be *imageBuffer = (u24_be*)data; +static int JpegConvertRGBToYCbCr(const void *data, u8 *output, int width, int height) { + u24_be *imageBuffer = (u24_be *)data; int sizeY = width * height; int sizeCb = sizeY >> 2; - u8 *Y = (u8*)Memory::GetPointer(bufferOutputAddr); + u8 *Y = output; u8 *Cb = Y + sizeY; u8 *Cr = Cb + sizeCb; @@ -338,57 +339,83 @@ static int __JpegConvertRGBToYCbCr (const void *data, u32 bufferOutputAddr, int *Cr++ = yCbCr0 & 0xFF; } imageBuffer += width; - Y += width ; + Y += width; } return getWidthHeight(width, height); } -static int __JpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr) { - const u8 *buf = Memory::GetPointer(jpegAddr); +static int JpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, int yCbCrSize, int &usec) { + if (!Memory::IsValidRange(jpegAddr, jpegSize)) + return hleLogError(ME, ERROR_JPEG_NO_SOI, "invalid jpeg address"); + if (jpegSize == 0) + return hleLogError(ME, ERROR_JPEG_INVALID_DATA, "invalid jpeg data"); + + NotifyMemInfo(MemBlockFlags::READ, jpegAddr, jpegSize, "JpegDecodeMJpegYCbCr"); + + const u8 *buf = Memory::GetPointerUnchecked(jpegAddr); + if (jpegSize < 2 || buf[0] != 0xFF || buf[1] != 0xD8) + return hleLogError(ME, ERROR_JPEG_NO_SOI, "no SOI found, invalid data"); + int width, height, actual_components; unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, 3); - if (actual_components != 3) { + if (actual_components != 3 && actual_components != 1) { // The assumption that the image was RGB was wrong... // Try again. int components = actual_components; jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, components); } - if (jpegBuf == NULL) { - return getWidthHeight(0, 0); + if (jpegBuf == nullptr) { + return hleLogError(ME, ERROR_JPEG_INVALID_DATA, "unable to decompress jpeg"); } - if (actual_components == 3) { - __JpegConvertRGBToYCbCr(jpegBuf, yCbCrAddr, width, height); + if (yCbCrSize < getYCbCrBufferSize(width, height)) { + free(jpegBuf); + return hleLogError(ME, ERROR_JPEG_OUT_OF_MEMORY, "buffer not large enough"); + } + + // Technically, it seems like the PSP doesn't support grayscale, but we might as well. + if (actual_components == 3 || actual_components == 1) { + if (Memory::IsValidRange(yCbCrAddr, getYCbCrBufferSize(width, height))) { + JpegConvertRGBToYCbCr(jpegBuf, Memory::GetPointerWriteUnchecked(yCbCrAddr), width, height); + NotifyMemInfo(MemBlockFlags::WRITE, yCbCrAddr, getYCbCrBufferSize(width, height), "JpegDecodeMJpegYCbCr"); + } else { + // There's some weird behavior on the PSP where it writes data around the last passed address. + WARN_LOG_REPORT(ME, "JpegDecodeMJpegYCbCr: Invalid output address (%08x / %08x) for %dx%d", yCbCrAddr, yCbCrSize, width, height); + } } free(jpegBuf); - // TODO: There's more... - - return getWidthHeight(width, height); + // Rough estimate based on observed timing. + usec += getYCbCrBufferSize(width, height) / 21; + return hleLogSuccessI(ME, getWidthHeight(width, height)); } static int sceJpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, int yCbCrSize, int dhtMode) { - if (!Memory::IsValidAddress(jpegAddr)) { - ERROR_LOG(ME, "sceJpegDecodeMJpegYCbCr: Bad JPEG address 0x%08x", jpegAddr); - return getWidthHeight(0, 0); - } + if ((jpegAddr | jpegSize | (jpegAddr + jpegSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid jpeg address"); + if ((yCbCrAddr | yCbCrSize | (yCbCrAddr + yCbCrSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid output address"); + if (!Memory::IsValidRange(jpegAddr, jpegSize)) + return hleLogError(ME, ERROR_JPEG_INVALID_VALUE, "invalid jpeg address"); - DEBUG_LOG(ME, "sceJpegDecodeMJpegYCbCr(%08x, %i, %08x, %i, %i)", jpegAddr, jpegSize, yCbCrAddr, yCbCrSize, dhtMode); - return __JpegDecodeMJpegYCbCr(jpegAddr, jpegSize, yCbCrAddr); + int usec = 300; + int result = JpegDecodeMJpegYCbCr(jpegAddr, jpegSize, yCbCrAddr, yCbCrSize, usec); + return hleDelayResult(result, "jpeg decode", usec); } static int sceJpegDecodeMJpegYCbCrSuccessively(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, int yCbCrSize, int dhtMode) { - if (!Memory::IsValidAddress(jpegAddr)) { - ERROR_LOG(ME, "sceJpegDecodeMJpegYCbCrSuccessively: Bad JPEG address 0x%08x", jpegAddr); - return getWidthHeight(0, 0); - } + if ((jpegAddr | jpegSize | (jpegAddr + jpegSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid jpeg address"); + if ((yCbCrAddr | yCbCrSize | (yCbCrAddr + yCbCrSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid output address"); - DEBUG_LOG(ME, "sceJpegDecodeMJpegYCbCrSuccessively(%08x, %i, %08x, %i, %i)", jpegAddr, jpegSize, yCbCrAddr, yCbCrSize, dhtMode); // Do as same way as sceJpegDecodeMJpegYCbCr() but with smaller block size - return __JpegDecodeMJpegYCbCr(jpegAddr, jpegSize, yCbCrAddr); + int usec = 300; + int result = JpegDecodeMJpegYCbCr(jpegAddr, jpegSize, yCbCrAddr, yCbCrSize, usec); + return hleDelayResult(result, "jpeg decode", usec); } static int sceJpeg_9B36444C() { From 159d4ed4a3686be4750fcda4a23fb78ab71946ef Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 7 Oct 2022 23:53:04 -0700 Subject: [PATCH 067/374] Jpeg: Decode buffers using configured stride. Previously, it was assumed that the stride was the nearest power of two, but it's actually the Create width. --- Core/HLE/sceJpeg.cpp | 95 ++++++++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 35 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index 59060830bb..142b8074ef 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -151,63 +151,88 @@ static u32 convertARGBtoABGR(u32 argb) { return ((argb & 0xFF00FF00)) | ((argb & 0x000000FF) << 16) | ((argb & 0x00FF0000) >> 16); } -static int __DecodeJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr) { - const u8 *buf = Memory::GetPointer(jpegAddr); +static int DecodeJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr, int &usec) { + if (!Memory::IsValidRange(jpegAddr, jpegSize)) + return hleLogError(ME, ERROR_JPEG_NO_SOI, "invalid jpeg address"); + if (jpegSize == 0) + return hleLogError(ME, ERROR_JPEG_INVALID_DATA, "invalid jpeg data"); + + NotifyMemInfo(MemBlockFlags::READ, jpegAddr, jpegSize, "JpegDecodeMJpeg"); + + const u8 *buf = Memory::GetPointerUnchecked(jpegAddr); + if (jpegSize < 2 || buf[0] != 0xFF || buf[1] != 0xD8) + return hleLogError(ME, ERROR_JPEG_NO_SOI, "no SOI found, invalid data"); + int width, height, actual_components; unsigned char *jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, 3); - if (actual_components != 3) { + if (actual_components != 3 && actual_components != 1) { // The assumption that the image was RGB was wrong... // Try again. int components = actual_components; jpegBuf = jpgd::decompress_jpeg_image_from_memory(buf, jpegSize, &width, &height, &actual_components, components); } - if (jpegBuf == NULL) { - return getWidthHeight(0, 0); + if (jpegBuf == nullptr) { + return hleLogError(ME, ERROR_JPEG_INVALID_DATA, "unable to decompress jpeg"); } - if (actual_components == 3) { - u24_be *imageBuffer = (u24_be*)jpegBuf; - u32_le *abgr = (u32_le *)Memory::GetPointer(imageAddr); - int pspWidth = 0; - for (int w = 2; w <= 4096; w *= 2) { - if (w >= width && w >= height) { - pspWidth = w; - break; - } - } - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; x++) { - abgr[x] = convertARGBtoABGR(imageBuffer[x]); - } - imageBuffer += width; - abgr += pspWidth; // Smallest value power of 2 fitting width and height(needs to be square!) + usec += (width * height) / 14; + + if (!Memory::IsValidRange(imageAddr, mjpegWidth * mjpegHeight * 4)) { + free(jpegBuf); + return hleLogError(ME, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid output address"); + } + // Note: even if you Delete, the size is still allowed. + if (width > mjpegWidth || height > mjpegHeight) { + free(jpegBuf); + return hleLogError(ME, ERROR_JPEG_INVALID_SIZE, "invalid output address"); + } + if (mjpegInited == 0) { + // If you finish after setting the size, then call this - you get an interesting error. + free(jpegBuf); + return hleLogError(ME, 0x80000001, "mjpeg not inited"); + } + + usec += (width * height) / 110; + + if (actual_components == 3 || actual_components == 1) { + u24_be *imageBuffer = (u24_be*)jpegBuf; + u32_le *abgr = (u32_le *)Memory::GetPointerUnchecked(imageAddr); + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; x++) { + abgr[x] = convertARGBtoABGR(imageBuffer[x]); } + imageBuffer += width; + abgr += mjpegWidth; + } + NotifyMemInfo(MemBlockFlags::WRITE, imageAddr, mjpegWidth * height, "JpegDecodeMJpeg"); } free(jpegBuf); - return getWidthHeight(width, height); + return hleLogSuccessI(ME, getWidthHeight(width, height)); } static int sceJpegDecodeMJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr, int dhtMode) { - if (!Memory::IsValidAddress(jpegAddr)) { - ERROR_LOG(ME, "sceJpegDecodeMJpeg: Bad JPEG address 0x%08x", jpegAddr); - return 0; - } + if ((jpegAddr | jpegSize | (jpegAddr + jpegSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid jpeg address"); + if (imageAddr & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid output address"); - DEBUG_LOG(ME, "sceJpegDecodeMJpeg(%08x, %i, %08x, %i)", jpegAddr, jpegSize, imageAddr, dhtMode); - return __DecodeJpeg(jpegAddr, jpegSize, imageAddr); + int usec = 300; + int result = DecodeJpeg(jpegAddr, jpegSize, imageAddr, usec); + return hleDelayResult(result, "jpeg decode", usec); } static int sceJpegDecodeMJpegSuccessively(u32 jpegAddr, int jpegSize, u32 imageAddr, int dhtMode) { - if (!Memory::IsValidAddress(jpegAddr)) { - ERROR_LOG(ME, "sceJpegDecodeMJpegSuccessively: Bad JPEG address 0x%08x", jpegAddr); - return 0; - } + if ((jpegAddr | jpegSize | (jpegAddr + jpegSize)) & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid jpeg address"); + if (imageAddr & 0x80000000) + return hleLogError(ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid output address"); - DEBUG_LOG(ME, "sceJpegDecodeMJpegSuccessively(%08x, %i, %08x, %i)", jpegAddr, jpegSize, imageAddr, dhtMode); - return __DecodeJpeg(jpegAddr, jpegSize, imageAddr); + int usec = 300; + int result = DecodeJpeg(jpegAddr, jpegSize, imageAddr, usec); + return hleDelayResult(result, "jpeg decode", usec); } static int sceJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo) { @@ -389,7 +414,7 @@ static int JpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, int y free(jpegBuf); // Rough estimate based on observed timing. - usec += getYCbCrBufferSize(width, height) / 21; + usec += (width * height) / 14; return hleLogSuccessI(ME, getWidthHeight(width, height)); } From af28a3d497bc9149c70284eb2e6cc881843e9966 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 11:28:36 -0700 Subject: [PATCH 068/374] Jpeg: Correct colorspace conversion funcs. For non-mjpeg, the height and width are halved, and more sampling modes are supported. This also checks for invalid pointers and notifies the debugger. The exact YCbCr->RGBA conversion is not accurate, but it writes in the correct places now. MJpeg is still a bit off. --- Core/HLE/sceJpeg.cpp | 204 +++++++++++++++++++++++++++++++++---------- 1 file changed, 156 insertions(+), 48 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index 142b8074ef..f748ebea46 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -56,6 +56,7 @@ void __JpegInit() { enum : uint32_t { ERROR_JPEG_INVALID_DATA = 0x80650004, + ERROR_JPEG_INVALID_COLORSPACE = 0x80650013, ERROR_JPEG_INVALID_SIZE = 0x80650020, ERROR_JPEG_NO_SOI = 0x80650023, ERROR_JPEG_INVALID_STATE = 0x80650039, @@ -82,7 +83,8 @@ static int getWidthHeight(int width, int height) { return (width << 16) | height; } -static u32 convertYCbCrToABGR (int y, int cb, int cr) { +// TODO: sceJpegCsc and sceJpegMJpegCsc use different factors. +static u32 convertYCbCrToABGR(int y, int cb, int cr) { //see http://en.wikipedia.org/wiki/Yuv#Y.27UV444_to_RGB888_conversion for more information. cb = cb - 128; cr = cr - 128; @@ -95,56 +97,166 @@ static u32 convertYCbCrToABGR (int y, int cb, int cr) { if (g > 0xFF) g = 0xFF; if(g < 0) g = 0; if (b > 0xFF) b = 0xFF; if(b < 0) b = 0; - return 0xFF000000 | (b << 16) | (g << 8) | (r << 0); + return (b << 16) | (g << 8) | (r << 0); } -static void __JpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidth) { - int height = widthHeight & 0xFFF; - int width = (widthHeight >> 16) & 0xFFF; - int lineWidth = std::min(width, bufferWidth); - int skipEndOfLine = std::max(0, bufferWidth - lineWidth); - u32_le *imageBuffer = (u32_le *)Memory::GetPointer(imageAddr); +static int JpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidth, uint32_t chroma, int &usec) { + if ((chroma & 0x000FFFFF) != 0x00020202 && (chroma & 0x000FFFFF) != 0x00020201 && (chroma & 0x000FFFFF) != 0x00020101) + return hleLogError(ME, ERROR_JPEG_INVALID_COLORSPACE, "invalid colorspace"); + if (bufferWidth < 0) + bufferWidth = 0; + + int height = widthHeight & 0xFFFF; + int width = (widthHeight >> 16) & 0xFFFF; + if (height == 0) + height = 1; + + uint8_t widthShift = ((chroma >> 8) & 0x03) - 1; + uint8_t heightShift = (chroma & 0x03) - 1; + int sizeY = width * height; + int sizeCb = sizeY >> (widthShift + heightShift); + + uint64_t destSize = ((uint64_t)bufferWidth * (height - 1) + width) * 4; + if (destSize > 0x3FFFFFFF || !Memory::IsValidRange(imageAddr, (uint32_t)destSize)) + return hleLogError(ME, ERROR_JPEG_INVALID_VALUE, "invalid dest address or size"); + if (sizeY > 0x3FFFFFFF || !Memory::IsValidRange(yCbCrAddr, sizeY + sizeCb + sizeCb)) + return hleLogError(ME, ERROR_JPEG_INVALID_VALUE, "invalid src address or size"); + + u32_le *imageBuffer = (u32_le *)Memory::GetPointerWriteUnchecked(imageAddr); + const u8 *Y = (const u8 *)Memory::GetPointerUnchecked(yCbCrAddr); + const u8 *Cb = Y + sizeY; + const u8 *Cr = Cb + sizeCb; + + // Very approximate estimate based on tests on a PSP. Usually under. + usec += 60 + 6 * height + width / 2 + width / 4; + + if ((widthHeight & 0x00010001) == 0 && height > 1) { + for (int y = 0; y < height; y += 2) { + for (int x = 0; x < width; x += 2) { + u8 y0 = Y[width * y + x]; + u8 y1 = Y[width * y + x + 1]; + u8 y2 = Y[width * (y + 1) + x]; + u8 y3 = Y[width * (y + 1) + x + 1]; + u8 cb = Cb[(width >> widthShift) * (y >> heightShift) + (x >> widthShift)]; + u8 cr = Cr[(width >> widthShift) * (y >> heightShift) + (x >> widthShift)]; + + imageBuffer[bufferWidth * y + x + 0] = convertYCbCrToABGR(y0, cb, cr); + imageBuffer[bufferWidth * y + x + 1] = convertYCbCrToABGR(y1, cb, cr); + imageBuffer[bufferWidth * (y + 1) + x] = convertYCbCrToABGR(y2, cb, cr); + imageBuffer[bufferWidth * (y + 1) + x + 1] = convertYCbCrToABGR(y3, cb, cr); + } + } + } else { + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + u8 yy = Y[width * y + x]; + u8 cb = Cb[(width >> widthShift) * (y >> heightShift) + (x >> widthShift)]; + u8 cr = Cr[(width >> widthShift) * (y >> heightShift) + (x >> widthShift)]; + + imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(yy, cb, cr); + } + } + } + + NotifyMemInfo(MemBlockFlags::READ, yCbCrAddr, sizeY + sizeCb + sizeCb, "JpegCsc"); + NotifyMemInfo(MemBlockFlags::WRITE, imageAddr, (uint32_t)destSize, "JpegCsc"); + + if ((widthHeight & 0xFFFF) == 0) + return hleLogSuccessI(ME, -1); + return hleLogSuccessI(ME, 0); +} + +static int JpegMJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidth, int &usec) { + int height = widthHeight & 0xFFFF; + int width = (widthHeight >> 16) & 0xFFFF; + if (bufferWidth < 0) + bufferWidth = bufferWidth > -901 ? 901 + bufferWidth : 0; + if (height == 0) + height = 1; + + uint8_t widthShift = 1; + uint8_t heightShift = 1; int sizeY = width * height; int sizeCb = sizeY >> 2; - u8 *Y = (u8*)Memory::GetPointer(yCbCrAddr); - u8 *Cb = Y + sizeY; - u8 *Cr = Cb + sizeCb; - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; x += 4) { - u8 y0 = Y[x + 0]; - u8 y1 = Y[x + 1]; - u8 y2 = Y[x + 2]; - u8 y3 = Y[x + 3]; - u8 cb = *Cb++; - u8 cr = *Cr++; + if (width > 720 || height > 480) + return hleLogError(ME, ERROR_JPEG_INVALID_SIZE, "invalid size, max 720x480"); + if (bufferWidth > 1024) + return hleLogError(ME, ERROR_JPEG_INVALID_SIZE, "invalid stride, max 1024"); + uint32_t destSize = (bufferWidth * (height - 1) + width) * 4; + if (!Memory::IsValidRange(imageAddr, destSize)) + return hleLogError(ME, SCE_KERNEL_ERROR_INVALID_POINTER, "invalid dest address or size"); - // Convert to ABGR. This is not a fast way to do it. - u32 abgr0 = convertYCbCrToABGR(y0, cb, cr); - u32 abgr1 = convertYCbCrToABGR(y1, cb, cr); - u32 abgr2 = convertYCbCrToABGR(y2, cb, cr); - u32 abgr3 = convertYCbCrToABGR(y3, cb, cr); + u32_le *imageBuffer = (u32_le *)Memory::GetPointerWriteUnchecked(imageAddr); + const u8 *Y = (const u8 *)Memory::GetPointerUnchecked(yCbCrAddr); + const u8 *Cb = Y + sizeY; + const u8 *Cr = Cb + sizeCb; - // Write ABGR - imageBuffer[x + 0] = abgr0; - imageBuffer[x + 1] = abgr1; - imageBuffer[x + 2] = abgr2; - imageBuffer[x + 3] = abgr3; - } - Y += width; - imageBuffer += width; - imageBuffer += skipEndOfLine; + // Very approximate estimate based on tests on a PSP. Usually under. + // The PSP behaves strangely for heights below 16, not rescheduling and writing fewer bytes. + if (height >= 16) { + usec += 9 * height; } + + if (!Memory::IsValidRange(yCbCrAddr, sizeY + sizeCb + sizeCb)) { + // Seems to write based on zeros? Maybe reuses some other value? + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(0, 0, 0); + } + } + } else if ((widthHeight & 0x00030000) == 0) { + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; x += 4) { + int offset = width * y + x; + u8 y0 = Y[offset + 0]; + u8 y1 = Y[offset + 1]; + u8 y2 = Y[offset + 2]; + u8 y3 = Y[offset + 3]; + u8 cb = Cb[offset >> 2]; + u8 cr = Cr[offset >> 2]; + + imageBuffer[bufferWidth * y + x + 0] = convertYCbCrToABGR(y0, cb, cr); + imageBuffer[bufferWidth * y + x + 1] = convertYCbCrToABGR(y1, cb, cr); + imageBuffer[bufferWidth * y + x + 2] = convertYCbCrToABGR(y2, cb, cr); + imageBuffer[bufferWidth * y + x + 3] = convertYCbCrToABGR(y3, cb, cr); + } + } + NotifyMemInfo(MemBlockFlags::READ, yCbCrAddr, sizeY + sizeCb + sizeCb, "JpegMJpegCsc"); + } else { + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + int offset = width * y + x; + u8 yy = Y[offset]; + u8 cb = Cb[offset >> 2]; + u8 cr = Cr[offset >> 2]; + + imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(yy, cb, cr); + } + } + NotifyMemInfo(MemBlockFlags::READ, yCbCrAddr, sizeY + sizeCb + sizeCb, "JpegMJpegCsc"); + } + + NotifyMemInfo(MemBlockFlags::WRITE, imageAddr, destSize, "JpegMJpegCsc"); + + return hleLogSuccessI(ME, 0); } static int sceJpegMJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidth) { - __JpegCsc(imageAddr, yCbCrAddr, widthHeight, bufferWidth); + if (mjpegInited == 0) + return hleLogError(ME, 0x80000001, "not yet inited"); + + int usec = 0; + int result = JpegMJpegCsc(imageAddr, yCbCrAddr, widthHeight, bufferWidth, usec); int width = (widthHeight >> 16) & 0xFFF; int height = widthHeight & 0xFFF; - DEBUG_LOG(ME, "sceJpegMJpegCsc(%08x, %08x, (%dx%d), %i)", imageAddr, yCbCrAddr, width, height, bufferWidth); - gpu->NotifyVideoUpload(imageAddr, width * height * 4, width, GE_FORMAT_8888); - return 0; + if (result >= 0) + gpu->NotifyVideoUpload(imageAddr, width * height * 4, width, GE_FORMAT_8888); + + if (usec != 0) + return hleDelayResult(result, "jpeg csc", usec); + return result; } static u32 convertARGBtoABGR(u32 argb) { @@ -236,15 +348,11 @@ static int sceJpegDecodeMJpegSuccessively(u32 jpegAddr, int jpegSize, u32 imageA } static int sceJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidth, int colourInfo) { - if (bufferWidth < 0 || widthHeight < 0){ - WARN_LOG(ME, "sceJpegCsc(%08x, %08x, %i, %i, %i)", imageAddr, yCbCrAddr, widthHeight, bufferWidth, colourInfo); - return ERROR_JPEG_INVALID_VALUE; - } - - __JpegCsc(imageAddr, yCbCrAddr, widthHeight, bufferWidth); - - DEBUG_LOG(ME, "sceJpegCsc(%08x, %08x, %i, %i, %i)", imageAddr, yCbCrAddr, widthHeight, bufferWidth, colourInfo); - return 0; + int usec = 0; + int result = JpegCsc(imageAddr, yCbCrAddr, widthHeight, bufferWidth, colourInfo, usec); + if (usec != 0) + return hleDelayResult(result, "jpeg csc", usec); + return result; } static int getYCbCrBufferSize(int w, int h) { @@ -514,12 +622,12 @@ void JpegNotifyLoadStatus(int state) { const HLEFunction sceJpeg[] = { {0X0425B986, &WrapI_V, "sceJpegDecompressAllImage", 'i', "" }, - {0X04B5AE02, &WrapI_UUII, "sceJpegMJpegCsc", 'i', "xxii" }, + {0X04B5AE02, &WrapI_UUII, "sceJpegMJpegCsc", 'i', "xxxi" }, {0X04B93CEF, &WrapI_UIUI, "sceJpegDecodeMJpeg", 'i', "xixi" }, {0X227662D7, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCrSuccessively", 'i', "xixii"}, {0X48B602B7, &WrapI_V, "sceJpegDeleteMJpeg", 'i', "" }, {0X64B6F978, &WrapI_UIUI, "sceJpegDecodeMJpegSuccessively", 'i', "xixi" }, - {0X67F0ED84, &WrapI_UUIII, "sceJpegCsc", 'i', "xxiii"}, + {0X67F0ED84, &WrapI_UUIII, "sceJpegCsc", 'i', "xxxix"}, {0X7D2F3D7F, &WrapI_V, "sceJpegFinishMJpeg", 'i', "" }, {0X8F2BB012, &WrapI_UIUI, "sceJpegGetOutputInfo", 'x', "xipi" }, {0X91EED83C, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCr", 'i', "xixii"}, From 81cf76a61968c1618cc48d24633f0b641fb59b89 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 15:33:16 -0700 Subject: [PATCH 069/374] D3D9: Correct sampler states for binding 1+. --- Common/GPU/D3D9/thin3d_d3d9.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 377a0b4050..04bec49896 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -201,11 +201,19 @@ public: D3DTEXTUREFILTERTYPE magFilt, minFilt, mipFilt; void Apply(LPDIRECT3DDEVICE9 device, int index) { - dxstate.texAddressU.set(wrapS); - dxstate.texAddressV.set(wrapT); - dxstate.texMagFilter.set(magFilt); - dxstate.texMinFilter.set(minFilt); - dxstate.texMipFilter.set(mipFilt); + if (index == 0) { + dxstate.texAddressU.set(wrapS); + dxstate.texAddressV.set(wrapT); + dxstate.texMagFilter.set(magFilt); + dxstate.texMinFilter.set(minFilt); + dxstate.texMipFilter.set(mipFilt); + } else { + pD3Ddevice9->SetSamplerState(index, D3DSAMP_ADDRESSU, wrapS); + pD3Ddevice9->SetSamplerState(index, D3DSAMP_ADDRESSV, wrapT); + pD3Ddevice9->SetSamplerState(index, D3DSAMP_MAGFILTER, magFilt); + pD3Ddevice9->SetSamplerState(index, D3DSAMP_MINFILTER, minFilt); + pD3Ddevice9->SetSamplerState(index, D3DSAMP_MIPFILTER, mipFilt); + } } }; From 157ffed57f30e59c4a66356430ba51622e74f976 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 15:36:36 -0700 Subject: [PATCH 070/374] D3D9: Add simple rendered CLUT handling. I think there's still a deeper half-pixel offset issue, but this fixes Brave Story. --- GPU/Common/DepalettizeShaderCommon.cpp | 9 ++++++++- GPU/Directx9/TextureCacheDX9.cpp | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index a1e593e626..628efc787f 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -174,7 +174,10 @@ void GenerateDepalShaderFloat(ShaderWriter &writer, const DepalConfig &config) { case GE_FORMAT_CLUT8: if (shift == 0 && mask == 0xFF) { // Easy peasy. - sprintf(lookupMethod, "index.r"); + if (writer.Lang().shaderLanguage == HLSL_D3D9) + sprintf(lookupMethod, "index.a"); + else + sprintf(lookupMethod, "index.r"); formatOK = true; } else { // Deal with this if we find it. @@ -302,6 +305,10 @@ void GenerateDepalShaderFloat(ShaderWriter &writer, const DepalConfig &config) { // Offset by half a texel (plus clutBase) to turn NEAREST filtering into FLOOR. // Technically, the clutBase should be |'d, not added, but that's hard with floats. float texel_offset = ((float)config.startPos + 0.5f) / texturePixels; + if (writer.Lang().shaderLanguage == HLSL_D3D9) { + // Seems to need a half-pixel offset fix? Might mean it was rendered wrong... + texel_offset += 0.5f / texturePixels; + } char offset[128] = ""; sprintf(offset, " + %f", texel_offset); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 9edc451a52..0870299ac5 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -47,6 +47,8 @@ Draw::DataFormat FromD3D9Format(u32 fmt) { return Draw::DataFormat::A1R5G5B5_UNORM_PACK16; case D3DFMT_R5G6B5: return Draw::DataFormat::R5G6B5_UNORM_PACK16; + case D3DFMT_A8: + return Draw::DataFormat::R8_UNORM; case D3DFMT_A8R8G8B8: default: return Draw::DataFormat::R8G8B8A8_UNORM; @@ -251,6 +253,8 @@ void TextureCacheDX9::BuildTexture(TexCacheEntry *const entry) { dstFmt = ToD3D9Format(plan.replaced->Format(plan.baseLevelSrc)); } else if (plan.scaleFactor > 1 || plan.saveTexture) { dstFmt = D3DFMT_A8R8G8B8; + } else if (plan.decodeToClut8) { + dstFmt = D3DFMT_A8; } int levels; From ce79649c02edd1e167815cfc72e4c3b986237894 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 16:06:39 -0700 Subject: [PATCH 071/374] GLES: Use GL_LUMINANCE on GLES for indexed tex. See #16176, used for rendered CLUTs. --- Common/GPU/D3D9/D3D9StateCache.h | 12 ------------ Common/GPU/OpenGL/DataFormatGL.cpp | 13 +++++++++++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Common/GPU/D3D9/D3D9StateCache.h b/Common/GPU/D3D9/D3D9StateCache.h index ae2dbd0ff4..1478442c0f 100644 --- a/Common/GPU/D3D9/D3D9StateCache.h +++ b/Common/GPU/D3D9/D3D9StateCache.h @@ -398,15 +398,3 @@ public: #undef STATE2 extern DirectXState dxstate; - -struct GLExtensions { - bool OES_depth24; - bool OES_packed_depth_stencil; - bool OES_depth_texture; - bool EXT_discard_framebuffer; - bool FBO_ARB; -}; - -extern GLExtensions gl_extensions; - -void CheckGLExtensions(); diff --git a/Common/GPU/OpenGL/DataFormatGL.cpp b/Common/GPU/OpenGL/DataFormatGL.cpp index 48e439a76d..1b2af548d8 100644 --- a/Common/GPU/OpenGL/DataFormatGL.cpp +++ b/Common/GPU/OpenGL/DataFormatGL.cpp @@ -1,4 +1,5 @@ #include "Common/GPU/OpenGL/DataFormatGL.h" +#include "Common/GPU/OpenGL/GLFeatures.h" #include "Common/Log.h" namespace Draw { @@ -15,8 +16,16 @@ bool Thin3DFormatToGLFormatAndType(DataFormat fmt, GLuint &internalFormat, GLuin break; case DataFormat::R8_UNORM: - internalFormat = GL_RGBA; - format = GL_RED; + if (gl_extensions.IsGLES) { + internalFormat = GL_LUMINANCE; + format = GL_LUMINANCE; + } else if (gl_extensions.VersionGEThan(3, 0)) { + internalFormat = GL_RED; + format = GL_RED; + } else { + internalFormat = GL_RGBA; + format = GL_RED; + } type = GL_UNSIGNED_BYTE; alignment = 1; break; From 7d331f1928573d747a059901142a5a0c0beecd57 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 17:33:14 -0700 Subject: [PATCH 072/374] GPU: Ignore depth when masked and ALWAYS. Seen in NFS Pro Street, for example. Shouldn't be interpreted as depth usage. --- GPU/GPUCommon.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 9830984739..c5271b2705 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1715,13 +1715,22 @@ void GPUCommon::Execute_VertexTypeSkinning(u32 op, u32 diff) { void GPUCommon::CheckDepthUsage(VirtualFramebuffer *vfb) { if (!gstate_c.usingDepth) { - bool isClearingDepth = gstate.isModeClear() && gstate.isClearModeDepthMask(); + bool isReadingDepth = false; + bool isClearingDepth = false; + bool isWritingDepth = false; + if (gstate.isModeClear()) { + isClearingDepth = gstate.isClearModeDepthMask(); + isWritingDepth = isClearingDepth; + } else if (gstate.isDepthTestEnabled()) { + isWritingDepth = gstate.isDepthWriteEnabled(); + isReadingDepth = gstate.getDepthTestFunction() > GE_COMP_ALWAYS; + } - if ((gstate.isDepthTestEnabled() || isClearingDepth)) { + if (isWritingDepth || isReadingDepth) { gstate_c.usingDepth = true; gstate_c.clearingDepth = isClearingDepth; vfb->last_frame_depth_render = gpuStats.numFlips; - if (isClearingDepth || gstate.isDepthWriteEnabled()) { + if (isWritingDepth) { vfb->last_frame_depth_updated = gpuStats.numFlips; } framebufferManager_->SetDepthFrameBuffer(isClearingDepth); From b2ce4d2c3f1d20ed80743bdb3969a9332d26175b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 17:50:18 -0700 Subject: [PATCH 073/374] GPU: Refuse to set fb_address == z_address. We don't do it when creating framebufs either, so don't update to matching values. --- GPU/Common/FramebufferManagerCommon.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index df0342724a..158ac3ae0a 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -567,13 +567,22 @@ void FramebufferManagerCommon::SetDepthFrameBuffer(bool isClearingDepth) { currentRenderVfb_->usageFlags |= FB_USAGE_RENDER_DEPTH; uint32_t boundDepthBuffer = gstate.getDepthBufRawAddress() | 0x04000000; - if (currentRenderVfb_->z_address != boundDepthBuffer) { + uint32_t boundDepthStride = gstate.DepthBufStride(); + if (currentRenderVfb_->z_address != boundDepthBuffer || currentRenderVfb_->z_stride != boundDepthStride) { + if (currentRenderVfb_->fb_address == boundDepthBuffer) { + // Disallow setting depth buffer to the same address as the color buffer, usually means it's not used. + WARN_LOG_N_TIMES(z_reassign, 5, G3D, "Ignoring color matching depth buffer at %08x", boundDepthBuffer); + boundDepthBuffer = 0; + boundDepthStride = 0; + } WARN_LOG_N_TIMES(z_reassign, 5, G3D, "Framebuffer at %08x/%d has switched associated depth buffer from %08x to %08x, updating.", currentRenderVfb_->fb_address, currentRenderVfb_->fb_stride, currentRenderVfb_->z_address, boundDepthBuffer); // Technically, here we should copy away the depth buffer to another framebuffer that uses that z_address, or maybe // even write it back to RAM. However, this is rare. Silent Hill is one example, see #16126. currentRenderVfb_->z_address = boundDepthBuffer; + // Update the stride in case it changed. + currentRenderVfb_->z_stride = boundDepthStride; if (currentRenderVfb_->fbo) { char tag[128]; From 1c7a5bbb496b8e8a3910f0800277cf4dc6d45640 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 17:51:04 -0700 Subject: [PATCH 074/374] Debugger: Fix off-by-one in func scanning. This is inclusive. --- Core/Debugger/WebSocket/HLESubscriber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Debugger/WebSocket/HLESubscriber.cpp b/Core/Debugger/WebSocket/HLESubscriber.cpp index 2e4a7be55e..ca41d07a05 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.cpp +++ b/Core/Debugger/WebSocket/HLESubscriber.cpp @@ -428,7 +428,7 @@ void WebSocketHLEFuncScan(DebuggerRequest &req) { if (!Memory::IsValidRange(addr, size)) return req.Fail("Address or size outside valid memory"); - bool insertSymbols = MIPSAnalyst::ScanForFunctions(addr, addr + size, true); + bool insertSymbols = MIPSAnalyst::ScanForFunctions(addr, addr + size - 1, true); MIPSAnalyst::FinalizeScan(insertSymbols); req.Respond(); From 1c18d9b49b68ebabe315a474afeead1200eb48a3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 12:22:09 -0700 Subject: [PATCH 075/374] Jpeg: Correct some logging of return types. --- Core/HLE/sceJpeg.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index f748ebea46..f27aabe5bf 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -322,7 +322,7 @@ static int DecodeJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr, int &usec) { } free(jpegBuf); - return hleLogSuccessI(ME, getWidthHeight(width, height)); + return hleLogSuccessX(ME, getWidthHeight(width, height)); } static int sceJpegDecodeMJpeg(u32 jpegAddr, int jpegSize, u32 imageAddr, int dhtMode) { @@ -413,7 +413,7 @@ static int JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) { fclose(wfp); #endif //JPEG_DEBUG - return hleLogSuccessI(ME, getYCbCrBufferSize(width, height)); + return hleLogSuccessX(ME, getYCbCrBufferSize(width, height)); } static int sceJpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr, int dhtMode) { @@ -523,7 +523,7 @@ static int JpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, int y // Rough estimate based on observed timing. usec += (width * height) / 14; - return hleLogSuccessI(ME, getWidthHeight(width, height)); + return hleLogSuccessX(ME, getWidthHeight(width, height)); } static int sceJpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, int yCbCrSize, int dhtMode) { @@ -623,14 +623,14 @@ const HLEFunction sceJpeg[] = { {0X0425B986, &WrapI_V, "sceJpegDecompressAllImage", 'i', "" }, {0X04B5AE02, &WrapI_UUII, "sceJpegMJpegCsc", 'i', "xxxi" }, - {0X04B93CEF, &WrapI_UIUI, "sceJpegDecodeMJpeg", 'i', "xixi" }, - {0X227662D7, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCrSuccessively", 'i', "xixii"}, + {0X04B93CEF, &WrapI_UIUI, "sceJpegDecodeMJpeg", 'x', "xixi" }, + {0X227662D7, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCrSuccessively", 'x', "xixii"}, {0X48B602B7, &WrapI_V, "sceJpegDeleteMJpeg", 'i', "" }, - {0X64B6F978, &WrapI_UIUI, "sceJpegDecodeMJpegSuccessively", 'i', "xixi" }, + {0X64B6F978, &WrapI_UIUI, "sceJpegDecodeMJpegSuccessively", 'x', "xixi" }, {0X67F0ED84, &WrapI_UUIII, "sceJpegCsc", 'i', "xxxix"}, {0X7D2F3D7F, &WrapI_V, "sceJpegFinishMJpeg", 'i', "" }, {0X8F2BB012, &WrapI_UIUI, "sceJpegGetOutputInfo", 'x', "xipi" }, - {0X91EED83C, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCr", 'i', "xixii"}, + {0X91EED83C, &WrapI_UIUII, "sceJpegDecodeMJpegYCbCr", 'x', "xixii"}, {0X9B36444C, &WrapI_V, "sceJpeg_9B36444C", 'i', "" }, {0X9D47469C, &WrapI_II, "sceJpegCreateMJpeg", 'i', "ii" }, {0XAC9E70E6, &WrapI_V, "sceJpegInitMJpeg", 'i', "" }, From 9c026927bd7dba0fcafe7dd9bd224dc71495e5c6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 20:24:54 -0700 Subject: [PATCH 076/374] Jpeg: Encode and decode YCbCr as 2x2. Verified this is what's output from a PSP's DecodeMJpegYCbCr, and games directly use its output in MJpegCsc - so change to match. This makes the colors in Gods Eater Burst character portraits look better. --- Core/HLE/sceJpeg.cpp | 86 ++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index f27aabe5bf..f7140ae229 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -140,7 +140,7 @@ static int JpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bufferWidt u8 cb = Cb[(width >> widthShift) * (y >> heightShift) + (x >> widthShift)]; u8 cr = Cr[(width >> widthShift) * (y >> heightShift) + (x >> widthShift)]; - imageBuffer[bufferWidth * y + x + 0] = convertYCbCrToABGR(y0, cb, cr); + imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(y0, cb, cr); imageBuffer[bufferWidth * y + x + 1] = convertYCbCrToABGR(y1, cb, cr); imageBuffer[bufferWidth * (y + 1) + x] = convertYCbCrToABGR(y2, cb, cr); imageBuffer[bufferWidth * (y + 1) + x + 1] = convertYCbCrToABGR(y3, cb, cr); @@ -174,8 +174,6 @@ static int JpegMJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int buffe if (height == 0) height = 1; - uint8_t widthShift = 1; - uint8_t heightShift = 1; int sizeY = width * height; int sizeCb = sizeY >> 2; @@ -205,31 +203,29 @@ static int JpegMJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int buffe imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(0, 0, 0); } } - } else if ((widthHeight & 0x00030000) == 0) { - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; x += 4) { - int offset = width * y + x; - u8 y0 = Y[offset + 0]; - u8 y1 = Y[offset + 1]; - u8 y2 = Y[offset + 2]; - u8 y3 = Y[offset + 3]; - u8 cb = Cb[offset >> 2]; - u8 cr = Cr[offset >> 2]; + } else if ((widthHeight & 0x00010001) == 0 && height > 1) { + for (int y = 0; y < height; y += 2) { + for (int x = 0; x < width; x += 2) { + u8 y0 = Y[width * y + x]; + u8 y1 = Y[width * y + x + 1]; + u8 y2 = Y[width * (y + 1) + x]; + u8 y3 = Y[width * (y + 1) + x + 1]; + u8 cb = Cb[(width >> 1) * (y >> 1) + (x >> 1)]; + u8 cr = Cr[(width >> 1) * (y >> 1) + (x >> 1)]; - imageBuffer[bufferWidth * y + x + 0] = convertYCbCrToABGR(y0, cb, cr); + imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(y0, cb, cr); imageBuffer[bufferWidth * y + x + 1] = convertYCbCrToABGR(y1, cb, cr); - imageBuffer[bufferWidth * y + x + 2] = convertYCbCrToABGR(y2, cb, cr); - imageBuffer[bufferWidth * y + x + 3] = convertYCbCrToABGR(y3, cb, cr); + imageBuffer[bufferWidth * (y + 1) + x] = convertYCbCrToABGR(y2, cb, cr); + imageBuffer[bufferWidth * (y + 1) + x + 1] = convertYCbCrToABGR(y3, cb, cr); } } NotifyMemInfo(MemBlockFlags::READ, yCbCrAddr, sizeY + sizeCb + sizeCb, "JpegMJpegCsc"); } else { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { - int offset = width * y + x; - u8 yy = Y[offset]; - u8 cb = Cb[offset >> 2]; - u8 cr = Cr[offset >> 2]; + u8 yy = Y[width * y + x]; + u8 cb = Cb[(width >> 1) * (y >> 1) + (x >> 1)]; + u8 cr = Cr[(width >> 1) * (y >> 1) + (x >> 1)]; imageBuffer[bufferWidth * y + x] = convertYCbCrToABGR(yy, cb, cr); } @@ -451,28 +447,40 @@ static int JpegConvertRGBToYCbCr(const void *data, u8 *output, int width, int he u8 *Cb = Y + sizeY; u8 *Cr = Cb + sizeCb; - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; x += 4) { - u32 abgr0 = imageBuffer[x + 0]; - u32 abgr1 = imageBuffer[x + 1]; - u32 abgr2 = imageBuffer[x + 2]; - u32 abgr3 = imageBuffer[x + 3]; + if ((width & 1) == 0 && (height & 1) == 0) { + for (int y = 0; y < height; y += 2) { + for (int x = 0; x < width; x += 2) { + u32 rgb0 = imageBuffer[width * y + x]; + u32 rgb1 = imageBuffer[width * y + x + 1]; + u32 rgb2 = imageBuffer[width * (y + 1) + x]; + u32 rgb3 = imageBuffer[width * (y + 1) + x + 1]; - u32 yCbCr0 = convertRGBToYCbCr(abgr0); - u32 yCbCr1 = convertRGBToYCbCr(abgr1); - u32 yCbCr2 = convertRGBToYCbCr(abgr2); - u32 yCbCr3 = convertRGBToYCbCr(abgr3); - - Y[x + 0] = (yCbCr0 >> 16) & 0xFF; - Y[x + 1] = (yCbCr1 >> 16) & 0xFF; - Y[x + 2] = (yCbCr2 >> 16) & 0xFF; - Y[x + 3] = (yCbCr3 >> 16) & 0xFF; + u32 yCbCr0 = convertRGBToYCbCr(rgb0); + u32 yCbCr1 = convertRGBToYCbCr(rgb1); + u32 yCbCr2 = convertRGBToYCbCr(rgb2); + u32 yCbCr3 = convertRGBToYCbCr(rgb3); - *Cb++ = (yCbCr0 >> 8) & 0xFF; - *Cr++ = yCbCr0 & 0xFF; + Y[width * y + x] = (yCbCr0 >> 16) & 0xFF; + Y[width * y + x + 1] = (yCbCr1 >> 16) & 0xFF; + Y[width * (y + 1) + x] = (yCbCr2 >> 16) & 0xFF; + Y[width * (y + 1) + x + 1] = (yCbCr3 >> 16) & 0xFF; + Cb[(width >> 1) * (y >> 1) + (x >> 1)] = (yCbCr0 >> 8) & 0xFF; + Cr[(width >> 1) * (y >> 1) + (x >> 1)] = yCbCr0 & 0xFF; + } + } + } else { + for (int y = 0; y < height; ++y) { + for (int x = 0; x < width; ++x) { + u32 rgb = imageBuffer[width * y + x]; + u32 yCbCr = convertRGBToYCbCr(rgb); + Y[width * y + x] = (yCbCr >> 16) & 0xFF; + if ((y & 1) == 0 && (x & 1) == 0) { + // Ideally, would average, but I suppose these just came from a JPEG, so they ought to match. + Cb[(width >> 1) * (y >> 1) + (x >> 1)] = (yCbCr >> 8) & 0xFF; + Cr[(width >> 1) * (y >> 1) + (x >> 1)] = yCbCr & 0xFF; + } + } } - imageBuffer += width; - Y += width; } return getWidthHeight(width, height); } From 33993b857449dd57808d8f96eadd3abafc07ccfe Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Oct 2022 20:31:39 -0700 Subject: [PATCH 077/374] Jpeg: Cleanup debug dump file access. --- Core/HLE/sceJpeg.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index f7140ae229..bc99171c7c 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -34,6 +34,8 @@ // #define JPEG_DEBUG #ifdef JPEG_DEBUG #include "ext/xxhash.h" +#include "Common/File/FileUtil.h" +#include "Common/StringUtils.h" #endif struct u24_be { @@ -396,14 +398,14 @@ static int JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) { } #ifdef JPEG_DEBUG - char jpeg_fname[256]; const u8 *jpegDumpBuf = Memory::GetPointer(jpegAddr); u32 jpeg_xxhash = XXH32((const char *)jpegDumpBuf, jpegSize, 0xC0108888); - sprintf(jpeg_fname, "Jpeg\\%X.jpg", jpeg_xxhash); - FILE *wfp = fopen(jpeg_fname, "wb"); + Path jpegDir("Jpeg"); + Path jpegFile = jpegDir / StringFromFormat("%X.jpg", jpeg_xxhash); + FILE *wfp = File::OpenCFile(jpegFile, "wb"); if (!wfp) { - _wmkdir(L"Jpeg\\"); - wfp = fopen(jpeg_fname, "wb"); + File::CreateDir(jpegDir); + wfp = File::OpenCFile(jpegFile, "wb"); } fwrite(jpegDumpBuf, 1, jpegSize, wfp); fclose(wfp); From e7e7528fbcd5d41113281d081c85d7900c16347e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 00:50:45 -0700 Subject: [PATCH 078/374] GPU: Consider depth buffers in block transfer. Right now, only with an explicit flag (not yet used.) --- GPU/Common/FramebufferManagerCommon.cpp | 42 ++++++++++++++++++++----- GPU/GPUInterface.h | 3 +- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index df0342724a..17c618c43a 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1657,13 +1657,14 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, VirtualFramebuffer *srcBuffer = nullptr; bool ignoreDstBuffer = flags & GPUCopyFlag::FORCE_DST_MEM; bool ignoreSrcBuffer = flags & (GPUCopyFlag::FORCE_SRC_MEM | GPUCopyFlag::MEMSET); + RasterChannel channel = flags & GPUCopyFlag::DEPTH_REQUESTED ? RASTER_DEPTH : RASTER_COLOR; u32 dstY = (u32)-1; u32 dstH = 0; u32 srcY = (u32)-1; u32 srcH = 0; for (auto vfb : vfbs_) { - if (vfb->fb_stride == 0) { + if (vfb->fb_stride == 0 || channel != RASTER_COLOR) { continue; } @@ -1715,14 +1716,36 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, } } + if (channel == RASTER_DEPTH) { + srcBuffer = nullptr; + dstBuffer = nullptr; + // Let's assume exact matches only for simplicity. + for (auto vfb : vfbs_) { + if (!ignoreDstBuffer && dst == vfb->z_address && size == vfb->z_stride * 2 * vfb->height) { + if (!dstBuffer || dstBuffer->depthBindSeq < vfb->depthBindSeq) { + dstBuffer = vfb; + dstY = 0; + dstH = vfb->height; + } + } + if (!ignoreSrcBuffer && src == vfb->z_address && size == vfb->z_stride * 2 * vfb->height) { + if (!srcBuffer || srcBuffer->depthBindSeq < vfb->depthBindSeq) { + srcBuffer = vfb; + srcY = 0; + srcH = vfb->height; + } + } + } + } + if (!useBufferedRendering_) { // If we're copying into a recently used display buf, it's probably destined for the screen. - if (srcBuffer || (dstBuffer != displayFramebuf_ && dstBuffer != prevDisplayFramebuf_)) { + if (channel == RASTER_DEPTH || srcBuffer || (dstBuffer != displayFramebuf_ && dstBuffer != prevDisplayFramebuf_)) { return false; } } - if (!dstBuffer && srcBuffer) { + if (!dstBuffer && srcBuffer && channel != RASTER_DEPTH) { // Note - if we're here, we're in a memcpy, not a block transfer. Not allowing IntraVRAMBlockTransferAllowCreateFB. // Technically, that makes BlockTransferAllowCreateFB a bit of a misnomer. if (PSP_CoreParameter().compat.flags().BlockTransferAllowCreateFB) { @@ -1740,7 +1763,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, } else { WARN_LOG_ONCE(dstnotsrccpy, G3D, "Inter-buffer memcpy %08x -> %08x (size: %x)", src, dst, size); // Just do the blit! - BlitFramebuffer(dstBuffer, 0, dstY, srcBuffer, 0, srcY, srcBuffer->width, srcH, 0, RASTER_COLOR, "Blit_InterBufferMemcpy"); + BlitFramebuffer(dstBuffer, 0, dstY, srcBuffer, 0, srcY, srcBuffer->width, srcH, 0, channel, "Blit_InterBufferMemcpy"); SetColorUpdated(dstBuffer, skipDrawReason); RebindFramebuffer("RebindFramebuffer - Inter-buffer memcpy"); } @@ -1752,7 +1775,9 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, WARN_LOG_ONCE(btucpy, G3D, "Memcpy fbo upload %08x -> %08x (size: %x)", src, dst, size); FlushBeforeCopy(); const u8 *srcBase = Memory::GetPointerUnchecked(src); - DrawPixels(dstBuffer, 0, dstY, srcBase, dstBuffer->fb_format, dstBuffer->fb_stride, dstBuffer->width, dstH, RASTER_COLOR, "MemcpyFboUpload_DrawPixels"); + GEBufferFormat srcFormat = channel == RASTER_DEPTH ? GE_FORMAT_DEPTH16 : dstBuffer->fb_format; + int srcStride = channel == RASTER_DEPTH ? dstBuffer->z_stride : dstBuffer->fb_stride; + DrawPixels(dstBuffer, 0, dstY, srcBase, srcFormat, srcStride, dstBuffer->width, dstH, channel, "MemcpyFboUpload_DrawPixels"); SetColorUpdated(dstBuffer, skipDrawReason); RebindFramebuffer("RebindFramebuffer - Memcpy fbo upload"); // This is a memcpy, let's still copy just in case. @@ -1762,8 +1787,8 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, FlushBeforeCopy(); if (srcH == 0 || srcY + srcH > srcBuffer->bufferHeight) { WARN_LOG_ONCE(btdcpyheight, G3D, "Memcpy fbo download %08x -> %08x skipped, %d+%d is taller than %d", src, dst, srcY, srcH, srcBuffer->bufferHeight); - } else if (g_Config.bBlockTransferGPU && !srcBuffer->memoryUpdated) { - ReadFramebufferToMemory(srcBuffer, 0, srcY, srcBuffer->width, srcH, RASTER_COLOR); + } else if (g_Config.bBlockTransferGPU && (!srcBuffer->memoryUpdated || channel == RASTER_DEPTH)) { + ReadFramebufferToMemory(srcBuffer, 0, srcY, srcBuffer->width, srcH, channel); srcBuffer->usageFlags = (srcBuffer->usageFlags | FB_USAGE_DOWNLOAD) & ~FB_USAGE_DOWNLOAD_CLEAR; } return false; @@ -2623,7 +2648,8 @@ void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, vfb->usageFlags |= FB_USAGE_DOWNLOAD; } else if (x == 0 && y == 0 && w == vfb->width && h == vfb->height) { // Mark it as fully downloaded until next render to it. - vfb->memoryUpdated = true; + if (channel == RASTER_COLOR) + vfb->memoryUpdated = true; vfb->usageFlags |= FB_USAGE_DOWNLOAD; } else { // Let's try to set the flag eventually, if the game copies a lot. diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index e7cf2f9af6..3a71b550b4 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -120,7 +120,8 @@ enum class GPUCopyFlag { FORCE_DST_MEM = 2, // Note: implies src == dst and FORCE_SRC_MEM. MEMSET = 4, - DEBUG_NOTIFIED = 8, + DEPTH_REQUESTED = 8, + DEBUG_NOTIFIED = 16, }; ENUM_CLASS_BITOPS(GPUCopyFlag); From 057661380efc6e31bf634b1eca4d24a7e805f5fa Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 00:52:35 -0700 Subject: [PATCH 079/374] GPU: Hook Gods Eater Burst avatar read. Currently not working since depth comes back as 0. --- Core/HLE/ReplaceTables.cpp | 30 ++++++++++++++++++++++++++++++ Core/MIPS/MIPSAnalyst.cpp | 1 + 2 files changed, 31 insertions(+) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 462bad0a7e..cc4777af98 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -691,6 +691,35 @@ static int Hook_godseaterburst_blit_texture() { return 0; } +static int Hook_godseaterburst_depthmask_5551() { + // This function copies the 5551 framebuffer to a temporary, generating alpha based on depth. + // Depth is optional, in which case all pixels get full alpha. + // Called when your avatar changes to screenshot for save data. + uint32_t colorBuffer = currentMIPS->r[MIPS_REG_A1]; + uint32_t depthBuffer = currentMIPS->r[MIPS_REG_T2]; + uint32_t byteStride = currentMIPS->r[MIPS_REG_A2]; + uint32_t height = currentMIPS->r[MIPS_REG_T1]; + uint32_t size = byteStride * height; + + if (!Memory::IsVRAMAddress(colorBuffer) || !Memory::IsValidRange(colorBuffer, size)) + return 0; + if (depthBuffer != 0) { + if (!Memory::IsVRAMAddress(colorBuffer) || !Memory::IsValidRange(depthBuffer, size)) + return 0; + + // This is added to read from the linearized mirror. + uint32_t depthMirror = depthBuffer + 0x00200000; + // Depth download required, or it won't work and will be transparent. + gpu->PerformMemoryCopy(depthMirror, depthMirror, size, GPUCopyFlag::FORCE_DST_MEM | GPUCopyFlag::DEPTH_REQUESTED); + NotifyMemInfo(MemBlockFlags::WRITE, depthMirror, size, "godseaterburst_depthmask_5551"); + } + + gpu->PerformMemoryDownload(colorBuffer, size); + NotifyMemInfo(MemBlockFlags::WRITE, colorBuffer, size, "godseaterburst_depthmask_5551"); + + return 0; +} + static int Hook_hexyzforce_monoclome_thread() { u32 fb_info; if (!GetMIPSStaticAddress(fb_info, -4, 0)) { @@ -1414,6 +1443,7 @@ static const ReplacementTableEntry entries[] = { // { "vmmul_q_transp", &Replace_vmmul_q_transp, 0, REPFLAG_DISABLED }, { "godseaterburst_blit_texture", &Hook_godseaterburst_blit_texture, 0, REPFLAG_HOOKENTER }, + { "godseaterburst_depthmask_5551", &Hook_godseaterburst_depthmask_5551, 0, REPFLAG_HOOKENTER }, { "hexyzforce_monoclome_thread", &Hook_hexyzforce_monoclome_thread, 0, REPFLAG_HOOKENTER, 0x58 }, { "starocean_write_stencil", &Hook_starocean_write_stencil, 0, REPFLAG_HOOKENTER, 0x260 }, { "topx_create_saveicon", &Hook_topx_create_saveicon, 0, REPFLAG_HOOKENTER, 0x34 }, diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index 81f87da663..09e9771c34 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -289,6 +289,7 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0x70a6152b265228e8, 296, "unendingbloodycall_download_frame", }, // unENDing Bloody Call { 0x7245b74db370ae72, 64, "vmmul_q_transp3", }, { 0x7259d52b21814a5a, 40, "vtfm_t_transp", }, + { 0x730f59cc6c0f5732, 452, "godseaterburst_depthmask_5551", }, // Gods Eater Burst (US) { 0x7354fd206796d817, 864, "flowers_download_frame", }, // Flowers { 0x736b34ebc702d873, 104, "vmmul_q_transp", }, { 0x73a614c08f777d52, 792, "danganronpa2_2_download_frame", }, // Danganronpa 2 From d0eb14ec0214788b4061cc61510c8c752791cae9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 00:54:59 -0700 Subject: [PATCH 080/374] GPU: Correct sizing account on block transfer. --- GPU/Common/FramebufferManagerCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 17c618c43a..308bd8bfeb 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2605,7 +2605,7 @@ void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int const int dstByteOffset = (y * stride + x) * dstBpp; // Leave the gap between the end of the last line and the full stride. // This is only used for the NotifyMemInfo range. - const int dstSize = (h * stride + w - 1) * dstBpp; + const int dstSize = ((h - 1) * stride + w) * dstBpp; if (!Memory::IsValidRange(fb_address + dstByteOffset, dstSize)) { ERROR_LOG_REPORT(G3D, "PackFramebufferSync would write outside of memory, ignoring"); From bc84d6345b6e7cc2c76322f8af36f0a53de2a66c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 00:57:10 -0700 Subject: [PATCH 081/374] Vulkan: Disable geometry shaders for Mali <= 18. These drivers apparently have some weird behavior. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 5 +++-- Common/GPU/thin3d.h | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index cf2a28ea53..6c342f8e9e 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -848,8 +848,9 @@ VKContext::VKContext(VulkanContext *vulkan) } // Older ARM devices have very slow geometry shaders, not worth using. At least before 15. - if (majorVersion <= 15) { - bugs_.Infest(Bugs::GEOMETRY_SHADERS_SLOW); + // Also seen to cause weird issues on 18, so let's lump it in. + if (majorVersion <= 18) { + bugs_.Infest(Bugs::GEOMETRY_SHADERS_SLOW_OR_BROKEN); } } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index c04b7119cd..3e482687a3 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -333,7 +333,7 @@ public: RASPBERRY_SHADER_COMP_HANG = 8, MALI_CONSTANT_LOAD_BUG = 9, SUBPASS_FEEDBACK_BROKEN = 10, - GEOMETRY_SHADERS_SLOW = 11, + GEOMETRY_SHADERS_SLOW_OR_BROKEN = 11, MAX_BUG, }; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index f285af82d0..64f69a861b 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -234,7 +234,7 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { // Fall back to geometry shader culling if we can't do vertex range culling. if (enabledFeatures.geometryShader) { - const bool useGeometry = g_Config.bUseGeometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW); + const bool useGeometry = g_Config.bUseGeometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW_OR_BROKEN); const bool vertexSupported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; if (useGeometry && (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0)) { // Switch to culling via the geometry shader if not fully supported in vertex. diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 4d1d6c6798..153f03d69c 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -474,7 +474,7 @@ void GameSettingsScreen::CreateViews() { } if (GetGPUBackend() == GPUBackend::VULKAN) { - const bool usable = !draw->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW); + const bool usable = !draw->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW_OR_BROKEN); const bool vertexSupported = draw->GetDeviceCaps().clipDistanceSupported && draw->GetDeviceCaps().cullDistanceSupported; if (usable && !vertexSupported) { CheckBox *geometryCulling = graphicsSettings->Add(new CheckBox(&g_Config.bUseGeometryShader, gr->T("Geometry shader culling"))); From ad3220f8572faca0d8756d65e6823f73d7d2a4c9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 01:08:04 -0700 Subject: [PATCH 082/374] GLES: Hook up depth download. Currently, only used by one hook. --- GPU/Common/FramebufferManagerCommon.cpp | 17 ++++++++++++++++- GPU/Common/FramebufferManagerCommon.h | 2 ++ GPU/Directx9/FramebufferManagerDX9.h | 2 +- GPU/GLES/FramebufferManagerGLES.h | 3 +-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 308bd8bfeb..7fbb9a74fc 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2619,7 +2619,11 @@ void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int DEBUG_LOG(G3D, "Reading framebuffer to mem, fb_address = %08x, ptr=%p", fb_address, destPtr); if (destPtr) { - draw_->CopyFramebufferToMemorySync(vfb->fbo, channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackFramebufferSync"); + if (channel == RASTER_DEPTH) + PackDepthbuffer(vfb, x, y, w, h); + else + draw_->CopyFramebufferToMemorySync(vfb->fbo, channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackFramebufferSync"); + char tag[128]; size_t len = snprintf(tag, sizeof(tag), "FramebufferPack/%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString(vfb->fb_format)); NotifyMemInfo(MemBlockFlags::WRITE, fb_address + dstByteOffset, dstSize, tag, len); @@ -2630,6 +2634,17 @@ void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int gpuStats.numReadbacks++; } +void FramebufferManagerCommon::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) { + _assert_msg_(vfb && vfb->z_address != 0 && vfb->z_stride != 0, "Depth buffer invalid"); + + Draw::DataFormat destFormat = GEFormatToThin3D(GE_FORMAT_DEPTH16); + const int dstByteOffset = (y * vfb->z_stride + x) * 2; + u8 *destPtr = Memory::GetPointerWriteUnchecked(vfb->z_address + dstByteOffset); + if (!draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackDepthbuffer")) { + WARN_LOG(G3D, "PackDepthbuffer failed"); + } +} + void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { // Clamp to bufferWidth. Sometimes block transfers can cause this to hit. if (x + w >= vfb->bufferWidth) { diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index b3bd21d7c9..e727c1a25a 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -442,6 +442,8 @@ public: protected: virtual void PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel); + // Used for when a shader is required, such as GLES. + virtual void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h); void SetViewport2D(int x, int y, int w, int h); Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height); void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags); diff --git a/GPU/Directx9/FramebufferManagerDX9.h b/GPU/Directx9/FramebufferManagerDX9.h index 0f4f7d7ce1..1d7e522b48 100644 --- a/GPU/Directx9/FramebufferManagerDX9.h +++ b/GPU/Directx9/FramebufferManagerDX9.h @@ -49,10 +49,10 @@ public: protected: void DecimateFBOs() override; + void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; private: void PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) override; - void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h); bool GetRenderTargetFramebuffer(LPDIRECT3DSURFACE9 renderTarget, LPDIRECT3DSURFACE9 offscreen, int w, int h, GPUDebugBuffer &buffer); LPDIRECT3DDEVICE9 device_; diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index eb5354b60e..e75de97308 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -38,10 +38,9 @@ public: protected: void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; + void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; private: - void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h); - u8 *convBuf_ = nullptr; u32 convBufSize_ = 0; From e67cc1666009181a02e843f93fc84894ff81b03a Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Sun, 9 Oct 2022 19:11:14 +0300 Subject: [PATCH 083/374] Remote API: hle.func.removeRange added --- Core/Debugger/WebSocket/HLESubscriber.cpp | 61 +++++++++++++++++++++-- Core/Debugger/WebSocket/HLESubscriber.h | 1 + 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/Core/Debugger/WebSocket/HLESubscriber.cpp b/Core/Debugger/WebSocket/HLESubscriber.cpp index ca41d07a05..2a90ca619d 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.cpp +++ b/Core/Debugger/WebSocket/HLESubscriber.cpp @@ -36,6 +36,7 @@ DebuggerSubscriber *WebSocketHLEInit(DebuggerEventHandlerMap &map) { map["hle.func.list"] = &WebSocketHLEFuncList; map["hle.func.add"] = &WebSocketHLEFuncAdd; map["hle.func.remove"] = &WebSocketHLEFuncRemove; + map["hle.func.removeRange"] = &WebSocketHLEFuncRemoveRange; map["hle.func.rename"] = &WebSocketHLEFuncRename; map["hle.func.scan"] = &WebSocketHLEFuncScan; map["hle.module.list"] = &WebSocketHLEModuleList; @@ -361,6 +362,60 @@ void WebSocketHLEFuncRemove(DebuggerRequest &req) { json.writeUint("size", funcSize); } +// Remove function symbols in range (hle.func.removeRange) +// +// Parameters: +// - address: unsigned integer address for the start of the range. +// - size: unsigned integer size in bytes for removal +// +// Response (same event name): +// - count: number of removed functions +void WebSocketHLEFuncRemoveRange(DebuggerRequest &req) { + if (!g_symbolMap) + return req.Fail("CPU not active"); + if (!Core_IsStepping()) + return req.Fail("CPU currently running (cpu.stepping first)"); + + u32 addr; + if (!req.ParamU32("address", &addr)) + return; + u32 size; + if (!req.ParamU32("size", &size)) + return; + + if (!Memory::IsValidRange(addr, size)) + return req.Fail("Address or size outside valid memory"); + + u32 first_address = g_symbolMap->GetFunctionStart(addr); + if (first_address == SymbolMap::INVALID_ADDRESS) { + first_address = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION); + } + + u32 counter = 0; + for (u32 current_addr = first_address; (current_addr < addr + size) && current_addr != SymbolMap::INVALID_ADDRESS; current_addr = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION)) { + g_symbolMap->RemoveFunction(current_addr, true); + ++counter; + } + MIPSAnalyst::ForgetFunctions(addr, addr + size - 1); + + // The following was copied from hle.func.remove: + g_symbolMap->SortSymbols(); + + MIPSAnalyst::UpdateHashMap(); + MIPSAnalyst::ApplyHashMap(); + + if (g_Config.bFuncReplacements) { + MIPSAnalyst::ReplaceFunctions(); + } + + // Clear cache for branch lines and such. + DisassemblyManager manager; + manager.clear(); + + JsonWriter &json = req.Respond(); + json.writeUint("count", counter); +} + // Rename a function symbol (hle.func.rename) // // Parameters: @@ -368,8 +423,8 @@ void WebSocketHLEFuncRemove(DebuggerRequest &req) { // - name: string, new name for the function. // // Response (same event name): -// - address: the start address of the removed function. -// - size: the size in bytes of the removed function. +// - address: the start address of the renamed function. +// - size: the size in bytes of the renamed function. // - name: string, new name repeated back. void WebSocketHLEFuncRename(DebuggerRequest &req) { if (!g_symbolMap) @@ -408,7 +463,7 @@ void WebSocketHLEFuncRename(DebuggerRequest &req) { // Auto-detect functions in a memory range (hle.func.scan) // // Parameters: -// - address: unsigned integer address within function to rename. +// - address: unsigned integer address for the start of the range. // - size: unsigned integer size in bytes for scan. // // Response (same event name) with no extra data. diff --git a/Core/Debugger/WebSocket/HLESubscriber.h b/Core/Debugger/WebSocket/HLESubscriber.h index e70b4c8ff0..9ee4bad800 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.h +++ b/Core/Debugger/WebSocket/HLESubscriber.h @@ -27,6 +27,7 @@ void WebSocketHLEThreadStop(DebuggerRequest &req); void WebSocketHLEFuncList(DebuggerRequest &req); void WebSocketHLEFuncAdd(DebuggerRequest &req); void WebSocketHLEFuncRemove(DebuggerRequest &req); +void WebSocketHLEFuncRemoveRange(DebuggerRequest &req); void WebSocketHLEFuncRename(DebuggerRequest &req); void WebSocketHLEFuncScan(DebuggerRequest &req); void WebSocketHLEModuleList(DebuggerRequest &req); From 9422b05ee3a0108eabfa7aa643b0113d2d53ac2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 Oct 2022 18:57:48 +0200 Subject: [PATCH 084/374] Fix depal bounds with dynamic CLUT. Fixes lens flare glitches in Ridge Racer With this wrong, we ended up drawing pixels that came from a DONT_CARE init of the depal temp buffer, which was a pile of garbage on Android and blank on PC. Now, we seem to end up not drawing anything because the depal operation results in transparent black into whatever is actually intended, but at least the screen isn't full of glitches when the sun is visible on Adreno. See issue #16083 --- GPU/Common/TextureCacheCommon.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index cf012d4010..f96d922a85 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2242,10 +2242,11 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { float u2 = texWidth; float v2 = texHeight; if (bounds.minV < bounds.maxV) { - u1 = (bounds.minU + gstate_c.curTextureXOffset) * texWidth; - v1 = (bounds.minV + gstate_c.curTextureYOffset) * texHeight; - u2 = (bounds.maxU + gstate_c.curTextureXOffset) * texWidth; - v2 = (bounds.maxV + gstate_c.curTextureYOffset) * texHeight; + // These are already in pixel coords! Doesn't seem like we should multiply by texwidth/height. + u1 = bounds.minU + gstate_c.curTextureXOffset; + v1 = bounds.minV + gstate_c.curTextureYOffset; + u2 = bounds.maxU + gstate_c.curTextureXOffset; + v2 = bounds.maxV + gstate_c.curTextureYOffset; // We need to reapply the texture next time since we cropped UV. gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); } From be37de106c3fa657611c9ad0a63683c93adbbd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 2 Oct 2022 15:52:52 +0200 Subject: [PATCH 085/374] Vulkan: Create depth/stencil buffers on demand --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 5 +++-- Common/GPU/Vulkan/VulkanRenderManager.cpp | 16 +++++++++++----- Common/GPU/Vulkan/VulkanRenderManager.h | 5 ++++- Common/UI/Context.cpp | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 69d81b5391..c1da294a0f 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1611,7 +1611,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR renderPass = GetRenderPass(key); VKRFramebuffer *fb = step.render.framebuffer; - framebuf = fb->Get(renderPass, step.render.renderPassType); + framebuf = fb->Get(renderPass, step.render.renderPassType, cmd); w = fb->width; h = fb->height; @@ -1799,7 +1799,8 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { // We can't copy only depth or only stencil unfortunately. if (step.blit.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { _dbg_assert_(src->depth.image != VK_NULL_HANDLE); - _dbg_assert_(dst->depth.image != VK_NULL_HANDLE); + + dst->EnsureDepthImage(cmd); if (src->depth.layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { SetupTransitionToTransferSrc(src->depth, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, &recordBarrier_); diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 3343bd889f..44a4455d98 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -161,9 +161,6 @@ VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRe _dbg_assert_(tag); CreateImage(vulkan_, initCmd, color, width, height, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true, tag); - if (createDepthStencilBuffer) { - CreateImage(vulkan_, initCmd, depth, width, height, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false, tag); - } UpdateTag(tag); @@ -172,6 +169,7 @@ VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRe } void VKRFramebuffer::UpdateTag(const char *newTag) { + tag_ = newTag; char name[128]; snprintf(name, sizeof(name), "fb_color_%s", tag_.c_str()); vulkan_->SetDebugName(color.image, VK_OBJECT_TYPE_IMAGE, name); @@ -189,7 +187,14 @@ void VKRFramebuffer::UpdateTag(const char *newTag) { } } -VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType) { +void VKRFramebuffer::EnsureDepthImage(VkCommandBuffer initCmd) { + if (!depth.image) { + CreateImage(vulkan_, initCmd, depth, width, height, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false, tag_.c_str()); + UpdateTag(tag_.c_str()); + } +} + +VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, VkCommandBuffer initCmd) { if (framebuf[(int)rpType]) { return framebuf[(int)rpType]; } @@ -201,7 +206,8 @@ VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPas views[0] = color.imageView; if (hasDepth) { - _dbg_assert_(depth.imageView != VK_NULL_HANDLE); + // Make sure there's a depth buffer! + EnsureDepthImage(initCmd); views[1] = depth.imageView; } fbci.renderPass = compatibleRenderPass->Get(vulkan_, rpType); diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 7fd45e2246..e1f66c29e2 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -46,7 +46,10 @@ public: VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, bool createDepthStencilBuffer, const char *tag); ~VKRFramebuffer(); - VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType); + void EnsureDepthImage(VkCommandBuffer initCmd); + + // Needs a command buffer in case it need to initialize the depth buffer on-demand. + VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, VkCommandBuffer initCmd); int width = 0; int height = 0; diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index 21c687bd2b..da4a98fa78 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -170,7 +170,7 @@ void UIContext::ActivateTopScissor() { int h = std::max(0.0f, ceilf(scale_y * bounds.h)); if (x < 0 || y < 0 || x + w > pixel_xres || y + h > pixel_yres) { // This won't actually report outside a game, but we can try. - ERROR_LOG_REPORT(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres); + WARN_LOG(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres); x = std::max(0, x); y = std::max(0, y); w = std::min(w, pixel_xres - x); From 0c4935f336dee11e23b990079d3569b13eef723d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 Oct 2022 20:45:27 +0200 Subject: [PATCH 086/374] Depal from dynamic CLUT: When detecting bounds, be more conservative. Followup to #16188 . Further fixes the lens flare. It confused me before that there are two sections of the track on Sunset Drive where the sun is visible, but only on the second is the lens flare sprite actually shown, which is rather weird. Verified that exactly the same thing happens on hardware, so it's not a an emulation problem! Rather seems like a glitch in the game itself. --- GPU/Common/TextureCacheCommon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index f96d922a85..00fcf6afd7 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2245,8 +2245,8 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { // These are already in pixel coords! Doesn't seem like we should multiply by texwidth/height. u1 = bounds.minU + gstate_c.curTextureXOffset; v1 = bounds.minV + gstate_c.curTextureYOffset; - u2 = bounds.maxU + gstate_c.curTextureXOffset; - v2 = bounds.maxV + gstate_c.curTextureYOffset; + u2 = bounds.maxU + gstate_c.curTextureXOffset + 1.0f; + v2 = bounds.maxV + gstate_c.curTextureYOffset + 1.0f; // We need to reapply the texture next time since we cropped UV. gstate_c.Dirty(DIRTY_TEXTURE_PARAMS); } From d83f736b1f7cd97e4f26d323fe1879011e361166 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 13:21:04 -0700 Subject: [PATCH 087/374] D3D9: Correct depth readback. --- GPU/Common/FramebufferManagerCommon.cpp | 5 ++--- GPU/Directx9/FramebufferManagerDX9.cpp | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index b353bd8761..583e149ea9 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2662,8 +2662,7 @@ void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, if (vfb && vfb->fbo) { // We'll pseudo-blit framebuffers here to get a resized version of vfb. if (gameUsesSequentialCopies_) { - // Ignore the x/y/etc., read the entire thing. - // TODO: What game did we need this for? + // Ignore the x/y/etc., read the entire thing. See below. x = 0; y = 0; w = vfb->width; @@ -2677,7 +2676,7 @@ void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, vfb->usageFlags |= FB_USAGE_DOWNLOAD; } else { // Let's try to set the flag eventually, if the game copies a lot. - // Some games copy subranges very frequently. + // Some games (like Grand Knights History) copy subranges very frequently. const static int FREQUENT_SEQUENTIAL_COPIES = 3; static int frameLastCopy = 0; static u32 bufferLastCopy = 0; diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index f0281c400e..8fdacbd450 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -134,7 +134,10 @@ } void FramebufferManagerDX9::PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { - if (channel != RASTER_COLOR) { + if (channel == RASTER_DEPTH) { + PackDepthbuffer(vfb, x, y, w, h); + return; + } else if (channel != RASTER_COLOR) { // Unsupported WARN_LOG_ONCE(d3ddepthreadback, G3D, "Not yet supporting depth readbacks on DX9"); return; From 55d5dc3834a84875768dfe4015f7f54519a5e502 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 13:49:41 -0700 Subject: [PATCH 088/374] GPU: Rename readback and buffer write operations. Avoid download/upload and pack, which don't have clear directions. --- Core/HLE/ReplaceTables.cpp | 128 ++++++++++++------------ Core/HLE/sceJpeg.cpp | 2 +- Core/HLE/sceMpeg.cpp | 6 +- Core/HLE/scePsmf.cpp | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 32 +++--- GPU/Common/FramebufferManagerCommon.h | 8 +- GPU/Common/StencilCommon.cpp | 16 +-- GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/Common/TextureCacheCommon.h | 2 +- GPU/Debugger/Playback.cpp | 2 +- GPU/Directx9/FramebufferManagerDX9.cpp | 6 +- GPU/Directx9/FramebufferManagerDX9.h | 4 +- GPU/GLES/DepthBufferGLES.cpp | 10 +- GPU/GLES/FramebufferManagerGLES.h | 2 +- GPU/GPUCommon.cpp | 16 +-- GPU/GPUCommon.h | 8 +- GPU/GPUInterface.h | 15 +-- GPU/Software/SoftGpu.cpp | 8 +- GPU/Software/SoftGpu.h | 8 +- 19 files changed, 140 insertions(+), 137 deletions(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index cc4777af98..5e8c093671 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -166,7 +166,7 @@ static int Replace_memcpy() { // It's pretty common that games will copy video data. if (tag == "ReplaceMemcpy/VideoDecode" || tag == "ReplaceMemcpy/VideoDecodeRange") { if (bytes == 512 * 272 * 4) { - gpu->NotifyVideoUpload(destPtr, bytes, 512, GE_FORMAT_8888); + gpu->PerformWriteFormattedFromMemory(destPtr, bytes, 512, GE_FORMAT_8888); } } } @@ -218,7 +218,7 @@ static int Replace_memcpy_jak() { // It's pretty common that games will copy video data. if (tag == "ReplaceMemcpy/VideoDecode" || tag == "ReplaceMemcpy/VideoDecodeRange") { if (bytes == 512 * 272 * 4) { - gpu->NotifyVideoUpload(destPtr, bytes, 512, GE_FORMAT_8888); + gpu->PerformWriteFormattedFromMemory(destPtr, bytes, 512, GE_FORMAT_8888); } } } @@ -264,7 +264,7 @@ static int Replace_memcpy_swizzled() { u32 h = PARAM(4); if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0) { if (Memory::IsVRAMAddress(srcPtr)) { - gpu->PerformMemoryDownload(srcPtr, pitch * h); + gpu->PerformReadbackToMemory(srcPtr, pitch * h); } } u8 *dstp = Memory::GetPointerWrite(destPtr); @@ -685,7 +685,7 @@ static int Hook_godseaterburst_blit_texture() { const u32 fb_info = Memory::Read_U32(fb_infoaddr); const u32 fb_address = Memory::Read_U32(fb_info); if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "godseaterburst_blit_texture"); } return 0; @@ -714,7 +714,7 @@ static int Hook_godseaterburst_depthmask_5551() { NotifyMemInfo(MemBlockFlags::WRITE, depthMirror, size, "godseaterburst_depthmask_5551"); } - gpu->PerformMemoryDownload(colorBuffer, size); + gpu->PerformReadbackToMemory(colorBuffer, size); NotifyMemInfo(MemBlockFlags::WRITE, colorBuffer, size, "godseaterburst_depthmask_5551"); return 0; @@ -728,7 +728,7 @@ static int Hook_hexyzforce_monoclome_thread() { const u32 fb_address = Memory::Read_U32(fb_info); if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "hexyzforce_monoclome_thread"); } return 0; @@ -737,7 +737,7 @@ static int Hook_hexyzforce_monoclome_thread() { static int Hook_starocean_write_stencil() { const u32 fb_address = currentMIPS->r[MIPS_REG_T7]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformStencilUpload(fb_address, 0x00088000, StencilUpload::IGNORE_ALPHA); + gpu->PerformWriteStencilFromMemory(fb_address, 0x00088000, WriteStencil::IGNORE_ALPHA); } return 0; } @@ -745,7 +745,7 @@ static int Hook_starocean_write_stencil() { static int Hook_topx_create_saveicon() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "topx_create_saveicon"); } return 0; @@ -754,7 +754,7 @@ static int Hook_topx_create_saveicon() { static int Hook_ff1_battle_effect() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "ff1_battle_effect"); } return 0; @@ -764,7 +764,7 @@ static int Hook_dissidia_recordframe_avi() { // This is called once per frame, and records that frame's data to avi. const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "dissidia_recordframe_avi"); } return 0; @@ -785,7 +785,7 @@ static int Hook_brandish_download_frame() { const u32 fb_address = 0x4000000 + (0x44000 * fb_index); const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsRAMAddress(dest_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "brandish_download_frame"); } return 0; @@ -796,7 +796,7 @@ static int Hook_growlanser_create_saveicon() { const u32 fmt = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP]); const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { - gpu->PerformMemoryDownload(fb_address, sz); + gpu->PerformReadbackToMemory(fb_address, sz); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "growlanser_create_saveicon"); } return 0; @@ -807,7 +807,7 @@ static int Hook_sd_gundam_g_generation_download_frame() { const u32 fmt = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP] + 4); const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { - gpu->PerformMemoryDownload(fb_address, sz); + gpu->PerformReadbackToMemory(fb_address, sz); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "sd_gundam_g_generation_download_frame"); } return 0; @@ -816,7 +816,7 @@ static int Hook_sd_gundam_g_generation_download_frame() { static int Hook_narisokonai_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "narisokonai_download_frame"); } return 0; @@ -825,7 +825,7 @@ static int Hook_narisokonai_download_frame() { static int Hook_kirameki_school_life_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A2]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kirameki_school_life_download_frame"); } return 0; @@ -834,7 +834,7 @@ static int Hook_kirameki_school_life_download_frame() { static int Hook_orenoimouto_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A4]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "orenoimouto_download_frame"); } return 0; @@ -843,7 +843,7 @@ static int Hook_orenoimouto_download_frame() { static int Hook_sakurasou_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "sakurasou_download_frame"); } return 0; @@ -852,7 +852,7 @@ static int Hook_sakurasou_download_frame() { static int Hook_suikoden1_and_2_download_frame_1() { const u32 fb_address = currentMIPS->r[MIPS_REG_S4]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "suikoden1_and_2_download_frame_1"); } return 0; @@ -861,7 +861,7 @@ static int Hook_suikoden1_and_2_download_frame_1() { static int Hook_suikoden1_and_2_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "suikoden1_and_2_download_frame_2"); } return 0; @@ -872,7 +872,7 @@ static int Hook_rezel_cross_download_frame() { const u32 fmt = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP] + 0x14); const u32 sz = fmt == GE_FORMAT_8888 ? 0x00088000 : 0x00044000; if (Memory::IsVRAMAddress(fb_address) && fmt <= 3) { - gpu->PerformMemoryDownload(fb_address, sz); + gpu->PerformReadbackToMemory(fb_address, sz); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, sz, "rezel_cross_download_frame"); } return 0; @@ -881,7 +881,7 @@ static int Hook_rezel_cross_download_frame() { static int Hook_kagaku_no_ensemble_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kagaku_no_ensemble_download_frame"); } return 0; @@ -890,7 +890,7 @@ static int Hook_kagaku_no_ensemble_download_frame() { static int Hook_soranokiseki_fc_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A2]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "soranokiseki_fc_download_frame"); } return 0; @@ -911,7 +911,7 @@ static int Hook_soranokiseki_sc_download_frame() { const u32 fb_address = 0x4000000 + (0x44000 * fb_index); const u32 dest_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsRAMAddress(dest_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "soranokiseki_sc_download_frame"); } return 0; @@ -920,7 +920,7 @@ static int Hook_soranokiseki_sc_download_frame() { static int Hook_bokunonatsuyasumi4_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "bokunonatsuyasumi4_download_frame"); } return 0; @@ -932,7 +932,7 @@ static int Hook_danganronpa2_1_download_frame() { const u32 fb_offset_fix = fb_offset & 0xFFFFFFFC; const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa2_1_download_frame"); } return 0; @@ -944,7 +944,7 @@ static int Hook_danganronpa2_2_download_frame() { const u32 fb_offset_fix = fb_offset & 0xFFFFFFFC; const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa2_2_download_frame"); } return 0; @@ -956,7 +956,7 @@ static int Hook_danganronpa1_1_download_frame() { const u32 fb_offset_fix = fb_offset & 0xFFFFFFFC; const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa1_1_download_frame"); } return 0; @@ -970,7 +970,7 @@ static int Hook_danganronpa1_2_download_frame() { const u32 fb_offset_fix = fb_offset & 0xFFFFFFFC; const u32 fb_address = fb_base + fb_offset_fix; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "danganronpa1_2_download_frame"); } return 0; @@ -979,7 +979,7 @@ static int Hook_danganronpa1_2_download_frame() { static int Hook_kankabanchoutbr_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "kankabanchoutbr_download_frame"); } return 0; @@ -988,7 +988,7 @@ static int Hook_kankabanchoutbr_download_frame() { static int Hook_orenoimouto_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_A4]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "orenoimouto_download_frame_2"); } return 0; @@ -997,7 +997,7 @@ static int Hook_orenoimouto_download_frame_2() { static int Hook_rewrite_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "rewrite_download_frame"); } return 0; @@ -1006,7 +1006,7 @@ static int Hook_rewrite_download_frame() { static int Hook_kudwafter_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kudwafter_download_frame"); } return 0; @@ -1015,7 +1015,7 @@ static int Hook_kudwafter_download_frame() { static int Hook_kumonohatateni_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kumonohatateni_download_frame"); } return 0; @@ -1024,7 +1024,7 @@ static int Hook_kumonohatateni_download_frame() { static int Hook_otomenoheihou_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "otomenoheihou_download_frame"); } return 0; @@ -1033,7 +1033,7 @@ static int Hook_otomenoheihou_download_frame() { static int Hook_grisaianokajitsu_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "grisaianokajitsu_download_frame"); } return 0; @@ -1042,7 +1042,7 @@ static int Hook_grisaianokajitsu_download_frame() { static int Hook_kokoroconnect_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "kokoroconnect_download_frame"); } return 0; @@ -1051,7 +1051,7 @@ static int Hook_kokoroconnect_download_frame() { static int Hook_toheart2_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "toheart2_download_frame"); } return 0; @@ -1060,7 +1060,7 @@ static int Hook_toheart2_download_frame() { static int Hook_toheart2_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "toheart2_download_frame_2"); } return 0; @@ -1069,7 +1069,7 @@ static int Hook_toheart2_download_frame_2() { static int Hook_flowers_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "flowers_download_frame"); } return 0; @@ -1078,7 +1078,7 @@ static int Hook_flowers_download_frame() { static int Hook_motorstorm_download_frame() { const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_A1] + 0x18); if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "motorstorm_download_frame"); } return 0; @@ -1087,7 +1087,7 @@ static int Hook_motorstorm_download_frame() { static int Hook_utawarerumono_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "utawarerumono_download_frame"); } return 0; @@ -1096,7 +1096,7 @@ static int Hook_utawarerumono_download_frame() { static int Hook_photokano_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "photokano_download_frame"); } return 0; @@ -1105,7 +1105,7 @@ static int Hook_photokano_download_frame() { static int Hook_photokano_download_frame_2() { const u32 fb_address = currentMIPS->r[MIPS_REG_A1]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "photokano_download_frame_2"); } return 0; @@ -1114,7 +1114,7 @@ static int Hook_photokano_download_frame_2() { static int Hook_gakuenheaven_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "gakuenheaven_download_frame"); } return 0; @@ -1123,7 +1123,7 @@ static int Hook_gakuenheaven_download_frame() { static int Hook_youkosohitsujimura_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_V0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "youkosohitsujimura_download_frame"); } return 0; @@ -1146,7 +1146,7 @@ static int Hook_zettai_hero_update_minimap_tex() { static int Hook_tonyhawkp8_upload_tutorial_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryUpload(fb_address, 0x00088000); + gpu->PerformWriteColorFromMemory(fb_address, 0x00088000); } return 0; } @@ -1154,7 +1154,7 @@ static int Hook_tonyhawkp8_upload_tutorial_frame() { static int Hook_sdgundamggenerationportable_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "sdgundamggenerationportable_download_frame"); } return 0; @@ -1164,7 +1164,7 @@ static int Hook_atvoffroadfurypro_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_S2]; const u32 fb_size = (currentMIPS->r[MIPS_REG_S4] >> 3) * currentMIPS->r[MIPS_REG_S3]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, fb_size); + gpu->PerformReadbackToMemory(fb_address, fb_size); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "atvoffroadfurypro_download_frame"); } return 0; @@ -1174,7 +1174,7 @@ static int Hook_atvoffroadfuryblazintrails_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_S5]; const u32 fb_size = (currentMIPS->r[MIPS_REG_S3] >> 3) * currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, fb_size); + gpu->PerformReadbackToMemory(fb_address, fb_size); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "atvoffroadfuryblazintrails_download_frame"); } return 0; @@ -1183,7 +1183,7 @@ static int Hook_atvoffroadfuryblazintrails_download_frame() { static int Hook_littlebustersce_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "littlebustersce_download_frame"); } return 0; @@ -1192,7 +1192,7 @@ static int Hook_littlebustersce_download_frame() { static int Hook_shinigamitoshoujo_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "shinigamitoshoujo_download_frame"); } return 0; @@ -1202,7 +1202,7 @@ static int Hook_atvoffroadfuryprodemo_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_S5]; const u32 fb_size = ((currentMIPS->r[MIPS_REG_A0] + currentMIPS->r[MIPS_REG_A1]) >> 3) * currentMIPS->r[MIPS_REG_S2]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, fb_size); + gpu->PerformReadbackToMemory(fb_address, fb_size); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "atvoffroadfuryprodemo_download_frame"); } return 0; @@ -1211,7 +1211,7 @@ static int Hook_atvoffroadfuryprodemo_download_frame() { static int Hook_unendingbloodycall_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_T3]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00088000); + gpu->PerformReadbackToMemory(fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00088000, "unendingbloodycall_download_frame"); } return 0; @@ -1220,7 +1220,7 @@ static int Hook_unendingbloodycall_download_frame() { static int Hook_omertachinmokunookitethelegacy_download_frame() { const u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_SP] + 4); if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryDownload(fb_address, 0x00044000); + gpu->PerformReadbackToMemory(fb_address, 0x00044000); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, 0x00044000, "omertachinmokunookitethelegacy_download_frame"); } return 0; @@ -1240,7 +1240,7 @@ static int Hook_katamari_render_check() { const u32 heightBlockCount = Memory::Read_U8(fbInfoPtr + 0x08) + 1; const u32 totalBytes = width * heightBlocks * heightBlockCount; - gpu->PerformMemoryDownload(fb_address, totalBytes); + gpu->PerformReadbackToMemory(fb_address, totalBytes); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, totalBytes, "katamari_render_check"); } return 0; @@ -1249,7 +1249,7 @@ static int Hook_katamari_render_check() { static int Hook_katamari_screenshot_to_565() { u32 fb_address; if (GetMIPSStaticAddress(fb_address, 0x0040, 0x0044)) { - gpu->PerformMemoryDownload(0x04000000 | fb_address, 0x00088000); + gpu->PerformReadbackToMemory(0x04000000 | fb_address, 0x00088000); NotifyMemInfo(MemBlockFlags::WRITE, 0x04000000 | fb_address, 0x00088000, "katamari_screenshot_to_565"); } return 0; @@ -1258,7 +1258,7 @@ static int Hook_katamari_screenshot_to_565() { static int Hook_mytranwars_upload_frame() { u32 fb_address = currentMIPS->r[MIPS_REG_S0]; if (Memory::IsVRAMAddress(fb_address)) { - gpu->PerformMemoryUpload(fb_address, 0x00088000); + gpu->PerformWriteColorFromMemory(fb_address, 0x00088000); } return 0; } @@ -1272,7 +1272,7 @@ static int Hook_marvelalliance1_copy_a1_before() { marvelalliance1_copy_dst = currentMIPS->r[MIPS_REG_V1]; marvelalliance1_copy_size = currentMIPS->r[MIPS_REG_V0] - currentMIPS->r[MIPS_REG_V1]; - gpu->PerformMemoryDownload(marvelalliance1_copy_src, marvelalliance1_copy_size); + gpu->PerformReadbackToMemory(marvelalliance1_copy_src, marvelalliance1_copy_size); NotifyMemInfo(MemBlockFlags::WRITE, marvelalliance1_copy_src, marvelalliance1_copy_size, "marvelalliance1_copy_a1_before"); return 0; @@ -1283,14 +1283,14 @@ static int Hook_marvelalliance1_copy_a2_before() { marvelalliance1_copy_dst = currentMIPS->r[MIPS_REG_V0]; marvelalliance1_copy_size = currentMIPS->r[MIPS_REG_A1] - currentMIPS->r[MIPS_REG_A2]; - gpu->PerformMemoryDownload(marvelalliance1_copy_src, marvelalliance1_copy_size); + gpu->PerformReadbackToMemory(marvelalliance1_copy_src, marvelalliance1_copy_size); NotifyMemInfo(MemBlockFlags::WRITE, marvelalliance1_copy_src, marvelalliance1_copy_size, "marvelalliance1_copy_a2_before"); return 0; } static int Hook_marvelalliance1_copy_after() { - gpu->PerformMemoryUpload(marvelalliance1_copy_dst, marvelalliance1_copy_size); + gpu->PerformWriteColorFromMemory(marvelalliance1_copy_dst, marvelalliance1_copy_size); NotifyMemInfo(MemBlockFlags::READ, marvelalliance1_copy_dst, marvelalliance1_copy_size, "marvelalliance1_copy_after"); return 0; @@ -1314,7 +1314,7 @@ static int Hook_starocean_clear_framebuf_after() { DEBUG_LOG(HLE, "starocean_clear_framebuf() - %08x y=%d-%d", framebuf, y, h); // TODO: This is always clearing to 0, actually, which could be faster than an upload. - gpu->PerformMemoryUpload(framebuf + 512 * y * 4, 512 * h * 4); + gpu->PerformWriteColorFromMemory(framebuf + 512 * y * 4, 512 * h * 4); } return 0; } @@ -1323,7 +1323,7 @@ static int Hook_motorstorm_pixel_read() { u32 fb_address = Memory::Read_U32(currentMIPS->r[MIPS_REG_A0] + 0x18); u32 fb_height = Memory::Read_U16(currentMIPS->r[MIPS_REG_A0] + 0x26); u32 fb_stride = Memory::Read_U16(currentMIPS->r[MIPS_REG_A0] + 0x28); - gpu->PerformMemoryDownload(fb_address, fb_height * fb_stride); + gpu->PerformReadbackToMemory(fb_address, fb_height * fb_stride); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_height * fb_stride, "motorstorm_pixel_read"); return 0; } @@ -1333,7 +1333,7 @@ static int Hook_worms_copy_normalize_alpha() { u32 fb_address = currentMIPS->r[MIPS_REG_S1]; u32 fb_size = currentMIPS->r[MIPS_REG_A2]; if (Memory::IsVRAMAddress(fb_address) && Memory::IsValidRange(fb_address, fb_size)) { - gpu->PerformMemoryDownload(fb_address, fb_size); + gpu->PerformReadbackToMemory(fb_address, fb_size); NotifyMemInfo(MemBlockFlags::WRITE, fb_address, fb_size, "worms_copy_normalize_alpha"); } return 0; @@ -1350,7 +1350,7 @@ static int Hook_openseason_data_decode() { firstWritePtr = startPtr; } if (Memory::IsVRAMAddress(endPtr) && curWritePtr == endPtr) { - gpu->PerformMemoryUpload(firstWritePtr, endPtr - firstWritePtr); + gpu->PerformWriteColorFromMemory(firstWritePtr, endPtr - firstWritePtr); firstWritePtr = 0; } return 0; diff --git a/Core/HLE/sceJpeg.cpp b/Core/HLE/sceJpeg.cpp index bc99171c7c..8b2e4272de 100644 --- a/Core/HLE/sceJpeg.cpp +++ b/Core/HLE/sceJpeg.cpp @@ -250,7 +250,7 @@ static int sceJpegMJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bu int width = (widthHeight >> 16) & 0xFFF; int height = widthHeight & 0xFFF; if (result >= 0) - gpu->NotifyVideoUpload(imageAddr, width * height * 4, width, GE_FORMAT_8888); + gpu->PerformWriteFormattedFromMemory(imageAddr, width * height * 4, width, GE_FORMAT_8888); if (usec != 0) return hleDelayResult(result, "jpeg csc", usec); diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 929e782d0c..3192e443b1 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1171,7 +1171,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr // playing all pmp_queue frames ctx->mediaengine->m_pFrameRGB = pmp_queue.front(); int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode); - gpu->NotifyVideoUpload(buffer, bufferSize, frameWidth, ctx->videoPixelMode); + gpu->PerformWriteFormattedFromMemory(buffer, bufferSize, frameWidth, (GEBufferFormat)ctx->videoPixelMode); ctx->avc.avcFrameStatus = 1; ctx->videoFrameCount++; @@ -1183,7 +1183,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr } else if(ctx->mediaengine->stepVideo(ctx->videoPixelMode)) { int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode); - gpu->NotifyVideoUpload(buffer, bufferSize, frameWidth, ctx->videoPixelMode); + gpu->PerformWriteFormattedFromMemory(buffer, bufferSize, frameWidth, (GEBufferFormat)ctx->videoPixelMode); ctx->avc.avcFrameStatus = 1; ctx->videoFrameCount++; } else { @@ -2050,7 +2050,7 @@ static u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth } int destSize = ctx->mediaengine->writeVideoImageWithRange(destAddr, frameWidth, ctx->videoPixelMode, x, y, width, height); - gpu->NotifyVideoUpload(destAddr, destSize, frameWidth, ctx->videoPixelMode); + gpu->PerformWriteFormattedFromMemory(destAddr, destSize, frameWidth, (GEBufferFormat)ctx->videoPixelMode); // Do not use avcDecodeDelayMs 's value // Will cause video 's screen dislocation in Bleach heat of soul 6 diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 06fc172c53..eebac79bfa 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -1633,7 +1633,7 @@ static int scePsmfPlayerGetVideoData(u32 psmfPlayer, u32 videoDataAddr) int bufw = videoData->frameWidth == 0 ? 512 : videoData->frameWidth & ~1; // Always write the video frame, even after the video has ended. int displaybufSize = psmfplayer->mediaengine->writeVideoImage(videoData->displaybuf, bufw, videoPixelMode); - gpu->NotifyVideoUpload(videoData->displaybuf, displaybufSize, bufw, videoPixelMode); + gpu->PerformWriteFormattedFromMemory(videoData->displaybuf, displaybufSize, bufw, (GEBufferFormat)videoPixelMode); __PsmfUpdatePts(psmfplayer, videoData); _PsmfPlayerFillRingbuffer(psmfplayer); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 583e149ea9..4266701083 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -514,9 +514,9 @@ VirtualFramebuffer *FramebufferManagerCommon::DoSetRenderFrameBuffer(Framebuffer // Assume that if we're clearing right when switching to a new framebuffer, we don't need to upload. if (useBufferedRendering_ && params.isDrawing) { - gpu->PerformMemoryUpload(params.fb_address, colorByteSize); - // Alpha was already done by PerformMemoryUpload. - PerformStencilUpload(params.fb_address, colorByteSize, StencilUpload::STENCIL_IS_ZERO | StencilUpload::IGNORE_ALPHA); + gpu->PerformWriteColorFromMemory(params.fb_address, colorByteSize); + // Alpha was already done by PerformWriteColorFromMemory. + PerformWriteStencilFromMemory(params.fb_address, colorByteSize, WriteStencil::STENCIL_IS_ZERO | WriteStencil::IGNORE_ALPHA); // TODO: Is it worth trying to upload the depth buffer (only if it wasn't copied above..?) } @@ -1029,7 +1029,7 @@ void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffe NotifyRenderFramebufferUpdated(vfb); } -void FramebufferManagerCommon::NotifyVideoUpload(u32 addr, int size, int stride, GEBufferFormat fmt) { +void FramebufferManagerCommon::PerformWriteFormattedFromMemory(u32 addr, int size, int stride, GEBufferFormat fmt) { // Note: UpdateFromMemory() is still called later. // This is a special case where we have extra information prior to the invalidation. @@ -2598,9 +2598,9 @@ bool FramebufferManagerCommon::GetOutputFramebuffer(GPUDebugBuffer &buffer) { // (Except using the GPU might cause problems because of various implementations' // dithering behavior and games that expect exact colors like Danganronpa, so we // can't entirely be rid of the CPU path.) -- unknown -void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { +void FramebufferManagerCommon::ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { if (w <= 0 || h <= 0) { - ERROR_LOG(G3D, "Bad inputs to PackFramebufferSync: %d %d %d %d", x, y, w, h); + ERROR_LOG(G3D, "Bad inputs to ReadbackFramebufferSync: %d %d %d %d", x, y, w, h); return; } @@ -2617,7 +2617,7 @@ void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int const int dstSize = ((h - 1) * stride + w) * dstBpp; if (!Memory::IsValidRange(fb_address + dstByteOffset, dstSize)) { - ERROR_LOG_REPORT(G3D, "PackFramebufferSync would write outside of memory, ignoring"); + ERROR_LOG_REPORT(G3D, "ReadbackFramebufferSync would write outside of memory, ignoring"); return; } @@ -2629,28 +2629,28 @@ void FramebufferManagerCommon::PackFramebufferSync(VirtualFramebuffer *vfb, int if (destPtr) { if (channel == RASTER_DEPTH) - PackDepthbuffer(vfb, x, y, w, h); + ReadbackDepthbufferSync(vfb, x, y, w, h); else - draw_->CopyFramebufferToMemorySync(vfb->fbo, channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackFramebufferSync"); + draw_->CopyFramebufferToMemorySync(vfb->fbo, channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "ReadbackFramebufferSync"); char tag[128]; size_t len = snprintf(tag, sizeof(tag), "FramebufferPack/%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString(vfb->fb_format)); NotifyMemInfo(MemBlockFlags::WRITE, fb_address + dstByteOffset, dstSize, tag, len); } else { - ERROR_LOG(G3D, "PackFramebufferSync: Tried to readback to bad address %08x (stride = %d)", fb_address + dstByteOffset, vfb->fb_stride); + ERROR_LOG(G3D, "ReadbackFramebufferSync: Tried to readback to bad address %08x (stride = %d)", fb_address + dstByteOffset, vfb->fb_stride); } gpuStats.numReadbacks++; } -void FramebufferManagerCommon::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) { +void FramebufferManagerCommon::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { _assert_msg_(vfb && vfb->z_address != 0 && vfb->z_stride != 0, "Depth buffer invalid"); Draw::DataFormat destFormat = GEFormatToThin3D(GE_FORMAT_DEPTH16); const int dstByteOffset = (y * vfb->z_stride + x) * 2; u8 *destPtr = Memory::GetPointerWriteUnchecked(vfb->z_address + dstByteOffset); - if (!draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "PackDepthbuffer")) { - WARN_LOG(G3D, "PackDepthbuffer failed"); + if (!draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "ReadbackDepthbufferSync")) { + WARN_LOG(G3D, "ReadbackDepthbufferSync failed"); } } @@ -2693,12 +2693,12 @@ void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, if (vfb->renderWidth == vfb->width && vfb->renderHeight == vfb->height) { // No need to stretch-blit - PackFramebufferSync(vfb, x, y, w, h, channel); + ReadbackFramebufferSync(vfb, x, y, w, h, channel); } else { VirtualFramebuffer *nvfb = FindDownloadTempBuffer(vfb, channel); if (nvfb) { BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0, channel, "Blit_ReadFramebufferToMemory"); - PackFramebufferSync(nvfb, x, y, w, h, channel); + ReadbackFramebufferSync(nvfb, x, y, w, h, channel); } } @@ -2755,7 +2755,7 @@ void FramebufferManagerCommon::DownloadFramebufferForClut(u32 fb_address, u32 lo VirtualFramebuffer *nvfb = FindDownloadTempBuffer(vfb, RASTER_COLOR); if (nvfb) { BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0, RASTER_COLOR, "Blit_DownloadFramebufferForClut"); - PackFramebufferSync(nvfb, x, y, w, h, RASTER_COLOR); + ReadbackFramebufferSync(nvfb, x, y, w, h, RASTER_COLOR); } textureCache_->ForgetLastTexture(); diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index e727c1a25a..d44a0ecb18 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -307,10 +307,10 @@ public: void CopyDisplayToOutput(bool reallyDirty); bool NotifyFramebufferCopy(u32 src, u32 dest, int size, GPUCopyFlag flags, u32 skipDrawReason); - void NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt); + void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat fmt); void UpdateFromMemory(u32 addr, int size); void ApplyClearToMemory(int x1, int y1, int x2, int y2, u32 clearColor); - bool PerformStencilUpload(u32 addr, int size, StencilUpload flags); + bool PerformWriteStencilFromMemory(u32 addr, int size, WriteStencil flags); // Returns true if it's sure this is a direct FBO->FBO transfer and it has already handle it. // In that case we hardly need to actually copy the bytes in VRAM, they will be wrong anyway (unless @@ -441,9 +441,9 @@ public: Draw2DPipeline *pipeline, const char *tag); protected: - virtual void PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel); + virtual void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel); // Used for when a shader is required, such as GLES. - virtual void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h); + virtual void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h); void SetViewport2D(int x, int y, int w, int h); Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height); void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags); diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index d30327df93..2c32a2a06c 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -127,7 +127,7 @@ void GenerateStencilVs(char *buffer, const ShaderLanguageDesc &lang) { writer.EndVSMain(varyings); } -bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilUpload flags) { +bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, WriteStencil flags) { using namespace Draw; addr &= 0x3FFFFFFF; @@ -178,16 +178,16 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU } if (usedBits == 0) { - if (flags & StencilUpload::STENCIL_IS_ZERO) { + if (flags & WriteStencil::STENCIL_IS_ZERO) { // Common when creating buffers, it's already 0. // We're done. return false; } // Otherwise, we can skip alpha in many cases, in which case we don't even use a shader. - if (flags & StencilUpload::IGNORE_ALPHA) { + if (flags & WriteStencil::IGNORE_ALPHA) { if (dstBuffer->fbo) { - draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "PerformStencilUpload_Clear"); + draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Clear"); } return true; } @@ -271,7 +271,7 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU useBlit = false; } // The blit path doesn't set alpha, so we can't use it if that's needed. - if (!(flags & StencilUpload::IGNORE_ALPHA)) { + if (!(flags & WriteStencil::IGNORE_ALPHA)) { useBlit = false; } @@ -281,9 +281,9 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU Draw::Framebuffer *blitFBO = nullptr; if (useBlit) { blitFBO = GetTempFBO(TempFBO::STENCIL, w, h); - draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::CLEAR }, "PerformStencilUpload_Blit"); + draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Blit"); } else if (dstBuffer->fbo) { - draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "PerformStencilUpload_NoBlit"); + draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_NoBlit"); } Draw::Viewport viewport = { 0.0f, 0.0f, (float)w, (float)h, 0.0f, 1.0f }; @@ -326,7 +326,7 @@ bool FramebufferManagerCommon::PerformStencilUpload(u32 addr, int size, StencilU if (useBlit) { // Note that scissors don't affect blits on other APIs than OpenGL, so might want to try to get rid of this. draw_->SetScissorRect(0, 0, dstBuffer->renderWidth, dstBuffer->renderHeight); - draw_->BlitFramebuffer(blitFBO, 0, 0, w, h, dstBuffer->fbo, 0, 0, dstBuffer->renderWidth, dstBuffer->renderHeight, Draw::FB_STENCIL_BIT, Draw::FB_BLIT_NEAREST, "PerformStencilUpload_Blit"); + draw_->BlitFramebuffer(blitFBO, 0, 0, w, h, dstBuffer->fbo, 0, 0, dstBuffer->renderWidth, dstBuffer->renderHeight, Draw::FB_STENCIL_BIT, Draw::FB_BLIT_NEAREST, "WriteStencilFromMemory_Blit"); RebindFramebuffer("RebindFramebuffer - Stencil"); } tex->Release(); diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 00fcf6afd7..f6889e5cb0 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1183,7 +1183,7 @@ void TextureCacheCommon::NotifyConfigChanged() { replacer_.NotifyConfigChanged(); } -void TextureCacheCommon::NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt) { +void TextureCacheCommon::NotifyWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat fmt) { addr &= 0x3FFFFFFF; videos_.push_back({ addr, (u32)size, gpuStats.numFlips }); } diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 9922e9070a..48c44d981f 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -336,7 +336,7 @@ public: // FramebufferManager keeps TextureCache updated about what regions of memory are being rendered to, // so that it can invalidate TexCacheEntries pointed at those addresses. void NotifyFramebuffer(VirtualFramebuffer *framebuffer, FramebufferNotification msg); - void NotifyVideoUpload(u32 addr, int size, int width, GEBufferFormat fmt); + void NotifyWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat fmt); size_t NumLoadedTextures() const { return cache_.size(); diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index 0410a61c76..eb3f9fa2bc 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -556,7 +556,7 @@ void DumpExecute::Memcpy(u32 ptr, u32 sz) { SyncStall(); Memory::MemcpyUnchecked(execMemcpyDest, pushbuf_.data() + ptr, sz); NotifyMemInfo(MemBlockFlags::WRITE, execMemcpyDest, sz, "ReplayMemcpy"); - gpu->PerformMemoryUpload(execMemcpyDest, sz); + gpu->PerformWriteColorFromMemory(execMemcpyDest, sz); } } diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index 8fdacbd450..ef3af4c41c 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -133,9 +133,9 @@ } } - void FramebufferManagerDX9::PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { + void FramebufferManagerDX9::ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { if (channel == RASTER_DEPTH) { - PackDepthbuffer(vfb, x, y, w, h); + ReadbackDepthbufferSync(vfb, x, y, w, h); return; } else if (channel != RASTER_COLOR) { // Unsupported @@ -178,7 +178,7 @@ } } - void FramebufferManagerDX9::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) { + void FramebufferManagerDX9::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { // We always read the depth buffer in 24_8 format. const u32 z_address = vfb->z_address; diff --git a/GPU/Directx9/FramebufferManagerDX9.h b/GPU/Directx9/FramebufferManagerDX9.h index 1d7e522b48..ea69262917 100644 --- a/GPU/Directx9/FramebufferManagerDX9.h +++ b/GPU/Directx9/FramebufferManagerDX9.h @@ -49,10 +49,10 @@ public: protected: void DecimateFBOs() override; - void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; + void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; + void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) override; private: - void PackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) override; bool GetRenderTargetFramebuffer(LPDIRECT3DSURFACE9 renderTarget, LPDIRECT3DSURFACE9 offscreen, int w, int h, GPUDebugBuffer &buffer); LPDIRECT3DDEVICE9 device_; diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 342ebdad60..f76d133564 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -75,9 +75,9 @@ void main() { } )"; -void FramebufferManagerGLES::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) { +void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { if (!vfb->fbo) { - ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "PackDepthbuffer: vfb->fbo == 0"); + ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackDepthbufferSync: vfb->fbo == 0"); return; } @@ -130,7 +130,7 @@ void FramebufferManagerGLES::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int shaderManager_->DirtyLastShader(); auto *blitFBO = GetTempFBO(TempFBO::COPY, vfb->renderWidth, vfb->renderHeight); - draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "PackDepthbuffer"); + draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); render->SetViewport({ 0, 0, (float)vfb->renderWidth, (float)vfb->renderHeight, 0.0f, 1.0f }); // We must bind the program after starting the render pass, and set the color mask after clearing. @@ -157,13 +157,13 @@ void FramebufferManagerGLES::PackDepthbuffer(VirtualFramebuffer *vfb, int x, int float v1 = 1.0f; DrawActiveTexture(x, y, w, h, vfb->renderWidth, vfb->renderHeight, 0.0f, 0.0f, u1, v1, ROTATION_LOCKED_HORIZONTAL, DRAWTEX_NEAREST); - draw_->CopyFramebufferToMemorySync(blitFBO, Draw::FB_COLOR_BIT, 0, y, packWidth, h, Draw::DataFormat::R8G8B8A8_UNORM, convBuf_, vfb->z_stride, "PackDepthbuffer"); + draw_->CopyFramebufferToMemorySync(blitFBO, Draw::FB_COLOR_BIT, 0, y, packWidth, h, Draw::DataFormat::R8G8B8A8_UNORM, convBuf_, vfb->z_stride, "ReadbackDepthbufferSync"); textureCache_->ForgetLastTexture(); // TODO: Use 4444 so we can copy lines directly? format16Bit = true; } else { - draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, 0, y, packWidth, h, Draw::DataFormat::D32F, convBuf_, vfb->z_stride, "PackDepthbuffer"); + draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, 0, y, packWidth, h, Draw::DataFormat::D32F, convBuf_, vfb->z_stride, "ReadbackDepthbufferSync"); format16Bit = false; } diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index e75de97308..61c2daef1b 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -38,7 +38,7 @@ public: protected: void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; - void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; + void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; private: u8 *convBuf_ = nullptr; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index c5271b2705..7df0d02861 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3059,7 +3059,7 @@ bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags // Track stray copies of a framebuffer in RAM. MotoGP does this. if (framebufferManager_->MayIntersectFramebuffer(src) || framebufferManager_->MayIntersectFramebuffer(dest)) { if (!framebufferManager_->NotifyFramebufferCopy(src, dest, size, flags, gstate_c.skipDrawReason)) { - // We use a little hack for PerformMemoryDownload/PerformMemoryUpload using a VRAM mirror. + // We use a little hack for PerformReadbackToMemory/PerformWriteColorFromMemory using a VRAM mirror. // Since they're identical we don't need to copy. if (!Memory::IsVRAMAddress(dest) || (dest ^ 0x00400000) != src) { if (MemBlockInfoDetailed(size)) { @@ -3102,14 +3102,14 @@ bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) { return false; } -bool GPUCommon::PerformMemoryDownload(u32 dest, int size) { +bool GPUCommon::PerformReadbackToMemory(u32 dest, int size) { if (Memory::IsVRAMAddress(dest)) { return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_DST_MEM); } return false; } -bool GPUCommon::PerformMemoryUpload(u32 dest, int size) { +bool GPUCommon::PerformWriteColorFromMemory(u32 dest, int size) { if (Memory::IsVRAMAddress(dest)) { GPURecord::NotifyUpload(dest, size); return PerformMemoryCopy(dest, dest, size, GPUCopyFlag::FORCE_SRC_MEM | GPUCopyFlag::DEBUG_NOTIFIED); @@ -3132,17 +3132,17 @@ void GPUCommon::InvalidateCache(u32 addr, int size, GPUInvalidationType type) { } } -void GPUCommon::NotifyVideoUpload(u32 addr, int size, int frameWidth, int format) { +void GPUCommon::PerformWriteFormattedFromMemory(u32 addr, int size, int frameWidth, GEBufferFormat format) { if (Memory::IsVRAMAddress(addr)) { - framebufferManager_->NotifyVideoUpload(addr, size, frameWidth, (GEBufferFormat)format); + framebufferManager_->PerformWriteFormattedFromMemory(addr, size, frameWidth, format); } - textureCache_->NotifyVideoUpload(addr, size, frameWidth, (GEBufferFormat)format); + textureCache_->NotifyWriteFormattedFromMemory(addr, size, frameWidth, format); InvalidateCache(addr, size, GPU_INVALIDATE_SAFE); } -bool GPUCommon::PerformStencilUpload(u32 dest, int size, StencilUpload flags) { +bool GPUCommon::PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) { if (framebufferManager_->MayIntersectFramebuffer(dest)) { - framebufferManager_->PerformStencilUpload(dest, size, flags); + framebufferManager_->PerformWriteStencilFromMemory(dest, size, flags); return true; } return false; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 3c478e2cec..92f7d943d8 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -126,12 +126,12 @@ public: void InitClear() override = 0; bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; - bool PerformMemoryDownload(u32 dest, int size) override; - bool PerformMemoryUpload(u32 dest, int size) override; + bool PerformReadbackToMemory(u32 dest, int size) override; + bool PerformWriteColorFromMemory(u32 dest, int size) override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; - void NotifyVideoUpload(u32 addr, int size, int width, int format) override; - bool PerformStencilUpload(u32 dest, int size, StencilUpload flags) override; + void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) override; + bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) override; void Execute_OffsetAddr(u32 op, u32 diff); void Execute_Vaddr(u32 op, u32 diff); diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 3a71b550b4..5e523a955a 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -107,12 +107,12 @@ enum GPUSyncType { GPU_SYNC_LIST, }; -enum class StencilUpload { +enum class WriteStencil { NEEDS_CLEAR = 1, STENCIL_IS_ZERO = 2, IGNORE_ALPHA = 4, }; -ENUM_CLASS_BITOPS(StencilUpload); +ENUM_CLASS_BITOPS(WriteStencil); enum class GPUCopyFlag { NONE = 0, @@ -231,13 +231,16 @@ public: // Invalidate any cached content sourced from the specified range. // If size = -1, invalidate everything. virtual void InvalidateCache(u32 addr, int size, GPUInvalidationType type) = 0; - virtual void NotifyVideoUpload(u32 addr, int size, int width, int format) = 0; + // Clear caches, update hardware framebuffers, or similar based on written pixels of known format (typically video.) + virtual void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) = 0; // Update either RAM from VRAM, or VRAM from RAM... or even VRAM from VRAM. virtual bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) = 0; virtual bool PerformMemorySet(u32 dest, u8 v, int size) = 0; - virtual bool PerformMemoryDownload(u32 dest, int size) = 0; - virtual bool PerformMemoryUpload(u32 dest, int size) = 0; - virtual bool PerformStencilUpload(u32 dest, int size, StencilUpload flags = StencilUpload::NEEDS_CLEAR) = 0; + // Update PSP memory with render results. + virtual bool PerformReadbackToMemory(u32 dest, int size) = 0; + // Update rendering data (i.e. hardware framebuffers) with data in PSP memory. Format unspecified. + virtual bool PerformWriteColorFromMemory(u32 dest, int size) = 0; + virtual bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags = WriteStencil::NEEDS_CLEAR) = 0; // Will cause the texture cache to be cleared at the start of the next frame. virtual void ClearCacheNextFrame() = 0; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 28fe4041fb..88977a9008 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1260,7 +1260,7 @@ void SoftGPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) // Nothing to invalidate. } -void SoftGPU::NotifyVideoUpload(u32 addr, int size, int width, int format) +void SoftGPU::PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) { // Ignore. } @@ -1285,14 +1285,14 @@ bool SoftGPU::PerformMemorySet(u32 dest, u8 v, int size) return false; } -bool SoftGPU::PerformMemoryDownload(u32 dest, int size) +bool SoftGPU::PerformReadbackToMemory(u32 dest, int size) { // Nothing to update. InvalidateCache(dest, size, GPU_INVALIDATE_HINT); return false; } -bool SoftGPU::PerformMemoryUpload(u32 dest, int size) +bool SoftGPU::PerformWriteColorFromMemory(u32 dest, int size) { // Nothing to update. InvalidateCache(dest, size, GPU_INVALIDATE_HINT); @@ -1300,7 +1300,7 @@ bool SoftGPU::PerformMemoryUpload(u32 dest, int size) return false; } -bool SoftGPU::PerformStencilUpload(u32 dest, int size, StencilUpload flags) +bool SoftGPU::PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) { return false; } diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 84732eb43a..33e2768dbf 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -138,12 +138,12 @@ public: void CopyDisplayToOutput(bool reallyDirty) override; void GetStats(char *buffer, size_t bufsize) override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; - void NotifyVideoUpload(u32 addr, int size, int width, int format) override; + void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) override; bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; - bool PerformMemoryDownload(u32 dest, int size) override; - bool PerformMemoryUpload(u32 dest, int size) override; - bool PerformStencilUpload(u32 dest, int size, StencilUpload flags) override; + bool PerformReadbackToMemory(u32 dest, int size) override; + bool PerformWriteColorFromMemory(u32 dest, int size) override; + bool PerformWriteStencilFromMemory(u32 dest, int size, WriteStencil flags) override; void ClearCacheNextFrame() override {} void DeviceLost() override; From d473aa6db0627bfe00af671697f5ac301b200bdb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 07:47:13 -0700 Subject: [PATCH 089/374] Module: Cleanup file read pattern. Let's always use ReadEntireFile() when we can. --- Core/Dialog/PSPGamedataInstallDialog.cpp | 9 ++--- Core/FileSystems/MetaFileSystem.cpp | 2 +- Core/HLE/sceKernelModule.cpp | 48 +++++++----------------- 3 files changed, 17 insertions(+), 42 deletions(-) diff --git a/Core/Dialog/PSPGamedataInstallDialog.cpp b/Core/Dialog/PSPGamedataInstallDialog.cpp index 3bbe9442f1..30da2953c6 100644 --- a/Core/Dialog/PSPGamedataInstallDialog.cpp +++ b/Core/Dialog/PSPGamedataInstallDialog.cpp @@ -206,12 +206,9 @@ void PSPGamedataInstallDialog::CloseCurrentFile() { void PSPGamedataInstallDialog::WriteSfoFile() { ParamSFOData sfoFile; std::string sfopath = GetGameDataInstallFileName(&request, SFO_FILENAME); - PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath); - if (sfoInfo.exists) { - std::vector sfoData; - if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) { - sfoFile.ReadSFO(sfoData); - } + std::vector sfoFileData; + if (pspFileSystem.ReadEntireFile(sfopath, sfoFileData) >= 0) { + sfoFile.ReadSFO(sfoFileData); } // Update based on the just-saved data. diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 4ac716aa57..580c70e7f7 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -593,7 +593,7 @@ int MetaFileSystem::ReadEntireFile(const std::string &filename, std::vector SeekFile(handle, 0, FILEMOVE_BEGIN); data.resize(dataSize); - size_t result = ReadFile(handle, (u8 *)&data[0], dataSize); + size_t result = ReadFile(handle, data.data(), dataSize); CloseFile(handle); if (result != dataSize) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index 4f3d586672..db190c45f7 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1634,16 +1634,9 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load } SceUID KernelLoadModule(const std::string &filename, std::string *error_string) { - PSPFileInfo info = pspFileSystem.GetFileInfo(filename); - if (!info.exists) - return SCE_KERNEL_ERROR_NOFILE; - std::vector buffer; - buffer.resize((size_t)info.size); - - u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ); - pspFileSystem.ReadFile(handle, &buffer[0], info.size); - pspFileSystem.CloseFile(handle); + if (pspFileSystem.ReadEntireFile(filename, buffer) < 0) + return SCE_KERNEL_ERROR_NOFILE; u32 error = SCE_KERNEL_ERROR_ILLEGAL_OBJECT; u32 magic; @@ -1796,8 +1789,8 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str __KernelLoadReset(); - PSPFileInfo info = pspFileSystem.GetFileInfo(filename); - if (!info.exists) { + std::vector fileData; + if (pspFileSystem.ReadEntireFile(filename, fileData) < 0) { ERROR_LOG(LOADER, "Failed to load executable %s - file doesn't exist", filename); *error_string = StringFromFormat("Could not find executable %s", filename); delete[] param_argp; @@ -1806,14 +1799,11 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str return false; } - u32 handle = pspFileSystem.OpenFile(filename, FILEACCESS_READ); - - u8 *temp = new u8[(int)info.size + 0x01000000]; - - pspFileSystem.ReadFile(handle, temp, (size_t)info.size); - PSP_SetLoading("Loading modules..."); - PSPModule *module = __KernelLoadModule(temp, (size_t)info.size, 0, error_string); + size_t size = fileData.size(); + // TODO: Why do we add this padding? Crash avoidance? + fileData.resize(fileData.size() + 0x01000000); + PSPModule *module = __KernelLoadModule(fileData.data(), size, 0, error_string); if (!module || module->isFake) { if (module) { @@ -1822,7 +1812,6 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str } ERROR_LOG(LOADER, "Failed to load module %s", filename); *error_string = "Failed to load executable: " + *error_string; - delete [] temp; delete[] param_argp; delete[] param_key; return false; @@ -1834,10 +1823,6 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str INFO_LOG(LOADER, "Module entry: %08x", mipsr4k.pc); - delete [] temp; - - pspFileSystem.CloseFile(handle); - SceKernelSMOption option; option.size = sizeof(SceKernelSMOption); option.attribute = PSP_THREAD_ATTR_USER; @@ -2007,15 +1992,12 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) { } } - PSPFileInfo info = pspFileSystem.GetFileInfo(name); - s64 size = (s64)info.size; - - if (!info.exists) { + std::vector fileData; + if (pspFileSystem.ReadEntireFile(name, fileData) < 0) { const u32 error = hleLogError(LOADER, SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND, "file does not exist"); return hleDelayResult(error, "module loaded", 500); } - - if (!size) { + if (fileData.empty()) { const u32 error = hleLogError(LOADER, SCE_KERNEL_ERROR_FILEERR, "module file size is 0"); return hleDelayResult(error, "module loaded", 500); } @@ -2045,15 +2027,10 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) { } PSPModule *module = nullptr; - u8 *temp = new u8[(int)size]; - u32 handle = pspFileSystem.OpenFile(name, FILEACCESS_READ); - pspFileSystem.ReadFile(handle, temp, (size_t)size); u32 magic; u32 error; std::string error_string; - module = __KernelLoadELFFromPtr(temp, (size_t)size, 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, error); - delete [] temp; - pspFileSystem.CloseFile(handle); + module = __KernelLoadELFFromPtr(fileData.data(), fileData.size(), 0, lmoption ? lmoption->position == PSP_SMEM_High : false, &error_string, &magic, error); if (!module) { if (magic == 0x46535000) { @@ -2063,6 +2040,7 @@ u32 sceKernelLoadModule(const char *name, u32 flags, u32 optionAddr) { return hleDelayResult(error, "module loaded", 500); } + PSPFileInfo info = pspFileSystem.GetFileInfo(name); if (info.name == "BOOT.BIN") { NOTICE_LOG_REPORT(LOADER, "Module %s is blacklisted or undecryptable - we try __KernelLoadExec", name); // Name might get deleted. From 8d848f083b8cfb8f12f6ee54e37a8278ea00e33f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 08:02:11 -0700 Subject: [PATCH 090/374] Io: Reduce operations inside GetFileInfo(). These can take time so let's try to bundle them. --- Core/FileSystems/DirectoryFileSystem.cpp | 30 ++++++++++-------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index c2b69342d7..0a2205a8d5 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -671,40 +671,34 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) { PSPFileInfo x; x.name = filename; + File::FileInfo info; Path fullName = GetLocalPath(filename); - if (!File::Exists(fullName)) { + if (!File::GetFileInfo(fullName, &info)) { #if HOST_IS_CASE_SENSITIVE if (! FixPathCase(basePath, filename, FPC_FILE_MUST_EXIST)) return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs()); fullName = GetLocalPath(filename); - if (! File::Exists(fullName)) + if (!File::GetFileInfo(fullName, &info)) return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs()); #else return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs()); #endif } - // TODO: Consolidate to just a File::GetFileInfo call. - - x.type = File::IsDirectory(fullName) ? FILETYPE_DIRECTORY : FILETYPE_NORMAL; + x.type = info.isDirectory ? FILETYPE_DIRECTORY : FILETYPE_NORMAL; x.exists = true; if (x.type != FILETYPE_DIRECTORY) { - File::FileInfo info; - if (!File::GetFileInfo(fullName, &info)) { - ERROR_LOG(FILESYS, "DirectoryFileSystem::GetFileInfo: GetFileInfo failed: %s", fullName.c_str()); - } else { - x.size = info.size; - x.access = info.access; - time_t atime = info.atime; - time_t ctime = info.ctime; - time_t mtime = info.mtime; + x.size = info.size; + x.access = info.access; + time_t atime = info.atime; + time_t ctime = info.ctime; + time_t mtime = info.mtime; - localtime_r((time_t*)&atime, &x.atime); - localtime_r((time_t*)&ctime, &x.ctime); - localtime_r((time_t*)&mtime, &x.mtime); - } + localtime_r((time_t*)&atime, &x.atime); + localtime_r((time_t*)&ctime, &x.ctime); + localtime_r((time_t*)&mtime, &x.mtime); } return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs()); From 4db30e772468bbf4c2cd7cd47625ff619012e4dc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 08:16:33 -0700 Subject: [PATCH 091/374] Io: Defer GetFileInfo() until it's needed. We often won't need this, so skip the call until needed. --- Core/HLE/sceIo.cpp | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 9e161828a8..03cff5c911 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -230,6 +230,17 @@ public: return pendingAsyncResult || hasAsyncResult; } + const PSPFileInfo &FileInfo() { + if (!infoReady) { + info = pspFileSystem.GetFileInfo(fullpath); + if (!info.exists) { + ERROR_LOG(IO, "File %s no longer exists when reading info", fullpath.c_str()); + } + infoReady = true; + } + return info; + } + void DoState(PointerWrap &p) override { auto s = p.Section("FileNode", 1, 3); if (!s) @@ -246,6 +257,9 @@ public: Do(p, closePending); Do(p, info); Do(p, openMode); + if (p.mode == p.MODE_READ) { + infoReady = info.exists; + } Do(p, npdrm); Do(p, pgd_offset); @@ -285,6 +299,7 @@ public: // TODO: Use an enum instead? bool closePending = false; + bool infoReady = false; PSPFileInfo info; u32 openMode = 0; @@ -1356,7 +1371,7 @@ static s64 __IoLseekDest(FileNode *f, s64 offset, int whence, FileMove &seek) { seek = FILEMOVE_CURRENT; break; case 2: - newPos = f->info.size + offset; + newPos = f->FileInfo().size + offset; seek = FILEMOVE_END; break; default: @@ -1489,8 +1504,6 @@ static FileNode *__IoOpen(int &error, const char *filename, int flags, int mode) isTTY = true; } else { - info = pspFileSystem.GetFileInfo(filename); - h = pspFileSystem.OpenFile(filename, (FileAccess)access); if (h < 0) { error = h; @@ -1504,7 +1517,10 @@ static FileNode *__IoOpen(int &error, const char *filename, int flags, int mode) f->handle = h; f->fullpath = filename; f->asyncResult = h; - f->info = info; + if (isTTY) { + f->info = info; + f->infoReady = true; + } f->openMode = access; f->isTTY = isTTY; @@ -2528,7 +2544,7 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, if(f->pgdInfo) return f->pgdInfo->data_size; else - return (int)f->info.size; + return (int)f->FileInfo().size; break; // Get UMD sector size @@ -2571,7 +2587,7 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, const auto seekInfo = PSPPointer::Create(indataPtr); FileMove seek; s64 newPos = __IoLseekDest(f, seekInfo->offset, seekInfo->whence, seek); - if (newPos < 0 || newPos > f->info.size) { + if (newPos < 0 || newPos > f->FileInfo().size) { // Not allowed to seek past the end of the file with this API. return ERROR_ERRNO_IO_ERROR; } @@ -2587,7 +2603,7 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, // TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem. INFO_LOG(SCEIO, "sceIoIoctl: Asked for start sector of file %i", id); if (Memory::IsValidAddress(outdataPtr) && outlen >= 4) { - Memory::Write_U32(f->info.startSector, outdataPtr); + Memory::Write_U32(f->FileInfo().startSector, outdataPtr); } else { return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT; } @@ -2599,7 +2615,7 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, // TODO: Should probably move this to something common between ISOFileSystem and VirtualDiscSystem. INFO_LOG(SCEIO, "sceIoIoctl: Asked for size of file %i", id); if (Memory::IsValidAddress(outdataPtr) && outlen >= 8) { - Memory::Write_U64(f->info.size, outdataPtr); + Memory::Write_U64(f->FileInfo().size, outdataPtr); } else { return SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT; } @@ -2676,7 +2692,7 @@ static int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, FileMove seek; s64 newPos = __IoLseekDest(f, seekInfo->offset, seekInfo->whence, seek); // Position is in sectors, don't forget. - if (newPos < 0 || newPos > f->info.size) { + if (newPos < 0 || newPos > f->FileInfo().size) { // Not allowed to seek past the end of the file with this API. return SCE_KERNEL_ERROR_ERRNO_INVALID_FILE_SIZE; } From 6fd2940376aaccbf73a9b2d6165e5eba03abbbe5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 08:29:02 -0700 Subject: [PATCH 092/374] Font: Reduce internal font loading IO. Improves startup for games that load sceFont on devices with slow storage. --- Core/HLE/sceFont.cpp | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index d55ce61514..f819b3a2c7 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -858,22 +858,21 @@ static void __LoadInternalFonts() { } const std::string fontPath = "flash0:/font/"; const std::string fontOverridePath = "ms0:/PSP/flash0/font/"; - const std::string userfontPath = "disc0:/PSP_GAME/USRDIR/"; - + const std::string gameFontPath = "disc0:/PSP_GAME/USRDIR/"; + if (!pspFileSystem.GetFileInfo(fontPath).exists) { pspFileSystem.MkDir(fontPath); } if ((pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/zh_gb.pgf").exists) && (pspFileSystem.GetFileInfo("disc0:/PSP_GAME/USRDIR/oldfont.prx").exists)) { for (size_t i = 0; i < ARRAY_SIZE(fontRegistry); i++) { const FontRegistryEntry &entry = fontRegistry[i]; - std::string fontFilename = userfontPath + entry.fileName; - PSPFileInfo info = pspFileSystem.GetFileInfo(fontFilename); - DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)info.size); + std::string fontFilename = gameFontPath + entry.fileName; std::vector buffer; if (pspFileSystem.ReadEntireFile(fontFilename, buffer) < 0) { - ERROR_LOG(SCEFONT, "Failed opening font"); + ERROR_LOG(SCEFONT, "Failed opening font %s", fontFilename.c_str()); continue; } + DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)buffer.size()); internalFonts.push_back(new Font(buffer, entry)); DEBUG_LOG(SCEFONT, "Loaded font %s", fontFilename.c_str()); return; @@ -882,29 +881,26 @@ static void __LoadInternalFonts() { for (size_t i = 0; i < ARRAY_SIZE(fontRegistry); i++) { const FontRegistryEntry &entry = fontRegistry[i]; - std::string fontFilename = userfontPath + entry.fileName; - PSPFileInfo info = pspFileSystem.GetFileInfo(fontFilename); + std::vector buffer; + bool bufferRead = false; - if (!info.exists) { - // No user font, let's try override path. + std::string fontFilename = gameFontPath + entry.fileName; + bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0; + + if (!bufferRead) { + // No game font, let's try override path. fontFilename = fontOverridePath + entry.fileName; - info = pspFileSystem.GetFileInfo(fontFilename); + bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0; } - if (!info.exists) { + if (!bufferRead) { // No override, let's use the default path. fontFilename = fontPath + entry.fileName; - info = pspFileSystem.GetFileInfo(fontFilename); + bufferRead = pspFileSystem.ReadEntireFile(fontFilename, buffer) >= 0; } - if (info.exists) { - DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)info.size); - std::vector buffer; - if (pspFileSystem.ReadEntireFile(fontFilename, buffer) < 0) { - ERROR_LOG(SCEFONT, "Failed opening font"); - continue; - } - + if (bufferRead) { + DEBUG_LOG(SCEFONT, "Loading internal font %s (%i bytes)", fontFilename.c_str(), (int)buffer.size()); internalFonts.push_back(new Font(buffer, entry)); DEBUG_LOG(SCEFONT, "Loaded font %s", fontFilename.c_str()); From 6168e03b4a5f26a30c8864f059fcb6982e0d91cd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 08:50:48 -0700 Subject: [PATCH 093/374] Savedata: Reduce some duplicate file info lookups. --- Core/Dialog/SavedataParam.cpp | 77 +++++++++++++++-------------------- 1 file changed, 33 insertions(+), 44 deletions(-) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 67ef655ccf..054d39d0a0 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1488,23 +1488,20 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) for (int i = 0; i < saveDataListCount; i++) { // "<>" means saveName can be anything... if (strncmp(saveNameListData[i], "<>", ARRAY_SIZE(saveNameListData[i])) == 0) { - std::string fileDataPath = ""; // TODO:Maybe we need a way to reorder the files? auto allSaves = pspFileSystem.GetDirListing(savePath); std::string gameName = GetGameName(param); - std::string saveName = ""; - for(auto it = allSaves.begin(); it != allSaves.end(); ++it) { - if(it->name.compare(0, gameName.length(), gameName) == 0) { - saveName = it->name.substr(gameName.length()); + for (auto it = allSaves.begin(); it != allSaves.end(); ++it) { + if (it->name.compare(0, gameName.length(), gameName) == 0) { + std::string saveName = it->name.substr(gameName.length()); - if(IsInSaveDataList(saveName, realCount)) // Already in SaveDataList, skip... + if (IsInSaveDataList(saveName, realCount)) // Already in SaveDataList, skip... continue; - fileDataPath = savePath + it->name; - PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath); - if (info.exists) { - SetFileInfo(realCount, info, saveName); - DEBUG_LOG(SCEUTILITY,"%s Exist",fileDataPath.c_str()); + std::string fileDataPath = savePath + it->name; + if (it->exists) { + SetFileInfo(realCount, *it, saveName); + DEBUG_LOG(SCEUTILITY, "%s Exist", fileDataPath.c_str()); ++realCount; } else { if (listEmptyFile) { @@ -1597,11 +1594,9 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std:: saveInfo.texture = new PPGeImage(fileDataPath2); // Load info in PARAM.SFO + std::vector sfoData; fileDataPath2 = savePath + saveDir + "/" + SFO_FILENAME; - info2 = pspFileSystem.GetFileInfo(fileDataPath2); - if (info2.exists) { - std::vector sfoData; - pspFileSystem.ReadEntireFile(fileDataPath2, sfoData); + if (pspFileSystem.ReadEntireFile(fileDataPath2, sfoData) >= 0) { ParamSFOData sfoFile; if (sfoFile.ReadSFO(sfoData)) { SetStringFromSFO(sfoFile, "TITLE", saveInfo.title, sizeof(saveInfo.title)); @@ -1878,39 +1873,33 @@ void SavedataParam::DoState(PointerWrap &p) DoArray(p, saveDataList, saveDataListCount); } -int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam* param, const std::string &saveDirName) -{ +int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam *param, const std::string &saveDirName) { ParamSFOData sfoFile; std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); std::string sfopath = dirPath + "/" + SFO_FILENAME; - PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath); - if(sfoInfo.exists) // Read sfo - { - std::vector sfoData; - if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) - { - sfoFile.ReadSFO(sfoData); + std::vector sfoData; + if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) { + sfoFile.ReadSFO(sfoData); - // save created in PPSSPP and not encrypted has '0' in SAVEDATA_PARAMS - u32 tmpDataSize = 0; - const u8 *tmpDataOrig = sfoFile.GetValueData("SAVEDATA_PARAMS", &tmpDataSize); - if (tmpDataSize == 0 || !tmpDataOrig) { - return 0; - } - switch (tmpDataOrig[0]) { - case 0: - return 0; - case 0x01: - return 1; - case 0x21: - return 3; - case 0x41: - return 5; - default: - // Well, it's not zero, so yes. - ERROR_LOG_REPORT(SCEUTILITY, "Unexpected SAVEDATA_PARAMS hash flag: %02x", tmpDataOrig[0]); - return 1; - } + // save created in PPSSPP and not encrypted has '0' in SAVEDATA_PARAMS + u32 tmpDataSize = 0; + const u8 *tmpDataOrig = sfoFile.GetValueData("SAVEDATA_PARAMS", &tmpDataSize); + if (tmpDataSize == 0 || !tmpDataOrig) { + return 0; + } + switch (tmpDataOrig[0]) { + case 0: + return 0; + case 0x01: + return 1; + case 0x21: + return 3; + case 0x41: + return 5; + default: + // Well, it's not zero, so yes. + ERROR_LOG_REPORT(SCEUTILITY, "Unexpected SAVEDATA_PARAMS hash flag: %02x", tmpDataOrig[0]); + return 1; } } return 0; From 7b8350f8a86f12b3b56c73ec27c4913c922cee98 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 11:37:19 -0700 Subject: [PATCH 094/374] Android: Differentiate empty dir from failure. --- Common/File/AndroidStorage.cpp | 12 +++++++++--- Common/File/AndroidStorage.h | 5 +++-- Common/File/DirListing.cpp | 5 +++-- android/src/org/ppsspp/ppsspp/PpssppActivity.java | 10 ++++------ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Common/File/AndroidStorage.cpp b/Common/File/AndroidStorage.cpp index c1b4283651..ec8248947b 100644 --- a/Common/File/AndroidStorage.cpp +++ b/Common/File/AndroidStorage.cpp @@ -206,11 +206,13 @@ bool Android_FileExists(const std::string &fileUri) { return exists; } -std::vector Android_ListContentUri(const std::string &path) { +std::vector Android_ListContentUri(const std::string &path, bool *exists) { if (!g_nativeActivity) { + *exists = false; return std::vector(); } auto env = getEnv(); + *exists = true; double start = time_now_d(); @@ -224,8 +226,12 @@ std::vector Android_ListContentUri(const std::string &path) { jstring str = (jstring)env->GetObjectArrayElement(fileList, i); const char *charArray = env->GetStringUTFChars(str, 0); if (charArray) { // paranoia + std::string line = charArray; File::FileInfo info; - if (ParseFileInfo(std::string(charArray), &info)) { + if (line == "X") { + // Indicates an exception thrown, path doesn't exist. + *exists = false; + } else if (ParseFileInfo(line, &info)) { // We can just reconstruct the URI. info.fullName = Path(path) / info.name; items.push_back(info); @@ -238,7 +244,7 @@ std::vector Android_ListContentUri(const std::string &path) { double elapsed = time_now_d() - start; if (elapsed > 0.1) { - INFO_LOG(FILESYS, "Listing directory on content URI took %0.3f s (%d files)", elapsed, (int)size); + INFO_LOG(FILESYS, "Listing directory on content URI took %0.3f s (%d files)", elapsed, (int)items.size()); } return items; } diff --git a/Common/File/AndroidStorage.h b/Common/File/AndroidStorage.h index a9a88055d1..1b4585f775 100644 --- a/Common/File/AndroidStorage.h +++ b/Common/File/AndroidStorage.h @@ -55,7 +55,7 @@ int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath); bool Android_IsExternalStoragePreservedLegacy(); const char *Android_ErrorToString(StorageError error); -std::vector Android_ListContentUri(const std::string &uri); +std::vector Android_ListContentUri(const std::string &uri, bool *exists); void Android_RegisterStorageCallbacks(JNIEnv * env, jobject obj); @@ -78,7 +78,8 @@ inline int64_t Android_GetFreeSpaceByContentUri(const std::string &uri) { return inline int64_t Android_GetFreeSpaceByFilePath(const std::string &filePath) { return -1; } inline bool Android_IsExternalStoragePreservedLegacy() { return false; } inline const char *Android_ErrorToString(StorageError error) { return ""; } -inline std::vector Android_ListContentUri(const std::string &uri) { +inline std::vector Android_ListContentUri(const std::string &uri, bool *exists) { + *exists = false; return std::vector(); } diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index 2f7178847b..6847df3e84 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -171,10 +171,11 @@ std::vector ApplyFilter(std::vector files, const bool GetFilesInDir(const Path &directory, std::vector *files, const char *filter, int flags) { if (directory.Type() == PathType::CONTENT_URI) { - std::vector fileList = Android_ListContentUri(directory.ToString()); + bool exists = false; + std::vector fileList = Android_ListContentUri(directory.ToString(), &exists); *files = ApplyFilter(fileList, filter); std::sort(files->begin(), files->end()); - return true; + return exists; } std::set filters; diff --git a/android/src/org/ppsspp/ppsspp/PpssppActivity.java b/android/src/org/ppsspp/ppsspp/PpssppActivity.java index 3142995042..aa383a1568 100644 --- a/android/src/org/ppsspp/ppsspp/PpssppActivity.java +++ b/android/src/org/ppsspp/ppsspp/PpssppActivity.java @@ -273,15 +273,13 @@ public class PpssppActivity extends NativeActivity { // Is ArrayList weird or what? String[] strings = new String[listing.size()]; return listing.toArray(strings); - } - catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { // Due to sloppy exception handling in resolver.query, we get this wrapping // a FileNotFoundException if the directory doesn't exist. - return new String[]{}; - } - catch (Exception e) { + return new String[]{ "X" }; + } catch (Exception e) { Log.e(TAG, "listContentUriDir exception: " + e.toString()); - return new String[]{}; + return new String[]{ "X" }; } finally { if (c != null) { c.close(); From 49426925587f5a83f31cb255756c5105e38bd57e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 09:08:18 -0700 Subject: [PATCH 095/374] Io: Provide directory existence with listing. Sometimes, you need to tell the difference between an empty directory and one that doesn't exist at all. We can do this in a single call. --- Core/FileSystems/BlobFileSystem.cpp | 4 +++- Core/FileSystems/BlobFileSystem.h | 2 +- Core/FileSystems/DirectoryFileSystem.cpp | 18 ++++++++++++++---- Core/FileSystems/DirectoryFileSystem.h | 4 ++-- Core/FileSystems/FileSystem.h | 9 +++++++-- Core/FileSystems/ISOFileSystem.cpp | 10 ++++++++-- Core/FileSystems/ISOFileSystem.h | 8 ++++++-- Core/FileSystems/MetaFileSystem.cpp | 14 ++++++-------- Core/FileSystems/MetaFileSystem.h | 2 +- Core/FileSystems/VirtualDiscFileSystem.cpp | 22 +++++++++++++++++----- Core/FileSystems/VirtualDiscFileSystem.h | 2 +- 11 files changed, 66 insertions(+), 29 deletions(-) diff --git a/Core/FileSystems/BlobFileSystem.cpp b/Core/FileSystems/BlobFileSystem.cpp index 46f22085e5..fb47eefa9d 100644 --- a/Core/FileSystems/BlobFileSystem.cpp +++ b/Core/FileSystems/BlobFileSystem.cpp @@ -30,9 +30,11 @@ void BlobFileSystem::DoState(PointerWrap &p) { // Not used in real emulation. } -std::vector BlobFileSystem::GetDirListing(std::string path) { +std::vector BlobFileSystem::GetDirListing(const std::string &path, bool *exists) { std::vector listing; listing.push_back(GetFileInfo(alias_)); + if (exists) + *exists = true; return listing; } diff --git a/Core/FileSystems/BlobFileSystem.h b/Core/FileSystems/BlobFileSystem.h index f45576d6a7..6def55870d 100644 --- a/Core/FileSystems/BlobFileSystem.h +++ b/Core/FileSystems/BlobFileSystem.h @@ -34,7 +34,7 @@ public: ~BlobFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(std::string path) override; + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index 0a2205a8d5..cf2ff0c8d9 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -789,7 +789,7 @@ bool DirectoryFileSystem::ComputeRecursiveDirSizeIfFast(const std::string &path, } } -std::vector DirectoryFileSystem::GetDirListing(std::string path) { +std::vector DirectoryFileSystem::GetDirListing(const std::string &path, bool *exists) { std::vector myVector; std::vector files; @@ -798,14 +798,19 @@ std::vector DirectoryFileSystem::GetDirListing(std::string path) { if (!File::GetFilesInDir(localPath, &files, nullptr, flags)) { // TODO: Case sensitivity should be checked on a file system basis, right? #if HOST_IS_CASE_SENSITIVE - if (FixPathCase(basePath, path, FPC_FILE_MUST_EXIST)) { + std::string fixedPath = path; + if (FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again - localPath = GetLocalPath(path); + localPath = GetLocalPath(fixedPath); if (!File::GetFilesInDir(localPath, &files, nullptr, 0)) { + if (exists) + *exists = false; return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs()); } } #else + if (exists) + *exists = false; return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs()); #endif } @@ -835,6 +840,7 @@ std::vector DirectoryFileSystem::GetDirListing(std::string path) { entry.type = FILETYPE_NORMAL; } entry.access = file.access; + entry.exists = file.exists; localtime_r((time_t*)&file.atime, &entry.atime); localtime_r((time_t*)&file.ctime, &entry.ctime); @@ -843,6 +849,8 @@ std::vector DirectoryFileSystem::GetDirListing(std::string path) { myVector.push_back(entry); } + if (exists) + *exists = true; return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs()); } @@ -1073,9 +1081,11 @@ size_t VFSFileSystem::SeekFile(u32 handle, s32 position, FileMove type) { } } -std::vector VFSFileSystem::GetDirListing(std::string path) { +std::vector VFSFileSystem::GetDirListing(const std::string &path, bool *exists) { std::vector myVector; // TODO + if (exists) + *exists = false; return myVector; } diff --git a/Core/FileSystems/DirectoryFileSystem.h b/Core/FileSystems/DirectoryFileSystem.h index 779325ed65..5edfa9a1a3 100644 --- a/Core/FileSystems/DirectoryFileSystem.h +++ b/Core/FileSystems/DirectoryFileSystem.h @@ -65,7 +65,7 @@ public: void CloseAll(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(std::string path) override; + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; @@ -111,7 +111,7 @@ public: ~VFSFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(std::string path) override; + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/FileSystem.h b/Core/FileSystems/FileSystem.h index 87c87ae569..350b97cd8f 100644 --- a/Core/FileSystems/FileSystem.h +++ b/Core/FileSystems/FileSystem.h @@ -118,7 +118,7 @@ public: virtual ~IFileSystem() {} virtual void DoState(PointerWrap &p) = 0; - virtual std::vector GetDirListing(std::string path) = 0; + virtual std::vector GetDirListing(const std::string &path, bool *exists = nullptr) = 0; virtual int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) = 0; virtual void CloseFile(u32 handle) = 0; virtual size_t ReadFile(u32 handle, u8 *pointer, s64 size) = 0; @@ -143,7 +143,12 @@ public: class EmptyFileSystem : public IFileSystem { public: virtual void DoState(PointerWrap &p) override {} - std::vector GetDirListing(std::string path) override {std::vector vec; return vec;} + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { + if (exists) + *exists = false; + std::vector vec; + return vec; + } int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override {return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND;} void CloseFile(u32 handle) override {} size_t ReadFile(u32 handle, u8 *pointer, s64 size) override {return 0;} diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index 0d57bf2848..f52bc947c2 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -631,11 +631,14 @@ PSPFileInfo ISOFileSystem::GetFileInfo(std::string filename) { return x; } -std::vector ISOFileSystem::GetDirListing(std::string path) { +std::vector ISOFileSystem::GetDirListing(const std::string &path, bool *exists) { std::vector myVector; TreeEntry *entry = GetFromPath(path); - if (!entry) + if (!entry) { + if (exists) + *exists = false; return myVector; + } const std::string dot("."); const std::string dotdot(".."); @@ -651,6 +654,7 @@ std::vector ISOFileSystem::GetDirListing(std::string path) { x.name = e->name; // Strangely, it seems to be executable even for files. x.access = 0555; + x.exists = true; x.size = e->size; x.type = e->isDirectory ? FILETYPE_DIRECTORY : FILETYPE_NORMAL; x.isOnSectorSystem = true; @@ -659,6 +663,8 @@ std::vector ISOFileSystem::GetDirListing(std::string path) { x.numSectors = (u32)((e->size + sectorSize - 1) / sectorSize); myVector.push_back(x); } + if (exists) + *exists = true; return myVector; } diff --git a/Core/FileSystems/ISOFileSystem.h b/Core/FileSystems/ISOFileSystem.h index 608fa444e0..c7813bf1ac 100644 --- a/Core/FileSystems/ISOFileSystem.h +++ b/Core/FileSystems/ISOFileSystem.h @@ -33,7 +33,7 @@ public: ~ISOFileSystem(); void DoState(PointerWrap &p) override; - std::vector GetDirListing(std::string path) override; + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; @@ -110,7 +110,11 @@ public: isoFileSystem_->DoState(p); } - std::vector GetDirListing(std::string path) override { return std::vector(); } + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override { + if (exists) + *exists = true; + return std::vector(); + } int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override { return isoFileSystem_->OpenFile("", access, devicename); } diff --git a/Core/FileSystems/MetaFileSystem.cpp b/Core/FileSystems/MetaFileSystem.cpp index 580c70e7f7..49ddcc892b 100644 --- a/Core/FileSystems/MetaFileSystem.cpp +++ b/Core/FileSystems/MetaFileSystem.cpp @@ -369,19 +369,17 @@ PSPFileInfo MetaFileSystem::GetFileInfo(std::string filename) } } -std::vector MetaFileSystem::GetDirListing(std::string path) -{ +std::vector MetaFileSystem::GetDirListing(const std::string &path, bool *exists) { std::lock_guard guard(lock); std::string of; IFileSystem *system; int error = MapFilePath(path, of, &system); - if (error == 0) - { - return system->GetDirListing(of); - } - else - { + if (error == 0) { + return system->GetDirListing(of, exists); + } else { std::vector empty; + if (exists) + *exists = false; return empty; } } diff --git a/Core/FileSystems/MetaFileSystem.h b/Core/FileSystems/MetaFileSystem.h index 9a3b041c93..545f21bddc 100644 --- a/Core/FileSystems/MetaFileSystem.h +++ b/Core/FileSystems/MetaFileSystem.h @@ -103,7 +103,7 @@ public: std::string NormalizePrefix(std::string prefix) const; - std::vector GetDirListing(std::string path) override; + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; int OpenFile(std::string filename, FileAccess access, const char *devicename = nullptr) override; void CloseFile(u32 handle) override; size_t ReadFile(u32 handle, u8 *pointer, s64 size) override; diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 9a9e0f8c8b..dbe130f30c 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -661,8 +661,7 @@ static void tmFromFiletime(tm &dest, FILETIME &src) } #endif -std::vector VirtualDiscFileSystem::GetDirListing(std::string path) -{ +std::vector VirtualDiscFileSystem::GetDirListing(const std::string &path, bool *exists) { std::vector myVector; // TODO(scoped): Switch this over to GetFilesInDir! @@ -681,9 +680,14 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) hFind = FindFirstFileEx(w32path.c_str(), FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0); #endif if (hFind == INVALID_HANDLE_VALUE) { + if (exists) + *exists = false; return myVector; //the empty list } + if (exists) + *exists = true; + for (BOOL retval = 1; retval; retval = FindNextFile(hFind, &findData)) { if (!wcscmp(findData.cFileName, L"..") || !wcscmp(findData.cFileName, L".")) { continue; @@ -697,6 +701,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) } entry.access = 0555; + entry.exists = true; entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32); entry.name = ConvertWStringToUTF8(findData.cFileName); tmFromFiletime(entry.atime, findData.ftLastAccessTime); @@ -717,18 +722,24 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) DIR *dp = opendir(localPath.c_str()); #if HOST_IS_CASE_SENSITIVE - if(dp == NULL && FixPathCase(basePath, path, FPC_FILE_MUST_EXIST)) { + std::string fixedPath = path; + if(dp == NULL && FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again - localPath = GetLocalPath(path); + localPath = GetLocalPath(fixedPath); dp = opendir(localPath.c_str()); } #endif if (dp == NULL) { ERROR_LOG(FILESYS,"Error opening directory %s\n", path.c_str()); + if (exists) + *exists = false; return myVector; } + if (exists) + *exists = true; + while ((dirp = readdir(dp)) != NULL) { if (!strcmp(dirp->d_name, "..") || !strcmp(dirp->d_name, ".")) { continue; @@ -736,13 +747,14 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) PSPFileInfo entry; struct stat s; - std::string fullName = (GetLocalPath(path) / std::string(dirp->d_name)).ToString(); + std::string fullName = (localPath / std::string(dirp->d_name)).ToString(); stat(fullName.c_str(), &s); if (S_ISDIR(s.st_mode)) entry.type = FILETYPE_DIRECTORY; else entry.type = FILETYPE_NORMAL; entry.access = 0555; + entry.exists = true; entry.name = dirp->d_name; entry.size = s.st_size; localtime_r((time_t*)&s.st_atime,&entry.atime); diff --git a/Core/FileSystems/VirtualDiscFileSystem.h b/Core/FileSystems/VirtualDiscFileSystem.h index 0c1b6db872..1af7b5d842 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.h +++ b/Core/FileSystems/VirtualDiscFileSystem.h @@ -40,7 +40,7 @@ public: bool OwnsHandle(u32 handle) override; int Ioctl(u32 handle, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec) override; PSPDevType DevType(u32 handle) override; - std::vector GetDirListing(std::string path) override; + std::vector GetDirListing(const std::string &path, bool *exists = nullptr) override; FileSystemFlags Flags() override { return FileSystemFlags::UMD; } u64 FreeSpace(const std::string &path) override { return 0; } From 8c1acc30e4591eae35ec055485cb06468ce225b7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 09:33:39 -0700 Subject: [PATCH 096/374] Savedata: Combine file info and dir listing calls. --- Common/File/DirListing.cpp | 4 +-- Core/Dialog/SavedataParam.cpp | 38 ++++++++++++++++-------- Core/FileSystems/DirectoryFileSystem.cpp | 16 +++++----- Core/HLE/sceIo.cpp | 11 ++++--- 4 files changed, 41 insertions(+), 28 deletions(-) diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index 6847df3e84..d17a4f2241 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -220,7 +220,7 @@ bool GetFilesInDir(const Path &directory, std::vector *files, const ch HANDLE hFind = FindFirstFileEx((directory.ToWString() + L"\\*").c_str(), FindExInfoStandard, &ffd, FindExSearchNameMatch, NULL, 0); #endif if (hFind == INVALID_HANDLE_VALUE) { - return 0; + return false; } do { const std::string virtualName = ConvertWStringToUTF8(ffd.cFileName); @@ -267,7 +267,7 @@ bool GetFilesInDir(const Path &directory, std::vector *files, const ch struct dirent *result = NULL; DIR *dirp = opendir(directory.c_str()); if (!dirp) - return 0; + return false; while ((result = readdir(dirp))) { const std::string virtualName(result->d_name); // check for "." and ".." diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 054d39d0a0..67a5110899 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -95,6 +95,18 @@ namespace return result == dataSize; } + PSPFileInfo FileFromListing(const std::vector &listing, const std::string &filename) { + for (const PSPFileInfo &sub : listing) { + if (sub.name == filename) + return sub; + } + + PSPFileInfo info; + info.name = filename; + info.exists = false; + return info; + } + bool PSPMatch(std::string text, std::string regexp) { if(text.empty() && regexp.empty()) @@ -1094,13 +1106,12 @@ int SavedataParam::GetSizes(SceUtilitySavedataParam *param) const std::string saveName(msData->saveName, strnlen(msData->saveName, sizeof(msData->saveName))); // TODO: How should <> be handled? std::string path = GetSaveFilePath(param, gameName + (saveName == "<>" ? "" : saveName)); - PSPFileInfo finfo = pspFileSystem.GetFileInfo(path); - if (finfo.exists) - { + bool listingExists = false; + auto listing = pspFileSystem.GetDirListing(path, &listingExists); + if (listingExists) { param->msData->info.usedClusters = 0; - auto listing = pspFileSystem.GetDirListing(path); - for (auto it = listing.begin(), end = listing.end(); it != end; ++it) { - param->msData->info.usedClusters += (it->size + (u32)MemoryStick_SectorSize() - 1) / (u32)MemoryStick_SectorSize(); + for (auto &item : listing) { + param->msData->info.usedClusters += (item.size + (u32)MemoryStick_SectorSize() - 1) / (u32)MemoryStick_SectorSize(); } // The usedSpaceKB value is definitely based on clusters, not bytes or even KB. @@ -1251,7 +1262,9 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr) } std::string dirPath = savePath + GetGameName(param) + GetSaveName(param); - if (!pspFileSystem.GetFileInfo(dirPath).exists) { + bool dirPathExists = false; + auto files = pspFileSystem.GetDirListing(dirPath, &dirPathExists); + if (!dirPathExists) { DEBUG_LOG(SCEUTILITY, "SavedataParam::GetFilesList(): directory %s does not exist", dirPath.c_str()); return SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA; } @@ -1262,7 +1275,7 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr) fileList->resultNumSystemEntries = 0; // We need PARAM.SFO's SAVEDATA_FILE_LIST to determine which entries are secure. - PSPFileInfo sfoFileInfo = pspFileSystem.GetFileInfo(dirPath + "/" + SFO_FILENAME); + PSPFileInfo sfoFileInfo = FileFromListing(files, SFO_FILENAME); std::set secureFilenames; if (sfoFileInfo.exists) { @@ -1279,7 +1292,6 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr) requestPtr->bind = 1021; // Does not list directories, nor recurse into them, and ignores files not ALL UPPERCASE. - auto files = pspFileSystem.GetDirListing(dirPath); for (auto file = files.begin(), end = files.end(); file != end; ++file) { if (file->type == FILETYPE_DIRECTORY) { continue; @@ -1348,8 +1360,8 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param) } const std::string saveDir = savePath + GetGameName(param) + GetSaveName(param); - PSPFileInfo info = pspFileSystem.GetFileInfo(saveDir); - bool exists = info.exists; + bool exists = false; + auto listing = pspFileSystem.GetDirListing(saveDir, &exists); if (param->sizeInfo.IsValid()) { @@ -1359,12 +1371,12 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param) s64 writeBytes = 0; for (int i = 0; i < param->sizeInfo->numNormalEntries; ++i) { const auto &entry = param->sizeInfo->normalEntries[i]; - overwriteBytes += pspFileSystem.GetFileInfo(saveDir + "/" + entry.name).size; + overwriteBytes += FileFromListing(listing, entry.name).size; writeBytes += entry.size; } for (int i = 0; i < param->sizeInfo->numSecureEntries; ++i) { const auto &entry = param->sizeInfo->secureEntries[i]; - overwriteBytes += pspFileSystem.GetFileInfo(saveDir + "/" + entry.name).size; + overwriteBytes += FileFromListing(listing, entry.name).size; writeBytes += entry.size + 0x10; } diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index cf2ff0c8d9..af8ea370a4 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -795,24 +795,22 @@ std::vector DirectoryFileSystem::GetDirListing(const std::string &p std::vector files; Path localPath = GetLocalPath(path); const int flags = File::GETFILES_GETHIDDEN | File::GETFILES_GET_NAVIGATION_ENTRIES; - if (!File::GetFilesInDir(localPath, &files, nullptr, flags)) { - // TODO: Case sensitivity should be checked on a file system basis, right? + bool success = File::GetFilesInDir(localPath, &files, nullptr, flags); #if HOST_IS_CASE_SENSITIVE + if (!success) { + // TODO: Case sensitivity should be checked on a file system basis, right? std::string fixedPath = path; if (FixPathCase(basePath, fixedPath, FPC_FILE_MUST_EXIST)) { // May have failed due to case sensitivity, try again localPath = GetLocalPath(fixedPath); - if (!File::GetFilesInDir(localPath, &files, nullptr, 0)) { - if (exists) - *exists = false; - return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs()); - } + success = File::GetFilesInDir(localPath, &files, nullptr, flags); } -#else + } +#endif + if (!success) { if (exists) *exists = false; return ReplayApplyDiskListing(myVector, CoreTiming::GetGlobalTimeUs()); -#endif } bool hideISOFiles = PSP_CoreParameter().compat.flags().HideISOFiles; diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 03cff5c911..f4c98dfb6b 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -2336,16 +2336,19 @@ public: static u32 sceIoDopen(const char *path) { DEBUG_LOG(SCEIO, "sceIoDopen(\"%s\")", path); - if (!pspFileSystem.GetFileInfo(path).exists) { + double startTime = time_now_d(); + + bool listingExists = false; + auto listing = pspFileSystem.GetDirListing(path, &listingExists); + + if (!listingExists) { return SCE_KERNEL_ERROR_ERRNO_FILE_NOT_FOUND; } DirListing *dir = new DirListing(); SceUID id = kernelObjects.Create(dir); - double startTime = time_now_d(); - - dir->listing = pspFileSystem.GetDirListing(path); + dir->listing = listing; dir->index = 0; dir->name = std::string(path); From 5bed35b2938e2af54aad0ddd18b0b3f14c5f23e6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 10:36:19 -0700 Subject: [PATCH 097/374] Savedata: Skip and defer texture exist check. We can skip if there's no UI. --- Core/Dialog/PSPSaveDialog.cpp | 30 +++++++++++++++++++++++++++--- Core/Dialog/SavedataParam.cpp | 32 +++++++++++++++++--------------- Core/Dialog/SavedataParam.h | 4 ++++ Core/Util/PPGeDraw.cpp | 32 +++++++++++++++++++++++++++----- Core/Util/PPGeDraw.h | 4 +++- 5 files changed, 78 insertions(+), 24 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 8ab80a4761..1c85219d2b 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -56,6 +56,29 @@ const static int SAVEDATA_DIALOG_SIZE_V1 = 1480; const static int SAVEDATA_DIALOG_SIZE_V2 = 1500; const static int SAVEDATA_DIALOG_SIZE_V3 = 1536; +static bool IsNotVisibleAction(SceUtilitySavedataType type) { + switch (type) { + case SCE_UTILITY_SAVEDATA_TYPE_AUTOLOAD: + case SCE_UTILITY_SAVEDATA_TYPE_AUTOSAVE: + case SCE_UTILITY_SAVEDATA_TYPE_SIZES: + case SCE_UTILITY_SAVEDATA_TYPE_LIST: + case SCE_UTILITY_SAVEDATA_TYPE_FILES: + case SCE_UTILITY_SAVEDATA_TYPE_GETSIZE: + case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE: + case SCE_UTILITY_SAVEDATA_TYPE_MAKEDATA: + case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATASECURE: + case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA: + case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE: + case SCE_UTILITY_SAVEDATA_TYPE_READDATA: + case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA: + case SCE_UTILITY_SAVEDATA_TYPE_AUTODELETE: + return true; + + default: + break; + } + return false; +} PSPSaveDialog::PSPSaveDialog(UtilityDialogType type) : PSPDialog(type) { param.SetPspParam(0); @@ -87,6 +110,7 @@ int PSPSaveDialog::Init(int paramAddr) Memory::Memcpy(&request, requestAddr, size); Memory::Memcpy(&originalRequest, requestAddr, size); + param.SetIgnoreTextures(IsNotVisibleAction((SceUtilitySavedataType)(u32)request.mode)); int retval = param.SetPspParam(&request); const u32 mode = (u32)param.GetPspParam()->mode; @@ -345,7 +369,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) { PPGeImageStyle imageStyle = FadedImageStyle(); auto fileInfo = param.GetFileInfo(displayCount); - if (fileInfo.size == 0 && fileInfo.texture != NULL) + if (fileInfo.size == 0 && fileInfo.texture && fileInfo.texture->IsValid()) imageStyle.color = CalcFadedColor(0xFF777777); // Calc save image position on screen @@ -370,7 +394,7 @@ void PSPSaveDialog::DisplaySaveList(bool canMove) { continue; int pad = 0; - if (fileInfo.texture != nullptr) { + if (fileInfo.texture != nullptr && fileInfo.texture->IsValid()) { fileInfo.texture->SetTexture(); int tw = fileInfo.texture->Width(); int th = fileInfo.texture->Height(); @@ -420,7 +444,7 @@ void PSPSaveDialog::DisplaySaveIcon(bool checkExists) int tw = 256; int th = 256; - if (curSave.texture != NULL) { + if (curSave.texture != nullptr && curSave.texture->IsValid()) { curSave.texture->SetTexture(); tw = curSave.texture->Width(); th = curSave.texture->Height(); diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 67a5110899..c799fb5b2d 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1600,15 +1600,14 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std:: // Search save image icon0 // TODO : If icon0 don't exist, need to use icon1 which is a moving icon. Also play sound - std::string fileDataPath2 = savePath + saveDir + "/" + ICON0_FILENAME; - PSPFileInfo info2 = pspFileSystem.GetFileInfo(fileDataPath2); - if (info2.exists) - saveInfo.texture = new PPGeImage(fileDataPath2); + if (!ignoreTextures_) { + saveInfo.texture = new PPGeImage(savePath + saveDir + "/" + ICON0_FILENAME); + } // Load info in PARAM.SFO std::vector sfoData; - fileDataPath2 = savePath + saveDir + "/" + SFO_FILENAME; - if (pspFileSystem.ReadEntireFile(fileDataPath2, sfoData) >= 0) { + std::string sfoFilename = savePath + saveDir + "/" + SFO_FILENAME; + if (pspFileSystem.ReadEntireFile(sfoFilename, sfoData) >= 0) { ParamSFOData sfoFile; if (sfoFile.ReadSFO(sfoData)) { SetStringFromSFO(sfoFile, "TITLE", saveInfo.title, sizeof(saveInfo.title)); @@ -1859,9 +1858,8 @@ bool SavedataParam::wouldHasMultiSaveName(SceUtilitySavedataParam* param) { } } -void SavedataParam::DoState(PointerWrap &p) -{ - auto s = p.Section("SavedataParam", 1); +void SavedataParam::DoState(PointerWrap &p) { + auto s = p.Section("SavedataParam", 1, 2); if (!s) return; @@ -1869,20 +1867,24 @@ void SavedataParam::DoState(PointerWrap &p) Do(p, selectedSave); Do(p, saveDataListCount); Do(p, saveNameListDataCount); - if (p.mode == p.MODE_READ) - { + if (p.mode == p.MODE_READ) { if (saveDataList != NULL) delete [] saveDataList; - if (saveDataListCount != 0) - { + if (saveDataListCount != 0) { saveDataList = new SaveFileInfo[saveDataListCount]; DoArray(p, saveDataList, saveDataListCount); - } - else + } else { saveDataList = NULL; + } } else DoArray(p, saveDataList, saveDataListCount); + + if (s >= 2) { + Do(p, ignoreTextures_); + } else { + ignoreTextures_ = false; + } } int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam *param, const std::string &saveDirName) { diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index 8599a1428d..aa157511c6 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -324,6 +324,9 @@ public: static std::string GetSpaceText(u64 size, bool roundUp); + void SetIgnoreTextures(bool state) { + ignoreTextures_ = state; + } int SetPspParam(SceUtilitySavedataParam* param); SceUtilitySavedataParam *GetPspParam(); const SceUtilitySavedataParam *GetPspParam() const; @@ -379,4 +382,5 @@ private: SaveFileInfo *noSaveIcon = nullptr; int saveDataListCount = 0; int saveNameListDataCount = 0; + bool ignoreTextures_ = false; }; diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 13fd62a22f..d7559c0fa1 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -1256,11 +1256,11 @@ void PPGeDisableTexture() std::vector PPGeImage::loadedTextures_; PPGeImage::PPGeImage(const std::string &pspFilename) - : filename_(pspFilename), texture_(0) { + : filename_(pspFilename) { } PPGeImage::PPGeImage(u32 pngPointer, size_t pngSize) - : filename_(""), png_(pngPointer), size_(pngSize), texture_(0) { + : filename_(""), png_(pngPointer), size_(pngSize) { } PPGeImage::~PPGeImage() { @@ -1268,6 +1268,7 @@ PPGeImage::~PPGeImage() { } bool PPGeImage::Load() { + loadFailed_ = false; Free(); // In case it fails to load. @@ -1281,7 +1282,8 @@ bool PPGeImage::Load() { } else { std::vector pngData; if (pspFileSystem.ReadEntireFile(filename_, pngData) < 0) { - WARN_LOG(SCEGE, "Bad PPGeImage - cannot load file"); + WARN_LOG(SCEGE, "PPGeImage cannot load file %s", filename_.c_str()); + loadFailed_ = true; return false; } @@ -1289,6 +1291,7 @@ bool PPGeImage::Load() { } if (!success) { WARN_LOG(SCEGE, "Bad PPGeImage - not a valid png"); + loadFailed_ = true; return false; } @@ -1298,6 +1301,7 @@ bool PPGeImage::Load() { if (texture_ == 0) { free(textureData); WARN_LOG(SCEGE, "Bad PPGeImage - unable to allocate space for texture"); + // Don't set loadFailed_ here, we'll try again if there's more memory later. return false; } @@ -1310,16 +1314,28 @@ bool PPGeImage::Load() { return true; } +bool PPGeImage::IsValid() { + if (loadFailed_) + return false; + + if (texture_ == 0) { + Decimate(); + return Load(); + } + return true; +} + void PPGeImage::Free() { if (texture_ != 0) { kernelMemory.Free(texture_); texture_ = 0; loadedTextures_.erase(std::remove(loadedTextures_.begin(), loadedTextures_.end(), this), loadedTextures_.end()); + loadFailed_ = false; } } void PPGeImage::DoState(PointerWrap &p) { - auto s = p.Section("PPGeImage", 1); + auto s = p.Section("PPGeImage", 1, 2); if (!s) return; @@ -1330,6 +1346,11 @@ void PPGeImage::DoState(PointerWrap &p) { Do(p, width_); Do(p, height_); Do(p, lastFrame_); + if (s >= 2) { + Do(p, loadFailed_); + } else { + loadFailed_ = false; + } } void PPGeImage::CompatLoad(u32 texture, int width, int height) { @@ -1337,6 +1358,7 @@ void PPGeImage::CompatLoad(u32 texture, int width, int height) { texture_ = texture; width_ = width; height_ = height; + loadFailed_ = false; } void PPGeImage::Decimate(int age) { @@ -1351,7 +1373,7 @@ void PPGeImage::Decimate(int age) { } void PPGeImage::SetTexture() { - if (texture_ == 0) { + if (texture_ == 0 && !loadFailed_) { Decimate(); Load(); } diff --git a/Core/Util/PPGeDraw.h b/Core/Util/PPGeDraw.h index 409b56564b..ee02acb8cc 100644 --- a/Core/Util/PPGeDraw.h +++ b/Core/Util/PPGeDraw.h @@ -122,6 +122,7 @@ public: // Does not normally need to be called (except to force preloading.) bool Load(); void Free(); + bool IsValid(); void DoState(PointerWrap &p); @@ -147,11 +148,12 @@ private: u32 png_; size_t size_; - u32 texture_; + u32 texture_ = 0; int width_; int height_; int lastFrame_; + bool loadFailed_ = false; }; void PPGeDrawRect(float x1, float y1, float x2, float y2, u32 color); From db5011d7f13133590ed3e0408c303e211b0a426a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 11:25:39 -0700 Subject: [PATCH 098/374] Savedata: Cache SFO data during processing. This only caches between touching PSP code, in case something changes. Reduces cases of multiple SFO lookups and reads. --- Core/Dialog/PSPSaveDialog.cpp | 10 +++ Core/Dialog/SavedataParam.cpp | 116 +++++++++++++++++++--------------- Core/Dialog/SavedataParam.h | 12 ++++ 3 files changed, 87 insertions(+), 51 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 1c85219d2b..91994d3f36 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -111,6 +111,7 @@ int PSPSaveDialog::Init(int paramAddr) Memory::Memcpy(&originalRequest, requestAddr, size); param.SetIgnoreTextures(IsNotVisibleAction((SceUtilitySavedataType)(u32)request.mode)); + param.ClearCaches(); int retval = param.SetPspParam(&request); const u32 mode = (u32)param.GetPspParam()->mode; @@ -263,6 +264,7 @@ int PSPSaveDialog::Init(int paramAddr) ChangeStatusInit(SAVEDATA_INIT_DELAY_US); } + param.ClearCaches(); UpdateButtons(); StartFade(true); @@ -642,6 +644,7 @@ int PSPSaveDialog::Update(int animSpeed) param.SetPspParam(&request); } + param.ClearCaches(); UpdateButtons(); UpdateFade(animSpeed); @@ -1059,11 +1062,13 @@ int PSPSaveDialog::Update(int animSpeed) if (ReadStatus() == SCE_UTILITY_STATUS_FINISHED || pendingStatus == SCE_UTILITY_STATUS_FINISHED) Memory::Memcpy(requestAddr, &request, request.common.size, "SaveDialogParam"); + param.ClearCaches(); return 0; } void PSPSaveDialog::ExecuteIOAction() { + param.ClearCaches(); auto &result = param.GetPspParam()->common.result; std::lock_guard guard(paramLock); switch (display) { @@ -1102,9 +1107,11 @@ void PSPSaveDialog::ExecuteIOAction() { } ioThreadStatus = SAVEIO_DONE; + param.ClearCaches(); } void PSPSaveDialog::ExecuteNotVisibleIOAction() { + param.ClearCaches(); auto &result = param.GetPspParam()->common.result; switch ((SceUtilitySavedataType)(u32)param.GetPspParam()->mode) { @@ -1185,6 +1192,8 @@ void PSPSaveDialog::ExecuteNotVisibleIOAction() { default: break; } + + param.ClearCaches(); } void PSPSaveDialog::JoinIOThread() { @@ -1222,6 +1231,7 @@ int PSPSaveDialog::Shutdown(bool force) { ChangeStatusShutdown(SAVEDATA_SHUTDOWN_DELAY_US); } param.SetPspParam(0); + param.ClearCaches(); return 0; } diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index c799fb5b2d..53d6d819a3 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -343,6 +343,7 @@ bool SavedataParam::Delete(SceUtilitySavedataParam* param, int saveId) { return false; } + ClearCaches(); pspFileSystem.RmDir(dirPath); return true; } @@ -378,6 +379,7 @@ int SavedataParam::DeleteData(SceUtilitySavedataParam* param) { return 0; } + ClearCaches(); pspFileSystem.RemoveFile(filePath); return 0; @@ -455,28 +457,23 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD } // SAVE PARAM.SFO - ParamSFOData sfoFile; std::string sfopath = dirPath + "/" + SFO_FILENAME; - { - std::vector sfoData; - if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) - sfoFile.ReadSFO(sfoData); - } + std::shared_ptr sfoFile = LoadCachedSFO(sfopath, true); // Update values - sfoFile.SetValue("TITLE",param->sfoParam.title,128); - sfoFile.SetValue("SAVEDATA_TITLE",param->sfoParam.savedataTitle,128); - sfoFile.SetValue("SAVEDATA_DETAIL",param->sfoParam.detail,1024); - sfoFile.SetValue("PARENTAL_LEVEL",param->sfoParam.parentalLevel,4); - sfoFile.SetValue("CATEGORY","MS",4); - sfoFile.SetValue("SAVEDATA_DIRECTORY", GetSaveDir(param, saveDirName), 64); + sfoFile->SetValue("TITLE", param->sfoParam.title, 128); + sfoFile->SetValue("SAVEDATA_TITLE", param->sfoParam.savedataTitle, 128); + sfoFile->SetValue("SAVEDATA_DETAIL", param->sfoParam.detail, 1024); + sfoFile->SetValue("PARENTAL_LEVEL", param->sfoParam.parentalLevel, 4); + sfoFile->SetValue("CATEGORY", "MS", 4); + sfoFile->SetValue("SAVEDATA_DIRECTORY", GetSaveDir(param, saveDirName), 64); // Always write and update the file list. // For each file, 13 bytes for filename, 16 bytes for file hash (0 in PPSSPP), 3 byte for padding const int FILE_LIST_COUNT_MAX = 99; const u32 FILE_LIST_TOTAL_SIZE = sizeof(SaveSFOFileListEntry) * FILE_LIST_COUNT_MAX; u32 tmpDataSize = 0; - SaveSFOFileListEntry *tmpDataOrig = (SaveSFOFileListEntry *)sfoFile.GetValueData("SAVEDATA_FILE_LIST", &tmpDataSize); + SaveSFOFileListEntry *tmpDataOrig = (SaveSFOFileListEntry *)sfoFile->GetValueData("SAVEDATA_FILE_LIST", &tmpDataSize); SaveSFOFileListEntry *updatedList = new SaveSFOFileListEntry[FILE_LIST_COUNT_MAX]; if (tmpDataSize != 0) memcpy(updatedList, tmpDataOrig, std::min(tmpDataSize, FILE_LIST_TOTAL_SIZE)); @@ -497,28 +494,30 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD } } - sfoFile.SetValue("SAVEDATA_FILE_LIST", (u8 *)updatedList, FILE_LIST_TOTAL_SIZE, (int)FILE_LIST_TOTAL_SIZE); + sfoFile->SetValue("SAVEDATA_FILE_LIST", (u8 *)updatedList, FILE_LIST_TOTAL_SIZE, (int)FILE_LIST_TOTAL_SIZE); delete[] updatedList; // Init param with 0. This will be used to detect crypted save or not on loading u8 *tmpData = new u8[128]; memset(tmpData, 0, 128); - sfoFile.SetValue("SAVEDATA_PARAMS", tmpData, 128, 128); + sfoFile->SetValue("SAVEDATA_PARAMS", tmpData, 128, 128); delete[] tmpData; u8 *sfoData; size_t sfoSize; - sfoFile.WriteSFO(&sfoData,&sfoSize); + sfoFile->WriteSFO(&sfoData, &sfoSize); // Calc SFO hash for PSP. - if(cryptedData != 0) - { - int offset = sfoFile.GetDataOffset(sfoData,"SAVEDATA_PARAMS"); + if (cryptedData != 0) { + int offset = sfoFile->GetDataOffset(sfoData, "SAVEDATA_PARAMS"); if(offset >= 0) UpdateHash(sfoData, (int)sfoSize, offset, DetermineCryptMode(param)); } + + ClearCaches(); WritePSPFile(sfopath, sfoData, (SceSize)sfoSize); delete[] sfoData; + sfoData = nullptr; if(param->dataBuf.IsValid()) // Can launch save without save data in mode 13 { @@ -804,38 +803,31 @@ u32 SavedataParam::LoadNotCryptedSave(SceUtilitySavedataParam *param, u8 *data, } bool SavedataParam::LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath) { - ParamSFOData sfoFile; std::string sfopath = dirPath + "/" + SFO_FILENAME; - std::vector sfoData; - if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) { - sfoFile.ReadSFO(sfoData); - + std::shared_ptr sfoFile = LoadCachedSFO(sfopath); + if (sfoFile) { // copy back info in request - strncpy(param->sfoParam.title,sfoFile.GetValueString("TITLE").c_str(),128); - strncpy(param->sfoParam.savedataTitle,sfoFile.GetValueString("SAVEDATA_TITLE").c_str(),128); - strncpy(param->sfoParam.detail,sfoFile.GetValueString("SAVEDATA_DETAIL").c_str(),1024); - param->sfoParam.parentalLevel = sfoFile.GetValueInt("PARENTAL_LEVEL"); + strncpy(param->sfoParam.title, sfoFile->GetValueString("TITLE").c_str(), 128); + strncpy(param->sfoParam.savedataTitle, sfoFile->GetValueString("SAVEDATA_TITLE").c_str(), 128); + strncpy(param->sfoParam.detail, sfoFile->GetValueString("SAVEDATA_DETAIL").c_str(), 1024); + param->sfoParam.parentalLevel = sfoFile->GetValueInt("PARENTAL_LEVEL"); return true; - } else { - return false; } + return false; } std::vector SavedataParam::GetSFOEntries(const std::string &dirPath) { std::vector result; const std::string sfoPath = dirPath + "/" + SFO_FILENAME; - ParamSFOData sfoFile; - std::vector sfoData; - if (pspFileSystem.ReadEntireFile(sfoPath, sfoData) >= 0) { - sfoFile.ReadSFO(sfoData); - } else { + std::shared_ptr sfoFile = LoadCachedSFO(sfoPath); + if (!sfoFile) { return result; } const int FILE_LIST_COUNT_MAX = 99; u32 sfoFileListSize = 0; - SaveSFOFileListEntry *sfoFileList = (SaveSFOFileListEntry *)sfoFile.GetValueData("SAVEDATA_FILE_LIST", &sfoFileListSize); + SaveSFOFileListEntry *sfoFileList = (SaveSFOFileListEntry *)sfoFile->GetValueData("SAVEDATA_FILE_LIST", &sfoFileListSize); const u32 count = std::min((u32)FILE_LIST_COUNT_MAX, sfoFileListSize / (u32)sizeof(SaveSFOFileListEntry)); for (u32 i = 0; i < count; ++i) { @@ -1292,6 +1284,7 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr) requestPtr->bind = 1021; // Does not list directories, nor recurse into them, and ignores files not ALL UPPERCASE. + bool isCrypted = GetSaveCryptMode(param, GetSaveDirName(param, 0)) != 0; for (auto file = files.begin(), end = files.end(); file != end; ++file) { if (file->type == FILETYPE_DIRECTORY) { continue; @@ -1316,7 +1309,6 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr) entry = &fileList->secureEntries[fileList->resultNumSecureEntries++]; } // Secure files are slightly bigger. - bool isCrypted = GetSaveCryptMode(param, GetSaveDirName(param, 0)) != 0; if (isCrypted) { sizeOffset = -0x10; } @@ -1605,15 +1597,12 @@ void SavedataParam::SetFileInfo(SaveFileInfo &saveInfo, PSPFileInfo &info, std:: } // Load info in PARAM.SFO - std::vector sfoData; std::string sfoFilename = savePath + saveDir + "/" + SFO_FILENAME; - if (pspFileSystem.ReadEntireFile(sfoFilename, sfoData) >= 0) { - ParamSFOData sfoFile; - if (sfoFile.ReadSFO(sfoData)) { - SetStringFromSFO(sfoFile, "TITLE", saveInfo.title, sizeof(saveInfo.title)); - SetStringFromSFO(sfoFile, "SAVEDATA_TITLE", saveInfo.saveTitle, sizeof(saveInfo.saveTitle)); - SetStringFromSFO(sfoFile, "SAVEDATA_DETAIL", saveInfo.saveDetail, sizeof(saveInfo.saveDetail)); - } + std::shared_ptr sfoFile = LoadCachedSFO(sfoFilename); + if (sfoFile) { + SetStringFromSFO(*sfoFile, "TITLE", saveInfo.title, sizeof(saveInfo.title)); + SetStringFromSFO(*sfoFile, "SAVEDATA_TITLE", saveInfo.saveTitle, sizeof(saveInfo.saveTitle)); + SetStringFromSFO(*sfoFile, "SAVEDATA_DETAIL", saveInfo.saveDetail, sizeof(saveInfo.saveDetail)); } else { saveInfo.broken = true; truncate_cpy(saveInfo.title, saveDir.c_str()); @@ -1887,17 +1876,42 @@ void SavedataParam::DoState(PointerWrap &p) { } } +void SavedataParam::ClearCaches() { + std::lock_guard guard(cacheLock_); + sfoCache_.clear(); +} + +std::shared_ptr SavedataParam::LoadCachedSFO(const std::string &path, bool orCreate) { + std::lock_guard guard(cacheLock_); + if (sfoCache_.find(path) == sfoCache_.end()) { + std::vector data; + if (pspFileSystem.ReadEntireFile(path, data) < 0) { + // Mark as not existing for later. + sfoCache_[path].reset(); + } else { + sfoCache_.emplace(path, new ParamSFOData()); + // If it fails to load, also keep it to indicate failed. + if (!sfoCache_.at(path)->ReadSFO(data)) + sfoCache_.at(path).reset(); + } + } + + if (!sfoCache_.at(path)) { + if (!orCreate) + return nullptr; + sfoCache_.at(path).reset(new ParamSFOData()); + } + return sfoCache_.at(path); +} + int SavedataParam::GetSaveCryptMode(SceUtilitySavedataParam *param, const std::string &saveDirName) { - ParamSFOData sfoFile; std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName)); std::string sfopath = dirPath + "/" + SFO_FILENAME; - std::vector sfoData; - if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) { - sfoFile.ReadSFO(sfoData); - + std::shared_ptr sfoFile = LoadCachedSFO(sfopath); + if (sfoFile) { // save created in PPSSPP and not encrypted has '0' in SAVEDATA_PARAMS u32 tmpDataSize = 0; - const u8 *tmpDataOrig = sfoFile.GetValueData("SAVEDATA_PARAMS", &tmpDataSize); + const u8 *tmpDataOrig = sfoFile->GetValueData("SAVEDATA_PARAMS", &tmpDataSize); if (tmpDataSize == 0 || !tmpDataOrig) { return 0; } diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index aa157511c6..65a1ac5cd1 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -17,8 +17,12 @@ #pragma once +#include +#include #include +#include #include "Common/CommonTypes.h" +#include "Core/ELF/ParamSFO.h" #include "Core/MemMap.h" #include "Core/HLE/sceRtc.h" #include "Core/Dialog/PSPDialog.h" @@ -351,6 +355,8 @@ public: bool wouldHasMultiSaveName(SceUtilitySavedataParam* param); + void ClearCaches(); + void DoState(PointerWrap &p); private: @@ -376,6 +382,8 @@ private: std::set GetSecureFileNames(const std::string &dirPath); bool GetExpectedHash(const std::string &dirPath, const std::string &filename, u8 hash[16]); + std::shared_ptr LoadCachedSFO(const std::string &path, bool orCreate = false); + SceUtilitySavedataParam* pspParam = nullptr; int selectedSave = 0; SaveFileInfo *saveDataList = nullptr; @@ -383,4 +391,8 @@ private: int saveDataListCount = 0; int saveNameListDataCount = 0; bool ignoreTextures_ = false; + + // Cleared before returning to PSP, no need to save state. + std::mutex cacheLock_; + std::unordered_map> sfoCache_; }; From bad4a93d3c2ca8a2e1b9119b6b6177e11e44ad05 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 15:50:50 -0700 Subject: [PATCH 099/374] D3D11: Correct depth readback. --- Common/GPU/D3D11/thin3d_d3d11.cpp | 36 +++++++++++++++++-------- GPU/Common/FramebufferManagerCommon.cpp | 2 +- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 166a0ebe66..3b9837fbe1 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -1509,7 +1509,7 @@ bool D3D11DrawContext::BlitFramebuffer(Framebuffer *srcfb, int srcX1, int srcY1, return false; } -bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int bx, int by, int bw, int bh, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) { +bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int bx, int by, int bw, int bh, Draw::DataFormat destFormat, void *pixels, int pixelStride, const char *tag) { D3D11Framebuffer *fb = (D3D11Framebuffer *)src; if (fb) { @@ -1569,15 +1569,18 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel } D3D11_BOX srcBox{ (UINT)bx, (UINT)by, 0, (UINT)(bx + bw), (UINT)(by + bh), 1 }; + DataFormat srcFormat = DataFormat::UNDEFINED; switch (channelBits) { case FB_COLOR_BIT: context_->CopySubresourceRegion(packTex, 0, bx, by, 0, fb ? fb->colorTex : bbRenderTargetTex_, 0, &srcBox); + srcFormat = DataFormat::R8G8B8A8_UNORM; break; case FB_DEPTH_BIT: case FB_STENCIL_BIT: // For depth/stencil buffers, we can't reliably copy subrectangles, so just copy the whole resource. _assert_(fb); // Can't copy depth/stencil from backbuffer. Shouldn't happen thanks to checks above. context_->CopyResource(packTex, fb->depthStencilTex); + srcFormat = Draw::DataFormat::D24_S8; break; default: _assert_(false); @@ -1594,26 +1597,37 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel return false; } - const int srcByteOffset = by * map.RowPitch + bx * 4; + const size_t srcByteOffset = by * map.RowPitch + bx * DataFormatSizeInBytes(srcFormat); + const uint8_t *srcWithOffset = (const uint8_t *)map.pData + srcByteOffset; switch (channelBits) { case FB_COLOR_BIT: // Pixel size always 4 here because we always request BGRA8888. - ConvertFromRGBA8888((uint8_t *)pixels, (uint8_t *)map.pData + srcByteOffset, pixelStride, map.RowPitch / sizeof(uint32_t), bw, bh, format); + ConvertFromRGBA8888((uint8_t *)pixels, srcWithOffset, pixelStride, map.RowPitch / sizeof(uint32_t), bw, bh, destFormat); break; case FB_DEPTH_BIT: - for (int y = by; y < by + bh; y++) { - float *dest = (float *)((uint8_t *)pixels + y * pixelStride * sizeof(float)); - const uint32_t *src = (const uint32_t *)((const uint8_t *)map.pData + map.RowPitch * y); - for (int x = bx; x < bx + bw; x++) { - dest[x] = (src[x] & 0xFFFFFF) / (256.f * 256.f * 256.f); + if (srcFormat == destFormat) { + // Can just memcpy when it matches no matter the format! + uint8_t *dst = (uint8_t *)pixels; + const uint8_t *src = (const uint8_t *)srcWithOffset; + for (int y = 0; y < bh; ++y) { + memcpy(dst, src, bw * DataFormatSizeInBytes(srcFormat)); + dst += pixelStride * DataFormatSizeInBytes(srcFormat); + src += map.RowPitch; } + } else if (destFormat == DataFormat::D32F) { + ConvertToD32F((uint8_t *)pixels, srcWithOffset, pixelStride, map.RowPitch / sizeof(uint32_t), bw, bh, srcFormat); + } else if (destFormat == DataFormat::D16) { + ConvertToD16((uint8_t *)pixels, srcWithOffset, pixelStride, map.RowPitch / sizeof(uint32_t), bw, bh, srcFormat); + } else { + _assert_(false); } break; case FB_STENCIL_BIT: - for (int y = by; y < by + bh; y++) { + _assert_(destFormat == DataFormat::S8); + for (int y = 0; y < bh; y++) { uint8_t *destStencil = (uint8_t *)pixels + y * pixelStride; - const uint32_t *src = (const uint32_t *)((const uint8_t *)map.pData + map.RowPitch * y); - for (int x = bx; x < bx + bw; x++) { + const uint32_t *src = (const uint32_t *)(srcWithOffset + map.RowPitch * y); + for (int x = 0; x < bw; x++) { destStencil[x] = src[x] >> 24; } } diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 4266701083..f6e66efd98 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2649,7 +2649,7 @@ void FramebufferManagerCommon::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, Draw::DataFormat destFormat = GEFormatToThin3D(GE_FORMAT_DEPTH16); const int dstByteOffset = (y * vfb->z_stride + x) * 2; u8 *destPtr = Memory::GetPointerWriteUnchecked(vfb->z_address + dstByteOffset); - if (!draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "ReadbackDepthbufferSync")) { + if (!draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->z_stride, "ReadbackDepthbufferSync")) { WARN_LOG(G3D, "ReadbackDepthbufferSync failed"); } } From 4ecdce2a379fb429c4dc3d7de02d148a2aeff0f0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 16:38:33 -0700 Subject: [PATCH 100/374] Loader: Validate offsets and truncation in ELF. --- Core/ELF/ElfReader.cpp | 45 ++++++++++++++++++++++++++++++++++++------ Core/ELF/ElfReader.h | 18 ++++++++++++----- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index 980e427e83..513786d0d6 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -34,9 +34,10 @@ const char *ElfReader::GetSectionName(int section) const { if (sections[section].sh_type == SHT_NULL) return nullptr; + int stringsOffset = GetSectionDataOffset(header->e_shstrndx); int nameOffset = sections[section].sh_name; - if (nameOffset < 0 || (size_t)nameOffset >= size_) { - ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d (max = %d)", nameOffset, section, (int)size_); + if (nameOffset < 0 || (size_t)nameOffset + stringsOffset >= size_) { + ERROR_LOG(LOADER, "ELF: Bad name offset %d + %d in section %d (max = %d)", nameOffset, stringsOffset, section, (int)size_); return nullptr; } const char *ptr = (const char *)GetSectionDataPtr(header->e_shstrndx); @@ -235,6 +236,10 @@ void ElfReader::LoadRelocations2(int rel_seg) const Elf32_Phdr *ph = segments + rel_seg; buf = (u8*)GetSegmentPtr(rel_seg); + if (!buf) { + ERROR_LOG(LOADER, "Rel2 segment invalid"); + return; + } end = buf+ph->p_filesz; flag_bits = buf[2]; @@ -383,6 +388,12 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) { DEBUG_LOG(LOADER,"String section: %i", header->e_shstrndx); + if (size_ < sizeof(Elf32_Ehdr)) { + ERROR_LOG(LOADER, "Truncated ELF header, %d bytes", (int)size_); + // Probably not the right error code. + return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + } + if (header->e_ident[0] != ELFMAG0 || header->e_ident[1] != ELFMAG1 || header->e_ident[2] != ELFMAG2 || header->e_ident[3] != ELFMAG3) return SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE; @@ -399,6 +410,12 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) if (header->e_ident[EI_DATA] != ELFDATA2LSB) return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + if (size_ < header->e_phoff + sizeof(Elf32_Phdr) * GetNumSegments() || size_ < header->e_shoff + sizeof(Elf32_Shdr) * GetNumSections()) { + ERROR_LOG(LOADER, "Truncated ELF, %d bytes with %d sections and %d segments", (int)size_, GetNumSections(), GetNumSegments()); + // Probably not the right error code. + return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + } + // e_ident[EI_VERSION] is ignored sectionOffsets = new u32[GetNumSections()]; @@ -412,11 +429,11 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) for (int i = 0; i < GetNumSections(); i++) { const Elf32_Shdr *s = §ions[i]; const char *name = GetSectionName(i); - if (name && !strcmp(name, ".rodata.sceModuleInfo")) { + if (name && !strcmp(name, ".rodata.sceModuleInfo") && s->sh_offset + sizeof(PspModuleInfo) <= size_) { modInfo = (const PspModuleInfo *)GetPtr(s->sh_offset); } } - if (!modInfo && GetNumSegments() >= 1) { + if (!modInfo && GetNumSegments() >= 1 && (segments[0].p_paddr & 0x7FFFFFFF) + sizeof(PspModuleInfo) <= size_) { modInfo = (const PspModuleInfo *)GetPtr(segments[0].p_paddr & 0x7FFFFFFF); } @@ -493,6 +510,10 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) u32 writeAddr = segmentVAddr[i]; const u8 *src = GetSegmentPtr(i); + if (!src || p->p_offset + p->p_filesz > size_) { + ERROR_LOG(LOADER, "Segment %d pointer invalid - truncated?", i); + continue; + } u8 *dst = Memory::GetPointerWrite(writeAddr); u32 srcSize = p->p_filesz; u32 dstSize = p->p_memsz; @@ -557,9 +578,11 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) int numRelocs = s->sh_size / sizeof(Elf32_Rel); Elf32_Rel *rels = (Elf32_Rel *)GetSectionDataPtr(i); + if (GetSectionDataOffset(i) + sizeof(Elf32_Rel) * numRelocs > size_) + rels = nullptr; DEBUG_LOG(LOADER,"%s: Performing %i relocations on %s : offset = %08x", name, numRelocs, GetSectionName(sectionToModify), sections[i].sh_offset); - if (!LoadRelocations(rels, numRelocs)) { + if (!rels || !LoadRelocations(rels, numRelocs)) { WARN_LOG(LOADER, "LoadInto: Relocs failed, trying anyway"); } } @@ -607,7 +630,9 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) int numRelocs = p->p_filesz / sizeof(Elf32_Rel); Elf32_Rel *rels = (Elf32_Rel *)GetSegmentPtr(i); - if (!LoadRelocations(rels, numRelocs)) { + if (p->p_offset + p->p_filesz > size_) + rels = nullptr; + if (!rels || !LoadRelocations(rels, numRelocs)) { ERROR_LOG(LOADER, "LoadInto: Relocs failed, trying anyway (2)"); } } else if (p->p_type == PT_PSPREL2) { @@ -695,11 +720,17 @@ bool ElfReader::LoadSymbols() int stringSection = sections[sec].sh_link; const char *stringBase = (const char*)GetSectionDataPtr(stringSection); + u32 stringOffset = GetSectionDataOffset(stringSection); //We have a symbol table! Elf32_Sym *symtab = (Elf32_Sym *)(GetSectionDataPtr(sec)); + u32 symtabOffset = GetSectionDataOffset(sec); int numSymbols = sections[sec].sh_size / sizeof(Elf32_Sym); + if (!stringBase || !symtab || symtabOffset + sections[sec].sh_size > size_) { + ERROR_LOG(LOADER, "Symbols truncated - ignoring"); + return false; + } for (int sym = 0; sym= size_) + continue; if (bRelocate) value += sectionAddrs[sectionIndex]; diff --git a/Core/ELF/ElfReader.h b/Core/ELF/ElfReader.h index 0284b56bd4..9dcde2980a 100644 --- a/Core/ELF/ElfReader.h +++ b/Core/ELF/ElfReader.h @@ -77,15 +77,23 @@ public: const u8 *GetPtr(u32 offset) const { return (const u8*)base + offset; } - const u8 *GetSectionDataPtr(int section) const { + // Note: zero is not a valid output, means unavailable. + u32 GetSectionDataOffset(int section) const { if (section < 0 || section >= header->e_shnum) + return 0; + if (sections[section].sh_type == SHT_NOBITS) + return 0; + return sections[section].sh_offset; + } + const u8 *GetSectionDataPtr(int section) const { + u32 offset = GetSectionDataOffset(section); + if (offset == 0 || offset > size_) return nullptr; - if (sections[section].sh_type != SHT_NOBITS) - return GetPtr(sections[section].sh_offset); - else - return nullptr; + return GetPtr(offset); } const u8 *GetSegmentPtr(int segment) const { + if (segments[segment].p_offset > size_) + return nullptr; return GetPtr(segments[segment].p_offset); } u32 GetSectionAddr(SectionID section) const { From 7e462c087c7984b8032cb725c284360a17591258 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 16:42:05 -0700 Subject: [PATCH 101/374] Loader: Get rid of overalloc on module exec. --- Core/HLE/sceKernelModule.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index db190c45f7..a482395a73 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1159,12 +1159,14 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load if (*magicPtr == 0x4543537e) { // "~SCE" INFO_LOG(SCEMODULE, "~SCE module, skipping header"); u32 headerSize = *(u32_le*)(ptr + 4); - ptr += headerSize; - elfSize -= headerSize; - magicPtr = (u32_le *)ptr; + if (headerSize < elfSize) { + ptr += headerSize; + elfSize -= headerSize; + magicPtr = (u32_le *)ptr; + } } *magic = *magicPtr; - if (*magic == 0x5053507e) { // "~PSP" + if (*magic == 0x5053507e && elfSize > sizeof(PSP_Header)) { // "~PSP" DEBUG_LOG(SCEMODULE, "Decrypting ~PSP file"); PSP_Header *head = (PSP_Header*)ptr; devkitVersion = head->devkitversion; @@ -1650,19 +1652,23 @@ SceUID KernelLoadModule(const std::string &filename, std::string *error_string) static PSPModule *__KernelLoadModule(u8 *fileptr, size_t fileSize, SceKernelLMOption *options, std::string *error_string) { PSPModule *module = nullptr; // Check for PBP - if (memcmp(fileptr, "\0PBP", 4) == 0) { + if (fileSize >= sizeof(PSP_Header) && memcmp(fileptr, "\0PBP", 4) == 0) { // PBP! u32_le version; memcpy(&version, fileptr + 4, 4); u32_le offset0, offsets[16]; memcpy(&offset0, fileptr + 8, 4); - int numfiles = (offset0 - 8)/4; + int numfiles = (offset0 - 8) / 4; offsets[0] = offset0; + if (12 + 4 * numfiles > fileSize) { + *error_string = "ELF file truncated - can't load"; + return nullptr; + } for (int i = 1; i < numfiles; i++) memcpy(&offsets[i], fileptr + 12 + 4*i, 4); - if (offsets[6] > fileSize) { + if (offsets[6] > fileSize || offsets[5] > offsets[6]) { // File is too small to fully contain the ELF! Must have been truncated. *error_string = "ELF file truncated - can't load"; return nullptr; @@ -1685,10 +1691,13 @@ static PSPModule *__KernelLoadModule(u8 *fileptr, size_t fileSize, SceKernelLMOp if (temp) { delete [] temp; } - } else { + } else if (fileSize > sizeof(PSP_Header)) { u32 error; u32 magic = 0; module = __KernelLoadELFFromPtr(fileptr, fileSize, PSP_GetDefaultLoadAddress(), false, error_string, &magic, error); + } else { + *error_string = "ELF file truncated - can't load"; + return nullptr; } return module; @@ -1801,8 +1810,6 @@ bool __KernelLoadExec(const char *filename, u32 paramPtr, std::string *error_str PSP_SetLoading("Loading modules..."); size_t size = fileData.size(); - // TODO: Why do we add this padding? Crash avoidance? - fileData.resize(fileData.size() + 0x01000000); PSPModule *module = __KernelLoadModule(fileData.data(), size, 0, error_string); if (!module || module->isFake) { From 4d5e6f53bb16c41afd5aaa6a046515fbba97a2c7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 21:25:20 -0700 Subject: [PATCH 102/374] GE Debugger: Reset on shutdown. Previously, it kept showing the last frame, which made it seem like it was still stepping. --- Windows/GEDebugger/GEDebugger.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 59e8fb018d..43797e9dcd 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -1067,6 +1067,8 @@ BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { UpdatePreviews(); lastCounter = GPUStepping::GetSteppingCounter(); } + } else if (!PSP_IsInited() && primaryBuffer_) { + SendMessage(m_hDlg, WM_COMMAND, IDC_GEDBG_RESUME, 0); } break; From 825450a373e3f09a0a4cce32921ddd82b137eafd Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 21:26:13 -0700 Subject: [PATCH 103/374] jit: Defer invalidations made while running. Previously, invalidating icache could happen while running, which might cause the CPU to return into outer space. This runs such invalidations after letting the CPU exit. It was easy to trigger this with the debugger: step using the GE debugger, add a CPU memory breakpoint, then resume from the GE debugger. However, cheats and the like could cause similar issues. --- Core/Debugger/Breakpoints.cpp | 15 +++++-------- Core/MIPS/MIPS.cpp | 42 +++++++++++++++++++++++++++++++---- Core/MIPS/MIPS.h | 7 ++++++ Core/MIPS/MIPSAsm.cpp | 4 +--- 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index 715f18cbf1..ad1d37e41d 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -648,16 +648,11 @@ void CBreakPoints::Update(u32 addr) { resume = true; } - { - std::lock_guard guard(MIPSComp::jitLock); - if (MIPSComp::jit) { - // In case this is a delay slot, clear the previous instruction too. - if (addr != 0) - MIPSComp::jit->InvalidateCacheAt(addr - 4, 8); - else - MIPSComp::jit->ClearCache(); - } - } + // In case this is a delay slot, clear the previous instruction too. + if (addr != 0) + mipsr4k.InvalidateICache(addr - 4, 8); + else + mipsr4k.ClearJitCache(); if (resume) Core_EnableStepping(false); diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 08958c14c6..5aeeacbbf8 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "Common/Math/math_util.h" @@ -334,7 +335,11 @@ int MIPSState::RunLoopUntil(u64 globalTicks) { // We must get out of the delay slot before going into jit. SingleStep(); } + insideJit = true; + if (hasPendingClears) + ProcessPendingClears(); MIPSComp::jit->RunLoopUntil(globalTicks); + insideJit = false; break; case CPUCore::INTERPRETER: @@ -343,15 +348,44 @@ int MIPSState::RunLoopUntil(u64 globalTicks) { return 1; } +// Kept outside MIPSState to avoid header pollution (MIPS.h doesn't even have vector, and is used widely.) +static std::vector> pendingClears; + +void MIPSState::ProcessPendingClears() { + std::lock_guard guard(MIPSComp::jitLock); + for (auto &p : pendingClears) { + if (p.first == 0 && p.second == 0) + MIPSComp::jit->ClearCache(); + else + MIPSComp::jit->InvalidateCacheAt(p.first, p.second); + } + pendingClears.clear(); + hasPendingClears = false; +} + void MIPSState::InvalidateICache(u32 address, int length) { // Only really applies to jit. std::lock_guard guard(MIPSComp::jitLock); - if (MIPSComp::jit) - MIPSComp::jit->InvalidateCacheAt(address, length); + if (MIPSComp::jit) { + if (coreState == CORE_RUNNING || insideJit) { + pendingClears.emplace_back(address, length); + hasPendingClears = true; + CoreTiming::ForceCheck(); + } else { + MIPSComp::jit->InvalidateCacheAt(address, length); + } + } } void MIPSState::ClearJitCache() { std::lock_guard guard(MIPSComp::jitLock); - if (MIPSComp::jit) - MIPSComp::jit->ClearCache(); + if (MIPSComp::jit) { + if (coreState == CORE_RUNNING || insideJit) { + pendingClears.emplace_back(0, 0); + hasPendingClears = true; + CoreTiming::ForceCheck(); + } else { + MIPSComp::jit->ClearCache(); + } + } } diff --git a/Core/MIPS/MIPS.h b/Core/MIPS/MIPS.h index 1bab17031f..d2f4a4ba54 100644 --- a/Core/MIPS/MIPS.h +++ b/Core/MIPS/MIPS.h @@ -266,6 +266,13 @@ public: void InvalidateICache(u32 address, int length = 4); void ClearJitCache(); + +protected: + void ProcessPendingClears(); + + // Doesn't need save stating. + volatile bool insideJit = false; + volatile bool hasPendingClears = false; }; diff --git a/Core/MIPS/MIPSAsm.cpp b/Core/MIPS/MIPSAsm.cpp index 1c45f14ac5..efecdac2e6 100644 --- a/Core/MIPS/MIPSAsm.cpp +++ b/Core/MIPS/MIPSAsm.cpp @@ -40,9 +40,7 @@ public: Memory::Memcpy((u32)address, data, (u32)length, "Debugger"); // In case this is a delay slot or combined instruction, clear cache above it too. - std::lock_guard guard(MIPSComp::jitLock); - if (MIPSComp::jit) - MIPSComp::jit->InvalidateCacheAt((u32)(address - 4),(int)length+4); + mipsr4k.InvalidateICache((u32)(address - 4), (int)length + 4); address += length; return true; From 6a5824031dba1d758e25a7d656877dfc0d11be28 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 21:42:04 -0700 Subject: [PATCH 104/374] Windows: Retain log console on graphics restart. It's a small thing but I always use -l and it annoys me when I restart. --- Windows/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Windows/main.cpp b/Windows/main.cpp index 90e216f283..6584f0cf65 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -132,6 +132,11 @@ void Vibrate(int length_ms) { // Ignore on PC } +static void AddDebugRestartArgs() { + if (LogManager::GetInstance()->GetConsoleListener()->IsOpen()) + restartArgs += " -l"; +} + // Adapted mostly as-is from http://www.gamedev.net/topic/495075-how-to-retrieve-info-about-videocard/?view=findpost&p=4229170 // so credit goes to that post's author, and in turn, the author of the site mentioned in that post (which seems to be down?). std::string GetVideoCardDriverVersion() { @@ -352,6 +357,8 @@ void System_SendMessage(const char *command, const char *parameter) { } } else if (!strcmp(command, "graphics_restart")) { restartArgs = parameter == nullptr ? "" : parameter; + if (!restartArgs.empty()) + AddDebugRestartArgs(); if (IsDebuggerPresent()) { PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_RESTART_EMUTHREAD, 0, 0); } else { From c2da29392c51d4a1772b1d9e1fb43b0c90e57179 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 24 Dec 2018 16:29:13 -0800 Subject: [PATCH 105/374] GLES: Depth download cleanup. --- GPU/GLES/DepthBufferGLES.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index f76d133564..0a3178cfe7 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -52,7 +52,6 @@ void main() { vec4 enc = u_depthShift * clamped; enc = floor(mod(enc, 256.0)) * u_depthTo8; - enc = enc * u_depthTo8; // Let's ignore the bits outside 16 bit precision. gl_FragColor = enc.yzww; } @@ -75,11 +74,22 @@ void main() { } )"; +static bool SupportsDepthTexturing() { + if (gl_extensions.IsGLES) { + return gl_extensions.OES_packed_depth_stencil && (gl_extensions.OES_depth_texture || gl_extensions.GLES3); + } + return gl_extensions.VersionGEThan(3, 0); +} + void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { if (!vfb->fbo) { ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackDepthbufferSync: vfb->fbo == 0"); return; } + // Old desktop GL can download depth, but not upload. + if (gl_extensions.IsGLES && !SupportsDepthTexturing()) { + return; + } // Pixel size always 4 here because we always request float const u32 bufSize = vfb->z_stride * (h - y) * 4; From 93346d6e2c479cd0e1a3df161d9c2b4d0b008614 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 23:15:12 -0700 Subject: [PATCH 106/374] GLES: Refactor depth shader download. This makes it similar to the Draw interface. --- GPU/GLES/DepthBufferGLES.cpp | 80 +++++++++++++++++-------------- GPU/GLES/FramebufferManagerGLES.h | 1 + 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 0a3178cfe7..ff9582ac82 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -86,24 +86,35 @@ void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, in ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackDepthbufferSync: vfb->fbo == 0"); return; } + + const u32 z_address = vfb->z_address; + DEBUG_LOG(FRAMEBUF, "Reading depthbuffer to mem at %08x for vfb=%08x", z_address, vfb->fb_address); + + int dstByteOffset = y * vfb->z_stride * sizeof(u16); + u16 *depth = (u16 *)Memory::GetPointer(z_address + dstByteOffset); + ReadbackDepthbufferSync(vfb->fbo, x, y, w, h, depth, vfb->z_stride); + + gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); +} + +void FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { + if (!fbo) { + ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackDepthbufferSync: bad fbo"); + return; + } // Old desktop GL can download depth, but not upload. if (gl_extensions.IsGLES && !SupportsDepthTexturing()) { return; } - // Pixel size always 4 here because we always request float - const u32 bufSize = vfb->z_stride * (h - y) * 4; - const u32 z_address = vfb->z_address; - const int packWidth = std::min((int)vfb->z_stride, std::min(x + w, (int)vfb->width)); - + // Pixel size always 4 here because we always request float or RGBA. + const u32 bufSize = w * h * 4; if (!convBuf_ || convBufSize_ < bufSize) { delete[] convBuf_; convBuf_ = new u8[bufSize]; convBufSize_ = bufSize; } - DEBUG_LOG(FRAMEBUF, "Reading depthbuffer to mem at %08x for vfb=%08x", z_address, vfb->fb_address); - const bool useColorPath = gl_extensions.IsGLES; bool format16Bit = false; @@ -139,12 +150,12 @@ void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, in } shaderManager_->DirtyLastShader(); - auto *blitFBO = GetTempFBO(TempFBO::COPY, vfb->renderWidth, vfb->renderHeight); + auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); - render->SetViewport({ 0, 0, (float)vfb->renderWidth, (float)vfb->renderHeight, 0.0f, 1.0f }); + render->SetViewport({ 0, 0, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }); // We must bind the program after starting the render pass, and set the color mask after clearing. - render->SetScissor({ 0, 0, vfb->renderWidth, vfb->renderHeight }); + render->SetScissor({ 0, 0, fbo->Width(), fbo->Height() }); render->SetDepth(false, false, GL_ALWAYS); render->SetRaster(false, GL_CCW, GL_FRONT, GL_FALSE, GL_FALSE); render->BindProgram(depthDownloadProgram_); @@ -162,54 +173,51 @@ void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, in float to8[] = { 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f }; render->SetUniformF(&u_depthDownloadTo8, 4, to8); - draw_->BindFramebufferAsTexture(vfb->fbo, TEX_SLOT_PSP_TEXTURE, Draw::FB_DEPTH_BIT, 0); + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, Draw::FB_DEPTH_BIT, 0); float u1 = 1.0f; float v1 = 1.0f; - DrawActiveTexture(x, y, w, h, vfb->renderWidth, vfb->renderHeight, 0.0f, 0.0f, u1, v1, ROTATION_LOCKED_HORIZONTAL, DRAWTEX_NEAREST); + DrawActiveTexture(x, y, w, h, fbo->Width(), fbo->Height(), 0.0f, 0.0f, u1, v1, ROTATION_LOCKED_HORIZONTAL, DRAWTEX_NEAREST); - draw_->CopyFramebufferToMemorySync(blitFBO, Draw::FB_COLOR_BIT, 0, y, packWidth, h, Draw::DataFormat::R8G8B8A8_UNORM, convBuf_, vfb->z_stride, "ReadbackDepthbufferSync"); + draw_->CopyFramebufferToMemorySync(blitFBO, Draw::FB_COLOR_BIT, x, y, w, h, Draw::DataFormat::R8G8B8A8_UNORM, convBuf_, w, "ReadbackDepthbufferSync"); textureCache_->ForgetLastTexture(); - // TODO: Use 4444 so we can copy lines directly? + // TODO: Use 4444 so we can copy lines directly (instead of 32 -> 16 on CPU)? format16Bit = true; } else { - draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, 0, y, packWidth, h, Draw::DataFormat::D32F, convBuf_, vfb->z_stride, "ReadbackDepthbufferSync"); + draw_->CopyFramebufferToMemorySync(fbo, Draw::FB_DEPTH_BIT, x, y, w, h, Draw::DataFormat::D32F, convBuf_, w, "ReadbackDepthbufferSync"); format16Bit = false; } - int dstByteOffset = y * vfb->z_stride * sizeof(u16); - u16 *depth = (u16 *)Memory::GetPointer(z_address + dstByteOffset); - u32_le *packed32 = (u32_le *)convBuf_; - GLfloat *packedf = (GLfloat *)convBuf_; - - int totalPixels = h == 1 ? packWidth : vfb->z_stride * h; if (format16Bit) { - // TODO: We have to apply GetDepthScaleFactors here too, right? + // In this case, we used the shader to apply depth scale factors. + uint16_t *dest = pixels; + const u32_le *packed32 = (u32_le *)convBuf_; for (int yp = 0; yp < h; ++yp) { - int row_offset = vfb->z_stride * yp; - for (int xp = 0; xp < packWidth; ++xp) { - const int i = row_offset + xp; - depth[i] = packed32[i] & 0xFFFF; + for (int xp = 0; xp < w; ++xp) { + dest[xp] = packed32[xp] & 0xFFFF; } + dest += pixelsStride; + packed32 += w; } } else { - // TODO: Apply this in the shader. + // TODO: Apply this in the shader? May have precision issues if it becomes important to match. + // We downloaded float values directly in this case. + uint16_t *dest = pixels; + const GLfloat *packedf = (GLfloat *)convBuf_; DepthScaleFactors depthScale = GetDepthScaleFactors(); for (int yp = 0; yp < h; ++yp) { - int row_offset = vfb->z_stride * yp; - for (int xp = 0; xp < packWidth; ++xp) { - const int i = row_offset + xp; - float scaled = depthScale.Apply(packedf[i]); + for (int xp = 0; xp < w; ++xp) { + float scaled = depthScale.Apply(packedf[xp]); if (scaled <= 0.0f) { - depth[i] = 0; + dest[xp] = 0; } else if (scaled >= 65535.0f) { - depth[i] = 65535; + dest[xp] = 65535; } else { - depth[i] = (int)scaled; + dest[xp] = (int)scaled; } } + dest += pixelsStride; + packedf += w; } } - - gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); } diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 61c2daef1b..eca6d80f06 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -39,6 +39,7 @@ public: protected: void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; + void ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride); private: u8 *convBuf_ = nullptr; From 179c1e4a3b4e40bcb060869ffc1dfda8bb05e119 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 9 Oct 2022 23:19:31 -0700 Subject: [PATCH 107/374] GLES: Enable EXT_depth_clamp where supported. Seems like Freedreno may support this. --- Common/GPU/OpenGL/GLFeatures.cpp | 1 + Common/GPU/OpenGL/GLFeatures.h | 1 + Common/GPU/OpenGL/thin3d_gl.cpp | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/GPU/OpenGL/GLFeatures.cpp b/Common/GPU/OpenGL/GLFeatures.cpp index aa79ac5941..103fe00985 100644 --- a/Common/GPU/OpenGL/GLFeatures.cpp +++ b/Common/GPU/OpenGL/GLFeatures.cpp @@ -386,6 +386,7 @@ void CheckGLExtensions() { gl_extensions.OES_texture_3D = g_set_gl_extensions.count("GL_OES_texture_3D") != 0; gl_extensions.EXT_buffer_storage = g_set_gl_extensions.count("GL_EXT_buffer_storage") != 0; gl_extensions.EXT_clip_cull_distance = g_set_gl_extensions.count("GL_EXT_clip_cull_distance") != 0; + gl_extensions.EXT_depth_clamp = g_set_gl_extensions.count("GL_EXT_depth_clamp") != 0; gl_extensions.APPLE_clip_distance = g_set_gl_extensions.count("GL_APPLE_clip_distance") != 0; #if defined(__ANDROID__) diff --git a/Common/GPU/OpenGL/GLFeatures.h b/Common/GPU/OpenGL/GLFeatures.h index 43f0ba52a7..5fe965c3f0 100644 --- a/Common/GPU/OpenGL/GLFeatures.h +++ b/Common/GPU/OpenGL/GLFeatures.h @@ -87,6 +87,7 @@ struct GLExtensions { bool EXT_draw_instanced; bool EXT_buffer_storage; bool EXT_clip_cull_distance; + bool EXT_depth_clamp; // NV bool NV_copy_image; diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 95e737e63a..bb937379ef 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -551,7 +551,7 @@ OpenGLContext::OpenGLContext() { caps_.framebufferBlitSupported = gl_extensions.NV_framebuffer_blit || gl_extensions.ARB_framebuffer_object || gl_extensions.GLES3; caps_.framebufferDepthBlitSupported = caps_.framebufferBlitSupported; caps_.framebufferStencilBlitSupported = caps_.framebufferBlitSupported; - caps_.depthClampSupported = gl_extensions.ARB_depth_clamp; + caps_.depthClampSupported = gl_extensions.ARB_depth_clamp || gl_extensions.EXT_depth_clamp; caps_.blendMinMaxSupported = gl_extensions.EXT_blend_minmax; if (gl_extensions.IsGLES) { From f8908c691b710847e294c9536c60bfd1e3371310 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 00:40:54 -0700 Subject: [PATCH 108/374] GLES: Use Draw for depth readback shader. Was not working before, since the program was not being used by Draw2D. --- GPU/Common/FramebufferManagerCommon.cpp | 2 + GPU/Common/FramebufferManagerCommon.h | 3 + GPU/GLES/DepthBufferGLES.cpp | 159 +++++++++++++++--------- GPU/GLES/FramebufferManagerGLES.h | 2 +- 4 files changed, 103 insertions(+), 63 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f6e66efd98..27d18c476f 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2811,6 +2811,8 @@ void FramebufferManagerCommon::DeviceLost() { } DoRelease(stencilUploadSampler_); DoRelease(stencilUploadPipeline_); + DoRelease(depthReadbackSampler_); + DoRelease(depthReadbackPipeline_); DoRelease(draw2DPipelineColor_); DoRelease(draw2DPipelineColorRect2Lin_); DoRelease(draw2DPipelineDepth_); diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index d44a0ecb18..28d83186d8 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -571,6 +571,9 @@ protected: Draw::Pipeline *stencilUploadPipeline_ = nullptr; Draw::SamplerState *stencilUploadSampler_ = nullptr; + Draw::Pipeline *depthReadbackPipeline_ = nullptr; + Draw::SamplerState *depthReadbackSampler_ = nullptr; + // Draw2D pipelines Draw2DPipeline *draw2DPipelineColor_ = nullptr; Draw2DPipeline *draw2DPipelineColorRect2Lin_ = nullptr; diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index ff9582ac82..bf239f547f 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -40,13 +40,13 @@ precision mediump float; #define gl_FragColor fragColor0 out vec4 fragColor0; #endif -varying vec2 v_texcoord0; -uniform vec2 u_depthFactor; +varying vec2 v_texcoord; +uniform vec4 u_depthFactor; uniform vec4 u_depthShift; uniform vec4 u_depthTo8; uniform sampler2D tex; void main() { - float depth = texture2D(tex, v_texcoord0).r; + float depth = texture2D(tex, v_texcoord).r; // At this point, clamped maps [0, 1] to [0, 65535]. float clamped = clamp((depth + u_depthFactor.x) * u_depthFactor.y, 0.0, 1.0); @@ -65,15 +65,26 @@ precision highp float; #define attribute in #define varying out #endif -attribute vec4 a_position; -attribute vec2 a_texcoord0; -varying vec2 v_texcoord0; +attribute vec2 a_position; +varying vec2 v_texcoord; void main() { - v_texcoord0 = a_texcoord0; - gl_Position = a_position; + v_texcoord = a_position * 2.0; + gl_Position = vec4(v_texcoord * 2.0 - vec2(1.0, 1.0), 0.0, 1.0); } )"; +struct DepthUB { + float u_depthFactor[4]; + float u_depthShift[4]; + float u_depthTo8[4]; +}; + +const UniformBufferDesc depthUBDesc{ sizeof(DepthUB), { + { "u_depthFactor", -1, -1, UniformType::FLOAT4, 0 }, + { "u_depthShift", -1, -1, UniformType::FLOAT4, 16 }, + { "u_depthTo8", -1, -1, UniformType::FLOAT4, 32 }, +} }; + static bool SupportsDepthTexturing() { if (gl_extensions.IsGLES) { return gl_extensions.OES_packed_depth_stencil && (gl_extensions.OES_depth_texture || gl_extensions.GLES3); @@ -94,17 +105,19 @@ void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, in u16 *depth = (u16 *)Memory::GetPointer(z_address + dstByteOffset); ReadbackDepthbufferSync(vfb->fbo, x, y, w, h, depth, vfb->z_stride); - gstate_c.Dirty(DIRTY_BLEND_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); + gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); } -void FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { +bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { + using namespace Draw; + if (!fbo) { ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackDepthbufferSync: bad fbo"); - return; + return false; } // Old desktop GL can download depth, but not upload. if (gl_extensions.IsGLES && !SupportsDepthTexturing()) { - return; + return false; } // Pixel size always 4 here because we always request float or RGBA. @@ -118,73 +131,93 @@ void FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int const bool useColorPath = gl_extensions.IsGLES; bool format16Bit = false; - GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); - if (useColorPath) { - if (!depthDownloadProgram_) { - std::string errorString; - static std::string vs_code, fs_code; - vs_code = ApplyGLSLPrelude(depth_vs, GL_VERTEX_SHADER); - fs_code = ApplyGLSLPrelude(depth_dl_fs, GL_FRAGMENT_SHADER); - std::vector shaders; - shaders.push_back(render->CreateShader(GL_VERTEX_SHADER, vs_code, "depth_dl")); - shaders.push_back(render->CreateShader(GL_FRAGMENT_SHADER, fs_code, "depth_dl")); - std::vector semantics; - semantics.push_back({ 0, "a_position" }); - semantics.push_back({ 1, "a_texcoord0" }); - std::vector queries; - queries.push_back({ &u_depthDownloadTex, "tex" }); - queries.push_back({ &u_depthDownloadFactor, "u_depthFactor" }); - queries.push_back({ &u_depthDownloadShift, "u_depthShift" }); - queries.push_back({ &u_depthDownloadTo8, "u_depthTo8" }); - std::vector inits; - inits.push_back({ &u_depthDownloadTex, 0, TEX_SLOT_PSP_TEXTURE }); - GLRProgramFlags flags{}; - depthDownloadProgram_ = render->CreateProgram(shaders, semantics, queries, inits, flags); - for (auto iter : shaders) { - render->DeleteShader(iter); - } - if (!depthDownloadProgram_) { - ERROR_LOG_REPORT(G3D, "Failed to compile depthDownloadProgram! This shouldn't happen.\n%s", errorString.c_str()); - } + if (!depthReadbackPipeline_) { + const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); + + ShaderModule *depthReadbackFs = draw_->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)depth_dl_fs, strlen(depth_dl_fs), "depth_dl_fs"); + ShaderModule *depthReadbackVs = draw_->CreateShaderModule(ShaderStage::Vertex, shaderLanguageDesc.shaderLanguage, (const uint8_t *)depth_vs, strlen(depth_vs), "depth_vs"); + _assert_(depthReadbackFs && depthReadbackVs); + + InputLayoutDesc desc = { + { + { 8, false }, + }, + { + { 0, SEM_POSITION, DataFormat::R32G32_FLOAT, 0 }, + }, + }; + InputLayout *inputLayout = draw_->CreateInputLayout(desc); + + BlendState *blendOff = draw_->CreateBlendState({ false, 0xF }); + DepthStencilState *stencilIgnore = draw_->CreateDepthStencilState({}); + RasterState *rasterNoCull = draw_->CreateRasterState({}); + + PipelineDesc depthReadbackDesc{ + Primitive::TRIANGLE_LIST, + { depthReadbackVs, depthReadbackFs }, + inputLayout, stencilIgnore, blendOff, rasterNoCull, &depthUBDesc, + }; + depthReadbackPipeline_ = draw_->CreateGraphicsPipeline(depthReadbackDesc, "depth_dl"); + _assert_(depthReadbackPipeline_); + + rasterNoCull->Release(); + blendOff->Release(); + stencilIgnore->Release(); + inputLayout->Release(); + + depthReadbackFs->Release(); + depthReadbackVs->Release(); + + SamplerStateDesc descNearest{}; + depthReadbackSampler_ = draw_->CreateSamplerState(descNearest); } shaderManager_->DirtyLastShader(); auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); - draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); - render->SetViewport({ 0, 0, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }); + draw_->BindFramebufferAsRenderTarget(blitFBO, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); + Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; + draw_->SetViewports(1, &viewport); - // We must bind the program after starting the render pass, and set the color mask after clearing. - render->SetScissor({ 0, 0, fbo->Width(), fbo->Height() }); - render->SetDepth(false, false, GL_ALWAYS); - render->SetRaster(false, GL_CCW, GL_FRONT, GL_FALSE, GL_FALSE); - render->BindProgram(depthDownloadProgram_); + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_DEPTH_BIT, 0); + draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &depthReadbackSampler_); - if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { - float factors[] = { 0.0f, 1.0f }; - render->SetUniformF(&u_depthDownloadFactor, 2, factors); + // We must bind the program after starting the render pass. + draw_->SetScissorRect(0, 0, w, h); + draw_->BindPipeline(depthReadbackPipeline_); + + DepthUB ub{}; + + if (gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + ub.u_depthFactor[0] = 0.0f; + ub.u_depthFactor[1] = 1.0f; } else { const float factor = DepthSliceFactor(); - float factors[] = { -0.5f * (factor - 1.0f) * (1.0f / factor), factor }; - render->SetUniformF(&u_depthDownloadFactor, 2, factors); + ub.u_depthFactor[0] = -0.5f * (factor - 1.0f) * (1.0f / factor); + ub.u_depthFactor[1] = factor; } - float shifts[] = { 16777215.0f, 16777215.0f / 256.0f, 16777215.0f / 65536.0f, 16777215.0f / 16777216.0f }; - render->SetUniformF(&u_depthDownloadShift, 4, shifts); - float to8[] = { 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f }; - render->SetUniformF(&u_depthDownloadTo8, 4, to8); + static constexpr float shifts[] = { 16777215.0f, 16777215.0f / 256.0f, 16777215.0f / 65536.0f, 16777215.0f / 16777216.0f }; + memcpy(ub.u_depthShift, shifts, sizeof(shifts)); + static constexpr float to8[] = { 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f, 1.0f / 255.0f }; + memcpy(ub.u_depthTo8, to8, sizeof(to8)); - draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, Draw::FB_DEPTH_BIT, 0); - float u1 = 1.0f; - float v1 = 1.0f; - DrawActiveTexture(x, y, w, h, fbo->Width(), fbo->Height(), 0.0f, 0.0f, u1, v1, ROTATION_LOCKED_HORIZONTAL, DRAWTEX_NEAREST); + draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub)); - draw_->CopyFramebufferToMemorySync(blitFBO, Draw::FB_COLOR_BIT, x, y, w, h, Draw::DataFormat::R8G8B8A8_UNORM, convBuf_, w, "ReadbackDepthbufferSync"); + // Fullscreen triangle coordinates. + static const float positions[6] = { + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + }; + draw_->DrawUP(positions, 3); + + draw_->CopyFramebufferToMemorySync(blitFBO, FB_COLOR_BIT, x, y, w, h, DataFormat::R8G8B8A8_UNORM, convBuf_, w, "ReadbackDepthbufferSync"); textureCache_->ForgetLastTexture(); // TODO: Use 4444 so we can copy lines directly (instead of 32 -> 16 on CPU)? format16Bit = true; } else { - draw_->CopyFramebufferToMemorySync(fbo, Draw::FB_DEPTH_BIT, x, y, w, h, Draw::DataFormat::D32F, convBuf_, w, "ReadbackDepthbufferSync"); + draw_->CopyFramebufferToMemorySync(fbo, FB_DEPTH_BIT, x, y, w, h, DataFormat::D32F, convBuf_, w, "ReadbackDepthbufferSync"); format16Bit = false; } @@ -220,4 +253,6 @@ void FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int packedf += w; } } + + return true; } diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index eca6d80f06..b5967e7c40 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -39,7 +39,7 @@ public: protected: void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; - void ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride); + bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride); private: u8 *convBuf_ = nullptr; From 1dc35b3ac4b5841c9743e760c2b5b2fa477d8b47 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 00:53:31 -0700 Subject: [PATCH 109/374] GLES: Simplify, enable debug depth readback. --- GPU/Common/FramebufferManagerCommon.cpp | 36 ++++++++++++------------- GPU/Common/FramebufferManagerCommon.h | 2 +- GPU/Directx9/FramebufferManagerDX9.h | 2 +- GPU/GLES/DepthBufferGLES.cpp | 20 +++----------- GPU/GLES/FramebufferManagerGLES.h | 3 +-- 5 files changed, 23 insertions(+), 40 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 27d18c476f..c36d39a6f1 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2538,6 +2538,12 @@ bool FramebufferManagerCommon::GetDepthbuffer(u32 fb_address, int fb_stride, u32 } // No need to free on failure, that's the caller's job (it likely will reuse a buffer.) bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, 0, 0, w, h, Draw::DataFormat::D32F, buffer.GetData(), w, "GetDepthBuffer"); + if (!retval) { + // Try ReadbackDepthbufferSync, in case GLES. + buffer.Allocate(w, h, GPU_DBG_FORMAT_16BIT, flipY); + retval = ReadbackDepthbufferSync(vfb->fbo, 0, 0, w, h, (uint16_t *)buffer.GetData(), w); + } + // After a readback we'll have flushed and started over, need to dirty a bunch of things to be safe. gstate_c.Dirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); // That may have unbound the framebuffer, rebind to avoid crashes when debugging. @@ -2604,7 +2610,7 @@ void FramebufferManagerCommon::ReadbackFramebufferSync(VirtualFramebuffer *vfb, return; } - const u32 fb_address = vfb->fb_address; + const u32 fb_address = channel == RASTER_COLOR ? vfb->fb_address : vfb->z_address; Draw::DataFormat destFormat = channel == RASTER_COLOR ? GEFormatToThin3D(vfb->fb_format) : GEFormatToThin3D(GE_FORMAT_DEPTH16); const int dstBpp = (int)DataFormatSizeInBytes(destFormat); @@ -2627,31 +2633,23 @@ void FramebufferManagerCommon::ReadbackFramebufferSync(VirtualFramebuffer *vfb, // Right now that's always 8888. DEBUG_LOG(G3D, "Reading framebuffer to mem, fb_address = %08x, ptr=%p", fb_address, destPtr); - if (destPtr) { - if (channel == RASTER_DEPTH) - ReadbackDepthbufferSync(vfb, x, y, w, h); - else - draw_->CopyFramebufferToMemorySync(vfb->fbo, channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride, "ReadbackFramebufferSync"); - - char tag[128]; - size_t len = snprintf(tag, sizeof(tag), "FramebufferPack/%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString(vfb->fb_format)); - NotifyMemInfo(MemBlockFlags::WRITE, fb_address + dstByteOffset, dstSize, tag, len); + if (channel == RASTER_DEPTH) { + _assert_msg_(vfb && vfb->z_address != 0 && vfb->z_stride != 0, "Depth buffer invalid"); + ReadbackDepthbufferSync(vfb->fbo, x, y, w, h, (uint16_t *)destPtr, stride); } else { - ERROR_LOG(G3D, "ReadbackFramebufferSync: Tried to readback to bad address %08x (stride = %d)", fb_address + dstByteOffset, vfb->fb_stride); + draw_->CopyFramebufferToMemorySync(vfb->fbo, channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, stride, "ReadbackFramebufferSync"); } + char tag[128]; + size_t len = snprintf(tag, sizeof(tag), "FramebufferPack/%08x_%08x_%dx%d_%s", vfb->fb_address, vfb->z_address, w, h, GeBufferFormatToString(vfb->fb_format)); + NotifyMemInfo(MemBlockFlags::WRITE, fb_address + dstByteOffset, dstSize, tag, len); + gpuStats.numReadbacks++; } -void FramebufferManagerCommon::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { - _assert_msg_(vfb && vfb->z_address != 0 && vfb->z_stride != 0, "Depth buffer invalid"); - +bool FramebufferManagerCommon::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { Draw::DataFormat destFormat = GEFormatToThin3D(GE_FORMAT_DEPTH16); - const int dstByteOffset = (y * vfb->z_stride + x) * 2; - u8 *destPtr = Memory::GetPointerWriteUnchecked(vfb->z_address + dstByteOffset); - if (!draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, destPtr, vfb->z_stride, "ReadbackDepthbufferSync")) { - WARN_LOG(G3D, "ReadbackDepthbufferSync failed"); - } + return draw_->CopyFramebufferToMemorySync(fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, pixels, pixelsStride, "ReadbackDepthbufferSync"); } void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 28d83186d8..63f7b082ba 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -443,7 +443,7 @@ public: protected: virtual void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel); // Used for when a shader is required, such as GLES. - virtual void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h); + virtual bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride); void SetViewport2D(int x, int y, int w, int h); Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height); void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags); diff --git a/GPU/Directx9/FramebufferManagerDX9.h b/GPU/Directx9/FramebufferManagerDX9.h index ea69262917..cb0a8ff37f 100644 --- a/GPU/Directx9/FramebufferManagerDX9.h +++ b/GPU/Directx9/FramebufferManagerDX9.h @@ -49,11 +49,11 @@ public: protected: void DecimateFBOs() override; - void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) override; private: bool GetRenderTargetFramebuffer(LPDIRECT3DSURFACE9 renderTarget, LPDIRECT3DSURFACE9 offscreen, int w, int h, GPUDebugBuffer &buffer); + void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h); LPDIRECT3DDEVICE9 device_; LPDIRECT3DDEVICE9 deviceEx_; diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index bf239f547f..6b9dbc219c 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -92,22 +92,6 @@ static bool SupportsDepthTexturing() { return gl_extensions.VersionGEThan(3, 0); } -void FramebufferManagerGLES::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { - if (!vfb->fbo) { - ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackDepthbufferSync: vfb->fbo == 0"); - return; - } - - const u32 z_address = vfb->z_address; - DEBUG_LOG(FRAMEBUF, "Reading depthbuffer to mem at %08x for vfb=%08x", z_address, vfb->fb_address); - - int dstByteOffset = y * vfb->z_stride * sizeof(u16); - u16 *depth = (u16 *)Memory::GetPointer(z_address + dstByteOffset); - ReadbackDepthbufferSync(vfb->fbo, x, y, w, h, depth, vfb->z_stride); - - gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); -} - bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { using namespace Draw; @@ -188,7 +172,8 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int DepthUB ub{}; - if (gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + // Don't scale anything, since we're not using factors outside accurate mode. ub.u_depthFactor[0] = 0.0f; ub.u_depthFactor[1] = 1.0f; } else { @@ -254,5 +239,6 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int } } + gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); return true; } diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index b5967e7c40..36aa2545fd 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -38,8 +38,7 @@ public: protected: void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; - void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; - bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride); + bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) override; private: u8 *convBuf_ = nullptr; From 32699da6dfb6c251412794ad8bd0e6eff1ae44e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 4 Oct 2022 17:56:30 +0200 Subject: [PATCH 110/374] Vulkan (trivial): Fix numDraws stat when merging render passes. Shorten a name. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 4 ++++ GPU/Common/FramebufferManagerCommon.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index c1da294a0f..1696487d5c 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -515,6 +515,8 @@ void VulkanQueueRunner::PreprocessSteps(std::vector &steps) { } MergeRenderAreaRectInto(&steps[i]->render.renderArea, steps[j]->render.renderArea); steps[i]->render.renderPassType = MergeRPTypes(steps[i]->render.renderPassType, steps[j]->render.renderPassType); + steps[i]->render.numDraws += steps[j]->render.numDraws; + steps[i]->render.numReads += steps[j]->render.numReads; // Cheaply skip the first step. steps[j]->stepType = VKRStepType::RENDER_SKIP; break; @@ -936,6 +938,8 @@ void VulkanQueueRunner::ApplyRenderPassMerge(std::vector &steps) { // So we don't consider it for other things, maybe doesn't matter. src->dependencies.clear(); src->stepType = VKRStepType::RENDER_SKIP; + dst->render.numDraws += src->render.numDraws; + dst->render.numReads += src->render.numReads; dst->render.pipelineFlags |= src->render.pipelineFlags; dst->render.renderPassType = MergeRPTypes(dst->render.renderPassType, src->render.renderPassType); }; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f6e66efd98..c8535ebda8 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1215,7 +1215,7 @@ void FramebufferManagerCommon::CopyFramebufferForColorTexture(VirtualFramebuffer } if (x < src->drawnWidth && y < src->drawnHeight && w > 0 && h > 0) { - BlitFramebuffer(dst, x, y, src, x, y, w, h, 0, RASTER_COLOR, "Blit_CopyFramebufferForColorTexture"); + BlitFramebuffer(dst, x, y, src, x, y, w, h, 0, RASTER_COLOR, "CopyFBForColorTexture"); } } From d52d383c224aa60d0d4541276e80e114486eaab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 10:46:51 +0200 Subject: [PATCH 111/374] Delete some misguided FPU control code, that we definitely don't want --- Common/Math/math_util.cpp | 43 ++------------------------------------- Common/Math/math_util.h | 9 -------- Qt/QtMain.cpp | 1 - SDL/SDLMain.cpp | 1 - ios/ViewController.mm | 3 --- 5 files changed, 2 insertions(+), 55 deletions(-) diff --git a/Common/Math/math_util.cpp b/Common/Math/math_util.cpp index 9b1a59a755..6e72791f87 100644 --- a/Common/Math/math_util.cpp +++ b/Common/Math/math_util.cpp @@ -1,44 +1,5 @@ #include "Common/Math/math_util.h" -#include -// QNX can only use RunFast mode and it is already the default. -#if defined(__ARM_ARCH_7A__) -// Enables 'RunFast' VFP mode. -void EnableFZ() { - int x; - asm( - "fmrx %[result],FPSCR \r\n" - "orr %[result],%[result],#16777216 \r\n" - "fmxr FPSCR,%[result]" - :[result] "=r" (x) : : - ); - //printf("ARM FPSCR: %08x\n",x); -} +#include -// New fastmode code from: http://pandorawiki.org/Floating_Point_Optimization -// These settings turbocharge the slow VFP unit on Cortex-A8 based chips by setting -// restrictions that permit running VFP instructions on the NEON unit. -// Denormal flush-to-zero, for example. -void FPU_SetFastMode() { - static const unsigned int x = 0x04086060; - static const unsigned int y = 0x03000000; - int r; - asm volatile ( - "fmrx %0, fpscr \n\t" //r0 = FPSCR - "and %0, %0, %1 \n\t" //r0 = r0 & 0x04086060 - "orr %0, %0, %2 \n\t" //r0 = r0 | 0x03000000 - "fmxr fpscr, %0 \n\t" //FPSCR = r0 - : "=r"(r) - : "r"(x), "r"(y) - ); -} - -#else - -void EnableFZ() { - // TODO -} - -void FPU_SetFastMode() {} - -#endif +// Could delete this file, but might find use again. diff --git a/Common/Math/math_util.h b/Common/Math/math_util.h index fd47662b54..8f8962cab4 100644 --- a/Common/Math/math_util.h +++ b/Common/Math/math_util.h @@ -189,12 +189,3 @@ inline uint16_t ShrinkToHalf(float full) { FP16 fp = float_to_half_fast3(fp32); return fp.u; } - -// FPU control. -void EnableFZ(); - -// Enable both FZ and Default-NaN. Is documented to flip some ARM implementation into a "run-fast" mode -// where they can schedule VFP instructions on the NEON unit (these implementations have -// very slow VFP units). -// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0274h/Babffifj.html -void FPU_SetFastMode(); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index bba1f1ae2b..c6381a112d 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -316,7 +316,6 @@ static int mainInternal(QApplication &a) { emugl->resize(pixel_xres, pixel_yres); emugl->showFullScreen(); #endif - EnableFZ(); // Disable screensaver #if defined(QT_HAS_SYSTEMINFO) QScreenSaver ssObject(emugl); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index da966cabae..0a6daa5361 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -807,7 +807,6 @@ int main(int argc, char *argv[]) { } else { joystick = nullptr; } - EnableFZ(); int framecount = 0; bool mouseDown = false; diff --git a/ios/ViewController.mm b/ios/ViewController.mm index c90c30a22a..63d241cf46 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -807,6 +807,3 @@ void bindDefaultFBO() { [sharedViewController bindDefaultFBO]; } - -void EnableFZ(){}; -void DisableFZ(){}; From d4bfe9299d388017bbad02d446202cccc61286ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 10:53:27 +0200 Subject: [PATCH 112/374] Track min and max GPU time, init time, render CPU time. Mainly wanted to see if init time is a factor, there are optimizations we can do there. --- CMakeLists.txt | 2 ++ Common/Common.vcxproj | 2 ++ Common/Common.vcxproj.filters | 6 ++++ Common/GPU/Vulkan/VulkanRenderManager.cpp | 30 +++++++++++++--- Common/GPU/Vulkan/VulkanRenderManager.h | 8 +++++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 4 +++ Common/GPU/thin3d.h | 3 ++ Common/Math/Statistics.cpp | 11 ++++++ Common/Math/Statistics.h | 42 +++++++++++++++++++++++ UI/EmuScreen.cpp | 2 ++ UWP/CommonUWP/CommonUWP.vcxproj | 4 ++- UWP/CommonUWP/CommonUWP.vcxproj.filters | 14 ++++---- android/jni/Android.mk | 1 + libretro/Makefile.common | 1 + 14 files changed, 119 insertions(+), 11 deletions(-) create mode 100644 Common/Math/Statistics.cpp create mode 100644 Common/Math/Statistics.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cb38fb017..28ce455b8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -650,6 +650,8 @@ add_library(Common STATIC Common/Math/lin/vec3.h Common/Math/math_util.cpp Common/Math/math_util.h + Common/Math/Statistics.h + Common/Math/Statistics.cpp Common/Net/HTTPClient.cpp Common/Net/HTTPClient.h Common/Net/HTTPHeaders.cpp diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 901006a0d9..aa0f9bb1e7 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -466,6 +466,7 @@ + @@ -886,6 +887,7 @@ + diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 991b03a71f..0cb9e79423 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -422,6 +422,9 @@ GPU\Vulkan + + Math + @@ -797,6 +800,9 @@ GPU\Vulkan + + Math + diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 44a4455d98..7c7d8418c6 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -327,7 +327,12 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int img.tag = tag ? tag : "N/A"; } -VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan), queueRunner_(vulkan) { +VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) + : vulkan_(vulkan), queueRunner_(vulkan), + initTimeMs_("initTimeMs"), + totalGPUTimeMs_("totalGPUTimeMs"), + renderCPUTimeMs_("renderCPUTimeMs") +{ inflightFramesAtStart_ = vulkan_->GetInflightFrames(); frameDataShared_.Init(vulkan); @@ -579,14 +584,25 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile std::stringstream str; char line[256]; - snprintf(line, sizeof(line), "Total GPU time: %0.3f ms\n", ((double)((queryResults[numQueries - 1] - queryResults[0]) & timestampDiffMask) * timestampConversionFactor)); + totalGPUTimeMs_.Update(((double)((queryResults[numQueries - 1] - queryResults[0]) & timestampDiffMask) * timestampConversionFactor)); + totalGPUTimeMs_.Format(line, sizeof(line)); str << line; - snprintf(line, sizeof(line), "Render CPU time: %0.3f ms\n", (frameData.profile.cpuEndTime - frameData.profile.cpuStartTime) * 1000.0); + renderCPUTimeMs_.Update((frameData.profile.cpuEndTime - frameData.profile.cpuStartTime) * 1000.0); + renderCPUTimeMs_.Format(line, sizeof(line)); str << line; for (int i = 0; i < numQueries - 1; i++) { uint64_t diff = (queryResults[i + 1] - queryResults[i]) & timestampDiffMask; double milliseconds = (double)diff * timestampConversionFactor; - snprintf(line, sizeof(line), "%s: %0.3f ms\n", frameData.profile.timestampDescriptions[i + 1].c_str(), milliseconds); + + // Can't use SimpleStat for these very easily since these are dynamic per frame. + // Only the first one is static, the initCmd. + // Could try some hashtable tracking for the rest, later. + if (i == 0) { + initTimeMs_.Update(milliseconds); + initTimeMs_.Format(line, sizeof(line)); + } else { + snprintf(line, sizeof(line), "%s: %0.3f ms\n", frameData.profile.timestampDescriptions[i + 1].c_str(), milliseconds); + } str << line; } frameData.profile.profileSummary = str.str(); @@ -1344,3 +1360,9 @@ void VulkanRenderManager::FlushSync() { frameData.syncDone = false; } } + +void VulkanRenderManager::ResetStats() { + initTimeMs_.Reset(); + totalGPUTimeMs_.Reset(); + renderCPUTimeMs_.Reset(); +} diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index e1f66c29e2..7ba98b485c 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -12,6 +12,7 @@ #include #include +#include "Common/Math/Statistics.h" #include "Common/Thread/Promise.h" #include "Common/System/Display.h" #include "Common/GPU/Vulkan/VulkanContext.h" @@ -465,6 +466,8 @@ public: return outOfDateFrames_ > VulkanContext::MAX_INFLIGHT_FRAMES; } + void ResetStats(); + private: void EndCurRenderStep(); @@ -535,4 +538,9 @@ private: // pipelines to check and possibly create at the end of the current render pass. std::vector pipelinesToCheck_; + + // For nicer output in the little internal GPU profiler. + SimpleStat initTimeMs_; + SimpleStat totalGPUTimeMs_; + SimpleStat renderCPUTimeMs_; }; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 6c342f8e9e..dc1b806011 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -455,6 +455,10 @@ public: void FlushState() override {} + void ResetStats() override { + renderManager_.ResetStats(); + } + std::string GetInfoString(InfoField info) const override { // TODO: Make these actually query the right information switch (info) { diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 3e482687a3..132c0e02f9 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -735,6 +735,9 @@ public: // Flush state like scissors etc so the caller can do its own custom drawing. virtual void FlushState() {} + // This is called when we launch a new game, so any collected internal stats in the backends don't carry over. + virtual void ResetStats() {} + virtual int GetCurrentStepId() const = 0; protected: diff --git a/Common/Math/Statistics.cpp b/Common/Math/Statistics.cpp new file mode 100644 index 0000000000..c05dd84e85 --- /dev/null +++ b/Common/Math/Statistics.cpp @@ -0,0 +1,11 @@ +#include + +#include "Common/Math/Statistics.h" + +void SimpleStat::Format(char *buffer, size_t sz) { + if (min_ == INFINITY) { + snprintf(buffer, sz, "%s: N/A\n", name_); + } else { + snprintf(buffer, sz, "%s: %0.2f (%0.2f..%0.2f, avg %0.2f)\n", name_, value_, min_, max_, smoothed_); + } +} diff --git a/Common/Math/Statistics.h b/Common/Math/Statistics.h new file mode 100644 index 0000000000..0b03d1d420 --- /dev/null +++ b/Common/Math/Statistics.h @@ -0,0 +1,42 @@ +#pragma once + +#include + +// Very simple stat for convenience. Keeps track of min, max, smoothed. +struct SimpleStat { + SimpleStat(const char *name) : name_(name) { Reset(); } + + void Update(double value) { + value_ = value; + if (min_ == INFINITY) { + smoothed_ = value; + } else { + // TODO: Make factor adjustable? + smoothed_ = 0.99 * smoothed_ + 0.01 * value; + } + if (value < min_) { + min_ = value; + } + if (value > max_) { + max_ = value; + } + } + + void Reset() { + value_ = 0.0; + smoothed_ = 0.0; // doens't really need init + min_ = INFINITY; + max_ = -INFINITY; + } + + void Format(char *buffer, size_t sz); + +private: + const char *name_; + + // These are initialized in Reset(). + double value_; + double min_; + double max_; + double smoothed_; +}; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index c29d8e67c6..bcf5a47a48 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -344,6 +344,8 @@ void EmuScreen::bootGame(const Path &filename) { loadingViewColor_->Divert(0xFFFFFFFF, 0.75f); loadingViewVisible_->Divert(UI::V_VISIBLE, 0.75f); + + screenManager()->getDrawContext()->ResetStats(); } void EmuScreen::bootComplete() { diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index 5c03d355c9..09e9173e41 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -387,6 +387,7 @@ + @@ -519,6 +520,7 @@ + @@ -639,4 +641,4 @@ - + \ No newline at end of file diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 7ab8b012c7..23de400ce6 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -372,6 +372,9 @@ File + + Math + @@ -688,11 +691,9 @@ File - - - - ext\libpng17 - + + Math + @@ -701,5 +702,6 @@ Math\lin + - + \ No newline at end of file diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 42cae5cb28..305caf67a5 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -164,6 +164,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/Common/Input/InputState.cpp \ $(SRC)/Common/Math/fast/fast_matrix.c \ $(SRC)/Common/Math/math_util.cpp \ + $(SRC)/Common/Math/Statistics.cpp \ $(SRC)/Common/Math/curves.cpp \ $(SRC)/Common/Math/expression_parser.cpp \ $(SRC)/Common/Math/lin/vec3.cpp.arm \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 56c748b52a..375792b296 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -271,6 +271,7 @@ SOURCES_CXX += \ $(COMMONDIR)/Math/curves.cpp \ $(COMMONDIR)/Math/expression_parser.cpp \ $(COMMONDIR)/Math/math_util.cpp \ + $(COMMONDIR)/Math/Statistics.cpp \ $(COMMONDIR)/Math/lin/vec3.cpp \ $(COMMONDIR)/Math/lin/matrix4x4.cpp \ $(COMMONDIR)/Net/HTTPClient.cpp \ From 470edac18a1af1f8107338db5357f7a625d3cb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 11:42:24 +0200 Subject: [PATCH 113/374] Revert "Loader: Validate offsets and truncation in ELF." This reverts commit 4ecdce2a379fb429c4dc3d7de02d148a2aeff0f0. --- Core/ELF/ElfReader.cpp | 45 ++++++------------------------------------ Core/ELF/ElfReader.h | 18 +++++------------ 2 files changed, 11 insertions(+), 52 deletions(-) diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index 513786d0d6..980e427e83 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -34,10 +34,9 @@ const char *ElfReader::GetSectionName(int section) const { if (sections[section].sh_type == SHT_NULL) return nullptr; - int stringsOffset = GetSectionDataOffset(header->e_shstrndx); int nameOffset = sections[section].sh_name; - if (nameOffset < 0 || (size_t)nameOffset + stringsOffset >= size_) { - ERROR_LOG(LOADER, "ELF: Bad name offset %d + %d in section %d (max = %d)", nameOffset, stringsOffset, section, (int)size_); + if (nameOffset < 0 || (size_t)nameOffset >= size_) { + ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d (max = %d)", nameOffset, section, (int)size_); return nullptr; } const char *ptr = (const char *)GetSectionDataPtr(header->e_shstrndx); @@ -236,10 +235,6 @@ void ElfReader::LoadRelocations2(int rel_seg) const Elf32_Phdr *ph = segments + rel_seg; buf = (u8*)GetSegmentPtr(rel_seg); - if (!buf) { - ERROR_LOG(LOADER, "Rel2 segment invalid"); - return; - } end = buf+ph->p_filesz; flag_bits = buf[2]; @@ -388,12 +383,6 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) { DEBUG_LOG(LOADER,"String section: %i", header->e_shstrndx); - if (size_ < sizeof(Elf32_Ehdr)) { - ERROR_LOG(LOADER, "Truncated ELF header, %d bytes", (int)size_); - // Probably not the right error code. - return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; - } - if (header->e_ident[0] != ELFMAG0 || header->e_ident[1] != ELFMAG1 || header->e_ident[2] != ELFMAG2 || header->e_ident[3] != ELFMAG3) return SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE; @@ -410,12 +399,6 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) if (header->e_ident[EI_DATA] != ELFDATA2LSB) return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; - if (size_ < header->e_phoff + sizeof(Elf32_Phdr) * GetNumSegments() || size_ < header->e_shoff + sizeof(Elf32_Shdr) * GetNumSections()) { - ERROR_LOG(LOADER, "Truncated ELF, %d bytes with %d sections and %d segments", (int)size_, GetNumSections(), GetNumSegments()); - // Probably not the right error code. - return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; - } - // e_ident[EI_VERSION] is ignored sectionOffsets = new u32[GetNumSections()]; @@ -429,11 +412,11 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) for (int i = 0; i < GetNumSections(); i++) { const Elf32_Shdr *s = §ions[i]; const char *name = GetSectionName(i); - if (name && !strcmp(name, ".rodata.sceModuleInfo") && s->sh_offset + sizeof(PspModuleInfo) <= size_) { + if (name && !strcmp(name, ".rodata.sceModuleInfo")) { modInfo = (const PspModuleInfo *)GetPtr(s->sh_offset); } } - if (!modInfo && GetNumSegments() >= 1 && (segments[0].p_paddr & 0x7FFFFFFF) + sizeof(PspModuleInfo) <= size_) { + if (!modInfo && GetNumSegments() >= 1) { modInfo = (const PspModuleInfo *)GetPtr(segments[0].p_paddr & 0x7FFFFFFF); } @@ -510,10 +493,6 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) u32 writeAddr = segmentVAddr[i]; const u8 *src = GetSegmentPtr(i); - if (!src || p->p_offset + p->p_filesz > size_) { - ERROR_LOG(LOADER, "Segment %d pointer invalid - truncated?", i); - continue; - } u8 *dst = Memory::GetPointerWrite(writeAddr); u32 srcSize = p->p_filesz; u32 dstSize = p->p_memsz; @@ -578,11 +557,9 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) int numRelocs = s->sh_size / sizeof(Elf32_Rel); Elf32_Rel *rels = (Elf32_Rel *)GetSectionDataPtr(i); - if (GetSectionDataOffset(i) + sizeof(Elf32_Rel) * numRelocs > size_) - rels = nullptr; DEBUG_LOG(LOADER,"%s: Performing %i relocations on %s : offset = %08x", name, numRelocs, GetSectionName(sectionToModify), sections[i].sh_offset); - if (!rels || !LoadRelocations(rels, numRelocs)) { + if (!LoadRelocations(rels, numRelocs)) { WARN_LOG(LOADER, "LoadInto: Relocs failed, trying anyway"); } } @@ -630,9 +607,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) int numRelocs = p->p_filesz / sizeof(Elf32_Rel); Elf32_Rel *rels = (Elf32_Rel *)GetSegmentPtr(i); - if (p->p_offset + p->p_filesz > size_) - rels = nullptr; - if (!rels || !LoadRelocations(rels, numRelocs)) { + if (!LoadRelocations(rels, numRelocs)) { ERROR_LOG(LOADER, "LoadInto: Relocs failed, trying anyway (2)"); } } else if (p->p_type == PT_PSPREL2) { @@ -720,17 +695,11 @@ bool ElfReader::LoadSymbols() int stringSection = sections[sec].sh_link; const char *stringBase = (const char*)GetSectionDataPtr(stringSection); - u32 stringOffset = GetSectionDataOffset(stringSection); //We have a symbol table! Elf32_Sym *symtab = (Elf32_Sym *)(GetSectionDataPtr(sec)); - u32 symtabOffset = GetSectionDataOffset(sec); int numSymbols = sections[sec].sh_size / sizeof(Elf32_Sym); - if (!stringBase || !symtab || symtabOffset + sections[sec].sh_size > size_) { - ERROR_LOG(LOADER, "Symbols truncated - ignoring"); - return false; - } for (int sym = 0; sym= size_) - continue; if (bRelocate) value += sectionAddrs[sectionIndex]; diff --git a/Core/ELF/ElfReader.h b/Core/ELF/ElfReader.h index 9dcde2980a..0284b56bd4 100644 --- a/Core/ELF/ElfReader.h +++ b/Core/ELF/ElfReader.h @@ -77,23 +77,15 @@ public: const u8 *GetPtr(u32 offset) const { return (const u8*)base + offset; } - // Note: zero is not a valid output, means unavailable. - u32 GetSectionDataOffset(int section) const { - if (section < 0 || section >= header->e_shnum) - return 0; - if (sections[section].sh_type == SHT_NOBITS) - return 0; - return sections[section].sh_offset; - } const u8 *GetSectionDataPtr(int section) const { - u32 offset = GetSectionDataOffset(section); - if (offset == 0 || offset > size_) + if (section < 0 || section >= header->e_shnum) + return nullptr; + if (sections[section].sh_type != SHT_NOBITS) + return GetPtr(sections[section].sh_offset); + else return nullptr; - return GetPtr(offset); } const u8 *GetSegmentPtr(int segment) const { - if (segments[segment].p_offset > size_) - return nullptr; return GetPtr(segments[segment].p_offset); } u32 GetSectionAddr(SectionID section) const { From 6833589e382e08ac4a8fdf47ad41d934c536a9d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 12:22:05 +0200 Subject: [PATCH 114/374] Update elfSize to uncompressed elf size when needed. Fixes infinite loading in Wipeout. Also minor cleanups. --- Core/ELF/ElfReader.cpp | 8 ++++---- Core/ELF/ElfReader.h | 2 +- Core/HLE/sceKernelModule.cpp | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index 980e427e83..d85867978c 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -401,9 +401,6 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) // e_ident[EI_VERSION] is ignored - sectionOffsets = new u32[GetNumSections()]; - sectionAddrs = new u32[GetNumSections()]; - // Should we relocate? bRelocate = (header->e_type != ET_EXEC); @@ -513,6 +510,9 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) DEBUG_LOG(LOADER,"%i sections:", header->e_shnum); + sectionOffsets = new u32[GetNumSections()]; + sectionAddrs = new u32[GetNumSections()]; + for (int i = 0; i < GetNumSections(); i++) { const Elf32_Shdr *s = §ions[i]; @@ -534,7 +534,7 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) } } - DEBUG_LOG(LOADER,"Relocations:"); + DEBUG_LOG(LOADER, "Relocations:"); // Second pass: Do necessary relocations for (int i = 0; i < GetNumSections(); i++) diff --git a/Core/ELF/ElfReader.h b/Core/ELF/ElfReader.h index 0284b56bd4..f3ddbfee4b 100644 --- a/Core/ELF/ElfReader.h +++ b/Core/ELF/ElfReader.h @@ -154,7 +154,7 @@ private: u32 entryPoint = 0; u32 totalSize = 0; u32 vaddr = 0; - u32 segmentVAddr[32]; + u32 segmentVAddr[32]{}; size_t size_ = 0; u32 firstSegAlign = 0; }; diff --git a/Core/HLE/sceKernelModule.cpp b/Core/HLE/sceKernelModule.cpp index a482395a73..a5d7264827 100644 --- a/Core/HLE/sceKernelModule.cpp +++ b/Core/HLE/sceKernelModule.cpp @@ -1198,6 +1198,7 @@ static PSPModule *__KernelLoadELFFromPtr(const u8 *ptr, size_t elfSize, u32 load } const auto maxElfSize = std::max(head->elf_size, head->psp_size); newptr = new u8[maxElfSize]; + elfSize = maxElfSize; ptr = newptr; magicPtr = (u32_le *)ptr; int ret = pspDecryptPRX(in, (u8*)ptr, head->psp_size); From 50285f6bf60dc50a230786de088a1ec42f95200e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 13:29:09 +0200 Subject: [PATCH 115/374] Revert "Revert "Loader: Validate offsets and truncation in ELF."" This reverts commit 470edac18a1af1f8107338db5357f7a625d3cb44. --- Core/ELF/ElfReader.cpp | 45 ++++++++++++++++++++++++++++++++++++------ Core/ELF/ElfReader.h | 18 ++++++++++++----- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Core/ELF/ElfReader.cpp b/Core/ELF/ElfReader.cpp index d85867978c..a4a6bfb856 100644 --- a/Core/ELF/ElfReader.cpp +++ b/Core/ELF/ElfReader.cpp @@ -34,9 +34,10 @@ const char *ElfReader::GetSectionName(int section) const { if (sections[section].sh_type == SHT_NULL) return nullptr; + int stringsOffset = GetSectionDataOffset(header->e_shstrndx); int nameOffset = sections[section].sh_name; - if (nameOffset < 0 || (size_t)nameOffset >= size_) { - ERROR_LOG(LOADER, "ELF: Bad name offset %d in section %d (max = %d)", nameOffset, section, (int)size_); + if (nameOffset < 0 || (size_t)nameOffset + stringsOffset >= size_) { + ERROR_LOG(LOADER, "ELF: Bad name offset %d + %d in section %d (max = %d)", nameOffset, stringsOffset, section, (int)size_); return nullptr; } const char *ptr = (const char *)GetSectionDataPtr(header->e_shstrndx); @@ -235,6 +236,10 @@ void ElfReader::LoadRelocations2(int rel_seg) const Elf32_Phdr *ph = segments + rel_seg; buf = (u8*)GetSegmentPtr(rel_seg); + if (!buf) { + ERROR_LOG(LOADER, "Rel2 segment invalid"); + return; + } end = buf+ph->p_filesz; flag_bits = buf[2]; @@ -383,6 +388,12 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) { DEBUG_LOG(LOADER,"String section: %i", header->e_shstrndx); + if (size_ < sizeof(Elf32_Ehdr)) { + ERROR_LOG(LOADER, "Truncated ELF header, %d bytes", (int)size_); + // Probably not the right error code. + return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + } + if (header->e_ident[0] != ELFMAG0 || header->e_ident[1] != ELFMAG1 || header->e_ident[2] != ELFMAG2 || header->e_ident[3] != ELFMAG3) return SCE_KERNEL_ERROR_UNSUPPORTED_PRX_TYPE; @@ -399,6 +410,12 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) if (header->e_ident[EI_DATA] != ELFDATA2LSB) return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + if (size_ < header->e_phoff + sizeof(Elf32_Phdr) * GetNumSegments() || size_ < header->e_shoff + sizeof(Elf32_Shdr) * GetNumSections()) { + ERROR_LOG(LOADER, "Truncated ELF, %d bytes with %d sections and %d segments", (int)size_, GetNumSections(), GetNumSegments()); + // Probably not the right error code. + return SCE_KERNEL_ERROR_MEMBLOCK_ALLOC_FAILED; + } + // e_ident[EI_VERSION] is ignored // Should we relocate? @@ -409,11 +426,11 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) for (int i = 0; i < GetNumSections(); i++) { const Elf32_Shdr *s = §ions[i]; const char *name = GetSectionName(i); - if (name && !strcmp(name, ".rodata.sceModuleInfo")) { + if (name && !strcmp(name, ".rodata.sceModuleInfo") && s->sh_offset + sizeof(PspModuleInfo) <= size_) { modInfo = (const PspModuleInfo *)GetPtr(s->sh_offset); } } - if (!modInfo && GetNumSegments() >= 1) { + if (!modInfo && GetNumSegments() >= 1 && (segments[0].p_paddr & 0x7FFFFFFF) + sizeof(PspModuleInfo) <= size_) { modInfo = (const PspModuleInfo *)GetPtr(segments[0].p_paddr & 0x7FFFFFFF); } @@ -490,6 +507,10 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) u32 writeAddr = segmentVAddr[i]; const u8 *src = GetSegmentPtr(i); + if (!src || p->p_offset + p->p_filesz > size_) { + ERROR_LOG(LOADER, "Segment %d pointer invalid - truncated?", i); + continue; + } u8 *dst = Memory::GetPointerWrite(writeAddr); u32 srcSize = p->p_filesz; u32 dstSize = p->p_memsz; @@ -557,9 +578,11 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) int numRelocs = s->sh_size / sizeof(Elf32_Rel); Elf32_Rel *rels = (Elf32_Rel *)GetSectionDataPtr(i); + if (GetSectionDataOffset(i) + sizeof(Elf32_Rel) * numRelocs > size_) + rels = nullptr; DEBUG_LOG(LOADER,"%s: Performing %i relocations on %s : offset = %08x", name, numRelocs, GetSectionName(sectionToModify), sections[i].sh_offset); - if (!LoadRelocations(rels, numRelocs)) { + if (!rels || !LoadRelocations(rels, numRelocs)) { WARN_LOG(LOADER, "LoadInto: Relocs failed, trying anyway"); } } @@ -607,7 +630,9 @@ int ElfReader::LoadInto(u32 loadAddress, bool fromTop) int numRelocs = p->p_filesz / sizeof(Elf32_Rel); Elf32_Rel *rels = (Elf32_Rel *)GetSegmentPtr(i); - if (!LoadRelocations(rels, numRelocs)) { + if (p->p_offset + p->p_filesz > size_) + rels = nullptr; + if (!rels || !LoadRelocations(rels, numRelocs)) { ERROR_LOG(LOADER, "LoadInto: Relocs failed, trying anyway (2)"); } } else if (p->p_type == PT_PSPREL2) { @@ -695,11 +720,17 @@ bool ElfReader::LoadSymbols() int stringSection = sections[sec].sh_link; const char *stringBase = (const char*)GetSectionDataPtr(stringSection); + u32 stringOffset = GetSectionDataOffset(stringSection); //We have a symbol table! Elf32_Sym *symtab = (Elf32_Sym *)(GetSectionDataPtr(sec)); + u32 symtabOffset = GetSectionDataOffset(sec); int numSymbols = sections[sec].sh_size / sizeof(Elf32_Sym); + if (!stringBase || !symtab || symtabOffset + sections[sec].sh_size > size_) { + ERROR_LOG(LOADER, "Symbols truncated - ignoring"); + return false; + } for (int sym = 0; sym= size_) + continue; if (bRelocate) value += sectionAddrs[sectionIndex]; diff --git a/Core/ELF/ElfReader.h b/Core/ELF/ElfReader.h index f3ddbfee4b..ff10e5d31a 100644 --- a/Core/ELF/ElfReader.h +++ b/Core/ELF/ElfReader.h @@ -77,15 +77,23 @@ public: const u8 *GetPtr(u32 offset) const { return (const u8*)base + offset; } - const u8 *GetSectionDataPtr(int section) const { + // Note: zero is not a valid output, means unavailable. + u32 GetSectionDataOffset(int section) const { if (section < 0 || section >= header->e_shnum) + return 0; + if (sections[section].sh_type == SHT_NOBITS) + return 0; + return sections[section].sh_offset; + } + const u8 *GetSectionDataPtr(int section) const { + u32 offset = GetSectionDataOffset(section); + if (offset == 0 || offset > size_) return nullptr; - if (sections[section].sh_type != SHT_NOBITS) - return GetPtr(sections[section].sh_offset); - else - return nullptr; + return GetPtr(offset); } const u8 *GetSegmentPtr(int segment) const { + if (segments[segment].p_offset > size_) + return nullptr; return GetPtr(segments[segment].p_offset); } u32 GetSectionAddr(SectionID section) const { From 69bc7b060fa4f81abdcdbfb31415d268678bffcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 17:14:56 +0200 Subject: [PATCH 116/374] glslang: Set a missing resource limit. Avoids spurious errors in shader unit test --- Common/GPU/Shader.cpp | 1 + unittest/TestShaderGenerators.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/GPU/Shader.cpp b/Common/GPU/Shader.cpp index ac90a9f404..1fce76ff66 100644 --- a/Common/GPU/Shader.cpp +++ b/Common/GPU/Shader.cpp @@ -202,6 +202,7 @@ void init_resources(TBuiltInResource &Resources) { Resources.maxCullDistances = 8; Resources.maxCombinedClipAndCullDistances = 8; Resources.maxSamples = 4; + Resources.maxDualSourceDrawBuffersEXT = 1; Resources.limits.nonInductiveForLoops = 1; Resources.limits.whileLoops = 1; Resources.limits.doWhileLoops = 1; diff --git a/unittest/TestShaderGenerators.cpp b/unittest/TestShaderGenerators.cpp index fa5fd1eb7c..d5f2f9cc55 100644 --- a/unittest/TestShaderGenerators.cpp +++ b/unittest/TestShaderGenerators.cpp @@ -560,6 +560,7 @@ bool TestGeometryShaders() { std::string genErrorString[numLanguages]; for (int j = 0; j < numLanguages; j++) { + buffer[j][0] = 0; generateSuccess[j] = GenerateGShader(id, buffer[j], languages[j], bugs, &genErrorString[j]); if (!genErrorString[j].empty()) { printf("%s\n", genErrorString[j].c_str()); @@ -569,7 +570,7 @@ bool TestGeometryShaders() { for (int j = 0; j < numLanguages; j++) { if (strlen(buffer[j]) >= CODE_BUFFER_SIZE) { - printf("Geoemtry shader exceeded buffer:\n\n%s\n", LineNumberString(buffer[j]).c_str()); + printf("Geometry shader exceeded buffer:\n\n%s\n", LineNumberString(buffer[j]).c_str()); for (int i = 0; i < numLanguages; i++) { delete[] buffer[i]; } From aec22491fe2b28fb836f98b5785b6839bec8296c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 17:16:52 +0200 Subject: [PATCH 117/374] Don't expand alphaColorRef to 128 bytes on backends where we don't need to. --- GPU/Common/FragmentShaderGenerator.cpp | 10 +++++++--- GPU/Common/ShaderUniforms.cpp | 4 ++-- GPU/Common/ShaderUniforms.h | 11 ++++------- GPU/GLES/ShaderManagerGLES.cpp | 16 ++++++++++------ GPU/GLES/ShaderManagerGLES.h | 2 +- 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 2f8f248dbd..cce87a5487 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -353,7 +353,11 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, "uniform sampler2D testtex;\n"); } else { *uniformMask |= DIRTY_ALPHACOLORREF; - WRITE(p, "uniform vec4 u_alphacolorref;\n"); + if (compat.bitwiseOps) { + WRITE(p, "uniform uint u_alphacolorref;\n"); + } else { + WRITE(p, "uniform vec4 u_alphacolorref;\n"); + } if (compat.bitwiseOps && ((enableColorTest && !colorTestAgainstZero) || (enableAlphaTest && !alphaTestAgainstZero))) { *uniformMask |= DIRTY_ALPHACOLORMASK; WRITE(p, "uniform uint u_alphacolormask;\n"); @@ -882,7 +886,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu const char *alphaTestFuncs[] = { "#", "#", " != ", " == ", " >= ", " > ", " <= ", " < " }; if (alphaTestFuncs[alphaTestFunc][0] != '#') { if (compat.bitwiseOps) { - WRITE(p, " if ((roundAndScaleTo255i(v.a) & int(u_alphacolormask >> 24)) %s int(u_alphacolorref.a)) %s\n", alphaTestFuncs[alphaTestFunc], discardStatement); + WRITE(p, " if ((roundAndScaleTo255i(v.a) & int(u_alphacolormask >> 24)) %s int(u_alphacolorref >> 24)) %s\n", alphaTestFuncs[alphaTestFunc], discardStatement); } else if (gl_extensions.gpuVendor == GPU_VENDOR_IMGTEC) { // Work around bad PVR driver problem where equality check + discard just doesn't work. if (alphaTestFunc != GE_COMP_NOTEQUAL) { @@ -946,7 +950,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } else if (compat.bitwiseOps) { WRITE(p, " uint v_uint = roundAndScaleTo8x4(v.rgb);\n"); WRITE(p, " uint v_masked = v_uint & u_alphacolormask;\n"); - WRITE(p, " uint colorTestRef = packFloatsTo8x4(u_alphacolorref.rgb) & u_alphacolormask;\n"); + WRITE(p, " uint colorTestRef = (u_alphacolorref & u_alphacolormask) & 0xFFFFFFu;\n"); WRITE(p, " if (v_masked %s colorTestRef) %s\n", test, discardStatement); } else if (gl_extensions.gpuVendor == GPU_VENDOR_IMGTEC) { WRITE(p, " if (roundTo255thv(v.rgb) %s u_alphacolorref.rgb) %s\n", test, discardStatement); diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index b276f7f094..3c56d833e5 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -77,13 +77,13 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView Uint8x3ToFloat3(ub->texEnvColor, gstate.texenvcolor); } if (dirtyUniforms & DIRTY_ALPHACOLORREF) { - Uint8x3ToInt4_Alpha(ub->alphaColorRef, gstate.getColorTestRef(), gstate.getAlphaTestRef() & gstate.getAlphaTestMask()); + ub->alphaColorRef = gstate.getColorTestRef() | ((gstate.getAlphaTestRef() & gstate.getAlphaTestMask()) << 24); } if (dirtyUniforms & DIRTY_ALPHACOLORMASK) { ub->colorTestMask = gstate.getColorTestMask() | (gstate.getAlphaTestMask() << 24); } if (dirtyUniforms & DIRTY_FOGCOLOR) { - Uint8x3ToFloat4(ub->fogColor, gstate.fogcolor); + Uint8x3ToFloat3(ub->fogColor, gstate.fogcolor); } if (dirtyUniforms & DIRTY_SHADERBLEND) { Uint8x3ToFloat3(ub->blendFixA, gstate.getFixA()); diff --git a/GPU/Common/ShaderUniforms.h b/GPU/Common/ShaderUniforms.h index 04b6437dff..68834e2fd8 100644 --- a/GPU/Common/ShaderUniforms.h +++ b/GPU/Common/ShaderUniforms.h @@ -17,7 +17,7 @@ enum : uint64_t { DIRTY_MATDIFFUSE | DIRTY_MATSPECULAR | DIRTY_MATEMISSIVE | DIRTY_AMBIENT, }; -// Currently 480 bytes. Probably can't get to 256 (nVidia's UBO alignment, also common in other vendors). +// Currently 448 bytes. // Every line here is a 4-float. struct alignas(16) UB_VS_FS_Base { float proj[16]; @@ -34,9 +34,8 @@ struct alignas(16) UB_VS_FS_Base { uint32_t spline_counts; uint32_t depal_mask_shift_off_fmt; // 4 params packed into one. uint32_t colorWriteMask; float mipBias; // Fragment data - float fogColor[4]; // .w is unused + float fogColor[3]; uint32_t alphaColorRef; float texEnvColor[3]; uint32_t colorTestMask; - int alphaColorRef[4]; float blendFixA[3]; float stencil; float blendFixB[3]; float rotation; float texClamp[4]; @@ -58,10 +57,8 @@ R"( mat4 u_proj; uint u_depal_mask_shift_off_fmt; uint u_colorWriteMask; float u_mipBias; - vec3 u_fogcolor; - vec3 u_texenv; - uint u_alphacolormask; - ivec4 u_alphacolorref; + vec3 u_fogcolor; uint u_alphacolorref; + vec3 u_texenv; uint u_alphacolormask; vec3 u_blendFixA; float u_stencilReplaceValue; vec3 u_blendFixB; float u_rotation; vec4 u_texclamp; diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index a1f37a12f4..bc0193e1d6 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -359,7 +359,7 @@ void LinkedShader::use(const ShaderID &VSID) { // Note that we no longer track attr masks here - we do it for the input layouts instead. } -void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBufferedRendering) { +void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBufferedRendering, const Draw::DeviceCaps &caps) { u64 dirty = dirtyUniforms & availableUniforms; dirtyUniforms = 0; @@ -432,8 +432,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu render_->SetUniformM4x4(&u_proj, flippedMatrix.m); render_->SetUniformF1(&u_rotation, useBufferedRendering ? 0 : (float)g_display_rotation); } - if (dirty & DIRTY_PROJTHROUGHMATRIX) - { + if (dirty & DIRTY_PROJTHROUGHMATRIX) { Matrix4x4 proj_through; if (useBufferedRendering) { proj_through.setOrtho(0.0f, gstate_c.curRTWidth, 0.0f, gstate_c.curRTHeight, 0.0f, 1.0f); @@ -446,7 +445,12 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu SetColorUniform3(render_, &u_texenv, gstate.texenvcolor); } if (dirty & DIRTY_ALPHACOLORREF) { - SetColorUniform3Alpha255(render_, &u_alphacolorref, gstate.getColorTestRef(), gstate.getAlphaTestRef() & gstate.getAlphaTestMask()); + if (caps.fragmentShaderInt32Supported) { + // Same as bitwiseOps really + render_->SetUniformUI1(&u_alphacolorref, gstate.getColorTestRef() | ((gstate.getAlphaTestRef() & gstate.getAlphaTestMask()) << 24)); + } else { + SetColorUniform3Alpha255(render_, &u_alphacolorref, gstate.getColorTestRef(), gstate.getAlphaTestRef() & gstate.getAlphaTestMask()); + } } if (dirty & DIRTY_ALPHACOLORMASK) { render_->SetUniformUI1(&u_alphacolormask, gstate.getColorTestMask() | (gstate.getAlphaTestMask() << 24)); @@ -813,7 +817,7 @@ LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs, } if (lastVShaderSame_ && FSID == lastFSID_) { - lastShader_->UpdateUniforms(vertType, VSID, useBufferedRendering); + lastShader_->UpdateUniforms(vertType, VSID, useBufferedRendering, draw_->GetDeviceCaps()); return lastShader_; } @@ -856,7 +860,7 @@ LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs, } else { ls->use(VSID); } - ls->UpdateUniforms(vertType, VSID, useBufferedRendering); + ls->UpdateUniforms(vertType, VSID, useBufferedRendering, draw_->GetDeviceCaps()); lastShader_ = ls; return ls; diff --git a/GPU/GLES/ShaderManagerGLES.h b/GPU/GLES/ShaderManagerGLES.h index 2dd715cc0b..47fd2105aa 100644 --- a/GPU/GLES/ShaderManagerGLES.h +++ b/GPU/GLES/ShaderManagerGLES.h @@ -35,7 +35,7 @@ public: ~LinkedShader(); void use(const ShaderID &VSID); - void UpdateUniforms(u32 vertType, const ShaderID &VSID, bool useBufferedRendering); + void UpdateUniforms(u32 vertType, const ShaderID &VSID, bool useBufferedRendering, const Draw::DeviceCaps &caps); GLRenderManager *render_; Shader *vs_; From ee46f8992eab8621c11a3818f48cd8f8b9ef9458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 17:51:32 +0200 Subject: [PATCH 118/374] Don't use fragmentShaderInt32Support as a replacement for checking for bitwiseOps --- GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/D3D11/StateMappingD3D11.cpp | 2 +- GPU/Directx9/StateMappingDX9.cpp | 2 +- GPU/GLES/ShaderManagerGLES.cpp | 9 ++++----- GPU/GLES/ShaderManagerGLES.h | 3 ++- GPU/GLES/StateMappingGLES.cpp | 2 +- GPU/GPUCommon.cpp | 2 +- GPU/Vulkan/StateMappingVulkan.cpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index f6889e5cb0..c5f590a44e 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2059,7 +2059,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer bool useShaderDepal = framebufferManager_->GetCurrentRenderVFB() != framebuffer && !depth && !gstate_c.curTextureIs3D && - draw_->GetDeviceCaps().fragmentShaderInt32Supported; + draw_->GetShaderLanguageDesc().bitwiseOps; // TODO: Implement shader depal in the fragment shader generator for D3D11 at least. switch (draw_->GetShaderLanguageDesc().shaderLanguage) { diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index 2f86aa9914..6f113f23d0 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -147,7 +147,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { } else { keys_.blend.value = 0; - pipelineState_.Convert(draw_->GetDeviceCaps().fragmentShaderInt32Supported); + pipelineState_.Convert(draw_->GetShaderLanguageDesc().bitwiseOps); GenericMaskState &maskState = pipelineState_.maskState; GenericBlendState &blendState = pipelineState_.blendState; // We ignore the logicState on D3D since there's no support, the emulation of it is blend-and-shader only. diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index 0dfa352f00..bc1af41143 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -127,7 +127,7 @@ void DrawEngineDX9::ApplyDrawState(int prim) { } dxstate.colorMask.set(mask); } else { - pipelineState_.Convert(draw_->GetDeviceCaps().fragmentShaderInt32Supported); + pipelineState_.Convert(draw_->GetShaderLanguageDesc().bitwiseOps); GenericMaskState &maskState = pipelineState_.maskState; GenericBlendState &blendState = pipelineState_.blendState; // We ignore the logicState on D3D since there's no support, the emulation of it is blend-and-shader only. diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index bc0193e1d6..70295fdfdf 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -359,7 +359,7 @@ void LinkedShader::use(const ShaderID &VSID) { // Note that we no longer track attr masks here - we do it for the input layouts instead. } -void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBufferedRendering, const Draw::DeviceCaps &caps) { +void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBufferedRendering, const ShaderLanguageDesc &shaderLanguage) { u64 dirty = dirtyUniforms & availableUniforms; dirtyUniforms = 0; @@ -445,8 +445,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu SetColorUniform3(render_, &u_texenv, gstate.texenvcolor); } if (dirty & DIRTY_ALPHACOLORREF) { - if (caps.fragmentShaderInt32Supported) { - // Same as bitwiseOps really + if (shaderLanguage.bitwiseOps) { render_->SetUniformUI1(&u_alphacolorref, gstate.getColorTestRef() | ((gstate.getAlphaTestRef() & gstate.getAlphaTestMask()) << 24)); } else { SetColorUniform3Alpha255(render_, &u_alphacolorref, gstate.getColorTestRef(), gstate.getAlphaTestRef() & gstate.getAlphaTestMask()); @@ -817,7 +816,7 @@ LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs, } if (lastVShaderSame_ && FSID == lastFSID_) { - lastShader_->UpdateUniforms(vertType, VSID, useBufferedRendering, draw_->GetDeviceCaps()); + lastShader_->UpdateUniforms(vertType, VSID, useBufferedRendering, draw_->GetShaderLanguageDesc()); return lastShader_; } @@ -860,7 +859,7 @@ LinkedShader *ShaderManagerGLES::ApplyFragmentShader(VShaderID VSID, Shader *vs, } else { ls->use(VSID); } - ls->UpdateUniforms(vertType, VSID, useBufferedRendering, draw_->GetDeviceCaps()); + ls->UpdateUniforms(vertType, VSID, useBufferedRendering, draw_->GetShaderLanguageDesc()); lastShader_ = ls; return ls; diff --git a/GPU/GLES/ShaderManagerGLES.h b/GPU/GLES/ShaderManagerGLES.h index 47fd2105aa..a937318dd1 100644 --- a/GPU/GLES/ShaderManagerGLES.h +++ b/GPU/GLES/ShaderManagerGLES.h @@ -28,6 +28,7 @@ #include "GPU/Common/FragmentShaderGenerator.h" class Shader; +struct ShaderLanguageDesc; class LinkedShader { public: @@ -35,7 +36,7 @@ public: ~LinkedShader(); void use(const ShaderID &VSID); - void UpdateUniforms(u32 vertType, const ShaderID &VSID, bool useBufferedRendering, const Draw::DeviceCaps &caps); + void UpdateUniforms(u32 vertType, const ShaderID &VSID, bool useBufferedRendering, const ShaderLanguageDesc &shaderLanguage); GLRenderManager *render_; Shader *vs_; diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index cdcc9e5069..cbe5aecfd7 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -143,7 +143,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) { bool alphaMask = gstate.isClearModeAlphaMask(); renderManager->SetNoBlendAndMask((colorMask ? 7 : 0) | (alphaMask ? 8 : 0)); } else { - pipelineState_.Convert(draw_->GetDeviceCaps().fragmentShaderInt32Supported); + pipelineState_.Convert(draw_->GetShaderLanguageDesc().bitwiseOps); GenericMaskState &maskState = pipelineState_.maskState; GenericBlendState &blendState = pipelineState_.blendState; GenericLogicState &logicState = pipelineState_.logicState; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 7df0d02861..3d7b8b87cd 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3325,7 +3325,7 @@ u32 GPUCommon::CheckGPUFeatures() const { features |= GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH; } - if (draw_->GetDeviceCaps().fragmentShaderInt32Supported) { + if (draw_->GetShaderLanguageDesc().bitwiseOps) { features |= GPU_USE_LIGHT_UBERSHADER; } diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index 929482a88d..4a81988a7f 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -147,7 +147,7 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag bool alphaMask = gstate.isClearModeAlphaMask(); key.colorWriteMask = (colorMask ? (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT) : 0) | (alphaMask ? VK_COLOR_COMPONENT_A_BIT : 0); } else { - pipelineState_.Convert(draw_->GetDeviceCaps().fragmentShaderInt32Supported); + pipelineState_.Convert(draw_->GetShaderLanguageDesc().bitwiseOps); GenericMaskState &maskState = pipelineState_.maskState; GenericBlendState &blendState = pipelineState_.blendState; GenericLogicState &logicState = pipelineState_.logicState; From 089ac9a50e4c03bbc6bf91a3f53de4fa951a88ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 18:00:21 +0200 Subject: [PATCH 119/374] Comment about VR uniforms --- GPU/Common/ShaderUniforms.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/GPU/Common/ShaderUniforms.h b/GPU/Common/ShaderUniforms.h index 68834e2fd8..c746179316 100644 --- a/GPU/Common/ShaderUniforms.h +++ b/GPU/Common/ShaderUniforms.h @@ -40,6 +40,8 @@ struct alignas(16) UB_VS_FS_Base { float blendFixB[3]; float rotation; float texClamp[4]; float texClampOffset[2]; float fogCoef[2]; + // VR stuff is to go here, later. For normal drawing, we can then get away + // with just uploading the first 448 bytes of the struct (up to and including fogCoef). }; static const char * const ub_baseStr = From 6f703128ec7c9994be7f1ef05973429b794aeaa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 18:35:29 +0200 Subject: [PATCH 120/374] Experimentally revert "Delete some misguided FPU control code, that we definitely don't want" This reverts commit d52d383c224aa60d0d4541276e80e114486eaab3. --- Common/Math/math_util.cpp | 43 +++++++++++++++++++++++++++++++++++++-- Common/Math/math_util.h | 9 ++++++++ Qt/QtMain.cpp | 1 + SDL/SDLMain.cpp | 1 + ios/ViewController.mm | 3 +++ 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/Common/Math/math_util.cpp b/Common/Math/math_util.cpp index 6e72791f87..9b1a59a755 100644 --- a/Common/Math/math_util.cpp +++ b/Common/Math/math_util.cpp @@ -1,5 +1,44 @@ #include "Common/Math/math_util.h" +#include -#include +// QNX can only use RunFast mode and it is already the default. +#if defined(__ARM_ARCH_7A__) +// Enables 'RunFast' VFP mode. +void EnableFZ() { + int x; + asm( + "fmrx %[result],FPSCR \r\n" + "orr %[result],%[result],#16777216 \r\n" + "fmxr FPSCR,%[result]" + :[result] "=r" (x) : : + ); + //printf("ARM FPSCR: %08x\n",x); +} -// Could delete this file, but might find use again. +// New fastmode code from: http://pandorawiki.org/Floating_Point_Optimization +// These settings turbocharge the slow VFP unit on Cortex-A8 based chips by setting +// restrictions that permit running VFP instructions on the NEON unit. +// Denormal flush-to-zero, for example. +void FPU_SetFastMode() { + static const unsigned int x = 0x04086060; + static const unsigned int y = 0x03000000; + int r; + asm volatile ( + "fmrx %0, fpscr \n\t" //r0 = FPSCR + "and %0, %0, %1 \n\t" //r0 = r0 & 0x04086060 + "orr %0, %0, %2 \n\t" //r0 = r0 | 0x03000000 + "fmxr fpscr, %0 \n\t" //FPSCR = r0 + : "=r"(r) + : "r"(x), "r"(y) + ); +} + +#else + +void EnableFZ() { + // TODO +} + +void FPU_SetFastMode() {} + +#endif diff --git a/Common/Math/math_util.h b/Common/Math/math_util.h index 8f8962cab4..fd47662b54 100644 --- a/Common/Math/math_util.h +++ b/Common/Math/math_util.h @@ -189,3 +189,12 @@ inline uint16_t ShrinkToHalf(float full) { FP16 fp = float_to_half_fast3(fp32); return fp.u; } + +// FPU control. +void EnableFZ(); + +// Enable both FZ and Default-NaN. Is documented to flip some ARM implementation into a "run-fast" mode +// where they can schedule VFP instructions on the NEON unit (these implementations have +// very slow VFP units). +// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0274h/Babffifj.html +void FPU_SetFastMode(); diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index c6381a112d..bba1f1ae2b 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -316,6 +316,7 @@ static int mainInternal(QApplication &a) { emugl->resize(pixel_xres, pixel_yres); emugl->showFullScreen(); #endif + EnableFZ(); // Disable screensaver #if defined(QT_HAS_SYSTEMINFO) QScreenSaver ssObject(emugl); diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 0a6daa5361..da966cabae 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -807,6 +807,7 @@ int main(int argc, char *argv[]) { } else { joystick = nullptr; } + EnableFZ(); int framecount = 0; bool mouseDown = false; diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 63d241cf46..c90c30a22a 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -807,3 +807,6 @@ void bindDefaultFBO() { [sharedViewController bindDefaultFBO]; } + +void EnableFZ(){}; +void DisableFZ(){}; From 5318452e763e010141b84da35d2900c151340b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 10 Oct 2022 19:15:53 +0200 Subject: [PATCH 121/374] it_IT - Italian localization: Apply giona888's latest changes --- assets/lang/it_IT.ini | 105 +++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 53 deletions(-) diff --git a/assets/lang/it_IT.ini b/assets/lang/it_IT.ini index 849b469c39..e52113462f 100644 --- a/assets/lang/it_IT.ini +++ b/assets/lang/it_IT.ini @@ -19,15 +19,15 @@ WASAPI (fast) = WASAPI (veloce) [Controls] Analog Binding = Mappatura Analogico -Analog Settings = Impostazioni Analogico -Analog Style = Stile Analogico -Auto-rotation speed = Velocità rotazione automat. analogico Analog Limiter = Limitatore Analogico +Analog Settings = Impostazioni Analogico Analog Stick = Stick Analogico +Analog Style = Stile Analogico AnalogLimiter Tip = Quando viene premuto il tasto del limitatore analogico Auto = Automatico Auto-centering analog stick = Auto-centramento dello stick analogico Auto-hide buttons after seconds = Nascondi automat. i pulsanti dopo 2 secondi +Auto-rotation speed = Velocità rotazione automat. analogico Auto-switch = Auto-switch Base tilt position = Posizione inclinazione di base Binds = Assegnazioni @@ -82,7 +82,6 @@ Portrait = Ritratto Portrait Reversed = Ritratto invertito PSP Action Buttons = Pulsanti Azione PSP (△◯✕☐) Raw input = Input grezzo -Repeat mode = Repeat mode Reset to defaults = Reset ai predefiniti Screen aligned to ground = Schermo allineato a terra Screen at right angle to ground = Schermo perpendicolare a terra @@ -102,6 +101,7 @@ Tilt Sensitivity along X axis = Inverti Sensibilità sull'asse X Tilt Sensitivity along Y axis = Inverti Sensibilità sull'asse Y To Calibrate = Per calibrare, mantenere il dispositivo su una superficie piatta e premere "Calibra". Toggle mode = Scambia modalità +Repeat mode = Modalità ripeti Touch Control Visibility = Visibilità controlli Touch Use custom right analog = Usa analogico destro personalizzato Use Mouse Control = Usa il controllo con il mouse @@ -269,7 +269,7 @@ Show Developer Menu = Mostra Menu Sviluppatore Show on-screen messages = Mostra i messaggi on-screen Stats = Statistiche System Information = Informazioni Sistema -Texture ini file created = Texture ini file created +Texture ini file created = Creato file ini delle texture Texture Replacement = Sostituzione Texture Toggle Audio Debug = Attiva/Disattiva debug audio Toggle Freeze = Attiva/Disattiva congelamento @@ -490,6 +490,7 @@ Deposterize Tip = Sistema i possibili problemi visivi nelle texture upscalate Device = Dispositivo Direct3D 9 = Direct3D 9 Direct3D 11 = Direct3D 11 +Disable slower effects (speedup) = Disattiva gli effetti più lenti (veloce) Disabled = Disabilitato Display layout editor = Editor Display Display Resolution (HW scaler) = Risoluzione Display (scaler HW) @@ -500,7 +501,7 @@ Frame Rate Control = Controllo Framerate Frame Skipping = Salto frame Frame Skipping Type = Tipo di Salto frame FullScreen = Schermo Intero -GPU log profiler = GPU log profiler +GPU log profiler = Log profilo GPU Hack Settings = Impostazioni Hack (causerà dei problemi, sicuramente) Hardware Tessellation = Tassellazione Hardware Hardware Transform = Trasformazione Hardware @@ -512,7 +513,7 @@ Hybrid + Bicubic = Ibrido + Bicubico Ignore camera notch when centering = Ignora il notch della foto camera durante il centramento Internal Resolution = Risoluzione Interna Lazy texture caching = Caching lenta delle texture (velocizza) -Lazy texture caching Tip = Faster, but can cause text problems in a few games +Lazy texture caching Tip = Veloce, ma può causare problemi di testo in alcuni giochi Linear = Lineare Low = Bassa LowCurves = Riduci qualità splines e curve di bezier (maggior velocità) @@ -628,7 +629,7 @@ Audio = Audio Controls = Controlli Graphics = Grafica Networking = Rete -Search = Search +Search = Ricerca System = Sistema Tools = Strumenti @@ -660,10 +661,10 @@ D-pad left = D-pad sinistra D-pad right = D-pad destra D-pad up = D-pad su DevMenu = DevMenu -Display Landscape = Display Landscape -Display Landscape Reversed = Display Landscape Reversed -Display Portrait = Display Portrait -Display Portrait Reversed = Display Portrait Reversed +Display Landscape = Visuale panoramica +Display Landscape Reversed = Visuale panoramica invertita +Display Portrait = Visuale ritratto +Display Portrait Reversed = Visuale ritratto invertita Double tap button = Pulsante doppio tocco Down = D-Pad Giù Dpad = Dpad @@ -727,8 +728,6 @@ Center Left = Al centro a sinistra Center Right = Al centro a destra Change Mac Address = Cambia indirizzo MAC Change proAdhocServer Address = Cambia indirizzo server IP PRO ad hoc (localhost = istanze multiple) -ChangeMacSaveConfirm = Generate a new MAC address? -ChangeMacSaveWarning = Some games verify the MAC address when loading savedata, so this may break old saves. Chat = Chat Chat Button Position = Posizione del pulsante chat Chat Here = Scrivi qui @@ -804,12 +803,12 @@ Undo last save = Annulla ultimo salvataggio 5xBR-lv2 = 5xBR-lv2 AAColor = Colore AA Amount = Quantità -Animation speed (0 -> disable) = Animation speed (0 -> disable) +Animation speed (0 -> disable) = Velocità animazione (0 -> disabilita) Black border = Bordo nero Bloom = Sfocatura luminosa Brightness = Luminosità Cartoon = Disegno -CatmullRom = Bicubic (Catmull-Rom) Upscaler +CatmullRom = Upscaler Bicubico (Catmull-Rom) ColorCorrection = Correzione dei colori Contrast = Contrasto CRT = Linee di scansione CRT @@ -818,7 +817,7 @@ Gamma = Gamma Grayscale = Scala di grigi Intensity = Intensità InverseColors = Colori invertiti -MitchellNetravali = Bicubic (Mitchell-Netravali) Upscaler +MitchellNetravali = Upscaler Bicubico (Mitchell-Netravali) Natural = Colori naturali NaturalA = Colori naturali (nessuna sfocatura) Off = Nessuno @@ -864,10 +863,10 @@ tools = Strumenti Liberi utilizzati: # Add translators or contributors who translated PPSSPP into your language here. # Add translators1-6 for up to 6 lines of translator credits. # Leave extra lines blank. 4 contributors per line seems to look best. -translators1 = MrYadro, mgaver, adrian17, raven02, papel +translators1 = MrYadro, mgaver, VIRGINKLM, raven02 translators2 = sum2012, vnctdj, unknownbrackets, ufdada -translators3 = The Dax, wuspring, hrydgard, VIRGINKLM -translators4 = Vecna +translators3 = The Dax, wuspring, hrydgard, adrian17 +translators4 = papel translators5 = translators6 = Twitter @PPSSPP_emu = Twitter @@ -971,11 +970,11 @@ Date = Data Filename = Nome del file No screenshot = Nessuno screenshot None yet. Things will appear here after you save. = Ancora niente. Si inizierà a vedere qualcosa dopo il salvataggio. -Nothing matching '%1' was found. = Nothing matching '%1' was found. +Nothing matching '%1' was found. = Non è stata trovata nessuna corrispondenza su: '%1'. Save Data = Salvataggi Save States = Salvataggio stati Savedata Manager = Gestione dei Salvataggi -Showing matches for '%1'. = Showing matches for '%1'. +Showing matches for '%1'. = Corrispondenze per: '%1'. Size = Dimensioni [Screen] @@ -983,8 +982,8 @@ Cardboard VR OFF = Cardboard VR spenta Chainfire3DWarning = AVVISO: rilevato Chainfire3D, potrebbe causare problemi Failed to load state = Impossibile caricare il salvataggio di stato Failed to save state = Impossibile salvare il salvataggio di stato -Loaded. Game may refuse to save over different savedata. = Loaded. Game may refuse to save over different savedata. -Loaded. Game may refuse to save over newer savedata. = Loaded. Game may refuse to save over newer savedata +Loaded. Game may refuse to save over different savedata. = Caricato. Il gioco potrebbe rifiutarsi da salvare su dati di salvataggio differenti. +Loaded. Game may refuse to save over newer savedata. = Caricato. Il gioco potrebbe rifiutarsi da salvare su dati di salvataggio nuovi. Loaded. Save in game, restart, and load for less bugs. = Caricato. Salvataggio in gioco, riavvia, e carica per meno bug. fixed = Velocità: alternata GLToolsWarning = AVVISO: rilevato GLTools, potrebbe causare problemi @@ -1004,15 +1003,15 @@ saveNewTextures_false = Il salvataggio delle texture è stato disattivato. saveNewTextures_true = Le texture verranno salvate su disco. SpeedCustom2 = Velocità: alternativa 2 standard = Velocità: standard -State load undone = State load undone +State load undone = Annullato caricamento stato Untitled PSP game = Gioco PSP senza titolo [Search] -Clear filter = Clear filter -Filter = Filter -Filtering settings by '%1' = Filtering settings by '%1' -Find settings = Find settings -No settings matched '%1' = No settings matched '%1' +Clear filter = Svuota filtro +Filter = Filtro +Filtering settings by '%1' = Impostazioni filtro per '%1' +Find settings = Ricerca impostazioni +No settings matched '%1' = Nessuna impostazione con corrispondenza: '%1' [Store] Already Installed = Già installato @@ -1046,7 +1045,7 @@ Debug = Debug Debugger Present = Debugger presente Device Info = Informazioni dispositivo Directories = Cartelle -Display Color Formats = Display Color Formats +Display Color Formats = Formati colore di visualizzazione Display Information = Informazioni display Driver bugs = Driver bugs Driver Version = Versione dei Driver @@ -1058,7 +1057,7 @@ High precision int range = Ampiezza interi ad alta precisione Lang/Region = Lingua/Regione Memory Page Size = Ampiezza pagina di memoria Native Resolution = Risoluzione nativa -No GPU driver bugs detected = No GPU driver bugs detected +No GPU driver bugs detected = Nessun bug per i driver GPU rilevato OGL Extensions = Estensioni OGL OpenGL ES 2.0 Extensions = Estensioni OpenGL ES 2.0 OpenGL ES 3.0 Extensions = Estensioni OpenGL ES 3.0 @@ -1094,11 +1093,11 @@ AVI Dump started. = Dump AVI avviato AVI Dump stopped. = Dump AVI interrotto Cache ISO in RAM = Metti l'ISO in cache nella RAM (avvio lento) Change CPU Clock = Cambia la frequenza della CPU (instabile) -Color Saturation = Color Saturation -Color Tint = Color Tint -Error: load undo state is from a different game = Error: load undo state is from a different game -Failed to load state for load undo. Error in the file system. = Failed to load state for load undo. Error in the file system. -Floating symbols = Floating symbols +Color Saturation = Saturazione colore +Color Tint = Tonalità colore +Error: load undo state is from a different game = Errore: lo stato annullato proviene da un gioco diverso. +Failed to load state for load undo. Error in the file system. = Impossibile caricare lo stato da un caricamento annullato. Errore nel file system. +Floating symbols = Simboli fluttuanti Memory Stick folder = Cartella della Memory Stick Memory Stick size = Cambia dimensioni Memory Stick Change Nickname = Cambia Nick @@ -1127,15 +1126,15 @@ Failed to save state. Error in the file system. = Impossibile effettuare il salv Fast (lag on slow storage) = Veloce (lag nei dischi lenti) Fast Memory = Memoria Rapida (instabile) Force real clock sync (slower, less lag) = Forza sincronizzazione con frequenza reale (lento, meno lag) -Moving background = Moving background +Moving background = Spostamento dello sfondo No animation = Nessuna animazione Path does not exist! = Il percorso non esiste! PSP Memory Stick = Memory Stick PSP Recent games = Giochi recenti -Show Memory Stick folder = Show Memory Stick folder -Theme = Theme -UI = UI -frames, 0:off = frames, 0 = off +Show Memory Stick folder = Mostra cartella Memory Stick +Theme = Tema +UI = Interfaccia +frames, 0:off = frames, 0 = spento Games list settings = Impostazioni Lista giochi General = Generali Grid icon size = Dimensioni delle icone @@ -1192,7 +1191,7 @@ Use X to confirm = Usa ✕ come tasto di conferma VersionCheck = Controlla se ci sono aggiornamenti per PPSSPP WARNING: Android battery save mode is on = ATTENZIONE: La modalità Risparmio Energetico di Android è attivata WARNING: Battery save mode is on = ATTENZIONE: La modalità Risparmio Energetico è attivata -Waves = Waves +Waves = Onde YYYYMMDD = AAAAMMGG [TextureShaders] @@ -1205,16 +1204,16 @@ Tex4xBRZ = Tex4xBRZ Default = Default [UI Elements] -%1 button = %1 button -%1 checkbox = %1 checkbox -%1 choice = %1 choice -%1 heading = %1 heading -%1 radio button = %1 radio button -%1 text field = %1 text field -Choices: = Choices: -List: = List: -Progress: %1% = Progress: %1% -Screen representation = Screen representation +%1 button = %1 pulsante +%1 checkbox = %1 casella di controllo +%1 choice = %1 scelta +%1 heading = %1 intestazione +%1 radio button = %1 pulsante radio +%1 text field = %1 campo di testo +Choices: = Scelte: +List: = Lista: +Progress: %1% = Avanzamento: %1% +Screen representation = Rappresentazione su schermo [Upgrade] Details = Dettagli Dismiss = Ignora From b991a84b91c832690af31539b05e522070e703ee Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 16:43:19 -0700 Subject: [PATCH 122/374] GLES: Allow stencil texturing if supported. --- Common/GPU/OpenGL/GLQueueRunner.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index 80222bbfbf..c63f42301a 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -24,6 +24,12 @@ #elif !defined(GL_CLIP_DISTANCE0) #define GL_CLIP_DISTANCE0 0x3000 #endif +#ifndef GL_DEPTH_STENCIL_TEXTURE_MODE +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif +#ifndef GL_STENCIL_INDEX +#define GL_STENCIL_INDEX 0x1901 +#endif static constexpr int TEXCACHE_NAME_CACHE_SIZE = 16; @@ -1114,8 +1120,16 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last glBindTexture(GL_TEXTURE_2D, c.bind_fb_texture.framebuffer->z_stencil_texture.texture); curTex[slot] = &c.bind_fb_texture.framebuffer->z_stencil_texture; } + // This should be uncommon, so always set the mode. + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_DEPTH_COMPONENT); + } else if (c.bind_fb_texture.aspect == GL_STENCIL_BUFFER_BIT) { + if (curTex[slot] != &c.bind_fb_texture.framebuffer->z_stencil_texture) { + glBindTexture(GL_TEXTURE_2D, c.bind_fb_texture.framebuffer->z_stencil_texture.texture); + curTex[slot] = &c.bind_fb_texture.framebuffer->z_stencil_texture; + } + // This should be uncommon, so always set the mode. + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX); } else { - // Can't texture from stencil buffers. curTex[slot] = nullptr; } CHECK_GL_ERROR_IF_DEBUG(); From 59cc7a80000c30d7127b744fa8bdd873f7686459 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 16:54:29 -0700 Subject: [PATCH 123/374] GPU: Rename stencil write pipeline. --- GPU/Common/FramebufferManagerCommon.cpp | 4 ++-- GPU/Common/FramebufferManagerCommon.h | 4 ++-- GPU/Common/StencilCommon.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index c36d39a6f1..397d5ae764 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2807,8 +2807,8 @@ void FramebufferManagerCommon::DeviceLost() { DoRelease(reinterpretFromTo_[i][j]); } } - DoRelease(stencilUploadSampler_); - DoRelease(stencilUploadPipeline_); + DoRelease(stencilWriteSampler_); + DoRelease(stencilWritePipeline_); DoRelease(depthReadbackSampler_); DoRelease(depthReadbackPipeline_); DoRelease(draw2DPipelineColor_); diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 63f7b082ba..bb28032be0 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -568,8 +568,8 @@ protected: // Common implementation of stencil buffer upload. Also not 100% optimal, but not performance // critical either. - Draw::Pipeline *stencilUploadPipeline_ = nullptr; - Draw::SamplerState *stencilUploadSampler_ = nullptr; + Draw::Pipeline *stencilWritePipeline_ = nullptr; + Draw::SamplerState *stencilWriteSampler_ = nullptr; Draw::Pipeline *depthReadbackPipeline_ = nullptr; Draw::SamplerState *depthReadbackSampler_ = nullptr; diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index 2c32a2a06c..02dea5f739 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -196,7 +196,7 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, shaderManager_->DirtyLastShader(); textureCache_->ForgetLastTexture(); - if (!stencilUploadPipeline_) { + if (!stencilWritePipeline_) { const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); char *fsCode = new char[8192]; @@ -237,8 +237,8 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, { stencilUploadVs, stencilUploadFs }, inputLayout, stencilWrite, blendOff, rasterNoCull, &stencilUBDesc, }; - stencilUploadPipeline_ = draw_->CreateGraphicsPipeline(stencilWriteDesc, "stencil_upload"); - _assert_(stencilUploadPipeline_); + stencilWritePipeline_ = draw_->CreateGraphicsPipeline(stencilWriteDesc, "stencil_upload"); + _assert_(stencilWritePipeline_); delete[] fsCode; delete[] vsCode; @@ -252,7 +252,7 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, stencilUploadVs->Release(); SamplerStateDesc descNearest{}; - stencilUploadSampler_ = draw_->CreateSamplerState(descNearest); + stencilWriteSampler_ = draw_->CreateSamplerState(descNearest); } // Fullscreen triangle coordinates. @@ -297,11 +297,11 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, } draw_->BindTextures(TEX_SLOT_PSP_TEXTURE, 1, &tex); - draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &stencilUploadSampler_); + draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &stencilWriteSampler_); // We must bind the program after starting the render pass, and set the color mask after clearing. draw_->SetScissorRect(0, 0, w, h); - draw_->BindPipeline(stencilUploadPipeline_); + draw_->BindPipeline(stencilWritePipeline_); for (int i = 1; i < values; i += i) { if (!(usedBits & i)) { From c03d327ddd25c75b98c0f00e3ca4ea79852e8733 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 16:55:30 -0700 Subject: [PATCH 124/374] GLES: Refactor depth pipeline create. So we can reuse for stencil as well. --- GPU/GLES/DepthBufferGLES.cpp | 82 +++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 6b9dbc219c..03e5656ea1 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -92,6 +92,48 @@ static bool SupportsDepthTexturing() { return gl_extensions.VersionGEThan(3, 0); } +static Draw::Pipeline *CreateReadbackPipeline(Draw::DrawContext *draw, const char *tag, const UniformBufferDesc *ubDesc, const char *fs, const char *fsTag, const char *vs, const char *vsTag) { + using namespace Draw; + + const ShaderLanguageDesc &shaderLanguageDesc = draw->GetShaderLanguageDesc(); + + ShaderModule *readbackFs = draw->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)fs, strlen(fs), fsTag); + ShaderModule *readbackVs = draw->CreateShaderModule(ShaderStage::Vertex, shaderLanguageDesc.shaderLanguage, (const uint8_t *)vs, strlen(vs), vsTag); + _assert_(readbackFs && readbackVs); + + InputLayoutDesc desc = { + { + { 8, false }, + }, + { + { 0, SEM_POSITION, DataFormat::R32G32_FLOAT, 0 }, + }, + }; + InputLayout *inputLayout = draw->CreateInputLayout(desc); + + BlendState *blendOff = draw->CreateBlendState({ false, 0xF }); + DepthStencilState *stencilIgnore = draw->CreateDepthStencilState({}); + RasterState *rasterNoCull = draw->CreateRasterState({}); + + PipelineDesc readbackDesc{ + Primitive::TRIANGLE_LIST, + { readbackVs, readbackFs }, + inputLayout, stencilIgnore, blendOff, rasterNoCull, ubDesc, + }; + Draw::Pipeline *pipeline = draw->CreateGraphicsPipeline(readbackDesc, tag); + _assert_(pipeline); + + rasterNoCull->Release(); + blendOff->Release(); + stencilIgnore->Release(); + inputLayout->Release(); + + readbackFs->Release(); + readbackVs->Release(); + + return pipeline; +} + bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { using namespace Draw; @@ -117,44 +159,8 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int if (useColorPath) { if (!depthReadbackPipeline_) { - const ShaderLanguageDesc &shaderLanguageDesc = draw_->GetShaderLanguageDesc(); - - ShaderModule *depthReadbackFs = draw_->CreateShaderModule(ShaderStage::Fragment, shaderLanguageDesc.shaderLanguage, (const uint8_t *)depth_dl_fs, strlen(depth_dl_fs), "depth_dl_fs"); - ShaderModule *depthReadbackVs = draw_->CreateShaderModule(ShaderStage::Vertex, shaderLanguageDesc.shaderLanguage, (const uint8_t *)depth_vs, strlen(depth_vs), "depth_vs"); - _assert_(depthReadbackFs && depthReadbackVs); - - InputLayoutDesc desc = { - { - { 8, false }, - }, - { - { 0, SEM_POSITION, DataFormat::R32G32_FLOAT, 0 }, - }, - }; - InputLayout *inputLayout = draw_->CreateInputLayout(desc); - - BlendState *blendOff = draw_->CreateBlendState({ false, 0xF }); - DepthStencilState *stencilIgnore = draw_->CreateDepthStencilState({}); - RasterState *rasterNoCull = draw_->CreateRasterState({}); - - PipelineDesc depthReadbackDesc{ - Primitive::TRIANGLE_LIST, - { depthReadbackVs, depthReadbackFs }, - inputLayout, stencilIgnore, blendOff, rasterNoCull, &depthUBDesc, - }; - depthReadbackPipeline_ = draw_->CreateGraphicsPipeline(depthReadbackDesc, "depth_dl"); - _assert_(depthReadbackPipeline_); - - rasterNoCull->Release(); - blendOff->Release(); - stencilIgnore->Release(); - inputLayout->Release(); - - depthReadbackFs->Release(); - depthReadbackVs->Release(); - - SamplerStateDesc descNearest{}; - depthReadbackSampler_ = draw_->CreateSamplerState(descNearest); + depthReadbackPipeline_ = CreateReadbackPipeline(draw_, "depth_dl", &depthUBDesc, depth_dl_fs, "depth_dl_fs", depth_vs, "depth_vs"); + depthReadbackSampler_ = draw_->CreateSamplerState({}); } shaderManager_->DirtyLastShader(); From fc68cd9457bbc2df4c76ed3b5b8ac2d67e1ca566 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 17:09:14 -0700 Subject: [PATCH 125/374] GLES: Add debug readback of stencil data. This allows the existing gpu.buffer.renderStencil to snapshot the state. --- Common/GPU/OpenGL/GLFeatures.cpp | 2 +- Common/GPU/OpenGL/GLFeatures.h | 1 + GPU/Common/FramebufferManagerCommon.cpp | 10 +++ GPU/Common/FramebufferManagerCommon.h | 4 + GPU/GLES/DepthBufferGLES.cpp | 111 ++++++++++++++++++++++++ GPU/GLES/FramebufferManagerGLES.h | 1 + 6 files changed, 128 insertions(+), 1 deletion(-) diff --git a/Common/GPU/OpenGL/GLFeatures.cpp b/Common/GPU/OpenGL/GLFeatures.cpp index 103fe00985..ecec49c82e 100644 --- a/Common/GPU/OpenGL/GLFeatures.cpp +++ b/Common/GPU/OpenGL/GLFeatures.cpp @@ -544,8 +544,8 @@ void CheckGLExtensions() { } if (gl_extensions.VersionGEThan(4, 3)) { gl_extensions.ARB_copy_image = true; + gl_extensions.ARB_stencil_texturing = true; // ARB_explicit_uniform_location = true; - // ARB_stencil_texturing = true; // ARB_texture_view = true; // ARB_vertex_attrib_binding = true; } diff --git a/Common/GPU/OpenGL/GLFeatures.h b/Common/GPU/OpenGL/GLFeatures.h index 5fe965c3f0..0e07fd266f 100644 --- a/Common/GPU/OpenGL/GLFeatures.h +++ b/Common/GPU/OpenGL/GLFeatures.h @@ -71,6 +71,7 @@ struct GLExtensions { bool ARB_depth_clamp; bool ARB_uniform_buffer_object; bool ARB_texture_non_power_of_two; + bool ARB_stencil_texturing; // EXT bool EXT_swap_control_tear; diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 397d5ae764..e408798375 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2578,6 +2578,10 @@ bool FramebufferManagerCommon::GetStencilbuffer(u32 fb_address, int fb_stride, G // No need to free on failure, the caller/destructor will do that. Usually this is a reused buffer, anyway. buffer.Allocate(w, h, GPU_DBG_FORMAT_8BIT, flipY); bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_STENCIL_BIT, 0, 0, w,h, Draw::DataFormat::S8, buffer.GetData(), w, "GetStencilbuffer"); + if (!retval) { + // Try ReadbackStencilbufferSync, in case GLES. + retval = ReadbackStencilbufferSync(vfb->fbo, 0, 0, w, h, buffer.GetData(), w); + } // That may have unbound the framebuffer, rebind to avoid crashes when debugging. RebindFramebuffer("RebindFramebuffer - GetStencilbuffer"); return retval; @@ -2652,6 +2656,10 @@ bool FramebufferManagerCommon::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, i return draw_->CopyFramebufferToMemorySync(fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, pixels, pixelsStride, "ReadbackDepthbufferSync"); } +bool FramebufferManagerCommon::ReadbackStencilbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint8_t *pixels, int pixelsStride) { + return draw_->CopyFramebufferToMemorySync(fbo, Draw::FB_DEPTH_BIT, x, y, w, h, Draw::DataFormat::S8, pixels, pixelsStride, "ReadbackStencilbufferSync"); +} + void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { // Clamp to bufferWidth. Sometimes block transfers can cause this to hit. if (x + w >= vfb->bufferWidth) { @@ -2809,6 +2817,8 @@ void FramebufferManagerCommon::DeviceLost() { } DoRelease(stencilWriteSampler_); DoRelease(stencilWritePipeline_); + DoRelease(stencilReadbackSampler_); + DoRelease(stencilReadbackPipeline_); DoRelease(depthReadbackSampler_); DoRelease(depthReadbackPipeline_); DoRelease(draw2DPipelineColor_); diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index bb28032be0..ffcab7a1ec 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -444,6 +444,7 @@ protected: virtual void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel); // Used for when a shader is required, such as GLES. virtual bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride); + virtual bool ReadbackStencilbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint8_t *pixels, int pixelsStride); void SetViewport2D(int x, int y, int w, int h); Draw::Texture *MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height); void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags); @@ -571,6 +572,9 @@ protected: Draw::Pipeline *stencilWritePipeline_ = nullptr; Draw::SamplerState *stencilWriteSampler_ = nullptr; + // Used on GLES where we can't directly readback depth or stencil, but here for simplicity. + Draw::Pipeline *stencilReadbackPipeline_ = nullptr; + Draw::SamplerState *stencilReadbackSampler_ = nullptr; Draw::Pipeline *depthReadbackPipeline_ = nullptr; Draw::SamplerState *depthReadbackSampler_ = nullptr; diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 03e5656ea1..5283612f51 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -85,6 +85,45 @@ const UniformBufferDesc depthUBDesc{ sizeof(DepthUB), { { "u_depthTo8", -1, -1, UniformType::FLOAT4, 32 }, } }; +static const char *stencil_dl_fs = R"( +#ifdef GL_ES +#ifdef GL_FRAGMENT_PRECISION_HIGH +precision highp float; +#else +precision mediump float; +#endif +#endif +#if __VERSION__ >= 130 +#define varying in +#define texture2D texture +#define gl_FragColor fragColor0 +out vec4 fragColor0; +#endif +varying vec2 v_texcoord; +lowp uniform usampler2D tex; +void main() { + uint stencil = texture2D(tex, v_texcoord).r; + float scaled = float(stencil) / 255.0; + gl_FragColor = vec4(scaled, scaled, scaled, scaled); +} +)"; + +static const char *stencil_vs = R"( +#ifdef GL_ES +precision highp float; +#endif +#if __VERSION__ >= 130 +#define attribute in +#define varying out +#endif +attribute vec2 a_position; +varying vec2 v_texcoord; +void main() { + v_texcoord = a_position * 2.0; + gl_Position = vec4(v_texcoord * 2.0 - vec2(1.0, 1.0), 0.0, 1.0); +} +)"; + static bool SupportsDepthTexturing() { if (gl_extensions.IsGLES) { return gl_extensions.OES_packed_depth_stencil && (gl_extensions.OES_depth_texture || gl_extensions.GLES3); @@ -248,3 +287,75 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); return true; } + +// Well, this is not depth, but it's depth/stencil related. +bool FramebufferManagerGLES::ReadbackStencilbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint8_t *pixels, int pixelsStride) { + using namespace Draw; + + if (!fbo) { + ERROR_LOG_REPORT_ONCE(vfbfbozero, SCEGE, "ReadbackStencilbufferSync: bad fbo"); + return false; + } + + const bool useColorPath = gl_extensions.IsGLES; + if (!useColorPath) { + return draw_->CopyFramebufferToMemorySync(fbo, FB_STENCIL_BIT, x, y, w, h, DataFormat::S8, pixels, pixelsStride, "ReadbackStencilbufferSync"); + } + + // Unsupported below GLES 3.1 or without ARB_stencil_texturing. + // OES_texture_stencil8 is related, but used to specify texture data. + if ((gl_extensions.IsGLES && !gl_extensions.VersionGEThan(3, 1)) && !gl_extensions.ARB_stencil_texturing) + return false; + + // Pixel size always 4 here because we always request RGBA back. + const u32 bufSize = w * h * 4; + if (!convBuf_ || convBufSize_ < bufSize) { + delete[] convBuf_; + convBuf_ = new u8[bufSize]; + convBufSize_ = bufSize; + } + + if (!stencilReadbackPipeline_) { + stencilReadbackPipeline_ = CreateReadbackPipeline(draw_, "stencil_dl", &depthUBDesc, stencil_dl_fs, "stencil_dl_fs", stencil_vs, "stencil_vs"); + stencilReadbackSampler_ = draw_->CreateSamplerState({}); + } + + shaderManager_->DirtyLastShader(); + auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); + draw_->BindFramebufferAsRenderTarget(blitFBO, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackStencilbufferSync"); + Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; + draw_->SetViewports(1, &viewport); + + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_STENCIL_BIT, 0); + draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &stencilReadbackSampler_); + + // We must bind the program after starting the render pass. + draw_->SetScissorRect(0, 0, w, h); + draw_->BindPipeline(stencilReadbackPipeline_); + + // Fullscreen triangle coordinates. + static const float positions[6] = { + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + }; + draw_->DrawUP(positions, 3); + + draw_->CopyFramebufferToMemorySync(blitFBO, FB_COLOR_BIT, x, y, w, h, DataFormat::R8G8B8A8_UNORM, convBuf_, w, "ReadbackStencilbufferSync"); + + textureCache_->ForgetLastTexture(); + + // TODO: Use 1/4 width to write all values directly and skip CPU conversion? + uint8_t *dest = pixels; + const u32_le *packed32 = (u32_le *)convBuf_; + for (int yp = 0; yp < h; ++yp) { + for (int xp = 0; xp < w; ++xp) { + dest[xp] = packed32[xp] & 0xFF; + } + dest += pixelsStride; + packed32 += w; + } + + gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); + return true; +} diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 36aa2545fd..7bbfa1a510 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -39,6 +39,7 @@ public: protected: void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) override; + bool ReadbackStencilbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint8_t *pixels, int pixelsStride) override; private: u8 *convBuf_ = nullptr; From 728748b108e8b01eabe76f386ddf4aa998a55d0b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 17:30:15 -0700 Subject: [PATCH 126/374] MIPS: Fix non standard layout offsets. --- Core/MIPS/MIPS.h | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/MIPS/MIPS.h b/Core/MIPS/MIPS.h index d2f4a4ba54..62dc150203 100644 --- a/Core/MIPS/MIPS.h +++ b/Core/MIPS/MIPS.h @@ -267,7 +267,6 @@ public: void ClearJitCache(); -protected: void ProcessPendingClears(); // Doesn't need save stating. From 26fd063cd1e26f7e4263e6b22b78044971cad57a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 19:14:34 -0700 Subject: [PATCH 127/374] Vulkan: Fix initial depth copy w/o existing depth. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index c1da294a0f..8f6b48420d 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1724,6 +1724,10 @@ void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) { // We can't copy only depth or only stencil unfortunately - or can we?. if (step.copy.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { + _dbg_assert_(src->depth.image != VK_NULL_HANDLE); + + dst->EnsureDepthImage(cmd); + if (src->depth.layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { SetupTransitionToTransferSrc(src->depth, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, &recordBarrier_); } @@ -1989,6 +1993,7 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd srcImage = &step.readback.src->color; } else if (step.readback.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { srcImage = &step.readback.src->depth; + _dbg_assert_(srcImage->image != VK_NULL_HANDLE); } else { _dbg_assert_msg_(false, "No image aspect to readback?"); return; From c89cf1cde7bde7e27435ad717934c921c5175f4e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 21:28:14 -0700 Subject: [PATCH 128/374] D3D9: Implement CopyFramebufferToMemorySync(). This works like other backends, including D3D11. This allows us to get rid of the old implementation and reuse more code. --- Common/GPU/D3D11/thin3d_d3d11.cpp | 24 +++- Common/GPU/D3D9/thin3d_d3d9.cpp | 103 ++++++++++++++++ GPU/Directx9/FramebufferManagerDX9.cpp | 155 ------------------------- GPU/Directx9/FramebufferManagerDX9.h | 6 - 4 files changed, 121 insertions(+), 167 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 3b9837fbe1..0b10980c0f 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -1623,13 +1623,25 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel } break; case FB_STENCIL_BIT: - _assert_(destFormat == DataFormat::S8); - for (int y = 0; y < bh; y++) { - uint8_t *destStencil = (uint8_t *)pixels + y * pixelStride; - const uint32_t *src = (const uint32_t *)(srcWithOffset + map.RowPitch * y); - for (int x = 0; x < bw; x++) { - destStencil[x] = src[x] >> 24; + if (srcFormat == destFormat) { + // Can just memcpy when it matches no matter the format! + uint8_t *dst = (uint8_t *)pixels; + const uint8_t *src = (const uint8_t *)srcWithOffset; + for (int y = 0; y < bh; ++y) { + memcpy(dst, src, bw * DataFormatSizeInBytes(srcFormat)); + dst += pixelStride * DataFormatSizeInBytes(srcFormat); + src += map.RowPitch; } + } else if (destFormat == DataFormat::S8) { + for (int y = 0; y < bh; y++) { + uint8_t *destStencil = (uint8_t *)pixels + y * pixelStride; + const uint32_t *src = (const uint32_t *)(srcWithOffset + map.RowPitch * y); + for (int x = 0; x < bw; x++) { + destStencil[x] = src[x] >> 24; + } + } + } else { + _assert_(false); } break; } diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 04bec49896..11e9f08012 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -528,6 +528,7 @@ public: // Not implemented } bool BlitFramebuffer(Framebuffer *src, int srcX1, int srcY1, int srcX2, int srcY2, Framebuffer *dst, int dstX1, int dstY1, int dstX2, int dstY2, int channelBits, FBBlitFilter filter, const char *tag) override; + bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; @@ -1400,6 +1401,108 @@ bool D3D9Context::BlitFramebuffer(Framebuffer *srcfb, int srcX1, int srcY1, int return SUCCEEDED(device_->StretchRect(srcSurf, &srcRect, dstSurf, &dstRect, (filter == FB_BLIT_LINEAR && channelBits == FB_COLOR_BIT) ? D3DTEXF_LINEAR : D3DTEXF_POINT)); } +bool D3D9Context::CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int bx, int by, int bw, int bh, Draw::DataFormat destFormat, void *pixels, int pixelStride, const char *tag) { + D3D9Framebuffer *fb = (D3D9Framebuffer *)src; + + if (fb) { + if (bx + bw > fb->Width()) { + bw -= (bx + bw) - fb->Width(); + } + if (by + bh > fb->Height()) { + bh -= (by + bh) - fb->Height(); + } + } + + if (bh <= 0 || bw <= 0) + return true; + + DataFormat srcFormat = Draw::DataFormat::R8G8B8A8_UNORM; + if (channelBits != FB_COLOR_BIT) { + srcFormat = Draw::DataFormat::D24_S8; + if (!supportsINTZ) + return false; + } + + D3DSURFACE_DESC desc; + D3DLOCKED_RECT locked; + RECT rect = { (LONG)bx, (LONG)by, (LONG)bw, (LONG)bh }; + + LPDIRECT3DSURFACE9 offscreen = nullptr; + HRESULT hr = E_UNEXPECTED; + if (channelBits == FB_COLOR_BIT) { + fb->tex->GetLevelDesc(0, &desc); + + hr = device_->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &offscreen, nullptr); + if (SUCCEEDED(hr)) { + hr = device_->GetRenderTargetData(fb->surf, offscreen); + if (SUCCEEDED(hr)) { + hr = offscreen->LockRect(&locked, &rect, D3DLOCK_READONLY); + } + } + } else { + fb->depthstenciltex->GetLevelDesc(0, &desc); + hr = fb->depthstenciltex->LockRect(0, &locked, &rect, D3DLOCK_READONLY); + } + + if (SUCCEEDED(hr)) { + switch (channelBits) { + case FB_COLOR_BIT: + // Pixel size always 4 here because we always request BGRA8888. + ConvertFromBGRA8888((uint8_t *)pixels, (const uint8_t *)locked.pBits, pixelStride, locked.Pitch / sizeof(uint32_t), bw, bh, destFormat); + break; + case FB_DEPTH_BIT: + if (srcFormat == destFormat) { + // Can just memcpy when it matches no matter the format! + uint8_t *dst = (uint8_t *)pixels; + const uint8_t *src = (const uint8_t *)locked.pBits; + for (int y = 0; y < bh; ++y) { + memcpy(dst, src, bw * DataFormatSizeInBytes(srcFormat)); + dst += pixelStride * DataFormatSizeInBytes(srcFormat); + src += locked.Pitch; + } + } else if (destFormat == DataFormat::D32F) { + ConvertToD32F((uint8_t *)pixels, (const uint8_t *)locked.pBits, pixelStride, locked.Pitch / sizeof(uint32_t), bw, bh, srcFormat); + } else if (destFormat == DataFormat::D16) { + ConvertToD16((uint8_t *)pixels, (const uint8_t *)locked.pBits, pixelStride, locked.Pitch / sizeof(uint32_t), bw, bh, srcFormat); + } else { + _assert_(false); + } + break; + case FB_STENCIL_BIT: + if (srcFormat == destFormat) { + uint8_t *dst = (uint8_t *)pixels; + const uint8_t *src = (const uint8_t *)locked.pBits; + for (int y = 0; y < bh; ++y) { + memcpy(dst, src, bw * DataFormatSizeInBytes(srcFormat)); + dst += pixelStride * DataFormatSizeInBytes(srcFormat); + src += locked.Pitch; + } + } else if (destFormat == DataFormat::S8) { + for (int y = 0; y < bh; y++) { + uint8_t *destStencil = (uint8_t *)pixels + y * pixelStride; + const uint32_t *src = (const uint32_t *)((const uint8_t *)locked.pBits + locked.Pitch * y); + for (int x = 0; x < bw; x++) { + destStencil[x] = src[x] >> 24; + } + } + } else { + _assert_(false); + } + break; + } + } + + if (channelBits != FB_COLOR_BIT) { + fb->depthstenciltex->UnlockRect(0); + } + if (offscreen) { + offscreen->UnlockRect(); + offscreen->Release(); + } + + return SUCCEEDED(hr); +} + void D3D9Context::HandleEvent(Event ev, int width, int height, void *param1, void *param2) { switch (ev) { case Event::LOST_BACKBUFFER: diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index ef3af4c41c..421b01cbd2 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -243,158 +243,3 @@ } offscreenSurfaces_.clear(); } - - bool FramebufferManagerDX9::GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat fb_format, GPUDebugBuffer &buffer, int maxRes) { - VirtualFramebuffer *vfb = currentRenderVfb_; - if (!vfb) { - vfb = GetVFBAt(fb_address); - } - - if (!vfb) { - if (!Memory::IsValidAddress(fb_address)) - return false; - // If there's no vfb and we're drawing there, must be memory? - buffer = GPUDebugBuffer(Memory::GetPointerWrite(fb_address), fb_stride, 512, fb_format); - return true; - } - LPDIRECT3DSURFACE9 renderTarget = vfb->fbo ? (LPDIRECT3DSURFACE9)draw_->GetFramebufferAPITexture(vfb->fbo, Draw::FB_COLOR_BIT | Draw::FB_SURFACE_BIT, 0) : nullptr; - bool success = false; - if (renderTarget) { - Draw::Framebuffer *tempFBO = nullptr; - int w = vfb->renderWidth, h = vfb->renderHeight; - - if (maxRes > 0 && vfb->renderWidth > vfb->width * maxRes) { - // Let's resize. We must stretch to a render target first. - w = vfb->width * maxRes; - h = vfb->height * maxRes; - tempFBO = draw_->CreateFramebuffer({ w, h, 1, 1, false }); - if (draw_->BlitFramebuffer(vfb->fbo, 0, 0, vfb->renderWidth, vfb->renderHeight, tempFBO, 0, 0, w, h, Draw::FB_COLOR_BIT, g_Config.iBufFilter == SCALE_LINEAR ? Draw::FB_BLIT_LINEAR : Draw::FB_BLIT_NEAREST, "GetFramebuffer")) { - renderTarget = (LPDIRECT3DSURFACE9)draw_->GetFramebufferAPITexture(tempFBO, Draw::FB_COLOR_BIT | Draw::FB_SURFACE_BIT, 0); - } - } - - LPDIRECT3DSURFACE9 offscreen = GetOffscreenSurface(renderTarget, vfb); - if (offscreen) { - success = GetRenderTargetFramebuffer(renderTarget, offscreen, w, h, buffer); - } - } - - return success; - } - - bool FramebufferManagerDX9::GetOutputFramebuffer(GPUDebugBuffer &buffer) { - LPDIRECT3DSURFACE9 renderTarget = nullptr; - HRESULT hr = device_->GetRenderTarget(0, &renderTarget); - bool success = false; - if (renderTarget && SUCCEEDED(hr)) { - D3DSURFACE_DESC desc; - renderTarget->GetDesc(&desc); - - LPDIRECT3DSURFACE9 offscreen = nullptr; - HRESULT hr = device_->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &offscreen, NULL); - if (offscreen && SUCCEEDED(hr)) { - success = GetRenderTargetFramebuffer(renderTarget, offscreen, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, buffer); - offscreen->Release(); - } - renderTarget->Release(); - } - return success; - } - - bool FramebufferManagerDX9::GetRenderTargetFramebuffer(LPDIRECT3DSURFACE9 renderTarget, LPDIRECT3DSURFACE9 offscreen, int w, int h, GPUDebugBuffer &buffer) { - D3DSURFACE_DESC desc; - renderTarget->GetDesc(&desc); - - bool success = false; - HRESULT hr = device_->GetRenderTargetData(renderTarget, offscreen); - if (SUCCEEDED(hr)) { - D3DLOCKED_RECT locked; - RECT rect = {0, 0, w, h}; - hr = offscreen->LockRect(&locked, &rect, D3DLOCK_READONLY); - if (SUCCEEDED(hr)) { - // TODO: Handle the other formats? We don't currently create them, I think. - buffer.Allocate(locked.Pitch / 4, desc.Height, GPU_DBG_FORMAT_8888_BGRA, false); - memcpy(buffer.GetData(), locked.pBits, locked.Pitch * desc.Height); - offscreen->UnlockRect(); - success = true; - } - } - - return success; - } - - bool FramebufferManagerDX9::GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer) { - VirtualFramebuffer *vfb = currentRenderVfb_; - if (!vfb) { - vfb = GetVFBAt(fb_address); - } - - if (!vfb) { - // If there's no vfb and we're drawing there, must be memory? - buffer = GPUDebugBuffer(Memory::GetPointerWrite(z_address), z_stride, 512, GPU_DBG_FORMAT_16BIT); - return true; - } - - bool success = false; - LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)draw_->GetFramebufferAPITexture(vfb->fbo, Draw::FB_DEPTH_BIT, 0); - if (tex) { - D3DSURFACE_DESC desc; - D3DLOCKED_RECT locked; - tex->GetLevelDesc(0, &desc); - RECT rect = {0, 0, (LONG)desc.Width, (LONG)desc.Height}; - HRESULT hr = tex->LockRect(0, &locked, &rect, D3DLOCK_READONLY); - - if (SUCCEEDED(hr)) { - GPUDebugBufferFormat fmt = GPU_DBG_FORMAT_24BIT_8X; - if (gstate_c.Supports(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { - fmt = GPU_DBG_FORMAT_24BIT_8X_DIV_256; - } - int pixelSize = 4; - - buffer.Allocate(locked.Pitch / pixelSize, desc.Height, fmt, false); - memcpy(buffer.GetData(), locked.pBits, locked.Pitch * desc.Height); - success = true; - tex->UnlockRect(0); - } - } - - return success; - } - - bool FramebufferManagerDX9::GetStencilbuffer(u32 fb_address, int fb_stride, GPUDebugBuffer &buffer) { - VirtualFramebuffer *vfb = currentRenderVfb_; - if (!vfb) { - vfb = GetVFBAt(fb_address); - } - - if (!vfb) { - if (!Memory::IsValidAddress(fb_address)) - return false; - // If there's no vfb and we're drawing there, must be memory? - // TODO: Actually get the stencil. - buffer = GPUDebugBuffer(Memory::GetPointerWrite(fb_address), fb_stride, 512, GPU_DBG_FORMAT_8888); - return true; - } - - bool success = false; - LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)draw_->GetFramebufferAPITexture(vfb->fbo, Draw::FB_DEPTH_BIT, 0); - if (tex) { - D3DSURFACE_DESC desc; - D3DLOCKED_RECT locked; - tex->GetLevelDesc(0, &desc); - RECT rect = {0, 0, (LONG)desc.Width, (LONG)desc.Height}; - HRESULT hr = tex->LockRect(0, &locked, &rect, D3DLOCK_READONLY); - - if (SUCCEEDED(hr)) { - GPUDebugBufferFormat fmt = GPU_DBG_FORMAT_24X_8BIT; - int pixelSize = 4; - - buffer.Allocate(locked.Pitch / pixelSize, desc.Height, fmt, false); - memcpy(buffer.GetData(), locked.pBits, locked.Pitch * desc.Height); - success = true; - tex->UnlockRect(0); - } - } - - return success; - } diff --git a/GPU/Directx9/FramebufferManagerDX9.h b/GPU/Directx9/FramebufferManagerDX9.h index cb0a8ff37f..5a79b25e1f 100644 --- a/GPU/Directx9/FramebufferManagerDX9.h +++ b/GPU/Directx9/FramebufferManagerDX9.h @@ -39,11 +39,6 @@ public: void DestroyAllFBOs() override; - bool GetFramebuffer(u32 fb_address, int fb_stride, GEBufferFormat format, GPUDebugBuffer &buffer, int maxRes) override; - bool GetDepthbuffer(u32 fb_address, int fb_stride, u32 z_address, int z_stride, GPUDebugBuffer &buffer) override; - bool GetStencilbuffer(u32 fb_address, int fb_stride, GPUDebugBuffer &buffer) override; - bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override; - LPDIRECT3DSURFACE9 GetOffscreenSurface(LPDIRECT3DSURFACE9 similarSurface, VirtualFramebuffer *vfb); LPDIRECT3DSURFACE9 GetOffscreenSurface(D3DFORMAT fmt, u32 w, u32 h); @@ -52,7 +47,6 @@ protected: void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) override; private: - bool GetRenderTargetFramebuffer(LPDIRECT3DSURFACE9 renderTarget, LPDIRECT3DSURFACE9 offscreen, int w, int h, GPUDebugBuffer &buffer); void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h); LPDIRECT3DDEVICE9 device_; From 999055791dcf5db1f3e55434986b2e1d18275cf1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 21:48:38 -0700 Subject: [PATCH 129/374] D3D9: Remove block transfer code overrides. We can just use Draw now. Keep depth, though, since it applies scale. --- Common/GPU/thin3d.cpp | 31 +++- GPU/Common/FramebufferManagerCommon.cpp | 1 + GPU/Directx9/FramebufferManagerDX9.cpp | 222 ++++-------------------- GPU/Directx9/FramebufferManagerDX9.h | 21 +-- 4 files changed, 68 insertions(+), 207 deletions(-) diff --git a/Common/GPU/thin3d.cpp b/Common/GPU/thin3d.cpp index a81c38ba10..ac2daa68c7 100644 --- a/Common/GPU/thin3d.cpp +++ b/Common/GPU/thin3d.cpp @@ -586,7 +586,36 @@ void ConvertFromBGRA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, u dst += dstStride * 3; } } else { - WARN_LOG(G3D, "Unable to convert from format to BGRA: %d", (int)format); + // But here it shouldn't matter if they do intersect + uint16_t *dst16 = (uint16_t *)dst; + switch (format) { + case Draw::DataFormat::R5G6B5_UNORM_PACK16: // BGR 565 + for (uint32_t y = 0; y < height; ++y) { + ConvertBGRA8888ToRGB565(dst16, src32, width); + src32 += srcStride; + dst16 += dstStride; + } + break; + case Draw::DataFormat::A1R5G5B5_UNORM_PACK16: // ABGR 1555 + for (uint32_t y = 0; y < height; ++y) { + ConvertBGRA8888ToRGBA5551(dst16, src32, width); + src32 += srcStride; + dst16 += dstStride; + } + break; + case Draw::DataFormat::A4R4G4B4_UNORM_PACK16: // ABGR 4444 + for (uint32_t y = 0; y < height; ++y) { + ConvertBGRA8888ToRGBA4444(dst16, src32, width); + src32 += srcStride; + dst16 += dstStride; + } + break; + case Draw::DataFormat::R8G8B8A8_UNORM: + case Draw::DataFormat::UNDEFINED: + default: + WARN_LOG(G3D, "Unable to convert from format to BGRA: %d", (int)format); + break; + } } } diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 3d14e9c1aa..5baca6b887 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2649,6 +2649,7 @@ void FramebufferManagerCommon::ReadbackFramebufferSync(VirtualFramebuffer *vfb, bool FramebufferManagerCommon::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { Draw::DataFormat destFormat = GEFormatToThin3D(GE_FORMAT_DEPTH16); + // TODO: Apply depth scale factors if we don't have depth clamp. return draw_->CopyFramebufferToMemorySync(fbo, Draw::FB_DEPTH_BIT, x, y, w, h, destFormat, pixels, pixelsStride, "ReadbackDepthbufferSync"); } diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index 421b01cbd2..87900dfbb7 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -45,201 +45,51 @@ #include #endif -// TODO: De-indent, the day we move all this readback stuff to GPU/Common +FramebufferManagerDX9::FramebufferManagerDX9(Draw::DrawContext *draw) + : FramebufferManagerCommon(draw) { + presentation_->SetLanguage(HLSL_D3D9); + preferredPixelsFormat_ = Draw::DataFormat::B8G8R8A8_UNORM; +} - FramebufferManagerDX9::FramebufferManagerDX9(Draw::DrawContext *draw) - : FramebufferManagerCommon(draw) { +FramebufferManagerDX9::~FramebufferManagerDX9() { +} - device_ = (LPDIRECT3DDEVICE9)draw->GetNativeObject(Draw::NativeObject::DEVICE); - deviceEx_ = (LPDIRECT3DDEVICE9)draw->GetNativeObject(Draw::NativeObject::DEVICE_EX); +bool FramebufferManagerDX9::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) { + // We always read the depth buffer in 24_8 format. + LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)draw_->GetFramebufferAPITexture(fbo, Draw::FB_DEPTH_BIT, 0); + if (!tex) + return false; - presentation_->SetLanguage(HLSL_D3D9); - preferredPixelsFormat_ = Draw::DataFormat::B8G8R8A8_UNORM; - } + // This is separate from the thin3d way because it applies DepthScaleFactors. + D3DSURFACE_DESC desc; + D3DLOCKED_RECT locked; + tex->GetLevelDesc(0, &desc); - FramebufferManagerDX9::~FramebufferManagerDX9() { - for (auto &it : offscreenSurfaces_) { - it.second.surface->Release(); - } - } + RECT rect = {(LONG)x, (LONG)y, (LONG)w, (LONG)h}; + HRESULT hr = tex->LockRect(0, &locked, &rect, D3DLOCK_READONLY); + if (!SUCCEEDED(hr)) + return false; - LPDIRECT3DSURFACE9 FramebufferManagerDX9::GetOffscreenSurface(LPDIRECT3DSURFACE9 similarSurface, VirtualFramebuffer *vfb) { - D3DSURFACE_DESC desc = {}; - HRESULT hr = similarSurface->GetDesc(&desc); - if (FAILED(hr)) { - ERROR_LOG_REPORT(G3D, "Unable to get size for offscreen surface at %08x", vfb->fb_address); - return nullptr; - } + const u32 *packed = (const u32 *)locked.pBits; + u16 *depth = (u16 *)pixels; - return GetOffscreenSurface(desc.Format, desc.Width, desc.Height); - } + DepthScaleFactors depthScale = GetDepthScaleFactors(); + // TODO: Optimize. + for (int yp = 0; yp < h; ++yp) { + for (int xp = 0; xp < w; ++xp) { + const int offset = (yp + y) * pixelsStride + x + xp; - LPDIRECT3DSURFACE9 FramebufferManagerDX9::GetOffscreenSurface(D3DFORMAT fmt, u32 w, u32 h) { - u64 key = ((u64)fmt << 32) | (w << 16) | h; - auto it = offscreenSurfaces_.find(key); - if (it != offscreenSurfaces_.end()) { - it->second.last_frame_used = gpuStats.numFlips; - return it->second.surface; - } - - textureCache_->ForgetLastTexture(); - LPDIRECT3DSURFACE9 offscreen = nullptr; - HRESULT hr = device_->CreateOffscreenPlainSurface(w, h, fmt, D3DPOOL_SYSTEMMEM, &offscreen, NULL); - if (FAILED(hr) || !offscreen) { - ERROR_LOG_REPORT(G3D, "Unable to create offscreen surface %dx%d @%d", w, h, fmt); - return nullptr; - } - const OffscreenSurface info = {offscreen, gpuStats.numFlips}; - offscreenSurfaces_[key] = info; - return offscreen; - } - - void ConvertFromBGRA8888(u8 *dst, u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format) { - // Must skip stride in the cases below. Some games pack data into the cracks, like MotoGP. - const u32 *src32 = (const u32 *)src; - - if (format == GE_FORMAT_8888) { - ConvertFromBGRA8888(dst, src, dstStride, srcStride, width, height, Draw::DataFormat::R8G8B8A8_UNORM); - } else { - // But here it shouldn't matter if they do intersect - u16 *dst16 = (u16 *)dst; - switch (format) { - case GE_FORMAT_565: // BGR 565 - for (u32 y = 0; y < height; ++y) { - ConvertBGRA8888ToRGB565(dst16, src32, width); - src32 += srcStride; - dst16 += dstStride; - } - break; - case GE_FORMAT_5551: // ABGR 1555 - for (u32 y = 0; y < height; ++y) { - ConvertBGRA8888ToRGBA5551(dst16, src32, width); - src32 += srcStride; - dst16 += dstStride; - } - break; - case GE_FORMAT_4444: // ABGR 4444 - for (u32 y = 0; y < height; ++y) { - ConvertBGRA8888ToRGBA4444(dst16, src32, width); - src32 += srcStride; - dst16 += dstStride; - } - break; - case GE_FORMAT_8888: - case GE_FORMAT_INVALID: - // Not possible. - break; - } - } - } - - void FramebufferManagerDX9::ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) { - if (channel == RASTER_DEPTH) { - ReadbackDepthbufferSync(vfb, x, y, w, h); - return; - } else if (channel != RASTER_COLOR) { - // Unsupported - WARN_LOG_ONCE(d3ddepthreadback, G3D, "Not yet supporting depth readbacks on DX9"); - return; - } - - const u32 fb_address = vfb->fb_address; - const int dstBpp = vfb->fb_format == GE_FORMAT_8888 ? 4 : 2; - - // We always need to convert from the framebuffer native format. - // Right now that's always 8888. - DEBUG_LOG(G3D, "Reading framebuffer to mem, fb_address = %08x", fb_address); - - LPDIRECT3DSURFACE9 renderTarget = (LPDIRECT3DSURFACE9)draw_->GetFramebufferAPITexture(vfb->fbo, Draw::FB_COLOR_BIT | Draw::FB_SURFACE_BIT, 0); - D3DSURFACE_DESC desc; - renderTarget->GetDesc(&desc); - - LPDIRECT3DSURFACE9 offscreen = GetOffscreenSurface(renderTarget, vfb); - if (offscreen) { - HRESULT hr = device_->GetRenderTargetData(renderTarget, offscreen); - if (SUCCEEDED(hr)) { - D3DLOCKED_RECT locked; - u32 widthFactor = vfb->renderWidth / vfb->bufferWidth; - u32 heightFactor = vfb->renderHeight / vfb->bufferHeight; - RECT rect = {(LONG)(x * widthFactor), (LONG)(y * heightFactor), (LONG)((x + w) * widthFactor), (LONG)((y + h) * heightFactor)}; - hr = offscreen->LockRect(&locked, &rect, D3DLOCK_READONLY); - if (SUCCEEDED(hr)) { - // TODO: Handle the other formats? We don't currently create them, I think. - const int dstByteOffset = (y * vfb->fb_stride + x) * dstBpp; - // Pixel size always 4 here because we always request BGRA8888. - ConvertFromBGRA8888(Memory::GetPointerWrite(fb_address + dstByteOffset), (u8 *)locked.pBits, vfb->fb_stride, locked.Pitch / 4, w, h, vfb->fb_format); - offscreen->UnlockRect(); - } else { - ERROR_LOG_REPORT(G3D, "Unable to lock rect from %08x: %d,%d %dx%d of %dx%d", fb_address, (int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom, vfb->renderWidth, vfb->renderHeight); - } + float scaled = depthScale.Apply((packed[offset] & 0x00FFFFFF) * (1.0f / 16777215.0f)); + if (scaled <= 0.0f) { + depth[offset] = 0; + } else if (scaled >= 65535.0f) { + depth[offset] = 65535; } else { - ERROR_LOG_REPORT(G3D, "Unable to download render target data from %08x", fb_address); + depth[offset] = (int)scaled; } } } - void FramebufferManagerDX9::ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h) { - // We always read the depth buffer in 24_8 format. - const u32 z_address = vfb->z_address; - - DEBUG_LOG(FRAMEBUF, "Reading depthbuffer to mem at %08x for vfb=%08x", z_address, vfb->fb_address); - - LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)draw_->GetFramebufferAPITexture(vfb->fbo, Draw::FB_DEPTH_BIT, 0); - if (tex) { - D3DSURFACE_DESC desc; - D3DLOCKED_RECT locked; - tex->GetLevelDesc(0, &desc); - RECT rect = {0, 0, (LONG)desc.Width, (LONG)desc.Height}; - HRESULT hr = tex->LockRect(0, &locked, &rect, D3DLOCK_READONLY); - - if (SUCCEEDED(hr)) { - const u32 *packed = (const u32 *)locked.pBits; - u16 *depth = (u16 *)Memory::GetPointer(z_address); - - DepthScaleFactors depthScale = GetDepthScaleFactors(); - // TODO: Optimize. - for (int yp = 0; yp < h; ++yp) { - for (int xp = 0; xp < w; ++xp) { - const int offset = (yp + y) * vfb->z_stride + x + xp; - - float scaled = depthScale.Apply((packed[offset] & 0x00FFFFFF) * (1.0f / 16777215.0f)); - if (scaled <= 0.0f) { - depth[offset] = 0; - } else if (scaled >= 65535.0f) { - depth[offset] = 65535; - } else { - depth[offset] = (int)scaled; - } - } - } - - tex->UnlockRect(0); - } else { - ERROR_LOG_REPORT(G3D, "Unable to lock rect from depth %08x: %d,%d %dx%d of %dx%d", vfb->fb_address, (int)rect.left, (int)rect.top, (int)rect.right, (int)rect.bottom, vfb->renderWidth, vfb->renderHeight); - } - } else { - ERROR_LOG_REPORT(G3D, "Unable to download render target depth from %08x", vfb->fb_address); - } - } - - void FramebufferManagerDX9::DecimateFBOs() { - FramebufferManagerCommon::DecimateFBOs(); - for (auto it = offscreenSurfaces_.begin(); it != offscreenSurfaces_.end(); ) { - int age = frameLastFramebufUsed_ - it->second.last_frame_used; - if (age > FBO_OLD_AGE) { - it->second.surface->Release(); - it = offscreenSurfaces_.erase(it); - } else { - ++it; - } - } - } - - void FramebufferManagerDX9::DestroyAllFBOs() { - FramebufferManagerCommon::DestroyAllFBOs(); - - for (auto &it : offscreenSurfaces_) { - it.second.surface->Release(); - } - offscreenSurfaces_.clear(); - } + tex->UnlockRect(0); + return true; +} diff --git a/GPU/Directx9/FramebufferManagerDX9.h b/GPU/Directx9/FramebufferManagerDX9.h index 5a79b25e1f..e189425b38 100644 --- a/GPU/Directx9/FramebufferManagerDX9.h +++ b/GPU/Directx9/FramebufferManagerDX9.h @@ -37,25 +37,6 @@ public: FramebufferManagerDX9(Draw::DrawContext *draw); ~FramebufferManagerDX9(); - void DestroyAllFBOs() override; - - LPDIRECT3DSURFACE9 GetOffscreenSurface(LPDIRECT3DSURFACE9 similarSurface, VirtualFramebuffer *vfb); - LPDIRECT3DSURFACE9 GetOffscreenSurface(D3DFORMAT fmt, u32 w, u32 h); - protected: - void DecimateFBOs() override; - void ReadbackFramebufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel) override; - -private: - void ReadbackDepthbufferSync(VirtualFramebuffer *vfb, int x, int y, int w, int h); - - LPDIRECT3DDEVICE9 device_; - LPDIRECT3DDEVICE9 deviceEx_; - - struct OffscreenSurface { - LPDIRECT3DSURFACE9 surface; - int last_frame_used; - }; - - std::unordered_map offscreenSurfaces_; + bool ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int x, int y, int w, int h, uint16_t *pixels, int pixelsStride) override; }; From fc9f2002242820c673c4f4e1781878763d04625c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 21:50:53 -0700 Subject: [PATCH 130/374] GE Debugger: Centralize current fb tex fetch code. --- GPU/Common/TextureCacheCommon.cpp | 18 ++++++++++++++++++ GPU/Common/TextureCacheCommon.h | 1 + GPU/D3D11/TextureCacheD3D11.cpp | 16 +--------------- GPU/Directx9/TextureCacheDX9.cpp | 4 ++++ GPU/GLES/TextureCacheGLES.cpp | 17 +---------------- GPU/Vulkan/TextureCacheVulkan.cpp | 16 +--------------- 6 files changed, 26 insertions(+), 46 deletions(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index f6889e5cb0..8a33791337 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1162,6 +1162,24 @@ bool TextureCacheCommon::SetOffsetTexture(u32 yOffset) { } } +bool TextureCacheCommon::GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffer) { + if (!nextFramebufferTexture_) + return false; + + VirtualFramebuffer *vfb = nextFramebufferTexture_; + buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, false); + bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth, "GetCurrentTextureDebug"); + + // Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf. + // So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends. + gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE); + // We may have blitted to a temp FBO. + framebufferManager_->RebindFramebuffer("RebindFramebuffer - GetCurrentTextureDebug"); + if (!retval) + ERROR_LOG(G3D, "Failed to get debug texture: copy to memory failed"); + return retval; +} + void TextureCacheCommon::NotifyConfigChanged() { int scaleFactor = g_Config.iTexScalingLevel; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 48c44d981f..996f0003e8 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -399,6 +399,7 @@ protected: bool GetBestFramebufferCandidate(const TextureDefinition &entry, u32 texAddrOffset, AttachCandidate *bestCandidate) const; void SetTextureFramebuffer(const AttachCandidate &candidate); + bool GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffer); virtual void BoundFramebufferTexture() {} diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 8d051c915c..50eca0200f 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -456,21 +456,7 @@ DXGI_FORMAT TextureCacheD3D11::GetDestFormat(GETextureFormat format, GEPaletteFo bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { SetTexture(); if (!nextTexture_) { - if (nextFramebufferTexture_) { - VirtualFramebuffer *vfb = nextFramebufferTexture_; - buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, false); - bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth, "GetCurrentTextureDebug"); - // Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf. - // So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends. - gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE); - // We may have blitted to a temp FBO. - framebufferManager_->RebindFramebuffer("RebindFramebuffer - GetCurrentTextureDebug"); - if (!retval) - ERROR_LOG(G3D, "Failed to get debug texture: copy to memory failed"); - return retval; - } else { - return false; - } + return GetCurrentFramebufferTextureDebug(buffer); } // Apply texture may need to rebuild the texture if we're about to render, or bind a framebuffer. diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 0870299ac5..bbb7934da1 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -364,6 +364,10 @@ D3DFORMAT TextureCacheDX9::GetDestFormat(GETextureFormat format, GEPaletteFormat bool TextureCacheDX9::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { SetTexture(); + if (!nextTexture_) { + return GetCurrentFramebufferTextureDebug(buffer); + } + ApplyTexture(); LPDIRECT3DBASETEXTURE9 baseTex; diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 83309208b8..e9591736cf 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -389,22 +389,7 @@ bool TextureCacheGLES::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) InvalidateLastTexture(); SetTexture(); if (!nextTexture_) { - if (nextFramebufferTexture_) { - VirtualFramebuffer *vfb = nextFramebufferTexture_; - buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, false); - bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth, "GetCurrentTextureDebug"); - // Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf. - // So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends. - gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE); - // We may have blitted to a temp FBO. - framebufferManager_->RebindFramebuffer("RebindFramebuffer - GetCurrentTextureDebug"); - if (!retval) - ERROR_LOG(G3D, "Failed to get debug texture: copy to memory failed"); - return retval; - } else { - ERROR_LOG(G3D, "Failed to get debug texture: no texture set"); - return false; - } + return GetCurrentFramebufferTextureDebug(buffer); } // Apply texture may need to rebuild the texture if we're about to render, or bind a framebuffer. diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 75b067cc40..670a469cb6 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -777,21 +777,7 @@ void TextureCacheVulkan::BoundFramebufferTexture() { bool TextureCacheVulkan::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { SetTexture(); if (!nextTexture_) { - if (nextFramebufferTexture_) { - VirtualFramebuffer *vfb = nextFramebufferTexture_; - buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, false); - bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth, "GetCurrentTextureDebug"); - // Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf. - // So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends. - gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE); - // We may have blitted to a temp FBO. - framebufferManager_->RebindFramebuffer("RebindFramebuffer - GetCurrentTextureDebug"); - if (!retval) - ERROR_LOG(G3D, "Failed to get debug texture: copy to memory failed"); - return retval; - } else { - return false; - } + return GetCurrentFramebufferTextureDebug(buffer); } // Apply texture may need to rebuild the texture if we're about to render, or bind a framebuffer. From 48c39543afe606ecf9df89dd04725d43df537a1b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 21:54:24 -0700 Subject: [PATCH 131/374] GE Debugger: Normalize framebuffer texture preview. Previously, we would show the render-to-texture with its original dimensions. While useful, this skewed the preview coordinates and was sometimes confusing. Additionally, depth texturing didn't preview. This pads and subsets the texture preview so it's the right size. --- GPU/Common/GPUDebugInterface.cpp | 5 +++++ GPU/Common/GPUDebugInterface.h | 2 ++ GPU/Common/TextureCacheCommon.cpp | 22 ++++++++++++++++++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/GPU/Common/GPUDebugInterface.cpp b/GPU/Common/GPUDebugInterface.cpp index 1f7d04369e..a94a3b46a1 100644 --- a/GPU/Common/GPUDebugInterface.cpp +++ b/GPU/Common/GPUDebugInterface.cpp @@ -985,6 +985,11 @@ void GPUDebugBuffer::Free() { data_ = NULL; } +void GPUDebugBuffer::ZeroBytes() { + _dbg_assert_(data_); + memset(data_, 0, PixelSize() * stride_ * height_); +} + u32 GPUDebugBuffer::PixelSize() const { switch (fmt_) { case GPU_DBG_FORMAT_8888: diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index f584dfd576..a2e1e2627b 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -136,6 +136,8 @@ struct GPUDebugBuffer { void Allocate(u32 stride, u32 height, GPUDebugBufferFormat fmt, bool flipped = false); void Free(); + void ZeroBytes(); + u8 *GetData() { return data_; } diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 8a33791337..3601a17c62 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1167,8 +1167,26 @@ bool TextureCacheCommon::GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffe return false; VirtualFramebuffer *vfb = nextFramebufferTexture_; - buffer.Allocate(vfb->bufferWidth, vfb->bufferHeight, GPU_DBG_FORMAT_8888, false); - bool retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, 0, 0, vfb->bufferWidth, vfb->bufferHeight, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), vfb->bufferWidth, "GetCurrentTextureDebug"); + u8 sf = vfb->renderScaleFactor; + int x = gstate_c.curTextureXOffset * sf; + int y = gstate_c.curTextureYOffset * sf; + int desiredW = gstate.getTextureWidth(0) * sf; + int desiredH = gstate.getTextureHeight(0) * sf; + int w = std::min(desiredW, vfb->bufferWidth * sf - x); + int h = std::min(desiredH, vfb->bufferHeight * sf - y); + + bool retval; + if (nextFramebufferTextureChannel_ == RASTER_DEPTH) { + buffer.Allocate(desiredW, desiredH, GPU_DBG_FORMAT_FLOAT, false); + if (w < desiredW || h < desiredH) + buffer.ZeroBytes(); + retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_DEPTH_BIT, x, y, w, h, Draw::DataFormat::D32F, buffer.GetData(), desiredW, "GetCurrentTextureDebug"); + } else { + buffer.Allocate(desiredW, desiredH, GPU_DBG_FORMAT_8888, false); + if (w < desiredW || h < desiredH) + buffer.ZeroBytes(); + retval = draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, x, y, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), desiredW, "GetCurrentTextureDebug"); + } // Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf. // So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends. From fb6b2514f28ea753dc4db97d9462c03139aefc5b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 21:59:54 -0700 Subject: [PATCH 132/374] GE Debugger: Remove ancient unecessary GL calls. --- Windows/GEDebugger/SimpleGLWindow.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index 6f0464a87c..03454dbc34 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -129,16 +129,6 @@ void SimpleGLWindow::ResizeGL(int w, int h) { return; } - wglMakeCurrent(hDC_, hGLRC_); - - glViewport(0, 0, w, h); - glScissor(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0f, w, h, 0.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - w_ = w; h_ = h; } From a4bd0af3f2bae47e559e5ba961d86074bb9af404 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 22:13:16 -0700 Subject: [PATCH 133/374] GE Debugger: Use a modern GL context. Note: still a separate context from Draw, since it's drawn to an entirely separate window. This stops RenderDoc from getting angry. --- Windows/GEDebugger/SimpleGLWindow.cpp | 43 +++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/Windows/GEDebugger/SimpleGLWindow.cpp b/Windows/GEDebugger/SimpleGLWindow.cpp index 03454dbc34..cc73c1f2fd 100644 --- a/Windows/GEDebugger/SimpleGLWindow.cpp +++ b/Windows/GEDebugger/SimpleGLWindow.cpp @@ -15,13 +15,15 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include "Common/CommonWindows.h" -#include -#include "Common/Math/lin/matrix4x4.h" -#include "Common/GPU/OpenGL/GLSLProgram.h" -#include "Common/GPU/OpenGL/GLFeatures.h" #include "Common/CommonTypes.h" +#include "Common/CommonWindows.h" #include "Common/Log.h" +#include "Common/GPU/OpenGL/GLCommon.h" +#include "Common/GPU/OpenGL/GLFeatures.h" +#include "Common/GPU/OpenGL/GLSLProgram.h" +#include "Common/Math/lin/matrix4x4.h" +#include "GL/gl.h" +#include "GL/wglew.h" #include "Windows/GEDebugger/SimpleGLWindow.h" #include "Windows/W32Util/ContextMenu.h" @@ -120,8 +122,31 @@ void SimpleGLWindow::SetupGL() { ENFORCE(hGLRC_ = wglCreateContext(hDC_), "Unable to create GL context."); ENFORCE(wglMakeCurrent(hDC_, hGLRC_), "Unable to activate GL context."); - glewInit(); - valid_ = true; + valid_ = glewInit() == GLEW_OK; + + // Switch to a modern context so RenderDoc doesn't get mad. + HGLRC oldGL = hGLRC_; + if (wglewIsSupported("WGL_ARB_create_context") == 1) { + static const int attribs33[] = { + WGL_CONTEXT_MAJOR_VERSION_ARB, 3, + WGL_CONTEXT_MINOR_VERSION_ARB, 3, + WGL_CONTEXT_FLAGS_ARB, 0, + WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB, + 0, + }; + hGLRC_ = wglCreateContextAttribsARB(hDC_, 0, attribs33); + + if (!hGLRC_) { + hGLRC_ = oldGL; + } else { + // Switch to the new ARB context. + wglMakeCurrent(nullptr, nullptr); + wglDeleteContext(oldGL); + wglMakeCurrent(hDC_, hGLRC_); + + valid_ = glewInit() == GLEW_OK; + } + } } void SimpleGLWindow::ResizeGL(int w, int h) { @@ -622,8 +647,8 @@ LRESULT CALLBACK SimpleGLWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPA case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MOUSEMOVE: - mouseX = GET_X_LPARAM(lParam); - mouseY = GET_Y_LPARAM(lParam); + mouseX = (int)(short)LOWORD(lParam); + mouseY = (int)(short)HIWORD(lParam); break; default: break; From 416265431bed8e775d561100614333e5e795bc46 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 10 Oct 2022 22:35:42 -0700 Subject: [PATCH 134/374] GE Debugger: Display if tex is framebuf. Rather than guessing based on size, let's show explicitly. --- .../WebSocket/GPUBufferSubscriber.cpp | 41 +++++++++++++------ GPU/Common/GPUDebugInterface.h | 2 +- GPU/Common/TextureCacheCommon.cpp | 3 +- GPU/Common/TextureCacheCommon.h | 4 +- GPU/D3D11/TextureCacheD3D11.cpp | 5 ++- GPU/D3D11/TextureCacheD3D11.h | 2 +- GPU/Debugger/Stepping.cpp | 9 ++-- GPU/Debugger/Stepping.h | 2 +- GPU/Directx9/TextureCacheDX9.cpp | 7 +++- GPU/Directx9/TextureCacheDX9.h | 2 +- GPU/GLES/TextureCacheGLES.cpp | 5 ++- GPU/GLES/TextureCacheGLES.h | 2 +- GPU/GPUCommon.cpp | 4 +- GPU/GPUCommon.h | 2 +- GPU/Software/SoftGpu.cpp | 4 +- GPU/Software/SoftGpu.h | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 5 ++- GPU/Vulkan/TextureCacheVulkan.h | 2 +- Windows/GEDebugger/GEDebugger.cpp | 13 ++++-- Windows/GEDebugger/GEDebugger.h | 2 + 20 files changed, 76 insertions(+), 42 deletions(-) diff --git a/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp b/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp index 155d70c70e..70a60ac435 100644 --- a/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp +++ b/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp @@ -41,7 +41,7 @@ DebuggerSubscriber *WebSocketGPUBufferInit(DebuggerEventHandlerMap &map) { } // Note: Calls req.Respond(). Other data can be added afterward. -static bool StreamBufferToDataURI(DebuggerRequest &req, const GPUDebugBuffer &buf, bool includeAlpha, int stackWidth) { +static bool StreamBufferToDataURI(DebuggerRequest &req, const GPUDebugBuffer &buf, bool isFramebuffer, bool includeAlpha, int stackWidth) { #ifdef USING_QT_UI req.Fail("Not supported on Qt yet, pull requests accepted"); return false; @@ -83,6 +83,9 @@ static bool StreamBufferToDataURI(DebuggerRequest &req, const GPUDebugBuffer &bu auto &json = req.Respond(); json.writeInt("width", w); json.writeInt("height", h); + if (isFramebuffer) { + json.writeBool("isFramebuffer", isFramebuffer); + } // Start a value... json.writeRaw("uri", ""); @@ -191,7 +194,7 @@ static std::string DescribeFormat(GPUDebugBufferFormat fmt) { } // Note: Calls req.Respond(). Other data can be added afterward. -static bool StreamBufferToBase64(DebuggerRequest &req, const GPUDebugBuffer &buf) { +static bool StreamBufferToBase64(DebuggerRequest &req, const GPUDebugBuffer &buf, bool isFramebuffer) { size_t length = buf.GetStride() * buf.GetHeight(); auto &json = req.Respond(); @@ -199,6 +202,9 @@ static bool StreamBufferToBase64(DebuggerRequest &req, const GPUDebugBuffer &buf json.writeInt("height", buf.GetHeight()); json.writeBool("flipped", buf.GetFlipped()); json.writeString("format", DescribeFormat(buf.GetFormat())); + if (isFramebuffer) { + json.writeBool("isFramebuffer", isFramebuffer); + } // Start a value without any actual data yet... json.writeRaw("base64", ""); @@ -217,7 +223,7 @@ static bool StreamBufferToBase64(DebuggerRequest &req, const GPUDebugBuffer &buf return true; } -static void GenericStreamBuffer(DebuggerRequest &req, std::function func) { +static void GenericStreamBuffer(DebuggerRequest &req, std::function func) { if (!currentDebugMIPS->isAlive()) { return req.Fail("CPU not started"); } @@ -238,15 +244,16 @@ static void GenericStreamBuffer(DebuggerRequest &req, std::functionrenderScaleFactor; diff --git a/GPU/Common/TextureCacheCommon.h b/GPU/Common/TextureCacheCommon.h index 996f0003e8..889dbb85b5 100644 --- a/GPU/Common/TextureCacheCommon.h +++ b/GPU/Common/TextureCacheCommon.h @@ -348,7 +348,7 @@ public: bool VideoIsPlaying() { return !videos_.empty(); } - virtual bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { return false; } + virtual bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { return false; } protected: virtual void *GetNativeTextureView(const TexCacheEntry *entry) = 0; @@ -399,7 +399,7 @@ protected: bool GetBestFramebufferCandidate(const TextureDefinition &entry, u32 texAddrOffset, AttachCandidate *bestCandidate) const; void SetTextureFramebuffer(const AttachCandidate &candidate); - bool GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffer); + bool GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffer, bool *isFramebuffer); virtual void BoundFramebufferTexture() {} diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 50eca0200f..2dac7b0749 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -453,10 +453,10 @@ DXGI_FORMAT TextureCacheD3D11::GetDestFormat(GETextureFormat format, GEPaletteFo } } -bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { +bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { SetTexture(); if (!nextTexture_) { - return GetCurrentFramebufferTextureDebug(buffer); + return GetCurrentFramebufferTextureDebug(buffer, isFramebuffer); } // Apply texture may need to rebuild the texture if we're about to render, or bind a framebuffer. @@ -499,6 +499,7 @@ bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level context_->Unmap(stagingCopy, level); stagingCopy->Release(); + *isFramebuffer = false; return true; } diff --git a/GPU/D3D11/TextureCacheD3D11.h b/GPU/D3D11/TextureCacheD3D11.h index 8b9d7caa78..20d84d6d48 100644 --- a/GPU/D3D11/TextureCacheD3D11.h +++ b/GPU/D3D11/TextureCacheD3D11.h @@ -53,7 +53,7 @@ public: void ForgetLastTexture() override; void InvalidateLastTexture() override; - bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override; protected: void BindTexture(TexCacheEntry *entry) override; diff --git a/GPU/Debugger/Stepping.cpp b/GPU/Debugger/Stepping.cpp index 2b750235a7..d0fe232de6 100644 --- a/GPU/Debugger/Stepping.cpp +++ b/GPU/Debugger/Stepping.cpp @@ -63,6 +63,7 @@ static GPUDebugBuffer bufferStencil; static GPUDebugBuffer bufferTex; static GPUDebugBuffer bufferClut; static int bufferLevel; +static bool lastWasFramebuffer; static u32 pauseSetCmdValue; static GPUgstate lastGState; @@ -111,7 +112,7 @@ static void RunPauseAction() { break; case PAUSE_GETTEX: - bufferResult = gpuDebug->GetCurrentTexture(bufferTex, bufferLevel); + bufferResult = gpuDebug->GetCurrentTexture(bufferTex, bufferLevel, &lastWasFramebuffer); break; case PAUSE_GETCLUT: @@ -237,9 +238,11 @@ bool GPU_GetCurrentStencilbuffer(const GPUDebugBuffer *&buffer) { return GetBuffer(buffer, PAUSE_GETSTENCILBUF, bufferStencil); } -bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level) { +bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level, bool *isFramebuffer) { bufferLevel = level; - return GetBuffer(buffer, PAUSE_GETTEX, bufferTex); + bool result = GetBuffer(buffer, PAUSE_GETTEX, bufferTex); + *isFramebuffer = lastWasFramebuffer; + return result; } bool GPU_GetCurrentClut(const GPUDebugBuffer *&buffer) { diff --git a/GPU/Debugger/Stepping.h b/GPU/Debugger/Stepping.h index 35409c03b9..4b3c5e5ab9 100644 --- a/GPU/Debugger/Stepping.h +++ b/GPU/Debugger/Stepping.h @@ -36,7 +36,7 @@ namespace GPUStepping { bool GPU_GetCurrentFramebuffer(const GPUDebugBuffer *&buffer, GPUDebugFramebufferType type); bool GPU_GetCurrentDepthbuffer(const GPUDebugBuffer *&buffer); bool GPU_GetCurrentStencilbuffer(const GPUDebugBuffer *&buffer); - bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level); + bool GPU_GetCurrentTexture(const GPUDebugBuffer *&buffer, int level, bool *isFramebuffer); bool GPU_GetCurrentClut(const GPUDebugBuffer *&buffer); bool GPU_SetCmdValue(u32 op); bool GPU_FlushDrawing(); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index bbb7934da1..dedbb55660 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -362,10 +362,10 @@ D3DFORMAT TextureCacheDX9::GetDestFormat(GETextureFormat format, GEPaletteFormat } } -bool TextureCacheDX9::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { +bool TextureCacheDX9::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { SetTexture(); if (!nextTexture_) { - return GetCurrentFramebufferTextureDebug(buffer); + return GetCurrentFramebufferTextureDebug(buffer, isFramebuffer); } ApplyTexture(); @@ -400,6 +400,9 @@ bool TextureCacheDX9::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) } renderTarget->Release(); } + *isFramebuffer = true; + } else { + *isFramebuffer = false; } if (SUCCEEDED(hr)) { diff --git a/GPU/Directx9/TextureCacheDX9.h b/GPU/Directx9/TextureCacheDX9.h index 6a52eb2007..23c2e0163b 100644 --- a/GPU/Directx9/TextureCacheDX9.h +++ b/GPU/Directx9/TextureCacheDX9.h @@ -43,7 +43,7 @@ public: } void InvalidateLastTexture() override; - bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override; protected: void BindTexture(TexCacheEntry *entry) override; diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index e9591736cf..bbb7c9838b 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -385,11 +385,11 @@ Draw::DataFormat TextureCacheGLES::GetDestFormat(GETextureFormat format, GEPalet } } -bool TextureCacheGLES::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { +bool TextureCacheGLES::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { InvalidateLastTexture(); SetTexture(); if (!nextTexture_) { - return GetCurrentFramebufferTextureDebug(buffer); + return GetCurrentFramebufferTextureDebug(buffer, isFramebuffer); } // Apply texture may need to rebuild the texture if we're about to render, or bind a framebuffer. @@ -415,6 +415,7 @@ bool TextureCacheGLES::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) gstate_c.Dirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS); framebufferManager_->RebindFramebuffer("RebindFramebuffer - GetCurrentTextureDebug"); + *isFramebuffer = false; return result; } diff --git a/GPU/GLES/TextureCacheGLES.h b/GPU/GLES/TextureCacheGLES.h index 2a4d04574d..8f9517371b 100644 --- a/GPU/GLES/TextureCacheGLES.h +++ b/GPU/GLES/TextureCacheGLES.h @@ -55,7 +55,7 @@ public: lastBoundTexture = nullptr; } - bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override; void DeviceLost(); void DeviceRestore(Draw::DrawContext *draw); diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 7df0d02861..52708dc9a6 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3190,11 +3190,11 @@ bool GPUCommon::GetCurrentClut(GPUDebugBuffer &buffer) { return textureCache_->GetCurrentClutBuffer(buffer); } -bool GPUCommon::GetCurrentTexture(GPUDebugBuffer &buffer, int level) { +bool GPUCommon::GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { if (!gstate.isTextureMapEnabled()) { return false; } - return textureCache_->GetCurrentTextureDebug(buffer, level); + return textureCache_->GetCurrentTextureDebug(buffer, level, isFramebuffer); } bool GPUCommon::DescribeCodePtr(const u8 *ptr, std::string &name) { diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 92f7d943d8..8823a52715 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -200,7 +200,7 @@ public: bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) override; bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override; bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override; - bool GetCurrentTexture(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override; bool GetCurrentClut(GPUDebugBuffer &buffer) override; bool GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) override; bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 88977a9008..6ba435028a 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1405,8 +1405,8 @@ bool SoftGPU::GetCurrentStencilbuffer(GPUDebugBuffer &buffer) { return true; } -bool SoftGPU::GetCurrentTexture(GPUDebugBuffer &buffer, int level) -{ +bool SoftGPU::GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { + *isFramebuffer = false; return Rasterizer::GetCurrentTexture(buffer, level); } diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 33e2768dbf..6c317d89c9 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -162,7 +162,7 @@ public: bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override; bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override; bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override; - bool GetCurrentTexture(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override; bool GetCurrentClut(GPUDebugBuffer &buffer) override; bool GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) override; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 670a469cb6..1a910bc5a1 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -774,10 +774,10 @@ void TextureCacheVulkan::BoundFramebufferTexture() { imageView_ = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::BOUND_TEXTURE0_IMAGEVIEW); } -bool TextureCacheVulkan::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { +bool TextureCacheVulkan::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) { SetTexture(); if (!nextTexture_) { - return GetCurrentFramebufferTextureDebug(buffer); + return GetCurrentFramebufferTextureDebug(buffer, isFramebuffer); } // Apply texture may need to rebuild the texture if we're about to render, or bind a framebuffer. @@ -829,6 +829,7 @@ bool TextureCacheVulkan::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int leve // So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends. gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE); framebufferManager_->RebindFramebuffer("RebindFramebuffer - GetCurrentTextureDebug"); + *isFramebuffer = false; return true; } diff --git a/GPU/Vulkan/TextureCacheVulkan.h b/GPU/Vulkan/TextureCacheVulkan.h index 5deeb30ea9..f83595dc46 100644 --- a/GPU/Vulkan/TextureCacheVulkan.h +++ b/GPU/Vulkan/TextureCacheVulkan.h @@ -81,7 +81,7 @@ public: sampler = curSampler_; } - bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override; + bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override; void GetStats(char *ptr, size_t size); diff --git a/Windows/GEDebugger/GEDebugger.cpp b/Windows/GEDebugger/GEDebugger.cpp index 43797e9dcd..f9496f13f9 100644 --- a/Windows/GEDebugger/GEDebugger.cpp +++ b/Windows/GEDebugger/GEDebugger.cpp @@ -376,7 +376,10 @@ void CGEDebugger::DescribePrimaryPreview(const GPUgstate &state, char desc[256]) if (showClut_) { // In this case, we're showing the texture here. - snprintf(desc, 256, "Texture L%d: 0x%08x (%dx%d)", textureLevel_, state.getTextureAddress(textureLevel_), state.getTextureWidth(textureLevel_), state.getTextureHeight(textureLevel_)); + if (primaryIsFramebuffer_) + snprintf(desc, 256, "FB Tex L%d: 0x%08x (%dx%d)", textureLevel_, state.getTextureAddress(textureLevel_), state.getTextureWidth(textureLevel_), state.getTextureHeight(textureLevel_)); + else + snprintf(desc, 256, "Texture L%d: 0x%08x (%dx%d)", textureLevel_, state.getTextureAddress(textureLevel_), state.getTextureWidth(textureLevel_), state.getTextureHeight(textureLevel_)); return; } @@ -416,6 +419,8 @@ void CGEDebugger::DescribeSecondPreview(const GPUgstate &state, char desc[256]) if (showClut_) { snprintf(desc, 256, "CLUT: 0x%08x (%d)", state.getClutAddress(), state.getClutPaletteFormat()); + } else if (secondIsFramebuffer_) { + snprintf(desc, 256, "FB Tex L%d: 0x%08x (%dx%d)", textureLevel_, state.getTextureAddress(textureLevel_), state.getTextureWidth(textureLevel_), state.getTextureHeight(textureLevel_)); } else { snprintf(desc, 256, "Texture L%d: 0x%08x (%dx%d)", textureLevel_, state.getTextureAddress(textureLevel_), state.getTextureWidth(textureLevel_), state.getTextureHeight(textureLevel_)); } @@ -658,8 +663,9 @@ void CGEDebugger::UpdatePrimaryPreview(const GPUgstate &state) { SetupPreviews(); primaryBuffer_ = nullptr; + primaryIsFramebuffer_ = false; if (showClut_) { - bufferResult = GPU_GetCurrentTexture(primaryBuffer_, textureLevel_); + bufferResult = GPU_GetCurrentTexture(primaryBuffer_, textureLevel_, &primaryIsFramebuffer_); flags = TexturePreviewFlags(state); if (bufferResult) { UpdateLastTexture(state.getTextureAddress(textureLevel_)); @@ -707,10 +713,11 @@ void CGEDebugger::UpdateSecondPreview(const GPUgstate &state) { SetupPreviews(); secondBuffer_ = nullptr; + secondIsFramebuffer_ = false; if (showClut_) { bufferResult = GPU_GetCurrentClut(secondBuffer_); } else { - bufferResult = GPU_GetCurrentTexture(secondBuffer_, textureLevel_); + bufferResult = GPU_GetCurrentTexture(secondBuffer_, textureLevel_, &secondIsFramebuffer_); if (bufferResult) { UpdateLastTexture(state.getTextureAddress(textureLevel_)); } else { diff --git a/Windows/GEDebugger/GEDebugger.h b/Windows/GEDebugger/GEDebugger.h index 9488c6ec21..24e7ffd280 100644 --- a/Windows/GEDebugger/GEDebugger.h +++ b/Windows/GEDebugger/GEDebugger.h @@ -139,6 +139,8 @@ private: // The most recent primary/framebuffer and texture buffers. const GPUDebugBuffer *primaryBuffer_ = nullptr; const GPUDebugBuffer *secondBuffer_ = nullptr; + bool primaryIsFramebuffer_ = false; + bool secondIsFramebuffer_ = false; uint32_t primaryTrackX_ = 0xFFFFFFFF; uint32_t primaryTrackY_ = 0xFFFFFFFF; From baa9451cb77293743bd504bd778d2c94d01e11cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 09:55:53 +0200 Subject: [PATCH 135/374] Warning fixes --- GPU/Common/FramebufferManagerCommon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 3d14e9c1aa..ba8a9dbc70 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1270,6 +1270,7 @@ Draw::Texture *FramebufferManagerCommon::MakePixelTexture(const u8 *srcPixels, G break; case GE_FORMAT_INVALID: + case GE_FORMAT_CLUT8: // Bad break; } @@ -1685,7 +1686,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, const int vfb_byteWidth = vfb->width * vfb_bpp; // Heuristic to try to prevent potential glitches with video playback. - if (!ignoreDstBuffer && vfb_address == dst && (size == 0x44000 && vfb_size == 0x88000 || size == 0x88000 && vfb_size == 0x44000)) { + if (!ignoreDstBuffer && vfb_address == dst && ((size == 0x44000 && vfb_size == 0x88000) || (size == 0x88000 && vfb_size == 0x44000))) { // Not likely to be a correct color format copy for this buffer. Ignore it, there will either be RAM // that can be displayed from, or another matching buffer with the right format if rendering is going on. WARN_LOG_N_TIMES(notify_copy_2x, 5, G3D, "Framebuffer size %08x conspicuously not matching copy size %08x in NotifyFramebufferCopy. Ignoring.", size, vfb_size); From bc28f546126e8d275e8c891dc6d7f4faefc7668e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 10:10:52 +0200 Subject: [PATCH 136/374] Disables "ForceCheck" on jit invalidation on ARM32, introduced in #16194 I'm not sure if we should call it at all here, but at least this makes games work again on ARM32. Will need more investigation. --- Core/CoreTiming.cpp | 2 ++ Core/MIPS/JitCommon/JitState.cpp | 2 +- Core/MIPS/MIPS.cpp | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index da24649553..c75db0a08f 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -585,6 +585,8 @@ void ForceCheck() int cyclesExecuted = slicelength - currentMIPS->downcount; globalTimer += cyclesExecuted; // This will cause us to check for new events immediately. + // NOTE: This causes problems on ARM32 in certain contexts due to jo.downcountInRegister. + // Not 100% sure what's going on there yet. currentMIPS->downcount = -1; // But let's not eat a bunch more time in Advance() because of this. slicelength = -1; diff --git a/Core/MIPS/JitCommon/JitState.cpp b/Core/MIPS/JitCommon/JitState.cpp index 0326519245..6da26656c2 100644 --- a/Core/MIPS/JitCommon/JitState.cpp +++ b/Core/MIPS/JitCommon/JitState.cpp @@ -37,7 +37,7 @@ namespace MIPSComp { // ARM only downcountInRegister = true; - useNEONVFPU = false; // true + useNEONVFPU = false; if (Disabled(JitDisable::SIMD)) useNEONVFPU = false; diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 5aeeacbbf8..b31dfe63e2 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -370,7 +370,9 @@ void MIPSState::InvalidateICache(u32 address, int length) { if (coreState == CORE_RUNNING || insideJit) { pendingClears.emplace_back(address, length); hasPendingClears = true; +#if !PPSSPP_ARCH(ARM) // See comment in ForceCheck CoreTiming::ForceCheck(); +#endif } else { MIPSComp::jit->InvalidateCacheAt(address, length); } @@ -383,7 +385,9 @@ void MIPSState::ClearJitCache() { if (coreState == CORE_RUNNING || insideJit) { pendingClears.emplace_back(0, 0); hasPendingClears = true; +#if !PPSSPP_ARCH(ARM) // See comment in ForceCheck CoreTiming::ForceCheck(); +#endif } else { MIPSComp::jit->ClearCache(); } From b0cf97cf4d076dd8c09b9e13e4c5018753aae15b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 14:00:46 +0200 Subject: [PATCH 137/374] Touchpad/mousewheel scrolling acted very weirdly on Mac due to 0 deltas. Make it work better. Ignoring the 0 deltas helps a lot for the feel, even though it still isn't that smooth feel yet. --- Common/GPU/Vulkan/VulkanContext.cpp | 1 + SDL/SDLMain.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index c2140c5663..f0764a72f3 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -1563,6 +1563,7 @@ const char *VulkanFormatToString(VkFormat format) { switch (format) { case VK_FORMAT_A1R5G5B5_UNORM_PACK16: return "A1R5G5B5_UNORM_PACK16"; case VK_FORMAT_A2B10G10R10_UNORM_PACK32: return "A2B10G10R10_UNORM_PACK32"; + case VK_FORMAT_A2R10G10B10_UNORM_PACK32: return "A2R10G10B10_UNORM_PACK32"; case VK_FORMAT_A8B8G8R8_SNORM_PACK32: return "A8B8G8R8_SNORM_PACK32"; case VK_FORMAT_A8B8G8R8_SRGB_PACK32: return "A8B8G8R8_SRGB_PACK32"; case VK_FORMAT_A8B8G8R8_UNORM_PACK32: return "A8B8G8R8_UNORM_PACK32"; diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index da966cabae..b09a64d5dd 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -1042,17 +1042,18 @@ int main(int argc, char *argv[]) { { KeyInput key; key.deviceId = DEVICE_ID_MOUSE; + key.flags = KEY_DOWN; if (event.wheel.y > 0) { key.keyCode = NKCODE_EXT_MOUSEWHEEL_UP; mouseWheelMovedUpFrames = 5; - } else { + NativeKey(key); + } else if (event.wheel.y < 0) { key.keyCode = NKCODE_EXT_MOUSEWHEEL_DOWN; mouseWheelMovedDownFrames = 5; + NativeKey(key); } - key.flags = KEY_DOWN; - NativeKey(key); + break; } - break; case SDL_MOUSEMOTION: if (mouseDown) { TouchInput input; From a34e32abe10573ca81a06b77159dcfd64f0a44e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 15:42:59 +0200 Subject: [PATCH 138/374] Revert "Disables "ForceCheck" on jit invalidation on ARM32, introduced in #16194" This reverts commit bc28f546126e8d275e8c891dc6d7f4faefc7668e. --- Core/CoreTiming.cpp | 2 -- Core/MIPS/JitCommon/JitState.cpp | 2 +- Core/MIPS/MIPS.cpp | 4 ---- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index c75db0a08f..da24649553 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -585,8 +585,6 @@ void ForceCheck() int cyclesExecuted = slicelength - currentMIPS->downcount; globalTimer += cyclesExecuted; // This will cause us to check for new events immediately. - // NOTE: This causes problems on ARM32 in certain contexts due to jo.downcountInRegister. - // Not 100% sure what's going on there yet. currentMIPS->downcount = -1; // But let's not eat a bunch more time in Advance() because of this. slicelength = -1; diff --git a/Core/MIPS/JitCommon/JitState.cpp b/Core/MIPS/JitCommon/JitState.cpp index 6da26656c2..0326519245 100644 --- a/Core/MIPS/JitCommon/JitState.cpp +++ b/Core/MIPS/JitCommon/JitState.cpp @@ -37,7 +37,7 @@ namespace MIPSComp { // ARM only downcountInRegister = true; - useNEONVFPU = false; + useNEONVFPU = false; // true if (Disabled(JitDisable::SIMD)) useNEONVFPU = false; diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index b31dfe63e2..5aeeacbbf8 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -370,9 +370,7 @@ void MIPSState::InvalidateICache(u32 address, int length) { if (coreState == CORE_RUNNING || insideJit) { pendingClears.emplace_back(address, length); hasPendingClears = true; -#if !PPSSPP_ARCH(ARM) // See comment in ForceCheck CoreTiming::ForceCheck(); -#endif } else { MIPSComp::jit->InvalidateCacheAt(address, length); } @@ -385,9 +383,7 @@ void MIPSState::ClearJitCache() { if (coreState == CORE_RUNNING || insideJit) { pendingClears.emplace_back(0, 0); hasPendingClears = true; -#if !PPSSPP_ARCH(ARM) // See comment in ForceCheck CoreTiming::ForceCheck(); -#endif } else { MIPSComp::jit->ClearCache(); } From df5b51990d62128e614b437930aeee4256ac6600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 15:50:37 +0200 Subject: [PATCH 139/374] ArmJit: Save/restore downcount where needed, we missed a few cases. --- Core/MIPS/ARM/ArmJit.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index 9977ca0c43..0794ebc22f 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -497,7 +497,9 @@ bool ArmJit::ReplaceJalTo(u32 dest) { gpr.SetImm(MIPS_REG_RA, GetCompilerPC() + 8); CompileDelaySlot(DELAYSLOT_NICE); FlushAll(); + SaveDowncount(); RestoreRoundingMode(); + if (BLInRange((const void *)(entry->replaceFunc))) { BL((const void *)(entry->replaceFunc)); } else { @@ -505,6 +507,8 @@ bool ArmJit::ReplaceJalTo(u32 dest) { BL(R0); } ApplyRoundingMode(); + RestoreDowncount(); + WriteDownCountR(R0); } @@ -745,6 +749,7 @@ bool ArmJit::CheckJitBreakpoint(u32 addr, int downcountOffset) { FlushAll(); MOVI2R(SCRATCHREG1, GetCompilerPC()); MovToPC(SCRATCHREG1); + SaveDowncount(); RestoreRoundingMode(); MOVI2R(R0, addr); QuickCallFunction(SCRATCHREG2, &JitBreakpoint); @@ -754,6 +759,7 @@ bool ArmJit::CheckJitBreakpoint(u32 addr, int downcountOffset) { FixupBranch skip = B_CC(CC_EQ); WriteDownCount(downcountOffset); ApplyRoundingMode(); + RestoreDowncount(); B((const void *)dispatcherCheckCoreState); SetJumpTarget(skip); @@ -771,6 +777,7 @@ bool ArmJit::CheckMemoryBreakpoint(int instructionOffset) { MRS(R8); FlushAll(); + SaveDowncount(); RestoreRoundingMode(); MOVI2R(R0, GetCompilerPC()); MovToPC(R0); @@ -783,6 +790,7 @@ bool ArmJit::CheckMemoryBreakpoint(int instructionOffset) { FixupBranch skip = B_CC(CC_EQ); WriteDownCount(-1 - off); ApplyRoundingMode(); + RestoreDowncount(); B((const void *)dispatcherCheckCoreState); SetJumpTarget(skip); From d30d8bf35ce6c094b3804138124df0c6ee0f74c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Oct 2022 16:09:57 +0200 Subject: [PATCH 140/374] Removes the option, autodetect instead - only enable if the GPU doesn't support bitwise ops. --- Core/Config.cpp | 1 - Core/Config.h | 1 - GPU/Common/FragmentShaderGenerator.cpp | 2 +- GPU/GLES/FragmentTestCacheGLES.cpp | 8 ++------ GPU/GLES/GPU_GLES.cpp | 4 ++++ GPU/GLES/StateMappingGLES.cpp | 2 +- GPU/GPUState.h | 8 +++++--- headless/Headless.cpp | 1 - 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 4eeca428ab..650e1812fa 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -937,7 +937,6 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("ShaderChainRequires60FPS", &g_Config.bShaderChainRequires60FPS, false, true, true), ReportedConfigSetting("MemBlockTransferGPU", &g_Config.bBlockTransferGPU, true, true, true), - ReportedConfigSetting("FragmentTestCache", &g_Config.bFragmentTestCache, true, true, true), ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, false, false), ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false), diff --git a/Core/Config.h b/Core/Config.h index 65eaf74099..10748583a9 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -235,7 +235,6 @@ public: float fGameListScrollPosition; int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive bool bBlockTransferGPU; - bool bFragmentTestCache; int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High bool bHardwareTessellation; bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times. diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 2f8f248dbd..57253eb670 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -45,7 +45,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool highpFog = false; bool highpTexcoord = false; - bool enableFragmentTestCache = g_Config.bFragmentTestCache && ShaderLanguageIsOpenGL(compat.shaderLanguage); + bool enableFragmentTestCache = gstate_c.Supports(GPU_USE_FRAGMENT_TEST_CACHE); if (compat.gles) { // PowerVR needs highp to do the fog in MHU correctly. diff --git a/GPU/GLES/FragmentTestCacheGLES.cpp b/GPU/GLES/FragmentTestCacheGLES.cpp index 1206911f4d..1033f2a2a2 100644 --- a/GPU/GLES/FragmentTestCacheGLES.cpp +++ b/GPU/GLES/FragmentTestCacheGLES.cpp @@ -40,10 +40,6 @@ void FragmentTestCacheGLES::DeviceRestore(Draw::DrawContext *draw) { } void FragmentTestCacheGLES::BindTestTexture(int slot) { - if (!g_Config.bFragmentTestCache) { - return; - } - bool alphaNeedsTexture = gstate.isAlphaTestEnabled() && !IsAlphaTestAgainstZero() && !IsAlphaTestTriviallyTrue(); bool colorNeedsTexture = gstate.isColorTestEnabled() && !IsColorTestAgainstZero() && !IsColorTestTriviallyTrue(); if (!alphaNeedsTexture && !colorNeedsTexture) { @@ -156,7 +152,7 @@ void FragmentTestCacheGLES::Clear(bool deleteThem) { } } cache_.clear(); - lastTexture_ = 0; + lastTexture_ = nullptr; } void FragmentTestCacheGLES::Decimate() { @@ -173,5 +169,5 @@ void FragmentTestCacheGLES::Decimate() { decimationCounter_ = FRAGTEST_DECIMATION_INTERVAL; } - lastTexture_ = 0; + lastTexture_ = nullptr; } diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index abae5134f9..65dd71a539 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -205,6 +205,10 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_DEPTH_RANGE_HACK; } + if (!draw_->GetShaderLanguageDesc().bitwiseOps) { + features |= GPU_USE_FRAGMENT_TEST_CACHE; + } + return features; } diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index cdcc9e5069..749cdf2fca 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -304,7 +304,7 @@ void DrawEngineGLES::ApplyDrawStateLate(bool setStencilValue, int stencilValue) // At this point, we know if the vertices are full alpha or not. // TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)? - if (!gstate.isModeClear()) { + if (!gstate.isModeClear() && gstate_c.Supports(GPU_USE_FRAGMENT_TEST_CACHE)) { // Apply last, once we know the alpha params of the texture. if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) { fragmentTestCache_->BindTestTexture(TEX_SLOT_ALPHATEST); diff --git a/GPU/GPUState.h b/GPU/GPUState.h index fa9d4b575c..15b837e5ba 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -466,12 +466,14 @@ struct UVScale { #define FLAG_BIT(x) (1 << x) -// Some of these are OpenGL-specific even though this file is neutral, unfortunately. -// Might want to move this mechanism into the backend later. +// These flags are mainly to make sure that we make decisions on code path in a single +// location. Sometimes we need to take things into account in multiple places, it helps +// to centralize into flags like this. They're also fast to check since the cache line +// will be hot. enum { GPU_SUPPORTS_DUALSOURCE_BLEND = FLAG_BIT(0), GPU_USE_LIGHT_UBERSHADER = FLAG_BIT(1), - // Free bit: 2 + GPU_USE_FRAGMENT_TEST_CACHE = FLAG_BIT(2), GPU_SUPPORTS_VS_RANGE_CULLING = FLAG_BIT(3), GPU_SUPPORTS_BLEND_MINMAX = FLAG_BIT(4), GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5), diff --git a/headless/Headless.cpp b/headless/Headless.cpp index dcfad07e8d..5b2b8adfd3 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -437,7 +437,6 @@ int main(int argc, const char* argv[]) g_Config.bHighQualityDepth = true; g_Config.bMemStickInserted = true; g_Config.iMemStickSizeGB = 16; - g_Config.bFragmentTestCache = true; g_Config.bEnableWlan = true; g_Config.sMACAddress = "12:34:56:78:9A:BC"; g_Config.iFirmwareVersion = PSP_DEFAULT_FIRMWARE; From 26f6afbfa7caef42fc590d42686f8b72ef3da5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 12 Oct 2022 01:02:25 +0200 Subject: [PATCH 141/374] Followup to #16205, fix one more instance of the problem. --- Core/MIPS/ARM/ArmJit.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index 0794ebc22f..0f138c6092 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -566,6 +566,7 @@ void ArmJit::Comp_ReplacementFunc(MIPSOpcode op) } } else if (entry->replaceFunc) { FlushAll(); + SaveDowncount(); RestoreRoundingMode(); gpr.SetRegImm(SCRATCHREG1, GetCompilerPC()); MovToPC(SCRATCHREG1); @@ -582,9 +583,11 @@ void ArmJit::Comp_ReplacementFunc(MIPSOpcode op) if (entry->flags & (REPFLAG_HOOKENTER | REPFLAG_HOOKEXIT)) { // Compile the original instruction at this address. We ignore cycles for hooks. ApplyRoundingMode(); + RestoreDowncount(); MIPSCompileOp(Memory::Read_Instruction(GetCompilerPC(), true), this); } else { ApplyRoundingMode(); + RestoreDowncount(); LDR(R1, CTXREG, MIPS_REG_RA * 4); WriteDownCountR(R0); WriteExitDestInR(R1); From 2f9392083a8a0826ca74b933cfbf2d18e8a9658f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 11 Oct 2022 22:26:31 -0700 Subject: [PATCH 142/374] GPU: Respect stencil state in shader blend. --- GPU/Common/FragmentShaderGenerator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 5b8b9ae070..c9bb2d0992 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -1160,7 +1160,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu // Note that the mask has already been flipped to the PC way - 1 means write. if (colorWriteMask) { - WRITE(p, " v32 = (v32 & u_colorWriteMask) | (d32 & ~u_colorWriteMask);\n"); + if (stencilToAlpha != REPLACE_ALPHA_NO) + WRITE(p, " v32 = (v32 & u_colorWriteMask) | (d32 & ~u_colorWriteMask);\n"); + else + WRITE(p, " v32 = (v32 & u_colorWriteMask & 0x00FFFFFFu) | (d32 & (~u_colorWriteMask | 0xFF000000u));\n"); } WRITE(p, " %s = unpackUnorm4x8(v32);\n", compat.fragColor0); } From acdaaae7a4b0af0efe93eb6f3760b2cd85fe6a5f Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Wed, 12 Oct 2022 11:55:01 +0300 Subject: [PATCH 143/374] Added optional parameter to hle.func.scan, improved code of hle.func.removeRange --- Core/Debugger/WebSocket/HLESubscriber.cpp | 92 ++++++++++++++++------- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/Core/Debugger/WebSocket/HLESubscriber.cpp b/Core/Debugger/WebSocket/HLESubscriber.cpp index 2a90ca619d..50ef77163d 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.cpp +++ b/Core/Debugger/WebSocket/HLESubscriber.cpp @@ -362,6 +362,41 @@ void WebSocketHLEFuncRemove(DebuggerRequest &req) { json.writeUint("size", funcSize); } +static u32 RemoveFuncSymbolsInRange(u32 addr, u32 size) { + // Note: this makes no checks whether the range is valid + + u32 func_address = g_symbolMap->GetFunctionStart(addr); + if (func_address == SymbolMap::INVALID_ADDRESS) { + func_address = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION); + } + + u32 counter = 0; + while (func_address < addr + size && func_address != SymbolMap::INVALID_ADDRESS) { + g_symbolMap->RemoveFunction(func_address, true); + ++counter; + func_address = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION); + } + + if (counter) { + MIPSAnalyst::ForgetFunctions(addr, addr + size - 1); + + // The following was copied from hle.func.remove: + g_symbolMap->SortSymbols(); + + MIPSAnalyst::UpdateHashMap(); + MIPSAnalyst::ApplyHashMap(); + + if (g_Config.bFuncReplacements) { + MIPSAnalyst::ReplaceFunctions(); + } + + // Clear cache for branch lines and such. + DisassemblyManager manager; + manager.clear(); + } + return counter; +} + // Remove function symbols in range (hle.func.removeRange) // // Parameters: @@ -386,34 +421,10 @@ void WebSocketHLEFuncRemoveRange(DebuggerRequest &req) { if (!Memory::IsValidRange(addr, size)) return req.Fail("Address or size outside valid memory"); - u32 first_address = g_symbolMap->GetFunctionStart(addr); - if (first_address == SymbolMap::INVALID_ADDRESS) { - first_address = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION); - } - - u32 counter = 0; - for (u32 current_addr = first_address; (current_addr < addr + size) && current_addr != SymbolMap::INVALID_ADDRESS; current_addr = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION)) { - g_symbolMap->RemoveFunction(current_addr, true); - ++counter; - } - MIPSAnalyst::ForgetFunctions(addr, addr + size - 1); - - // The following was copied from hle.func.remove: - g_symbolMap->SortSymbols(); - - MIPSAnalyst::UpdateHashMap(); - MIPSAnalyst::ApplyHashMap(); - - if (g_Config.bFuncReplacements) { - MIPSAnalyst::ReplaceFunctions(); - } - - // Clear cache for branch lines and such. - DisassemblyManager manager; - manager.clear(); + u32 count = RemoveFuncSymbolsInRange(addr, size); JsonWriter &json = req.Respond(); - json.writeUint("count", counter); + json.writeUint("count", count); } // Rename a function symbol (hle.func.rename) @@ -480,9 +491,38 @@ void WebSocketHLEFuncScan(DebuggerRequest &req) { if (!req.ParamU32("size", &size)) return; + bool has_recreate = req.HasParam("recreate"); + bool recreate; + if (has_recreate) { + if (!req.ParamBool("recreate", &recreate)) { + return; + } + } + if (!Memory::IsValidRange(addr, size)) return req.Fail("Address or size outside valid memory"); + if (recreate) { + // let's see if the last function is partially inside our range + + u32 last_func_start = g_symbolMap->GetFunctionStart(addr + size - 1); + if (last_func_start != SymbolMap::INVALID_ADDRESS) { + // there is a function + // u32 end = last_func_start + g_symbolMap->GetFunctionSize(last_func_start); + if (last_func_start + g_symbolMap->GetFunctionSize(last_func_start) != addr + size) { + size = last_func_start - addr; + } + } + // let's see if the first function is partially inside our range + u32 start = g_symbolMap->GetFunctionStart(addr); + + if (start != SymbolMap::INVALID_ADDRESS && start != addr) { + // skip to a byte after end + addr = start + g_symbolMap->GetFunctionSize(start); + } + RemoveFuncSymbolsInRange(addr, size); + } + bool insertSymbols = MIPSAnalyst::ScanForFunctions(addr, addr + size - 1, true); MIPSAnalyst::FinalizeScan(insertSymbols); From a772e87072731376340c841120090b1f619be642 Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Wed, 12 Oct 2022 12:09:05 +0300 Subject: [PATCH 144/374] Comments updated, default value for parameter "recreate" set to false --- Core/Debugger/WebSocket/HLESubscriber.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/Debugger/WebSocket/HLESubscriber.cpp b/Core/Debugger/WebSocket/HLESubscriber.cpp index 50ef77163d..8c8bfe50dd 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.cpp +++ b/Core/Debugger/WebSocket/HLESubscriber.cpp @@ -476,6 +476,7 @@ void WebSocketHLEFuncRename(DebuggerRequest &req) { // Parameters: // - address: unsigned integer address for the start of the range. // - size: unsigned integer size in bytes for scan. +// - recreate: optional bool indicating whether functions that lie inside the range must be removed before scanning // // Response (same event name) with no extra data. void WebSocketHLEFuncScan(DebuggerRequest &req) { @@ -492,7 +493,7 @@ void WebSocketHLEFuncScan(DebuggerRequest &req) { return; bool has_recreate = req.HasParam("recreate"); - bool recreate; + bool recreate = false; if (has_recreate) { if (!req.ParamBool("recreate", &recreate)) { return; @@ -510,7 +511,7 @@ void WebSocketHLEFuncScan(DebuggerRequest &req) { // there is a function // u32 end = last_func_start + g_symbolMap->GetFunctionSize(last_func_start); if (last_func_start + g_symbolMap->GetFunctionSize(last_func_start) != addr + size) { - size = last_func_start - addr; + size = last_func_start - addr; // decrease the size parameter } } // let's see if the first function is partially inside our range From ade606bc3c7a13f7a13b01f664aa1f0bf17313eb Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 12 Oct 2022 16:21:54 +0200 Subject: [PATCH 145/374] OpenXR - Hookup VR API into Vulkan --- Common/GPU/OpenGL/GLQueueRunner.cpp | 7 +++---- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 18 ++++++++++++------ Common/GPU/Vulkan/VulkanQueueRunner.h | 2 +- Common/GPU/Vulkan/VulkanRenderManager.cpp | 17 ++++++++++++++++- Common/UI/UIScreen.cpp | 5 ----- Common/VR/PPSSPPVR.cpp | 4 ++-- Common/VR/PPSSPPVR.h | 4 ++-- Common/VR/VRFramebuffer.cpp | 23 +++-------------------- Common/VR/VRFramebuffer.h | 4 +--- Common/VR/VRRenderer.cpp | 11 ++++------- Common/VR/VRRenderer.h | 2 +- 11 files changed, 45 insertions(+), 52 deletions(-) diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index 80222bbfbf..e5a7b74eb8 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -1589,6 +1589,9 @@ void GLQueueRunner::PerformBindFramebufferAsRenderTarget(const GLRStep &pass) { fbo_bind_fb_target(false, curFB_->handle); } else { fbo_unbind(); + if (IsVRBuild()) { + BindVRFramebuffer(); + } // Backbuffer is now bound. } CHECK_GL_ERROR_IF_DEBUG(); @@ -1741,10 +1744,6 @@ void GLQueueRunner::fbo_unbind() { bindDefaultFBO(); #endif - if (IsVRBuild()) { - BindVRFramebuffer(); - } - currentDrawHandle_ = 0; currentReadHandle_ = 0; CHECK_GL_ERROR_IF_DEBUG(); diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 69d81b5391..161c2942b9 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -3,6 +3,7 @@ #include "Common/GPU/DataFormat.h" #include "Common/GPU/Vulkan/VulkanQueueRunner.h" #include "Common/GPU/Vulkan/VulkanRenderManager.h" +#include "Common/VR/PPSSPPVR.h" #include "Common/Log.h" #include "Common/TimeUtil.h" @@ -544,7 +545,7 @@ void VulkanQueueRunner::PreprocessSteps(std::vector &steps) { } } -void VulkanQueueRunner::RunSteps(std::vector &steps, FrameData &frameData, FrameDataShared &frameDataShared) { +void VulkanQueueRunner::RunSteps(std::vector &steps, FrameData &frameData, FrameDataShared &frameDataShared, bool keepSteps) { QueueProfileContext *profile = frameData.profilingEnabled_ ? &frameData.profile : nullptr; if (profile) @@ -622,12 +623,13 @@ void VulkanQueueRunner::RunSteps(std::vector &steps, FrameData &frame // Deleting all in one go should be easier on the instruction cache than deleting // them as we go - and easier to debug because we can look backwards in the frame. - for (auto step : steps) { - delete step; + if (!keepSteps) { + for (auto step : steps) { + delete step; + } + steps.clear(); } - steps.clear(); - if (profile) profile->cpuEndTime = time_now_d(); } @@ -1652,7 +1654,11 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR }; renderPass = GetRenderPass(key); - framebuf = backbuffer_; + if (IsVRBuild()) { + framebuf = (VkFramebuffer)BindVRFramebuffer(); + } else { + framebuf = backbuffer_; + } // Raw, rotated backbuffer size. w = vulkan_->GetBackbufferWidth(); diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index 7036029149..63dcd66b23 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -278,7 +278,7 @@ public: } void PreprocessSteps(std::vector &steps); - void RunSteps(std::vector &steps, FrameData &frameData, FrameDataShared &frameDataShared); + void RunSteps(std::vector &steps, FrameData &frameData, FrameDataShared &frameDataShared, bool keepSteps = false); void LogSteps(const std::vector &steps, bool verbose); std::string StepToString(const VKRStep &step) const; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 3343bd889f..9d48914e94 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -12,6 +12,9 @@ #include "Common/GPU/Vulkan/VulkanRenderManager.h" #include "Common/Thread/ThreadUtil.h" +#include "Common/VR/PPSSPPVR.h" + +#include "Core/Config.h" #if 0 // def _DEBUG #define VLOG(...) NOTICE_LOG(G3D, __VA_ARGS__) @@ -1262,7 +1265,19 @@ void VulkanRenderManager::Run(VKRRenderThreadTask &task) { if (task.steps.empty() && !frameData.hasAcquired) frameData.skipSwap = true; //queueRunner_.LogSteps(stepsOnThread, false); - queueRunner_.RunSteps(task.steps, frameData, frameDataShared_); + if (IsVRBuild()) { + int passes = 1; + if (!IsMultiviewSupported() && g_Config.bEnableStereo) { + passes = 2; + } + for (int i = 0; i < passes; i++) { + PreVRFrameRender(i); + queueRunner_.RunSteps(task.steps, frameData, frameDataShared_, i < passes - 1); + PostVRFrameRender(); + } + } else { + queueRunner_.RunSteps(task.steps, frameData, frameDataShared_); + } switch (task.runType) { case VKRRunType::PRESENT: diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index ecebae3a81..41ec1bb76d 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -12,7 +12,6 @@ #include "Common/UI/Root.h" #include "Common/Data/Text/I18n.h" #include "Common/Render/DrawBuffer.h" -#include "Common/VR/PPSSPPVR.h" #include "Common/Log.h" #include "Common/StringUtils.h" @@ -89,10 +88,6 @@ void UIScreen::preRender() { draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "UI"); screenManager()->getUIContext()->BeginFrame(); - if (IsVRBuild()) { - BindVRFramebuffer(); - } - Draw::Viewport viewport; viewport.TopLeftX = 0; viewport.TopLeftY = 0; diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 18b9f00e3c..31c6a20fce 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -290,8 +290,8 @@ VR rendering integration ================================================================================ */ -void BindVRFramebuffer() { - VR_BindFramebuffer(VR_GetEngine()); +void* BindVRFramebuffer() { + return VR_BindFramebuffer(VR_GetEngine()); } bool StartVRRender() { diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 6fbe2f00fb..a7b5d8420d 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -32,7 +32,7 @@ void PreprocessStepVR(void* step); void SetVRCompat(VRCompatFlag flag, long value); // VR rendering integration -void BindVRFramebuffer(); +void* BindVRFramebuffer(); bool StartVRRender(); void FinishVRRender(); void PreVRFrameRender(int fboIndex); @@ -59,7 +59,7 @@ inline void PreprocessStepVR(void* step) {} inline void SetVRCompat(VRCompatFlag flag, long value) {} // VR rendering integration -inline void BindVRFramebuffer() {} +inline void* BindVRFramebuffer() { return nullptr; } inline bool StartVRRender() { return false; } inline void FinishVRRender() {} inline void PreVRFrameRender(int fboIndex) {} diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 1a62417c3e..b8dbe5671b 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -217,29 +217,12 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { ovrFramebuffer_Clear(frameBuffer); } -void ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { +void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { - //TODO:bind framebuffer + return frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); - } -} - -void ovrFramebuffer_SetNone(ovrFramebuffer* frameBuffer) { - if (frameBuffer->UseVulkan) { - //TODO:unbind framebuffer - } else { - GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0)); - } -} - -void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer) { - // Discard the depth buffer, so the tiler won't need to write it back out to memory. - if (frameBuffer->UseVulkan) { - //TODO:implement - } else { - const GLenum depthAttachment[1] = {GL_DEPTH_ATTACHMENT}; - glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, 1, depthAttachment); + return nullptr; } } diff --git a/Common/VR/VRFramebuffer.h b/Common/VR/VRFramebuffer.h index 12eb162980..644a28fe4c 100644 --- a/Common/VR/VRFramebuffer.h +++ b/Common/VR/VRFramebuffer.h @@ -7,10 +7,8 @@ void ovrApp_Destroy(ovrApp* app); int ovrApp_HandleXrEvents(ovrApp* app); void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer); -void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer); void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer); -void ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer); -void ovrFramebuffer_SetNone(ovrFramebuffer* frameBuffer); +void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer); void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int height, bool multiview, void* vulkanContext); void ovrRenderer_Destroy(ovrRenderer* renderer); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 4d41d09bcd..77e80ca9aa 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -372,10 +372,7 @@ void VR_EndFrame( engine_t* engine ) { ovrRenderer_MouseCursor(&engine->appState.Renderer, x, y, size); } - ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer[fboIndex]; - //ovrFramebuffer_Resolve(frameBuffer); - ovrFramebuffer_Release(frameBuffer); - ovrFramebuffer_SetNone(frameBuffer); + ovrFramebuffer_Release(&engine->appState.Renderer.FrameBuffer[fboIndex]); } void VR_FinishFrame( engine_t* engine ) { @@ -487,10 +484,10 @@ void VR_SetConfig( VRConfig config, int value) { vrConfig[config] = value; } -void VR_BindFramebuffer(engine_t *engine) { - if (!initialized) return; +void* VR_BindFramebuffer(engine_t *engine) { + if (!initialized) return nullptr; int fboIndex = vrConfig[VR_CONFIG_CURRENT_FBO]; - ovrFramebuffer_SetCurrent(&engine->appState.Renderer.FrameBuffer[fboIndex]); + return ovrFramebuffer_SetCurrent(&engine->appState.Renderer.FrameBuffer[fboIndex]); } ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) { diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index e19a0e82a5..fe7a4671f1 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -51,5 +51,5 @@ void VR_FinishFrame( engine_t* engine ); int VR_GetConfig( VRConfig config ); void VR_SetConfig( VRConfig config, int value); -void VR_BindFramebuffer(engine_t *engine); +void* VR_BindFramebuffer(engine_t *engine); ovrMatrix4f VR_GetMatrix( VRMatrix matrix ); From d0431e494ad281aac0a3187c95274441bd86a667 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 12 Oct 2022 19:16:17 +0200 Subject: [PATCH 146/374] OpenXR - Create VR framebuffer for Vulkan --- Common/VR/VRBase.h | 2 ++ Common/VR/VRFramebuffer.cpp | 52 +++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index c05e4739a9..08ae4708f2 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -111,6 +111,8 @@ typedef struct { void* DepthSwapChainImage; unsigned int* GLFrameBuffers; VkFramebuffer* VKFrameBuffers; + VkImageView* VKColorImages; + VkImageView* VKDepthImages; bool Acquired; bool UseVulkan; diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index b8dbe5671b..1e948ea90c 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -187,13 +187,51 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int &frameBuffer->TextureSwapChainLength, (XrSwapchainImageBaseHeader*)frameBuffer->DepthSwapChainImage)); - frameBuffer->VKFrameBuffers = (VkFramebuffer*)malloc(frameBuffer->TextureSwapChainLength * sizeof(VkFramebuffer)); + frameBuffer->VKColorImages = new VkImageView[frameBuffer->TextureSwapChainLength]; + frameBuffer->VKDepthImages = new VkImageView[frameBuffer->TextureSwapChainLength]; + frameBuffer->VKFrameBuffers = new VkFramebuffer[frameBuffer->TextureSwapChainLength]; for (uint32_t i = 0; i < frameBuffer->TextureSwapChainLength; i++) { - VkImage colorTexture = ((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].image; - VkImage depthTexture = ((XrSwapchainImageVulkanKHR*)frameBuffer->DepthSwapChainImage)[i].image; + VkImageViewCreateInfo createInfo{}; + createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + createInfo.image = ((XrSwapchainImageVulkanKHR*)frameBuffer->ColorSwapChainImage)[i].image; + createInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; + createInfo.format = VK_FORMAT_R8G8B8A8_UNORM; + createInfo.components.r = VK_COMPONENT_SWIZZLE_IDENTITY; + createInfo.components.g = VK_COMPONENT_SWIZZLE_IDENTITY; + createInfo.components.b = VK_COMPONENT_SWIZZLE_IDENTITY; + createInfo.components.a = VK_COMPONENT_SWIZZLE_IDENTITY; + createInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + createInfo.subresourceRange.baseMipLevel = 0; + createInfo.subresourceRange.levelCount = 1; + createInfo.subresourceRange.baseArrayLayer = 0; + createInfo.subresourceRange.layerCount = swapChainCreateInfo.arraySize; + if (vkCreateImageView(frameBuffer->VKContext->device, &createInfo, nullptr, &frameBuffer->VKColorImages[i]) != VK_SUCCESS) { + ALOGE("failed to create color image view!"); + return false; + } + + createInfo.image = ((XrSwapchainImageVulkanKHR*)frameBuffer->DepthSwapChainImage)[i].image; + createInfo.format = VK_FORMAT_D24_UNORM_S8_UINT; + createInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; + if (vkCreateImageView(frameBuffer->VKContext->device, &createInfo, nullptr, &frameBuffer->VKDepthImages[i]) != VK_SUCCESS) { + ALOGE("failed to create depth image view!"); + return false; + } // Create the frame buffer. - //TODO:implement framebuffer creation + VkImageView attachments[] = { frameBuffer->VKColorImages[i], frameBuffer->VKDepthImages[i] }; + VkFramebufferCreateInfo framebufferInfo{}; + framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; + framebufferInfo.renderPass = VK_NULL_HANDLE; + framebufferInfo.attachmentCount = 2; + framebufferInfo.pAttachments = attachments; + framebufferInfo.width = width; + framebufferInfo.height = height; + framebufferInfo.layers = swapChainCreateInfo.arraySize; + if (vkCreateFramebuffer(frameBuffer->VKContext->device, &framebufferInfo, nullptr, &frameBuffer->VKFrameBuffers[i]) != VK_SUCCESS) { + ALOGE("failed to create framebuffer!"); + return false; + } } return true; @@ -202,9 +240,13 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { for (int i = 0; i < frameBuffer->TextureSwapChainLength; i++) { + vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr); + vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKDepthImages[i], nullptr); vkDestroyFramebuffer(frameBuffer->VKContext->device, frameBuffer->VKFrameBuffers[i], nullptr); } - free(frameBuffer->VKFrameBuffers); + delete[] frameBuffer->VKColorImages; + delete[] frameBuffer->VKDepthImages; + delete[] frameBuffer->VKFrameBuffers; } else { GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers)); free(frameBuffer->GLFrameBuffers); From 4d1da5859c72ddf1e845b5a9a8c7979e85bfac86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 13 Oct 2022 22:34:21 +0200 Subject: [PATCH 147/374] Add simple way to add debug annotation in the middle of the command stream. Vulkan-only. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 9 +++++++++ Common/GPU/Vulkan/VulkanQueueRunner.h | 4 ++++ Common/GPU/Vulkan/VulkanRenderManager.h | 7 +++++++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 8 ++++++++ Common/GPU/thin3d.h | 2 ++ GPU/Common/FragmentShaderGenerator.cpp | 3 ++- 6 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 6ce019b1fb..5a55e1e916 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1579,6 +1579,15 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c } break; } + + case VKRRenderCommand::DEBUG_ANNOTATION: + if (vulkan_->Extensions().EXT_debug_utils) { + VkDebugUtilsLabelEXT labelInfo{ VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT }; + labelInfo.pLabelName = c.debugAnnotation.annotation; + vkCmdInsertDebugUtilsLabelEXT(cmd, &labelInfo); + } + break; + default: ERROR_LOG(G3D, "Unimpl queue command"); } diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index 7036029149..396a37edae 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -38,6 +38,7 @@ enum class VKRRenderCommand : uint8_t { DRAW_INDEXED, PUSH_CONSTANTS, SELF_DEPENDENCY_BARRIER, + DEBUG_ANNOTATION, NUM_RENDER_COMMANDS, }; @@ -136,6 +137,9 @@ struct VkRenderData { uint8_t size; uint8_t data[40]; // Should be enough for now. } push; + struct { + const char *annotation; + } debugAnnotation; }; }; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 7ba98b485c..3c2f9dd12d 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -429,6 +429,13 @@ public: curRenderStep_->render.numDraws++; } + // These can be useful both when inspecting in RenderDoc, and when manually inspecting recorded commands + // in the debugger. + void DebugAnnotate(const char *annotation) { + VkRenderData data{ VKRRenderCommand::DEBUG_ANNOTATION }; + data.debugAnnotation.annotation = annotation; + } + VkCommandBuffer GetInitCmd(); // Gets a frame-unique ID of the current step being recorded. Can be used to figure out diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index dc1b806011..7d3b0e8218 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -367,6 +367,8 @@ public: VKContext(VulkanContext *vulkan); virtual ~VKContext(); + void DebugAnnotate(const char *annotation) override; + const DeviceCaps &GetDeviceCaps() const override { return caps_; } @@ -1010,6 +1012,8 @@ VkDescriptorSet VKContext::GetOrCreateDescriptorSet(VkBuffer buf) { return VK_NULL_HANDLE; } + vulkan_->SetDebugName(descSet, VK_OBJECT_TYPE_DESCRIPTOR_SET, "(thin3d desc set)"); + VkDescriptorBufferInfo bufferDesc; bufferDesc.buffer = buf; bufferDesc.offset = 0; @@ -1651,4 +1655,8 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) { } } +void VKContext::DebugAnnotate(const char *annotation) { + renderManager_.DebugAnnotate(annotation); +} + } // namespace Draw diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 132c0e02f9..8c440deb04 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -616,6 +616,8 @@ public: virtual void SetErrorCallback(ErrorCallbackFn callback, void *userdata) {} + virtual void DebugAnnotate(const char *annotation) {} + // Partial pipeline state, used to create pipelines. (in practice, in d3d11 they'll use the native state objects directly). // TODO: Possibly ditch these and just put the descs directly in PipelineDesc since only D3D11 benefits. virtual DepthStencilState *CreateDepthStencilState(const DepthStencilStateDesc &desc) = 0; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index c9bb2d0992..efd7c5a229 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -120,8 +120,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool isModeClear = id.Bit(FS_BIT_CLEARMODE); const char *shading = ""; - if (compat.glslES30 || compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) + if (compat.glslES30 || compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) { shading = doFlatShading ? "flat" : ""; + } bool useDiscardStencilBugWorkaround = id.Bit(FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL); From a605366254a5ff7e3c4807de183b05d73fcabd8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 13 Oct 2022 22:35:23 +0200 Subject: [PATCH 148/374] Add ShaderId utility function to be used for some sanity checking. --- GPU/Common/ShaderId.cpp | 12 +++++++++--- GPU/Common/ShaderId.h | 3 +++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 94ade2fd26..43fcbab8ab 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -255,6 +255,12 @@ std::string FragmentShaderDesc(const FShaderID &id) { return desc.str(); } +bool FragmentIdNeedsFramebufferRead(const FShaderID &id) { + return id.Bit(FS_BIT_COLOR_WRITEMASK) || + id.Bits(FS_BIT_REPLACE_LOGIC_OP, 4) != GE_LOGIC_COPY || + (ReplaceBlendType)id.Bits(FS_BIT_REPLACE_BLEND, 3) == REPLACE_BLEND_READ_FRAMEBUFFER; +} + // Here we must take all the bits of the gstate that determine what the fragment shader will // look like, and concatenate them together into an ID. void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pipelineState, const Draw::Bugs &bugs) { @@ -276,12 +282,12 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip ShaderDepalMode shaderDepalMode = gstate_c.shaderDepalMode; bool colorWriteMask = pipelineState.maskState.applyFramebufferRead; - ReplaceBlendType replaceBlend = pipelineState.blendState.replaceBlend; - ReplaceAlphaType stencilToAlpha = pipelineState.blendState.replaceAlphaWithStencil; - SimulateLogicOpType simulateLogicOpType = pipelineState.blendState.simulateLogicOpType; GELogicOp replaceLogicOpType = pipelineState.logicState.applyFramebufferRead ? pipelineState.logicState.logicOp : GE_LOGIC_COPY; + SimulateLogicOpType simulateLogicOpType = pipelineState.blendState.simulateLogicOpType; + ReplaceAlphaType stencilToAlpha = pipelineState.blendState.replaceAlphaWithStencil; + // All texfuncs except replace are the same for RGB as for RGBA with full alpha. // Note that checking this means that we must dirty the fragment shader ID whenever textureFullAlpha changes. if (gstate_c.textureFullAlpha && gstate.getTextureFunction() != GE_TEXFUNC_REPLACE) { diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 560b8a873a..2edf271b6d 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -284,3 +284,6 @@ std::string FragmentShaderDesc(const FShaderID &id); void ComputeGeometryShaderID(GShaderID *id, const Draw::Bugs &bugs, int prim); std::string GeometryShaderDesc(const GShaderID &id); + +// For sanity checking. +bool FragmentIdNeedsFramebufferRead(const FShaderID &id); From f269137c78113fdf2c9e7fcc3fca88cc0c312fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 13 Oct 2022 22:38:04 +0200 Subject: [PATCH 149/374] Revert "Vulkan: Create depth/stencil buffers on demand" This reverts commit be37de106c3fa657611c9ad0a63683c93adbbd19. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 7 ++----- Common/GPU/Vulkan/VulkanRenderManager.cpp | 16 +++++----------- Common/GPU/Vulkan/VulkanRenderManager.h | 5 +---- Common/UI/Context.cpp | 2 +- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 5a55e1e916..b085adcef7 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1624,7 +1624,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR renderPass = GetRenderPass(key); VKRFramebuffer *fb = step.render.framebuffer; - framebuf = fb->Get(renderPass, step.render.renderPassType, cmd); + framebuf = fb->Get(renderPass, step.render.renderPassType); w = fb->width; h = fb->height; @@ -1739,8 +1739,6 @@ void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) { if (step.copy.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { _dbg_assert_(src->depth.image != VK_NULL_HANDLE); - dst->EnsureDepthImage(cmd); - if (src->depth.layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { SetupTransitionToTransferSrc(src->depth, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, &recordBarrier_); } @@ -1816,8 +1814,7 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { // We can't copy only depth or only stencil unfortunately. if (step.blit.aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) { _dbg_assert_(src->depth.image != VK_NULL_HANDLE); - - dst->EnsureDepthImage(cmd); + _dbg_assert_(dst->depth.image != VK_NULL_HANDLE); if (src->depth.layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { SetupTransitionToTransferSrc(src->depth, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, &recordBarrier_); diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 7c7d8418c6..da43a85d7e 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -161,6 +161,9 @@ VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRe _dbg_assert_(tag); CreateImage(vulkan_, initCmd, color, width, height, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true, tag); + if (createDepthStencilBuffer) { + CreateImage(vulkan_, initCmd, depth, width, height, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false, tag); + } UpdateTag(tag); @@ -169,7 +172,6 @@ VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRe } void VKRFramebuffer::UpdateTag(const char *newTag) { - tag_ = newTag; char name[128]; snprintf(name, sizeof(name), "fb_color_%s", tag_.c_str()); vulkan_->SetDebugName(color.image, VK_OBJECT_TYPE_IMAGE, name); @@ -187,14 +189,7 @@ void VKRFramebuffer::UpdateTag(const char *newTag) { } } -void VKRFramebuffer::EnsureDepthImage(VkCommandBuffer initCmd) { - if (!depth.image) { - CreateImage(vulkan_, initCmd, depth, width, height, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false, tag_.c_str()); - UpdateTag(tag_.c_str()); - } -} - -VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, VkCommandBuffer initCmd) { +VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType) { if (framebuf[(int)rpType]) { return framebuf[(int)rpType]; } @@ -206,8 +201,7 @@ VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPas views[0] = color.imageView; if (hasDepth) { - // Make sure there's a depth buffer! - EnsureDepthImage(initCmd); + _dbg_assert_(depth.imageView != VK_NULL_HANDLE); views[1] = depth.imageView; } fbci.renderPass = compatibleRenderPass->Get(vulkan_, rpType); diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 3c2f9dd12d..a96dd96875 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -47,10 +47,7 @@ public: VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, bool createDepthStencilBuffer, const char *tag); ~VKRFramebuffer(); - void EnsureDepthImage(VkCommandBuffer initCmd); - - // Needs a command buffer in case it need to initialize the depth buffer on-demand. - VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, VkCommandBuffer initCmd); + VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType); int width = 0; int height = 0; diff --git a/Common/UI/Context.cpp b/Common/UI/Context.cpp index da4a98fa78..21c687bd2b 100644 --- a/Common/UI/Context.cpp +++ b/Common/UI/Context.cpp @@ -170,7 +170,7 @@ void UIContext::ActivateTopScissor() { int h = std::max(0.0f, ceilf(scale_y * bounds.h)); if (x < 0 || y < 0 || x + w > pixel_xres || y + h > pixel_yres) { // This won't actually report outside a game, but we can try. - WARN_LOG(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres); + ERROR_LOG_REPORT(G3D, "UI scissor out of bounds in %sScreen: %d,%d-%d,%d / %d,%d", screenTag_ ? screenTag_ : "N/A", x, y, w, h, pixel_xres, pixel_yres); x = std::max(0, x); y = std::max(0, y); w = std::min(w, pixel_xres - x); From de416503184a2e1b28f4eb9818dc5c97133373e9 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 14 Oct 2022 16:47:54 +0200 Subject: [PATCH 150/374] OpenXR - Disable VUlkan for now --- Common/GPU/Vulkan/VulkanLoader.cpp | 6 ++++++ Common/VR/VRFramebuffer.cpp | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Common/GPU/Vulkan/VulkanLoader.cpp b/Common/GPU/Vulkan/VulkanLoader.cpp index 2ead5cb95d..b0c2ab370b 100644 --- a/Common/GPU/Vulkan/VulkanLoader.cpp +++ b/Common/GPU/Vulkan/VulkanLoader.cpp @@ -23,6 +23,7 @@ #include "Common/GPU/Vulkan/VulkanLoader.h" #include "Common/Log.h" #include "Common/System/System.h" +#include "Common/VR/PPSSPPVR.h" #if !PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(SWITCH) #include @@ -308,6 +309,11 @@ void VulkanSetAvailable(bool available) { bool VulkanMayBeAvailable() { + //unsupported in VR at the moment + if (IsVRBuild()) { + return false; + } + if (g_vulkanAvailabilityChecked) { return g_vulkanMayBeAvailable; } diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 1e948ea90c..742e9457c6 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -222,7 +222,7 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int VkImageView attachments[] = { frameBuffer->VKColorImages[i], frameBuffer->VKDepthImages[i] }; VkFramebufferCreateInfo framebufferInfo{}; framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO; - framebufferInfo.renderPass = VK_NULL_HANDLE; + framebufferInfo.renderPass = VK_NULL_HANDLE; //TODO:This is probably wrong framebufferInfo.attachmentCount = 2; framebufferInfo.pAttachments = attachments; framebufferInfo.width = width; From e1924be464f3751b6c8c088bc985753c509c3a20 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 14 Oct 2022 18:28:22 +0200 Subject: [PATCH 151/374] OpenXR - Ensure the app gets unloaded when killed by OS --- android/src/org/ppsspp/ppsspp/NativeActivity.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index bed2de57e3..7fcfe678f6 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -789,6 +789,11 @@ public abstract class NativeActivity extends Activity { initialized = false; } navigationCallbackView = null; + + // Workaround for VR issues PPSSPP restart + if (isVRDevice()) { + System.exit(0); + } } @Override From 7b058a534c708f60bbd5ef775d07410abc781645 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 14 Oct 2022 18:32:45 +0200 Subject: [PATCH 152/374] typo --- android/src/org/ppsspp/ppsspp/NativeActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 7fcfe678f6..5de8a70b77 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -790,7 +790,7 @@ public abstract class NativeActivity extends Activity { } navigationCallbackView = null; - // Workaround for VR issues PPSSPP restart + // Workaround for VR issues when PPSSPP restarts if (isVRDevice()) { System.exit(0); } From b0ceeede79026749680fd3dd943d3c8399278f7d Mon Sep 17 00:00:00 2001 From: catsout Date: Sat, 15 Oct 2022 18:49:45 +0800 Subject: [PATCH 153/374] Vulkan: fix wayland swapchain size 1x1 From Vulkan spec, surfaceCapabilities.currentExtent can be 0xFFFFFFFF(-1) Define a callback to get drawsize from window creator relate: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSurfaceCapabilitiesKHR.html https://github.com/KhronosGroup/Vulkan-Docs/issues/590#issuecomment-347932321 --- Common/GPU/Vulkan/VulkanContext.cpp | 19 ++++++++++++++++--- Common/GPU/Vulkan/VulkanContext.h | 3 +++ SDL/SDLVulkanGraphicsContext.cpp | 7 +++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index f0764a72f3..937276d10f 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -1011,12 +1011,21 @@ bool VulkanContext::InitSwapchain() { res = vkGetPhysicalDeviceSurfacePresentModesKHR(physical_devices_[physical_device_], surface_, &presentModeCount, presentModes); _dbg_assert_(res == VK_SUCCESS); + VkExtent2D currentExtent { surfCapabilities_.currentExtent }; + // https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSurfaceCapabilitiesKHR.html + // currentExtent is the current width and height of the surface, or the special value (0xFFFFFFFF, 0xFFFFFFFF) indicating that the surface size will be determined by the extent of a swapchain targeting the surface. + if (currentExtent.width == 0xFFFFFFFFu || currentExtent.height == 0xFFFFFFFFu) { + _dbg_assert_((bool)cbGetDrawSize_) + if (cbGetDrawSize_) { + currentExtent = cbGetDrawSize_(); + } + } - swapChainExtent_.width = clamp(surfCapabilities_.currentExtent.width, surfCapabilities_.minImageExtent.width, surfCapabilities_.maxImageExtent.width); - swapChainExtent_.height = clamp(surfCapabilities_.currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height); + swapChainExtent_.width = clamp(currentExtent.width, surfCapabilities_.minImageExtent.width, surfCapabilities_.maxImageExtent.width); + swapChainExtent_.height = clamp(currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height); INFO_LOG(G3D, "surfCapabilities_.current: %dx%d min: %dx%d max: %dx%d computed: %dx%d", - surfCapabilities_.currentExtent.width, surfCapabilities_.currentExtent.height, + currentExtent.width, currentExtent.height, surfCapabilities_.minImageExtent.width, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.width, surfCapabilities_.maxImageExtent.height, swapChainExtent_.width, swapChainExtent_.height); @@ -1161,6 +1170,10 @@ bool VulkanContext::InitSwapchain() { return true; } +void VulkanContext::SetCbGetDrawSize(std::function cb) { + cbGetDrawSize_ = cb; +} + VkFence VulkanContext::CreateFence(bool presignalled) { VkFence fence; VkFenceCreateInfo fenceInfo{ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index 87a73a59fc..fb98b5a0db 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "Common/Log.h" #include "Common/GPU/Vulkan/VulkanLoader.h" @@ -190,6 +191,7 @@ public: VkResult ReinitSurface(); bool InitSwapchain(); + void SetCbGetDrawSize(std::function); void DestroySwapchain(); void DestroySurface(); @@ -363,6 +365,7 @@ private: // that we really don't want in everything that uses VulkanContext. void *winsysData1_; void *winsysData2_; + std::function cbGetDrawSize_; VkInstance instance_ = VK_NULL_HANDLE; VkDevice device_ = VK_NULL_HANDLE; diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index b7eb932b11..624d3b497f 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -10,6 +10,7 @@ #include "Common/Data/Text/Parsers.h" #include "Core/System.h" +#include "SDL_vulkan.h" #include "SDLVulkanGraphicsContext.h" #if defined(VK_USE_PLATFORM_METAL_EXT) @@ -72,6 +73,12 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, return false; } + vulkan_->SetCbGetDrawSize([window]() { + int w=1,h=1; + SDL_Vulkan_GetDrawableSize(window, &w, &h); + return VkExtent2D {(uint32_t)w, (uint32_t)h}; + }); + SDL_SysWMinfo sys_info{}; SDL_VERSION(&sys_info.version); //Set SDL version if (!SDL_GetWindowWMInfo(window, &sys_info)) { From 4a967966ef6f09b4d1e9fb3c74c06d919d7f08fd Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Sat, 15 Oct 2022 16:01:12 +0300 Subject: [PATCH 154/374] Removed the bugged part of hle.func.scan + new comments --- Core/Debugger/WebSocket/HLESubscriber.cpp | 41 +++++++++++++---------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Core/Debugger/WebSocket/HLESubscriber.cpp b/Core/Debugger/WebSocket/HLESubscriber.cpp index 8c8bfe50dd..09b67624d1 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.cpp +++ b/Core/Debugger/WebSocket/HLESubscriber.cpp @@ -362,9 +362,10 @@ void WebSocketHLEFuncRemove(DebuggerRequest &req) { json.writeUint("size", funcSize); } +// This function removes function symbols that intersect or lie inside the range +// (Note: this makes no checks whether the range is valid) +// Returns the number of removed functions static u32 RemoveFuncSymbolsInRange(u32 addr, u32 size) { - // Note: this makes no checks whether the range is valid - u32 func_address = g_symbolMap->GetFunctionStart(addr); if (func_address == SymbolMap::INVALID_ADDRESS) { func_address = g_symbolMap->GetNextSymbolAddress(addr, SymbolType::ST_FUNCTION); @@ -476,7 +477,7 @@ void WebSocketHLEFuncRename(DebuggerRequest &req) { // Parameters: // - address: unsigned integer address for the start of the range. // - size: unsigned integer size in bytes for scan. -// - recreate: optional bool indicating whether functions that lie inside the range must be removed before scanning +// - recreate: optional bool indicating whether functions that intersect or inside lie inside the range must be removed before scanning // // Response (same event name) with no extra data. void WebSocketHLEFuncScan(DebuggerRequest &req) { @@ -504,23 +505,27 @@ void WebSocketHLEFuncScan(DebuggerRequest &req) { return req.Fail("Address or size outside valid memory"); if (recreate) { - // let's see if the last function is partially inside our range + // The following code doesn't do what I wanted it to do AND it's debatable whether it's needed at all + // In short, I wanted to shift the start and the end of the range before removal - u32 last_func_start = g_symbolMap->GetFunctionStart(addr + size - 1); - if (last_func_start != SymbolMap::INVALID_ADDRESS) { - // there is a function - // u32 end = last_func_start + g_symbolMap->GetFunctionSize(last_func_start); - if (last_func_start + g_symbolMap->GetFunctionSize(last_func_start) != addr + size) { - size = last_func_start - addr; // decrease the size parameter - } - } - // let's see if the first function is partially inside our range - u32 start = g_symbolMap->GetFunctionStart(addr); + //// let's see if the last function is partially inside our range + + //u32 last_func_start = g_symbolMap->GetFunctionStart(addr + size - 1); + //if (last_func_start != SymbolMap::INVALID_ADDRESS) { + // // there is a function + // // u32 end = last_func_start + g_symbolMap->GetFunctionSize(last_func_start); + // if (last_func_start + g_symbolMap->GetFunctionSize(last_func_start) != addr + size) { + // size = last_func_start - addr; // decrease the size parameter + // } + //} + //// let's see if the first function is partially inside our range + //u32 start = g_symbolMap->GetFunctionStart(addr); + + //if (start != SymbolMap::INVALID_ADDRESS && start != addr) { + // // skip to a byte after end + // addr = start + g_symbolMap->GetFunctionSize(start); + //} - if (start != SymbolMap::INVALID_ADDRESS && start != addr) { - // skip to a byte after end - addr = start + g_symbolMap->GetFunctionSize(start); - } RemoveFuncSymbolsInRange(addr, size); } From 4f5e821ce23f600dd9e3a7e45865fe4bdeb04726 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 11:49:05 -0700 Subject: [PATCH 155/374] softgpu: Fix crash on screenshot w/o display. --- GPU/Software/SoftGpu.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 6ba435028a..ba6da9455c 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1338,6 +1338,9 @@ bool SoftGPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferT GEBufferFormat fmt = gstate.FrameBufFormat(); const u8 *src = fb.data; + if (!Memory::IsValidAddress(displayFramebuf_)) + return false; + if (type == GPU_DBG_FRAMEBUF_DISPLAY) { size.x = 480; size.y = 272; From d33986a5ad2744b1021af25bc614c3f868b9203c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 11:49:28 -0700 Subject: [PATCH 156/374] softgpu: Cull a triangle with all negative w. Per tests, this seems to happen but only when all points are below zero. --- GPU/Software/Clipper.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPU/Software/Clipper.cpp b/GPU/Software/Clipper.cpp index 2581cdf4c2..e9ad7ec5b4 100644 --- a/GPU/Software/Clipper.cpp +++ b/GPU/Software/Clipper.cpp @@ -302,6 +302,9 @@ void ProcessTriangle(const ClipVertexData &v0, const ClipVertexData &v1, const C // If any verts were outside range, throw the entire prim away. if (v0.OutsideRange() || v1.OutsideRange() || v2.OutsideRange()) return; + // If all verts have negative W, we also cull. + if (v0.clippos.w < 0.0f && v1.clippos.w < 0.0f && v2.clippos.w < 0.0f) + return; mask |= CalcClipMask(v0.clippos); mask |= CalcClipMask(v1.clippos); From 49eb100d1ab85c677fa199d3beb565d6c4265ee2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 12:16:34 -0700 Subject: [PATCH 157/374] headless: Update tests. --- pspautotests | 2 +- test.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pspautotests b/pspautotests index dd16bcad59..2a607edab7 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit dd16bcad59dbd098a66b87048184e70debb22d6f +Subproject commit 2a607edab7c3f50d9597c3a2b77082c3be871b55 diff --git a/test.py b/test.py index 0a8896b2b7..2ae8d9237d 100755 --- a/test.py +++ b/test.py @@ -139,6 +139,7 @@ tests_good = [ "font/resolution", "font/shadowimagerect", "gpu/callbacks/ge_callbacks", + "gpu/clipping/homogeneous", "gpu/clut/address", "gpu/clut/masks", "gpu/clut/offset", @@ -192,6 +193,10 @@ tests_good = [ "intr/suspended", "intr/vblank/vblank", "io/cwd/cwd", + "jpeg/create", + "jpeg/delete", + "jpeg/finish", + "jpeg/init", "loader/bss/bss", "malloc/malloc", "misc/dcache", @@ -400,6 +405,7 @@ tests_next = [ "gpu/filtering/precisionlinear3d", "gpu/filtering/precisionnearest2d", "gpu/filtering/precisionnearest3d", + "gpu/ge/edramswizzle", "gpu/ge/get", "gpu/primitives/bezier", "gpu/primitives/continue", @@ -430,6 +436,13 @@ tests_next = [ "io/io/io", "io/iodrv/iodrv", "io/open/tty0", + "jpeg/csc", + "jpeg/decode", + "jpeg/decodes", + "jpeg/decodeycbcr", + "jpeg/decodeycbcrs", + "jpeg/getoutputinfo", + "jpeg/mjpegcsc", # Doesn't work on a PSP for security reasons, hangs in PPSSPP currently. # Commented out to make tests run much faster. #"modules/loadexec/loader", From 8156f6fe28cafe8e0271d155098e77e3a8ca3bdc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 12:50:27 -0700 Subject: [PATCH 158/374] D3D9: Correct scissor state cache in Draw. Gets reset when updating the render target. This fixes UI scissors. --- Common/GPU/D3D9/thin3d_d3d9.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 11e9f08012..20bcc14e5d 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -1318,6 +1318,7 @@ void D3D9Context::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPa } dxstate.scissorRect.restore(); + dxstate.scissorTest.restore(); dxstate.viewport.restore(); stepId_++; } From c4bf2cb5c0fa00c61c88f2c1036ce779dd7f161f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 18:27:52 -0700 Subject: [PATCH 159/374] jit: Ignore zero byte icache invalidates. These were getting marked pending and were clearing all cache, causing performance concerns in for example LittleBigPlanet. --- Core/HLE/ReplaceTables.cpp | 7 ++++--- Core/HLE/sceDmac.cpp | 2 +- Core/HLE/sceKernel.cpp | 3 ++- Core/HLE/sceKernelInterrupt.cpp | 3 ++- Core/MIPS/MIPS.cpp | 17 +++++++++-------- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 5e8c093671..85817a49e3 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -233,8 +233,9 @@ static int Replace_memcpy16() { bool skip = false; // Some games use memcpy on executable code. We need to flush emuhack ops. - currentMIPS->InvalidateICache(srcPtr, bytes); - if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0) { + if (bytes != 0) + currentMIPS->InvalidateICache(srcPtr, bytes); + if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMCPY) == 0 && bytes != 0) { if (Memory::IsVRAMAddress(destPtr) || Memory::IsVRAMAddress(srcPtr)) { skip = gpu->PerformMemoryCopy(destPtr, srcPtr, bytes); } @@ -305,7 +306,7 @@ static int Replace_memmove() { bool skip = false; // Some games use memcpy on executable code. We need to flush emuhack ops. - if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMMOVE) == 0) { + if ((skipGPUReplacements & (int)GPUReplacementSkip::MEMMOVE) == 0 && bytes != 0) { currentMIPS->InvalidateICache(srcPtr, bytes); if (Memory::IsVRAMAddress(destPtr) || Memory::IsVRAMAddress(srcPtr)) { skip = gpu->PerformMemoryCopy(destPtr, srcPtr, bytes); diff --git a/Core/HLE/sceDmac.cpp b/Core/HLE/sceDmac.cpp index 5fba8f9b94..3735eb2a84 100644 --- a/Core/HLE/sceDmac.cpp +++ b/Core/HLE/sceDmac.cpp @@ -49,7 +49,7 @@ static int __DmacMemcpy(u32 dst, u32 src, u32 size) { if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) { skip = gpu->PerformMemoryCopy(dst, src, size); } - if (!skip) { + if (!skip && size != 0) { currentMIPS->InvalidateICache(src, size); if (MemBlockInfoDetailed(size)) { const std::string tag = GetMemWriteTagAt("DmacMemcpy/", src, size); diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index b9d1028b48..6f18a5768e 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -392,7 +392,8 @@ int sceKernelDcacheInvalidateRange(u32 addr, int size) int sceKernelIcacheInvalidateRange(u32 addr, int size) { DEBUG_LOG(CPU, "sceKernelIcacheInvalidateRange(%08x, %i)", addr, size); - currentMIPS->InvalidateICache(addr, size); + if (size != 0) + currentMIPS->InvalidateICache(addr, size); return 0; } diff --git a/Core/HLE/sceKernelInterrupt.cpp b/Core/HLE/sceKernelInterrupt.cpp index 4c91ffe529..3dadc4dc77 100644 --- a/Core/HLE/sceKernelInterrupt.cpp +++ b/Core/HLE/sceKernelInterrupt.cpp @@ -624,7 +624,8 @@ static u32 sceKernelMemcpy(u32 dst, u32 src, u32 size) DEBUG_LOG(SCEKERNEL, "sceKernelMemcpy(dest=%08x, src=%08x, size=%i)", dst, src, size); // Some games copy from executable code. We need to flush emuhack ops. - currentMIPS->InvalidateICache(src, size); + if (size != 0) + currentMIPS->InvalidateICache(src, size); bool skip = false; if (Memory::IsVRAMAddress(src) || Memory::IsVRAMAddress(dst)) { diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 5aeeacbbf8..9a472b08c5 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -366,14 +366,15 @@ void MIPSState::ProcessPendingClears() { void MIPSState::InvalidateICache(u32 address, int length) { // Only really applies to jit. std::lock_guard guard(MIPSComp::jitLock); - if (MIPSComp::jit) { - if (coreState == CORE_RUNNING || insideJit) { - pendingClears.emplace_back(address, length); - hasPendingClears = true; - CoreTiming::ForceCheck(); - } else { - MIPSComp::jit->InvalidateCacheAt(address, length); - } + if (!MIPSComp::jit || length == 0) + return; + + if (coreState == CORE_RUNNING || insideJit) { + pendingClears.emplace_back(address, length); + hasPendingClears = true; + CoreTiming::ForceCheck(); + } else { + MIPSComp::jit->InvalidateCacheAt(address, length); } } From fa5f9d5e74b54e1abbfa1a4e2eacc527f5638e46 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 18:30:13 -0700 Subject: [PATCH 160/374] jit: Consistently check range on invalidate. We did this on x86, we should do it everywhere or nowhere. --- Core/MIPS/ARM/ArmJit.cpp | 7 ++++--- Core/MIPS/ARM64/Arm64Jit.cpp | 4 +++- Core/MIPS/MIPS/MipsJit.cpp | 7 ++++--- Core/MIPS/fake/FakeJit.cpp | 7 ++++--- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index 0f138c6092..74675a6ae4 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -182,9 +182,10 @@ void ArmJit::ClearCache() GenerateFixedCode(); } -void ArmJit::InvalidateCacheAt(u32 em_address, int length) -{ - blocks.InvalidateICache(em_address, length); +void ArmJit::InvalidateCacheAt(u32 em_address, int length) { + if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) { + blocks.InvalidateICache(em_address, length); + } } void ArmJit::EatInstruction(MIPSOpcode op) { diff --git a/Core/MIPS/ARM64/Arm64Jit.cpp b/Core/MIPS/ARM64/Arm64Jit.cpp index 8fb4c512d8..b111784c1a 100644 --- a/Core/MIPS/ARM64/Arm64Jit.cpp +++ b/Core/MIPS/ARM64/Arm64Jit.cpp @@ -180,7 +180,9 @@ void Arm64Jit::ClearCache() { } void Arm64Jit::InvalidateCacheAt(u32 em_address, int length) { - blocks.InvalidateICache(em_address, length); + if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) { + blocks.InvalidateICache(em_address, length); + } } void Arm64Jit::EatInstruction(MIPSOpcode op) { diff --git a/Core/MIPS/MIPS/MipsJit.cpp b/Core/MIPS/MIPS/MipsJit.cpp index 2a096759c4..2b263773c8 100644 --- a/Core/MIPS/MIPS/MipsJit.cpp +++ b/Core/MIPS/MIPS/MipsJit.cpp @@ -97,9 +97,10 @@ void MipsJit::ClearCache() //GenerateFixedCode(); } -void MipsJit::InvalidateCacheAt(u32 em_address, int length) -{ - blocks.InvalidateICache(em_address, length); +void MipsJit::InvalidateCacheAt(u32 em_address, int length) { + if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) { + blocks.InvalidateICache(em_address, length); + } } void MipsJit::EatInstruction(MIPSOpcode op) { diff --git a/Core/MIPS/fake/FakeJit.cpp b/Core/MIPS/fake/FakeJit.cpp index 8150e26118..d8fb86d07d 100644 --- a/Core/MIPS/fake/FakeJit.cpp +++ b/Core/MIPS/fake/FakeJit.cpp @@ -98,9 +98,10 @@ void FakeJit::ClearCache() //GenerateFixedCode(); } -void FakeJit::InvalidateCacheAt(u32 em_address, int length) -{ - blocks.InvalidateICache(em_address, length); +void FakeJit::InvalidateCacheAt(u32 em_address, int length) { + if (blocks.RangeMayHaveEmuHacks(em_address, em_address + length)) { + blocks.InvalidateICache(em_address, length); + } } void FakeJit::EatInstruction(MIPSOpcode op) { From 0226d950006c86c2b925d44fd22584cb72ca0999 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 18:44:21 -0700 Subject: [PATCH 161/374] jit: Run invalidates immediately. Previously, I thought we might clear native code when invalidating - we don't. We only do that when clearing. --- Core/MIPS/MIPS.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index 5aeeacbbf8..6700e5bfb3 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -365,15 +365,10 @@ void MIPSState::ProcessPendingClears() { void MIPSState::InvalidateICache(u32 address, int length) { // Only really applies to jit. + // Note that the backend is responsible for ensuring native code can still be returned to. std::lock_guard guard(MIPSComp::jitLock); if (MIPSComp::jit) { - if (coreState == CORE_RUNNING || insideJit) { - pendingClears.emplace_back(address, length); - hasPendingClears = true; - CoreTiming::ForceCheck(); - } else { - MIPSComp::jit->InvalidateCacheAt(address, length); - } + MIPSComp::jit->InvalidateCacheAt(address, length); } } From 8fa24045b1501e310fada3f0468f976cd66004ef Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 20:55:26 -0700 Subject: [PATCH 162/374] Io: Fail open earlier from ms0: w/ no access flags. The PSP returns this error code if you use 0 for the open flags on ms0:/. --- Core/FileSystems/DirectoryFileSystem.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index af8ea370a4..b2ae2fabb7 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -115,6 +115,11 @@ Path DirectoryFileSystem::GetLocalPath(std::string internalPath) const { bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, FileAccess access, u32 &error) { error = 0; + if (access == FILEACCESS_NONE) { + error = SCE_KERNEL_ERROR_ERRNO_INVALID_ARGUMENT; + return false; + } + #if HOST_IS_CASE_SENSITIVE if (access & (FILEACCESS_APPEND | FILEACCESS_CREATE | FILEACCESS_WRITE)) { DEBUG_LOG(FILESYS, "Checking case for path %s", fileName.c_str()); From 1b5e5e2556e41e82a4c20b8d47cbaa937041e66c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 21:23:49 -0700 Subject: [PATCH 163/374] Windows: Improve reporting of WASAPI errors. --- Windows/WASAPIStream.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Windows/WASAPIStream.cpp b/Windows/WASAPIStream.cpp index a80155cb0d..3481e42d69 100644 --- a/Windows/WASAPIStream.cpp +++ b/Windows/WASAPIStream.cpp @@ -366,13 +366,16 @@ bool WASAPIAudioThread::DetectFormat() { CoTaskMemFree(deviceFormat_); deviceFormat_ = closest; } else { - ERROR_LOG_REPORT_ONCE(badfallbackclosest, SCEAUDIO, "WASAPI fallback and closest unsupported"); + wchar_t guid[256]{}; + StringFromGUID2(closest->SubFormat, guid, 256); + ERROR_LOG_REPORT_ONCE(badfallbackclosest, SCEAUDIO, "WASAPI fallback and closest unsupported (fmt=%04x/%s)", closest->Format.wFormatTag, guid); CoTaskMemFree(closest); return false; } } else { CoTaskMemFree(closest); - ERROR_LOG_REPORT_ONCE(badfallback, SCEAUDIO, "WASAPI fallback format was unsupported"); + if (hr != AUDCLNT_E_DEVICE_INVALIDATED && hr != AUDCLNT_E_SERVICE_NOT_RUNNING) + ERROR_LOG_REPORT_ONCE(badfallback, SCEAUDIO, "WASAPI fallback format was unsupported (%08x)", hr); return false; } } @@ -390,7 +393,9 @@ bool WASAPIAudioThread::ValidateFormat(const WAVEFORMATEXTENSIBLE *fmt) { if (fmt->Format.nChannels >= 1) format_ = Format::IEEE_FLOAT; } else { - ERROR_LOG_REPORT_ONCE(unexpectedformat, SCEAUDIO, "Got unexpected WASAPI 0xFFFE stream format, expected float!"); + wchar_t guid[256]{}; + StringFromGUID2(fmt->SubFormat, guid, 256); + ERROR_LOG_REPORT_ONCE(unexpectedformat, SCEAUDIO, "Got unexpected WASAPI 0xFFFE stream format (%S), expected float!", guid); if (fmt->Format.wBitsPerSample == 16 && fmt->Format.nChannels == 2) { format_ = Format::PCM16; } From 770fdbeece3a38976685fd257eebca9e4c10012d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 15 Oct 2022 21:38:08 -0700 Subject: [PATCH 164/374] Kernel: Add reason to reported stop error. --- Core/HLE/sceKernelThread.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index f717cd5a3e..e3fcf2e442 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1644,7 +1644,7 @@ void __KernelStopThread(SceUID threadID, int exitStatus, const char *reason) t->nt.waitType = WAITTYPE_NONE; t->nt.waitID = 0; } else { - ERROR_LOG_REPORT(SCEKERNEL, "__KernelStopThread: thread %d does not exist", threadID); + ERROR_LOG_REPORT(SCEKERNEL, "__KernelStopThread: thread %d does not exist (%s)", threadID, reason ? reason : "?"); } } From 0d86eafe2fe15899b13536c42d335e2c4408b02d Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 16 Oct 2022 13:13:40 +0800 Subject: [PATCH 165/374] Add draft mp4msv module Meruru no Atelier Plus - Arland no Renkinjutsushi 3 - Official PlayView use it --- Core/HLE/sceMp4.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index 3dac7acacd..f09bc06357 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -395,6 +395,16 @@ static u32 sceAacResetPlayPosition(u32 id) return ctx->AuResetPlayPosition(); } +static u32 mp4msv_3C2183C7(u32 unknown1, u32 unknown2) { + ERROR_LOG(ME, "UNIMPL mp4msv_3C2183C7(%d, %x)", unknown1, unknown2); + return 0; +} + +static u32 mp4msv_9CA13D1A(u32 unknown1, u32 unknown2) { + ERROR_LOG(ME, "UNIMPL mp4msv_9CA13D1A(%d, %x)", unknown1, unknown2); + return 0; +} + const HLEFunction sceMp4[] = { {0X68651CBC, &WrapU_V, "sceMp4Init", 'x', "" }, @@ -455,8 +465,15 @@ const HLEFunction sceAac[] = { {0XD2DA2BBA, &WrapU_U, "sceAacResetPlayPosition", 'x', "x" }, }; +const HLEFunction mp4msv[] = { + {0x3C2183C7, &WrapU_UU, "mp4msv_3C2183C7", 'x', "xx" }, + {0x9CA13D1A, &WrapU_UU, "mp4msv_9CA13D1A", 'x', "xx" }, + +}; + void Register_sceMp4() { RegisterModule("sceMp4", ARRAY_SIZE(sceMp4), sceMp4); RegisterModule("sceAac", ARRAY_SIZE(sceAac), sceAac); -} + RegisterModule("mp4msv", ARRAY_SIZE(mp4msv), mp4msv); +} \ No newline at end of file From 620c515704ffcbf51a175b992cea7f9a44c8c97e Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 16 Oct 2022 13:51:08 +0800 Subject: [PATCH 166/374] know unknown in sceMp4Create It is callbacks --- Core/HLE/sceMp4.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index f09bc06357..03ae4214d9 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -60,9 +60,9 @@ static u32 sceMp4Finish() return 0; } -static u32 sceMp4Create(u32 mp4, u32 unknown2, u32 readBufferAddr, u32 readBufferSize) +static u32 sceMp4Create(u32 mp4, u32 callbacks, u32 readBufferAddr, u32 readBufferSize) { - ERROR_LOG_REPORT(ME, "UNIMPL sceMp4Create(mp4 %i,unknown2 %08x,readBufferAddr %08x,readBufferSize %i)", mp4, unknown2, readBufferAddr, readBufferSize); + ERROR_LOG_REPORT(ME, "UNIMPL sceMp4Create(mp4 %i,unknown2 %08x,readBufferAddr %08x,readBufferSize %i)", mp4, callbacks, readBufferAddr, readBufferSize); return 0; } From 266872bf152d0ab71baa78d082cd87d2df7f58f2 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 16 Oct 2022 14:09:52 +0800 Subject: [PATCH 167/374] OOP --- Core/HLE/sceMp4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index 03ae4214d9..f039f82c66 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -62,7 +62,7 @@ static u32 sceMp4Finish() static u32 sceMp4Create(u32 mp4, u32 callbacks, u32 readBufferAddr, u32 readBufferSize) { - ERROR_LOG_REPORT(ME, "UNIMPL sceMp4Create(mp4 %i,unknown2 %08x,readBufferAddr %08x,readBufferSize %i)", mp4, callbacks, readBufferAddr, readBufferSize); + ERROR_LOG_REPORT(ME, "UNIMPL sceMp4Create(mp4 %i,callbacks %08x,readBufferAddr %08x,readBufferSize %i)", mp4, callbacks, readBufferAddr, readBufferSize); return 0; } From 4764c54803fb376425f2afd1bca7ce8e1d400276 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 16 Oct 2022 15:23:33 +0800 Subject: [PATCH 168/374] Fix save states --- Core/HLE/HLETables.cpp | 1 + Core/HLE/sceMp4.cpp | 8 ++++++-- Core/HLE/sceMp4.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Core/HLE/HLETables.cpp b/Core/HLE/HLETables.cpp index cb775c7ebf..016a19e5c1 100644 --- a/Core/HLE/HLETables.cpp +++ b/Core/HLE/HLETables.cpp @@ -305,6 +305,7 @@ void RegisterAllModules() { Register_sceOpenPSID_driver(); Register_semaphore(); Register_sceDdrdb(); + Register_mp4msv(); // add new modules here. } diff --git a/Core/HLE/sceMp4.cpp b/Core/HLE/sceMp4.cpp index f039f82c66..38c288e950 100644 --- a/Core/HLE/sceMp4.cpp +++ b/Core/HLE/sceMp4.cpp @@ -474,6 +474,10 @@ const HLEFunction mp4msv[] = { void Register_sceMp4() { RegisterModule("sceMp4", ARRAY_SIZE(sceMp4), sceMp4); - RegisterModule("sceAac", ARRAY_SIZE(sceAac), sceAac); + RegisterModule("sceAac", ARRAY_SIZE(sceAac), sceAac); +} + +void Register_mp4msv() +{ RegisterModule("mp4msv", ARRAY_SIZE(mp4msv), mp4msv); -} \ No newline at end of file +} diff --git a/Core/HLE/sceMp4.h b/Core/HLE/sceMp4.h index b6870b90e2..9df50ed96f 100644 --- a/Core/HLE/sceMp4.h +++ b/Core/HLE/sceMp4.h @@ -25,3 +25,4 @@ enum { void Register_sceMp4(); void __AACShutdown(); void __AACDoState(PointerWrap &p); +void Register_mp4msv(); From 73e5791b08723780fa38991a53027152b4871453 Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Sun, 16 Oct 2022 14:43:56 +0300 Subject: [PATCH 169/374] Code cleanup, optional param renamed: "recreate" -> "remove" --- Core/Debugger/WebSocket/HLESubscriber.cpp | 35 ++++------------------- 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/Core/Debugger/WebSocket/HLESubscriber.cpp b/Core/Debugger/WebSocket/HLESubscriber.cpp index 09b67624d1..0efe01b222 100644 --- a/Core/Debugger/WebSocket/HLESubscriber.cpp +++ b/Core/Debugger/WebSocket/HLESubscriber.cpp @@ -477,7 +477,7 @@ void WebSocketHLEFuncRename(DebuggerRequest &req) { // Parameters: // - address: unsigned integer address for the start of the range. // - size: unsigned integer size in bytes for scan. -// - recreate: optional bool indicating whether functions that intersect or inside lie inside the range must be removed before scanning +// - remove: optional bool indicating whether functions that intersect or inside lie inside the range must be removed before scanning // // Response (same event name) with no extra data. void WebSocketHLEFuncScan(DebuggerRequest &req) { @@ -493,39 +493,14 @@ void WebSocketHLEFuncScan(DebuggerRequest &req) { if (!req.ParamU32("size", &size)) return; - bool has_recreate = req.HasParam("recreate"); - bool recreate = false; - if (has_recreate) { - if (!req.ParamBool("recreate", &recreate)) { - return; - } - } + bool remove = false; + if (!req.ParamBool("remove", &remove, DebuggerParamType::OPTIONAL)) + return; if (!Memory::IsValidRange(addr, size)) return req.Fail("Address or size outside valid memory"); - if (recreate) { - // The following code doesn't do what I wanted it to do AND it's debatable whether it's needed at all - // In short, I wanted to shift the start and the end of the range before removal - - //// let's see if the last function is partially inside our range - - //u32 last_func_start = g_symbolMap->GetFunctionStart(addr + size - 1); - //if (last_func_start != SymbolMap::INVALID_ADDRESS) { - // // there is a function - // // u32 end = last_func_start + g_symbolMap->GetFunctionSize(last_func_start); - // if (last_func_start + g_symbolMap->GetFunctionSize(last_func_start) != addr + size) { - // size = last_func_start - addr; // decrease the size parameter - // } - //} - //// let's see if the first function is partially inside our range - //u32 start = g_symbolMap->GetFunctionStart(addr); - - //if (start != SymbolMap::INVALID_ADDRESS && start != addr) { - // // skip to a byte after end - // addr = start + g_symbolMap->GetFunctionSize(start); - //} - + if (remove) { RemoveFuncSymbolsInRange(addr, size); } From a000c32820c603b255e96d33dcf1aa69eaf31354 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 08:40:01 -0700 Subject: [PATCH 170/374] Kernel: Stop reporting invalid mutex names. We know this behavior is correct, let's just make it logging. --- Core/HLE/sceKernel.cpp | 2 +- Core/HLE/sceKernelMutex.cpp | 31 ++++++++++--------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index 6f18a5768e..ec737dd1ad 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -735,7 +735,7 @@ const HLEFunction ThreadManForUser[] = {0XB011B11F, &WrapI_IIU, "sceKernelLockMutex", 'i', "iix", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED }, {0X5BF4DD27, &WrapI_IIU, "sceKernelLockMutexCB", 'i', "iix", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED }, {0X6B30100F, &WrapI_II, "sceKernelUnlockMutex", 'i', "ii" }, - {0XB7D098C6, &WrapI_CUIU, "sceKernelCreateMutex", 'i', "sxix" }, + {0XB7D098C6, &WrapI_CUIU, "sceKernelCreateMutex", 'i', "sxip" }, {0X0DDCD2C9, &WrapI_II, "sceKernelTryLockMutex", 'i', "ii" }, {0XA9C2CB9A, &WrapI_IU, "sceKernelReferMutexStatus", 'i', "ip" }, {0X87D9223C, &WrapI_IIU, "sceKernelCancelMutex", 'i', "iix" }, diff --git a/Core/HLE/sceKernelMutex.cpp b/Core/HLE/sceKernelMutex.cpp index 6921ffdf26..1885552ce1 100644 --- a/Core/HLE/sceKernelMutex.cpp +++ b/Core/HLE/sceKernelMutex.cpp @@ -305,23 +305,16 @@ void __KernelMutexEndCallback(SceUID threadID, SceUID prevCallbackId) DEBUG_LOG(SCEKERNEL, "sceKernelLockMutexCB: Resuming lock wait for callback"); } -int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr) -{ +int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optionsPtr) { if (!name) - { - WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateMutex(): invalid name", SCE_KERNEL_ERROR_ERROR); - return SCE_KERNEL_ERROR_ERROR; - } + return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ERROR, "invalid name"); if (attr & ~0xBFF) - { - WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateMutex(): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, attr); - return SCE_KERNEL_ERROR_ILLEGAL_ATTR; - } + return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "invalid attr parameter %08x", attr); if (initialCount < 0) - return SCE_KERNEL_ERROR_ILLEGAL_COUNT; + return hleLogDebug(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_COUNT, "illegal initial count"); if ((attr & PSP_MUTEX_ATTR_ALLOW_RECURSIVE) == 0 && initialCount > 1) - return SCE_KERNEL_ERROR_ILLEGAL_COUNT; + return hleLogDebug(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_COUNT, "illegal non-recursive count"); PSPMutex *mutex = new PSPMutex(); SceUID id = kernelObjects.Create(mutex); @@ -331,18 +324,14 @@ int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optio mutex->nm.name[KERNELOBJECT_MAX_NAME_LENGTH] = 0; mutex->nm.attr = attr; mutex->nm.initialCount = initialCount; - if (initialCount == 0) - { + if (initialCount == 0) { mutex->nm.lockLevel = 0; mutex->nm.lockThread = -1; - } - else + } else { __KernelMutexAcquireLock(mutex, initialCount); + } - DEBUG_LOG(SCEKERNEL, "%i=sceKernelCreateMutex(%s, %08x, %d, %08x)", id, name, attr, initialCount, optionsPtr); - - if (optionsPtr != 0) - { + if (optionsPtr != 0) { u32 size = Memory::Read_U32(optionsPtr); if (size > 4) WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateMutex(%s) unsupported options parameter, size = %d", name, size); @@ -350,7 +339,7 @@ int sceKernelCreateMutex(const char *name, u32 attr, int initialCount, u32 optio if ((attr & ~PSP_MUTEX_ATTR_KNOWN) != 0) WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateMutex(%s) unsupported attr parameter: %08x", name, attr); - return id; + return hleLogSuccessX(SCEKERNEL, id); } int sceKernelDeleteMutex(SceUID id) From 91bfa3ee4909d11a92ede9f7df702574c4890064 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 08:48:15 -0700 Subject: [PATCH 171/374] Kernel: Stop reporting invalid semaphore names. --- Core/HLE/sceKernel.cpp | 4 ++-- Core/HLE/sceKernelSemaphore.cpp | 28 ++++++++++------------------ 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/Core/HLE/sceKernel.cpp b/Core/HLE/sceKernel.cpp index ec737dd1ad..a7f5b7cb82 100644 --- a/Core/HLE/sceKernel.cpp +++ b/Core/HLE/sceKernel.cpp @@ -713,7 +713,7 @@ const HLEFunction ThreadManForUser[] = {0XA66B0120, &WrapU_IU, "sceKernelReferEventFlagStatus", 'x', "ix" }, {0X8FFDF9A2, &WrapI_IIU, "sceKernelCancelSema", 'i', "iix" }, - {0XD6DA4BA1, &WrapI_CUIIU, "sceKernelCreateSema", 'i', "sxiix" }, + {0XD6DA4BA1, &WrapI_CUIIU, "sceKernelCreateSema", 'i', "sxiip" }, {0X28B6489C, &WrapI_I, "sceKernelDeleteSema", 'i', "i" }, {0X58B1F937, &WrapI_II, "sceKernelPollSema", 'i', "ii" }, {0XBC6FEBC5, &WrapI_IU, "sceKernelReferSemaStatus", 'i', "ip" }, @@ -899,7 +899,7 @@ const HLEFunction ThreadManForKernel[] = {0X75156E8F, &WrapI_I, "sceKernelResumeThread", 'i', "i", HLE_KERNEL_SYSCALL }, {0X94416130, &WrapU_UUUU, "sceKernelGetThreadmanIdList", 'x', "xxxx", HLE_KERNEL_SYSCALL }, {0x278c0df5, &WrapI_IU, "sceKernelWaitThreadEnd", 'i', "ix", HLE_KERNEL_SYSCALL }, - {0xd6da4ba1, &WrapI_CUIIU, "sceKernelCreateSema", 'i', "sxiix", HLE_KERNEL_SYSCALL }, + {0xd6da4ba1, &WrapI_CUIIU, "sceKernelCreateSema", 'i', "sxiip", HLE_KERNEL_SYSCALL }, {0x28b6489c, &WrapI_I, "sceKernelDeleteSema", 'i', "i", HLE_KERNEL_SYSCALL }, {0x3f53e640, &WrapI_II, "sceKernelSignalSema", 'i', "ii", HLE_KERNEL_SYSCALL }, {0x4e3a1105, &WrapI_IIU, "sceKernelWaitSema", 'i', "iix", HLE_NOT_IN_INTERRUPT | HLE_NOT_DISPATCH_SUSPENDED | HLE_KERNEL_SYSCALL}, diff --git a/Core/HLE/sceKernelSemaphore.cpp b/Core/HLE/sceKernelSemaphore.cpp index fffb16c20f..b6a759cb76 100644 --- a/Core/HLE/sceKernelSemaphore.cpp +++ b/Core/HLE/sceKernelSemaphore.cpp @@ -203,18 +203,11 @@ int sceKernelCancelSema(SceUID id, int newCount, u32 numWaitThreadsPtr) } } -int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr) -{ +int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 optionPtr) { if (!name) - { - WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateSema(): invalid name", SCE_KERNEL_ERROR_ERROR); - return SCE_KERNEL_ERROR_ERROR; - } + return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ERROR, "invalid name"); if (attr >= 0x200) - { - WARN_LOG_REPORT(SCEKERNEL, "%08x=sceKernelCreateSema(): invalid attr parameter: %08x", SCE_KERNEL_ERROR_ILLEGAL_ATTR, attr); - return SCE_KERNEL_ERROR_ILLEGAL_ATTR; - } + return hleLogWarning(SCEKERNEL, SCE_KERNEL_ERROR_ILLEGAL_ATTR, "invalid attr parameter %08x", attr); PSPSemaphore *s = new PSPSemaphore(); SceUID id = kernelObjects.Create(s); @@ -228,18 +221,17 @@ int sceKernelCreateSema(const char* name, u32 attr, int initVal, int maxVal, u32 s->ns.maxCount = maxVal; s->ns.numWaitThreads = 0; - DEBUG_LOG(SCEKERNEL, "%i=sceKernelCreateSema(%s, %08x, %i, %i, %08x)", id, s->ns.name, s->ns.attr, s->ns.initCount, s->ns.maxCount, optionPtr); - - if (optionPtr != 0) - { - u32 size = Memory::Read_U32(optionPtr); - if (size > 4) - WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateSema(%s) unsupported options parameter, size = %d", name, size); + // Many games pass garbage into optionPtr, it doesn't have any options. + if (optionPtr != 0) { + if (!Memory::IsValidRange(optionPtr, 4)) + hleLogWarning(SCEKERNEL, id, "invalid options parameter"); + else if (Memory::Read_U32(optionPtr) > 4) + hleLogDebug(SCEKERNEL, id, "invalid options parameter size"); } if ((attr & ~PSP_SEMA_ATTR_PRIORITY) != 0) WARN_LOG_REPORT(SCEKERNEL, "sceKernelCreateSema(%s) unsupported attr parameter: %08x", name, attr); - return id; + return hleLogSuccessX(SCEKERNEL, id); } int sceKernelDeleteSema(SceUID id) From 29e7a53b5d5e66e594fc275372bd5674164909b8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 08:14:48 -0700 Subject: [PATCH 172/374] Savedata: Update filelist on file erasure. Also stop reporting as "not coded." --- Core/Dialog/PSPSaveDialog.cpp | 4 ++++ Core/Dialog/SavedataParam.cpp | 43 +++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 91994d3f36..ea600d5669 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -70,6 +70,8 @@ static bool IsNotVisibleAction(SceUtilitySavedataType type) { case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA: case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE: case SCE_UTILITY_SAVEDATA_TYPE_READDATA: + case SCE_UTILITY_SAVEDATA_TYPE_ERASESECURE: + case SCE_UTILITY_SAVEDATA_TYPE_ERASE: case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA: case SCE_UTILITY_SAVEDATA_TYPE_AUTODELETE: return true; @@ -222,6 +224,8 @@ int PSPSaveDialog::Init(int paramAddr) case SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA: case SCE_UTILITY_SAVEDATA_TYPE_READDATASECURE: case SCE_UTILITY_SAVEDATA_TYPE_READDATA: + case SCE_UTILITY_SAVEDATA_TYPE_ERASESECURE: + case SCE_UTILITY_SAVEDATA_TYPE_ERASE: case SCE_UTILITY_SAVEDATA_TYPE_DELETEDATA: display = DS_NONE; break; diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index 53d6d819a3..3c6c545baa 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -15,6 +15,8 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include +#include #include "Common/Log.h" #include "Common/Data/Text/I18n.h" #include "Common/Data/Format/ZIMLoad.h" @@ -36,14 +38,15 @@ #include "Core/HW/MemoryStick.h" #include "Core/Util/PPGeDraw.h" -#include - static const std::string ICON0_FILENAME = "ICON0.PNG"; static const std::string ICON1_FILENAME = "ICON1.PMF"; static const std::string PIC1_FILENAME = "PIC1.PNG"; static const std::string SND0_FILENAME = "SND0.AT3"; static const std::string SFO_FILENAME = "PARAM.SFO"; +static const int FILE_LIST_COUNT_MAX = 99; +static const u32 FILE_LIST_TOTAL_SIZE = sizeof(SaveSFOFileListEntry) * FILE_LIST_COUNT_MAX; + static const std::string savePath = "ms0:/PSP/SAVEDATA/"; namespace @@ -382,6 +385,39 @@ int SavedataParam::DeleteData(SceUtilitySavedataParam* param) { ClearCaches(); pspFileSystem.RemoveFile(filePath); + // Update PARAM.SFO to remove the file, if it was in the list. + std::shared_ptr sfoFile = LoadCachedSFO(sfoPath); + if (sfoFile) { + // Note: do not update values such as TITLE in this operation. + u32 fileListSize = 0; + SaveSFOFileListEntry *fileList = (SaveSFOFileListEntry *)sfoFile->GetValueData("SAVEDATA_FILE_LIST", &fileListSize); + size_t fileListCount = fileListSize / sizeof(SaveSFOFileListEntry); + bool changed = false; + for (size_t i = 0; i < fileListCount; ++i) { + if (strncmp(fileList[i].filename, fileName.c_str(), sizeof(fileList[i].filename)) != 0) + continue; + + memset(fileList[i].filename, 0, sizeof(fileList[i].filename)); + memset(fileList[i].hash, 0, sizeof(fileList[i].hash)); + changed = true; + break; + } + + if (changed) { + std::unique_ptr updatedList(new u8[fileListSize]); + memcpy(updatedList.get(), fileList, fileListSize); + sfoFile->SetValue("SAVEDATA_FILE_LIST", updatedList.get(), fileListSize, (int)FILE_LIST_TOTAL_SIZE); + + u8 *sfoData; + size_t sfoSize; + sfoFile->WriteSFO(&sfoData, &sfoSize); + + ClearCaches(); + WritePSPFile(sfoPath, sfoData, (SceSize)sfoSize); + delete[] sfoData; + } + } + return 0; } @@ -470,8 +506,6 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD // Always write and update the file list. // For each file, 13 bytes for filename, 16 bytes for file hash (0 in PPSSPP), 3 byte for padding - const int FILE_LIST_COUNT_MAX = 99; - const u32 FILE_LIST_TOTAL_SIZE = sizeof(SaveSFOFileListEntry) * FILE_LIST_COUNT_MAX; u32 tmpDataSize = 0; SaveSFOFileListEntry *tmpDataOrig = (SaveSFOFileListEntry *)sfoFile->GetValueData("SAVEDATA_FILE_LIST", &tmpDataSize); SaveSFOFileListEntry *updatedList = new SaveSFOFileListEntry[FILE_LIST_COUNT_MAX]; @@ -825,7 +859,6 @@ std::vector SavedataParam::GetSFOEntries(const std::string return result; } - const int FILE_LIST_COUNT_MAX = 99; u32 sfoFileListSize = 0; SaveSFOFileListEntry *sfoFileList = (SaveSFOFileListEntry *)sfoFile->GetValueData("SAVEDATA_FILE_LIST", &sfoFileListSize); const u32 count = std::min((u32)FILE_LIST_COUNT_MAX, sfoFileListSize / (u32)sizeof(SaveSFOFileListEntry)); From e90a7de3e4b09e0a74560a988949f16eeeb34ea8 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sun, 16 Oct 2022 20:28:45 +0200 Subject: [PATCH 173/374] OpenXR - Add VR mode for stereo flat screen rendering --- Common/VR/PPSSPPVR.cpp | 5 ++-- Common/VR/VRBase.h | 2 +- Common/VR/VRRenderer.cpp | 53 ++++++++++++++++++++++++++-------------- Common/VR/VRRenderer.h | 7 +++--- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 31c6a20fce..7bbda32cde 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -307,7 +307,7 @@ bool StartVRRender() { bool stereo = VR_GetConfig(VR_CONFIG_6DOF_PRECISE) && g_Config.bEnableStereo; VR_SetConfig(VR_CONFIG_MODE, stereo ? VR_MODE_STEREO_6DOF : VR_MODE_MONO_6DOF); } else { - VR_SetConfig(VR_CONFIG_MODE, VR_MODE_FLAT_SCREEN); + VR_SetConfig(VR_CONFIG_MODE, g_Config.bEnableStereo ? VR_MODE_STEREO_SCREEN : VR_MODE_MONO_SCREEN); } VR_SetConfig(VR_CONFIG_3D_GEOMETRY_COUNT, VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) / 2); @@ -345,7 +345,8 @@ bool IsMultiviewSupported() { } bool IsFlatVRScene() { - return VR_GetConfig(VR_CONFIG_MODE) == VR_MODE_FLAT_SCREEN; + int vrMode = VR_GetConfig(VR_CONFIG_MODE); + return (vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN); } bool Is2DVRObject(float* projMatrix, bool ortho) { diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 08ae4708f2..5f9016d7cd 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -86,7 +86,7 @@ static void OXR_CheckErrors(XrInstance instance, XrResult result, const char* fu #define OPENXR_HAS_PERFORMANCE_EXTENSION #endif -enum { ovrMaxLayerCount = 1 }; +enum { ovrMaxLayerCount = 2 }; enum { ovrMaxNumEyes = 2 }; typedef union { diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 77e80ca9aa..64c388df07 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -366,7 +366,9 @@ void VR_EndFrame( engine_t* engine ) { // Show mouse cursor int size = vrConfig[VR_CONFIG_MOUSE_SIZE]; - if ((vrConfig[VR_CONFIG_MODE] == VR_MODE_FLAT_SCREEN) && (size > 0)) { + int vrMode = vrConfig[VR_CONFIG_MODE]; + bool screenMode = (vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN); + if (screenMode && (size > 0)) { int x = vrConfig[VR_CONFIG_MOUSE_X]; int y = vrConfig[VR_CONFIG_MOUSE_Y]; ovrRenderer_MouseCursor(&engine->appState.Renderer, x, y, size); @@ -416,23 +418,9 @@ void VR_FinishFrame( engine_t* engine ) { projection_layer.views = projection_layer_elements; engine->appState.Layers[engine->appState.LayerCount++].Projection = projection_layer; - } else if (vrMode == VR_MODE_FLAT_SCREEN) { + } else if ((vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN)) { - // Build the cylinder layer - int width = engine->appState.Renderer.FrameBuffer[0].ColorSwapChain.Width; - int height = engine->appState.Renderer.FrameBuffer[0].ColorSwapChain.Height; - XrCompositionLayerCylinderKHR cylinder_layer = {}; - cylinder_layer.type = XR_TYPE_COMPOSITION_LAYER_CYLINDER_KHR; - cylinder_layer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; - cylinder_layer.space = engine->appState.CurrentSpace; - cylinder_layer.eyeVisibility = XR_EYE_VISIBILITY_BOTH; - memset(&cylinder_layer.subImage, 0, sizeof(XrSwapchainSubImage)); - cylinder_layer.subImage.swapchain = engine->appState.Renderer.FrameBuffer[0].ColorSwapChain.Handle; - cylinder_layer.subImage.imageRect.offset.x = 0; - cylinder_layer.subImage.imageRect.offset.y = 0; - cylinder_layer.subImage.imageRect.extent.width = width; - cylinder_layer.subImage.imageRect.extent.height = height; - cylinder_layer.subImage.imageArrayIndex = 0; + // Flat screen pose float distance = (float)vrConfig[VR_CONFIG_CANVAS_DISTANCE]; float menuPitch = ToRadians((float)vrConfig[VR_CONFIG_MENU_PITCH]); float menuYaw = ToRadians((float)vrConfig[VR_CONFIG_MENU_YAW]); @@ -443,13 +431,42 @@ void VR_FinishFrame( engine_t* engine ) { }; XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, -menuPitch); XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, menuYaw); + + // Setup the cylinder layer + XrCompositionLayerCylinderKHR cylinder_layer = {}; + cylinder_layer.type = XR_TYPE_COMPOSITION_LAYER_CYLINDER_KHR; + cylinder_layer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT; + cylinder_layer.space = engine->appState.CurrentSpace; + memset(&cylinder_layer.subImage, 0, sizeof(XrSwapchainSubImage)); + cylinder_layer.subImage.imageRect.offset.x = 0; + cylinder_layer.subImage.imageRect.offset.y = 0; + cylinder_layer.subImage.imageRect.extent.width = engine->appState.Renderer.FrameBuffer[0].ColorSwapChain.Width; + cylinder_layer.subImage.imageRect.extent.height = engine->appState.Renderer.FrameBuffer[0].ColorSwapChain.Height; + cylinder_layer.subImage.swapchain = engine->appState.Renderer.FrameBuffer[0].ColorSwapChain.Handle; + cylinder_layer.subImage.imageArrayIndex = 0; cylinder_layer.pose.orientation = XrQuaternionf_Multiply(pitch, yaw); cylinder_layer.pose.position = pos; cylinder_layer.radius = 12.0f; cylinder_layer.centralAngle = M_PI * 0.5f; cylinder_layer.aspectRatio = 1; - engine->appState.Layers[engine->appState.LayerCount++].Cylinder = cylinder_layer; + // Build the cylinder layer + if (vrMode == VR_MODE_MONO_SCREEN) { + cylinder_layer.eyeVisibility = XR_EYE_VISIBILITY_BOTH; + engine->appState.Layers[engine->appState.LayerCount++].Cylinder = cylinder_layer; + } else if (engine->appState.Renderer.Multiview) { + cylinder_layer.eyeVisibility = XR_EYE_VISIBILITY_LEFT; + engine->appState.Layers[engine->appState.LayerCount++].Cylinder = cylinder_layer; + cylinder_layer.eyeVisibility = XR_EYE_VISIBILITY_RIGHT; + cylinder_layer.subImage.imageArrayIndex = 1; + engine->appState.Layers[engine->appState.LayerCount++].Cylinder = cylinder_layer; + } else { + cylinder_layer.eyeVisibility = XR_EYE_VISIBILITY_LEFT; + engine->appState.Layers[engine->appState.LayerCount++].Cylinder = cylinder_layer; + cylinder_layer.eyeVisibility = XR_EYE_VISIBILITY_RIGHT; + cylinder_layer.subImage.swapchain = engine->appState.Renderer.FrameBuffer[1].ColorSwapChain.Handle; + engine->appState.Layers[engine->appState.LayerCount++].Cylinder = cylinder_layer; + } } else { assert(false); } diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index fe7a4671f1..7a86adf6b2 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -34,9 +34,10 @@ enum VRMatrix { }; enum VRMode { - VR_MODE_FLAT_SCREEN = 0, - VR_MODE_MONO_6DOF = 1, - VR_MODE_STEREO_6DOF = 2 + VR_MODE_MONO_SCREEN, + VR_MODE_STEREO_SCREEN, + VR_MODE_MONO_6DOF, + VR_MODE_STEREO_6DOF }; void VR_GetResolution( engine_t* engine, int *pWidth, int *pHeight ); From 1931fa2f5fea2dc1158f6a9f8d948a73599c79ac Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 16:01:09 -0700 Subject: [PATCH 174/374] softgpu: Make triangle fan rect detection generic. --- GPU/Software/RasterizerRectangle.cpp | 63 ++++++++++++++++------------ GPU/Software/RasterizerRectangle.h | 2 +- GPU/Software/TransformUnit.cpp | 2 +- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/GPU/Software/RasterizerRectangle.cpp b/GPU/Software/RasterizerRectangle.cpp index 5cc40566d6..8d39a2426a 100644 --- a/GPU/Software/RasterizerRectangle.cpp +++ b/GPU/Software/RasterizerRectangle.cpp @@ -483,40 +483,51 @@ bool DetectRectangleFromStrip(const RasterizerState &state, const ClipVertexData return false; } -bool DetectRectangleFromFan(const RasterizerState &state, const ClipVertexData *data, int c, int *tlIndex, int *brIndex) { +bool DetectRectangleFromFan(const RasterizerState &state, const ClipVertexData *data, int *tlIndex, int *brIndex) { // Color and Z must be flat. - for (int i = 1; i < c; ++i) { + int tl = 0, br = 0; + for (int i = 1; i < 4; ++i) { if (!AreCoordsRectangleCompatible(state, data[i], data[0])) return false; + + if (data[i].v.screenpos.x <= data[tl].v.screenpos.x && data[i].v.screenpos.y <= data[tl].v.screenpos.y) + tl = i; + if (data[i].v.screenpos.x >= data[br].v.screenpos.x && data[i].v.screenpos.y >= data[br].v.screenpos.y) + br = i; } - // Check for the common case: a single TL-TR-BR-BL. - if (c == 4) { - const auto &pos0 = data[0].v.screenpos, &pos1 = data[1].v.screenpos; - const auto &pos2 = data[2].v.screenpos, &pos3 = data[3].v.screenpos; - if (pos0.x == pos3.x && pos1.x == pos2.x && pos0.y == pos1.y && pos3.y == pos2.y) { - // Looking like yes. Set TL/BR based on y order first... - *tlIndex = pos0.y > pos3.y ? 2 : 0; - *brIndex = pos0.y > pos3.y ? 0 : 2; - // And if it's horizontally flipped, trade to the actual TL/BR. - if (pos0.x > pos1.x) { - *tlIndex ^= 1; - *brIndex ^= 1; - } + *tlIndex = tl; + *brIndex = br; - // Do we need to think about rotation? - if (!state.enableTextures) - return true; + int tr = 1, bl = 1; + for (int i = 0; i < 4; ++i) { + if (i == tl || i == br) + continue; - const auto &textl = data[*tlIndex].v.texturecoords, &textr = data[*tlIndex ^ 1].v.texturecoords; - const auto &texbl = data[*brIndex ^ 1].v.texturecoords, &texbr = data[*brIndex].v.texturecoords; + if (data[i].v.screenpos.x <= data[tl].v.screenpos.x && data[i].v.screenpos.y >= data[tl].v.screenpos.y) + bl = i; + if (data[i].v.screenpos.x >= data[br].v.screenpos.x && data[i].v.screenpos.y <= data[br].v.screenpos.y) + tr = i; + } - if (textl.x == texbl.x && textr.x == texbr.x && textl.y == textr.y && texbl.y == texbr.y) { - // Okay, the texture is also good, but let's avoid rotation issues. - const auto &postl = data[*tlIndex].v.screenpos; - const auto &posbr = data[*brIndex].v.screenpos; - return textl.y < texbr.y && postl.y < posbr.y && textl.x < texbr.x && postl.x < posbr.x; - } + // Must have found each of the coordinates. + if (tl + tr + bl + br != 6) + return false; + + // Note the common case is a single TL-TR-BR-BL. + const auto &postl = data[tl].v.screenpos, &postr = data[tr].v.screenpos; + const auto &posbr = data[br].v.screenpos, &posbl = data[bl].v.screenpos; + if (postl.x == posbl.x && postr.x == posbr.x && postl.y == postr.y && posbl.y == posbr.y) { + // Do we need to think about rotation? + if (!state.enableTextures) + return true; + + const auto &textl = data[tl].v.texturecoords, &textr = data[tr].v.texturecoords; + const auto &texbl = data[bl].v.texturecoords, &texbr = data[br].v.texturecoords; + + if (textl.x == texbl.x && textr.x == texbr.x && textl.y == textr.y && texbl.y == texbr.y) { + // Okay, the texture is also good, but let's avoid rotation issues. + return textl.y < texbr.y && postl.y < posbr.y && textl.x < texbr.x && postl.x < posbr.x; } } diff --git a/GPU/Software/RasterizerRectangle.h b/GPU/Software/RasterizerRectangle.h index 19e4b42b48..49f2e61c93 100644 --- a/GPU/Software/RasterizerRectangle.h +++ b/GPU/Software/RasterizerRectangle.h @@ -21,7 +21,7 @@ namespace Rasterizer { void DrawSprite(const VertexData &v0, const VertexData &v1, const BinCoords &range, const RasterizerState &state); bool DetectRectangleFromStrip(const RasterizerState &state, const ClipVertexData data[4], int *tlIndex, int *brIndex); - bool DetectRectangleFromFan(const RasterizerState &state, const ClipVertexData *data, int c, int *tlIndex, int *brIndex); + bool DetectRectangleFromFan(const RasterizerState &state, const ClipVertexData *data, int *tlIndex, int *brIndex); bool DetectRectangleFromPair(const RasterizerState &state, const ClipVertexData data[6], int *tlIndex, int *brIndex); bool DetectRectangleThroughModeSlices(const RasterizerState &state, const ClipVertexData data[4]); } diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 7d1d28d07d..fbbdcd3919 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -793,7 +793,7 @@ void TransformUnit::SubmitPrimitive(const void* vertices, const void* indices, G } int tl = -1, br = -1; - if (Rasterizer::DetectRectangleFromFan(binner_->State(), data_, vertex_count, &tl, &br)) { + if (Rasterizer::DetectRectangleFromFan(binner_->State(), data_, &tl, &br)) { Clipper::ProcessRect(data_[tl], data_[br], *binner_); break; } From 9d6de98ed95615dd0bd0f7ca16683f01e95026b3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 18:46:38 -0700 Subject: [PATCH 175/374] softgpu: Correct drawing outside TL of rectangle. If the start coordinate was something like 51.75, we were incorrectly drawing to 51. This can be seen in the Metal Slug intro (#15755.) --- GPU/Software/Rasterizer.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index d59c1fb0cf..2a24ee348a 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -796,11 +796,18 @@ void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords & int entireY1 = std::min(v0.screenpos.y, v1.screenpos.y); int entireX2 = std::max(v0.screenpos.x, v1.screenpos.x) - 1; int entireY2 = std::max(v0.screenpos.y, v1.screenpos.y) - 1; - int minX = std::max(entireX1, range.x1) | (SCREEN_SCALE_FACTOR / 2 - 1); - int minY = std::max(entireY1, range.y1) | (SCREEN_SCALE_FACTOR / 2 - 1); + int minX = std::max(entireX1 & ~(SCREEN_SCALE_FACTOR - 1), range.x1) | (SCREEN_SCALE_FACTOR / 2 - 1); + int minY = std::max(entireY1 & ~(SCREEN_SCALE_FACTOR - 1), range.y1) | (SCREEN_SCALE_FACTOR / 2 - 1); int maxX = std::min(entireX2, range.x2); int maxY = std::min(entireY2, range.y2); + // If TL x or y was after the half, we don't draw the pixel. + // TODO: Verify what center is used, allowing slight offset makes gpu/primitives/trianglefan pass. + if (minX < entireX1 - 1) + minX += SCREEN_SCALE_FACTOR; + if (minY < entireY1 - 1) + minY += SCREEN_SCALE_FACTOR; + RasterizerState state = OptimizeFlatRasterizerState(rastState, v1); Vec2f rowST(0.0f, 0.0f); @@ -1043,10 +1050,17 @@ void ClearRectangle(const VertexData &v0, const VertexData &v1, const BinCoords int entireY1 = std::min(v0.screenpos.y, v1.screenpos.y); int entireX2 = std::max(v0.screenpos.x, v1.screenpos.x) - 1; int entireY2 = std::max(v0.screenpos.y, v1.screenpos.y) - 1; - int minX = std::max(entireX1, range.x1) | (SCREEN_SCALE_FACTOR / 2 - 1); - int minY = std::max(entireY1, range.y1) | (SCREEN_SCALE_FACTOR / 2 - 1); + int minX = std::max(entireX1 & ~(SCREEN_SCALE_FACTOR - 1), range.x1) | (SCREEN_SCALE_FACTOR / 2 - 1); + int minY = std::max(entireY1 & ~(SCREEN_SCALE_FACTOR - 1), range.y1) | (SCREEN_SCALE_FACTOR / 2 - 1); int maxX = std::min(entireX2, range.x2); int maxY = std::min(entireY2, range.y2); + + // If TL x or y was after the half, we don't draw the pixel. + if (minX < entireX1 - 1) + minX += SCREEN_SCALE_FACTOR; + if (minY < entireY1 - 1) + minY += SCREEN_SCALE_FACTOR; + const DrawingCoords pprime = TransformUnit::ScreenToDrawing(minX, minY); const DrawingCoords pend = TransformUnit::ScreenToDrawing(maxX, maxY); auto &pixelID = state.pixelID; From 7eb7bd51417beff7c0d2abc3acca8ee6c4785e4a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 18:49:37 -0700 Subject: [PATCH 176/374] softgpu: Correct linear interp for uneven positions. Can't round to the pixel when calculating the S/T deltas. This fixes issues in Wipeout (#16131) and Call of Duty bloom. --- GPU/Software/Rasterizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index 2a24ee348a..d75f7f9476 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -826,8 +826,8 @@ void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords & tc1.t() *= 1.0f / (float)(1 << state.samplerID.height0Shift); } - int diffX = (entireX2 - entireX1 + 1) / SCREEN_SCALE_FACTOR; - int diffY = (entireY2 - entireY1 + 1) / SCREEN_SCALE_FACTOR; + float diffX = (entireX2 - entireX1 + 1) / (float)SCREEN_SCALE_FACTOR; + float diffY = (entireY2 - entireY1 + 1) / (float)SCREEN_SCALE_FACTOR; float diffS = tc1.s() - tc0.s(); float diffT = tc1.t() - tc0.t(); @@ -860,8 +860,8 @@ void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords & } // Okay, now move ST to the minX, minY position. - rowST += (stx / (float)(SCREEN_SCALE_FACTOR * 2)) * (minX - entireX1); - rowST += (sty / (float)(SCREEN_SCALE_FACTOR * 2)) * (minY - entireY1); + rowST += (stx / (float)(SCREEN_SCALE_FACTOR * 2)) * (minX - entireX1 + 1); + rowST += (sty / (float)(SCREEN_SCALE_FACTOR * 2)) * (minY - entireY1 + 1); } // And now what we add to spread out to 4 values. From 162b27e13677242eb720adc96b790512db87c26a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Oct 2022 22:24:43 -0700 Subject: [PATCH 177/374] GPU: Replace logic ops with blend for simple cases. So that alpha/stencil are handled correctly. --- GPU/Common/GPUStateUtils.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 2b8bb84dc1..1b3e348738 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -858,9 +858,12 @@ static inline bool blendColorSimilar(uint32_t a, uint32_t b, int margin = 25) { // The shader might also need modification, the below function SimulateLogicOpShaderTypeIfNeeded // takes care of that. static bool SimulateLogicOpIfNeeded(BlendFactor &srcBlend, BlendFactor &dstBlend, BlendEq &blendEq) { + if (!gstate.isLogicOpEnabled()) + return false; + // Note: our shader solution applies logic ops BEFORE blending, not correctly after. // This is however fine for the most common ones, like CLEAR/NOOP/SET, etc. - if (!gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP) && gstate.isLogicOpEnabled()) { + if (!gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) { switch (gstate.getLogicOp()) { case GE_LOGIC_CLEAR: srcBlend = BlendFactor::ZERO; @@ -916,6 +919,25 @@ static bool SimulateLogicOpIfNeeded(BlendFactor &srcBlend, BlendFactor &dstBlend WARN_LOG_REPORT_ONCE(d3dLogicOpSet, G3D, "Attempted set for logic op: %x", gstate.getLogicOp()); return true; } + } else { + // Even if we support hardware logic ops, alpha is handled wrong. + // It's better to override blending for the simple cases. + switch (gstate.getLogicOp()) { + case GE_LOGIC_CLEAR: + srcBlend = BlendFactor::ZERO; + dstBlend = BlendFactor::ZERO; + blendEq = BlendEq::ADD; + return true; + case GE_LOGIC_NOOP: + srcBlend = BlendFactor::ZERO; + dstBlend = BlendFactor::ONE; + blendEq = BlendEq::ADD; + return true; + + default: + // Let's hope hardware gets it right. + return false; + } } return false; } @@ -1598,5 +1620,7 @@ void GenericLogicState::ApplyToBlendState(GenericBlendState &blendState) { blendState.dstAlpha = BlendFactor::ZERO; blendState.eqAlpha = BlendEq::ADD; } + logicOpEnabled = false; + logicOp = GE_LOGIC_COPY; } } From daca0b2109aa0bfb7a0574766ed3a9f5fe1e4a2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 08:27:49 +0200 Subject: [PATCH 178/374] Rename gstate_c.Supports to gstate_c.Use --- GPU/Common/DrawEngineCommon.cpp | 2 +- GPU/Common/FragmentShaderGenerator.cpp | 16 ++++++------- GPU/Common/FramebufferManagerCommon.cpp | 2 +- GPU/Common/GPUStateUtils.cpp | 30 ++++++++++++------------- GPU/Common/GeometryShaderGenerator.cpp | 12 +++++----- GPU/Common/ShaderId.cpp | 8 +++---- GPU/Common/SoftwareTransformCommon.cpp | 2 +- GPU/Common/TextureCacheCommon.cpp | 12 +++++----- GPU/Common/VertexShaderGenerator.cpp | 18 +++++++-------- GPU/D3D11/DrawEngineD3D11.cpp | 2 +- GPU/D3D11/GPU_D3D11.cpp | 4 ++-- GPU/D3D11/StateMappingD3D11.cpp | 4 ++-- GPU/D3D11/TextureCacheD3D11.cpp | 2 +- GPU/Directx9/DrawEngineDX9.cpp | 2 +- GPU/Directx9/GPU_DX9.cpp | 4 ++-- GPU/Directx9/TextureCacheDX9.cpp | 2 +- GPU/GLES/DepthBufferGLES.cpp | 2 +- GPU/GLES/DrawEngineGLES.cpp | 4 ++-- GPU/GLES/GPU_GLES.cpp | 4 ++-- GPU/GLES/ShaderManagerGLES.cpp | 18 +++++++-------- GPU/GLES/StateMappingGLES.cpp | 6 ++--- GPU/GLES/TextureCacheGLES.cpp | 4 ++-- GPU/GPUCommon.cpp | 4 ++-- GPU/GPUState.h | 7 +++--- GPU/Vulkan/DrawEngineVulkan.cpp | 4 ++-- GPU/Vulkan/GPU_Vulkan.cpp | 6 ++--- GPU/Vulkan/ShaderManagerVulkan.cpp | 6 ++--- GPU/Vulkan/StateMappingVulkan.cpp | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 4 ++-- 29 files changed, 97 insertions(+), 96 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index f884486c65..249bcf48ef 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -537,7 +537,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, } void DrawEngineCommon::ApplyFramebufferRead(FBOTexState *fboTexState) { - if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) { + if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) { *fboTexState = FBO_TEX_READ_FRAMEBUFFER; } else { gpuStats.numCopiesForShaderBlend++; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index efd7c5a229..783afaa5b7 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -45,7 +45,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool highpFog = false; bool highpTexcoord = false; - bool enableFragmentTestCache = gstate_c.Supports(GPU_USE_FRAGMENT_TEST_CACHE); + bool enableFragmentTestCache = gstate_c.Use(GPU_USE_FRAGMENT_TEST_CACHE); if (compat.gles) { // PowerVR needs highp to do the fog in MHU correctly. @@ -137,11 +137,11 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool needFramebufferRead = replaceBlend == REPLACE_BLEND_READ_FRAMEBUFFER || colorWriteMask || replaceLogicOp; - bool fetchFramebuffer = needFramebufferRead && gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH); - bool readFramebufferTex = needFramebufferRead && !gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH); + bool fetchFramebuffer = needFramebufferRead && gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH); + bool readFramebufferTex = needFramebufferRead && !gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH); - bool needFragCoord = readFramebufferTex || gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); - bool writeDepth = gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); + bool needFragCoord = readFramebufferTex || gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); + bool writeDepth = gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); if (shaderDepalMode != ShaderDepalMode::OFF && !doTexture) { *errorString = "depal requires a texture"; @@ -149,7 +149,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) { - if (useDiscardStencilBugWorkaround && !gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { + if (useDiscardStencilBugWorkaround && !gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { WRITE(p, "layout (depth_unchanged) out float gl_FragDepth;\n"); } @@ -1173,11 +1173,11 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " %s = vec4(0.0, 0.0, 0.0, %s.z); // blue to alpha\n", compat.fragColor0, compat.fragColor0); } - if (gstate_c.Supports(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { + if (gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { const double scale = DepthSliceFactor() * 65535.0; WRITE(p, " highp float z = gl_FragCoord.z;\n"); - if (gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { // We center the depth with an offset, but only its fraction matters. // When (DepthSliceFactor() - 1) is odd, it will be 0.5, otherwise 0. if (((int)(DepthSliceFactor() - 1.0f) & 1) == 1) { diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 7195c9fc6e..295910c4fc 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -2532,7 +2532,7 @@ bool FramebufferManagerCommon::GetDepthbuffer(u32 fb_address, int fb_stride, u32 } bool flipY = (GetGPUBackend() == GPUBackend::OPENGL && !useBufferedRendering_) ? true : false; - if (gstate_c.Supports(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { + if (gstate_c.Use(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { buffer.Allocate(w, h, GPU_DBG_FORMAT_FLOAT_DIV_256, flipY); } else { buffer.Allocate(w, h, GPU_DBG_FORMAT_FLOAT, flipY); diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 1b3e348738..0adf0ea5d0 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -183,7 +183,7 @@ ReplaceAlphaType ReplaceAlphaWithStencil(ReplaceBlendType replaceBlend) { if (nonAlphaSrcFactors[gstate.getBlendFuncA()] && nonAlphaDestFactors[gstate.getBlendFuncB()]) { return REPLACE_ALPHA_YES; } else { - if (gstate_c.Supports(GPU_SUPPORTS_DUALSOURCE_BLEND)) { + if (gstate_c.Use(GPU_SUPPORTS_DUALSOURCE_BLEND)) { return REPLACE_ALPHA_DUALSOURCE; } else { return REPLACE_ALPHA_NO; @@ -275,7 +275,7 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_BLENDMODE_MIN: case GE_BLENDMODE_MAX: - if (gstate_c.Supports(GPU_SUPPORTS_BLEND_MINMAX)) { + if (gstate_c.Use(GPU_SUPPORTS_BLEND_MINMAX)) { return REPLACE_BLEND_STANDARD; } else { return REPLACE_BLEND_READ_FRAMEBUFFER; @@ -312,7 +312,7 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_DSTBLEND_DOUBLESRCALPHA: // We can't technically do this correctly (due to clamping) without reading the dst color. // Using a copy isn't accurate either, though, when there's overlap. - if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_PRE_SRC_2X_ALPHA; @@ -454,14 +454,14 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_DSTBLEND_DOUBLESRCALPHA: if (funcA == GE_SRCBLEND_SRCALPHA || funcA == GE_SRCBLEND_INVSRCALPHA) { // Can't safely double alpha, will clamp. However, a copy may easily be worse due to overlap. - if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_PRE_SRC_2X_ALPHA; } else { // This means dst alpha/color is used in the src factor. // Unfortunately, copying here causes overlap problems in Silent Hill games (it seems?) // We will just hope that doubling alpha for the dst factor will not clamp too badly. - if (gstate_c.Supports(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_2X_ALPHA; } @@ -494,10 +494,10 @@ static const float DEPTH_SLICE_FACTOR_HIGH = 4.0f; static const float DEPTH_SLICE_FACTOR_16BIT = 256.0f; float DepthSliceFactor() { - if (gstate_c.Supports(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { + if (gstate_c.Use(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { return DEPTH_SLICE_FACTOR_16BIT; } - if (gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP)) { + if (gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP)) { return 1.0f; } return DEPTH_SLICE_FACTOR_HIGH; @@ -505,12 +505,12 @@ float DepthSliceFactor() { // This is used for float values which might not be integers, but are in the integer scale of 65535. float ToScaledDepthFromIntegerScale(float z) { - if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { return z * (1.0f / 65535.0f); } const float depthSliceFactor = DepthSliceFactor(); - if (gstate_c.Supports(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { + if (gstate_c.Use(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { const double doffset = 0.5 * (depthSliceFactor - 1.0) * (1.0 / depthSliceFactor); // Use one bit for each value, rather than 1.0 / (25535.0 * 256.0). return (float)((double)z * (1.0 / 16777215.0) + doffset); @@ -523,7 +523,7 @@ float ToScaledDepthFromIntegerScale(float z) { // See struct DepthScaleFactors for how to apply. DepthScaleFactors GetDepthScaleFactors() { DepthScaleFactors factors; - if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { factors.offset = 0; factors.scale = 65535.0f; return factors; @@ -728,7 +728,7 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo // This adjusts the center from halfActualZRange to vpZCenter. out.zOffset = halfActualZRange < std::numeric_limits::epsilon() ? 0.0f : (vpZCenter - (minz + halfActualZRange)) / halfActualZRange; - if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { out.depthScale = 1.0f; out.zOffset = 0.0f; out.depthRangeMin = ToScaledDepthFromIntegerScale(vpZCenter - vpZScale); @@ -863,7 +863,7 @@ static bool SimulateLogicOpIfNeeded(BlendFactor &srcBlend, BlendFactor &dstBlend // Note: our shader solution applies logic ops BEFORE blending, not correctly after. // This is however fine for the most common ones, like CLEAR/NOOP/SET, etc. - if (!gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) { + if (!gstate_c.Use(GPU_SUPPORTS_LOGIC_OP)) { switch (gstate.getLogicOp()) { case GE_LOGIC_CLEAR: srcBlend = BlendFactor::ZERO; @@ -944,7 +944,7 @@ static bool SimulateLogicOpIfNeeded(BlendFactor &srcBlend, BlendFactor &dstBlend // Choose the shader part of the above logic op fallback simulation. SimulateLogicOpType SimulateLogicOpShaderTypeIfNeeded() { - if (!gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP) && gstate.isLogicOpEnabled()) { + if (!gstate_c.Use(GPU_SUPPORTS_LOGIC_OP) && gstate.isLogicOpEnabled()) { switch (gstate.getLogicOp()) { case GE_LOGIC_COPY_INVERTED: case GE_LOGIC_AND_INVERTED: @@ -1275,7 +1275,7 @@ static void ConvertBlendState(GenericBlendState &blendState, bool forceReplaceBl // At this point, through all paths above, glBlendFuncA and glBlendFuncB will be set right somehow. BlendEq colorEq; - if (gstate_c.Supports(GPU_SUPPORTS_BLEND_MINMAX)) { + if (gstate_c.Use(GPU_SUPPORTS_BLEND_MINMAX)) { colorEq = eqLookup[blendFuncEq]; } else { colorEq = eqLookupNoMinMax[blendFuncEq]; @@ -1597,7 +1597,7 @@ void ComputedPipelineState::Convert(bool shaderBitOpsSuppported) { // Passing on the previous applyFramebufferRead as forceFrameBuffer read in the next one, // thus propagating forward. ConvertMaskState(maskState, shaderBitOpsSuppported); - ConvertLogicOpState(logicState, gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP), shaderBitOpsSuppported, maskState.applyFramebufferRead); + ConvertLogicOpState(logicState, gstate_c.Use(GPU_SUPPORTS_LOGIC_OP), shaderBitOpsSuppported, maskState.applyFramebufferRead); ConvertBlendState(blendState, logicState.applyFramebufferRead); // Note: If the blend state decided it had to use framebuffer reads, diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index a814a345da..67a13e889b 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -46,11 +46,11 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } } bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); - bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP); + bool clipClampedDepth = gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - if (clipClampedDepth && vertexRangeCulling && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (clipClampedDepth && vertexRangeCulling && !gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { p.C("layout(triangle_strip, max_vertices = 12) out;\n"); } else { p.C("layout(triangle_strip, max_vertices = 6) out;\n"); @@ -85,7 +85,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" bool anyInside = false;\n"); } // And apply manual clipping if necessary. - if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (!gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { p.C(" float clip0[3];\n"); if (clipClampedDepth) { p.C(" float clip1[3];\n"); @@ -117,7 +117,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); } - if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (!gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { // This is basically the same value as gl_ClipDistance would take, z + w. if (vertexRangeCulling) { p.C(" clip0[i] = projZ * outPos.w + outPos.w;\n"); @@ -156,7 +156,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); } - if (!gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (!gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { // Clipping against one half-space cuts a triangle (17/27), culls (7/27), or creates two triangles (3/27). // We clip against two, so we can generate up to 4 triangles, a polygon with 6 points. p.C(" int indices[6];\n"); @@ -290,7 +290,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); } p.C(" gl_Position = outPos;\n"); - if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { } for (size_t i = 0; i < varyings.size(); i++) { diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 43fcbab8ab..e0c14945e1 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -83,7 +83,7 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, } bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough && !gstate.isModeClear(); - bool vertexRangeCulling = gstate_c.Supports(GPU_SUPPORTS_VS_RANGE_CULLING) && + bool vertexRangeCulling = gstate_c.Use(GPU_SUPPORTS_VS_RANGE_CULLING) && !isModeThrough && gstate_c.submitType == SubmitType::DRAW; // neither hw nor sw spline/bezier. See #11692 VShaderID id; @@ -124,7 +124,7 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, if (gstate.isLightingEnabled()) { // doShadeMapping is stored as UVGenMode, and light type doesn't matter for shade mapping. id.SetBit(VS_BIT_LIGHTING_ENABLE); - if (gstate_c.Supports(GPU_USE_LIGHT_UBERSHADER)) { + if (gstate_c.Use(GPU_USE_LIGHT_UBERSHADER)) { id.SetBit(VS_BIT_LIGHT_UBERSHADER); } else { id.SetBits(VS_BIT_MATERIAL_UPDATE, 3, gstate.getMaterialUpdate()); @@ -390,11 +390,11 @@ void ComputeGeometryShaderID(GShaderID *id_out, const Draw::Bugs &bugs, int prim bool isTriangle = prim == GE_PRIM_TRIANGLES || prim == GE_PRIM_TRIANGLE_FAN || prim == GE_PRIM_TRIANGLE_STRIP; bool vertexRangeCulling = !isCurve; - bool clipClampedDepth = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipClampedDepth = gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE); // If we're not using GS culling, return a zero ID. // Also, only use this for triangle primitives. - if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle || !gstate_c.Supports(GPU_SUPPORTS_GS_CULLING)) { + if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle || !gstate_c.Use(GPU_SUPPORTS_GS_CULLING)) { *id_out = id; return; } diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 5e3c0c5850..418868e219 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -639,7 +639,7 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy result->drawIndexed = true; // If we don't support custom cull in the shader, process it here. - if (!gstate_c.Supports(GPU_SUPPORTS_CULL_DISTANCE) && vertexCount > 0 && !throughmode) { + if (!gstate_c.Use(GPU_SUPPORTS_CULL_DISTANCE) && vertexCount > 0 && !throughmode) { const u16 *indsIn = (const u16 *)inds; u16 *newInds = inds + vertexCount; u16 *indsOut = newInds; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 32b234b49a..d1df05f809 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -197,7 +197,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac key.maxLevel = maxLevel * 256; key.minLevel = 0; key.lodBias = (int)(lodBias * 256.0f); - if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + if (gstate_c.Use(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { key.aniso = true; } break; @@ -281,7 +281,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac key.mipFilt = 1; key.maxLevel = 9 * 256; key.lodBias = 0.0f; - if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + if (gstate_c.Use(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { key.aniso = true; } break; @@ -1103,7 +1103,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate) gstate_c.SetNeedShaderTexclamp(true); } - if (channel == RASTER_DEPTH && !gstate_c.Supports(GPU_SUPPORTS_DEPTH_TEXTURE)) { + if (channel == RASTER_DEPTH && !gstate_c.Use(GPU_SUPPORTS_DEPTH_TEXTURE)) { WARN_LOG_ONCE(ndepthtex, G3D, "Depth textures not supported, not binding"); // Flag to bind a null texture if we can't support depth textures. // Should only happen on old OpenGL. @@ -1202,7 +1202,7 @@ bool TextureCacheCommon::GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffe void TextureCacheCommon::NotifyConfigChanged() { int scaleFactor = g_Config.iTexScalingLevel; - if (!gstate_c.Supports(GPU_SUPPORTS_TEXTURE_NPOT)) { + if (!gstate_c.Use(GPU_SUPPORTS_TEXTURE_NPOT)) { // Reduce the scale factor to a power of two (e.g. 2 or 4) if textures must be a power of two. // TODO: In addition we should probably remove these options from the UI in this case. while ((scaleFactor & (scaleFactor - 1)) != 0) { @@ -2581,7 +2581,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt int lastW = gstate.getTextureWidth(i - 1); int lastH = gstate.getTextureHeight(i - 1); - if (gstate_c.Supports(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { + if (gstate_c.Use(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { if (tw != 1 && tw != (lastW >> 1)) plan.badMipSizes = true; else if (th != 1 && th != (lastH >> 1)) @@ -2782,7 +2782,7 @@ void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, i decPitch = stride; } - if (!gstate_c.Supports(GPU_SUPPORTS_16BIT_FORMATS) || dstFmt == Draw::DataFormat::R8G8B8A8_UNORM) { + if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS) || dstFmt == Draw::DataFormat::R8G8B8A8_UNORM) { texDecFlags |= TexDecodeFlags::EXPAND32; } if (entry.status & TexCacheEntry::STATUS_CLUT_GPU) { diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 24f118603f..601be62a0c 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -139,7 +139,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (gl_extensions.EXT_gpu_shader4) { gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); } - bool useClamp = gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && !id.Bit(VS_BIT_IS_THROUGH); + bool useClamp = gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP) && !id.Bit(VS_BIT_IS_THROUGH); if (gl_extensions.EXT_clip_cull_distance && (id.Bit(VS_BIT_VERTEX_RANGE_CULLING) || useClamp)) { gl_exts.push_back("#extension GL_EXT_clip_cull_distance : enable"); } @@ -230,7 +230,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag bool texCoordInVec3 = false; bool vertexRangeCulling = id.Bit(VS_BIT_VERTEX_RANGE_CULLING) && !isModeThrough; - bool clipClampedDepth = !isModeThrough && gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipClampedDepth = !isModeThrough && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP) && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE); const char *clipClampedDepthSuffix = "[0]"; const char *vertexRangeClipSuffix = clipClampedDepth ? "[1]" : "[0]"; @@ -416,7 +416,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " vec4 gl_Position : POSITION;\n"); } else { WRITE(p, " vec4 gl_Position : SV_Position;\n"); - bool clipRange = vertexRangeCulling && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipRange = vertexRangeCulling && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE); if (clipClampedDepth && clipRange) { WRITE(p, " float2 gl_ClipDistance : SV_ClipDistance;\n"); clipClampedDepthSuffix = ".x"; @@ -426,7 +426,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag clipClampedDepthSuffix = ""; vertexRangeClipSuffix = ""; } - if (vertexRangeCulling && gstate_c.Supports(GPU_SUPPORTS_CULL_DISTANCE)) { + if (vertexRangeCulling && gstate_c.Use(GPU_SUPPORTS_CULL_DISTANCE)) { WRITE(p, " float2 gl_CullDistance : SV_CullDistance0;\n"); } } @@ -597,7 +597,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag } // See comment above this function (GenerateVertexShader). - if (!isModeThrough && gstate_c.Supports(GPU_ROUND_DEPTH_TO_16BIT)) { + if (!isModeThrough && gstate_c.Use(GPU_ROUND_DEPTH_TO_16BIT)) { // Apply the projection and viewport to get the Z buffer value, floor to integer, undo the viewport and projection. WRITE(p, "\nvec4 depthRoundZVP(vec4 v) {\n"); WRITE(p, " float z = v.z / v.w;\n"); @@ -847,7 +847,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag } // The viewport is used in this case, so need to compensate for that. - if (gstate_c.Supports(GPU_ROUND_DEPTH_TO_16BIT)) { + if (gstate_c.Use(GPU_ROUND_DEPTH_TO_16BIT)) { WRITE(p, " vec4 outPos = depthRoundZVP(pos);\n"); } else { WRITE(p, " vec4 outPos = pos;\n"); @@ -927,7 +927,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " vec4 viewPos = vec4(mul(vec4(worldpos, 1.0), u_view%s).xyz, 1.0);\n", matrixPostfix.c_str()); // Final view and projection transforms. - if (gstate_c.Supports(GPU_ROUND_DEPTH_TO_16BIT)) { + if (gstate_c.Use(GPU_ROUND_DEPTH_TO_16BIT)) { if (IsVRBuild()) { WRITE(p, " vec4 outPos = depthRoundZVP(mul(u_proj_lens%s, viewPos));\n", matrixPostfix.c_str()); WRITE(p, " vec4 orgPos = depthRoundZVP(mul(u_proj, viewPos));\n"); @@ -1306,11 +1306,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag const char *cull0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; const char *cull1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; - if (gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. WRITE(p, " %sgl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", compat.vsOutPrefix, vertexRangeClipSuffix); } - if (gstate_c.Supports(GPU_SUPPORTS_CULL_DISTANCE)) { + if (gstate_c.Use(GPU_SUPPORTS_CULL_DISTANCE)) { // Cull any triangle fully outside in the same direction when depth clamp enabled. WRITE(p, " if (u_cullRangeMin.w > 0.0) {\n"); WRITE(p, " %sgl_CullDistance%s = projPos.z - u_cullRangeMin.z;\n", compat.vsOutPrefix, cull0); diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index eff16b543b..c5c4669ba9 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -701,7 +701,7 @@ rotateVBO: uint8_t clearStencil = clearColor >> 24; draw_->Clear(clearFlag, clearColor, clearDepth, clearStencil); - if ((gstate_c.featureFlags & GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate_c.framebufFormat == GE_FORMAT_565)) { + if ((gstate_c.useFlags & GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate_c.framebufFormat == GE_FORMAT_565)) { int scissorX1 = gstate.getScissorX1(); int scissorY1 = gstate.getScissorY1(); int scissorX2 = gstate.getScissorX2() + 1; diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index bfbd12f190..59e3a5a4ed 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -82,7 +82,7 @@ GPU_D3D11::GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw) // No need to flush before the tex scale/offset commands if we are baking // the tex scale/offset into the vertices anyway. UpdateCmdInfo(); - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); BuildReportingInfo(); @@ -174,7 +174,7 @@ void GPU_D3D11::BeginHostFrame() { GPUCommon::BeginHostFrame(); UpdateCmdInfo(); if (resized_) { - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); framebufferManager_->Resized(); drawEngine_.Resized(); textureCache_->NotifyConfigChanged(); diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index 6f113f23d0..6a839e3d66 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -202,7 +202,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { dynState_.useBlendColor = false; } - if (gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) { + if (gstate_c.Use(GPU_SUPPORTS_LOGIC_OP)) { // Logic Ops if (gstate.isLogicOpEnabled() && gstate.getLogicOp() != GE_LOGIC_COPY) { keys_.blend.blendEnable = false; // Can't have both blend & logic op - although I think the PSP can! @@ -229,7 +229,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { if (gstate.getDepthRangeMin() == 0 || gstate.getDepthRangeMax() == 65535) { // TODO: Still has a bug where we clamp to depth range if one is not the full range. // But the alternate is not clamping in either direction... - keys_.raster.depthClipEnable = !gstate.isDepthClampEnabled() || !gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP); + keys_.raster.depthClipEnable = !gstate.isDepthClampEnabled() || !gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); } else { // We just want to clip in this case, the clamp would be clipped anyway. keys_.raster.depthClipEnable = 1; diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 2dac7b0749..a69dd20cd5 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -428,7 +428,7 @@ DXGI_FORMAT GetClutDestFormatD3D11(GEPaletteFormat format) { } DXGI_FORMAT TextureCacheD3D11::GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const { - if (!gstate_c.Supports(GPU_SUPPORTS_16BIT_FORMATS)) { + if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS)) { return DXGI_FORMAT_B8G8R8A8_UNORM; } diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index b8d4bfa0fb..8d0bac74ea 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -645,7 +645,7 @@ rotateVBO: device_->Clear(0, NULL, mask, SwapRB(clearColor), clearDepth, clearColor >> 24); - if ((gstate_c.featureFlags & GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate_c.framebufFormat == GE_FORMAT_565)) { + if (gstate_c.Use(GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate_c.framebufFormat == GE_FORMAT_565)) { int scissorX1 = gstate.getScissorX1(); int scissorY1 = gstate.getScissorY1(); int scissorX2 = gstate.getScissorX2() + 1; diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 075d89e460..7a69f7410d 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -81,7 +81,7 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw) // No need to flush before the tex scale/offset commands if we are baking // the tex scale/offset into the vertices anyway. UpdateCmdInfo(); - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); BuildReportingInfo(); @@ -163,7 +163,7 @@ void GPU_DX9::BeginHostFrame() { GPUCommon::BeginHostFrame(); UpdateCmdInfo(); if (resized_) { - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); framebufferManager_->Resized(); drawEngine_.Resized(); shaderManagerDX9_->DirtyShader(); diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index dedbb55660..4179c8b39d 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -170,7 +170,7 @@ void TextureCacheDX9::StartFrame() { Decimate(); } - if (gstate_c.Supports(GPU_SUPPORTS_ANISOTROPY)) { + if (gstate_c.Use(GPU_SUPPORTS_ANISOTROPY)) { DWORD aniso = 1 << g_Config.iAnisotropyLevel; DWORD anisotropyLevel = aniso > maxAnisotropyLevel ? maxAnisotropyLevel : aniso; device_->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, anisotropyLevel); diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 5283612f51..e82f055424 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -217,7 +217,7 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int DepthUB ub{}; - if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { // Don't scale anything, since we're not using factors outside accurate mode. ub.u_depthFactor[0] = 0.0f; ub.u_depthFactor[1] = 1.0f; diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 2102e46095..2e981d0474 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -437,7 +437,7 @@ void DrawEngineGLES::DoFlush() { render_->Clear(clearColor, clearDepth, clearColor >> 24, target, rgbaMask, vpAndScissor.scissorX, vpAndScissor.scissorY, vpAndScissor.scissorW, vpAndScissor.scissorH); framebufferManager_->SetColorUpdated(gstate_c.skipDrawReason); - if ((gstate_c.featureFlags & GPU_USE_CLEAR_RAM_HACK) && colorMask && (alphaMask || gstate_c.framebufFormat == GE_FORMAT_565)) { + if (gstate_c.Use(GPU_USE_CLEAR_RAM_HACK) && colorMask && (alphaMask || gstate_c.framebufFormat == GE_FORMAT_565)) { int scissorX1 = gstate.getScissorX1(); int scissorY1 = gstate.getScissorY1(); int scissorX2 = gstate.getScissorX2() + 1; @@ -476,7 +476,7 @@ bool DrawEngineGLES::IsCodePtrVertexDecoder(const u8 *ptr) const { bool DrawEngineGLES::SupportsHWTessellation() const { bool hasTexelFetch = gl_extensions.GLES3 || (!gl_extensions.IsGLES && gl_extensions.VersionGEThan(3, 3, 0)) || gl_extensions.EXT_gpu_shader4; - return hasTexelFetch && gstate_c.SupportsAll(GPU_SUPPORTS_VERTEX_TEXTURE_FETCH | GPU_SUPPORTS_TEXTURE_FLOAT | GPU_SUPPORTS_INSTANCE_RENDERING); + return hasTexelFetch && gstate_c.UseAll(GPU_SUPPORTS_VERTEX_TEXTURE_FETCH | GPU_SUPPORTS_TEXTURE_FLOAT | GPU_SUPPORTS_INSTANCE_RENDERING); } bool DrawEngineGLES::UpdateUseHWTessellation(bool enable) { diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 65dd71a539..39b9e59eb4 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -54,7 +54,7 @@ GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), drawEngine_(draw), fragmentTestCache_(draw) { UpdateVsyncInterval(true); - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); shaderManagerGL_ = new ShaderManagerGLES(draw); framebufferManagerGL_ = new FramebufferManagerGLES(draw); @@ -281,7 +281,7 @@ void GPU_GLES::BeginHostFrame() { GPUCommon::BeginHostFrame(); UpdateCmdInfo(); if (resized_) { - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); framebufferManager_->Resized(); drawEngine_.Resized(); shaderManagerGL_->DirtyShader(); diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 70295fdfdf..7d38e8df36 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -196,12 +196,12 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, initialize.push_back({ &u_tess_weights_v, 0, TEX_SLOT_SPLINE_WEIGHTS_V }); GLRProgramFlags flags{}; - flags.supportDualSource = (gstate_c.featureFlags & GPU_SUPPORTS_DUALSOURCE_BLEND) != 0; - if (!VSID.Bit(VS_BIT_IS_THROUGH) && gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP)) { + flags.supportDualSource = (gstate_c.useFlags & GPU_SUPPORTS_DUALSOURCE_BLEND) != 0; + if (!VSID.Bit(VS_BIT_IS_THROUGH) && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP)) { flags.useClipDistance0 = true; - if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) + if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) flags.useClipDistance1 = true; - } else if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Supports(GPU_SUPPORTS_CLIP_DISTANCE)) { + } else if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { flags.useClipDistance0 = true; } @@ -323,7 +323,7 @@ static inline void FlipProjMatrix(Matrix4x4 &in, bool useBufferedRendering) { // In Phantasy Star Portable 2, depth range sometimes goes negative and is clamped by glDepthRange to 0, // causing graphics clipping glitch (issue #1788). This hack modifies the projection matrix to work around it. - if (gstate_c.Supports(GPU_USE_DEPTH_RANGE_HACK)) { + if (gstate_c.Use(GPU_USE_DEPTH_RANGE_HACK)) { float zScale = gstate.getViewportZScale() / 65535.0f; float zCenter = gstate.getViewportZCenter() / 65535.0f; @@ -564,7 +564,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu float viewZScale = halfActualZRange; float viewZCenter = minz + halfActualZRange; - if (!gstate_c.Supports(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { viewZScale = vpZScale; viewZCenter = vpZCenter; } @@ -940,7 +940,7 @@ std::string ShaderManagerGLES::DebugGetShaderString(std::string id, DebugShaderT struct CacheHeader { uint32_t magic; uint32_t version; - uint32_t featureFlags; + uint32_t useFlags; uint32_t reserved; int numVertexShaders; int numFragmentShaders; @@ -957,7 +957,7 @@ void ShaderManagerGLES::Load(const Path &filename) { if (!f.ReadArray(&header, 1)) { return; } - if (header.magic != CACHE_HEADER_MAGIC || header.version != CACHE_VERSION || header.featureFlags != gstate_c.featureFlags) { + if (header.magic != CACHE_HEADER_MAGIC || header.version != CACHE_VERSION || header.useFlags != gstate_c.useFlags) { return; } diskCachePending_.start = time_now_d(); @@ -1113,7 +1113,7 @@ void ShaderManagerGLES::Save(const Path &filename) { header.magic = CACHE_HEADER_MAGIC; header.version = CACHE_VERSION; header.reserved = 0; - header.featureFlags = gstate_c.featureFlags; + header.useFlags = gstate_c.useFlags; header.numVertexShaders = GetNumVertexShaders(); header.numFragmentShaders = GetNumFragmentShaders(); header.numLinkedPrograms = GetNumPrograms(); diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index 5485db3c4e..cbbfb72a95 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -209,7 +209,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) { // TODO: Get rid of the ifdef #ifndef USING_GLES2 - if (gstate_c.Supports(GPU_SUPPORTS_LOGIC_OP)) { + if (gstate_c.Use(GPU_SUPPORTS_LOGIC_OP)) { renderManager->SetLogicOp(logicState.logicOpEnabled, logicOps[(int)logicState.logicOp]); } #endif @@ -232,7 +232,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) { if (gstate.getDepthRangeMin() == 0 || gstate.getDepthRangeMax() == 65535) { // TODO: Still has a bug where we clamp to depth range if one is not the full range. // But the alternate is not clamping in either direction... - depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP); + depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); } else { // We just want to clip in this case, the clamp would be clipped anyway. depthClampEnable = false; @@ -304,7 +304,7 @@ void DrawEngineGLES::ApplyDrawStateLate(bool setStencilValue, int stencilValue) // At this point, we know if the vertices are full alpha or not. // TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)? - if (!gstate.isModeClear() && gstate_c.Supports(GPU_USE_FRAGMENT_TEST_CACHE)) { + if (!gstate.isModeClear() && gstate_c.Use(GPU_USE_FRAGMENT_TEST_CACHE)) { // Apply last, once we know the alpha params of the texture. if (gstate.isAlphaTestEnabled() || gstate.isColorTestEnabled()) { fragmentTestCache_->BindTestTexture(TEX_SLOT_ALPHATEST); diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index bbb7c9838b..56b7f0d3b3 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -105,7 +105,7 @@ static const GLuint MagFiltGL[2] = { }; void TextureCacheGLES::ApplySamplingParams(const SamplerCacheKey &key) { - if (gstate_c.Supports(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { + if (gstate_c.Use(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { float minLod = (float)key.minLevel / 256.0f; float maxLod = (float)key.maxLevel / 256.0f; float lodBias = (float)key.lodBias / 256.0f; @@ -286,7 +286,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) { } } - if (!gstate_c.Supports(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { + if (!gstate_c.Use(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { // If the mip chain is not full.. if (plan.levelsToCreate != plan.maxPossibleLevels) { // We need to avoid creating mips at all, or generate them all - can't be incomplete diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 80f2eefefc..5cdfd9a434 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -454,7 +454,7 @@ void GPUCommon::UpdateCmdInfo() { // Reconfigure for light ubershader or not. for (int i = 0; i < 4; i++) { - if (gstate_c.Supports(GPU_USE_LIGHT_UBERSHADER)) { + if (gstate_c.Use(GPU_USE_LIGHT_UBERSHADER)) { cmdInfo_[GE_CMD_LIGHTENABLE0 + i].RemoveDirty(DIRTY_VERTEXSHADER_STATE); cmdInfo_[GE_CMD_LIGHTENABLE0 + i].AddDirty(DIRTY_LIGHT_CONTROL); cmdInfo_[GE_CMD_LIGHTTYPE0 + i].RemoveDirty(DIRTY_VERTEXSHADER_STATE); @@ -467,7 +467,7 @@ void GPUCommon::UpdateCmdInfo() { } } - if (gstate_c.Supports(GPU_USE_LIGHT_UBERSHADER)) { + if (gstate_c.Use(GPU_USE_LIGHT_UBERSHADER)) { cmdInfo_[GE_CMD_MATERIALUPDATE].RemoveDirty(DIRTY_VERTEXSHADER_STATE); cmdInfo_[GE_CMD_MATERIALUPDATE].AddDirty(DIRTY_LIGHT_CONTROL); } else { diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 15b837e5ba..052554b287 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -519,8 +519,9 @@ enum class SubmitType { }; struct GPUStateCache { - bool Supports(u32 flags) { return (featureFlags & flags) != 0; } // Return true if ANY of flags are true. - bool SupportsAll(u32 flags) { return (featureFlags & flags) == flags; } // Return true if ALL flags are true. + bool Use(u32 flags) { return (useFlags & flags) != 0; } // Return true if ANY of flags are true. + bool UseAll(u32 flags) { return (useFlags & flags) == flags; } // Return true if ALL flags are true. + uint64_t GetDirtyUniforms() { return dirty & DIRTY_ALL_UNIFORMS; } void Dirty(u64 what) { dirty |= what; @@ -561,7 +562,7 @@ struct GPUStateCache { } } - u32 featureFlags; + u32 useFlags; u32 vertexAddr; u32 indexAddr; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index b0e88aa0f2..f46b73de41 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -112,7 +112,7 @@ void DrawEngineVulkan::InitDeviceObjects() { bindings[3].descriptorCount = 1; bindings[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; bindings[3].stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; - if (gstate_c.Supports(GPU_SUPPORTS_GS_CULLING)) + if (gstate_c.Use(GPU_SUPPORTS_GS_CULLING)) bindings[3].stageFlags |= VK_SHADER_STAGE_GEOMETRY_BIT; bindings[3].binding = DRAW_BINDING_DYNUBO_BASE; bindings[4].descriptorCount = 1; @@ -973,7 +973,7 @@ void DrawEngineVulkan::DoFlush() { // If non-buffered though, it'll just do a plain clear. framebufferManager_->NotifyClear(gstate.isClearModeColorMask(), gstate.isClearModeAlphaMask(), gstate.isClearModeDepthMask(), result.color, result.depth); - if (gstate_c.Supports(GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate.FrameBufFormat() == GE_FORMAT_565)) { + if (gstate_c.Use(GPU_USE_CLEAR_RAM_HACK) && gstate.isClearModeColorMask() && (gstate.isClearModeAlphaMask() || gstate.FrameBufFormat() == GE_FORMAT_565)) { int scissorX1 = gstate.getScissorX1(); int scissorY1 = gstate.getScissorY1(); int scissorX2 = gstate.getScissorX2() + 1; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 64f69a861b..2ac1188824 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -52,7 +52,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPUCommon(gfxCtx, draw), drawEngine_(draw) { - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); drawEngine_.InitDeviceObjects(); VulkanContext *vulkan = (VulkanContext *)gfxCtx->GetAPIContext(); @@ -276,7 +276,7 @@ void GPU_Vulkan::BeginHostFrame() { UpdateCmdInfo(); if (resized_) { - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); // In case the GPU changed. BuildReportingInfo(); framebufferManager_->Resized(); @@ -515,7 +515,7 @@ void GPU_Vulkan::DeviceRestore() { GPUCommon::DeviceRestore(); InitDeviceObjects(); - gstate_c.featureFlags = CheckGPUFeatures(); + gstate_c.useFlags = CheckGPUFeatures(); BuildReportingInfo(); UpdateCmdInfo(); diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index c7724da670..97eb00c490 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -486,7 +486,7 @@ VulkanGeometryShader *ShaderManagerVulkan::GetGeometryShaderFromModule(VkShaderM struct VulkanCacheHeader { uint32_t magic; uint32_t version; - uint32_t featureFlags; + uint32_t useFlags; uint32_t reserved; int numVertexShaders; int numFragmentShaders; @@ -500,7 +500,7 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { return false; if (header.version != CACHE_VERSION) return false; - if (header.featureFlags != gstate_c.featureFlags) + if (header.useFlags != gstate_c.useFlags) return false; VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT); @@ -563,7 +563,7 @@ void ShaderManagerVulkan::SaveCache(FILE *f) { VulkanCacheHeader header{}; header.magic = CACHE_HEADER_MAGIC; header.version = CACHE_VERSION; - header.featureFlags = gstate_c.featureFlags; + header.useFlags = gstate_c.useFlags; header.reserved = 0; header.numVertexShaders = (int)vsCache_.size(); header.numFragmentShaders = (int)fsCache_.size(); diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index 4a81988a7f..62ef19d868 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -232,7 +232,7 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag if (gstate.getDepthRangeMin() == 0 || gstate.getDepthRangeMax() == 65535) { // TODO: Still has a bug where we clamp to depth range if one is not the full range. // But the alternate is not clamping in either direction... - key.depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Supports(GPU_SUPPORTS_DEPTH_CLAMP); + key.depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); } else { // We just want to clip in this case, the clamp would be clipped anyway. key.depthClampEnable = false; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 1a910bc5a1..f063dfa44a 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -685,7 +685,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } VkFormat TextureCacheVulkan::GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const { - if (!gstate_c.Supports(GPU_SUPPORTS_16BIT_FORMATS)) { + if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS)) { return VK_FORMAT_R8G8B8A8_UNORM; } switch (format) { @@ -726,7 +726,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt int decPitch; TexDecodeFlags texDecFlags{}; - if (!gstate_c.Supports(GPU_SUPPORTS_16BIT_FORMATS) || scaleFactor > 1 || dstFmt == VULKAN_8888_FORMAT) { + if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS) || scaleFactor > 1 || dstFmt == VULKAN_8888_FORMAT) { texDecFlags |= TexDecodeFlags::EXPAND32; } if (entry.status & TexCacheEntry::STATUS_CLUT_GPU) { From 9b8a5d1db30952de01bd760727591c1f7671a9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 08:30:27 +0200 Subject: [PATCH 179/374] Rename GPU_SUPPORTS_ to GPU_USE_ --- GPU/Common/DrawEngineCommon.cpp | 2 +- GPU/Common/FragmentShaderGenerator.cpp | 6 ++--- GPU/Common/GPUStateUtils.cpp | 26 +++++++++---------- GPU/Common/GeometryShaderGenerator.cpp | 12 ++++----- GPU/Common/ShaderId.cpp | 6 ++--- GPU/Common/SoftwareTransformCommon.cpp | 2 +- GPU/Common/TextureCacheCommon.cpp | 12 ++++----- GPU/Common/VertexShaderGenerator.cpp | 12 ++++----- GPU/D3D11/GPU_D3D11.cpp | 16 ++++++------ GPU/D3D11/StateMappingD3D11.cpp | 4 +-- GPU/D3D11/TextureCacheD3D11.cpp | 2 +- GPU/Directx9/GPU_DX9.cpp | 6 ++--- GPU/Directx9/TextureCacheDX9.cpp | 2 +- GPU/GLES/DepthBufferGLES.cpp | 2 +- GPU/GLES/DrawEngineGLES.cpp | 2 +- GPU/GLES/GPU_GLES.cpp | 18 ++++++------- GPU/GLES/ShaderManagerGLES.cpp | 10 +++---- GPU/GLES/StateMappingGLES.cpp | 4 +-- GPU/GLES/TextureCacheGLES.cpp | 4 +-- GPU/GPUCommon.cpp | 20 +++++++------- GPU/GPUState.h | 36 +++++++++++++------------- GPU/Vulkan/DrawEngineVulkan.cpp | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 30 ++++++++++----------- GPU/Vulkan/StateMappingVulkan.cpp | 2 +- GPU/Vulkan/TextureCacheVulkan.cpp | 4 +-- 25 files changed, 121 insertions(+), 121 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 249bcf48ef..155589641a 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -537,7 +537,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, } void DrawEngineCommon::ApplyFramebufferRead(FBOTexState *fboTexState) { - if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) { + if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) { *fboTexState = FBO_TEX_READ_FRAMEBUFFER; } else { gpuStats.numCopiesForShaderBlend++; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 783afaa5b7..e465e37ad1 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -137,8 +137,8 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool needFramebufferRead = replaceBlend == REPLACE_BLEND_READ_FRAMEBUFFER || colorWriteMask || replaceLogicOp; - bool fetchFramebuffer = needFramebufferRead && gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH); - bool readFramebufferTex = needFramebufferRead && !gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH); + bool fetchFramebuffer = needFramebufferRead && gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH); + bool readFramebufferTex = needFramebufferRead && !gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH); bool needFragCoord = readFramebufferTex || gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); bool writeDepth = gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); @@ -1177,7 +1177,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu const double scale = DepthSliceFactor() * 65535.0; WRITE(p, " highp float z = gl_FragCoord.z;\n"); - if (gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (gstate_c.Use(GPU_USE_ACCURATE_DEPTH)) { // We center the depth with an offset, but only its fraction matters. // When (DepthSliceFactor() - 1) is odd, it will be 0.5, otherwise 0. if (((int)(DepthSliceFactor() - 1.0f) & 1) == 1) { diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 0adf0ea5d0..1d2ceaaca0 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -183,7 +183,7 @@ ReplaceAlphaType ReplaceAlphaWithStencil(ReplaceBlendType replaceBlend) { if (nonAlphaSrcFactors[gstate.getBlendFuncA()] && nonAlphaDestFactors[gstate.getBlendFuncB()]) { return REPLACE_ALPHA_YES; } else { - if (gstate_c.Use(GPU_SUPPORTS_DUALSOURCE_BLEND)) { + if (gstate_c.Use(GPU_USE_DUALSOURCE_BLEND)) { return REPLACE_ALPHA_DUALSOURCE; } else { return REPLACE_ALPHA_NO; @@ -275,7 +275,7 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_BLENDMODE_MIN: case GE_BLENDMODE_MAX: - if (gstate_c.Use(GPU_SUPPORTS_BLEND_MINMAX)) { + if (gstate_c.Use(GPU_USE_BLEND_MINMAX)) { return REPLACE_BLEND_STANDARD; } else { return REPLACE_BLEND_READ_FRAMEBUFFER; @@ -312,7 +312,7 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_DSTBLEND_DOUBLESRCALPHA: // We can't technically do this correctly (due to clamping) without reading the dst color. // Using a copy isn't accurate either, though, when there's overlap. - if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_PRE_SRC_2X_ALPHA; @@ -454,14 +454,14 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_DSTBLEND_DOUBLESRCALPHA: if (funcA == GE_SRCBLEND_SRCALPHA || funcA == GE_SRCBLEND_INVSRCALPHA) { // Can't safely double alpha, will clamp. However, a copy may easily be worse due to overlap. - if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_PRE_SRC_2X_ALPHA; } else { // This means dst alpha/color is used in the src factor. // Unfortunately, copying here causes overlap problems in Silent Hill games (it seems?) // We will just hope that doubling alpha for the dst factor will not clamp too badly. - if (gstate_c.Use(GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_2X_ALPHA; } @@ -497,7 +497,7 @@ float DepthSliceFactor() { if (gstate_c.Use(GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT)) { return DEPTH_SLICE_FACTOR_16BIT; } - if (gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP)) { + if (gstate_c.Use(GPU_USE_DEPTH_CLAMP)) { return 1.0f; } return DEPTH_SLICE_FACTOR_HIGH; @@ -505,7 +505,7 @@ float DepthSliceFactor() { // This is used for float values which might not be integers, but are in the integer scale of 65535. float ToScaledDepthFromIntegerScale(float z) { - if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_USE_ACCURATE_DEPTH)) { return z * (1.0f / 65535.0f); } @@ -523,7 +523,7 @@ float ToScaledDepthFromIntegerScale(float z) { // See struct DepthScaleFactors for how to apply. DepthScaleFactors GetDepthScaleFactors() { DepthScaleFactors factors; - if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_USE_ACCURATE_DEPTH)) { factors.offset = 0; factors.scale = 65535.0f; return factors; @@ -728,7 +728,7 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo // This adjusts the center from halfActualZRange to vpZCenter. out.zOffset = halfActualZRange < std::numeric_limits::epsilon() ? 0.0f : (vpZCenter - (minz + halfActualZRange)) / halfActualZRange; - if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_USE_ACCURATE_DEPTH)) { out.depthScale = 1.0f; out.zOffset = 0.0f; out.depthRangeMin = ToScaledDepthFromIntegerScale(vpZCenter - vpZScale); @@ -863,7 +863,7 @@ static bool SimulateLogicOpIfNeeded(BlendFactor &srcBlend, BlendFactor &dstBlend // Note: our shader solution applies logic ops BEFORE blending, not correctly after. // This is however fine for the most common ones, like CLEAR/NOOP/SET, etc. - if (!gstate_c.Use(GPU_SUPPORTS_LOGIC_OP)) { + if (!gstate_c.Use(GPU_USE_LOGIC_OP)) { switch (gstate.getLogicOp()) { case GE_LOGIC_CLEAR: srcBlend = BlendFactor::ZERO; @@ -944,7 +944,7 @@ static bool SimulateLogicOpIfNeeded(BlendFactor &srcBlend, BlendFactor &dstBlend // Choose the shader part of the above logic op fallback simulation. SimulateLogicOpType SimulateLogicOpShaderTypeIfNeeded() { - if (!gstate_c.Use(GPU_SUPPORTS_LOGIC_OP) && gstate.isLogicOpEnabled()) { + if (!gstate_c.Use(GPU_USE_LOGIC_OP) && gstate.isLogicOpEnabled()) { switch (gstate.getLogicOp()) { case GE_LOGIC_COPY_INVERTED: case GE_LOGIC_AND_INVERTED: @@ -1275,7 +1275,7 @@ static void ConvertBlendState(GenericBlendState &blendState, bool forceReplaceBl // At this point, through all paths above, glBlendFuncA and glBlendFuncB will be set right somehow. BlendEq colorEq; - if (gstate_c.Use(GPU_SUPPORTS_BLEND_MINMAX)) { + if (gstate_c.Use(GPU_USE_BLEND_MINMAX)) { colorEq = eqLookup[blendFuncEq]; } else { colorEq = eqLookupNoMinMax[blendFuncEq]; @@ -1597,7 +1597,7 @@ void ComputedPipelineState::Convert(bool shaderBitOpsSuppported) { // Passing on the previous applyFramebufferRead as forceFrameBuffer read in the next one, // thus propagating forward. ConvertMaskState(maskState, shaderBitOpsSuppported); - ConvertLogicOpState(logicState, gstate_c.Use(GPU_SUPPORTS_LOGIC_OP), shaderBitOpsSuppported, maskState.applyFramebufferRead); + ConvertLogicOpState(logicState, gstate_c.Use(GPU_USE_LOGIC_OP), shaderBitOpsSuppported, maskState.applyFramebufferRead); ConvertBlendState(blendState, logicState.applyFramebufferRead); // Note: If the blend state decided it had to use framebuffer reads, diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 67a13e889b..18a2bc182e 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -46,11 +46,11 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu } } bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); - bool clipClampedDepth = gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); + bool clipClampedDepth = gstate_c.Use(GPU_USE_DEPTH_CLAMP); ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); p.C("layout(triangles) in;\n"); - if (clipClampedDepth && vertexRangeCulling && !gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (clipClampedDepth && vertexRangeCulling && !gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { p.C("layout(triangle_strip, max_vertices = 12) out;\n"); } else { p.C("layout(triangle_strip, max_vertices = 6) out;\n"); @@ -85,7 +85,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" bool anyInside = false;\n"); } // And apply manual clipping if necessary. - if (!gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (!gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { p.C(" float clip0[3];\n"); if (clipClampedDepth) { p.C(" float clip1[3];\n"); @@ -117,7 +117,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); } - if (!gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (!gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { // This is basically the same value as gl_ClipDistance would take, z + w. if (vertexRangeCulling) { p.C(" clip0[i] = projZ * outPos.w + outPos.w;\n"); @@ -156,7 +156,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.C(" }\n"); } - if (!gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (!gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { // Clipping against one half-space cuts a triangle (17/27), culls (7/27), or creates two triangles (3/27). // We clip against two, so we can generate up to 4 triangles, a polygon with 6 points. p.C(" int indices[6];\n"); @@ -290,7 +290,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu p.F(" gl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", clipSuffix0); } p.C(" gl_Position = outPos;\n"); - if (gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { } for (size_t i = 0; i < varyings.size(); i++) { diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index e0c14945e1..78483cf8a5 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -83,7 +83,7 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, } bool lmode = gstate.isUsingSecondaryColor() && gstate.isLightingEnabled() && !isModeThrough && !gstate.isModeClear(); - bool vertexRangeCulling = gstate_c.Use(GPU_SUPPORTS_VS_RANGE_CULLING) && + bool vertexRangeCulling = gstate_c.Use(GPU_USE_VS_RANGE_CULLING) && !isModeThrough && gstate_c.submitType == SubmitType::DRAW; // neither hw nor sw spline/bezier. See #11692 VShaderID id; @@ -390,11 +390,11 @@ void ComputeGeometryShaderID(GShaderID *id_out, const Draw::Bugs &bugs, int prim bool isTriangle = prim == GE_PRIM_TRIANGLES || prim == GE_PRIM_TRIANGLE_FAN || prim == GE_PRIM_TRIANGLE_STRIP; bool vertexRangeCulling = !isCurve; - bool clipClampedDepth = gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP) && !gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipClampedDepth = gstate_c.Use(GPU_USE_DEPTH_CLAMP) && !gstate_c.Use(GPU_USE_CLIP_DISTANCE); // If we're not using GS culling, return a zero ID. // Also, only use this for triangle primitives. - if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle || !gstate_c.Use(GPU_SUPPORTS_GS_CULLING)) { + if ((!vertexRangeCulling && !clipClampedDepth) || isModeThrough || !isTriangle || !gstate_c.Use(GPU_USE_GS_CULLING)) { *id_out = id; return; } diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 418868e219..0f841d1709 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -639,7 +639,7 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy result->drawIndexed = true; // If we don't support custom cull in the shader, process it here. - if (!gstate_c.Use(GPU_SUPPORTS_CULL_DISTANCE) && vertexCount > 0 && !throughmode) { + if (!gstate_c.Use(GPU_USE_CULL_DISTANCE) && vertexCount > 0 && !throughmode) { const u16 *indsIn = (const u16 *)inds; u16 *newInds = inds + vertexCount; u16 *indsOut = newInds; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index d1df05f809..0ee2c54b10 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -197,7 +197,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac key.maxLevel = maxLevel * 256; key.minLevel = 0; key.lodBias = (int)(lodBias * 256.0f); - if (gstate_c.Use(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + if (gstate_c.Use(GPU_USE_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { key.aniso = true; } break; @@ -281,7 +281,7 @@ SamplerCacheKey TextureCacheCommon::GetSamplingParams(int maxLevel, const TexCac key.mipFilt = 1; key.maxLevel = 9 * 256; key.lodBias = 0.0f; - if (gstate_c.Use(GPU_SUPPORTS_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { + if (gstate_c.Use(GPU_USE_ANISOTROPY) && g_Config.iAnisotropyLevel > 0) { key.aniso = true; } break; @@ -1103,7 +1103,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate) gstate_c.SetNeedShaderTexclamp(true); } - if (channel == RASTER_DEPTH && !gstate_c.Use(GPU_SUPPORTS_DEPTH_TEXTURE)) { + if (channel == RASTER_DEPTH && !gstate_c.Use(GPU_USE_DEPTH_TEXTURE)) { WARN_LOG_ONCE(ndepthtex, G3D, "Depth textures not supported, not binding"); // Flag to bind a null texture if we can't support depth textures. // Should only happen on old OpenGL. @@ -1202,7 +1202,7 @@ bool TextureCacheCommon::GetCurrentFramebufferTextureDebug(GPUDebugBuffer &buffe void TextureCacheCommon::NotifyConfigChanged() { int scaleFactor = g_Config.iTexScalingLevel; - if (!gstate_c.Use(GPU_SUPPORTS_TEXTURE_NPOT)) { + if (!gstate_c.Use(GPU_USE_TEXTURE_NPOT)) { // Reduce the scale factor to a power of two (e.g. 2 or 4) if textures must be a power of two. // TODO: In addition we should probably remove these options from the UI in this case. while ((scaleFactor & (scaleFactor - 1)) != 0) { @@ -2581,7 +2581,7 @@ bool TextureCacheCommon::PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEnt int lastW = gstate.getTextureWidth(i - 1); int lastH = gstate.getTextureHeight(i - 1); - if (gstate_c.Use(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { + if (gstate_c.Use(GPU_USE_TEXTURE_LOD_CONTROL)) { if (tw != 1 && tw != (lastW >> 1)) plan.badMipSizes = true; else if (th != 1 && th != (lastH >> 1)) @@ -2782,7 +2782,7 @@ void TextureCacheCommon::LoadTextureLevel(TexCacheEntry &entry, uint8_t *data, i decPitch = stride; } - if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS) || dstFmt == Draw::DataFormat::R8G8B8A8_UNORM) { + if (!gstate_c.Use(GPU_USE_16BIT_FORMATS) || dstFmt == Draw::DataFormat::R8G8B8A8_UNORM) { texDecFlags |= TexDecodeFlags::EXPAND32; } if (entry.status & TexCacheEntry::STATUS_CLUT_GPU) { diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 601be62a0c..45433a72d7 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -139,7 +139,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (gl_extensions.EXT_gpu_shader4) { gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); } - bool useClamp = gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP) && !id.Bit(VS_BIT_IS_THROUGH); + bool useClamp = gstate_c.Use(GPU_USE_DEPTH_CLAMP) && !id.Bit(VS_BIT_IS_THROUGH); if (gl_extensions.EXT_clip_cull_distance && (id.Bit(VS_BIT_VERTEX_RANGE_CULLING) || useClamp)) { gl_exts.push_back("#extension GL_EXT_clip_cull_distance : enable"); } @@ -230,7 +230,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag bool texCoordInVec3 = false; bool vertexRangeCulling = id.Bit(VS_BIT_VERTEX_RANGE_CULLING) && !isModeThrough; - bool clipClampedDepth = !isModeThrough && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP) && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipClampedDepth = !isModeThrough && gstate_c.Use(GPU_USE_DEPTH_CLAMP) && gstate_c.Use(GPU_USE_CLIP_DISTANCE); const char *clipClampedDepthSuffix = "[0]"; const char *vertexRangeClipSuffix = clipClampedDepth ? "[1]" : "[0]"; @@ -416,7 +416,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " vec4 gl_Position : POSITION;\n"); } else { WRITE(p, " vec4 gl_Position : SV_Position;\n"); - bool clipRange = vertexRangeCulling && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE); + bool clipRange = vertexRangeCulling && gstate_c.Use(GPU_USE_CLIP_DISTANCE); if (clipClampedDepth && clipRange) { WRITE(p, " float2 gl_ClipDistance : SV_ClipDistance;\n"); clipClampedDepthSuffix = ".x"; @@ -426,7 +426,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag clipClampedDepthSuffix = ""; vertexRangeClipSuffix = ""; } - if (vertexRangeCulling && gstate_c.Use(GPU_SUPPORTS_CULL_DISTANCE)) { + if (vertexRangeCulling && gstate_c.Use(GPU_USE_CULL_DISTANCE)) { WRITE(p, " float2 gl_CullDistance : SV_CullDistance0;\n"); } } @@ -1306,11 +1306,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag const char *cull0 = compat.shaderLanguage == HLSL_D3D11 ? ".x" : "[0]"; const char *cull1 = compat.shaderLanguage == HLSL_D3D11 ? ".y" : "[1]"; - if (gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + if (gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { // TODO: Ignore triangles from GE_PRIM_RECTANGLES in transform mode, which should not clip to neg z. WRITE(p, " %sgl_ClipDistance%s = projZ * outPos.w + outPos.w;\n", compat.vsOutPrefix, vertexRangeClipSuffix); } - if (gstate_c.Use(GPU_SUPPORTS_CULL_DISTANCE)) { + if (gstate_c.Use(GPU_USE_CULL_DISTANCE)) { // Cull any triangle fully outside in the same direction when depth clamp enabled. WRITE(p, " if (u_cullRangeMin.w > 0.0) {\n"); WRITE(p, " %sgl_CullDistance%s = projPos.z - u_cullRangeMin.z;\n", compat.vsOutPrefix, cull0); diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index 59e3a5a4ed..19155b0df5 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -106,23 +106,23 @@ u32 GPU_D3D11::CheckGPUFeatures() const { // Accurate depth is required because the Direct3D API does not support inverse Z. // So we cannot incorrectly use the viewport transform as the depth range on Direct3D. // TODO: Breaks text in PaRappa for some reason? - features |= GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_ACCURATE_DEPTH; if (draw_->GetDeviceCaps().depthClampSupported) - features |= GPU_SUPPORTS_DEPTH_CLAMP; + features |= GPU_USE_DEPTH_CLAMP; - features |= GPU_SUPPORTS_TEXTURE_FLOAT; - features |= GPU_SUPPORTS_INSTANCE_RENDERING; - features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; + features |= GPU_USE_TEXTURE_FLOAT; + features |= GPU_USE_INSTANCE_RENDERING; + features |= GPU_USE_TEXTURE_LOD_CONTROL; uint32_t fmt4444 = draw_->GetDataFormatSupport(Draw::DataFormat::A4R4G4B4_UNORM_PACK16); uint32_t fmt1555 = draw_->GetDataFormatSupport(Draw::DataFormat::A1R5G5B5_UNORM_PACK16); uint32_t fmt565 = draw_->GetDataFormatSupport(Draw::DataFormat::R5G6B5_UNORM_PACK16); if ((fmt4444 & Draw::FMT_TEXTURE) && (fmt565 & Draw::FMT_TEXTURE) && (fmt1555 & Draw::FMT_TEXTURE)) { - features |= GPU_SUPPORTS_16BIT_FORMATS; + features |= GPU_USE_16BIT_FORMATS; } - if (!g_Config.bHighQualityDepth && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) { + if (!g_Config.bHighQualityDepth && (features & GPU_USE_ACCURATE_DEPTH) != 0) { features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT; } else if (PSP_CoreParameter().compat.flags().PixelDepthRounding) { // Use fragment rounding on desktop and GLES3, most accurate. @@ -132,7 +132,7 @@ u32 GPU_D3D11::CheckGPUFeatures() const { } // The Phantasy Star hack :( - if (PSP_CoreParameter().compat.flags().DepthRangeHack && (features & GPU_SUPPORTS_ACCURATE_DEPTH) == 0) { + if (PSP_CoreParameter().compat.flags().DepthRangeHack && (features & GPU_USE_ACCURATE_DEPTH) == 0) { features |= GPU_USE_DEPTH_RANGE_HACK; } diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index 6a839e3d66..a902401122 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -202,7 +202,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { dynState_.useBlendColor = false; } - if (gstate_c.Use(GPU_SUPPORTS_LOGIC_OP)) { + if (gstate_c.Use(GPU_USE_LOGIC_OP)) { // Logic Ops if (gstate.isLogicOpEnabled() && gstate.getLogicOp() != GE_LOGIC_COPY) { keys_.blend.blendEnable = false; // Can't have both blend & logic op - although I think the PSP can! @@ -229,7 +229,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { if (gstate.getDepthRangeMin() == 0 || gstate.getDepthRangeMax() == 65535) { // TODO: Still has a bug where we clamp to depth range if one is not the full range. // But the alternate is not clamping in either direction... - keys_.raster.depthClipEnable = !gstate.isDepthClampEnabled() || !gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); + keys_.raster.depthClipEnable = !gstate.isDepthClampEnabled() || !gstate_c.Use(GPU_USE_DEPTH_CLAMP); } else { // We just want to clip in this case, the clamp would be clipped anyway. keys_.raster.depthClipEnable = 1; diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index a69dd20cd5..83c2c4869c 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -428,7 +428,7 @@ DXGI_FORMAT GetClutDestFormatD3D11(GEPaletteFormat format) { } DXGI_FORMAT TextureCacheD3D11::GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const { - if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS)) { + if (!gstate_c.Use(GPU_USE_16BIT_FORMATS)) { return DXGI_FORMAT_B8G8R8A8_UNORM; } diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 7a69f7410d..32d9d248c4 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -100,13 +100,13 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw) u32 GPU_DX9::CheckGPUFeatures() const { u32 features = GPUCommon::CheckGPUFeatures(); - features |= GPU_SUPPORTS_16BIT_FORMATS; - features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; + features |= GPU_USE_16BIT_FORMATS; + features |= GPU_USE_TEXTURE_LOD_CONTROL; // Accurate depth is required because the Direct3D API does not support inverse Z. // So we cannot incorrectly use the viewport transform as the depth range on Direct3D. // TODO: Breaks text in PaRappa for some reason? - features |= GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_ACCURATE_DEPTH; auto vendor = draw_->GetDeviceCaps().vendor; diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index 4179c8b39d..a280c7c590 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -170,7 +170,7 @@ void TextureCacheDX9::StartFrame() { Decimate(); } - if (gstate_c.Use(GPU_SUPPORTS_ANISOTROPY)) { + if (gstate_c.Use(GPU_USE_ANISOTROPY)) { DWORD aniso = 1 << g_Config.iAnisotropyLevel; DWORD anisotropyLevel = aniso > maxAnisotropyLevel ? maxAnisotropyLevel : aniso; device_->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, anisotropyLevel); diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index e82f055424..7be1adf9d3 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -217,7 +217,7 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int DepthUB ub{}; - if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_USE_ACCURATE_DEPTH)) { // Don't scale anything, since we're not using factors outside accurate mode. ub.u_depthFactor[0] = 0.0f; ub.u_depthFactor[1] = 1.0f; diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 2e981d0474..8bd39eadb4 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -476,7 +476,7 @@ bool DrawEngineGLES::IsCodePtrVertexDecoder(const u8 *ptr) const { bool DrawEngineGLES::SupportsHWTessellation() const { bool hasTexelFetch = gl_extensions.GLES3 || (!gl_extensions.IsGLES && gl_extensions.VersionGEThan(3, 3, 0)) || gl_extensions.EXT_gpu_shader4; - return hasTexelFetch && gstate_c.UseAll(GPU_SUPPORTS_VERTEX_TEXTURE_FETCH | GPU_SUPPORTS_TEXTURE_FLOAT | GPU_SUPPORTS_INSTANCE_RENDERING); + return hasTexelFetch && gstate_c.UseAll(GPU_USE_VERTEX_TEXTURE_FETCH | GPU_USE_TEXTURE_FLOAT | GPU_USE_INSTANCE_RENDERING); } bool DrawEngineGLES::UpdateUseHWTessellation(bool enable) { diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 39b9e59eb4..e71557c7ee 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -151,29 +151,29 @@ GPU_GLES::~GPU_GLES() { u32 GPU_GLES::CheckGPUFeatures() const { u32 features = GPUCommon::CheckGPUFeatures(); - features |= GPU_SUPPORTS_16BIT_FORMATS; + features |= GPU_USE_16BIT_FORMATS; if ((gl_extensions.gpuVendor == GPU_VENDOR_NVIDIA) || (gl_extensions.gpuVendor == GPU_VENDOR_AMD)) features |= GPU_PREFER_REVERSE_COLOR_ORDER; if (gl_extensions.GLES3 || !gl_extensions.IsGLES) - features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; + features |= GPU_USE_TEXTURE_LOD_CONTROL; bool canUseInstanceID = gl_extensions.EXT_draw_instanced || gl_extensions.ARB_draw_instanced; bool canDefInstanceID = gl_extensions.IsGLES || gl_extensions.EXT_gpu_shader4 || gl_extensions.VersionGEThan(3, 1); bool instanceRendering = gl_extensions.GLES3 || (canUseInstanceID && canDefInstanceID); if (instanceRendering) - features |= GPU_SUPPORTS_INSTANCE_RENDERING; + features |= GPU_USE_INSTANCE_RENDERING; int maxVertexTextureImageUnits = gl_extensions.maxVertexTextureUnits; if (maxVertexTextureImageUnits >= 3) // At least 3 for hardware tessellation - features |= GPU_SUPPORTS_VERTEX_TEXTURE_FETCH; + features |= GPU_USE_VERTEX_TEXTURE_FETCH; if (gl_extensions.ARB_texture_float || gl_extensions.OES_texture_float) - features |= GPU_SUPPORTS_TEXTURE_FLOAT; + features |= GPU_USE_TEXTURE_FLOAT; if (draw_->GetDeviceCaps().depthClampSupported) { - features |= GPU_SUPPORTS_DEPTH_CLAMP | GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_DEPTH_CLAMP | GPU_USE_ACCURATE_DEPTH; // Our implementation of depth texturing needs simple Z range, so can't // use the extension hacks (yet). } @@ -181,13 +181,13 @@ u32 GPU_GLES::CheckGPUFeatures() const { // If we already have a 16-bit depth buffer, we don't need to round. bool prefer24 = draw_->GetDeviceCaps().preferredDepthBufferFormat == Draw::DataFormat::D24_S8; if (prefer24) { - if (!g_Config.bHighQualityDepth && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) { + if (!g_Config.bHighQualityDepth && (features & GPU_USE_ACCURATE_DEPTH) != 0) { features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT; } else if (PSP_CoreParameter().compat.flags().PixelDepthRounding) { if (!gl_extensions.IsGLES || gl_extensions.GLES3) { // Use fragment rounding on desktop and GLES3, most accurate. features |= GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT; - } else if (prefer24 && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) { + } else if (prefer24 && (features & GPU_USE_ACCURATE_DEPTH) != 0) { // Here we can simulate a 16 bit depth buffer by scaling. // Note that the depth buffer is fixed point, not floating, so dividing by 256 is pretty good. features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT; @@ -201,7 +201,7 @@ u32 GPU_GLES::CheckGPUFeatures() const { } // The Phantasy Star hack :( - if (PSP_CoreParameter().compat.flags().DepthRangeHack && (features & GPU_SUPPORTS_ACCURATE_DEPTH) == 0) { + if (PSP_CoreParameter().compat.flags().DepthRangeHack && (features & GPU_USE_ACCURATE_DEPTH) == 0) { features |= GPU_USE_DEPTH_RANGE_HACK; } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 7d38e8df36..2148efa5fd 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -196,12 +196,12 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, initialize.push_back({ &u_tess_weights_v, 0, TEX_SLOT_SPLINE_WEIGHTS_V }); GLRProgramFlags flags{}; - flags.supportDualSource = (gstate_c.useFlags & GPU_SUPPORTS_DUALSOURCE_BLEND) != 0; - if (!VSID.Bit(VS_BIT_IS_THROUGH) && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP)) { + flags.supportDualSource = (gstate_c.useFlags & GPU_USE_DUALSOURCE_BLEND) != 0; + if (!VSID.Bit(VS_BIT_IS_THROUGH) && gstate_c.Use(GPU_USE_DEPTH_CLAMP)) { flags.useClipDistance0 = true; - if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) + if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_USE_CLIP_DISTANCE)) flags.useClipDistance1 = true; - } else if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_SUPPORTS_CLIP_DISTANCE)) { + } else if (VSID.Bit(VS_BIT_VERTEX_RANGE_CULLING) && gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { flags.useClipDistance0 = true; } @@ -564,7 +564,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu float viewZScale = halfActualZRange; float viewZCenter = minz + halfActualZRange; - if (!gstate_c.Use(GPU_SUPPORTS_ACCURATE_DEPTH)) { + if (!gstate_c.Use(GPU_USE_ACCURATE_DEPTH)) { viewZScale = vpZScale; viewZCenter = vpZCenter; } diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index cbbfb72a95..0b8f45c3c6 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -209,7 +209,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) { // TODO: Get rid of the ifdef #ifndef USING_GLES2 - if (gstate_c.Use(GPU_SUPPORTS_LOGIC_OP)) { + if (gstate_c.Use(GPU_USE_LOGIC_OP)) { renderManager->SetLogicOp(logicState.logicOpEnabled, logicOps[(int)logicState.logicOp]); } #endif @@ -232,7 +232,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) { if (gstate.getDepthRangeMin() == 0 || gstate.getDepthRangeMax() == 65535) { // TODO: Still has a bug where we clamp to depth range if one is not the full range. // But the alternate is not clamping in either direction... - depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); + depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Use(GPU_USE_DEPTH_CLAMP); } else { // We just want to clip in this case, the clamp would be clipped anyway. depthClampEnable = false; diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 56b7f0d3b3..9584955d34 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -105,7 +105,7 @@ static const GLuint MagFiltGL[2] = { }; void TextureCacheGLES::ApplySamplingParams(const SamplerCacheKey &key) { - if (gstate_c.Use(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { + if (gstate_c.Use(GPU_USE_TEXTURE_LOD_CONTROL)) { float minLod = (float)key.minLevel / 256.0f; float maxLod = (float)key.maxLevel / 256.0f; float lodBias = (float)key.lodBias / 256.0f; @@ -286,7 +286,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) { } } - if (!gstate_c.Use(GPU_SUPPORTS_TEXTURE_LOD_CONTROL)) { + if (!gstate_c.Use(GPU_USE_TEXTURE_LOD_CONTROL)) { // If the mip chain is not full.. if (plan.levelsToCreate != plan.maxPossibleLevels) { // We need to avoid creating mips at all, or generate them all - can't be incomplete diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 5cdfd9a434..49cf93d712 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3285,44 +3285,44 @@ size_t GPUCommon::FormatGPUStatsCommon(char *buffer, size_t size) { u32 GPUCommon::CheckGPUFeatures() const { u32 features = 0; if (draw_->GetDeviceCaps().logicOpSupported) { - features |= GPU_SUPPORTS_LOGIC_OP; + features |= GPU_USE_LOGIC_OP; } if (draw_->GetDeviceCaps().anisoSupported) { - features |= GPU_SUPPORTS_ANISOTROPY; + features |= GPU_USE_ANISOTROPY; } if (draw_->GetDeviceCaps().textureNPOTFullySupported) { - features |= GPU_SUPPORTS_TEXTURE_NPOT; + features |= GPU_USE_TEXTURE_NPOT; } if (draw_->GetDeviceCaps().dualSourceBlend) { if (!g_Config.bVendorBugChecksEnabled || !draw_->GetBugs().Has(Draw::Bugs::DUAL_SOURCE_BLENDING_BROKEN)) { - features |= GPU_SUPPORTS_DUALSOURCE_BLEND; + features |= GPU_USE_DUALSOURCE_BLEND; } } if (draw_->GetDeviceCaps().blendMinMaxSupported) { - features |= GPU_SUPPORTS_BLEND_MINMAX; + features |= GPU_USE_BLEND_MINMAX; } if (draw_->GetDeviceCaps().clipDistanceSupported) { - features |= GPU_SUPPORTS_CLIP_DISTANCE; + features |= GPU_USE_CLIP_DISTANCE; } if (draw_->GetDeviceCaps().cullDistanceSupported) { - features |= GPU_SUPPORTS_CULL_DISTANCE; + features |= GPU_USE_CULL_DISTANCE; } if (draw_->GetDeviceCaps().textureDepthSupported) { - features |= GPU_SUPPORTS_DEPTH_TEXTURE; + features |= GPU_USE_DEPTH_TEXTURE; } bool canClipOrCull = draw_->GetDeviceCaps().clipDistanceSupported || draw_->GetDeviceCaps().cullDistanceSupported; bool canDiscardVertex = draw_->GetBugs().Has(Draw::Bugs::BROKEN_NAN_IN_CONDITIONAL); if (canClipOrCull || canDiscardVertex) { // We'll dynamically use the parts that are supported, to reduce artifacts as much as possible. - features |= GPU_SUPPORTS_VS_RANGE_CULLING; + features |= GPU_USE_VS_RANGE_CULLING; } if (draw_->GetDeviceCaps().framebufferFetchSupported) { - features |= GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH; + features |= GPU_USE_ANY_FRAMEBUFFER_FETCH; } if (draw_->GetShaderLanguageDesc().bitwiseOps) { diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 052554b287..881c7b3c69 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -471,35 +471,35 @@ struct UVScale { // to centralize into flags like this. They're also fast to check since the cache line // will be hot. enum { - GPU_SUPPORTS_DUALSOURCE_BLEND = FLAG_BIT(0), + GPU_USE_DUALSOURCE_BLEND = FLAG_BIT(0), GPU_USE_LIGHT_UBERSHADER = FLAG_BIT(1), GPU_USE_FRAGMENT_TEST_CACHE = FLAG_BIT(2), - GPU_SUPPORTS_VS_RANGE_CULLING = FLAG_BIT(3), - GPU_SUPPORTS_BLEND_MINMAX = FLAG_BIT(4), - GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5), + GPU_USE_VS_RANGE_CULLING = FLAG_BIT(3), + GPU_USE_BLEND_MINMAX = FLAG_BIT(4), + GPU_USE_LOGIC_OP = FLAG_BIT(5), GPU_USE_DEPTH_RANGE_HACK = FLAG_BIT(6), // Free bit: 7 - GPU_SUPPORTS_ANISOTROPY = FLAG_BIT(8), + GPU_USE_ANISOTROPY = FLAG_BIT(8), GPU_USE_CLEAR_RAM_HACK = FLAG_BIT(9), - GPU_SUPPORTS_INSTANCE_RENDERING = FLAG_BIT(10), - GPU_SUPPORTS_VERTEX_TEXTURE_FETCH = FLAG_BIT(11), - GPU_SUPPORTS_TEXTURE_FLOAT = FLAG_BIT(12), - GPU_SUPPORTS_16BIT_FORMATS = FLAG_BIT(13), - GPU_SUPPORTS_DEPTH_CLAMP = FLAG_BIT(14), + GPU_USE_INSTANCE_RENDERING = FLAG_BIT(10), + GPU_USE_VERTEX_TEXTURE_FETCH = FLAG_BIT(11), + GPU_USE_TEXTURE_FLOAT = FLAG_BIT(12), + GPU_USE_16BIT_FORMATS = FLAG_BIT(13), + GPU_USE_DEPTH_CLAMP = FLAG_BIT(14), // Free bit: 15 - GPU_SUPPORTS_DEPTH_TEXTURE = FLAG_BIT(16), - GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17), - GPU_SUPPORTS_GS_CULLING = FLAG_BIT(18), // Geometry shader + GPU_USE_DEPTH_TEXTURE = FLAG_BIT(16), + GPU_USE_ACCURATE_DEPTH = FLAG_BIT(17), + GPU_USE_GS_CULLING = FLAG_BIT(18), // Geometry shader // Free bit: 19 - GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH = FLAG_BIT(20), + GPU_USE_ANY_FRAMEBUFFER_FETCH = FLAG_BIT(20), GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT = FLAG_BIT(21), GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT = FLAG_BIT(22), GPU_ROUND_DEPTH_TO_16BIT = FLAG_BIT(23), // Can be disabled either per game or if we use a real 16-bit depth buffer - GPU_SUPPORTS_TEXTURE_LOD_CONTROL = FLAG_BIT(24), + GPU_USE_TEXTURE_LOD_CONTROL = FLAG_BIT(24), // Free bits: 25-27 - GPU_SUPPORTS_TEXTURE_NPOT = FLAG_BIT(28), - GPU_SUPPORTS_CLIP_DISTANCE = FLAG_BIT(29), - GPU_SUPPORTS_CULL_DISTANCE = FLAG_BIT(30), + GPU_USE_TEXTURE_NPOT = FLAG_BIT(28), + GPU_USE_CLIP_DISTANCE = FLAG_BIT(29), + GPU_USE_CULL_DISTANCE = FLAG_BIT(30), GPU_PREFER_REVERSE_COLOR_ORDER = FLAG_BIT(31), }; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index f46b73de41..b24e4b0021 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -112,7 +112,7 @@ void DrawEngineVulkan::InitDeviceObjects() { bindings[3].descriptorCount = 1; bindings[3].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; bindings[3].stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; - if (gstate_c.Use(GPU_SUPPORTS_GS_CULLING)) + if (gstate_c.Use(GPU_USE_GS_CULLING)) bindings[3].stageFlags |= VK_SHADER_STAGE_GEOMETRY_BIT; bindings[3].binding = DRAW_BINDING_DYNUBO_BASE; bindings[4].descriptorCount = 1; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 2ac1188824..fbc31a90e3 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -190,11 +190,11 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { switch (vulkan->GetPhysicalDeviceProperties().properties.vendorID) { case VULKAN_VENDOR_AMD: // Accurate depth is required on AMD (due to reverse-Z driver bug) so we ignore the compat flag to disable it on those. See #9545 - features |= GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_ACCURATE_DEPTH; break; case VULKAN_VENDOR_QUALCOMM: // Accurate depth is required on Adreno too (seems to also have a reverse-Z driver bug). - features |= GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_ACCURATE_DEPTH; break; case VULKAN_VENDOR_ARM: { @@ -206,40 +206,40 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { || VK_VERSION_MAJOR(vulkan->GetPhysicalDeviceProperties().properties.driverVersion) < 14; if (!PSP_CoreParameter().compat.flags().DisableAccurateDepth || driverTooOld) { - features |= GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_ACCURATE_DEPTH; } break; } default: if (!PSP_CoreParameter().compat.flags().DisableAccurateDepth) { - features |= GPU_SUPPORTS_ACCURATE_DEPTH; + features |= GPU_USE_ACCURATE_DEPTH; } break; } // Might enable this later - in the first round we are mostly looking at depth/stencil/discard. // if (!g_Config.bEnableVendorBugChecks) - // features |= GPU_SUPPORTS_ACCURATE_DEPTH; + // features |= GPU_USE_ACCURATE_DEPTH; // Mandatory features on Vulkan, which may be checked in "centralized" code - features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; - features |= GPU_SUPPORTS_INSTANCE_RENDERING; - features |= GPU_SUPPORTS_VERTEX_TEXTURE_FETCH; - features |= GPU_SUPPORTS_TEXTURE_FLOAT; + features |= GPU_USE_TEXTURE_LOD_CONTROL; + features |= GPU_USE_INSTANCE_RENDERING; + features |= GPU_USE_VERTEX_TEXTURE_FETCH; + features |= GPU_USE_TEXTURE_FLOAT; auto &enabledFeatures = vulkan->GetDeviceFeatures().enabled; if (enabledFeatures.depthClamp) { - features |= GPU_SUPPORTS_DEPTH_CLAMP; + features |= GPU_USE_DEPTH_CLAMP; } // Fall back to geometry shader culling if we can't do vertex range culling. if (enabledFeatures.geometryShader) { const bool useGeometry = g_Config.bUseGeometryShader && !draw_->GetBugs().Has(Draw::Bugs::GEOMETRY_SHADERS_SLOW_OR_BROKEN); const bool vertexSupported = draw_->GetDeviceCaps().clipDistanceSupported && draw_->GetDeviceCaps().cullDistanceSupported; - if (useGeometry && (!vertexSupported || (features & GPU_SUPPORTS_VS_RANGE_CULLING) == 0)) { + if (useGeometry && (!vertexSupported || (features & GPU_USE_VS_RANGE_CULLING) == 0)) { // Switch to culling via the geometry shader if not fully supported in vertex. - features |= GPU_SUPPORTS_GS_CULLING; - features &= ~GPU_SUPPORTS_VS_RANGE_CULLING; + features |= GPU_USE_GS_CULLING; + features &= ~GPU_USE_VS_RANGE_CULLING; } } @@ -252,12 +252,12 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { // if it's not available, for simplicity. uint32_t fmt565 = draw_->GetDataFormatSupport(Draw::DataFormat::B5G6R5_UNORM_PACK16); if ((fmt4444 & Draw::FMT_TEXTURE) && (fmt565 & Draw::FMT_TEXTURE) && (fmt1555 & Draw::FMT_TEXTURE)) { - features |= GPU_SUPPORTS_16BIT_FORMATS; + features |= GPU_USE_16BIT_FORMATS; } else { INFO_LOG(G3D, "Deficient texture format support: 4444: %d 1555: %d 565: %d", fmt4444, fmt1555, fmt565); } - if (!g_Config.bHighQualityDepth && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) { + if (!g_Config.bHighQualityDepth && (features & GPU_USE_ACCURATE_DEPTH) != 0) { features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT; } else if (PSP_CoreParameter().compat.flags().PixelDepthRounding) { diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index 62ef19d868..c29d2317d9 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -232,7 +232,7 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag if (gstate.getDepthRangeMin() == 0 || gstate.getDepthRangeMax() == 65535) { // TODO: Still has a bug where we clamp to depth range if one is not the full range. // But the alternate is not clamping in either direction... - key.depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Use(GPU_SUPPORTS_DEPTH_CLAMP); + key.depthClampEnable = gstate.isDepthClampEnabled() && gstate_c.Use(GPU_USE_DEPTH_CLAMP); } else { // We just want to clip in this case, the clamp would be clipped anyway. key.depthClampEnable = false; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index f063dfa44a..c465aa31c2 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -685,7 +685,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { } VkFormat TextureCacheVulkan::GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const { - if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS)) { + if (!gstate_c.Use(GPU_USE_16BIT_FORMATS)) { return VK_FORMAT_R8G8B8A8_UNORM; } switch (format) { @@ -726,7 +726,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt int decPitch; TexDecodeFlags texDecFlags{}; - if (!gstate_c.Use(GPU_SUPPORTS_16BIT_FORMATS) || scaleFactor > 1 || dstFmt == VULKAN_8888_FORMAT) { + if (!gstate_c.Use(GPU_USE_16BIT_FORMATS) || scaleFactor > 1 || dstFmt == VULKAN_8888_FORMAT) { texDecFlags |= TexDecodeFlags::EXPAND32; } if (entry.status & TexCacheEntry::STATUS_CLUT_GPU) { From 30aa07b1560ba7fa9af292974ef0d1a5887b937a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 08:34:03 +0200 Subject: [PATCH 180/374] Two more renames to make things read better --- GPU/Common/DrawEngineCommon.cpp | 2 +- GPU/Common/FragmentShaderGenerator.cpp | 4 ++-- GPU/Common/GPUStateUtils.cpp | 6 +++--- GPU/GLES/GPU_GLES.cpp | 2 +- GPU/GPUCommon.cpp | 2 +- GPU/GPUState.h | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 155589641a..495b206515 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -537,7 +537,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, } void DrawEngineCommon::ApplyFramebufferRead(FBOTexState *fboTexState) { - if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) { + if (gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH)) { *fboTexState = FBO_TEX_READ_FRAMEBUFFER; } else { gpuStats.numCopiesForShaderBlend++; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index e465e37ad1..5fe27b19c0 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -137,8 +137,8 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool needFramebufferRead = replaceBlend == REPLACE_BLEND_READ_FRAMEBUFFER || colorWriteMask || replaceLogicOp; - bool fetchFramebuffer = needFramebufferRead && gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH); - bool readFramebufferTex = needFramebufferRead && !gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH); + bool fetchFramebuffer = needFramebufferRead && gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH); + bool readFramebufferTex = needFramebufferRead && !gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH); bool needFragCoord = readFramebufferTex || gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); bool writeDepth = gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT); diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 1d2ceaaca0..47d11afb4a 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -312,7 +312,7 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_DSTBLEND_DOUBLESRCALPHA: // We can't technically do this correctly (due to clamping) without reading the dst color. // Using a copy isn't accurate either, though, when there's overlap. - if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_PRE_SRC_2X_ALPHA; @@ -454,14 +454,14 @@ ReplaceBlendType ReplaceBlendWithShader(GEBufferFormat bufferFormat) { case GE_DSTBLEND_DOUBLESRCALPHA: if (funcA == GE_SRCBLEND_SRCALPHA || funcA == GE_SRCBLEND_INVSRCALPHA) { // Can't safely double alpha, will clamp. However, a copy may easily be worse due to overlap. - if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_PRE_SRC_2X_ALPHA; } else { // This means dst alpha/color is used in the src factor. // Unfortunately, copying here causes overlap problems in Silent Hill games (it seems?) // We will just hope that doubling alpha for the dst factor will not clamp too badly. - if (gstate_c.Use(GPU_USE_ANY_FRAMEBUFFER_FETCH)) + if (gstate_c.Use(GPU_USE_FRAMEBUFFER_FETCH)) return REPLACE_BLEND_READ_FRAMEBUFFER; return REPLACE_BLEND_2X_ALPHA; } diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index e71557c7ee..c2740460db 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -154,7 +154,7 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_16BIT_FORMATS; if ((gl_extensions.gpuVendor == GPU_VENDOR_NVIDIA) || (gl_extensions.gpuVendor == GPU_VENDOR_AMD)) - features |= GPU_PREFER_REVERSE_COLOR_ORDER; + features |= GPU_USE_REVERSE_COLOR_ORDER; if (gl_extensions.GLES3 || !gl_extensions.IsGLES) features |= GPU_USE_TEXTURE_LOD_CONTROL; diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 49cf93d712..7a6b3fea88 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3322,7 +3322,7 @@ u32 GPUCommon::CheckGPUFeatures() const { } if (draw_->GetDeviceCaps().framebufferFetchSupported) { - features |= GPU_USE_ANY_FRAMEBUFFER_FETCH; + features |= GPU_USE_FRAMEBUFFER_FETCH; } if (draw_->GetShaderLanguageDesc().bitwiseOps) { diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 881c7b3c69..d34b824c8a 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -491,7 +491,7 @@ enum { GPU_USE_ACCURATE_DEPTH = FLAG_BIT(17), GPU_USE_GS_CULLING = FLAG_BIT(18), // Geometry shader // Free bit: 19 - GPU_USE_ANY_FRAMEBUFFER_FETCH = FLAG_BIT(20), + GPU_USE_FRAMEBUFFER_FETCH = FLAG_BIT(20), GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT = FLAG_BIT(21), GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT = FLAG_BIT(22), GPU_ROUND_DEPTH_TO_16BIT = FLAG_BIT(23), // Can be disabled either per game or if we use a real 16-bit depth buffer @@ -500,7 +500,7 @@ enum { GPU_USE_TEXTURE_NPOT = FLAG_BIT(28), GPU_USE_CLIP_DISTANCE = FLAG_BIT(29), GPU_USE_CULL_DISTANCE = FLAG_BIT(30), - GPU_PREFER_REVERSE_COLOR_ORDER = FLAG_BIT(31), + GPU_USE_REVERSE_COLOR_ORDER = FLAG_BIT(31), }; struct KnownVertexBounds { From d5c9d15ec3931a0b00f4d6b7b09920bce8f9c3e8 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 17 Oct 2022 18:31:01 +0200 Subject: [PATCH 181/374] OpenXR - Move matrix composing out of VR tweaks --- Common/VR/PPSSPPVR.cpp | 57 ++++++++++++++++++++++++++++++++++++++---- Common/VR/VRTweaks.cpp | 50 +----------------------------------- Common/VR/VRTweaks.h | 5 ---- 3 files changed, 53 insertions(+), 59 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 7bbda32cde..b55d5d011c 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -362,9 +362,43 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { } void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { - VR_TweakProjection(projMatrix, leftEye, VR_PROJECTION_MATRIX_LEFT_EYE); - VR_TweakProjection(projMatrix, rightEye, VR_PROJECTION_MATRIX_RIGHT_EYE); - VR_TweakMirroring(projMatrix); + + // Update project matrices + float* dst[] = {leftEye, rightEye}; + VRMatrix enums[] = {VR_PROJECTION_MATRIX_LEFT_EYE, VR_PROJECTION_MATRIX_RIGHT_EYE}; + for (int index = 0; index < 2; index++) { + ovrMatrix4f hmdProjection = VR_GetMatrix(enums[index]); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + if ((hmdProjection.M[i][j] > 0) != (projMatrix[i * 4 + j] > 0)) { + hmdProjection.M[i][j] *= -1.0f; + } + } + } + memcpy(dst[index], hmdProjection.M, 16 * sizeof(float)); + } + + // Set mirroring of axes + VR_SetConfig(VR_CONFIG_MIRROR_AXIS_X, projMatrix[0] < 0); + VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Y, projMatrix[5] < 0); + VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Z, projMatrix[10] > 0); + if ((projMatrix[0] < 0) && (projMatrix[10] < 0)) { //e.g. Dante's inferno + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); + } else if (projMatrix[10] < 0) { //e.g. GTA - Liberty city + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, false); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); + } else if (projMatrix[5] < 0) { //e.g. PES 2014 + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); + } else { //e.g. Lego Pirates + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, true); + } // Set 6DoF scale float scale = pow(fabs(projMatrix[14]), 1.15f); @@ -378,6 +412,19 @@ void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { } void UpdateVRView(float* leftEye, float* rightEye) { - VR_TweakView(leftEye, VR_VIEW_MATRIX_LEFT_EYE); - VR_TweakView(rightEye, VR_VIEW_MATRIX_RIGHT_EYE); + float* dst[] = {leftEye, rightEye}; + VRMatrix enums[] = {VR_VIEW_MATRIX_LEFT_EYE, VR_VIEW_MATRIX_RIGHT_EYE}; + for (int index = 0; index < 2; index++) { + + // Get view matrix from the game + ovrMatrix4f gameView; + memcpy(gameView.M, dst[index], 16 * sizeof(float)); + + // Get view matrix from the headset + ovrMatrix4f hmdView = VR_GetMatrix(enums[index]); + + // Combine the matrices + ovrMatrix4f renderView = ovrMatrix4f_Multiply(&hmdView, &gameView); + memcpy(dst[index], renderView.M, 16 * sizeof(float)); + } } diff --git a/Common/VR/VRTweaks.cpp b/Common/VR/VRTweaks.cpp index 209ef56b6d..050e3c3b84 100644 --- a/Common/VR/VRTweaks.cpp +++ b/Common/VR/VRTweaks.cpp @@ -1,5 +1,5 @@ +#include "VRMath.h" #include "VRTweaks.h" -#include bool VR_TweakIsMatrixBigScale(float* matrix) { for (int i = 0; i < 2; i++) { @@ -43,51 +43,3 @@ bool VR_TweakIsMatrixOneTransform(float* matrix) { } return true; } - -void VR_TweakMirroring(float* projMatrix) { - VR_SetConfig(VR_CONFIG_MIRROR_AXIS_X, projMatrix[0] < 0); - VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Y, projMatrix[5] < 0); - VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Z, projMatrix[10] > 0); - if ((projMatrix[0] < 0) && (projMatrix[10] < 0)) { //e.g. Dante's inferno - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); - } else if (projMatrix[10] < 0) { //e.g. GTA - Liberty city - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, false); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); - } else if (projMatrix[5] < 0) { //e.g. PES 2014 - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); - } else { //e.g. Lego Pirates - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, true); - } -} - -void VR_TweakProjection(float* src, float* dst, VRMatrix matrix) { - ovrMatrix4f hmdProjection = VR_GetMatrix(matrix); - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - if ((hmdProjection.M[i][j] > 0) != (src[i * 4 + j] > 0)) { - hmdProjection.M[i][j] *= -1.0f; - } - } - } - memcpy(dst, hmdProjection.M, 16 * sizeof(float)); -} - -void VR_TweakView(float* view, VRMatrix matrix) { - // Get view matrix from the game - ovrMatrix4f gameView; - memcpy(gameView.M, view, 16 * sizeof(float)); - - // Get view matrix from the headset - ovrMatrix4f hmdView = VR_GetMatrix(matrix); - - // Combine the matrices - ovrMatrix4f renderView = ovrMatrix4f_Multiply(&hmdView, &gameView); - memcpy(view, renderView.M, 16 * sizeof(float)); -} diff --git a/Common/VR/VRTweaks.h b/Common/VR/VRTweaks.h index 173314a86f..1cbdfe347d 100644 --- a/Common/VR/VRTweaks.h +++ b/Common/VR/VRTweaks.h @@ -1,12 +1,7 @@ #pragma once -#include "VRRenderer.h" - bool VR_TweakIsMatrixBigScale(float* matrix); bool VR_TweakIsMatrixIdentity(float* matrix); bool VR_TweakIsMatrixOneOrtho(float* matrix); bool VR_TweakIsMatrixOneScale(float* matrix); bool VR_TweakIsMatrixOneTransform(float* matrix); -void VR_TweakMirroring(float* projMatrix); -void VR_TweakProjection(float* src, float* dst, VRMatrix matrix); -void VR_TweakView(float* view, VRMatrix matrix); From 468a193d6dadc4f758fe5ac428af5dc952c56387 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 17 Oct 2022 18:52:03 +0200 Subject: [PATCH 182/374] OpenXR - Get rid of VR tweaks --- CMakeLists.txt | 2 -- Common/VR/PPSSPPVR.cpp | 23 ++++++++++++++++----- Common/VR/VRTweaks.cpp | 45 ------------------------------------------ Common/VR/VRTweaks.h | 7 ------- 4 files changed, 18 insertions(+), 59 deletions(-) delete mode 100644 Common/VR/VRTweaks.cpp delete mode 100644 Common/VR/VRTweaks.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 28ce455b8a..f0577780a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1106,8 +1106,6 @@ if(ANDROID) Common/VR/VRMath.h Common/VR/VRRenderer.cpp Common/VR/VRRenderer.h - Common/VR/VRTweaks.cpp - Common/VR/VRTweaks.h ) set(nativeExtraLibs ${nativeExtraLibs} openxr) endif() diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index b55d5d011c..c29a8909f8 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -350,11 +350,24 @@ bool IsFlatVRScene() { } bool Is2DVRObject(float* projMatrix, bool ortho) { - bool is2D = VR_TweakIsMatrixBigScale(projMatrix) || - VR_TweakIsMatrixIdentity(projMatrix) || - VR_TweakIsMatrixOneOrtho(projMatrix) || - VR_TweakIsMatrixOneScale(projMatrix) || - VR_TweakIsMatrixOneTransform(projMatrix); + bool isOneTransform = (fabs(fabs(projMatrix[12]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[13]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[14]) - 1.0f) < EPSILON);; + bool isOneScale = (fabs(projMatrix[0] - 1) < EPSILON) && (fabs(projMatrix[5] - 1) < EPSILON); + bool isBigScale = (fabs(projMatrix[0]) > 10.0f) && (fabs(projMatrix[5]) > 10.0f); + bool isOrtho = fabs(projMatrix[15] - 1) < EPSILON; + + bool identity = true; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + float value = projMatrix[i * 4 + j]; + + // Other number than zero on non-diagonale + if ((i != j) && (fabs(value) > EPSILON)) identity = false; + // Other number than one on diagonale + if ((i == j) && (fabs(value - 1.0f) > EPSILON)) identity = false; + } + } + + bool is2D = isBigScale || identity || isOrtho || isOneScale || isOneTransform; if (!is2D && !ortho) { VR_SetConfig(VR_CONFIG_3D_GEOMETRY_COUNT, VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) + 1); } diff --git a/Common/VR/VRTweaks.cpp b/Common/VR/VRTweaks.cpp deleted file mode 100644 index 050e3c3b84..0000000000 --- a/Common/VR/VRTweaks.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "VRMath.h" -#include "VRTweaks.h" - -bool VR_TweakIsMatrixBigScale(float* matrix) { - for (int i = 0; i < 2; i++) { - float value = matrix[i * 4 + i]; - if (fabs(value) < 10.0f) return false; - } - return true; -} - -bool VR_TweakIsMatrixIdentity(float* matrix) { - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - float value = matrix[i * 4 + j]; - - // Other number than zero on non-diagonale - if ((i != j) && (fabs(value) > EPSILON)) return false; - // Other number than one on diagonale - if ((i == j) && (fabs(value - 1.0f) > EPSILON)) return false; - } - } - return true; -} - -bool VR_TweakIsMatrixOneOrtho(float* matrix) { - float value = matrix[15]; - return fabs(value - 1) < EPSILON; -} - -bool VR_TweakIsMatrixOneScale(float* matrix) { - for (int i = 0; i < 2; i++) { - float value = matrix[i * 4 + i]; - if (fabs(value - 1) > EPSILON) return false; - } - return true; -} - -bool VR_TweakIsMatrixOneTransform(float* matrix) { - for (int j = 0; j < 4; j++) { - float value = matrix[12 + j]; - if (fabs(fabs(value) - 1.0f) > EPSILON) return false; - } - return true; -} diff --git a/Common/VR/VRTweaks.h b/Common/VR/VRTweaks.h deleted file mode 100644 index 1cbdfe347d..0000000000 --- a/Common/VR/VRTweaks.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -bool VR_TweakIsMatrixBigScale(float* matrix); -bool VR_TweakIsMatrixIdentity(float* matrix); -bool VR_TweakIsMatrixOneOrtho(float* matrix); -bool VR_TweakIsMatrixOneScale(float* matrix); -bool VR_TweakIsMatrixOneTransform(float* matrix); From 8ed105ff83b63dbcf684767d6ebe5150fab18da6 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 17 Oct 2022 18:57:47 +0200 Subject: [PATCH 183/374] OpenXR - Simplify projection matrix analyze --- Common/VR/PPSSPPVR.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index c29a8909f8..80bbc9a81b 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -6,7 +6,6 @@ #include "Common/VR/VRInput.h" #include "Common/VR/VRMath.h" #include "Common/VR/VRRenderer.h" -#include "Common/VR/VRTweaks.h" #include "Core/HLE/sceDisplay.h" #include "Core/Config.h" @@ -350,11 +349,19 @@ bool IsFlatVRScene() { } bool Is2DVRObject(float* projMatrix, bool ortho) { - bool isOneTransform = (fabs(fabs(projMatrix[12]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[13]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[14]) - 1.0f) < EPSILON);; - bool isOneScale = (fabs(projMatrix[0] - 1) < EPSILON) && (fabs(projMatrix[5] - 1) < EPSILON); - bool isBigScale = (fabs(projMatrix[0]) > 10.0f) && (fabs(projMatrix[5]) > 10.0f); - bool isOrtho = fabs(projMatrix[15] - 1) < EPSILON; + // Quick analyze if the object is in 2D + if ((fabs(fabs(projMatrix[12]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[13]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[14]) - 1.0f) < EPSILON)) { + return true; + } else if ((fabs(projMatrix[0] - 1) < EPSILON) && (fabs(projMatrix[5] - 1) < EPSILON)) { + return true; + } else if ((fabs(projMatrix[0]) > 10.0f) && (fabs(projMatrix[5]) > 10.0f)) { + return true; + } else if (fabs(projMatrix[15] - 1) < EPSILON) { + return true; + } + + // Chceck if the projection matrix is identity bool identity = true; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { @@ -367,11 +374,11 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { } } - bool is2D = isBigScale || identity || isOrtho || isOneScale || isOneTransform; - if (!is2D && !ortho) { + // Update 3D geometry count + if (!identity && !ortho) { VR_SetConfig(VR_CONFIG_3D_GEOMETRY_COUNT, VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) + 1); } - return is2D; + return identity; } void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { From 1a6180583e8d801e67562e0136707de1b2e4dad8 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 17 Oct 2022 19:00:38 +0200 Subject: [PATCH 184/374] OpenXR - Reduce uniform calls --- GPU/GLES/ShaderManagerGLES.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 2148efa5fd..1c7bd4296b 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -363,10 +363,6 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu u64 dirty = dirtyUniforms & availableUniforms; dirtyUniforms = 0; - if (IsVRBuild()) { - dirty |= DIRTY_VIEWMATRIX; - SetVRCompat(VR_COMPAT_FOG_COLOR, gstate.fogcolor); - } if (!dirty) return; @@ -459,6 +455,9 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu } if (dirty & DIRTY_FOGCOLOR) { SetColorUniform3(render_, &u_fogcolor, gstate.fogcolor); + if (IsVRBuild()) { + SetVRCompat(VR_COMPAT_FOG_COLOR, gstate.fogcolor); + } } if (dirty & DIRTY_FOGCOEF) { float fogcoef[2] = { From be2613d495dd903eea8c0e7e480bb03d63702f71 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 17 Oct 2022 19:07:27 +0200 Subject: [PATCH 185/374] OpenXR - Move VR passes count calculation --- Common/GPU/OpenGL/GLRenderManager.cpp | 7 +------ Common/GPU/Vulkan/VulkanRenderManager.cpp | 7 +------ Common/VR/PPSSPPVR.cpp | 8 ++++++++ Common/VR/PPSSPPVR.h | 2 ++ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Common/GPU/OpenGL/GLRenderManager.cpp b/Common/GPU/OpenGL/GLRenderManager.cpp index 01cccb8874..bca19e274f 100644 --- a/Common/GPU/OpenGL/GLRenderManager.cpp +++ b/Common/GPU/OpenGL/GLRenderManager.cpp @@ -5,8 +5,6 @@ #include "Common/Thread/ThreadUtil.h" #include "Common/VR/PPSSPPVR.h" -#include "Core/Config.h" - #include "Common/Log.h" #include "Common/MemoryUtil.h" #include "Common/Math/math_util.h" @@ -580,10 +578,7 @@ void GLRenderManager::Run(int frame) { } if (IsVRBuild()) { - int passes = 1; - if (!IsMultiviewSupported() && g_Config.bEnableStereo) { - passes = 2; - } + int passes = GetVRPassesCount(); for (int i = 0; i < passes; i++) { PreVRFrameRender(i); queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1); diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 4e248a0077..66f3e287e9 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -14,8 +14,6 @@ #include "Common/Thread/ThreadUtil.h" #include "Common/VR/PPSSPPVR.h" -#include "Core/Config.h" - #if 0 // def _DEBUG #define VLOG(...) NOTICE_LOG(G3D, __VA_ARGS__) #else @@ -1282,10 +1280,7 @@ void VulkanRenderManager::Run(VKRRenderThreadTask &task) { frameData.skipSwap = true; //queueRunner_.LogSteps(stepsOnThread, false); if (IsVRBuild()) { - int passes = 1; - if (!IsMultiviewSupported() && g_Config.bEnableStereo) { - passes = 2; - } + int passes = GetVRPassesCount(); for (int i = 0; i < passes; i++) { PreVRFrameRender(i); queueRunner_.RunSteps(task.steps, frameData, frameDataShared_, i < passes - 1); diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 80bbc9a81b..a0807b049a 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -339,6 +339,14 @@ int GetVRFBOIndex() { return VR_GetConfig(VR_CONFIG_CURRENT_FBO); } +int GetVRPassesCount() { + if (!IsMultiviewSupported() && g_Config.bEnableStereo) { + return 2; + } else { + return 1; + } +} + bool IsMultiviewSupported() { return false; } diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index a7b5d8420d..91f5862ff0 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -38,6 +38,7 @@ void FinishVRRender(); void PreVRFrameRender(int fboIndex); void PostVRFrameRender(); int GetVRFBOIndex(); +int GetVRPassesCount(); bool IsMultiviewSupported(); bool IsFlatVRScene(); bool Is2DVRObject(float* projMatrix, bool ortho); @@ -65,6 +66,7 @@ inline void FinishVRRender() {} inline void PreVRFrameRender(int fboIndex) {} inline void PostVRFrameRender() {} inline int GetVRFBOIndex() { return 0; } +inline int GetVRPassesCount() { return 1; } inline bool IsMultiviewSupported() { return false; } inline bool IsFlatVRScene() { return true; } inline bool Is2DVRObject(float* projMatrix, bool ortho) { return false; } From 7c5fc3ccb50cbf0cf17dd19d39d4462e8b82000f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 09:34:26 +0200 Subject: [PATCH 186/374] Reorder the GPU USE flags a bit --- GPU/GLES/DrawEngineGLES.cpp | 1 + GPU/GLES/ShaderManagerGLES.cpp | 2 +- GPU/GPUState.h | 14 +++++--------- GPU/Vulkan/ShaderManagerVulkan.cpp | 2 +- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 8bd39eadb4..dd3395abd2 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -474,6 +474,7 @@ bool DrawEngineGLES::IsCodePtrVertexDecoder(const u8 *ptr) const { return decJitCache_->IsInSpace(ptr); } +// TODO: Refactor this to a single USE flag. bool DrawEngineGLES::SupportsHWTessellation() const { bool hasTexelFetch = gl_extensions.GLES3 || (!gl_extensions.IsGLES && gl_extensions.VersionGEThan(3, 3, 0)) || gl_extensions.EXT_gpu_shader4; return hasTexelFetch && gstate_c.UseAll(GPU_USE_VERTEX_TEXTURE_FETCH | GPU_USE_TEXTURE_FLOAT | GPU_USE_INSTANCE_RENDERING); diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 1c7bd4296b..055d626b28 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -935,7 +935,7 @@ std::string ShaderManagerGLES::DebugGetShaderString(std::string id, DebugShaderT // as sometimes these features might have an effect on the ID bits. #define CACHE_HEADER_MAGIC 0x83277592 -#define CACHE_VERSION 15 +#define CACHE_VERSION 16 struct CacheHeader { uint32_t magic; uint32_t version; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index d34b824c8a..272b39d70e 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -478,7 +478,7 @@ enum { GPU_USE_BLEND_MINMAX = FLAG_BIT(4), GPU_USE_LOGIC_OP = FLAG_BIT(5), GPU_USE_DEPTH_RANGE_HACK = FLAG_BIT(6), - // Free bit: 7 + GPU_USE_TEXTURE_NPOT = FLAG_BIT(7), GPU_USE_ANISOTROPY = FLAG_BIT(8), GPU_USE_CLEAR_RAM_HACK = FLAG_BIT(9), GPU_USE_INSTANCE_RENDERING = FLAG_BIT(10), @@ -486,21 +486,17 @@ enum { GPU_USE_TEXTURE_FLOAT = FLAG_BIT(12), GPU_USE_16BIT_FORMATS = FLAG_BIT(13), GPU_USE_DEPTH_CLAMP = FLAG_BIT(14), - // Free bit: 15 + GPU_USE_TEXTURE_LOD_CONTROL = FLAG_BIT(15), GPU_USE_DEPTH_TEXTURE = FLAG_BIT(16), GPU_USE_ACCURATE_DEPTH = FLAG_BIT(17), GPU_USE_GS_CULLING = FLAG_BIT(18), // Geometry shader - // Free bit: 19 + GPU_USE_REVERSE_COLOR_ORDER = FLAG_BIT(19), GPU_USE_FRAMEBUFFER_FETCH = FLAG_BIT(20), GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT = FLAG_BIT(21), GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT = FLAG_BIT(22), GPU_ROUND_DEPTH_TO_16BIT = FLAG_BIT(23), // Can be disabled either per game or if we use a real 16-bit depth buffer - GPU_USE_TEXTURE_LOD_CONTROL = FLAG_BIT(24), - // Free bits: 25-27 - GPU_USE_TEXTURE_NPOT = FLAG_BIT(28), - GPU_USE_CLIP_DISTANCE = FLAG_BIT(29), - GPU_USE_CULL_DISTANCE = FLAG_BIT(30), - GPU_USE_REVERSE_COLOR_ORDER = FLAG_BIT(31), + GPU_USE_CLIP_DISTANCE = FLAG_BIT(24), + GPU_USE_CULL_DISTANCE = FLAG_BIT(25), }; struct KnownVertexBounds { diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 97eb00c490..72a20476c0 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -482,7 +482,7 @@ VulkanGeometryShader *ShaderManagerVulkan::GetGeometryShaderFromModule(VkShaderM // instantaneous. #define CACHE_HEADER_MAGIC 0xff51f420 -#define CACHE_VERSION 29 +#define CACHE_VERSION 30 struct VulkanCacheHeader { uint32_t magic; uint32_t version; From aa51bfd1eff73f8a8c022aafbd6d84d859600513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 18:36:54 +0200 Subject: [PATCH 187/374] Use GPU "use" flags to replace IsVRBuild in the renderer. It remains elsewhere. --- Common/Common.vcxproj | 77 +++++++++++++++++++++++++++ Common/Common.vcxproj.filters | 45 ++++++++++++++++ Common/GPU/OpenGL/GLQueueRunner.cpp | 2 +- Common/GPU/OpenGL/GLQueueRunner.h | 2 +- Common/GPU/OpenGL/GLRenderManager.cpp | 4 +- Common/GPU/Vulkan/VulkanLoader.cpp | 3 +- GPU/Common/PresentationCommon.cpp | 16 +++--- GPU/Common/VertexShaderGenerator.cpp | 26 ++++----- GPU/GLES/GPU_GLES.cpp | 8 +++ GPU/GLES/ShaderManagerGLES.cpp | 13 +++-- GPU/GPUState.h | 5 ++ UI/NativeApp.cpp | 1 - 12 files changed, 168 insertions(+), 34 deletions(-) diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index aa0f9bb1e7..e5e6a5530a 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -557,6 +557,13 @@ + + + + + + + @@ -989,6 +996,76 @@ + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 0cb9e79423..e04ecff0c8 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -425,6 +425,27 @@ Math + + VR + + + VR + + + VR + + + VR + + + VR + + + VR + + + VR + @@ -803,6 +824,27 @@ Math + + VR + + + VR + + + VR + + + VR + + + VR + + + VR + + + VR + @@ -907,6 +949,9 @@ {7b17065c-729c-47c3-a02d-66dc383529dd} + + {9d1c29fd-8ac7-4475-8ea6-c8c759b695fe} + diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index 47874252e3..84f1b1a375 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -648,7 +648,7 @@ retry_depth: currentReadHandle_ = fbo->handle; } -void GLQueueRunner::RunSteps(const std::vector &steps, bool skipGLCalls, bool keepSteps) { +void GLQueueRunner::RunSteps(const std::vector &steps, bool skipGLCalls, bool keepSteps, bool useVR) { if (skipGLCalls) { if (keepSteps) { return; diff --git a/Common/GPU/OpenGL/GLQueueRunner.h b/Common/GPU/OpenGL/GLQueueRunner.h index 1e009787ae..e9ad214eb4 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.h +++ b/Common/GPU/OpenGL/GLQueueRunner.h @@ -363,7 +363,7 @@ public: void RunInitSteps(const std::vector &steps, bool skipGLCalls); - void RunSteps(const std::vector &steps, bool skipGLCalls, bool keepSteps = false); + void RunSteps(const std::vector &steps, bool skipGLCalls, bool keepSteps, bool useVR); void LogSteps(const std::vector &steps); void CreateDeviceObjects(); diff --git a/Common/GPU/OpenGL/GLRenderManager.cpp b/Common/GPU/OpenGL/GLRenderManager.cpp index bca19e274f..c3d14bb4a7 100644 --- a/Common/GPU/OpenGL/GLRenderManager.cpp +++ b/Common/GPU/OpenGL/GLRenderManager.cpp @@ -581,11 +581,11 @@ void GLRenderManager::Run(int frame) { int passes = GetVRPassesCount(); for (int i = 0; i < passes; i++) { PreVRFrameRender(i); - queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1); + queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, i < passes - 1, true); PostVRFrameRender(); } } else { - queueRunner_.RunSteps(stepsOnThread, skipGLCalls_); + queueRunner_.RunSteps(stepsOnThread, skipGLCalls_, false, false); } stepsOnThread.clear(); diff --git a/Common/GPU/Vulkan/VulkanLoader.cpp b/Common/GPU/Vulkan/VulkanLoader.cpp index b0c2ab370b..52ece65731 100644 --- a/Common/GPU/Vulkan/VulkanLoader.cpp +++ b/Common/GPU/Vulkan/VulkanLoader.cpp @@ -308,8 +308,7 @@ void VulkanSetAvailable(bool available) { } bool VulkanMayBeAvailable() { - - //unsupported in VR at the moment + // Unsupported in VR at the moment if (IsVRBuild()) { return false; } diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index e430374079..b771342e49 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -74,19 +74,21 @@ void CenterDisplayOutputRect(FRect *rc, float origW, float origH, const FRect &f bool rotated = rotation == ROTATION_LOCKED_VERTICAL || rotation == ROTATION_LOCKED_VERTICAL180; + SmallDisplayZoom zoomType = (SmallDisplayZoom)g_Config.iSmallDisplayZoomType; + if (IsVRBuild()) { if (IsFlatVRScene()) { - g_Config.iSmallDisplayZoomType = (int)SmallDisplayZoom::AUTO; + zoomType = SmallDisplayZoom::AUTO; } else { - g_Config.iSmallDisplayZoomType = (int)SmallDisplayZoom::STRETCH; + zoomType = SmallDisplayZoom::STRETCH; } } - if (g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::STRETCH) { + if (zoomType == SmallDisplayZoom::STRETCH) { outW = frame.w; outH = frame.h; } else { - if (g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::MANUAL) { + if (zoomType == SmallDisplayZoom::MANUAL) { float offsetX = (g_Config.fSmallDisplayOffsetX - 0.5f) * 2.0f * frame.w + frame.x; float offsetY = (g_Config.fSmallDisplayOffsetY - 0.5f) * 2.0f * frame.h + frame.y; // Have to invert Y for GL @@ -109,7 +111,7 @@ void CenterDisplayOutputRect(FRect *rc, float origW, float origH, const FRect &f rc->h = floorf(smallDisplayW); return; } - } else if (g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::AUTO) { + } else if (zoomType == SmallDisplayZoom::AUTO) { // Stretch to 1080 for 272*4. But don't distort if not widescreen (i.e. ultrawide of halfwide.) float pixelCrop = frame.h / 270.0f; float resCommonWidescreen = pixelCrop - floor(pixelCrop); @@ -130,13 +132,13 @@ void CenterDisplayOutputRect(FRect *rc, float origW, float origH, const FRect &f outW = frame.w; outH = frame.w / origRatio; // Stretch a little bit - if (!rotated && g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::PARTIAL_STRETCH) + if (!rotated && zoomType == SmallDisplayZoom::PARTIAL_STRETCH) outH = (frame.h + outH) / 2.0f; // (408 + 720) / 2 = 564 } else { // Image is taller than frame. Center horizontally. outW = frame.h * origRatio; outH = frame.h; - if (rotated && g_Config.iSmallDisplayZoomType == (int)SmallDisplayZoom::PARTIAL_STRETCH) + if (rotated && zoomType == SmallDisplayZoom::PARTIAL_STRETCH) outW = (frame.h + outH) / 2.0f; // (408 + 720) / 2 = 564 } } diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 45433a72d7..64258d1103 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -23,7 +23,6 @@ #include "Common/GPU/OpenGL/GLFeatures.h" #include "Common/GPU/ShaderWriter.h" #include "Common/GPU/thin3d.h" -#include "Common/VR/PPSSPPVR.h" #include "Core/Config.h" #include "GPU/ge_constants.h" #include "GPU/GPUState.h" @@ -149,10 +148,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (gl_extensions.ARB_cull_distance && id.Bit(VS_BIT_VERTEX_RANGE_CULLING)) { gl_exts.push_back("#extension GL_ARB_cull_distance : enable"); } + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY) && gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { + gl_exts.push_back("#extension GL_OVR_multiview2 : enable\nlayout(num_views=2) in;"); + } } - if (IsVRBuild() && IsMultiviewSupported()) { - gl_exts.push_back("#extension GL_OVR_multiview2 : enable\nlayout(num_views=2) in;"); - } + ShaderWriter p(buffer, compat, ShaderStage::Vertex, gl_exts.data(), gl_exts.size()); bool isModeThrough = id.Bit(VS_BIT_IS_THROUGH); @@ -480,8 +480,8 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, "uniform mat4 u_proj_through;\n"); *uniformMask |= DIRTY_PROJTHROUGHMATRIX; } else if (useHWTransform) { - if (IsVRBuild()) { - if (IsMultiviewSupported()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { WRITE(p, "layout(shared) uniform ProjectionMatrix { uniform mat4 u_proj_lens[2]; };\n"); } else { WRITE(p, "uniform mat4 u_proj_lens;\n"); @@ -495,7 +495,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag // When transforming by hardware, we need a great deal more uniforms... // TODO: Use 4x3 matrices where possible. Though probably doesn't matter much. WRITE(p, "uniform mat4 u_world;\n"); - if (IsVRBuild() && IsMultiviewSupported()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY) && gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { WRITE(p, "layout(shared) uniform ViewMatrices { uniform mat4 u_view[2]; };\n"); } else { WRITE(p, "uniform mat4 u_view;\n"); @@ -560,7 +560,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, "uniform lowp float u_rotation;\n"); } - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { WRITE(p, "uniform lowp float u_scaleX;\n"); WRITE(p, "uniform lowp float u_scaleY;\n"); } @@ -920,7 +920,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag } std::string matrixPostfix; - if (IsVRBuild() && IsMultiviewSupported()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY) && gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { matrixPostfix = "[gl_ViewID_OVR]"; } @@ -928,14 +928,14 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag // Final view and projection transforms. if (gstate_c.Use(GPU_ROUND_DEPTH_TO_16BIT)) { - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { WRITE(p, " vec4 outPos = depthRoundZVP(mul(u_proj_lens%s, viewPos));\n", matrixPostfix.c_str()); WRITE(p, " vec4 orgPos = depthRoundZVP(mul(u_proj, viewPos));\n"); } else { WRITE(p, " vec4 outPos = depthRoundZVP(mul(u_proj, viewPos));\n"); } } else { - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { WRITE(p, " vec4 outPos = mul(u_proj_lens%s, viewPos);\n", matrixPostfix.c_str()); WRITE(p, " vec4 orgPos = mul(u_proj, viewPos);\n"); } else { @@ -1284,7 +1284,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " }\n"); } - if (vertexRangeCulling && !IsVRBuild()) { + if (vertexRangeCulling && !gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { WRITE(p, " vec3 projPos = outPos.xyz / outPos.w;\n"); WRITE(p, " float projZ = (projPos.z - u_depthRange.z) * u_depthRange.w;\n"); @@ -1325,7 +1325,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag // We've named the output gl_Position in HLSL as well. WRITE(p, " %sgl_Position = outPos;\n", compat.vsOutPrefix); - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { // Z correction for the depth buffer if (useHWTransform) { WRITE(p, " %sgl_Position.z = orgPos.z / abs(orgPos.w) * abs(outPos.w);\n", compat.vsOutPrefix); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index c2740460db..b6b2b6a661 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -22,6 +22,7 @@ #include "Common/Serialize/Serializer.h" #include "Common/File/FileUtil.h" #include "Common/GraphicsContext.h" +#include "Common/VR/PPSSPPVR.h" #include "Core/Config.h" #include "Core/Debugger/Breakpoints.h" @@ -209,6 +210,13 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_FRAGMENT_TEST_CACHE; } + if (IsVRBuild()) { + features |= GPU_USE_VIRTUAL_REALITY; + } + if (IsMultiviewSupported()) { + features |= GPU_USE_SINGLE_PASS_STEREO; + } + return features; } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 055d626b28..db721ab475 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -130,10 +130,9 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs, queries.push_back({ &u_cullRangeMax, "u_cullRangeMax" }); queries.push_back({ &u_rotation, "u_rotation" }); - if (IsVRBuild()) { - queries.push_back({ &u_scaleX, "u_scaleX" }); - queries.push_back({ &u_scaleY, "u_scaleY" }); - } + // These two are only used for VR, but let's always query them for simplicity. + queries.push_back({ &u_scaleX, "u_scaleX" }); + queries.push_back({ &u_scaleY, "u_scaleY" }); #ifdef USE_BONE_ARRAY queries.push_back({ &u_bone, "u_bone" }); @@ -378,7 +377,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu } bool is2D, flatScreen; - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { // Analyze scene is2D = Is2DVRObject(gstate.projMatrix, gstate.isModeThrough()); flatScreen = IsFlatVRScene(); @@ -402,7 +401,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu // Update any dirty uniforms before we draw if (dirty & DIRTY_PROJMATRIX) { - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { Matrix4x4 leftEyeMatrix, rightEyeMatrix; if (flatScreen || is2D) { memcpy(&leftEyeMatrix, gstate.projMatrix, 16 * sizeof(float)); @@ -536,7 +535,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu SetMatrix4x3(render_, &u_world, gstate.worldMatrix); } if (dirty & DIRTY_VIEWMATRIX) { - if (IsVRBuild()) { + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { float leftEyeView[16]; float rightEyeView[16]; ConvertMatrix4x3To4x4Transposed(leftEyeView, gstate.viewMatrix); diff --git a/GPU/GPUState.h b/GPU/GPUState.h index 272b39d70e..e7a15e9536 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -497,6 +497,11 @@ enum { GPU_ROUND_DEPTH_TO_16BIT = FLAG_BIT(23), // Can be disabled either per game or if we use a real 16-bit depth buffer GPU_USE_CLIP_DISTANCE = FLAG_BIT(24), GPU_USE_CULL_DISTANCE = FLAG_BIT(25), + + // VR flags (reserved or in-use) + GPU_USE_VIRTUAL_REALITY = FLAG_BIT(29), + GPU_USE_SINGLE_PASS_STEREO = FLAG_BIT(30), + GPU_USE_SIMPLE_STEREO_PERSPECTIVE = FLAG_BIT(31), }; struct KnownVertexBounds { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 93b11fd53e..36ce962ea4 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1296,7 +1296,6 @@ bool NativeTouch(const TouchInput &touch) { } bool NativeKey(const KeyInput &key) { - // Hack to quickly enable 2D mode in VR game mode. if (IsVRBuild()) { UpdateVRScreenKey(key); From 70488be450eb9eb6a4b4edfcee6cef6f60595936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 18:39:02 +0200 Subject: [PATCH 188/374] Make as much as possible of the VR code build on all platforms --- CMakeLists.txt | 29 +++++------ Common/Common.vcxproj | 95 ++++++----------------------------- Common/Common.vcxproj.filters | 8 +-- Common/VR/PPSSPPVR.cpp | 6 +++ Common/VR/VRBase.cpp | 7 ++- Common/VR/VRBase.h | 32 +++++++++++- Common/VR/VRFramebuffer.cpp | 33 +++++++++--- Common/VR/VRFramebuffer.h | 2 +- Common/VR/VRInput.cpp | 23 +++------ Common/VR/VRMath.cpp | 5 ++ Common/VR/VRRenderer.cpp | 12 +++-- android/jni/Android.mk | 9 ++++ libretro/Makefile.common | 8 +++ 13 files changed, 136 insertions(+), 133 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f0577780a6..b8b323d4ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1092,21 +1092,22 @@ if(ANDROID) android/jni/OpenSLContext.h ) + set(nativeExtra ${nativeExtra} + Common/VR/PPSSPPVR.cpp + Common/VR/PPSSPPVR.h + Common/VR/VRBase.cpp + Common/VR/VRBase.h + Common/VR/VRFramebuffer.cpp + Common/VR/VRFramebuffer.h + Common/VR/VRInput.cpp + Common/VR/VRInput.h + Common/VR/VRMath.cpp + Common/VR/VRMath.h + Common/VR/VRRenderer.cpp + Common/VR/VRRenderer.h + ) + if (OPENXR) - set(nativeExtra ${nativeExtra} - Common/VR/PPSSPPVR.cpp - Common/VR/PPSSPPVR.h - Common/VR/VRBase.cpp - Common/VR/VRBase.h - Common/VR/VRFramebuffer.cpp - Common/VR/VRFramebuffer.h - Common/VR/VRInput.cpp - Common/VR/VRInput.h - Common/VR/VRMath.cpp - Common/VR/VRMath.h - Common/VR/VRRenderer.cpp - Common/VR/VRRenderer.h - ) set(nativeExtraLibs ${nativeExtraLibs} openxr) endif() # No target diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index e5e6a5530a..5c085bd0ed 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -136,7 +136,7 @@ _CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) Common/DbgNew.h MultiThreadedDebug - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib StreamingSIMDExtensions2 Precise true @@ -162,7 +162,7 @@ Common/DbgNew.h MultiThreadedDebug _CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib NotSet Precise false @@ -189,7 +189,7 @@ Common/DbgNew.h MultiThreadedDebug _CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib NotSet Precise false @@ -217,7 +217,7 @@ MultiThreadedDebug _CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib NotSet Precise false @@ -250,7 +250,7 @@ false StreamingSIMDExtensions2 Precise - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib Speed true false @@ -280,7 +280,7 @@ USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib false NotSet Precise @@ -315,7 +315,7 @@ USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib false NotSet Precise @@ -350,7 +350,7 @@ USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions) - ../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib + ../ext/openxr;../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..;../ext/zstd/lib false NotSet Precise @@ -563,7 +563,6 @@ - @@ -996,76 +995,12 @@ - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - - - true - true - true - true - true - true - true - true - + + + + + + @@ -1080,4 +1015,4 @@ - \ No newline at end of file + diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index e04ecff0c8..5c58a6453f 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -443,9 +443,6 @@ VR - - VR - @@ -842,9 +839,6 @@ VR - - VR - @@ -958,4 +952,4 @@ ext\libpng17 - \ No newline at end of file + diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index a0807b049a..abbd78cfdf 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -12,6 +12,8 @@ #include "Core/KeyMap.h" #include "Core/System.h" +#ifdef OPENXR + static long vrCompat[VR_COMPAT_MAX]; /* @@ -99,6 +101,7 @@ bool IsVRBuild() { return true; } +#if PPSSPP_PLATFORM(ANDROID) void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN; @@ -111,6 +114,7 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { __DisplaySetFramerate(72); } +#endif void EnterVR(bool firstStart, void* vulkanContext) { if (firstStart) { @@ -456,3 +460,5 @@ void UpdateVRView(float* leftEye, float* rightEye) { memcpy(dst[index], renderView.M, 16 * sizeof(float)); } } + +#endif diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index abbad01d78..687506aeb5 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -3,9 +3,12 @@ #include #include #include -#include #include +#if PPSSPP_PLATFORM(ANDROID) + +#include + #ifdef OPENXR_PLATFORM_PICO enum ConfigsSetEXT { UNREAL_VERSION = 0, @@ -248,3 +251,5 @@ void VR_LeaveVR( engine_t* engine ) { engine_t* VR_GetEngine( void ) { return &vr_engine; } + +#endif diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 5f9016d7cd..4caa9417ba 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -1,10 +1,14 @@ #pragma once -#ifdef ANDROID +#include "ppsspp_config.h" + +// TODO: Switch to PPSSPP logging +#if PPSSPP_PLATFORM(ANDROID) #include #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, "OpenXR", __VA_ARGS__); #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "OpenXR", __VA_ARGS__); #else +#include #define ALOGE(...) printf(__VA_ARGS__) #define ALOGV(...) printf(__VA_ARGS__) #endif @@ -17,6 +21,7 @@ using namespace PPSSPP_VK; #endif +#if PPSSPP_PLATFORM(ANDROID) //OpenXR #define XR_USE_PLATFORM_ANDROID 1 #define XR_USE_GRAPHICS_API_OPENGL_ES 1 @@ -24,13 +29,29 @@ using namespace PPSSPP_VK; #include #include #include +#elif PPSSPP_PLATFORM(WINDOWS) +#include "Common/CommonWindows.h" +#include +#define XR_USE_PLATFORM_WIN32 1 +#define XR_USE_GRAPHICS_API_OPENGL_ES 1 +#define XR_USE_GRAPHICS_API_VULKAN 1 +#else +#define XR_USE_GRAPHICS_API_OPENGL_ES 1 +#define XR_USE_GRAPHICS_API_VULKAN 1 +#endif + #include #include #include + +#if PPSSPP_PLATFORM(ANDROID) + #include #include -#ifdef _DEBUG +#endif + +#if defined(_DEBUG) && PPSSPP_PLATFORM(ANDROID) static const char* GlErrorString(GLenum error) { switch (error) { case GL_NO_ERROR: @@ -148,6 +169,7 @@ typedef struct { ovrRenderer Renderer; } ovrApp; +#if PPSSPP_PLATFORM(ANDROID) typedef struct { JavaVM* Vm; jobject ActivityObject; @@ -155,17 +177,23 @@ typedef struct { char AppName[64]; int AppVersion; } ovrJava; +#endif typedef struct { uint64_t frameIndex; ovrApp appState; +#if PPSSPP_PLATFORM(ANDROID) ovrJava java; +#endif float predictedDisplayTime; bool useVulkan; XrGraphicsBindingVulkanKHR graphicsBindingVulkan; } engine_t; +#if PPSSPP_PLATFORM(ANDROID) void VR_Init( ovrJava java, bool useVulkan ); +#endif + void VR_Destroy( engine_t* engine ); void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ); void VR_LeaveVR( engine_t* engine ); diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 742e9457c6..8e7828ded8 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -1,14 +1,17 @@ #include "VRFramebuffer.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include + +#if PPSSPP_PLATFORM(ANDROID) #include #include -#include +#endif double FromXrTime(const XrTime time) { return (time * 1e-9); @@ -41,6 +44,8 @@ void ovrFramebuffer_Clear(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = false; } +#if PPSSPP_PLATFORM(ANDROID) + bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview) { frameBuffer->Width = width; @@ -133,6 +138,8 @@ bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int return true; } +#endif + bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview, void* context) { @@ -248,8 +255,10 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { delete[] frameBuffer->VKDepthImages; delete[] frameBuffer->VKFrameBuffers; } else { +#if PPSSPP_PLATFORM(ANDROID) GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers)); free(frameBuffer->GLFrameBuffers); +#endif } OXR(xrDestroySwapchain(frameBuffer->ColorSwapChain.Handle)); OXR(xrDestroySwapchain(frameBuffer->DepthSwapChain.Handle)); @@ -263,7 +272,9 @@ void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { return frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { +#if PPSSPP_PLATFORM(ANDROID) GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); +#endif return nullptr; } } @@ -293,6 +304,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { //TODO:implement } else { +#if PPSSPP_PLATFORM(ANDROID) GL(glEnable( GL_SCISSOR_TEST )); GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); @@ -300,6 +312,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { GL(glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT )); GL(glScissor( 0, 0, 0, 0 )); GL(glDisable( GL_SCISSOR_TEST )); +#endif } } @@ -313,10 +326,12 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { //TODO:implement } else { +#if PPSSPP_PLATFORM(ANDROID) GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); GL(glClear(GL_COLOR_BUFFER_BIT)); GL(glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)); +#endif } } } @@ -342,7 +357,9 @@ void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int if (vulkanContext) { ovrFramebuffer_CreateVK(session, &renderer->FrameBuffer[i], width, height, multiview, vulkanContext); } else { +#if PPSSPP_PLATFORM(ANDROID) ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height, multiview); +#endif } } } @@ -358,12 +375,14 @@ void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { if (renderer->FrameBuffer[0].UseVulkan) { //TODO:implement } else { +#if PPSSPP_PLATFORM(ANDROID) GL(glEnable(GL_SCISSOR_TEST)); GL(glScissor(x, y, size, size)); GL(glViewport(x, y, size, size)); GL(glClearColor(1.0f, 1.0f, 1.0f, 1.0f)); GL(glClear(GL_COLOR_BUFFER_BIT)); GL(glDisable(GL_SCISSOR_TEST)); +#endif } } diff --git a/Common/VR/VRFramebuffer.h b/Common/VR/VRFramebuffer.h index 644a28fe4c..5dd455fd16 100644 --- a/Common/VR/VRFramebuffer.h +++ b/Common/VR/VRFramebuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "VR/VRBase.h" +#include "Common/VR/VRBase.h" void ovrApp_Clear(ovrApp* app); void ovrApp_Destroy(ovrApp* app); diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 2fc8816f61..e07c44fcda 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -1,6 +1,7 @@ #include "VRInput.h" #include -#include + +#include //OpenXR XrPath leftHandPath; @@ -41,20 +42,11 @@ float vibration_channel_intensity[2] = {0.0f, 0.0f}; unsigned long sys_timeBase = 0; int milliseconds(void) { - struct timeval tp; - - gettimeofday(&tp, NULL); - - if (!sys_timeBase) { - sys_timeBase = tp.tv_sec; - return tp.tv_usec/1000; - } - - return (tp.tv_sec - sys_timeBase)*1000 + tp.tv_usec/1000; + return (int)(1000.0 * time_now_d()); } XrTime ToXrTime(const double timeInSeconds) { - return (timeInSeconds * 1e9); + return (XrTime)(timeInSeconds * 1e9); } void INVR_Vibrate( int duration, int chan, float intensity ) { @@ -67,16 +59,15 @@ void INVR_Vibrate( int duration, int chan, float intensity ) { if (vibration_channel_duration[channel] == -1.0f && duration != 0.0f) return; - vibration_channel_duration[channel] = duration; + vibration_channel_duration[channel] = (float)duration; vibration_channel_intensity[channel] = intensity; } } } - void VR_processHaptics() { float lastFrameTime = 0.0f; - float timestamp = (float)(milliseconds( )); + float timestamp = (float)(milliseconds()); float frametime = timestamp - lastFrameTime; lastFrameTime = timestamp; @@ -438,6 +429,6 @@ XrPosef IN_VRGetPose( int controllerIndex ) { XrSpaceLocation loc = {}; loc.type = XR_TYPE_SPACE_LOCATION; XrSpace aimSpace[] = { leftControllerAimSpace, rightControllerAimSpace }; - xrLocateSpace(aimSpace[controllerIndex], engine->appState.CurrentSpace, engine->predictedDisplayTime, &loc); + xrLocateSpace(aimSpace[controllerIndex], engine->appState.CurrentSpace, (XrTime)(engine->predictedDisplayTime), &loc); return loc.pose; } diff --git a/Common/VR/VRMath.cpp b/Common/VR/VRMath.cpp index 204e591fad..df9512d186 100644 --- a/Common/VR/VRMath.cpp +++ b/Common/VR/VRMath.cpp @@ -1,5 +1,10 @@ +#include + #include "VRMath.h" +#include "Common/Math/math_util.h" + + float ToDegrees(float rad) { return (float)(rad / M_PI * 180.0f); } diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 64c388df07..08f44749e4 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -2,9 +2,11 @@ #include "VRInput.h" #include "VRRenderer.h" -#include -#include -#include +#include "Common/Math/math_util.h" + +#include +#include +#include XrFovf fov; XrView* projections; @@ -301,8 +303,8 @@ bool VR_InitFrame( engine_t* engine ) { // Update matrices for (int matrix = 0; matrix < VR_MATRIX_COUNT; matrix++) { if ((matrix == VR_PROJECTION_MATRIX_LEFT_EYE) || (matrix == VR_PROJECTION_MATRIX_RIGHT_EYE)) { - float near = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; - vrMatrix[matrix] = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, near, 0.0f ); + float nearPlane = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; + vrMatrix[matrix] = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, nearPlane, 0.0f ); } else if ((matrix == VR_VIEW_MATRIX_LEFT_EYE) || (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { XrPosef invView = invViewTransform[0]; diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 305caf67a5..333733382e 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -71,6 +71,14 @@ SPIRV_CROSS_FILES := \ $(SRC)/ext/SPIRV-Cross/spirv_parser.cpp \ $(SRC)/ext/SPIRV-Cross/spirv_cross_parsed_ir.cpp +VR_FILES := \ + $(SRC)/Common/VR/PPSSPPVR.cpp \ + $(SRC)/Common/VR/VRBase.cpp \ + $(SRC)/Common/VR/VRFramebuffer.cpp \ + $(SRC)/Common/VR/VRInput.cpp \ + $(SRC)/Common/VR/VRMath.cpp \ + $(SRC)/Common/VR/VRRenderer.cpp + EXT_FILES := \ $(SRC)/ext/cityhash/city.cpp \ $(SRC)/ext/libpng17/png.c \ @@ -115,6 +123,7 @@ EXEC_AND_LIB_FILES := \ $(ARCH_FILES) \ $(EGL_FILES) \ $(VULKAN_FILES) \ + $(VR_FILES) \ $(VMA_FILES) \ $(SPIRV_CROSS_FILES) \ $(EXT_FILES) \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 375792b296..014579eec4 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -314,6 +314,14 @@ SOURCES_CXX += \ $(COMMONDIR)/StringUtils.cpp \ $(COMMONDIR)/TimeUtil.cpp +SOURCES_CXX += \ + $(COMMONDIR)/VRBase.cpp \ + $(COMMONDIR)/VRMath.cpp \ + $(COMMONDIR)/VRFramebuffer.cpp \ + $(COMMONDIR)/VRInput.cpp \ + $(COMMONDIR)/VRMath.cpp \ + $(COMMONDIR)/VRRenderer.cpp + SOURCES_C +=\ $(COMMONDIR)/GPU/OpenGL/gl3stub.c \ $(COMMONDIR)/Math/fast/fast_matrix.c From 2ac0b6d8c1120f393b17afdad9592f2fbdff1e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 19:25:55 +0200 Subject: [PATCH 189/374] CMakeLists.txt fix --- CMakeLists.txt | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8b323d4ee..b9084bea3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,6 @@ add_definitions(-DASSETS_DIR="${CMAKE_INSTALL_FULL_DATADIR}/ppsspp/assets/") if(OPENXR) add_definitions(-DOPENXR) add_library(openxr SHARED IMPORTED) - include_directories(ext/openxr) if(OPENXR_PLATFORM_PICO) add_definitions(-DOPENXR_PLATFORM_PICO) set_property(TARGET openxr PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/ext/openxr/libs/pico/arm64-v8a/libopenxr_loader.so") @@ -507,6 +506,22 @@ if(WIN32) ) endif() +set(CommonVR + Common/VR/PPSSPPVR.cpp + Common/VR/PPSSPPVR.h + Common/VR/VRBase.cpp + Common/VR/VRBase.h + Common/VR/VRFramebuffer.cpp + Common/VR/VRFramebuffer.h + Common/VR/VRInput.cpp + Common/VR/VRInput.h + Common/VR/VRMath.cpp + Common/VR/VRMath.h + Common/VR/VRRenderer.cpp + Common/VR/VRRenderer.h +) +include_directories(ext/openxr) + add_library(Common STATIC ${CommonX86} ${CommonARM} @@ -514,6 +529,7 @@ add_library(Common STATIC ${CommonMIPS} ${CommonRISCV64} ${CommonD3D} + ${CommonVR} Common/Serialize/Serializer.cpp Common/Serialize/Serializer.h Common/Serialize/SerializeDeque.h @@ -1091,22 +1107,6 @@ if(ANDROID) android/jni/OpenSLContext.cpp android/jni/OpenSLContext.h ) - - set(nativeExtra ${nativeExtra} - Common/VR/PPSSPPVR.cpp - Common/VR/PPSSPPVR.h - Common/VR/VRBase.cpp - Common/VR/VRBase.h - Common/VR/VRFramebuffer.cpp - Common/VR/VRFramebuffer.h - Common/VR/VRInput.cpp - Common/VR/VRInput.h - Common/VR/VRMath.cpp - Common/VR/VRMath.h - Common/VR/VRRenderer.cpp - Common/VR/VRRenderer.h - ) - if (OPENXR) set(nativeExtraLibs ${nativeExtraLibs} openxr) endif() From 8df6efa712d1ede8e77f6821ef18a6474ab9b64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 19:27:39 +0200 Subject: [PATCH 190/374] Android non-gradle buildfix --- android/jni/Locals.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/android/jni/Locals.mk b/android/jni/Locals.mk index ef0d118462..beed008585 100644 --- a/android/jni/Locals.mk +++ b/android/jni/Locals.mk @@ -15,6 +15,7 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/../../ext/miniupnp-build \ $(LOCAL_PATH)/../../ext/libpng17 \ $(LOCAL_PATH)/../../ext/libzip \ + $(LOCAL_PATH)/../../ext/openxr \ $(LOCAL_PATH)/../../ext/zstd/lib \ $(LOCAL_PATH)/../../ext/armips \ $(LOCAL_PATH)/../../ext/armips/ext/filesystem/include \ From 0a222345c1225508a5be8ee527f911619a6dda42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 20:43:58 +0200 Subject: [PATCH 191/374] Buildfixes --- Common/VR/VRBase.cpp | 2 +- Common/VR/VRFramebuffer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index 687506aeb5..c30003624b 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -61,7 +61,7 @@ void VR_Init( ovrJava java, bool useVulkan ) { xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid); } - std::vector extensions; + std::vector extensions; if (useVulkan) { extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); } else { diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 8e7828ded8..e917006b51 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -270,7 +270,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { - return frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; + return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { #if PPSSPP_PLATFORM(ANDROID) GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); From 0251f33ec3b1db377c180e9242372c901d5d31f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 17 Oct 2022 23:13:18 +0200 Subject: [PATCH 192/374] Don't use PPSSPP-specific stuff in Common/VR for now. --- Common/File/DirListing.cpp | 2 +- Common/VR/PPSSPPVR.cpp | 4 +-- Common/VR/VRBase.cpp | 2 +- Common/VR/VRBase.h | 18 +++++------- Common/VR/VRFramebuffer.cpp | 20 ++++++------- Common/VR/VRInput.cpp | 4 +++ Common/VR/VRRenderer.cpp | 4 +++ UWP/CommonUWP/CommonUWP.vcxproj | 36 +++++++++++++++-------- UWP/CommonUWP/CommonUWP.vcxproj.filters | 39 +++++++++++++++++++++++++ UWP/Package.appxmanifest | 29 +++++++++++++++--- 10 files changed, 118 insertions(+), 40 deletions(-) diff --git a/Common/File/DirListing.cpp b/Common/File/DirListing.cpp index d17a4f2241..b793e85057 100644 --- a/Common/File/DirListing.cpp +++ b/Common/File/DirListing.cpp @@ -317,7 +317,7 @@ std::vector GetWindowsDrives() { if (logicaldrives & (1 << i)) { - CHAR driveName[] = { TEXT('A') + i, TEXT(':'), TEXT('\\'), TEXT('\0') }; + CHAR driveName[] = { (CHAR)(TEXT('A') + i), TEXT(':'), TEXT('\\'), TEXT('\0') }; std::string str(driveName); drives.push_back(driveName); } diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index abbd78cfdf..384be0b031 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -1,3 +1,5 @@ +#ifdef OPENXR + #include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/GPU/Vulkan/VulkanContext.h" @@ -12,8 +14,6 @@ #include "Core/KeyMap.h" #include "Core/System.h" -#ifdef OPENXR - static long vrCompat[VR_COMPAT_MAX]; /* diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index c30003624b..e0301bb6e6 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -5,7 +5,7 @@ #include #include -#if PPSSPP_PLATFORM(ANDROID) +#if defined(ANDROID) && defined(OPENXR) #include diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 4caa9417ba..b0d7b09f81 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -1,9 +1,7 @@ #pragma once -#include "ppsspp_config.h" - // TODO: Switch to PPSSPP logging -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID #include #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, "OpenXR", __VA_ARGS__); #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "OpenXR", __VA_ARGS__); @@ -21,7 +19,7 @@ using namespace PPSSPP_VK; #endif -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID //OpenXR #define XR_USE_PLATFORM_ANDROID 1 #define XR_USE_GRAPHICS_API_OPENGL_ES 1 @@ -29,7 +27,7 @@ using namespace PPSSPP_VK; #include #include #include -#elif PPSSPP_PLATFORM(WINDOWS) +#elif defined(_WIN32) #include "Common/CommonWindows.h" #include #define XR_USE_PLATFORM_WIN32 1 @@ -44,14 +42,14 @@ using namespace PPSSPP_VK; #include #include -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID #include #include #endif -#if defined(_DEBUG) && PPSSPP_PLATFORM(ANDROID) +#if defined(_DEBUG) && defined(ANDROID) static const char* GlErrorString(GLenum error) { switch (error) { case GL_NO_ERROR: @@ -169,7 +167,7 @@ typedef struct { ovrRenderer Renderer; } ovrApp; -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID typedef struct { JavaVM* Vm; jobject ActivityObject; @@ -182,7 +180,7 @@ typedef struct { typedef struct { uint64_t frameIndex; ovrApp appState; -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID ovrJava java; #endif float predictedDisplayTime; @@ -190,7 +188,7 @@ typedef struct { XrGraphicsBindingVulkanKHR graphicsBindingVulkan; } engine_t; -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID void VR_Init( ovrJava java, bool useVulkan ); #endif diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index e917006b51..2d9db6c3fc 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -8,7 +8,7 @@ #include #include -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID #include #include #endif @@ -44,7 +44,7 @@ void ovrFramebuffer_Clear(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = false; } -#if PPSSPP_PLATFORM(ANDROID) +#ifdef OPENXR bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview) { @@ -138,8 +138,6 @@ bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int return true; } -#endif - bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview, void* context) { @@ -255,7 +253,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { delete[] frameBuffer->VKDepthImages; delete[] frameBuffer->VKFrameBuffers; } else { -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers)); free(frameBuffer->GLFrameBuffers); #endif @@ -272,7 +270,7 @@ void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); #endif return nullptr; @@ -304,7 +302,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { //TODO:implement } else { -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID GL(glEnable( GL_SCISSOR_TEST )); GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); @@ -326,7 +324,7 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { //TODO:implement } else { -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); GL(glClear(GL_COLOR_BUFFER_BIT)); @@ -357,7 +355,7 @@ void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int if (vulkanContext) { ovrFramebuffer_CreateVK(session, &renderer->FrameBuffer[i], width, height, multiview, vulkanContext); } else { -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height, multiview); #endif } @@ -375,7 +373,7 @@ void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { if (renderer->FrameBuffer[0].UseVulkan) { //TODO:implement } else { -#if PPSSPP_PLATFORM(ANDROID) +#ifdef ANDROID GL(glEnable(GL_SCISSOR_TEST)); GL(glScissor(x, y, size, size)); GL(glViewport(x, y, size, size)); @@ -547,3 +545,5 @@ int ovrApp_HandleXrEvents(ovrApp* app) { } return recenter; } + +#endif diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index e07c44fcda..313f9f1d9b 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -3,6 +3,8 @@ #include +#ifdef OPENXR + //OpenXR XrPath leftHandPath; XrPath rightHandPath; @@ -432,3 +434,5 @@ XrPosef IN_VRGetPose( int controllerIndex ) { xrLocateSpace(aimSpace[controllerIndex], engine->appState.CurrentSpace, (XrTime)(engine->predictedDisplayTime), &loc); return loc.pose; } + +#endif diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 08f44749e4..60db7063e1 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -20,6 +20,8 @@ ovrMatrix4f vrMatrix[VR_MATRIX_COUNT]; XrVector3f hmdorientation; XrVector3f hmdposition; +#ifdef OPENXR + void VR_UpdateStageBounds(ovrApp* pappState) { XrExtent2Df stageBounds = {}; @@ -512,3 +514,5 @@ void* VR_BindFramebuffer(engine_t *engine) { ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) { return vrMatrix[matrix]; } + +#endif diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index 09e9173e41..90a1c1649c 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -203,7 +203,7 @@ false false pch.h - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) NotUsing @@ -217,7 +217,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) pch.h NotUsing @@ -232,7 +232,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) pch.h NotUsing @@ -248,7 +248,7 @@ false false pch.h - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) NotUsing @@ -263,7 +263,7 @@ false false pch.h - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) NotUsing @@ -277,7 +277,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) pch.h NotUsing @@ -292,7 +292,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) pch.h NotUsing @@ -307,7 +307,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) pch.h NotUsing @@ -322,7 +322,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_ARM64_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1;%(ClCompile.PreprocessorDefinitions) pch.h NotUsing @@ -338,7 +338,7 @@ false false pch.h - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) NotUsing @@ -352,7 +352,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) pch.h NotUsing @@ -367,7 +367,7 @@ false false - ../..;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) + ../..;../../ext/openxr;../../ext/native;../../ext/snappy;../../ext/glslang;../../ext/zlib;../../ext/libpng17;../../ext/zstd/lib;$(ProjectDir);$(GeneratedFilesDir);$(IntDir);%(AdditionalIncludeDirectories) NOMINMAX;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;%(PreprocessorDefinitions) pch.h NotUsing @@ -502,6 +502,12 @@ + + + + + + @@ -612,6 +618,12 @@ + + + + + + diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index 23de400ce6..dd2f6d6fda 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -85,6 +85,9 @@ {28139b08-f8d5-41a2-a5ee-bf86cf1469c3} + + {a5bfc343-9c3a-43ff-a033-7b0406e13816} + @@ -375,6 +378,24 @@ Math + + VR + + + VR + + + VR + + + VR + + + VR + + + VR + @@ -694,6 +715,24 @@ Math + + VR + + + VR + + + VR + + + VR + + + VR + + + VR + diff --git a/UWP/Package.appxmanifest b/UWP/Package.appxmanifest index dc955c64bb..68b9c930d7 100644 --- a/UWP/Package.appxmanifest +++ b/UWP/Package.appxmanifest @@ -1,9 +1,11 @@  - - + + + - DUMMY - DUMMY + PPSSPP - PSP emulator + Henrik Rydgård + Assets\StoreLogo.png @@ -11,4 +13,23 @@ + + + + + + + + + + + + + + + + + + + From feb4f9477a235f6b2c6b851bffe923332e50c344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 18 Oct 2022 10:35:42 +0200 Subject: [PATCH 193/374] Remove newly added dependencies on PPSSPP --- Common/TimeUtil.cpp | 3 --- Common/VR/VRBase.h | 1 - Common/VR/VRFramebuffer.cpp | 16 +++++++++------- Common/VR/VRFramebuffer.h | 2 +- Common/VR/VRInput.cpp | 36 +++++++++++++++++++++++++++++++----- Common/VR/VRMath.cpp | 5 ++--- Common/VR/VRRenderer.cpp | 2 -- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/Common/TimeUtil.cpp b/Common/TimeUtil.cpp index ad00e1e9a7..ad07fbd18c 100644 --- a/Common/TimeUtil.cpp +++ b/Common/TimeUtil.cpp @@ -21,8 +21,6 @@ // TODO: https://github.com/floooh/sokol/blob/9a6237fcdf213e6da48e4f9201f144bcb2dcb46f/sokol_time.h#L229-L248 -static double curtime = 0; - #ifdef _WIN32 static LARGE_INTEGER frequency; @@ -33,7 +31,6 @@ double time_now_d() { if (frequency.QuadPart == 0) { QueryPerformanceFrequency(&frequency); QueryPerformanceCounter(&startTime); - curtime = 0.0; frequencyMult = 1.0 / static_cast(frequency.QuadPart); } LARGE_INTEGER time; diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index b0d7b09f81..40c377ec84 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -1,6 +1,5 @@ #pragma once -// TODO: Switch to PPSSPP logging #ifdef ANDROID #include #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, "OpenXR", __VA_ARGS__); diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 2d9db6c3fc..3cf70642a9 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -8,7 +8,7 @@ #include #include -#ifdef ANDROID +#if !defined(_WIN32) #include #include #endif @@ -253,7 +253,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { delete[] frameBuffer->VKDepthImages; delete[] frameBuffer->VKFrameBuffers; } else { -#ifdef ANDROID +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers)); free(frameBuffer->GLFrameBuffers); #endif @@ -270,7 +270,7 @@ void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { -#ifdef ANDROID +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); #endif return nullptr; @@ -302,7 +302,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { //TODO:implement } else { -#ifdef ANDROID +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES GL(glEnable( GL_SCISSOR_TEST )); GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); @@ -324,7 +324,7 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { if (frameBuffer->UseVulkan) { //TODO:implement } else { -#ifdef ANDROID +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); GL(glClear(GL_COLOR_BUFFER_BIT)); @@ -355,7 +355,7 @@ void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int if (vulkanContext) { ovrFramebuffer_CreateVK(session, &renderer->FrameBuffer[i], width, height, multiview, vulkanContext); } else { -#ifdef ANDROID +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height, multiview); #endif } @@ -373,7 +373,7 @@ void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { if (renderer->FrameBuffer[0].UseVulkan) { //TODO:implement } else { -#ifdef ANDROID +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES GL(glEnable(GL_SCISSOR_TEST)); GL(glScissor(x, y, size, size)); GL(glViewport(x, y, size, size)); @@ -433,6 +433,8 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { app->SessionActive = (result == XR_SUCCESS); // Set session state once we have entered VR mode and have a valid session object. + + // TODO: This should be a runtime check of the extension's presence, no? #ifdef OPENXR_HAS_PERFORMANCE_EXTENSION if (app->SessionActive) { XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; diff --git a/Common/VR/VRFramebuffer.h b/Common/VR/VRFramebuffer.h index 5dd455fd16..7440e49d70 100644 --- a/Common/VR/VRFramebuffer.h +++ b/Common/VR/VRFramebuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "Common/VR/VRBase.h" +#include "VRBase.h" void ovrApp_Clear(ovrApp* app); void ovrApp_Destroy(ovrApp* app); diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 313f9f1d9b..58571b47f1 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -1,7 +1,5 @@ #include "VRInput.h" -#include - -#include +#include #ifdef OPENXR @@ -41,11 +39,39 @@ XrActionStateVector2f moveJoystickState[2]; float vibration_channel_duration[2] = {0.0f, 0.0f}; float vibration_channel_intensity[2] = {0.0f, 0.0f}; - +#if !defined(_WIN32) unsigned long sys_timeBase = 0; int milliseconds(void) { - return (int)(1000.0 * time_now_d()); + struct timeval tp; + + gettimeofday(&tp, NULL); + + if (!sys_timeBase) { + sys_timeBase = tp.tv_sec; + return tp.tv_usec / 1000; + } + + return (tp.tv_sec - sys_timeBase) * 1000 + tp.tv_usec / 1000; } +#else + +static LARGE_INTEGER frequency; +static double frequencyMult; +static LARGE_INTEGER startTime; + +int milliseconds() { + if (frequency.QuadPart == 0) { + QueryPerformanceFrequency(&frequency); + QueryPerformanceCounter(&startTime); + frequencyMult = 1.0 / static_cast(frequency.QuadPart); + } + LARGE_INTEGER time; + QueryPerformanceCounter(&time); + double elapsed = static_cast(time.QuadPart - startTime.QuadPart); + return (int)(elapsed * frequencyMult * 1000.0); +} + +#endif XrTime ToXrTime(const double timeInSeconds) { return (XrTime)(timeInSeconds * 1e9); diff --git a/Common/VR/VRMath.cpp b/Common/VR/VRMath.cpp index df9512d186..bafdff75ea 100644 --- a/Common/VR/VRMath.cpp +++ b/Common/VR/VRMath.cpp @@ -1,10 +1,9 @@ +#define _USE_MATH_DEFINES + #include #include "VRMath.h" -#include "Common/Math/math_util.h" - - float ToDegrees(float rad) { return (float)(rad / M_PI * 180.0f); } diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 60db7063e1..d4b35c596d 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -2,8 +2,6 @@ #include "VRInput.h" #include "VRRenderer.h" -#include "Common/Math/math_util.h" - #include #include #include From 269eb55c1741ee2caebabf40a8c88656b842cf79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 18 Oct 2022 10:48:16 +0200 Subject: [PATCH 194/374] Build/warning fix --- Common/VR/VRFramebuffer.cpp | 1 - Common/VR/VRInput.cpp | 2 ++ GPU/Common/TextureCacheCommon.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 3cf70642a9..34e3a3cbb4 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -10,7 +10,6 @@ #if !defined(_WIN32) #include -#include #endif double FromXrTime(const XrTime time) { diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 58571b47f1..7ea64f9674 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -40,6 +40,8 @@ float vibration_channel_duration[2] = {0.0f, 0.0f}; float vibration_channel_intensity[2] = {0.0f, 0.0f}; #if !defined(_WIN32) +#include + unsigned long sys_timeBase = 0; int milliseconds(void) { struct timeval tp; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 0ee2c54b10..a0c7180588 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2045,6 +2045,7 @@ static bool CanDepalettize(GETextureFormat texFormat, GEBufferFormat bufferForma } break; case GE_FORMAT_CLUT8: + case GE_FORMAT_INVALID: // Shouldn't happen here. return false; } From eed75889e4e3873143d099f22b8f6f9cf06df0b0 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 18 Oct 2022 12:23:23 +0200 Subject: [PATCH 195/374] OpenXR - Ensure scene analyze is called the same way as before --- GPU/GLES/ShaderManagerGLES.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index db721ab475..3bdd9c4f86 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -362,6 +362,13 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu u64 dirty = dirtyUniforms & availableUniforms; dirtyUniforms = 0; + // Analyze scene + bool is2D, flatScreen; + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { + is2D = Is2DVRObject(gstate.projMatrix, gstate.isModeThrough()); + flatScreen = IsFlatVRScene(); + } + if (!dirty) return; @@ -376,13 +383,8 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu render_->SetUniformUI1(&u_depal_mask_shift_off_fmt, val); } - bool is2D, flatScreen; + // Set HUD mode if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) { - // Analyze scene - is2D = Is2DVRObject(gstate.projMatrix, gstate.isModeThrough()); - flatScreen = IsFlatVRScene(); - - // Set HUD mode bool is3D = gstate.isDepthWriteEnabled(); bool hud = is2D && !is3D && !flatScreen && gstate.isModeThrough() && //2D content requires orthographic projection From fbb1e7eda0ec38fb1e9620d6aa4911d7da46fda8 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 18 Oct 2022 12:39:42 +0200 Subject: [PATCH 196/374] OpenXR - Use only the first projection matrix in frame for mirroing detection --- Common/VR/PPSSPPVR.cpp | 42 +++++++++++++++++++++++------------------- Common/VR/VRRenderer.h | 2 +- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 384be0b031..41101cdd9a 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -321,6 +321,7 @@ bool StartVRRender() { VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.iCanvasDistance); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage); + VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); return true; } return false; @@ -411,25 +412,28 @@ void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { } // Set mirroring of axes - VR_SetConfig(VR_CONFIG_MIRROR_AXIS_X, projMatrix[0] < 0); - VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Y, projMatrix[5] < 0); - VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Z, projMatrix[10] > 0); - if ((projMatrix[0] < 0) && (projMatrix[10] < 0)) { //e.g. Dante's inferno - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); - } else if (projMatrix[10] < 0) { //e.g. GTA - Liberty city - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, false); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); - } else if (projMatrix[5] < 0) { //e.g. PES 2014 - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); - } else { //e.g. Lego Pirates - VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); - VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); - VR_SetConfig(VR_CONFIG_MIRROR_ROLL, true); + if (!VR_GetConfig(VR_CONFIG_MIRROR_UPDATED)) { + VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, true); + VR_SetConfig(VR_CONFIG_MIRROR_AXIS_X, projMatrix[0] < 0); + VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Y, projMatrix[5] < 0); + VR_SetConfig(VR_CONFIG_MIRROR_AXIS_Z, projMatrix[10] > 0); + if ((projMatrix[0] < 0) && (projMatrix[10] < 0)) { //e.g. Dante's inferno + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); + } else if (projMatrix[10] < 0) { //e.g. GTA - Liberty city + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, false); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); + } else if (projMatrix[5] < 0) { //e.g. PES 2014 + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, true); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, false); + } else { //e.g. Lego Pirates + VR_SetConfig(VR_CONFIG_MIRROR_PITCH, false); + VR_SetConfig(VR_CONFIG_MIRROR_YAW, true); + VR_SetConfig(VR_CONFIG_MIRROR_ROLL, true); + } } // Set 6DoF scale diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 7a86adf6b2..16f70d9411 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -9,7 +9,7 @@ enum VRConfig { //camera setup VR_CONFIG_FOV_SCALE, VR_CONFIG_CANVAS_DISTANCE, //6DoF - VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, + VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, VR_CONFIG_MIRROR_PITCH, VR_CONFIG_MIRROR_YAW, VR_CONFIG_MIRROR_ROLL, //2D canvas positioning From 83fccd0835b99144298a1f2efc13c0ba8717276c Mon Sep 17 00:00:00 2001 From: catsout Date: Tue, 18 Oct 2022 20:33:58 +0800 Subject: [PATCH 197/374] SDL: fix glew on wayland by ignore glx glXGetProcAddress works on wayland if linking with x11. As long as we don't use glx related funcs, no_glx_error can be ignored. SDL should handle the no_glx_error brefore glewInit. Glew is only used to init gl funcs. related: https://github.com/nigels-com/glew/issues/172 --- SDL/SDLGLGraphicsContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SDL/SDLGLGraphicsContext.cpp b/SDL/SDLGLGraphicsContext.cpp index 492005a1f4..945c9a950e 100644 --- a/SDL/SDLGLGraphicsContext.cpp +++ b/SDL/SDLGLGraphicsContext.cpp @@ -394,7 +394,9 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std: if (gl_extensions.IsCoreContext) { glewExperimental = true; } - if (GLEW_OK != glewInit()) { + GLenum glew_err = glewInit(); + // glx is not required, igore. + if (glew_err != GLEW_OK && glew_err != GLEW_ERROR_NO_GLX_DISPLAY) { printf("Failed to initialize glew!\n"); return 1; } From f009d150785a9013387494a36ccde5ee0af7ee4e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:33:47 -0700 Subject: [PATCH 198/374] headless: Allow screenshot to not be 512x272. Ended up with a cropped screenshot for a frame dump, which just silently crashed. Could reject, but easy enough to support. --- headless/Compare.cpp | 13 ++++++++----- headless/Compare.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/headless/Compare.cpp b/headless/Compare.cpp index 76254d005a..9c42887342 100644 --- a/headless/Compare.cpp +++ b/headless/Compare.cpp @@ -399,6 +399,7 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) { if (header[0] == 'B' && header[1] == 'M') { reference_ = (u32 *)calloc(stride_ * h_, sizeof(u32)); + referenceStride_ = stride_; asBitmap_ = true; // The bitmap header is 14 + 40 bytes. We could validate it but the test would fail either way. if (reference_ && loader->ReadAt(14 + 40, sizeof(u32), stride_ * h_, reference_) != stride_ * h_) { @@ -424,6 +425,8 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) { reference_ = nullptr; return -1.0f; } + + referenceStride_ = width; } } else { error_ = "Unable to read screenshot: " + screenshotFilename.ToVisualString(); @@ -439,15 +442,15 @@ double ScreenshotComparer::Compare(const Path &screenshotFilename) { if (asBitmap_) { // The reference is flipped and BGRA by default for the common BMP compare case. for (u32 y = 0; y < h_; ++y) { - u32 yoff = y * stride_; + u32 yoff = y * referenceStride_; for (u32 x = 0; x < w_; ++x) errors += ComparePixel(pixels_[y * stride_ + x], reference_[yoff + x]); } } else { // Just convert to BGRA for simplicity. - ConvertRGBA8888ToBGRA8888(reference_, reference_, h_ * stride_); + ConvertRGBA8888ToBGRA8888(reference_, reference_, h_ * referenceStride_); for (u32 y = 0; y < h_; ++y) { - u32 yoff = (h_ - y - 1) * stride_; + u32 yoff = (h_ - y - 1) * referenceStride_; for (u32 x = 0; x < w_; ++x) errors += ComparePixel(pixels_[y * stride_ + x], reference_[yoff + x]); } @@ -486,7 +489,7 @@ bool ScreenshotComparer::SaveVisualComparisonPNG(const Path &resultFilename) { if (asBitmap_) { // The reference is flipped and BGRA by default for the common BMP compare case. for (u32 y = 0; y < h_; ++y) { - u32 yoff = y * stride_; + u32 yoff = y * referenceStride_; u32 comparisonRow = (h_ - y - 1) * 2 * w_ * 2; for (u32 x = 0; x < w_; ++x) { PlotVisualComparison(comparison.get(), comparisonRow + x * 2, pixels_[y * stride_ + x], reference_[yoff + x]); @@ -495,7 +498,7 @@ bool ScreenshotComparer::SaveVisualComparisonPNG(const Path &resultFilename) { } else { // Reference is already in BGRA either way. for (u32 y = 0; y < h_; ++y) { - u32 yoff = (h_ - y - 1) * stride_; + u32 yoff = (h_ - y - 1) * referenceStride_; u32 comparisonRow = (h_ - y - 1) * 2 * w_ * 2; for (u32 x = 0; x < w_; ++x) { PlotVisualComparison(comparison.get(), comparisonRow + x * 2, pixels_[y * stride_ + x], reference_[yoff + x]); diff --git a/headless/Compare.h b/headless/Compare.h index 0ddd702af8..2a59039cdd 100644 --- a/headless/Compare.h +++ b/headless/Compare.h @@ -58,6 +58,7 @@ protected: u32 *reference_ = nullptr; bool asBitmap_ = false; std::string error_; + u32 referenceStride_ = 0; u32 stride_; u32 w_; u32 h_; From 21573f43028ddcf079e93569556e31c83307c436 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:34:59 -0700 Subject: [PATCH 199/374] headless: Fix crash running some tests on Vulkan. If there's no frame display, tests were crashing because no backbuffer present blit happened. This allows those tests to run. --- headless/Headless.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 5b2b8adfd3..ff5c3f94b4 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -203,8 +203,9 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops); PSP_BeginHostFrame(); - if (coreParameter.graphicsContext && coreParameter.graphicsContext->GetDrawContext()) - coreParameter.graphicsContext->GetDrawContext()->BeginFrame(); + Draw::DrawContext *draw = coreParameter.graphicsContext ? coreParameter.graphicsContext->GetDrawContext() : nullptr; + if (draw) + draw->BeginFrame(); bool passed = true; double deadline = time_now_d() + opt.timeout; @@ -238,8 +239,14 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const } PSP_EndHostFrame(); - if (coreParameter.graphicsContext && coreParameter.graphicsContext->GetDrawContext()) - coreParameter.graphicsContext->GetDrawContext()->EndFrame(); + if (draw) { + draw->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); + // Vulkan may get angry if we don't do a final present. + if (gpu) + gpu->CopyDisplayToOutput(true); + + draw->EndFrame(); + } PSP_Shutdown(); From 01896a82755320eb158c6f1958e192101d0bc101 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:35:51 -0700 Subject: [PATCH 200/374] headless: Update passing tests. --- test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 2ae8d9237d..4bc6b25ff9 100755 --- a/test.py +++ b/test.py @@ -163,6 +163,7 @@ tests_good = [ "gpu/primitives/indices", "gpu/primitives/invalidprim", "gpu/primitives/points", + "gpu/primitives/rectangles", "gpu/primitives/trianglefan", "gpu/primitives/trianglestrip", "gpu/primitives/triangles", @@ -186,6 +187,7 @@ tests_good = [ "gpu/textures/mipmap", "gpu/textures/rotate", "gpu/vertices/colors", + "gpu/vertices/texcoords", "hash/hash", "hle/check_not_used_uids", "intr/intr", @@ -412,7 +414,6 @@ tests_next = [ "gpu/primitives/immediate", "gpu/primitives/lines", "gpu/primitives/linestrip", - "gpu/primitives/rectangles", "gpu/primitives/spline", "gpu/reflection/reflection", "gpu/rendertarget/rendertarget", @@ -426,7 +427,6 @@ tests_next = [ "gpu/texmtx/uvs", "gpu/textures/size", "gpu/triangle/triangle", - "gpu/vertices/texcoords", "intr/registersub", "intr/releasesub", "intr/waits", From 95d8b108be6feb168197ad4aca348ec9c0f65114 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:48:49 -0700 Subject: [PATCH 201/374] Kernel: Fix reported StopThread error. Was trying to delete -1, since it was never created. --- Core/HLE/HLEHelperThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HLE/HLEHelperThread.cpp b/Core/HLE/HLEHelperThread.cpp index 0975d1ea96..60f7efb759 100644 --- a/Core/HLE/HLEHelperThread.cpp +++ b/Core/HLE/HLEHelperThread.cpp @@ -26,7 +26,7 @@ #include "Core/HLE/sceKernelMemory.h" #include "Core/MIPS/MIPSCodeUtils.h" -HLEHelperThread::HLEHelperThread() : id_(-1), entry_(0) { +HLEHelperThread::HLEHelperThread() : id_(0), entry_(0) { } HLEHelperThread::HLEHelperThread(const char *threadName, const u32 instructions[], u32 instrCount, u32 prio, int stacksize) { @@ -52,7 +52,7 @@ HLEHelperThread::HLEHelperThread(const char *threadName, const char *module, con } HLEHelperThread::~HLEHelperThread() { - if (id_) + if (id_ > 0) __KernelDeleteThread(id_, SCE_KERNEL_ERROR_THREAD_TERMINATED, "helper deleted"); if (entry_) kernelMemory.Free(entry_); From a42064eb48745b7552282eebbc71313303fc4c08 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 18 Oct 2022 21:52:38 -0700 Subject: [PATCH 202/374] Vulkan: Correct some enum switch warnings. Nice to log debug annotations anyway. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 3 +++ GPU/Vulkan/ShaderManagerVulkan.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 427264b942..98bd2e7773 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1115,6 +1115,9 @@ void VulkanQueueRunner::LogRenderPass(const VKRStep &pass, bool verbose) { case VKRRenderCommand::PUSH_CONSTANTS: INFO_LOG(G3D, " PushConstants(%d)", cmd.push.size); break; + case VKRRenderCommand::DEBUG_ANNOTATION: + INFO_LOG(G3D, " DebugAnnotation(%s)", cmd.debugAnnotation.annotation); + break; case VKRRenderCommand::NUM_RENDER_COMMANDS: break; diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 97eb00c490..21e8f44347 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -81,6 +81,7 @@ static Promise *CompileShaderModuleAsync(VulkanContext *vulkan, case VK_SHADER_STAGE_FRAGMENT_BIT: createTag = "game_fragment"; break; case VK_SHADER_STAGE_GEOMETRY_BIT: createTag = "game_geometry"; break; case VK_SHADER_STAGE_COMPUTE_BIT: createTag = "game_compute"; break; + default: break; } } From 1e343370aed32c1ffe0ba5866228246525a0662f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 20 Oct 2022 10:02:40 +0200 Subject: [PATCH 203/374] Libretro buildfix attempt --- libretro/Makefile.common | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 014579eec4..d205c65f17 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -315,12 +315,13 @@ SOURCES_CXX += \ $(COMMONDIR)/TimeUtil.cpp SOURCES_CXX += \ - $(COMMONDIR)/VRBase.cpp \ - $(COMMONDIR)/VRMath.cpp \ - $(COMMONDIR)/VRFramebuffer.cpp \ - $(COMMONDIR)/VRInput.cpp \ - $(COMMONDIR)/VRMath.cpp \ - $(COMMONDIR)/VRRenderer.cpp + $(COMMONDIR)/VR/PPSSPPVR.cpp \ + $(COMMONDIR)/VR/VRBase.cpp \ + $(COMMONDIR)/VR/VRMath.cpp \ + $(COMMONDIR)/VR/VRFramebuffer.cpp \ + $(COMMONDIR)/VR/VRInput.cpp \ + $(COMMONDIR)/VR/VRMath.cpp \ + $(COMMONDIR)/VR/VRRenderer.cpp SOURCES_C +=\ $(COMMONDIR)/GPU/OpenGL/gl3stub.c \ From 90d395a10dd088d52845e976f8a7c841287391ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 20 Oct 2022 10:15:19 +0200 Subject: [PATCH 204/374] Remove "attachment" parameter from BindFramebufferAsTexture everywhere. Not actually useful since our framebuffer objects don't support multiple color images, and probably won't ever need to. --- Common/GPU/D3D11/thin3d_d3d11.cpp | 4 ++-- Common/GPU/D3D9/thin3d_d3d9.cpp | 4 ++-- Common/GPU/OpenGL/GLRenderManager.cpp | 2 +- Common/GPU/OpenGL/GLRenderManager.h | 2 +- Common/GPU/OpenGL/thin3d_gl.cpp | 6 +++--- Common/GPU/Vulkan/VulkanRenderManager.cpp | 2 +- Common/GPU/Vulkan/VulkanRenderManager.h | 2 +- Common/GPU/Vulkan/thin3d_vulkan.cpp | 7 ++++--- Common/GPU/thin3d.h | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 8 ++++---- GPU/Common/PresentationCommon.cpp | 8 ++++---- GPU/Common/TextureCacheCommon.cpp | 8 ++++---- GPU/GLES/DepthBufferGLES.cpp | 4 ++-- 13 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 0b10980c0f..ddbdecb0aa 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -98,7 +98,7 @@ public: Framebuffer *GetCurrentRenderTarget() override { return curRenderTarget_; } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1701,7 +1701,7 @@ void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const Ren stepId_++; } -void D3D11DrawContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) { +void D3D11DrawContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { _assert_(binding < MAX_BOUND_TEXTURES); D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo; switch (channelBit) { diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 20bcc14e5d..162c8febec 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -535,7 +535,7 @@ public: Framebuffer *GetCurrentRenderTarget() override { return curRenderTarget_; } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; uintptr_t GetFramebufferAPITexture(Framebuffer *fbo, int channelBits, int attachment) override; @@ -1348,7 +1348,7 @@ uintptr_t D3D9Context::GetFramebufferAPITexture(Framebuffer *fbo, int channelBit } } -void D3D9Context::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int color) { +void D3D9Context::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { _assert_(binding < MAX_BOUND_TEXTURES); D3D9Framebuffer *fb = (D3D9Framebuffer *)fbo; switch (channelBit) { diff --git a/Common/GPU/OpenGL/GLRenderManager.cpp b/Common/GPU/OpenGL/GLRenderManager.cpp index c3d14bb4a7..23c133272d 100644 --- a/Common/GPU/OpenGL/GLRenderManager.cpp +++ b/Common/GPU/OpenGL/GLRenderManager.cpp @@ -356,7 +356,7 @@ void GLRenderManager::BindFramebufferAsRenderTarget(GLRFramebuffer *fb, GLRRende } } -void GLRenderManager::BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, int aspectBit, int attachment) { +void GLRenderManager::BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, int aspectBit) { _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER); _dbg_assert_(binding < MAX_GL_TEXTURE_SLOTS); GLRRenderData data{ GLRRenderCommand::BIND_FB_TEXTURE }; diff --git a/Common/GPU/OpenGL/GLRenderManager.h b/Common/GPU/OpenGL/GLRenderManager.h index 51d7e1e9eb..135f776361 100644 --- a/Common/GPU/OpenGL/GLRenderManager.h +++ b/Common/GPU/OpenGL/GLRenderManager.h @@ -526,7 +526,7 @@ public: void BindFramebufferAsRenderTarget(GLRFramebuffer *fb, GLRRenderPassAction color, GLRRenderPassAction depth, GLRRenderPassAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, const char *tag); // Binds a framebuffer as a texture, for the following draws. - void BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, int aspectBit, int attachment); + void BindFramebufferAsTexture(GLRFramebuffer *fb, int binding, int aspectBit); bool CopyFramebufferToMemorySync(GLRFramebuffer *src, int aspectBits, int x, int y, int w, int h, Draw::DataFormat destFormat, uint8_t *pixels, int pixelStride, const char *tag); void CopyImageToMemorySync(GLRTexture *texture, int mipLevel, int x, int y, int w, int h, Draw::DataFormat destFormat, uint8_t *pixels, int pixelStride, const char *tag); diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index bb937379ef..91f89e7807 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -358,7 +358,7 @@ public: Framebuffer *GetCurrentRenderTarget() override { return curRenderTarget_; } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1436,7 +1436,7 @@ bool OpenGLContext::BlitFramebuffer(Framebuffer *fbsrc, int srcX1, int srcY1, in return true; } -void OpenGLContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int color) { +void OpenGLContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { OpenGLFramebuffer *fb = (OpenGLFramebuffer *)fbo; _assert_(binding < MAX_TEXTURE_SLOTS); @@ -1453,7 +1453,7 @@ void OpenGLContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBCh aspect |= GL_STENCIL_BUFFER_BIT; boundTextures_[binding] = &fb->framebuffer_->z_stencil_texture; } - renderManager_.BindFramebufferAsTexture(fb->framebuffer_, binding, aspect, color); + renderManager_.BindFramebufferAsTexture(fb->framebuffer_, binding, aspect); } void OpenGLContext::GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) { diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 66f3e287e9..a3f61976dc 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -1176,7 +1176,7 @@ void VulkanRenderManager::BlitFramebuffer(VKRFramebuffer *src, VkRect2D srcRect, steps_.push_back(step); } -VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBit, int attachment) { +VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBit) { _dbg_assert_(curRenderStep_ != nullptr); // We don't support texturing from stencil, neither do we support texturing from depth|stencil together (nonsensical). diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index a96dd96875..074e0c1db4 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -230,7 +230,7 @@ public: // Returns an ImageView corresponding to a framebuffer. Is called BindFramebufferAsTexture to maintain a similar interface // as the other backends, even though there's no actual binding happening here. - VkImageView BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBits, int attachment); + VkImageView BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBits); void BindCurrentFramebufferAsInputAttachment0(VkImageAspectFlags aspectBits); diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 7d3b0e8218..adfe90d14c 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -408,7 +408,7 @@ public: Framebuffer *GetCurrentRenderTarget() override { return (Framebuffer *)curFramebuffer_.ptr; } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; void BindCurrentFramebufferForColorInput() override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1563,7 +1563,7 @@ void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPass curFramebuffer_ = fb; } -void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) { +void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { VKFramebuffer *fb = (VKFramebuffer *)fbo; _assert_(binding < MAX_BOUND_TEXTURES); @@ -1583,8 +1583,9 @@ void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChanne _assert_(false); break; } + boundTextures_[binding] = nullptr; - boundImageView_[binding] = renderManager_.BindFramebufferAsTexture(fb->GetFB(), binding, aspect, attachment); + boundImageView_[binding] = renderManager_.BindFramebufferAsTexture(fb->GetFB(), binding, aspect); } void VKContext::BindCurrentFramebufferForColorInput() { diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 8c440deb04..2d9ce7f8c5 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -658,7 +658,7 @@ public: virtual Framebuffer *GetCurrentRenderTarget() = 0; // binding must be < MAX_TEXTURE_SLOTS (0, 1 are okay if it's 2). - virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int attachment) = 0; + virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) = 0; // Framebuffer fetch / input attachment support, needs to be explicit in Vulkan. virtual void BindCurrentFramebufferForColorInput() {} diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 295910c4fc..4513493c61 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1168,15 +1168,15 @@ bool FramebufferManagerCommon::BindFramebufferAsColorTexture(int stage, VirtualF copyInfo.fbo = renderCopy; CopyFramebufferForColorTexture(©Info, framebuffer, flags); RebindFramebuffer("After BindFramebufferAsColorTexture"); - draw_->BindFramebufferAsTexture(renderCopy, stage, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(renderCopy, stage, Draw::FB_COLOR_BIT); gpuStats.numCopiesForSelfTex++; } else { // Failed to get temp FBO? Weird. - draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT); } return true; } else if (framebuffer != currentRenderVfb_ || (flags & BINDFBCOLOR_FORCE_SELF) != 0) { - draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT); return true; } else { ERROR_LOG_REPORT_ONCE(selfTextureFail, G3D, "Attempting to texture from target (src=%08x / target=%08x / flags=%d)", framebuffer->fb_address, currentRenderVfb_->fb_address, flags); @@ -3022,7 +3022,7 @@ void FramebufferManagerCommon::BlitUsingRaster( draw_->BindTexture(0, nullptr); // This will get optimized away in case it's already bound (in VK and GL at least..) draw_->BindFramebufferAsRenderTarget(dest, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); - draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, 0); + draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT); if (destX1 == 0.0f && destY1 == 0.0f && destX2 >= destW && destY2 >= destH) { // We overwrite the whole channel of the framebuffer, so we can invalidate the current contents. diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index b771342e49..3fda863d81 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -552,7 +552,7 @@ void PresentationCommon::BindSource(int binding) { if (srcTexture_) { draw_->BindTexture(binding, srcTexture_); } else if (srcFramebuffer_) { - draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT); } else { _assert_(false); } @@ -671,13 +671,13 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u PostShaderUniforms uniforms; const auto performShaderPass = [&](const ShaderInfo *shaderInfo, Draw::Framebuffer *postShaderFramebuffer, Draw::Pipeline *postShaderPipeline) { if (postShaderOutput) { - draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT); } else { BindSource(0); } BindSource(1); if (shaderInfo->usePreviousFrame) - draw_->BindFramebufferAsTexture(previousFramebuffer, 2, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(previousFramebuffer, 2, Draw::FB_COLOR_BIT); int nextWidth, nextHeight; draw_->GetFramebufferDimensions(postShaderFramebuffer, &nextWidth, &nextHeight); @@ -765,7 +765,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u draw_->BindPipeline(pipeline); if (postShaderOutput) { - draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT); } else { BindSource(0); } diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index a0c7180588..3877b2df22 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2197,7 +2197,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer Draw::Viewport vp{ 0.0f, 0.0f, (float)depalWidth, (float)framebuffer->renderHeight, 0.0f, 1.0f }; draw_->SetViewports(1, &vp); - draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT); draw_->BindTexture(1, clutTexture.texture); Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false); Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(smoothedDepal); @@ -2213,7 +2213,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer draw_->BindTexture(0, nullptr); framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT); BoundFramebufferTexture(); const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); @@ -2299,7 +2299,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { draw_->SetViewports(1, &vp); draw_->BindNativeTexture(0, GetNativeTextureView(entry)); - draw_->BindFramebufferAsTexture(dynamicClutFbo_, 1, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(dynamicClutFbo_, 1, Draw::FB_COLOR_BIT); Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false); Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(false); draw_->BindSamplerStates(0, 1, &nearest); @@ -2314,7 +2314,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { draw_->BindTexture(0, nullptr); framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT); BoundFramebufferTexture(); const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 7be1adf9d3..5f783e48c7 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -208,7 +208,7 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); - draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_DEPTH_BIT, 0); + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_DEPTH_BIT); draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &depthReadbackSampler_); // We must bind the program after starting the render pass. @@ -326,7 +326,7 @@ bool FramebufferManagerGLES::ReadbackStencilbufferSync(Draw::Framebuffer *fbo, i Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); - draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_STENCIL_BIT, 0); + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_STENCIL_BIT); draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &stencilReadbackSampler_); // We must bind the program after starting the render pass. From 2b182417638e0263260f53a0aaa764cd7d7dd427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 20 Oct 2022 10:48:20 +0200 Subject: [PATCH 205/374] Libretro buildfix attempt again --- libretro/Makefile.common | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro/Makefile.common b/libretro/Makefile.common index d205c65f17..7a8fd74121 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -16,6 +16,7 @@ INCFLAGS += \ -I$(CORE_DIR) \ -I$(COMMONDIR) \ -I$(CORE_DIR)/libretro \ + -I$(EXTDIR)/openxr \ -I$(EXTDIR)/glslang \ -I$(EXTDIR)/native \ -I$(EXTDIR)/zlib \ From 9a01db5f422c41eaadc60e1997ee34c7ee27fa6c Mon Sep 17 00:00:00 2001 From: fp64 <106717720+fp64@users.noreply.github.com> Date: Thu, 20 Oct 2022 06:53:49 -0400 Subject: [PATCH 206/374] Change wrap_mode to clamp for bicubic upscaler It was set to wrap, even though the comment claimed otherwise. Previous implementation had clamp, as do (I think) other upscaling modes (Hybrid, etc.). Also make upscaler codestyle a little more consistent with the rest. --- GPU/Common/TextureScalerCommon.cpp | 46 +++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/GPU/Common/TextureScalerCommon.cpp b/GPU/Common/TextureScalerCommon.cpp index 3c6e946c2f..94624828e6 100644 --- a/GPU/Common/TextureScalerCommon.cpp +++ b/GPU/Common/TextureScalerCommon.cpp @@ -211,10 +211,10 @@ static void load_sample(ptrdiff_t w, ptrdiff_t h, ptrdiff_t s, const u8 *pixels, // equivalent to a>=0&&a= (size_t)w||(size_t)y >= (size_t)h) { + if((size_t)x >= (size_t)w || (size_t)y >= (size_t)h) { switch(wrap_mode) { case 0: // Wrap - if(!((w&(w-1))|(h&(h-1)))) { + if(!((w & (w-1)) | (h & (h-1)))) { // Both w and h are powers of 2. x &= w-1; y &= h-1; @@ -239,7 +239,7 @@ static void load_sample(ptrdiff_t w, ptrdiff_t h, ptrdiff_t s, const u8 *pixels, break; } } - memcpy(output, pixels+s*y+4*x, 4); + memcpy(output, pixels + s*y + 4*x, 4); } #define BLOCK 8 @@ -260,7 +260,7 @@ static void init_block( float w00 = B/6.0f , w01 = -C-0.5f*B, w02 = 2.0f*C+0.5f*B , w03 = -C-B/6.0f ; float w10 = 1.0f-B/3.0f,/*w11 = 0.0f ,*/w12 = C+2.0f*B-3.0f , w13 = -C-1.5f*B+2.0f; float w20 = B/6.0f , w21 = C+0.5f*B, w22 = -2.0f*C-2.5f*B+3.0f, w23 = C+1.5f*B-2.0f; - float /*w30 = 0.0f , w31 = 0.0f ,*/w32 = -C , w33 = C+B/6.0f ; + float /*w30 = 0.0f , w31 = 0.0f ,*/w32 = -C , w33 = C+B/6.0f ; // Express the sampling position as a rational // number num/den-1 (off by one, so that num is // always positive, since the C language does @@ -269,9 +269,9 @@ static void init_block( ptrdiff_t den = 2*factor; float inv_den = 1.0f/(float)den; for(int dir = 0; dir < 2; ++dir) { - ptrdiff_t num = (dir?2*y0+1+factor:2*x0+1+factor); - ptrdiff_t *l = (dir?ly:lx), *l0 = (dir?ly0:lx0), *s = (dir?sy:sx); - float (*c)[4] = (dir?cy:cx); + ptrdiff_t num = (dir ? 2*y0+1+factor : 2*x0+1+factor); + ptrdiff_t *l = (dir ? ly : lx), *l0 = (dir ? ly0 : lx0), *s = (dir ? sy : sx); + float (*c)[4] = (dir ? cy : cx); (*l0) = num/den-2; num = num%den; for(ptrdiff_t i = 0, j = 0; i < BLOCK; ++i) { @@ -288,13 +288,13 @@ static void init_block( (*s) = l[BLOCK-1]+4; // Total sampled src pixels in {x|y} direction. } // Get a local copy of the source pixels. - if((*lx0) >=0 && (*ly0) >= 0 && *lx0+(*sx) <= w && *ly0+(*sy) <= h) { + if((*lx0) >=0 && (*ly0) >= 0 && *lx0 + (*sx) <= w && *ly0 + (*sy) <= h) { for(ptrdiff_t iy = 0; iy < (*sy); ++iy) - memcpy(src[iy], src_pixels+src_stride*((*ly0)+iy)+4*(*lx0), (size_t)(4*(*sx))); + memcpy(src[iy], src_pixels+src_stride*((*ly0) + iy) + 4*(*lx0), (size_t)(4*(*sx))); } else { for(ptrdiff_t iy = 0; iy < (*sy); ++iy) for(ptrdiff_t ix = 0; ix < (*sx); ++ix) - load_sample(w, h, src_stride, src_pixels, wrap_mode, (*lx0)+ix, (*ly0)+iy, src[iy]+4*ix); + load_sample(w, h, src_stride, src_pixels, wrap_mode, (*lx0) + ix, (*ly0) + iy, src[iy] + 4*ix); } } @@ -315,10 +315,10 @@ static void upscale_block_c( for(ptrdiff_t iy = 0; iy < sy; ++iy) for(ptrdiff_t ix = 0; ix < sx; ++ix) for(ptrdiff_t k = 0; k < 4; ++k) - buf[0][iy][ix][k] = (float)(int)src[iy][4*ix+k]; + buf[0][iy][ix][k] = (float)(int)src[iy][4*ix + k]; // Horizontal pass. for(ptrdiff_t ix = 0; ix < BLOCK; ++ix) { - #define S(i) (buf[0][iy][lx[ix]+i][k]) + #define S(i) (buf[0][iy][lx[ix] + i][k]) float C0 = cx[ix][0], C1 = cx[ix][1], C2 = cx[ix][2], C3 = cx[ix][3]; for(ptrdiff_t iy = 0; iy < sy; ++iy) for(ptrdiff_t k = 0; k < 4; ++k) @@ -342,9 +342,9 @@ static void upscale_block_c( float C = buf[0][iy][ix][k]; if(!(C>0.0f)) C = 0.0f; if(C>255.0f) C = 255.0f; - pixel[k] = (u8)(int)(C+0.5f); + pixel[k] = (u8)(int)(C + 0.5f); } - memcpy(dst_pixels+4*(BLOCK*iy+ix), pixel, 4); + memcpy(dst_pixels + 4*(BLOCK*iy + ix), pixel, 4); } } @@ -377,7 +377,7 @@ static void upscale_block_sse2( for(ptrdiff_t iy = 0; iy < sy; ++iy) for(ptrdiff_t ix = 0; ix < sx; ++ix) { int pixel; - memcpy(&pixel, src[iy]+4*ix, 4); + memcpy(&pixel, src[iy] + 4*ix, 4); __m128i C = _mm_cvtsi32_si128(pixel); C = _mm_unpacklo_epi8(C, _mm_set1_epi32(0)); C = _mm_unpacklo_epi8(C, _mm_set1_epi32(0)); @@ -385,7 +385,7 @@ static void upscale_block_sse2( } // Horizontal pass. for(ptrdiff_t ix = 0; ix < BLOCK; ++ix) { - #define S(i) (buf[0][iy][lx[ix]+i]) + #define S(i) (buf[0][iy][lx[ix] + i]) __m128 C0 = _mm_set1_ps(cx[ix][0]), C1 = _mm_set1_ps(cx[ix][1]), C2 = _mm_set1_ps(cx[ix][2]), @@ -395,12 +395,12 @@ static void upscale_block_sse2( _mm_add_ps(_mm_mul_ps(_mm_loadu_ps(S(0)), C0), _mm_add_ps(_mm_mul_ps(_mm_loadu_ps(S(1)), C1), _mm_add_ps(_mm_mul_ps(_mm_loadu_ps(S(2)), C2), - _mm_mul_ps(_mm_loadu_ps(S(3)), C3))))); + _mm_mul_ps(_mm_loadu_ps(S(3)), C3))))); #undef S } // Vertical pass. for(ptrdiff_t iy = 0; iy < BLOCK; ++iy) { - #define S(i) (buf[1][ly[iy]+i][ix]) + #define S(i) (buf[1][ly[iy] + i][ix]) __m128 C0 = _mm_set1_ps(cy[iy][0]), C1 = _mm_set1_ps(cy[iy][1]), C2 = _mm_set1_ps(cy[iy][2]), @@ -410,7 +410,7 @@ static void upscale_block_sse2( _mm_add_ps(_mm_mul_ps(_mm_loadu_ps(S(0)), C0), _mm_add_ps(_mm_mul_ps(_mm_loadu_ps(S(1)), C1), _mm_add_ps(_mm_mul_ps(_mm_loadu_ps(S(2)), C2), - _mm_mul_ps(_mm_loadu_ps(S(3)), C3))))); + _mm_mul_ps(_mm_loadu_ps(S(3)), C3))))); #undef S } // Pack destination pixels. @@ -423,7 +423,7 @@ static void upscale_block_sse2( R = _mm_packus_epi16(R, R); R = _mm_packus_epi16(R, R); int pixel = _mm_cvtsi128_si32(R); - memcpy(dst_pixels+4*(BLOCK*iy+ix), &pixel, 4); + memcpy(dst_pixels + 4*(BLOCK*iy+ix), &pixel, 4); } } #endif // defined(_M_SSE) @@ -442,7 +442,7 @@ static void upscale_cubic( upscale_block_c (width, height, src_stride_in_bytes, (const u8*)src_pixels, wrap_mode, scale, B, C, x, y, pixels); #endif for(ptrdiff_t iy = 0, ny = (y1-y < BLOCK?y1-y:BLOCK), nx = (x1-x < BLOCK?x1-x:BLOCK); iy < ny; ++iy) - memcpy((u8*)dst_pixels+dst_stride_in_bytes*(y+iy)+4*x, pixels+BLOCK*4*iy, (size_t)(4*nx)); + memcpy((u8*)dst_pixels + dst_stride_in_bytes*(y+iy) + 4*x, pixels + BLOCK*4*iy, (size_t)(4*nx)); } } @@ -450,7 +450,7 @@ static void upscale_cubic( void scaleBicubicBSpline(int factor, u32* data, u32* out, int w, int h, int l, int u) { const float B = 1.0f, C = 0.0f; - const int wrap_mode = 0; // Clamp + const int wrap_mode = 1; // Clamp upscale_cubic( w, h, w*4, data, factor*w*4, out, @@ -460,7 +460,7 @@ void scaleBicubicBSpline(int factor, u32* data, u32* out, int w, int h, int l, i void scaleBicubicMitchell(int factor, u32* data, u32* out, int w, int h, int l, int u) { const float B = 0.0f, C = 0.5f; // Actually, Catmull-Rom - const int wrap_mode = 0; // Clamp + const int wrap_mode = 1; // Clamp upscale_cubic( w, h, w*4, data, factor*w*4, out, From 2c814c568a91e30367a35b37c9c4daf43e0865f9 Mon Sep 17 00:00:00 2001 From: fp64 <106717720+fp64@users.noreply.github.com> Date: Thu, 20 Oct 2022 06:59:35 -0400 Subject: [PATCH 207/374] Some more codestyle cleanup --- GPU/Common/TextureScalerCommon.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/GPU/Common/TextureScalerCommon.cpp b/GPU/Common/TextureScalerCommon.cpp index 94624828e6..257836d4f3 100644 --- a/GPU/Common/TextureScalerCommon.cpp +++ b/GPU/Common/TextureScalerCommon.cpp @@ -322,7 +322,7 @@ static void upscale_block_c( float C0 = cx[ix][0], C1 = cx[ix][1], C2 = cx[ix][2], C3 = cx[ix][3]; for(ptrdiff_t iy = 0; iy < sy; ++iy) for(ptrdiff_t k = 0; k < 4; ++k) - buf[1][iy][ix][k] = S(0)*C0+S(1)*C1+S(2)*C2+S(3)*C3; + buf[1][iy][ix][k] = S(0)*C0 + S(1)*C1 + S(2)*C2 + S(3)*C3; #undef S } // Vertical pass. @@ -331,7 +331,7 @@ static void upscale_block_c( float C0 = cy[iy][0], C1 = cy[iy][1], C2 = cy[iy][2], C3 = cy[iy][3]; for(ptrdiff_t ix = 0; ix < BLOCK; ++ix) for(ptrdiff_t k = 0; k < 4; ++k) - buf[0][iy][ix][k] = S(0)*C0+S(1)*C1+S(2)*C2+S(3)*C3; + buf[0][iy][ix][k] = S(0)*C0 + S(1)*C1 + S(2)*C2 + S(3)*C3; #undef S } // Pack destination pixels. @@ -429,8 +429,8 @@ static void upscale_block_sse2( #endif // defined(_M_SSE) static void upscale_cubic( - ptrdiff_t width, ptrdiff_t height, ptrdiff_t src_stride_in_bytes, const void *src_pixels, - ptrdiff_t dst_stride_in_bytes, void *dst_pixels, + ptrdiff_t width, ptrdiff_t height, ptrdiff_t src_stride_in_bytes, const void *src_pixels, + ptrdiff_t dst_stride_in_bytes, void *dst_pixels, ptrdiff_t scale, float B, float C, int wrap_mode, ptrdiff_t x0, ptrdiff_t y0, ptrdiff_t x1, ptrdiff_t y1) { u8 pixels[BLOCK*BLOCK*4]; @@ -441,7 +441,7 @@ static void upscale_cubic( #else upscale_block_c (width, height, src_stride_in_bytes, (const u8*)src_pixels, wrap_mode, scale, B, C, x, y, pixels); #endif - for(ptrdiff_t iy = 0, ny = (y1-y < BLOCK?y1-y:BLOCK), nx = (x1-x < BLOCK?x1-x:BLOCK); iy < ny; ++iy) + for(ptrdiff_t iy = 0, ny = (y1-y < BLOCK ? y1-y : BLOCK), nx = (x1-x < BLOCK ? x1-x : BLOCK); iy < ny; ++iy) memcpy((u8*)dst_pixels + dst_stride_in_bytes*(y+iy) + 4*x, pixels + BLOCK*4*iy, (size_t)(4*nx)); } } From 3009c6ee1a58a26b4e101f5c4420d4eadd3652a3 Mon Sep 17 00:00:00 2001 From: xujibbs <79200793+xujibbs@users.noreply.github.com> Date: Thu, 20 Oct 2022 19:45:33 +0800 Subject: [PATCH 208/374] Update zh_CN.ini --- assets/lang/zh_CN.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index 486a2d5230..e095a43345 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -714,6 +714,7 @@ Up = 方向键:上 Vol + = 音量+ Vol - = 音量- Wlan = 无线网络 +Analog speed = 模拟速度 [MemStick] Already contains PSP data = 已含有PSP数据 From 77f8f2f1f7b80ccb160deb09077f066e10db6689 Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 20 Oct 2022 21:04:56 +0200 Subject: [PATCH 209/374] OpenXR - Rearrange VR settings --- UI/GameSettingsScreen.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 153f03d69c..a02190445a 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1123,14 +1123,15 @@ void GameSettingsScreen::CreateViews() { if (deviceType == DEVICE_TYPE_VR) { LinearLayout *vrSettings = AddTab("GameSettingsVR", ms->T("VR")); vrSettings->Add(new ItemHeader(vr->T("Virtual reality"))); - vrSettings->Add(new CheckBox(&g_Config.bEnableVR, vr->T("Enable virtual reality"))); - vrSettings->Add(new PopupSliderChoice(&g_Config.iCanvasDistance, 1, 10, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1, screenManager(), "")); - CheckBox *vr6DoF = vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("Enable 6 degrees of freedom movement"))); + vrSettings->Add(new CheckBox(&g_Config.bEnableVR, vr->T("Virtual reality"))); + CheckBox *vr6DoF = vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("6DoF movement"))); vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); - PopupSliderChoice *vrFieldOfView = vrSettings->Add(new PopupSliderChoice(&g_Config.iFieldOfViewPercentage, 100, 200, vr->T("Field of view scale", "Headset's field of view scale"), 10, screenManager(), vr->T("% of native FoV"))); - vrFieldOfView->SetEnabledPtr(&g_Config.bEnableVR); - CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Enable stereoscopic vision (Experimental)"))); + CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); vrStereo->SetEnabledPtr(&g_Config.bEnableVR); + + vrSettings->Add(new ItemHeader(vr->T("VR camera"))); + vrSettings->Add(new PopupSliderChoice(&g_Config.iCanvasDistance, 1, 10, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1, screenManager(), "")); + vrSettings->Add(new PopupSliderChoice(&g_Config.iFieldOfViewPercentage, 100, 200, vr->T("Field of view scale", "Headset's field of view scale"), 10, screenManager(), vr->T("% of native FoV"))); } } From 2fd6438c0e515ca29995dbef5a07987b916f4adf Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 20 Oct 2022 21:23:27 +0200 Subject: [PATCH 210/374] OpenXR - Camera distance adjust added --- Common/VR/PPSSPPVR.cpp | 1 + Common/VR/VRRenderer.cpp | 8 ++++++++ Common/VR/VRRenderer.h | 2 +- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 1 + 6 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 41101cdd9a..edb88a3400 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -319,6 +319,7 @@ bool StartVRRender() { // Set customizations VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); + VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.iCameraDistance); VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.iCanvasDistance); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index d4b35c596d..5a8084941b 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -338,6 +338,14 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix].M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; } + if (abs(vrConfig[VR_CONFIG_CAMERA_DISTANCE]) > 0) { + XrVector3f forward = {0.0f, 0.0f, (float)vrConfig[VR_CONFIG_CAMERA_DISTANCE] * scale}; + forward = XrQuaternionf_Rotate(invView.orientation, forward); + forward = XrVector3f_ScalarMultiply(forward, vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f); + vrMatrix[matrix].M[0][3] += forward.x; + vrMatrix[matrix].M[1][3] += forward.y; + vrMatrix[matrix].M[2][3] += forward.z; + } if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 16f70d9411..1c93f98752 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -7,7 +7,7 @@ enum VRConfig { //switching between 2D and 3D VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup - VR_CONFIG_FOV_SCALE, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_DISTANCE, VR_CONFIG_CANVAS_DISTANCE, //6DoF VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, diff --git a/Core/Config.cpp b/Core/Config.cpp index 650e1812fa..1e44ed482b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1206,6 +1206,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable", &g_Config.bEnableVR, true), ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), + ConfigSetting("VRCameraDistance", &g_Config.iCameraDistance, 0), ConfigSetting("VRCanvasDistance", &g_Config.iCanvasDistance, 6), ConfigSetting("VRFieldOfView", &g_Config.iFieldOfViewPercentage, 100), diff --git a/Core/Config.h b/Core/Config.h index 10748583a9..497e8266bd 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -457,6 +457,7 @@ public: bool bEnableVR; bool bEnable6DoF; bool bEnableStereo; + int iCameraDistance; int iCanvasDistance; int iFieldOfViewPercentage; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a02190445a..158fc547d0 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1130,6 +1130,7 @@ void GameSettingsScreen::CreateViews() { vrStereo->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); + vrSettings->Add(new PopupSliderChoice(&g_Config.iCameraDistance, -10, 10, vr->T("Camera distance adjust", "Camera distance adjust"), 1, screenManager(), "")); vrSettings->Add(new PopupSliderChoice(&g_Config.iCanvasDistance, 1, 10, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1, screenManager(), "")); vrSettings->Add(new PopupSliderChoice(&g_Config.iFieldOfViewPercentage, 100, 200, vr->T("Field of view scale", "Headset's field of view scale"), 10, screenManager(), vr->T("% of native FoV"))); } From e048c5ded88d1b9e2da623ea79423d7af7cfbc1b Mon Sep 17 00:00:00 2001 From: leoxxx <5364709+leoxxx@users.noreply.github.com> Date: Fri, 21 Oct 2022 10:15:17 +0800 Subject: [PATCH 211/374] Update zh_CN.ini https://github.com/hrydgard/ppsspp/pull/15694 Translate "artifacts" to a straightaway meaning. --- assets/lang/zh_CN.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index e095a43345..9ca27412e8 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -517,7 +517,7 @@ Linear = 线性过滤 Low = 低 LowCurves = 低品质样条函数/贝塞尔曲线(提速) LowCurves Tip = 仅对部分游戏有效, 控制曲线的平滑度 -Lower resolution for effects (reduces artifacts) = 降低特效分辨率(减少失真) +Lower resolution for effects (reduces artifacts) = 降低特效分辨率(减少图像错误) Manual Scaling = 手动缩放 Medium = 中 Mode = 渲染模式 From ad06868a13e7d42afd2430f5000420f4526c6a02 Mon Sep 17 00:00:00 2001 From: leoxxx <5364709+leoxxx@users.noreply.github.com> Date: Fri, 21 Oct 2022 10:21:48 +0800 Subject: [PATCH 212/374] Update zh_TW.ini #15694 Translate "artifacts" to a straightaway meaning. Change 2 words to TC. --- assets/lang/zh_TW.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 3559284b19..6f57d92d16 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -516,12 +516,12 @@ Hybrid + Bicubic = 混合+雙立方 Ignore camera notch when centering = 居中時忽略攝像頭缺口 Internal Resolution = 內部分辨率 Lazy texture caching = 緩慢紋理快取(提升速度) -Lazy texture caching Tip = 更快,在一些游戲裏會引起文字渲染錯誤更快, 在一些游戏里引起文字渲染错误 +Lazy texture caching Tip = 更快,在一些游戲裏會引起文字渲染錯誤更快, 在一些游戏里引起文字渲染錯誤 Linear = 線性 Low = 低 LowCurves = 樣條函數/貝茲曲線品質 LowCurves Tip = 此選項將顯著提高/降低渲染樣條和貝塞爾曲線的質量 -Lower resolution for effects (reduces artifacts) = 降低效果的解析度(減少失真) +Lower resolution for effects (reduces artifacts) = 降低效果的解析度(減少圖像錯誤) Manual Scaling = 手動縮放 Medium = 中 Mode = 模式 From d6a59be012908bd7324b07a0b3beea06c896a82e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Oct 2022 23:09:48 -0700 Subject: [PATCH 213/374] softgpu: Respect negate normal flag without norm. Per tests, Z is still negated even when using the previous normal value. --- GPU/Software/TransformUnit.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index fbbdcd3919..ac52ef180f 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -337,17 +337,12 @@ ClipVertexData TransformUnit::ReadVertex(VertexReader &vreader, const TransformS vertex.v.texturecoords = lastTC; } - Vec3f normal; static Vec3f lastnormal; - if (vreader.hasNormal()) { - vreader.ReadNrm(normal.AsArray()); - lastnormal = normal; - - if (state.negateNormals) - normal = -normal; - } else { - normal = lastnormal; - } + if (vreader.hasNormal()) + vreader.ReadNrm(lastnormal.AsArray()); + Vec3f normal = lastnormal; + if (state.negateNormals) + normal = -normal; if (state.readWeights) { float W[8] = { 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; From 6945604492a1e09b05ce5de4aa2e6f67c37d39a6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Oct 2022 23:10:56 -0700 Subject: [PATCH 214/374] softgpu: Multiply prev normal by world matrix. Even when it's not in the vertex data, we still must multiply by the world matrix. Fixes some lighting issues in Nayuta no Kiseki. --- GPU/Software/TransformUnit.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index ac52ef180f..043683b88c 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -411,11 +411,9 @@ ClipVertexData TransformUnit::ReadVertex(VertexReader &vreader, const TransformS vertex.v.clipw = vertex.clippos.w; Vec3 worldnormal; - if (vreader.hasNormal()) { + if (state.enableLighting || state.uvGenMode == GE_TEXMAP_ENVIRONMENT_MAP) { worldnormal = TransformUnit::ModelToWorldNormal(normal); worldnormal.NormalizeOr001(); - } else { - worldnormal = Vec3(0.0f, 0.0f, 1.0f); } // Time to generate some texture coords. Lighting will handle shade mapping. From d23293ee72b3b8ed0af9545cf84ce2c5ecebf01d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 20 Oct 2022 23:15:25 -0700 Subject: [PATCH 215/374] GPU: Respect matrix and reverse flag w/o normals. See frame dump in #14223, which requires world matrix be applied. --- GPU/Common/VertexShaderGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 45433a72d7..a90299c57e 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -869,7 +869,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (hasNormalTess) { WRITE(p, " mediump vec3 worldnormal = normalizeOr001(mul(vec4(%stess.nrm, 0.0), u_world).xyz);\n", flipNormalTess ? "-" : ""); } else { - WRITE(p, " mediump vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n"); + WRITE(p, " mediump vec3 worldnormal = normalizeOr001(mul(vec4(0.0, 0.0, %s1.0, 0.0), u_world).xyz);\n", flipNormalTess ? "-" : ""); } } else { // No skinning, just standard T&L. @@ -877,7 +877,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (hasNormal) WRITE(p, " mediump vec3 worldnormal = normalizeOr001(mul(vec4(%snormal, 0.0), u_world).xyz);\n", flipNormal ? "-" : ""); else - WRITE(p, " mediump vec3 worldnormal = vec3(0.0, 0.0, 1.0);\n"); + WRITE(p, " mediump vec3 worldnormal = normalizeOr001(mul(vec4(0.0, 0.0, %s1.0, 0.0), u_world).xyz);\n", flipNormal ? "-" : ""); } } else { static const char *rescale[4] = {"", " * 1.9921875", " * 1.999969482421875", ""}; // 2*127.5f/128.f, 2*32767.5f/32768.f, 1.0f}; From cafce7365b2a8c11a51af5b3fd19d4ea13bd2396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Oct 2022 12:52:21 +0200 Subject: [PATCH 216/374] Vulkan: Fix frame ordering issue with postprocessing shaders Requested an init command buffer outside the frame, which is dangerous and caused validation problems with command pool resets. Would like to assert on insideFrame in GetInitCmd, but we use it from some init code where it does work correctly. Might clean that up at some point. --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 12 ++++++++++-- GPU/Common/FramebufferManagerCommon.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index a3f61976dc..8da78975d2 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -612,9 +612,9 @@ void VulkanRenderManager::BeginFrame(bool enableProfiling, bool enableLogProfile // Must be after the fence - this performs deletes. VLOG("PUSH: BeginFrame %d", curFrame); + insideFrame_ = true; vulkan_->BeginFrame(enableLogProfiler ? GetInitCmd() : VK_NULL_HANDLE); - insideFrame_ = true; renderStepOffset_ = 0; frameData.profile.timestampDescriptions.clear(); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 4513493c61..07f933778f 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -108,6 +108,13 @@ bool FramebufferManagerCommon::UpdateSize() { void FramebufferManagerCommon::BeginFrame() { DecimateFBOs(); + + // Might have a new post shader - let's compile it. + if (updatePostShaders_) { + presentation_->UpdatePostShader(); + updatePostShaders_ = false; + } + currentRenderVfb_ = nullptr; } @@ -2349,8 +2356,9 @@ void FramebufferManagerCommon::Resized() { DestroyAllFBOs(); } - // Might have a new post shader - let's compile it. - presentation_->UpdatePostShader(); + // No drawing is allowed here. This includes anything that might potentially touch a command buffer, like creating images! + // So we need to defer the post processing initialization. + updatePostShaders_ = true; #ifdef _WIN32 // Seems related - if you're ok with numbers all the time, show some more :) diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index ffcab7a1ec..5a85d93541 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -544,6 +544,7 @@ protected: int pixelWidth_ = 0; int pixelHeight_ = 0; int bloomHack_ = 0; + bool updatePostShaders_ = false; Draw::DataFormat preferredPixelsFormat_ = Draw::DataFormat::R8G8B8A8_UNORM; From f2193814eeca7eeaf3c7b5cb5214f11e4123ca7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Oct 2022 14:18:18 +0200 Subject: [PATCH 217/374] PresentationCommon: Use refcounts to simplify shader module management --- GPU/Common/PresentationCommon.cpp | 8 ++++---- GPU/Common/PresentationCommon.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 3fda863d81..bb3a6d8fad 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -307,6 +307,10 @@ bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const Sha } }; Draw::Pipeline *pipeline = CreatePipeline({ vs, fs }, true, &postShaderDesc); + + fs->Release(); + vs->Release(); + if (!pipeline) return false; @@ -504,7 +508,6 @@ void PresentationCommon::DestroyDeviceObjects() { void PresentationCommon::DestroyPostShader() { usePostShader_ = false; - DoReleaseVector(postShaderModules_); DoReleaseVector(postShaderPipelines_); DoReleaseVector(postShaderFramebuffers_); DoReleaseVector(previousFramebuffers_); @@ -521,10 +524,7 @@ Draw::ShaderModule *PresentationCommon::CompileShaderModule(ShaderStage stage, S return nullptr; } } - Draw::ShaderModule *shader = draw_->CreateShaderModule(stage, lang_, (const uint8_t *)translated.c_str(), translated.size(), "postshader"); - if (shader) - postShaderModules_.push_back(shader); return shader; } diff --git a/GPU/Common/PresentationCommon.h b/GPU/Common/PresentationCommon.h index 7ce81117b8..ea51fb0b5c 100644 --- a/GPU/Common/PresentationCommon.h +++ b/GPU/Common/PresentationCommon.h @@ -129,7 +129,6 @@ protected: Draw::Buffer *vdata_ = nullptr; Draw::Buffer *idata_ = nullptr; - std::vector postShaderModules_; std::vector postShaderPipelines_; std::vector postShaderFramebuffers_; std::vector postShaderInfo_; From 6aa3e4b2424971880ef47df4a6cc2588359e22e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Oct 2022 15:42:32 +0200 Subject: [PATCH 218/374] Minor refactoring in PresentationCommon Broken out from stereo work --- GPU/Common/PresentationCommon.cpp | 36 +++++++++++++++++++++---------- GPU/Common/PresentationCommon.h | 15 +++++++------ 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index bb3a6d8fad..ce3e155c93 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -157,7 +157,7 @@ PresentationCommon::~PresentationCommon() { DestroyDeviceObjects(); } -void PresentationCommon::GetCardboardSettings(CardboardSettings *cardboardSettings) { +void PresentationCommon::GetCardboardSettings(CardboardSettings *cardboardSettings) const { if (!g_Config.bEnableCardboardVR) { cardboardSettings->enabled = false; return; @@ -183,7 +183,7 @@ void PresentationCommon::GetCardboardSettings(CardboardSettings *cardboardSettin cardboardSettings->screenHeight = cardboardScreenHeight; } -void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int targetWidth, int targetHeight, const ShaderInfo *shaderInfo, PostShaderUniforms *uniforms) { +void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int targetWidth, int targetHeight, const ShaderInfo *shaderInfo, PostShaderUniforms *uniforms) const { float u_delta = 1.0f / bufferWidth; float v_delta = 1.0f / bufferHeight; float u_pixel_delta = 1.0f / targetWidth; @@ -234,17 +234,23 @@ bool PresentationCommon::UpdatePostShader() { } DestroyPostShader(); - if (shaderInfo.empty()) + if (shaderInfo.empty()) { + usePostShader_ = false; return false; + } bool usePreviousFrame = false; bool usePreviousAtOutputResolution = false; for (size_t i = 0; i < shaderInfo.size(); ++i) { const ShaderInfo *next = i + 1 < shaderInfo.size() ? shaderInfo[i + 1] : nullptr; - if (!BuildPostShader(shaderInfo[i], next)) { + Draw::Pipeline *postPipeline = nullptr; + if (!BuildPostShader(shaderInfo[i], next, &postPipeline)) { DestroyPostShader(); return false; } + _dbg_assert_(postPipeline); + postShaderPipelines_.push_back(postPipeline); + postShaderInfo_.push_back(*shaderInfo[i]); if (shaderInfo[i]->usePreviousFrame) { usePreviousFrame = true; usePreviousAtOutputResolution = shaderInfo[i]->outputResolution; @@ -272,7 +278,7 @@ bool PresentationCommon::UpdatePostShader() { return true; } -bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const ShaderInfo *next) { +bool PresentationCommon::CompilePostShader(const ShaderInfo *shaderInfo, Draw::Pipeline **outPipeline) const { std::string vsSourceGLSL = ReadShaderSrc(shaderInfo->vertexShaderFile); std::string fsSourceGLSL = ReadShaderSrc(shaderInfo->fragmentShaderFile); if (vsSourceGLSL.empty() || fsSourceGLSL.empty()) { @@ -314,6 +320,15 @@ bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const Sha if (!pipeline) return false; + *outPipeline = pipeline; + return true; +} + +bool PresentationCommon::BuildPostShader(const ShaderInfo * shaderInfo, const ShaderInfo * next, Draw::Pipeline **outPipeline) { + if (!CompilePostShader(shaderInfo, outPipeline)) { + return false; + } + if (!shaderInfo->outputResolution || next) { int nextWidth = renderWidth_; int nextHeight = renderHeight_; @@ -341,13 +356,12 @@ bool PresentationCommon::BuildPostShader(const ShaderInfo *shaderInfo, const Sha } if (!AllocateFramebuffer(nextWidth, nextHeight)) { - pipeline->Release(); + (*outPipeline)->Release(); + *outPipeline = nullptr; return false; } } - postShaderPipelines_.push_back(pipeline); - postShaderInfo_.push_back(*shaderInfo); return true; } @@ -416,7 +430,7 @@ void PresentationCommon::DeviceRestore(Draw::DrawContext *draw) { CreateDeviceObjects(); } -Draw::Pipeline *PresentationCommon::CreatePipeline(std::vector shaders, bool postShader, const UniformBufferDesc *uniformDesc) { +Draw::Pipeline *PresentationCommon::CreatePipeline(std::vector shaders, bool postShader, const UniformBufferDesc *uniformDesc) const { using namespace Draw; Semantic pos = SEM_POSITION; @@ -515,7 +529,7 @@ void PresentationCommon::DestroyPostShader() { postShaderFBOUsage_.clear(); } -Draw::ShaderModule *PresentationCommon::CompileShaderModule(ShaderStage stage, ShaderLanguage lang, const std::string &src, std::string *errorString) { +Draw::ShaderModule *PresentationCommon::CompileShaderModule(ShaderStage stage, ShaderLanguage lang, const std::string &src, std::string *errorString) const { std::string translated = src; if (lang != lang_) { // Gonna have to upconvert the shader. @@ -816,7 +830,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u previousUniforms_ = uniforms; } -void PresentationCommon::CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa) { +void PresentationCommon::CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa) const { // Check if postprocessing shader is doing upscaling as it requires native resolution std::vector shaderInfo; if (!g_Config.vPostShaderNames.empty()) { diff --git a/GPU/Common/PresentationCommon.h b/GPU/Common/PresentationCommon.h index ea51fb0b5c..c3faff6568 100644 --- a/GPU/Common/PresentationCommon.h +++ b/GPU/Common/PresentationCommon.h @@ -102,24 +102,25 @@ public: void SourceFramebuffer(Draw::Framebuffer *fb, int bufferWidth, int bufferHeight); void CopyToOutput(OutputFlags flags, int uvRotation, float u0, float v0, float u1, float v1); - void CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa); + void CalculateRenderResolution(int *width, int *height, int *scaleFactor, bool *upscaling, bool *ssaa) const; protected: void CreateDeviceObjects(); void DestroyDeviceObjects(); void DestroyPostShader(); - void ShowPostShaderError(const std::string &errorString); + static void ShowPostShaderError(const std::string &errorString); - Draw::ShaderModule *CompileShaderModule(ShaderStage stage, ShaderLanguage lang, const std::string &src, std::string *errorString); - Draw::Pipeline *CreatePipeline(std::vector shaders, bool postShader, const UniformBufferDesc *uniformDesc); - bool BuildPostShader(const ShaderInfo *shaderInfo, const ShaderInfo *next); + Draw::ShaderModule *CompileShaderModule(ShaderStage stage, ShaderLanguage lang, const std::string &src, std::string *errorString) const; + Draw::Pipeline *CreatePipeline(std::vector shaders, bool postShader, const UniformBufferDesc *uniformDesc) const; + bool CompilePostShader(const ShaderInfo *shaderInfo, Draw::Pipeline **outPipeline) const; + bool BuildPostShader(const ShaderInfo *shaderInfo, const ShaderInfo *next, Draw::Pipeline **outPipeline); bool AllocateFramebuffer(int w, int h); void BindSource(int binding); - void GetCardboardSettings(CardboardSettings *cardboardSettings); - void CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int targetWidth, int targetHeight, const ShaderInfo *shaderInfo, PostShaderUniforms *uniforms); + void GetCardboardSettings(CardboardSettings *cardboardSettings) const; + void CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int targetWidth, int targetHeight, const ShaderInfo *shaderInfo, PostShaderUniforms *uniforms) const; Draw::DrawContext *draw_; Draw::Pipeline *texColor_ = nullptr; From 6a6ccb4c68acb6c80dab8e3f188e0332a0db447d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Oct 2022 18:47:28 +0200 Subject: [PATCH 219/374] Apply Kyria's updates to tr_TR (Turkish) translation --- assets/lang/tr_TR.ini | 179 +++++++++++++++++++++--------------------- 1 file changed, 89 insertions(+), 90 deletions(-) diff --git a/assets/lang/tr_TR.ini b/assets/lang/tr_TR.ini index d6c04817fd..4af52fed3c 100644 --- a/assets/lang/tr_TR.ini +++ b/assets/lang/tr_TR.ini @@ -1,12 +1,12 @@ [Audio] -Alternate speed volume = Alternatif hız sesi +Alternate speed volume = Alternatif hız hacmi Audio backend = Ses alttabanı (Yeniden başlatma gerekir) Audio Error = Ses Hatası -AudioBufferingForBluetooth = Bluetooth-uyumlu arabellek (daha yavaş) -Auto = Auto +AudioBufferingForBluetooth = Bluetooth uyumlu arabellek (daha yavaş) +Auto = Otomatik Device = Cihaz Disabled = Devre dışı -DSound (compatible) = DSound (Uyumlu) +DSound (compatible) = DSound (uyumlu) Enable Sound = Sesi etkinleştir Global volume = Genel ses Microphone = Mikrofon @@ -15,10 +15,10 @@ Mute = Sessiz Reverb volume = Yankı sesi Use new audio devices automatically = Otomatik olarak yeni ses cihazlarını kullan Use global volume = Genel ses seviyesini kullan -WASAPI (fast) = WASAPI (Hızlı) +WASAPI (fast) = WASAPI (hızlı) [Controls] -Analog Binding = Analog Binding +Analog Binding = Analog Bağlama Analog Limiter = Analog sınırlayıcı Analog Settings = Analog Ayarları Analog Stick = Analog çubuk @@ -31,9 +31,9 @@ Auto-rotation speed = Otomatik rotasyon hızı Auto-switch = Oto-switch Base tilt position = Base tilt position Binds = Binds -Button Binding = Button Binding +Button Binding = Düğme Bağlama Button Opacity = Tuş görünürlüğü -Button style = Tuş biçimi +Button style = Tuş stili Calibrate Analog Stick = Analog Çubuğu Kalibre Et Calibrate D-Pad = D-Pad'i kalibre et Calibrated = Kalibre edildi @@ -44,7 +44,7 @@ Confine Mouse = Fareyi belirli bir pencere/görüntü alanı içinde sınırla Control Mapping = Kontrolleri Ayarla Custom Key Setting = Özel Tuş Ayarı Customize = Düzenle -Customize Touch Controls = Dokunmatik kontrol düzenini düzenle... +Customize Touch Controls = Dokunmatik kontrolleri düzenle... Customize tilt = Eğimi düzenle... D-PAD = D-Pad Deadzone radius = Ölü bölge yarıçapı @@ -70,22 +70,22 @@ L/R Trigger Buttons = L/R Tetik düğmeleri Landscape = Yatay Landscape Auto = Otomatik yatay Landscape Reversed = Ters yatay -Low end radius = Low end radius +Low end radius = Düşük uç yarıçapı Mouse = Fare ayarları Mouse sensitivity = Fare hassasiyeti Mouse smoothing = Fare yumuşatma MouseControl Tip = Fareye 'Kontrolleri Ayarlama' bölümünden 'M' simgesine basarak kontrol atayabilirsiniz. -None (Disabled) = Hiçbiri (Devre Dışı) +None (Disabled) = Hiçbiri (Devre dışı) Off = Kapalı OnScreen = Dokunmatik ekran kontrolleri Portrait = Dikey Portrait Reversed = Ters dikey PSP Action Buttons = PSP eylem tuşları -Raw input = Ham girdi -Repeat mode = Repeat mode +Raw input = Saf girdi +Repeat mode = Tekrar modu Reset to defaults = Varsayılanlara sıfırla Screen aligned to ground = Ekran yere hizalansın -Screen at right angle to ground = Screen at right angle to ground +Screen at right angle to ground = Yere dik açıda ekran Screen Rotation = Ekran rotasyonu seconds, 0 : off = saniyeler, 0 = kapalı Sensitivity (scale) = Hassasiyet (ölçek) @@ -101,7 +101,7 @@ Tilt Input Type = Eğim giriş türü Tilt Sensitivity along X axis = X ekseni boyunca eğim hassasiyeti Tilt Sensitivity along Y axis = Y ekseni boyunca eğim hassasiyeti To Calibrate = Kalibre etmek için cihazı düz bir zemine yerleştirin ve "Kalibre et" tuşuna basın. -Toggle mode = Toggle mode +Toggle mode = Geçiş modu Touch Control Visibility = Dokunmatik kontrol görünürlüğü Use custom right analog = Özel sağ analog kullan Use Mouse Control = Fareyle kontrolü etkinleştir @@ -116,7 +116,7 @@ Edit Cheat File = Hile dosyasını düzenle Enable/Disable All = Bütün hileleri Aç/Kapat Import Cheats = cheat.db'den hile al Options = Ayarlar -Refresh Rate = Yenileme hızı +Refresh Rate = Yenileme Hızı [DesktopUI] # EN: If your language does not show well with the default font, you can use Font to specify a different one. @@ -492,6 +492,7 @@ Deposterize Tip = Yeniden ölçeklenen dokulardaki görsel şerit hatalarını d Device = Cihaz Direct3D 9 = Direct3D 9 Direct3D 11 = Direct3D 11 +Disable slower effects (speedup) = Daha yavaş efektleri kapatın (daha hızlı) Disabled = Devre dışı Display layout editor = Görüntü Düzeni Düzenleyicisi Display Resolution (HW scaler) = Görüntü Çözünürlüğü (HW scaler) @@ -602,7 +603,7 @@ You can press ESC to cancel. = İptal etmek için Esc'ye basabilirsiniz. [MainMenu] Browse = Aç... -Buy PPSSPP Gold = Buy PPSSPP Gold +Buy PPSSPP Gold = PPSSPP Gold'u Al Choose folder = Klasör seç Credits = Emeği Geçenler PPSSPP Homebrew Store = PPSSPP Bağımsız Yapım Mağazası @@ -630,7 +631,7 @@ Audio = Ses Controls = Kontroller Graphics = Grafik Networking = Ağ ayarları -Search = Search +Search = Ara System = Sistem Tools = Araçlar @@ -758,8 +759,6 @@ Center Left = Sol orta Center Right = Sağ orta Change Mac Address = MAC adresini değiştir Change proAdhocServer Address = PRO Ad Hoc Server IP adresini değiştir (localhost = çoklu örnek) -ChangeMacSaveConfirm = Generate a new MAC address? -ChangeMacSaveWarning = Some games verify the MAC address when loading savedata, so this may break old saves. Chat = Chat Chat Button Position = Chat düğmesinin konumu Chat Here = Buraya yazın @@ -771,13 +770,13 @@ Enable built-in PRO Adhoc Server = Yerleşik PRO Ad Hoc Sunucusunu etkinleştir Enable network chat = Ağ sohbetini etkinleştir Enable networking = Ağ Oluşturma/WLAN'ı aç (Henüz Beta, oyun çökebilir.) Enable UPnP = UPnP'yi etkinleştirin (algılamak için birkaç saniye gerekir) -EnableQuickChat = Hızlı chat'i etkinleştirin +EnableQuickChat = Hızlı sohbeti etkinleştirin Enter a new PSP nickname = Yeni bir PSP kullanıcı adı girin -Enter Quick Chat 1 = Hızlı chat 1'e girin -Enter Quick Chat 2 = Hızlı chat 2'ye girin -Enter Quick Chat 3 = Hızlı chat 3'e girin -Enter Quick Chat 4 = Hızlı chat 4'e girin -Enter Quick Chat 5 = Hızlı chat 5'e girin +Enter Quick Chat 1 = Hızlı sohbet 1'e girin +Enter Quick Chat 2 = Hızlı sohbet 2'ye girin +Enter Quick Chat 3 = Hızlı sohbet 3'e girin +Enter Quick Chat 4 = Hızlı sohbet 4'e girin +Enter Quick Chat 5 = Hızlı sohbet 5'e girin Error = Hata Failed to Bind Localhost IP = Failed to bind localhost IP Failed to Bind Port = Failed to bind port @@ -794,11 +793,11 @@ Please change your Port Offset = Lütfen Port Offset'i değiştirin Port offset = Port offset(0 = PSP uyumluluğu) Open PPSSPP Multiplayer Wiki Page = PPSSPP Ad-Hoc Wiki Sayfası proAdhocServer Address: = Ad hoc sunucu adresi: -Quick Chat 1 = Hızlı chat 1 -Quick Chat 2 = Hızlı chat 2 -Quick Chat 3 = Hızlı chat 3 -Quick Chat 4 = Hızlı chat 4 -Quick Chat 5 = Hızlı chat 5 +Quick Chat 1 = Hızlı sohbet 1 +Quick Chat 2 = Hızlı sohbet 2 +Quick Chat 3 = Hızlı sohbet 3 +Quick Chat 4 = Hızlı sohbet 4 +Quick Chat 5 = Hızlı sohbet 5 QuickChat = Hızlı sohbet Send = Gönder Send Discord Presence information = Discord "Rich Presence" bilgisi gönder @@ -868,8 +867,8 @@ Vignette = Vinyet all the forum mods = Bütün forum modlarına build server = build server Buy Gold = Altın Sürümü alın -check = Ayrıca Etraftaki En İyi Wii/GC Emülatörü Olan Dolphin'e Gözatın: -CheckOutPPSSPP = Check out PPSSPP, the awesome PSP emulator: https://www.ppsspp.org/ +check = Ayrıca etraftaki en iyi Wii/GC emülatörü olan Dolphin'e göz atın: +CheckOutPPSSPP = PPSSPP'ye göz atın: https://www.ppsspp.org/ contributors = Yardımcılar: created = Yaratıcı Discord = Discord @@ -877,18 +876,18 @@ info1 = PPSSPP sadece eğitimsel amaçlar için tasarlandı. info2 = Lütfen oynadığınız herhangi bir oyunun haklarına sahip olduğunuzu, info3 = oyunun UMD'sini veya PSP'niz üzerinden info4 = PSN Store'dan dijital sürümünü satın alarak emin olunuz. -info5 = PSP SONY'nin tescilli markasıdır. -iOS builds = iOS builds +info5 = PSP, Sony'nin tescilli markasıdır. +iOS builds = iOS derlemeleri license = GPL 2.0+ altında bir "özgür yazılım" list = Uyumluluk Listeleri, Forumlar ve Geliştirme Bilgisi PPSSPP Forums = PPSSPP Forumları -Privacy Policy = Privacy policy +Privacy Policy = Gizlilik politikası Share PPSSPP = PPSSPP'yi Paylaş specialthanks = Özel Teşekkürler: specialthanksKeithGalocy = at NVIDIA (hardware, advice) specialthanksMaxim = for his amazing Atrac3+ decoder work -testing = testing -this translation by = Türkçe Çeviri Yapan: +testing = test +this translation by = Türkçe çeviri: title = Hızlı ve Taşınabilir PSP Emülatörü tools = Kullanılan Ücretsiz Araçlar: # Add translators or contributors who translated PPSSPP into your language here. @@ -896,12 +895,12 @@ tools = Kullanılan Ücretsiz Araçlar: # Leave extra lines blank. 4 contributors per line seems to look best. translators1 = Gravityy translators2 = mygizli04 -translators3 = kishiradarken1867 +translators3 = Kyria Crown translators4 = translators5 = translators6 = -Twitter @PPSSPP_emu = Twitter @PPSSPP_emu -website = PPSSPP.org'u Ziyaret Et +Twitter @PPSSPP_emu = Twitter +website = PPSSPP.org written = Hız ve Taşınabilirlik için C++ ile Yazıldı [RemoteISO] @@ -935,7 +934,7 @@ FeedbackIncludeCRC = Not: Batarya diskin döngüsel artıklık denetimini yollam FeedbackIncludeScreen = Ekran görüntüsü dahil et FeedbackSubmitDone = Veriniz gönderildi. FeedbackSubmitFail = Veri sunucuya gönderilemedi. PPSSPP'yi güncellemeyi deneyin. -FeedbackThanks = Geribildirimin için teşekkürler! +FeedbackThanks = Geribildiriminiz için teşekkürler! Gameplay = Oynanış Graphics = Grafikler Great = İyi @@ -958,20 +957,20 @@ Speed = Hız Submit Feedback = Geribildirimi yolla SuggestionConfig = İyi ayarlar için sitedeki ayarlara bakın. SuggestionCPUSpeed0 = Kilitlenmiş CPU hızını kapat. -SuggestionDowngrade = Daha eski bir PPSSPP sürümüne indirin ( Bu bugu rapor edin, lütfen. ) -SuggestionsFound = Diğer kullanıcılar daha iyi sonuçlar rapor etti. Daha fazla ayrıntı için "Geri dönüşü görüntüle" tuşuna basın. +SuggestionDowngrade = Daha eski bir PPSSPP sürümüne indirin (Lütfen bu hatayı raporlayın.) +SuggestionsFound = Diğer kullanıcılar daha iyi sonuçlar raporladı. Daha fazla ayrıntı için "Geribildirimi görüntüle"ye basın. SuggestionsNone = Bu oyun diğer kullanıcılar için de çalışmıyor. SuggestionsWaiting = Gönderiliyor ve diğer kullanıcıların da sonuçlarına bakılıyor... SuggestionUpgrade = Daha yeni bir PPSSPP sürümüne güncelleyin. SuggestionVerifyDisc = ISO dosyanızın doğru olduğunu kontrol edin. -Unselected Overall Description = Bu oyun nasıl simule ediliyor? +Unselected Overall Description = Bu oyun nasıl simüle ediliyor? View Feedback = Bütün geribildirimleri göster [Savedata] -Date = Date +Date = Tarih Filename = Dosya adı No screenshot = Ekran görüntüsü yok -None yet. Things will appear here after you save. = Henüz birşey yok.Kayıt aldığında kayıtların burada gözükecek. +None yet. Things will appear here after you save. = Henüz bir şey yok. Kayıt aldığında kayıtların burada görünecek. Nothing matching '%1' was found. = '%1' ile eşleşen hiçbir şey bulunamadı. Save Data = Normal Kayıtlar Save States = Durum Kayıtları @@ -986,7 +985,7 @@ Failed to load state = Durum yüklenemedi. Failed to save state = Durum kaydedilemedi. fixed = Hız: Alternatif GLToolsWarning = UYARI: GLTools algılandı, problemlere sebep olabilir. -In menu = In menu +In menu = Menüde Load savestate failed = Durum kaydı yüklenemedi. Loaded State = Durum yüklendi. Loaded. Game may refuse to save over different savedata. = Yüklendi. Oyun belki farklı verilerin üzerine kaydetmeyi reddedebilir. @@ -996,7 +995,7 @@ LoadStateDoesntExist = Durum yüklenemedi: Durum kaydı yerinde yok! LoadStateWrongVersion = Durum yüklenemedi: Durum kaydı eski bir PPSSPP versiyonu için uygun! norewind = Geriye sarma durumu bulunamadı. Playing = Oynatılıyor... -PressESC = PPSSPP menüsünü açmak için ESC'ye bas. +PressESC = PPSSPP menüsünü açmak için ESC'ye basın. replaceTextures_false = Dokular artık değiştirilmiyor. replaceTextures_true = Doku değiştirme etkinleştirildi. Save State Failed = Durum kaydı yapılamadı! @@ -1009,11 +1008,11 @@ State load undone = Durum yüklemesi tamamlanmadı Untitled PSP game = Başlıksız PSP oyunu [Search] -Clear filter = Clear filter -Filter = Filter -Filtering settings by '%1' = Filtering settings by '%1' -Find settings = Find settings -No settings matched '%1' = No settings matched '%1' +Clear filter = Filtreyi temizle +Filter = Filtre +Filtering settings by '%1' = Ayarlar '%1''e göre filtreleniyor +Find settings = Ayarları ara +No settings matched '%1' = '%1' ile eşleşen ayar yok [Store] Already Installed = Zaten yüklü @@ -1047,9 +1046,9 @@ Debug = Hata Ayıklama Debugger Present = Hata ayıklayıcı var Device Info = Cihaz bilgisi Directories = Dizinler -Display Color Formats = Display Color Formats +Display Color Formats = Renk Biçimlerini Görüntüle Display Information = Ekran bilgisi -Driver bugs = Driver bugs +Driver bugs = Sürücü hataları Driver Version = Sürücü sürümü EGL Extensions = EGL eklentileri Frames per buffer = Tampon başına çerçeveler @@ -1058,19 +1057,19 @@ High precision float range = High precision float range High precision int range = High precision int range Lang/Region = Dil/Bölge Memory Page Size = Bellek sayfa boyutu -Native Resolution = Doğal çözünürlük -No GPU driver bugs detected = No GPU driver bugs detected +Native Resolution = Yerel çözünürlük +No GPU driver bugs detected = GPU sürücü hatası algılanmadı OGL Extensions = OGL eklentileri OpenGL ES 2.0 Extensions = OpenGL ES 2.0 eklentileri OpenGL ES 3.0 Extensions = OpenGL ES 3.0 eklentileri OpenGL Extensions = OpenGL eklentileri Optimal frames per buffer = Optimum tampon başına çerçeveler Optimal sample rate = Optimum örnekleme hızı -OS Information = İS bilgisi +OS Information = İşletim sistemi bilgisi PPSSPP build = PPSSPP derlemesi Refresh rate = Yenileme hızı Release = Release -RW/RX exclusive = RW/RX 'e özel +RW/RX exclusive = RW/RX'e özel Sample rate = Örnekleme hızı Shading Language = Gölgelendirme dili Storage = Depolama @@ -1079,8 +1078,8 @@ System Information = Sistem bilgisi System Name = Ad System Version = Sistem sürümü Threads = İzlekler -Vendor = Satıcı -Vendor (detected) = Satıcı (tespit edildi) +Vendor = Üretici +Vendor (detected) = Üretici (tespit edildi) Version Information = Sürüm bilgisi Vulkan Extensions = Vulkan eklentileri Vulkan Features = Vulkan özellikleri @@ -1091,15 +1090,15 @@ Vulkan Features = Vulkan özellikleri 24HR = 24 saat Auto = Otomatik Auto Load Savestate = Otomatik durum kaydı yükle -AVI Dump started. = AVI kaydı başladı -AVI Dump stopped. = AVI kaydı bitti +AVI Dump started. = AVI kaydı başladı. +AVI Dump stopped. = AVI kaydı bitti. Cache ISO in RAM = Bütün ISO'yu RAM'e önbellekle Change CPU Clock = Taklit edilen PSP'nin CPU sayacını değiştir (kararsız) -Color Saturation = Color Saturation -Color Tint = Color Tint +Color Saturation = Renk Doygunluğu +Color Tint = Renk Tonu Error: load undo state is from a different game = Hata: yükleme geri alma durumu farklı bir oyundan Failed to load state for load undo. Error in the file system. = Yüklemeyi geri alma durumu yüklenemedi. Dosya sisteminde hata. -Floating symbols = kayan simgeler +Floating symbols = Kayan simgeler Memory Stick folder = Hafıza Kartı klasörü Memory Stick size = Hafıza Kartı boyutu Change Nickname = Kullanıcı adını değiştir @@ -1116,12 +1115,12 @@ DDMMYYYY = GGAAYYYY Decrease size = Boyutu küçült Developer Tools = Geliştirici araçları Display Extra Info = Fazladan bilgileri göster -Display Games on a grid = "Oyunlar"ı bir ızgarada göster -Display Homebrew on a grid = "Bağımsız Yapımlar && Demolar"ı bir ızgarada göster -Display Recent on a grid = "Geçmiş"i bir ızgarada göster +Display Games on a grid = Oyunları ızgarada göster +Display Homebrew on a grid = Demolar && Bağımsız Yapımları ızgarada göster +Display Recent on a grid = Geçmişi ızgarada göster Dynarec (JIT) = Dynarec (JIT) Emulation = Emülasyon -Enable Cheats = Hileleri aç +Enable Cheats = Hileleri etkinleştir Enable Compatibility Server Reports = Uyumluluk sunucusu raporlarını etkinleştir Failed to load state. Error in the file system. = Durum yüklenemedi. Dosya sistemi hatası. Failed to save state. Error in the file system. = Durum kaydedilemedi. Dosya sistemi hatası. @@ -1137,7 +1136,7 @@ Host (bugs, less lag) = Host (buglu, daha az kasma) Ignore bad memory accesses = Kötü bellek erişimlerini yoksay Increase size = Boyutu arttır Interpreter = Tercüman -IO timing method = G / Ç zamanlama yöntemi +IO timing method = G/Ç zamanlama yöntemi IR Interpreter = IR tercümanı Memory Stick Folder = Hafıza Kartı klasörü Memory Stick inserted = Hafıza kartı takıldı @@ -1160,15 +1159,15 @@ Record Audio = Sesi kaydet Record Display = Görüntüyü kaydet Reset Recording on Save/Load State = Kaydet/Yükle durumunda kaydı sıfırla Restore Default Settings = Varsayılan ayarları yükle -Rewind Snapshot Frequency = Geri sarma görüntüsü sıklılığı (mem hog) +Rewind Snapshot Frequency = Geri sarma görüntüsü sıklığı (mem hog) Save path in installed.txt = Yolu installed.txt'ye kaydet Save path in My Documents = Dosyaları "Belgeler"'e kaydet Savestate Slot = Durum kaydı yeri Savestate slot backups = Durum kaydı slot yedekleri -Screenshots as PNG = Ekran görüntülerini PNG formatında kaydet +Screenshots as PNG = Ekran görüntülerini PNG olarak kaydet Set UI background... = Arayüz arkaplanı ayarla... Show ID = ID'yi göster -Show Memory Stick folder = Show Memory Stick folder +Show Memory Stick folder = Hafıza Kartı klasörünü göster Show region flag = Bölge bayrağını göster Simulate UMD delays = UMD gecikmelerini simule et Slot 1 = Slot 1 @@ -1178,44 +1177,44 @@ Slot 4 = Slot 4 Slot 5 = Slot 5 Storage full = Depolama dolu Sustained performance mode = Sürekli performans modu -Theme = Theme +Theme = Tema Time Format = Zaman biçimi UI = Kullanıcı arayüzü UI background animation = UI arka plan animasyonu UI Sound = UI sesi undo %c = %c 'yi yedekle USB = USB -Use Lossless Video Codec (FFV1) = Kayıpsız video kodek'i kullan (FFV1) +Use Lossless Video Codec (FFV1) = Kayıpsız video codec'i kullan (FFV1) Use O to confirm = O (Japonya) Use output buffer (with overlay) for recording = Kayıt için çıktı arabelleğini kullanın (bindirmeli) Use system native keyboard = Sistem yerel klavyesini kullan Use X to confirm = X (Küresel) VersionCheck = Güncellemeleri denetle -WARNING: Android battery save mode is on = UYARI: Android güç tasaruufu açık -WARNING: Battery save mode is on = UYARI: Güç tasarrufu açık +WARNING: Android battery save mode is on = UYARI: Android pil tasarrufu açık +WARNING: Battery save mode is on = UYARI: Pil tasarrufu açık Waves = Dalgalar YYYYMMDD = YYYYAAGG [TextureShaders] Off = Off TexMMPX = TexMMPX -Tex2xBRZ = Tex2xBRZ +Tex2xBRZ = Tex2xBRZ Tex4xBRZ = Tex4xBRZ [Themes] -Default = Default +Default = Varsayılan [UI Elements] -%1 button = %1 button -%1 checkbox = %1 checkbox -%1 choice = %1 choice -%1 heading = %1 heading -%1 radio button = %1 radio button -%1 text field = %1 text field -Choices: = Choices: -List: = List: +%1 button = %1 düğmesi +%1 checkbox = %1 onay kutusu +%1 choice = %1 seçeneği +%1 heading = %1 başlığı +%1 radio button = %1 radyo düğmesi +%1 text field = %1 metin alanı +Choices: = Seçenekler: +List: = Liste: Progress: %1% = Progress: %1% -Screen representation = Screen representation +Screen representation = Ekran gösterimi [Upgrade] Details = Detaylar Dismiss = Reddet From f4d5c59b2e40c8fb4733e49e819083bbb47a91ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Von=C3=A1sek?= Date: Sat, 22 Oct 2022 16:16:23 +0200 Subject: [PATCH 220/374] OpenXR - Refactor compatvr.ini file (#16270) * OpenXR - Compat GTA games * OpenXR - Compat 0-9 games * OpenXR - Compat A games * OpenXR - Compat B games part 1 * OpenXR - Compat B games part 2 * OpenXR - Compat C games part 1 * OpenXR - Compat C games part 2 * OpenXR - Compat D games * OpenXR - Compat E games * OpenXR - Compat F games * OpenXR - Compat G games * OpenXR - Compat H games * OpenXR - Compat I games * OpenXR - Compat J games * OpenXR - Compat K games * OpenXR - Compat L games * OpenXR - Compat M games * OpenXR - Compat N games * OpenXR - Compat P games * OpenXR - Compat R games * OpenXR - Compat S games * OpenXR - Compat T games * OpenXR - Compat U games * OpenXR - Compat V games * OpenXR - Compat W games * OpenXR - Compat games sorting out part 1 * OpenXR - Compat games sorting out part 2 * OpenXR - Compat games sorting out part 3 * OpenXR - Compat games sorting out part 4 * OpenXR - Compat games sorting out part 5 * OpenXR - Compat games sorting out part 6 * OpenXR - Compat list description * OpenXR - Support getting compatvr.ini from filesystem --- Core/Compatibility.cpp | 21 +- Core/Compatibility.h | 1 + assets/compatvr.ini | 1722 +++++++++++++++++++++++++++------------- 3 files changed, 1194 insertions(+), 550 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 861e926429..f59a0da45b 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -42,21 +42,29 @@ void Compatibility::Load(const std::string &gameID) { } } + { + IniFile compat2; + // This one is user-editable. Need to load it after the system one. + Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compat.ini"; + if (compat2.Load(path.ToString())) { + CheckSettings(compat2, gameID); + } + } + { IniFile compat; // This loads from assets. if (compat.LoadFromVFS("compatvr.ini")) { - CheckSetting(compat, gameID, "Skyplane", &vrCompat_.Skyplane); - CheckSetting(compat, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter); + CheckVRSettings(compat, gameID); } } { IniFile compat2; // This one is user-editable. Need to load it after the system one. - Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compat.ini"; + Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compatvr.ini"; if (compat2.Load(path.ToString())) { - CheckSettings(compat2, gameID); + CheckVRSettings(compat2, gameID); } } } @@ -111,6 +119,11 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "NearestFilteringOnFramebufferCreate", &flags_.NearestFilteringOnFramebufferCreate); } +void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { + CheckSetting(iniFile, gameID, "Skyplane", &vrCompat_.Skyplane); + CheckSetting(iniFile, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter); +} + void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) { if (ignored_.find(option) == ignored_.end()) { iniFile.Get(option, gameID.c_str(), flag, *flag); diff --git a/Core/Compatibility.h b/Core/Compatibility.h index 8bbdc52ebd..5946f1633b 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -114,6 +114,7 @@ public: private: void Clear(); void CheckSettings(IniFile &iniFile, const std::string &gameID); + void CheckVRSettings(IniFile &iniFile, const std::string &gameID); void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag); void CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, float *value); diff --git a/assets/compatvr.ini b/assets/compatvr.ini index c3ec3f926a..92cf0d32d1 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -31,314 +31,508 @@ [Skyplane] +# Workaround to remove the background skyplane and add clearing framebuffer with a fog color. + # Grand Theft Auto: Liberty City Stories -ULUS10041 = true +NPJH50825 = true +ULES00051 = true ULES00151 = true +ULES00181 = true +ULES00182 = true ULJM05255 = true ULJM05359 = true ULJM05885 = true -NPJH50825 = true +ULUS10041 = true # Grand Theft Auto: Vice City Stories +NPJH50827 = true ULES00502 = true -ULUS10160 = true +ULES00503 = true ULJM05297 = true ULJM05395 = true ULJM05884 = true -NPJH50827 = true +ULUS10160 = true [UnitsPerMeter] -# Values exported from https://github.com/CarlKenner/ppsspp/tree/VR/Sys/GameSettings +# Scale of game world to convert the world units into meters. This enables following VR features: +# + 3D stereoscopy (that can work only with accurate values) +# * 6DoF motion tracking (that can work with inaccurate values) + +# cube.elf ELF000000 = 10.0 -JRPG00001 = 80 -JRPG00002 = 80 -NPEG00001 = 1.0 -NPEG00003 = 1000.0 -NPEG00023 = 1.0 -NPEG90003 = 1.0 -NPEH00003 = 30.0 -NPEH00017 = 1.0 -NPEH00031 = 1.0 -NPEH00134 = 8.0 -NPEH00135 = 1.0 -NPEH00138 = 80 -NPEH90011 = 100.0 -NPEH90014 = 1.0 -NPEH90023 = 1000.0 -NPEH90028 = 128.0 -NPEX00005 = 1.0 -NPEZ00007 = 1.0 -NPEZ00008 = 20.0 -NPEZ00011 = 1.0 -NPEZ00023 = 1.0 -NPEZ00041 = 1.0 -NPEZ00044 = 1.0 -NPEZ00045 = 1.0 -NPEZ00081 = 1.0 -NPEZ00101 = 1.0 -NPEZ00104 = 1.0 -NPEZ00107 = 1.0 -NPEZ00108 = 1.0 -NPEZ00118 = 70.0 -NPEZ00127 = 1.0 -NPEZ00140 = 1.0 -NPHG00002 = 1.0 -NPHG00025 = 80.0 -NPHH00351 = 8.0 -NPJB40001 = 100.0 -NPJG00004 = 1000.0 -NPJG00045 = 80.0 -NPJG00103 = 1.0 -NPJG00122 = 100.0 -NPJH00002 = 30.0 -NPJH50040 = 1.0 -NPJH50045 = 1000.0 -NPJH50065 = 1.0 -NPJH50145 = 9.0 -NPJH50148 = 1.0 -NPJH50180 = 1.0 -NPJH50184 = 1000.0 -NPJH50352 = 100 -NPJH50401 = 1.0 -NPJH50414 = 1.0 -NPJH50443 = 100.0 -NPJH50444 = 100.0 -NPJH50448 = 80 -NPJH50457 = 1.0 -NPJH50475 = 4.0 -NPJH50515 = 8.0 -NPJH50625 = 1.8 -NPJH50626 = 8.0 -NPJH50701 = 1.0 -NPJH90066 = 1.0 -NPUG70008 = 1.0 -NPUG80086 = 1000.0 -NPUG80325 = 1.0 -NPUH10006 = 30.0 -NPUH10023 = 1.0 -NPUH10024 = 1.0 -NPUH10026 = 1.0 -NPUH10034 = 1.0 -NPUH10125 = 8.0 -NPUH10126 = 80 -NPUH90019 = 1.0 -NPUH90029 = 1.0 -NPUH90048 = 1.0 -NPUH90067 = 128.0 -NPUX80433 = 1.0 -NPUZ00002 = 1.0 -NPUZ00007 = 1.0 -NPUZ00010 = 1.0 -NPUZ00020 = 1.0 -NPUZ00021 = 1.0 -NPUZ00024 = 1.0 -NPUZ00027 = 20.0 -NPUZ00028 = 1.0 -NPUZ00031 = 1.0 -NPUZ00033 = 70.0 -NPUZ00034 = 1.0 -NPUZ00040 = 1.0 -NPUZ00056 = 1.0 -NPUZ00080 = 1.0 -UCAS40011 = 1.0 -UCAS40012 = 1.0 -UCAS40018 = 9.0 -UCAS40020 = 100.0 -UCAS40021 = 10.0 -UCAS40023 = 9.0 -UCAS40024 = 0.98 -UCAS40025 = 83 -UCAS40026 = 0.1 -UCAS40049 = 1.0 -UCAS40063 = 1.0 -UCAS40076 = 5.0 -UCAS40089 = 9.0 -UCAS40092 = 100.0 -UCAS40095 = 1000.0 -UCAS40098 = 0.96 -UCAS40099 = 1000.0 -UCAS40102 = 1.0 -UCAS40113 = 1000.0 -UCAS40116 = 9.0 -UCAS40119 = 1000.0 + +# 300: March to Glory +ULES00766 = 0.95 +ULUS10241 = 0.95 + +# 50 Cent: Bulletproof G Unit Edition +ULES00451 = 1.0 +ULES00452 = 1.0 +ULUS10128 = 1.0 + +# 7 Wonders of the Ancient World +ULES01037 = 1.0 +ULUS10227 = 1.0 + +# Ace Combat X: Skies of Deception UCAS40120 = 1.0 -UCAS40129 = 7.0 -UCAS40130 = 0.98 -UCAS40145 = 1.0 -UCAS40146 = 6.8 -UCAS40148 = 1.0 -UCAS40149 = 0.96 -UCAS40156 = 9.0 -UCAS40164 = 1000.0 -UCAS40165 = 1000.0 -UCAS40167 = 100.0 UCAS40169 = 1.0 -UCAS40177 = 0.96 -UCAS40179 = 1.0 -UCAS40180 = 9.5 -UCAS40191 = 1.0 -UCAS40193 = 80.0 -UCAS40198 = 1.0 -UCAS40204 = 100.0 -UCAS40212 = 1.0 -UCAS40258 = 0.96 -UCAS40265 = 1.0 -UCAS40318 = 100.0 -UCED00432 = 1.0 -UCED00448 = 1000.0 -UCED00970 = 1.0 -UCED00971 = 1.0 -UCED90007 = 1.0 -UCES00001 = 1.0 -UCES00004 = 0.1 -UCES00010 = 100.0 -UCES00044 = 2.0 -UCES00109 = 5.0 -UCES00178 = 9.0 -UCES00249 = 1.0 -UCES00302 = 100.0 -UCES00304 = 1.0 -UCES00356 = 1000.0 -UCES00420 = 1.0 -UCES00422 = 1000.0 UCES00423 = 1.0 -UCES00465 = 1.0 -UCES00842 = 1.0 -UCES00995 = 80.0 -UCES01245 = 1.0 -UCES01312 = 80.0 -UCES01401 = 1.0 -UCES01421 = 100.0 -UCES01473 = 1.0 -UCET00179 = 5.0 -UCET00247 = 9.0 -UCET00357 = 1.0 -UCET00424 = 1000.0 -UCET00713 = 1.0 -UCJB98011 = 1.0 -UCJM95402 = 9.0 -UCJS10007 = 1.0 -UCJS10008 = 1.0 -UCJS10010 = 9.0 -UCJS10011 = 10.0 -UCJS10017 = 0.98 -UCJS10018 = 83 -UCJS10019 = 0.1 -UCJS10028 = 5.0 -UCJS10041 = 1.0 -UCJS10042 = 0.96 -UCJS10047 = 9.0 -UCJS10048 = 7.0 -UCJS10052 = 1.0 -UCJS10057 = 0.96 -UCJS10061 = 9.5 -UCJS10077 = 80.0 -UCJS10082 = 0.96 -UCJS10085 = 1.0 -UCJS10092 = 1.0 -UCJS10093 = 0.96 -UCJS10100 = 1.0 -UCJS10106 = 1.0 -UCJS10114 = 1.0 -UCJS18005 = 1.0 -UCJS18010 = 0.98 -UCJS18014 = 7.0 -UCJS18015 = 0.96 -UCJX90019 = 7.0 -UCKS45007 = 10.0 -UCKS45008 = 1.0 -UCKS45011 = 9.0 -UCKS45018 = 1.0 -UCKS45020 = 1.0 -UCKS45022 = 1.0 -UCKS45027 = 1000.0 -UCKS45032 = 1000.0 -UCKS45034 = 9.0 UCKS45038 = 1.0 -UCKS45050 = 10.0 -UCKS45052 = 100.0 -UCKS45056 = 6.8 UCKS45067 = 1.0 -UCKS45071 = 9.5 -UCKS45076 = 80.0 -UCKS45120 = 1.0 -UCUS98612 = 1.0 -UCUS98618 = 2.0 -UCUS98623 = 9.0 -UCUS98632 = 1.0 -UCUS98633 = 1.0 -UCUS98647 = 5.0 -UCUS98648 = 1.0 -UCUS98653 = 1.0 -UCUS98654 = 2.0 -UCUS98662 = 1.0 -UCUS98671 = 5.0 -UCUS98681 = 1.0 -UCUS98700 = 7.0 -UCUS98706 = 7.0 -UCUS98711 = 80.0 -UCUS98712 = 1.0 -UCUS98713 = 1.0 -UCUS98717 = 80.0 -UCUS98732 = 80.0 -UCUS98737 = 1.0 -UCUS98740 = 80.0 -UCUS98751 = 100.0 -ULAS40129 = 7.0 -ULAS40155 = 1.0 -ULAS42007 = 1000.0 -ULAS42019 = 1.0 -ULAS42035 = 930.0 -ULAS42037 = 1.0 -ULAS42052 = 10.0 -ULAS42069 = 7.8 -ULAS42072 = 1.0 -ULAS42073 = 7.8 -ULAS42087 = 970.0 -ULAS42093 = 100.0 -ULAS42097 = 10.0 -ULAS42099 = 1.0 -ULAS42110 = 100.0 -ULAS42115 = 1.0 -ULAS42117 = 1.0 -ULAS42119 = 1.0 -ULES00008 = 1000.0 +ULJS00086 = 1.0 +ULJS19018 = 1.0 +ULUS10176 = 1.0 + +# Activision Hits Remixed +ULES00640 = 1.0 +ULUS10186 = 1.0 + +# Age of Zombies +NPEZ00044 = 1.0 +NPUZ00024 = 1.0 + +# Alien Syndrome +ULES00772 = 1.0 +ULUS10245 = 1.0 + +# Ape Escape Academy +NPJG00048 = 100.0 +UCAS40007 = 100.0 +UCES00010 = 100.0 +UCJS10003 = 100.0 +UCJS18007 = 100.0 +UCJS18043 = 100.0 +UCUS98619 = 100.0 + +# Ape Escape Academy 2 +NPJG00049 = 100.0 +UCAS40041 = 100.0 +UCAS40052 = 100.0 +UCAS40123 = 100.0 +UCES00302 = 100.0 +UCJS10020 = 100.0 +UCJS18009 = 100.0 +UCKS45024 = 100.0 + +# Archer Maclean's Mercury +UCAS40021 = 10.0 +UCJS10011 = 10.0 +UCKS45007 = 10.0 ULES00011 = 10.0 -ULES00026 = 0.1 -ULES00033 = 0.005 -ULES00034 = 0.005 -ULES00035 = 0.005 -ULES00051 = 1.0 -ULES00118 = 0.1 -ULES00119 = 0.1 +ULUS10017 = 10.0 + +# Are You Alice? +AAPP11042 = 1.0 +ULJM05848 = 1.0 + +# Army of Two: The 40th Day +NPEH90028 = 128.0 +NPUH90067 = 128.0 +ULAS42215 = 128.0 +ULES01381 = 128.0 +ULJM05643 = 128.0 +ULJM05849 = 128.0 +ULUS10472 = 128.0 + +# Armored Core 3 Portable +NPEH00045 = 1.0 +NPUH10023 = 1.0 +UCAS40268 = 1.0 +ULJM05492 = 1.0 +ULKS46210 = 1.0 + +# Armored Core: Formula Front - Extreme Battle +NPJH50041 = 1.0 +UCAS40004 = 1.0 +UCAS40036 = 1.0 +ULES00219 = 1.0 +ULJS00003 = 1.0 +ULJS19001 = 1.0 +ULKS46003 = 1.0 +ULUS10034 = 1.0 + +# Armored Core: Last Raven Portable +NPEH00046 = 1.0 +NPUH10024 = 1.0 +ULJM05611 = 1.0 +UCAS40302 = 1.0 +UCKS45148 = 1.0 + +# Assassin's Creed: Bloodlines +NPEH00029 = 1.0 +NPUH10032 = 1.0 +ULES01367 = 1.0 +ULKS46231 = 1.0 +ULJM05571 = 1.0 +ULJM05720 = 1.0 +ULUS10455 = 1.0 + +# Astonishia Story +ULES00363 = 1.0 +ULJM05176 = 1.0 +ULKS46021 = 1.0 +ULUS10083 = 1.0 + +# Atari Classics Evolved +ULUS10325 = 1.0 + +# ATV Offroad Fury Pro +UCES00786 = 1.0 +UCUS98648 = 1.0 +UCUS98681 = 1.0 + +# Audition Portable +ULKS46122 = 32.0 + +# B-Boy +UCED00432 = 1.0 +UCES00249 = 1.0 +ULUS10363 = 1.0 + +# Battle Poker +NPUZ00020 = 1.0 + +# BattleZone +ULES00522 = 1.0 +ULET00456 = 1.0 +ULUS10156 = 1.0 + +# Beam 'em up +NPEZ00081 = 1.0 + +# Beaterator +ULES01023 = 1.0 +ULUS10405 = 1.0 + +# Beats +NPEG00001 = 1.0 +NPHG00002 = 1.0 +NPJG00001 = 1.0 +NPUG80060 = 1.0 + +# Big head snooker +NPEZ00104 = 1.0 + +# Black Rock Shooter: The Game +JRPG00001 = 80.0 +JRPG00002 = 80.0 +NPEH00138 = 80.0 +NPJH50448 = 80.0 +NPUH10126 = 80.0 +ULJM05859 = 80.0 + +# Blast Off +NPEZ00041 = 1.0 +NPUZ00021 = 1.0 + +# BlazBlue: Calamity Trigger Portable +NPJH50180 = 1.0 +UCAS40299 = 1.0 +ULJM05613 = 1.0 +ULJM05970 = 1.0 +ULUS10519 = 1.0 + +# BlazBlue: Continuum Shift II +NPJH50401 = 1.0 +UCKS45170 = 1.0 +ULES01526 = 1.0 +ULJM05850 = 1.0 +ULUS10579 = 1.0 + +# Bleach: Heat the Soul 1 +UCAS40011 = 1.0 +UCJS18005 = 1.0 +UCJS10008 = 1.0 + +# Bleach: Heat the Soul 2 +UCAS40024 = 0.98 +UCAS40130 = 0.98 +UCJS18010 = 0.98 +UCJS10017 = 0.98 + +# Bleach: Heat the Soul 3 +UCAS40098 = 0.96 +UCAS40177 = 0.96 +UCJS10042 = 0.96 +UCJS18015 = 0.96 + +# Bleach: Heat the Soul 4 +UCAS40149 = 0.96 +UCAS40216 = 0.96 +UCJS10057 = 0.96 +UCJS18025 = 0.96 + +# Bleach: Heat the Soul 5 +UCAS40210 = 0.96 +UCJS10082 = 0.96 +UCJS18033 = 0.96 + +# Bleach: Heat the Soul 6 +NPJG00021 = 0.96 +UCAS40258 = 0.96 +UCAS40308 = 0.96 +UCJS10093 = 0.96 +UCJS18039 = 0.96 + +# Bleach: Heat the Soul 7 +NPJG00114 = 0.96 +UCAS40314 = 0.96 +UCJS10110 = 0.96 +UCJS18057 = 0.96 +UCKS45158 = 0.96 + +# Bleach: Soul Carnival 1 +NPJG00008 = 1.0 +UCAS40227 = 1.0 +UCAS40234 = 1.0 +UCAS40296 = 1.0 +UCJS10085 = 1.0 +UCJS18038 = 1.0 +UCKS45102 = 1.0 +ULJS10085 = 1.0 + +# Bleach: Soul Carnival 2 +NPJG00070 = 1.0 +UCJS10106 = 1.0 +UCAS40291 = 1.0 +UCAS40297 = 1.0 + +# Bloons +NPEZ00045 = 1.0 +NPUZ00010 = 1.0 + +# Bomberman Land Portable +NPJH50142 = 10.0 +ULAS42097 = 10.0 +ULES00959 = 10.0 +ULJM05181 = 10.0 +ULJM05319 = 10.0 +ULUS10319 = 10.0 + +# Bowling 3D +NPUZ00002 = 1.0 + +# Burnout Legends +NPJH50305 = 1.0 +ULAS42019 = 1.0 ULES00125 = 1.0 -ULES00126 = 10.0 -ULES00135 = 83 -ULES00144 = 1.0 -ULES00151 = 1.0 -ULES00153 = 83 +ULJM05049 = 1.0 +ULJM05228 = 1.0 +ULKS46027 = 1.0 +ULUS10025 = 1.0 + +# Brain Challenge +NPEH00003 = 30.0 +NPJH00002 = 30.0 +NPUH10006 = 30.0 + +# BreakQuest +NPEZ00011 = 1.0 +NPUZ00031 = 1.0 + +# Bubble Trubble +NPEZ00023 = 1.0 +NPUZ00007 = 1.0 + +# Bust-A-Move Deluxe +NPJH50087 = 1.0 +ULES00233 = 1.0 +ULUS10057 = 1.0 +ULJM05116 = 1.0 + +# Cabela's African Safari +ULUS10175 = 1.0 + +# Call of Duty: Roads to Victory +ULES00643 = 1.05 +ULES00644 = 1.05 +ULUS10218 = 1.05 + +# Capcom Classics Collection Reloaded +ULAS42072 = 1.0 +ULES00377 = 1.0 +ULJM05104 = 1.0 +ULJM05280 = 1.0 +ULUS10134 = 1.0 + +# Castlevania: The Dracula X Chronicles +NPJH50028 = 100.0 +ULES00841 = 100.0 +ULJM05287 = 100.0 +ULKS46155 = 100.0 +ULUS10277 = 100.0 + +# Championship Manager +ULES00174 = 1.0 + +# Charge! Tank Squad +NPEX00005 = 1.0 +NPJG00103 = 1.0 +NPUX80433 = 1.0 + +# Chessmaster: The Art of Learning +ULES01013 = 1.0 +ULUS10335 = 1.0 + +# Circles, Circles, Circles +NPEZ00007 = 1.0 +NPUZ00028 = 1.0 + +# Coded Arms: Contagion +ULAS42099 = 1.0 +ULES00718 = 1.0 +ULJM05243 = 1.0 +ULKS46139 = 1.0 +ULUS10184 = 1.0 + +# Coded Soul: Uketsugareshi Idea +NPJG00043 = 9.5 +UCAS40180 = 9.5 +UCJS10061 = 9.5 +UCKS45071 = 9.5 + +# Crash Tag Team Racing ULES00168 = 1.0 ULES00169 = 1.0 ULES00170 = 1.0 ULES00171 = 1.0 ULES00172 = 1.0 -ULES00174 = 1.0 -ULES00181 = 1.0 -ULES00182 = 1.0 -ULES00183 = 1.0 -ULES00210 = 1.0 -ULES00214 = 1.0 -ULES00215 = 1.0 -ULES00216 = 1.0 -ULES00219 = 1.0 -ULES00223 = 1.0 -ULES00227 = 10.0 -ULES00233 = 1.0 -ULES00235 = 1.0 -ULES00277 = 100.0 -ULES00283 = 256.0 -ULES00284 = 930.0 -ULES00307 = 10.0 +ULJM05036 = 1.0 +ULUS10044 = 1.0 + +# Crazy Taxi: Fare Wars +NPJH50490 = 10.0 +ULES00811 = 10.0 +ULJM05340 = 10.0 +ULUS10273 = 10.0 + +# Creature Defense +NPEH00027 = 1.0 +NPJH00006 = 1.0 +NPUH10034 = 1.0 + +# Crimson Gem Saga +UCAS40212 = 1.0 +ULJM05369 = 1.0 +ULKS46142 = 1.0 +ULUS10400 = 1.0 + +# Crimson Room Reverse +NPJH50046 = 32.0 +NPUH10037 = 32.0 +ULJM05408 = 32.0 + +# Crisis Core: Final Fantasy VII +UCAS40167 = 100.0 +UCAS40204 = 100.0 +UCAS40272 = 100.0 +UCKS45052 = 100.0 +ULES01044 = 100.0 +ULES01045 = 100.0 +ULES01046 = 100.0 +ULES01047 = 100.0 +ULJM05254 = 100.0 +ULJM05275 = 100.0 +ULJM05517 = 100.0 +ULUS10336 = 100.0 + +# Crush +ULES00765 = 1.0 +ULUS10238 = 1.0 + +# Crystal Defenders +NPEH00017 = 1.0 +NPJH00005 = 1.0 +NPJH90066 = 1.0 +NPUH10026 = 1.0 +NPUH90048 = 1.0 + +# Cube +ULES00722 = 10.0 +ULJS00108 = 10.0 +ULUS10223 = 10.0 + +# Cubixx +NPEZ00101 = 1.0 +NPUZ00080 = 1.0 + +# D-Cube Planet +NPEZ00008 = 20.0 +NPUZ00027 = 20.0 + +# Dangan-Ronpa +NPJH50515 = 8.0 +ULJS00337 = 8.0 +ULJS00438 = 8.0 +ULJS19060 = 8.0 + +# Daxter +NPEG00025 = 2.0 +UCES00044 = 2.0 +UCKS45025 = 2.0 +UCUS98618 = 2.0 +UCUS98654 = 2.0 + +# Dead or Alive Paradise +NPEH00038 = 0.8 +NPJH50239 = 0.8 +ULES01416 = 0.8 +ULES01431 = 0.8 +ULJM05640 = 0.8 +ULJM08046 = 0.8 +ULKS46246 = 0.8 +ULUS10521 = 0.8 + +# Death Jr. +ULES00144 = 1.0 +ULUS10027 = 1.0 + +# Deflector +NPEZ00127 = 1.0 +NPUZ00040 = 1.0 + +# Diamond and the Sound of a Gunshot +UCJS10092 = 1.0 +UCKS45120 = 1.0 + +# Dissidia 012: Duodecim Final Fantasy +NPJH50377 = 1.0 +UCAS40333 = 1.0 +UCAS40329 = 1.0 +UCAS40335 = 1.0 +UCKS45166 = 1.0 +ULES01505 = 1.0 +ULJM05814 = 1.0 +ULJM06121 = 1.0 +ULUS10566 = 1.0 + +# Dissidia: Final Fantasy +NPEH90014 = 1.0 +NPJH50065 = 1.0 +NPJH50330 = 1.0 +NPUH90029 = 1.0 +UCAS40322 = 1.0 +ULES01270 = 1.0 +ULJM05262 = 1.0 +ULJM05405 = 1.0 +ULJM05550 = 1.0 +ULJM05760 = 1.0 +ULJM05761 = 1.0 +ULUS10437 = 1.0 + +# Disney G-Force +ULES01238 = 1.0 +ULES01239 = 1.0 +ULES01240 = 1.0 +ULUS10439 = 1.0 + +# Disney Hannah Montana: Rock Out the Show +ULES01303 = 1.0 +ULUS10431 = 1.0 + +# Disney/Pixar Cars +UCKS45018 = 1.0 ULES00319 = 1.0 ULES00320 = 1.0 ULES00321 = 1.0 @@ -348,30 +542,11 @@ ULES00324 = 1.0 ULES00325 = 1.0 ULES00326 = 1.0 ULES00327 = 1.0 -ULES00339 = 1.0 -ULES00363 = 1.0 -ULES00377 = 1.0 -ULES00382 = 1.0 -ULES00383 = 50.0 -ULES00419 = 7.8 -ULES00452 = 1.0 -ULES00474 = 0.1 -ULES00475 = 0.1 -ULES00479 = 47.0 -ULES00484 = 1.0 -ULES00502 = 1.0 -ULES00503 = 1.0 -ULES00522 = 1.0 -ULES00567 = 1.0 -ULES00601 = 1.0 -ULES00623 = 0.01 -ULES00640 = 1.0 -ULES00643 = 1.05 -ULES00644 = 1.05 -ULES00645 = 970.0 -ULES00704 = 1.0 -ULES00718 = 1.0 -ULES00722 = 10.0 +ULJM05149 = 1.0 +ULUS10073 = 1.0 + +# Disney/Pixar Ratatouille +UCKS45050 = 10.0 ULES00734 = 10.0 ULES00735 = 10.0 ULES00736 = 10.0 @@ -386,254 +561,709 @@ ULES00746 = 10.0 ULES00747 = 10.0 ULES00748 = 10.0 ULES00749 = 10.0 -ULES00757 = 1.0 -ULES00765 = 1.0 -ULES00766 = 0.95 -ULES00772 = 1.0 -ULES00811 = 10.0 +ULUS10247 = 10.0 + +# DJ Max Fever +NPEH00030 = 1.0 +ULUS10403 = 1.0 + +# DJ Max Portable 2 +ULKS46116 = 1.0 + +# DJ Max Portable 3 +NPJH50471 = 1.0 +ULKS46236 = 1.0 +ULJM05836 = 1.0 +ULJM06033 = 1.0 +ULUS10538 = 1.0 + +# DJ Max Portable: Black Square +NPJH50559 = 1.0 +ULJM06034 = 1.0 +ULKS46189 = 1.0 + +# DJ Max Portable: Clazziquai Edition +ULKS46190 = 1.0 +ULKS46191 = 1.0 + +# DJ Max Portable Hot Tunes +ULKS46240 = 1.0 + +# DreamWorks Shrek the Third +ULES00812 = 0.5 ULES00813 = 0.5 -ULES00841 = 100.0 +ULKS46141 = 0.5 +ULUS10248 = 0.5 + +# Dynasty Warriors +NPJH50030 = 0.1 +ULES00026 = 0.1 +ULES00118 = 0.1 +ULES00119 = 0.1 +ULJM05003 = 0.1 +ULJM08008 = 0.1 +ULJM08017 = 0.1 +ULKS46012 = 0.1 +ULUS10004 = 0.1 + +# Eragon +ULES00474 = 0.1 +ULES00475 = 0.1 +ULUS10146 = 0.1 + +# Evangelion Shin Gekijoban: 3nd Impact +ULAS42293 = 1.0 +ULJS00408 = 1.0 +NPJH50457 = 1.0 + +# F1 Grand Prix +UCAS40026 = 0.1 +UCES00004 = 0.1 +UCJS10019 = 0.1 + +# Family Guy +ULES00567 = 1.0 +ULES00601 = 1.0 +ULUS10185 = 1.0 + +# Fat Princess: Fistful of Cake +NPHG00025 = 80.0 +NPJG00045 = 80.0 +UCAS40285 = 80.0 +UCES01312 = 80.0 +UCKS45137 = 80.0 +UCUS98740 = 80.0 + +# Final Fantasy I +NPJH50406 = 6.8 +UCAS40146 = 6.8 +UCKS45056 = 6.8 +ULES00986 = 6.8 +ULJM05241 = 6.8 +ULJM05514 = 6.8 +ULUS10251 = 6.8 + +# Final Fantasy II +NPJH50407 = 1.0 +UCAS40152 = 1.0 +ULJM05245 = 1.0 +ULJM05515 = 1.0 +ULES00987 = 1.0 +ULUS10263 = 1.0 + +# Final Fantasy III +NPEH00134 = 8.0 +NPHH00351 = 8.0 +NPJH50626 = 8.0 +NPUH10125 = 8.0 +ULJM06133 = 8.0 + +# Final Fantasy IV +NPJH50414 = 1.0 +UCAS40334 = 1.0 +UCAS40342 = 1.0 +ULES01521 = 1.0 +ULJM05855 = 1.0 +ULJM06122 = 1.0 +ULUS10560 = 1.0 + +# Final Fantasy Tactics: The War of the Lions +NPJH50408 = 1.0 +UCAS40148 = 1.0 ULES00850 = 1.0 +ULJM05194 = 1.0 +ULJM05516 = 1.0 +ULUS10297 = 1.0 + +# Final Fantasy Type-0 +NPJH50443 = 100.0 +NPJH50444 = 100.0 +UCAS40346 = 100.0 +ULJM05900 = 100.0 +ULJM06217 = 100.0 + +# flOw +NPEG00003 = 1000.0 +NPJG00004 = 1000.0 +NPUG80086 = 1000.0 + +# Free Running +ULES00704 = 1.0 + +# Ghost in the Shell: Stand Alone Complex +UCAS40025 = 83.0 +UCJS10018 = 83.0 +ULES00135 = 83.0 +ULES00153 = 83.0 +ULUS10020 = 83.0 + +# Ghostbusters: The Video Game +UCES01276 = 3.28 +ULUS10485 = 3.28 +ULUS10486 = 3.28 + +# Gitaroo Man Lives! +NPJH50035 = 50.0 +ULES00383 = 50.0 +ULJM05130 = 50.0 +ULKS46071 = 50.0 +ULUS10207 = 50.0 + +# Gods Eater Burst +NPJH50352 = 100.0 +ULES01519 = 100.0 +ULJS00350 = 100.0 +ULJS00351 = 100.0 +ULJS19056 = 100.0 +ULJS19081 = 100.0 +ULKS46263 = 100.0 +ULUS10563 = 100.0 + +# God of War: Ghost of Sparta +NPEG00044 = 1.0 +NPHG00092 = 1.0 +NPJG00120 = 1.0 +UCAS40323 = 1.0 +UCES01401 = 1.0 +UCES01473 = 1.0 +UCJS10114 = 1.0 +UCKS45161 = 1.0 +UCUS98737 = 1.0 + +# God of War: Chains of Olympus +NPEG00023 = 1.0 +NPUG80325 = 1.0 +UCAS40191 = 1.0 +UCAS40198 = 1.0 +UCED00970 = 1.0 +UCED00971 = 1.0 +UCES00842 = 1.0 +ULJM05348 = 1.0 +UCKS45084 = 1.0 +UCUS98653 = 1.0 +UCUS98705 = 1.0 +UCUS98713 = 1.0 + +# Gran Turismo: The Real Driving Simulator +NPJG00027 = 1.0 +UCAS40265 = 1.0 +UCES01245 = 1.0 +UCJS10100 = 1.0 +UCUS98632 = 1.0 + +# Grand Theft Auto: Chinatown Wars +NPJH00138 = 1.0 +ULES01347 = 1.0 +ULJM05604 = 1.0 +ULUS10490 = 1.0 + +# Grand Theft Auto: Liberty City Stories +NPJH50825 = 1.0 +ULES00051 = 1.0 +ULES00151 = 1.0 +ULES00181 = 1.0 +ULES00182 = 1.0 +ULJM05255 = 1.0 +ULJM05359 = 1.0 +ULJM05885 = 1.0 +ULUS10041 = 1.0 + +# Grand Theft Auto: Vice City Stories +NPJH50827 = 1.0 +ULES00502 = 1.0 +ULES00503 = 1.0 +ULJM05297 = 1.0 +ULJM05395 = 1.0 +ULJM05884 = 1.0 +ULUS10160 = 1.0 + +# Gun Showdown +ULES00484 = 1.0 +ULUS10158 = 1.0 + +# Gungnir +NPEH00135 = 1.0 +NPJH50397 = 1.0 +ULJM05779 = 1.0 +ULUS10592 = 1.0 + +# Harry Potter and the Goblet of Fire +ULES00210 = 1.0 +ULES00214 = 1.0 +ULES00215 = 1.0 +ULES00216 = 1.0 +ULUS10032 = 1.0 + +# Hatsune Miku: Project Diva +NPJH50494 = 3.6 +UCKS45123 = 3.6 +ULAS42163 = 3.6 +ULJM05472 = 3.6 +ULJM05682 = 3.6 + +# Hatsune Miku: Project Diva 2nd +NPJH50475 = 4.0 +ULJM05681 = 4.0 +ULJM05952 = 4.0 + +# Indiana Jones and the Staff of Kings +ULES00939 = 1.0 +ULUS10316 = 1.0 + +# Iron Man 2 +ULES01422 = 1.000999 +ULUS10497 = 1.000999 + +# James Cameron's Avatar: The Game +NPEH00031 = 1.0 +ULES01357 = 1.0 +ULUS10451 = 1.0 + +# Jeanne d'Arc +NPJG00032 = 7.0 +UCAS40129 = 7.0 +UCJS10048 = 7.0 +UCJS18014 = 7.0 +UCJX90019 = 7.0 +UCKS45033 = 7.0 +UCUS98700 = 7.0 +UCUS98706 = 7.0 +ULAS40129 = 7.0 + +# Kingdom Hearts: Birth by Sleep +UCAS40295 = 1.0 +UCAS40317 = 1.0 +UCAS40326 = 1.0 +UCKS45143 = 1.0 +UCKS45168 = 1.0 +ULES01441 = 1.0 +ULJM05600 = 1.0 +ULJM05775 = 1.0 +ULJM06213 = 1.0 +ULJM06214 = 1.0 +ULUS10505 = 1.0 + +# Kingdom of Paradise 1 +UCAS40018 = 9.0 +UCAS40023 = 9.0 +UCAS40089 = 9.0 +UCES00178 = 9.0 +UCET00247 = 9.0 +UCJM95402 = 9.0 +UCJS10010 = 9.0 +UCKS45011 = 9.0 +UCUS98623 = 9.0 + +# Kingdom of Paradise 2 +UCAS40116 = 9.0 +UCAS40156 = 9.0 +UCJS10047 = 9.0 +UCKS45034 = 9.0 + +# LEGO Batman: The Videogame +NPUH90019 = 1.0 +ULES01151 = 1.0 +ULUS10380 = 1.0 + +# LEGO Indiana Jones 1: The Original Adventures +ULES01086 = 47.0 +ULUS10365 = 47.0 + +# LEGO Indiana Jones 2: The Adventure Continues +ULES01370 = 47.0 +ULUS10487 = 47.0 + +# LEGO Star Wars II: The Original Trilogy +ULES00479 = 47.0 +ULUS10155 = 47.0 + +# Lemmings +NPJG00058 = 5.0 +UCAS40076 = 5.0 +UCES00109 = 5.0 +UCET00179 = 5.0 +UCJS10028 = 5.0 +UCUS98647 = 5.0 +UCUS98671 = 5.0 + +# LocoRoco +NPJG00057 = 1.0 +UCAS40063 = 1.0 +UCAS40157 = 1.0 +UCED90007 = 1.0 +UCES00304 = 1.0 +UCET00357 = 1.0 +UCJB98011 = 1.0 +UCJS10041 = 1.0 +UCJS18041 = 1.0 +UCKS45020 = 1.0 +UCKS45055 = 1.0 +UCUS98662 = 1.0 + +# Macross Ace Frontier +ULJS00158 = 1.0 +ULJS19029 = 1.0 + +# Me & My Katamari +NPJH50141 = 1.0 +UCAS40049 = 1.0 +UCKS45022 = 1.0 +ULAS40155 = 1.0 +ULES00339 = 1.0 +ULJS00033 = 1.0 +ULJS19009 = 1.0 +ULUS10094 = 1.0 + +# Mega Man Powered Up +NPJH50183 = 10.0 +UCAS40208 = 10.0 +ULAS42050 = 10.0 +ULAS42052 = 10.0 +ULES00307 = 10.0 +ULJM05044 = 10.0 +ULJM05391 = 10.0 +ULUS10091 = 10.0 + +# Metal Gear Acid 1 +ULAS42007 = 1000.0 +ULES00008 = 1000.0 +ULJM05001 = 1000.0 +ULJM08001 = 1000.0 +ULUS10006 = 1000.0 + +# Metal Gear Acid 2 +ULAS42035 = 930.0 +ULES00284 = 930.0 +ULJM05047 = 930.0 +ULJM08011 = 930.0 +ULKS46065 = 930.0 +ULUS10077 = 930.0 + +# Metal Gear Solid: Digital Graphic Novel +NPJH50128 = 1.0 +ULES00382 = 1.0 +ULJM05150 = 1.0 +ULUS10108 = 1.0 + +# Metal Gear Solid: Peace Walker +NPEH90023 = 1000.0 +NPJH50045 = 1000.0 +ULES01372 = 1000.0 +ULJM05630 = 1000.0 +ULJM08038 = 1000.0 +ULKS46239 = 1000.0 +ULUS10509 = 1000.0 + +# Metal Gear Solid: Portable Ops +NPJH50112 = 970.0 +ULAS42087 = 970.0 +ULES00645 = 970.0 +ULJM05193 = 970.0 +ULJM05227 = 970.0 +ULJM05256 = 970.0 +ULJM05284 = 970.0 +ULJM05573 = 970.0 +ULJM08016 = 970.0 +ULKS46119 = 970.0 +ULUS10202 = 970.0 + +# Monopoly +NPEZ00118 = 70.0 +NPUZ00033 = 70.0 + +# Monster Hunter Freedom 2 +ULAS42110 = 100.0 ULES00851 = 100.0 +ULJM05156 = 100.0 +ULKS46152 = 100.0 +ULUS10266 = 100.0 + +# Monster Hunter Freedom Unite +NPEH90011 = 100.0 +NPJH50244 = 100.0 +ULAS42093 = 100.0 +ULES01213 = 100.0 +ULJM05500 = 100.0 +ULJM08019 = 100.0 +ULJM08053 = 100.0 +ULKS46177 = 100.0 +ULKS46202 = 100.0 +ULUS10391 = 100.0 +ULUS90003 = 100.0 + +# Monster Hunter Portable 3rd +NPJB40001 = 100.0 +NPJH55800 = 100.0 +ULJM05800 = 100.0 +ULJM08058 = 100.0 + +# Nayuta no Kiseki +NPJH50625 = 1.0 +ULJM06113 = 1.0 +ULJM08069 = 1.0 + +# Patapon 1 +NPJG00054 = 80.0 +UCAS40193 = 80.0 +UCAS40221 = 80.0 +UCES00995 = 80.0 +UCJS10077 = 80.0 +UCJS18027 = 80.0 +UCJS18042 = 80.0 +UCKS45076 = 80.0 +UCUS98711 = 80.0 +UCUS98717 = 80.0 + +# Patapon 2 +NPJG00010 = 80.0 +NPUG98732 = 80.0 +UCAS40232 = 80.0 +UCAS40239 = 80.0 +UCAS40292 = 80.0 +UCES01177 = 80.0 +UCJS10089 = 80.0 +UCJS18036 = 80.0 +UCJS18053 = 80.0 +UCUS98732 = 80.0 + +# Patapon 3 +NPJG00122 = 100.0 +UCAS40318 = 100.0 +UCES01421 = 100.0 +UCJS10113 = 100.0 +UCJS18048 = 100.0 +UCJS18059 = 100.0 +UCKS45169 = 100.0 +UCUS98751 = 100.0 + +# Petz: Dogz Family +ULUS10463 = 3.28 + +# Prince of Persia Revelations +ULES00223 = 1.0 +ULUS10063 = 1.0 + +# Ratchet & Clank: Size Matters +NPJG00015 = 1.0 +UCAS40145 = 1.0 +UCES00420 = 1.0 +UCJS10052 = 1.0 +UCJS18030 = 1.0 +UCJS18047 = 1.0 +UCKS45048 = 1.0 +UCUS98633 = 1.0 + +# Ridge Racer 2 +NPJH50366 = 1000.0 +UCAS40113 = 1000.0 +UCAS40119 = 1000.0 +UCAS40273 = 1000.0 +UCES00422 = 1000.0 +UCKS45032 = 1000.0 +ULJS00080 = 1000.0 + +# Sega Rally Revo +ULAS42119 = 1.0 +ULES00910 = 1.0 +ULET00919 = 1.0 +ULJM05302 = 1.0 +ULJM05417 = 1.0 +ULUS10311 = 1.0 + +# Shin Megami Tensei: Persona 3 Portable +NPJH50040 = 1.0 +UCAS40288 = 1.0 +UCKS45140 = 1.0 +UCKS45175 = 1.0 +ULES01523 = 1.0 +ULJM05489 = 1.0 +ULJM08044 = 1.0 +ULUS10512 = 1.0 + +# Silent Hill: Origins +NPJH50051 = 1.0 +ULAS42117 = 1.0 ULES00869 = 1.0 -ULES00959 = 1.0 +ULJM05281 = 1.0 +ULKS46161 = 1.0 +ULUS10285 = 1.0 + +# Silent Hill: Shattered Memories +NPJH50148 = 1.0 +ULAS42189 = 1.0 +ULES01352 = 1.0 +ULJM05564 = 1.0 +ULJM05828 = 1.0 +ULUS10450 = 1.0 + +# SoulCalibur: Broken Destiny +NPJH50034 = 1.0 +UCKS45126 = 1.0 +ULES01298 = 1.0 +ULJS00202 = 1.0 +ULJS19055 = 1.0 +ULUS10457 = 1.0 + +# Spectral vs Generation +UCAS40102 = 1.0 +ULES00757 = 1.0 +ULJM05162 = 1.0 +ULJM05599 = 1.0 +ULUS10076 = 1.0 + +# Spot the Differences! +NPEZ00107 = 1.0 +NPEZ00108 = 1.0 +NPUZ00034 = 1.0 + +# Star Soldier +NPJH50261 = 1.0 +ULJM05026 = 1.0 +ULJM05235 = 1.0 + +# Star Trek: Tactical Assault +ULES00623 = 0.01 +ULUS10150 = 0.01 + +# Star Wars: Battlefront II +ULAS42037 = 1.0 +ULES00183 = 1.0 +ULJM05060 = 1.0 +ULUS10053 = 1.0 + +# Star Wars: The Force Unleashed +ULES00981 = 100.0 +ULES00982 = 100.0 +ULKS46143 = 100.0 +ULUS10345 = 100.0 + +# Street Fighter Alpha 3 MAX +ULES00235 = 1.0 +ULJM05082 = 1.0 +ULJM05225 = 1.0 +ULUS10062 = 1.0 + +# Sword Art Online: Infinity Moment +NPJH50701 = 1.0 +ULJS00557 = 1.0 +ULJS00558 = 1.0 + +# Tekken: Dark Resurrection +NPJH50137 = 1000.0 +UCAS40095 = 1000.0 +UCAS40099 = 1000.0 +UCAS40164 = 1000.0 +UCAS40165 = 1000.0 +UCED00448 = 1000.0 +UCES00356 = 1000.0 +UCET00424 = 1000.0 +UCKS45027 = 1000.0 +ULJS00048 = 1000.0 +ULJS19013 = 1000.0 +ULUS10139 = 1000.0 + +# Tekken 6 +NPJH50184 = 1000.0 +NPUH10047 = 1000.0 +ULAS42214 = 1000.0 +ULES01376 = 1000.0 +ULJS00224 = 1000.0 +ULJS19054 = 1000.0 +ULKS46235 = 1000.0 +ULKS46265 = 1000.0 +ULUS10466 = 1000.0 + +# Tenchu: Shadow Assassins +UCAS40247 = 10.0 +ULES01237 = 10.0 +ULJM05425 = 10.0 +ULJM05471 = 10.0 +ULJM08027 = 10.0 +ULUS10419 = 10.0 + +# Tenchu: Time of the Assassins +NPJH50042 = 100.0 +UCAS40020 = 100.0 +UCAS40092 = 100.0 +ULES00277 = 100.0 +ULJS00018 = 100.0 +ULJS19007 = 100.0 + +# The 3rd Birthday +NPJH50361 = 100.0 +UCAS40325 = 100.0 +UCAS40336 = 100.0 +UCKS45163 = 100.0 +ULES01513 = 100.0 +ULJM05798 = 100.0 +ULJM06008 = 100.0 +ULUS10567 = 100.0 + +# The Simpsons Game +ULAS42115 = 1.0 ULES00975 = 1.0 ULES00976 = 1.0 ULES00977 = 1.0 ULES00978 = 1.0 ULES00979 = 1.0 -ULES00981 = 100.0 -ULES00982 = 100.0 -ULES00986 = 6.8 -ULES00987 = 1.0 -ULES01013 = 1.0 -ULES01037 = 1.0 -ULES01044 = 100.0 -ULES01045 = 100.0 -ULES01046 = 100.0 -ULES01047 = 100.0 -ULES01086 = 47.0 -ULES01151 = 1.0 -ULES01213 = 100.0 -ULES01237 = 10.0 -ULES01238 = 1.0 -ULES01239 = 1.0 -ULES01240 = 1.0 -ULES01270 = 1.0 -ULES01298 = 1.0 -ULES01347 = 1.0 -ULES01352 = 1.0 -ULES01357 = 1.0 -ULES01367 = 1.0 -ULES01370 = 47.0 -ULES01372 = 1000.0 -ULES01376 = 1000.0 -ULES01381 = 128.0 -ULES01417 = 9.0 -ULES01422 = 1.000999 -ULES01431 = 0.8 -ULES01441 = 1.0 -ULES01505 = 1.0 -ULES01513 = 100.0 -ULES01519 = 100 -ULES01521 = 1.0 -ULES01523 = 1.0 -ULES01526 = 1.0 -ULET00456 = 1.0 -ULET00919 = 1.0 -ULJM05001 = 1000.0 -ULJM05003 = 0.1 -ULJM05026 = 1.0 -ULJM05036 = 1.0 -ULJM05047 = 930.0 -ULJM05049 = 1.0 -ULJM05060 = 1.0 -ULJM05082 = 1.0 -ULJM05104 = 1.0 -ULJM05105 = 1.0 -ULJM05130 = 50.0 -ULJM05149 = 1.0 -ULJM05150 = 1.0 -ULJM05156 = 100.0 -ULJM05162 = 1.0 -ULJM05176 = 1.0 -ULJM05180 = 256.0 -ULJM05181 = 10.0 -ULJM05193 = 970.0 -ULJM05194 = 1.0 -ULJM05227 = 970.0 -ULJM05228 = 1.0 -ULJM05235 = 1.0 -ULJM05241 = 6.8 -ULJM05243 = 1.0 -ULJM05245 = 1.0 -ULJM05254 = 100.0 -ULJM05255 = 1.0 -ULJM05262 = 1.0 -ULJM05275 = 100.0 -ULJM05280 = 1.0 -ULJM05281 = 1.0 -ULJM05284 = 970.0 -ULJM05287 = 100.0 -ULJM05297 = 1.0 -ULJM05302 = 1.0 -ULJM05319 = 10.0 -ULJM05340 = 1.0 -ULJM05348 = 1.0 -ULJM05369 = 1.0 -ULJM05408 = 32.0 -ULJM05425 = 10.0 -ULJM05471 = 10.0 -ULJM05472 = 3.6 -ULJM05492 = 1.0 -ULJM05550 = 1.0 -ULJM05571 = 1.0 -ULJM05600 = 1.0 -ULJM05604 = 1.0 -ULJM05643 = 128.0 -ULJM05681 = 4.0 -ULJM05775 = 1.0 -ULJM05779 = 1.0 -ULJM05798 = 100.0 -ULJM05836 = 1.0 -ULJM05848 = 1.0 -ULJM05859 = 80 -ULJM06034 = 1.0 -ULJM08001 = 1000.0 -ULJM08011 = 930.0 -ULJM08027 = 10.0 -ULJS00003 = 1.0 -ULJS00018 = 100.0 -ULJS00033 = 1.0 -ULJS00048 = 1000.0 -ULJS00080 = 1000.0 -ULJS00086 = 1.0 -ULJS00158 = 1.0 -ULJS00202 = 1.0 -ULJS00224 = 1000.0 -ULJS00350 = 100 -ULJS19001 = 1.0 -ULJS19007 = 100.0 -ULJS19009 = 1.0 -ULJS19013 = 1000.0 -ULJS19018 = 1.0 -ULKS46003 = 1.0 -ULKS46012 = 0.1 -ULKS46021 = 1.0 -ULKS46023 = 10.0 -ULKS46027 = 1.0 -ULKS46057 = 10.0 -ULKS46065 = 930.0 -ULKS46071 = 50.0 -ULKS46116 = 1.0 -ULKS46119 = 970.0 -ULKS46122 = 32.0 -ULKS46139 = 1.0 -ULKS46142 = 1.0 -ULKS46152 = 100.0 -ULKS46155 = 100.0 -ULKS46189 = 1.0 -ULKS46190 = 1.0 -ULKS46236 = 1.0 -ULKS46240 = 1.0 -ULUS10004 = 0.1 -ULUS10006 = 1000.0 -ULUS10014 = 0.005 -ULUS10017 = 10.0 -ULUS10020 = 83 -ULUS10025 = 1.0 -ULUS10027 = 1.0 -ULUS10032 = 1.0 -ULUS10034 = 1.0 -ULUS10037 = 10.0 -ULUS10041 = 1.0 -ULUS10044 = 1.0 -ULUS10050 = 10.0 -ULUS10053 = 1.0 -ULUS10057 = 1.0 -ULUS10062 = 1.0 -ULUS10063 = 1.0 -ULUS10073 = 1.0 -ULUS10077 = 930.0 -ULUS10083 = 1.0 -ULUS10091 = 10.0 -ULUS10094 = 1.0 -ULUS10105 = 7.8 -ULUS10108 = 1.0 -ULUS10110 = 256.0 -ULUS10128 = 1.0 -ULUS10134 = 1.0 -ULUS10139 = 1000.0 -ULUS10146 = 0.1 -ULUS10150 = 0.01 -ULUS10155 = 47.0 -ULUS10156 = 1.0 -ULUS10158 = 1.0 -ULUS10160 = 1.0 -ULUS10175 = 1.0 -ULUS10176 = 1.0 -ULUS10184 = 1.0 -ULUS10185 = 1.0 -ULUS10186 = 1.0 -ULUS10202 = 970.0 -ULUS10207 = 50.0 -ULUS10218 = 1.05 -ULUS10223 = 10.0 -ULUS10227 = 1.0 -ULUS10238 = 1.0 -ULUS10241 = 0.95 -ULUS10245 = 1.0 -ULUS10247 = 10.0 -ULUS10248 = 0.5 -ULUS10251 = 6.8 -ULUS10263 = 1.0 -ULUS10266 = 100.0 -ULUS10273 = 1.0 -ULUS10277 = 100.0 -ULUS10285 = 1.0 ULUS10295 = 1.0 -ULUS10297 = 1.0 -ULUS10311 = 1.0 -ULUS10316 = 1.0 -ULUS10319 = 10.0 -ULUS10325 = 1.0 -ULUS10335 = 1.0 -ULUS10336 = 100.0 -ULUS10345 = 100.0 -ULUS10363 = 1.0 -ULUS10365 = 47.0 -ULUS10380 = 1.0 -ULUS10391 = 100.0 -ULUS10400 = 1.0 -ULUS10403 = 1.0 -ULUS10405 = 1.0 -ULUS10419 = 10.0 -ULUS10431 = 1.0 -ULUS10437 = 1.0 -ULUS10439 = 1.0 -ULUS10450 = 1.0 -ULUS10451 = 1.0 -ULUS10455 = 1.0 -ULUS10457 = 1.0 -ULUS10463 = 3.28 -ULUS10466 = 1000.0 -ULUS10472 = 128.0 -ULUS10486 = 3.28 -ULUS10487 = 47.0 -ULUS10490 = 1.0 -ULUS10497 = 1.000999 -ULUS10505 = 1.0 -ULUS10509 = 1000.0 -ULUS10512 = 1.0 -ULUS10515 = 9.0 -ULUS10519 = 1.0 -ULUS10521 = 0.8 -ULUS10538 = 1.0 -ULUS10560 = 1.0 -ULUS10563 = 100 -ULUS10566 = 1.0 -ULUS10567 = 100.0 -ULUS10579 = 1.0 -ULUS10592 = 1.0 -ULUS90003 = 100.0 +# The Terminator +NPEZ00140 = 1.0 +NPUZ00056 = 1.0 + +# Tomb Raider: Legend +ULES00283 = 256.0 +ULJM05180 = 256.0 +ULUS10110 = 256.0 + +# Tony Hawk's Underground 2 Remix +ULES00033 = 0.005 +ULES00034 = 0.005 +ULES00035 = 0.005 +ULUS10014 = 0.005 + +# Ultimate Ghosts 'n Goblins +NPJH50235 = 7.8 +ULAS42069 = 7.8 +ULAS42073 = 7.8 +ULES00419 = 7.8 +ULJM05147 = 7.8 +ULUS10105 = 7.8 + +# Valkyria Chronicles II +NPJH50145 = 9.0 +ULES01417 = 9.0 +ULJM05560 = 9.0 +ULJM05807 = 9.0 +ULUS10515 = 9.0 + +# Virtua Tennis: World Tour +ULES00126 = 10.0 +ULJM05079 = 10.0 +ULKS46023 = 10.0 +ULUS10037 = 10.0 + +# Wipeout Pulse +NPEG90003 = 1.0 +NPUG70008 = 1.0 +UCAS40179 = 1.0 +UCES00465 = 1.0 +UCET00713 = 1.0 +UCKS45078 = 1.0 +UCUS98712 = 1.0 + +# Wipeout Pure +NPJG00059 = 1.0 +UCAS40012 = 1.0 +UCES00001 = 1.0 +ULJM05105 = 1.0 +UCJS10007 = 1.0 +UCKS45008 = 1.0 +UCUS98612 = 1.0 + +# WWE SmackDown! vs. Raw 2006 +ULES00227 = 10.0 +ULJM05103 = 10.0 +ULKS46057 = 10.0 +ULUS10050 = 10.0 From df04280c3473ac211cf2ebf83d8cf8453fa83953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Von=C3=A1sek?= Date: Sat, 22 Oct 2022 16:45:57 +0200 Subject: [PATCH 221/374] OpenXR - Wrong condition removed (#16271) --- Common/VR/PPSSPPVR.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index edb88a3400..a3f550bee3 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -367,8 +367,6 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { // Quick analyze if the object is in 2D if ((fabs(fabs(projMatrix[12]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[13]) - 1.0f) < EPSILON) && (fabs(fabs(projMatrix[14]) - 1.0f) < EPSILON)) { return true; - } else if ((fabs(projMatrix[0] - 1) < EPSILON) && (fabs(projMatrix[5] - 1) < EPSILON)) { - return true; } else if ((fabs(projMatrix[0]) > 10.0f) && (fabs(projMatrix[5]) > 10.0f)) { return true; } else if (fabs(projMatrix[15] - 1) < EPSILON) { From 767bf55afb28ebc9dfc4bc3c5e66261f4b33f75d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 22 Oct 2022 17:11:40 +0200 Subject: [PATCH 222/374] Remove duplicate line in libretro makefile. Fixes #16269 --- libretro/Makefile.common | 1 - 1 file changed, 1 deletion(-) diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 7a8fd74121..cd9f7f04d7 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -321,7 +321,6 @@ SOURCES_CXX += \ $(COMMONDIR)/VR/VRMath.cpp \ $(COMMONDIR)/VR/VRFramebuffer.cpp \ $(COMMONDIR)/VR/VRInput.cpp \ - $(COMMONDIR)/VR/VRMath.cpp \ $(COMMONDIR)/VR/VRRenderer.cpp SOURCES_C +=\ From 3af86ec6f7d0a26541104c92b216d4b0a1d5041c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 22 Oct 2022 17:41:42 +0200 Subject: [PATCH 223/374] Make it possible to specify extensions for Vulkan in the ShaderWriter --- Common/GPU/ShaderWriter.cpp | 14 ++++++++------ Common/GPU/ShaderWriter.h | 7 ++++--- GPU/Common/FragmentShaderGenerator.cpp | 2 +- GPU/Common/GeometryShaderGenerator.cpp | 2 +- GPU/Common/StencilCommon.cpp | 4 ++-- GPU/Common/VertexShaderGenerator.cpp | 2 +- unittest/TestShaderGenerators.cpp | 2 +- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index 7ca6deaeb0..0f0d416bf7 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -7,7 +7,6 @@ #include "Common/Log.h" const char * const vulkan_glsl_preamble_fs = -"#version 450\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" "#extension GL_ARB_conservative_depth : enable\n" @@ -45,7 +44,6 @@ static const char * const hlsl_d3d9_preamble_fs = "#define DISCARD_BELOW(x) clip(x)\n"; static const char * const vulkan_glsl_preamble_vs = -"#version 450\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" "#define mul(x, y) ((x) * (y))\n" @@ -69,7 +67,6 @@ static const char * const hlsl_preamble_gs = "\n"; static const char * const vulkan_glsl_preamble_gs = -"#version 450\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" "#define mul(x, y) ((x) * (y))\n" @@ -113,9 +110,14 @@ ShaderWriter & ShaderWriter::F(const char *format, ...) { return *this; } -void ShaderWriter::Preamble(const char **gl_extensions, size_t num_gl_extensions) { +void ShaderWriter::Preamble(Slice extensions) { switch (lang_.shaderLanguage) { case GLSL_VULKAN: + C("#version 450\n"); + // IMPORTANT! Extensions must be the first thing after #version. + for (size_t i = 0; i < extensions.size(); i++) { + F("%s\n", extensions[i]); + } switch (stage_) { case ShaderStage::Vertex: W(vulkan_glsl_preamble_vs); @@ -154,8 +156,8 @@ void ShaderWriter::Preamble(const char **gl_extensions, size_t num_gl_extensions default: // OpenGL F("#version %d%s\n", lang_.glslVersionNumber, lang_.gles && lang_.glslES30 ? " es" : ""); // IMPORTANT! Extensions must be the first thing after #version. - for (size_t i = 0; i < num_gl_extensions; i++) { - F("%s\n", gl_extensions[i]); + for (size_t i = 0; i < extensions.size(); i++) { + F("%s\n", extensions[i]); } // Print some system info - useful to gather information directly from screenshots. if (strlen(lang_.driverInfo) != 0) { diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 50f3bb1f0d..a957362b70 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -37,8 +37,9 @@ enum FSFlags { class ShaderWriter { public: - ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, const char **gl_extensions = nullptr, size_t num_gl_extensions = 0) : p_(buffer), lang_(lang), stage_(stage) { - Preamble(gl_extensions, num_gl_extensions); + // Extensions are supported for both OpenGL ES and Vulkan (though of course, they're different). + ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, Slice extensions = Slice()) : p_(buffer), lang_(lang), stage_(stage) { + Preamble(extensions); } ShaderWriter(const ShaderWriter &) = delete; @@ -110,7 +111,7 @@ private: void DeclareSampler2D(const char *name, int binding); void DeclareTexture2D(const char *name, int binding); - void Preamble(const char **gl_extensions, size_t num_gl_extensions); + void Preamble(Slice extensions); char *p_; const ShaderLanguageDesc &lang_; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 5fe27b19c0..223cd7976f 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -74,7 +74,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } } - ShaderWriter p(buffer, compat, ShaderStage::Fragment, gl_exts.data(), gl_exts.size()); + ShaderWriter p(buffer, compat, ShaderStage::Fragment, gl_exts); bool lmode = id.Bit(FS_BIT_LMODE); bool doTexture = id.Bit(FS_BIT_DO_TEXTURE); diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 18a2bc182e..fc8a9f9a27 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -48,7 +48,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); bool clipClampedDepth = gstate_c.Use(GPU_USE_DEPTH_CLAMP); - ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts.data(), gl_exts.size()); + ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts); p.C("layout(triangles) in;\n"); if (clipClampedDepth && vertexRangeCulling && !gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { p.C("layout(triangle_strip, max_vertices = 12) out;\n"); diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index 02dea5f739..fd552208f7 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -84,7 +84,7 @@ static const SamplerDef samplers[1] = { }; void GenerateStencilFs(char *buffer, const ShaderLanguageDesc &lang, const Draw::Bugs &bugs) { - ShaderWriter writer(buffer, lang, ShaderStage::Fragment, nullptr, 0); + ShaderWriter writer(buffer, lang, ShaderStage::Fragment); writer.HighPrecisionFloat(); writer.DeclareSamplers(samplers); @@ -111,7 +111,7 @@ void GenerateStencilFs(char *buffer, const ShaderLanguageDesc &lang, const Draw: // This can probably be shared with some other shaders, like reinterpret or the future depth upload. void GenerateStencilVs(char *buffer, const ShaderLanguageDesc &lang) { - ShaderWriter writer(buffer, lang, ShaderStage::Vertex, nullptr, 0); + ShaderWriter writer(buffer, lang, ShaderStage::Vertex); writer.BeginVSMain(lang.vertexIndex ? Slice::empty() : inputs, Slice::empty(), varyings); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index ab8ed2a80f..5b7e321277 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -153,7 +153,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag } } - ShaderWriter p(buffer, compat, ShaderStage::Vertex, gl_exts.data(), gl_exts.size()); + ShaderWriter p(buffer, compat, ShaderStage::Vertex, gl_exts); bool isModeThrough = id.Bit(VS_BIT_IS_THROUGH); bool lmode = id.Bit(VS_BIT_LMODE); diff --git a/unittest/TestShaderGenerators.cpp b/unittest/TestShaderGenerators.cpp index d5f2f9cc55..a9546408a5 100644 --- a/unittest/TestShaderGenerators.cpp +++ b/unittest/TestShaderGenerators.cpp @@ -243,7 +243,7 @@ bool TestReinterpretShaders() { for (int j = 0; j < 3; j++) { if (i == j) continue; // useless shader! - ShaderWriter writer(buffer, desc, ShaderStage::Fragment, nullptr, 0); + ShaderWriter writer(buffer, desc, ShaderStage::Fragment); GenerateReinterpretFragmentShader(writer, fmts[i], fmts[j]); if (strlen(buffer) >= 8192) { printf("Reinterpret fragment shader %d exceeded buffer:\n\n%s\n", (int)j, LineNumberString(buffer).c_str()); From 299033929ad53ab685f728ea3451fb826c6774b2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 09:04:48 -0700 Subject: [PATCH 224/374] GE Debugger: List verts on bounding box command. --- Windows/GEDebugger/TabVertices.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Windows/GEDebugger/TabVertices.cpp b/Windows/GEDebugger/TabVertices.cpp index f7ab9af7ac..024938a43d 100644 --- a/Windows/GEDebugger/TabVertices.cpp +++ b/Windows/GEDebugger/TabVertices.cpp @@ -293,7 +293,7 @@ int CtrlVertexList::GetRowCount() { DisplayList list; if (gpuDebug->GetCurrentDisplayList(list)) { u32 cmd = Memory::Read_U32(list.pc); - if ((cmd >> 24) == GE_CMD_PRIM) { + if ((cmd >> 24) == GE_CMD_PRIM || (cmd >> 24) == GE_CMD_BOUNDINGBOX) { rowCount_ = cmd & 0xFFFF; } else if ((cmd >> 24) == GE_CMD_BEZIER || (cmd >> 24) == GE_CMD_SPLINE) { u32 u = (cmd & 0x00FF) >> 0; From 6ddf22487b3dd43d79a529a2504e5d0640f948b6 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 09:06:33 -0700 Subject: [PATCH 225/374] GPU: Correct bounding box for larger counts. Matches tests on a PSP with float/transform format. --- GPU/Common/DrawEngineCommon.cpp | 6 +----- GPU/Common/DrawEngineCommon.h | 2 +- GPU/GPUCommon.cpp | 23 ++++++++++++++++++----- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 495b206515..46742e79b7 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -244,7 +244,7 @@ void DrawEngineCommon::DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex // // It does the simplest and safest test possible: If all points of a bbox is outside a single of // our clipping planes, we reject the box. Tighter bounds would be desirable but would take more calculations. -bool DrawEngineCommon::TestBoundingBox(const void* control_points, int vertexCount, u32 vertType, int *bytesRead) { +bool DrawEngineCommon::TestBoundingBox(const void* control_points, int vertexCount, u32 vertType) { SimpleVertex *corners = (SimpleVertex *)(decoded + 65536 * 12); float *verts = (float *)(decoded + 65536 * 18); @@ -252,19 +252,16 @@ bool DrawEngineCommon::TestBoundingBox(const void* control_points, int vertexCou // and a large vertex format. if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_FLOAT) { verts = (float *)control_points; - *bytesRead = 3 * sizeof(float) * vertexCount; } else if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_8BIT) { const s8 *vtx = (const s8 *)control_points; for (int i = 0; i < vertexCount * 3; i++) { verts[i] = vtx[i] * (1.0f / 128.0f); } - *bytesRead = 3 * sizeof(s8) * vertexCount; } else if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_16BIT) { const s16 *vtx = (const s16*)control_points; for (int i = 0; i < vertexCount * 3; i++) { verts[i] = vtx[i] * (1.0f / 32768.0f); } - *bytesRead = 3 * sizeof(s16) * vertexCount; } else { // Simplify away bones and morph before proceeding u8 *temp_buffer = decoded + 65536 * 24; @@ -275,7 +272,6 @@ bool DrawEngineCommon::TestBoundingBox(const void* control_points, int vertexCou verts[i * 3 + 1] = corners[i].pos.y; verts[i * 3 + 2] = corners[i].pos.z; } - *bytesRead = vertexSize * vertexCount; } Plane planes[6]; diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 8fc0382a29..7a6ba863fd 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -92,7 +92,7 @@ public: virtual void DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex *buffer, int vertexCount, int cullMode, bool continuation); - bool TestBoundingBox(const void* control_points, int vertexCount, u32 vertType, int *bytesRead); + bool TestBoundingBox(const void* control_points, int vertexCount, u32 vertType); void SubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead); template diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 7a6b3fea88..35d91df78a 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -2153,13 +2153,17 @@ void GPUCommon::Execute_Spline(u32 op, u32 diff) { void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) { // Just resetting, nothing to check bounds for. - const u32 count = op & 0xFFFFFF; + const u32 count = op & 0xFFFF; if (count == 0) { currentList->bboxResult = false; return; } - if (((count & 7) == 0) && count <= 64) { // Sanity check - const void *control_points = Memory::GetPointer(gstate_c.vertexAddr); + + VertexDecoder *dec = drawEngineCommon_->GetVertexDecoder(gstate.vertType); + int bytesRead = dec->VertexSize() * count; + + if (Memory::IsValidRange(gstate_c.vertexAddr, bytesRead)) { + const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr); if (!control_points) { ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Invalid verts in bounding box check"); currentList->bboxResult = true; @@ -2174,8 +2178,17 @@ void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) { } // Test if the bounding box is within the drawing region. - int bytesRead; - currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, count, gstate.vertType, &bytesRead); + // The PSP only seems to vary the result based on a single range of 0x100. + if (count > 0x200) { + // The second to last set of 0x100 is checked (even for odd counts.) + size_t skipSize = (count - 0x200) * dec->VertexSize(); + currentList->bboxResult = drawEngineCommon_->TestBoundingBox((const uint8_t *)control_points + skipSize, 0x100, gstate.vertType); + } else if (count > 0x100) { + int checkSize = count - 0x100; + currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, checkSize, gstate.vertType); + } else { + currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, count, gstate.vertType); + } AdvanceVerts(gstate.vertType, count, bytesRead); } else { ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Bad bounding box data: %06x", count); From b7a617023c31fdc9cd399a8c7448de92e9aea075 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 09:09:17 -0700 Subject: [PATCH 226/374] GPU: Consume cycles in bounding box check. --- GPU/GPUCommon.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 35d91df78a..4fb2963851 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -2159,6 +2159,9 @@ void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) { return; } + // Approximate based on timings of several counts on a PSP. + cyclesExecuted += count * 22; + VertexDecoder *dec = drawEngineCommon_->GetVertexDecoder(gstate.vertType); int bytesRead = dec->VertexSize() * count; From 519c90e0494952890b1f58965d8a599cc80fe4fb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 09:41:09 -0700 Subject: [PATCH 227/374] GPU: Correct large morph vertex advance. Can be 544 bytes per vertex. --- GPU/Common/VertexDecoderCommon.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index 6a06093902..d3785e13c9 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -460,7 +460,8 @@ public: bool throughmode; bool skinInDecode; - u8 size; + // With morph and weights, this can be more than 256 bytes. + u16 size; u8 onesize_; u8 weightoff; From 8b80c5fb28871ad65f8508092f737281c9995ac4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 10:01:56 -0700 Subject: [PATCH 228/374] GPU: Allow/use indices in bounding box check. Not sure any games actually use this, but it's supported. --- GPU/Common/DrawEngineCommon.cpp | 27 ++++++++++++++++++--------- GPU/Common/DrawEngineCommon.h | 2 +- GPU/GPUCommon.cpp | 23 ++++++++++++++--------- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 46742e79b7..ad3f733a40 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -244,33 +244,42 @@ void DrawEngineCommon::DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex // // It does the simplest and safest test possible: If all points of a bbox is outside a single of // our clipping planes, we reject the box. Tighter bounds would be desirable but would take more calculations. -bool DrawEngineCommon::TestBoundingBox(const void* control_points, int vertexCount, u32 vertType) { +bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *inds, int vertexCount, u32 vertType) { SimpleVertex *corners = (SimpleVertex *)(decoded + 65536 * 12); float *verts = (float *)(decoded + 65536 * 18); // Try to skip NormalizeVertices if it's pure positions. No need to bother with a vertex decoder // and a large vertex format. - if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_FLOAT) { + if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_FLOAT && !inds) { verts = (float *)control_points; - } else if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_8BIT) { + } else if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_8BIT && !inds) { const s8 *vtx = (const s8 *)control_points; for (int i = 0; i < vertexCount * 3; i++) { verts[i] = vtx[i] * (1.0f / 128.0f); } - } else if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_16BIT) { + } else if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_16BIT && !inds) { const s16 *vtx = (const s16*)control_points; for (int i = 0; i < vertexCount * 3; i++) { verts[i] = vtx[i] * (1.0f / 32768.0f); } } else { - // Simplify away bones and morph before proceeding + // Simplify away indices, bones, and morph before proceeding. u8 *temp_buffer = decoded + 65536 * 24; int vertexSize = 0; - NormalizeVertices((u8 *)corners, temp_buffer, (const u8 *)control_points, 0, vertexCount, vertType, &vertexSize); + + u16 indexLowerBound = 0; + u16 indexUpperBound = (u16)vertexCount - 1; + if (vertexCount > 0 && inds) { + GetIndexBounds(inds, vertexCount, vertType, &indexLowerBound, &indexUpperBound); + } + + NormalizeVertices((u8 *)corners, temp_buffer, (const u8 *)control_points, indexLowerBound, indexUpperBound, vertType); + + IndexConverter conv(vertType, inds); for (int i = 0; i < vertexCount; i++) { - verts[i * 3] = corners[i].pos.x; - verts[i * 3 + 1] = corners[i].pos.y; - verts[i * 3 + 2] = corners[i].pos.z; + verts[i * 3] = corners[conv(i)].pos.x; + verts[i * 3 + 1] = corners[conv(i)].pos.y; + verts[i * 3 + 2] = corners[conv(i)].pos.z; } } diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 7a6ba863fd..ea14a07884 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -92,7 +92,7 @@ public: virtual void DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex *buffer, int vertexCount, int cullMode, bool continuation); - bool TestBoundingBox(const void* control_points, int vertexCount, u32 vertType); + bool TestBoundingBox(const void *control_points, const void *inds, int vertexCount, u32 vertType); void SubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, u32 vertTypeID, int cullMode, int *bytesRead); template diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 4fb2963851..c80aab881c 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -2162,8 +2162,9 @@ void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) { // Approximate based on timings of several counts on a PSP. cyclesExecuted += count * 22; + const bool useInds = (gstate.vertType & GE_VTYPE_IDX_MASK) != 0; VertexDecoder *dec = drawEngineCommon_->GetVertexDecoder(gstate.vertType); - int bytesRead = dec->VertexSize() * count; + int bytesRead = (useInds ? 1 : dec->VertexSize()) * count; if (Memory::IsValidRange(gstate_c.vertexAddr, bytesRead)) { const void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr); @@ -2173,11 +2174,15 @@ void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) { return; } - if (gstate.vertType & GE_VTYPE_IDX_MASK) { - ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Indexed bounding box data not supported."); - // Data seems invalid. Let's assume the box test passed. - currentList->bboxResult = true; - return; + const void *inds = nullptr; + if (useInds) { + int indexShift = ((gstate.vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT) - 1; + inds = Memory::GetPointerUnchecked(gstate_c.indexAddr); + if (!inds || !Memory::IsValidRange(gstate_c.indexAddr, count << indexShift)) { + ERROR_LOG_REPORT_ONCE(boundingboxInds, G3D, "Invalid inds in bounding box check"); + currentList->bboxResult = true; + return; + } } // Test if the bounding box is within the drawing region. @@ -2185,12 +2190,12 @@ void GPUCommon::Execute_BoundingBox(u32 op, u32 diff) { if (count > 0x200) { // The second to last set of 0x100 is checked (even for odd counts.) size_t skipSize = (count - 0x200) * dec->VertexSize(); - currentList->bboxResult = drawEngineCommon_->TestBoundingBox((const uint8_t *)control_points + skipSize, 0x100, gstate.vertType); + currentList->bboxResult = drawEngineCommon_->TestBoundingBox((const uint8_t *)control_points + skipSize, inds, 0x100, gstate.vertType); } else if (count > 0x100) { int checkSize = count - 0x100; - currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, checkSize, gstate.vertType); + currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, inds, checkSize, gstate.vertType); } else { - currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, count, gstate.vertType); + currentList->bboxResult = drawEngineCommon_->TestBoundingBox(control_points, inds, count, gstate.vertType); } AdvanceVerts(gstate.vertType, count, bytesRead); } else { From 93ee82d84f6b95c46ee2ea30ee64b66cc0441ff3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 10:29:47 -0700 Subject: [PATCH 229/374] GPU: Respect depth clamp in bounding box check. Although, logically, this feels reversed - it rejects the point if it's outside positive Z, which would clamp. This matches PSP tests. --- GPU/Common/DrawEngineCommon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index ad3f733a40..17b93dc810 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -295,7 +295,9 @@ bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *i Matrix4ByMatrix4(worldview, world, view); Matrix4ByMatrix4(worldviewproj, worldview, gstate.projMatrix); PlanesFromMatrix(worldviewproj, planes); - for (int plane = 0; plane < 6; plane++) { + // Note: near/far are not checked without clamp/clip enabled, so we skip those planes. + int totalPlanes = gstate.isDepthClampEnabled() ? 6 : 4; + for (int plane = 0; plane < totalPlanes; plane++) { int inside = 0; int out = 0; for (int i = 0; i < vertexCount; i++) { From 261f1e13dbd6d3205d588f3f9fe855e435a4295e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 15:47:14 -0700 Subject: [PATCH 230/374] GPU: Account for scissor/viewport in bound test. The bounding box check doesn't check against viewport (which the PSP generally doesn't clip against), but instead checks against the scissor. If the scissor doesn't fit inside the offset 4096x4096 box, that direction is cannot fail the test. --- GPU/Common/DrawEngineCommon.cpp | 49 ++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 17b93dc810..85efff21c6 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -16,8 +16,10 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include #include "Common/Data/Convert/ColorConv.h" +#include "Common/Math/lin/matrix4x4.h" #include "Common/Profiler/Profiler.h" #include "Common/LogReporting.h" #include "Core/Config.h" @@ -294,7 +296,34 @@ bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *i // TODO: Create a Matrix4x3ByMatrix4x3, and Matrix4x4ByMatrix4x3? Matrix4ByMatrix4(worldview, world, view); Matrix4ByMatrix4(worldviewproj, worldview, gstate.projMatrix); - PlanesFromMatrix(worldviewproj, planes); + + // Next, we need to apply viewport, scissor, region, and even offset - but only for X/Y. + // Note that the PSP does not clip against the viewport. + const Vec2f baseOffset = Vec2f(gstate.getOffsetX(), gstate.getOffsetY()); + // Region1 (rate) is used as an X1/Y1 here, matching PSP behavior. + Vec2f minOffset = baseOffset + Vec2f(std::max(gstate.getRegionRateX() - 0x100, gstate.getScissorX1()), std::max(gstate.getRegionRateY() - 0x100, gstate.getScissorY1())) - Vec2f(1.0f, 1.0f); + Vec2f maxOffset = baseOffset + Vec2f(std::min(gstate.getRegionX2(), gstate.getScissorX2()), std::min(gstate.getRegionY2(), gstate.getScissorY2())) + Vec2f(1.0f, 1.0f); + + // Now let's apply the viewport to our scissor/region + offset range. + Vec2f inverseViewportScale = Vec2f(1.0f / gstate.getViewportXScale(), 1.0f / gstate.getViewportYScale()); + Vec2f minViewport = (minOffset - Vec2f(gstate.getViewportXCenter(), gstate.getViewportYCenter())) * inverseViewportScale; + Vec2f maxViewport = (maxOffset - Vec2f(gstate.getViewportXCenter(), gstate.getViewportYCenter())) * inverseViewportScale; + + Lin::Matrix4x4 applyViewport; + applyViewport.empty(); + // Scale to the viewport's size. + applyViewport.xx = 2.0f / (maxViewport.x - minViewport.x); + applyViewport.yy = 2.0f / (maxViewport.y - minViewport.y); + applyViewport.zz = 1.0f; + applyViewport.ww = 1.0f; + // And offset to the viewport's centers. + applyViewport.wx = -(maxViewport.x + minViewport.x) / (maxViewport.x - minViewport.x); + applyViewport.wy = -(maxViewport.y + minViewport.y) / (maxViewport.y - minViewport.y); + + float screenBounds[16]; + Matrix4ByMatrix4(screenBounds, worldviewproj, applyViewport.m); + + PlanesFromMatrix(screenBounds, planes); // Note: near/far are not checked without clamp/clip enabled, so we skip those planes. int totalPlanes = gstate.isDepthClampEnabled() ? 6 : 4; for (int plane = 0; plane < totalPlanes; plane++) { @@ -303,15 +332,27 @@ bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *i for (int i = 0; i < vertexCount; i++) { // Here we can test against the frustum planes! float value = planes[plane].Test(verts + i * 3); - if (value < 0) + if (value <= -FLT_EPSILON) out++; else inside++; } if (inside == 0) { - // All out - return false; + // All out - but check for X and Y if the offset was near the cullbox edge. + bool outsideEdge = false; + if (plane == 1) + outsideEdge = minOffset.x < 1.0f; + if (plane == 2) + outsideEdge = minOffset.y < 1.0f; + else if (plane == 0) + outsideEdge = maxOffset.x >= 4096.0f; + else if (plane == 3) + outsideEdge = maxOffset.y >= 4096.0f; + + // Only consider this outside if offset + scissor/region is fully inside the cullbox. + if (!outsideEdge) + return false; } // Any out. For testing that the planes are in the right locations. From add2edcab8f21e10c2f130ebef1418a404362c9e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 16:09:14 -0700 Subject: [PATCH 231/374] VR: Always pass the bounding box check. Likely better to draw all objects, even if they wouldn't have been on screen, for VR purposes. --- GPU/Common/DrawEngineCommon.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 85efff21c6..35cfb7dfa9 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -250,6 +250,11 @@ bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *i SimpleVertex *corners = (SimpleVertex *)(decoded + 65536 * 12); float *verts = (float *)(decoded + 65536 * 18); + // Although this may lead to drawing that shouldn't happen, the viewport is more complex on VR. + // Let's always say objects are within bounds. + if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) + return true; + // Try to skip NormalizeVertices if it's pure positions. No need to bother with a vertex decoder // and a large vertex format. if ((vertType & 0xFFFFFF) == GE_VTYPE_POS_FLOAT && !inds) { From 10531ec9e6da494f0e34ee0ecbf32b3e3aedf179 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 22 Oct 2022 22:49:41 -0700 Subject: [PATCH 232/374] headless: Update tests. --- pspautotests | 2 +- test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pspautotests b/pspautotests index 2a607edab7..d40a8e05c3 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit 2a607edab7c3f50d9597c3a2b77082c3be871b55 +Subproject commit d40a8e05c3892bd67af71c6f80ea4396f8051541 diff --git a/test.py b/test.py index 4bc6b25ff9..b407f82686 100755 --- a/test.py +++ b/test.py @@ -138,6 +138,10 @@ tests_good = [ "font/optimum", "font/resolution", "font/shadowimagerect", + "gpu/bounding/count", + "gpu/bounding/planes", + "gpu/bounding/vertexaddr", + "gpu/bounding/viewport", "gpu/callbacks/ge_callbacks", "gpu/clipping/homogeneous", "gpu/clut/address", From 813bfded927d5ae67d7257733f567110ad405d1e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 23 Oct 2022 01:09:29 -0700 Subject: [PATCH 233/374] x86jit: Correct vh2f NAN handling (#16275) * x86jit: Correct vh2f NAN handling. Allows another test to pass. * x86jit: Reuse MAccessibleDisp(). --- Common/x64Emitter.h | 13 ++++++++++ Core/MIPS/x86/CompVFPU.cpp | 48 ++++++++++++++++++++++++----------- GPU/Software/DrawPixelX86.cpp | 13 ---------- test.py | 2 +- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/Common/x64Emitter.h b/Common/x64Emitter.h index 50887f18bf..b52a81f35b 100644 --- a/Common/x64Emitter.h +++ b/Common/x64Emitter.h @@ -278,6 +278,19 @@ inline OpArg MRegSum(X64Reg base, X64Reg offset) return MComplex(base, offset, 1, 0); } +template +inline bool Accessible(const T *t1, const T *t2) { + ptrdiff_t diff = (const uint8_t *)t1 - (const uint8_t *)t2; + return diff > -0x7FFFFFE0 && diff < 0x7FFFFFE0; +} + +template +inline OpArg MAccessibleDisp(X64Reg r, const T *tbase, const T *t) { + _assert_(Accessible(tbase, t)); + ptrdiff_t diff = (const uint8_t *)t - (const uint8_t *)tbase; + return MDisp(r, (int)diff); +} + inline OpArg Imm8 (u8 imm) {return OpArg(imm, SCALE_IMM8);} inline OpArg Imm16(u16 imm) {return OpArg(imm, SCALE_IMM16);} //rarely used inline OpArg Imm32(u32 imm) {return OpArg(imm, SCALE_IMM32);} diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index 88aa7da0b9..f2380c8499 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -1605,13 +1605,25 @@ void Jit::Comp_Vh2f(MIPSOpcode op) { #define SSE_CONST4(name, val) alignas(16) static const u32 name[4] = { (val), (val), (val), (val) } SSE_CONST4(mask_nosign, 0x7fff); + SSE_CONST4(nan_mantissa, 0x800003ff); SSE_CONST4(magic, (254 - 15) << 23); SSE_CONST4(was_infnan, 0x7bff); SSE_CONST4(exp_infnan, 255 << 23); - // TODO: Fix properly - if (!RipAccessible(mask_nosign)) { - DISABLE; + OpArg mask_nosign_arg, nan_mantissa_arg, magic_arg, was_infnan_arg, exp_infnan_arg; + if (RipAccessible(mask_nosign)) { + mask_nosign_arg = M(&mask_nosign[0]); + nan_mantissa_arg = M(&nan_mantissa[0]); + magic_arg = M(&magic[0]); + was_infnan_arg = M(&was_infnan[0]); + exp_infnan_arg = M(&exp_infnan[0]); + } else { + MOV(PTRBITS, R(TEMPREG), ImmPtr(&mask_nosign[0])); + mask_nosign_arg = MAccessibleDisp(TEMPREG, &mask_nosign[0], &mask_nosign[0]); + nan_mantissa_arg = MAccessibleDisp(TEMPREG, &mask_nosign[0], &nan_mantissa[0]); + magic_arg = MAccessibleDisp(TEMPREG, &mask_nosign[0], &magic[0]); + was_infnan_arg = MAccessibleDisp(TEMPREG, &mask_nosign[0], &was_infnan[0]); + exp_infnan_arg = MAccessibleDisp(TEMPREG, &mask_nosign[0], &exp_infnan[0]); } #undef SSE_CONST4 @@ -1649,30 +1661,36 @@ void Jit::Comp_Vh2f(MIPSOpcode op) { // OK, 16 bits in each word. // Let's go. Deep magic here. MOVAPS(XMM1, R(XMM0)); - ANDPS(XMM0, M(&mask_nosign[0])); // xmm0 = expmant. not rip accessible but bailing above + ANDPS(XMM0, mask_nosign_arg); // xmm0 = expmant XORPS(XMM1, R(XMM0)); // xmm1 = justsign = expmant ^ xmm0 MOVAPS(tempR, R(XMM0)); - PCMPGTD(tempR, M(&was_infnan[0])); // xmm2 = b_wasinfnan. not rip accessible but bailing above PSLLD(XMM0, 13); - MULPS(XMM0, M(magic)); /// xmm0 = scaled + MULPS(XMM0, magic_arg); /// xmm0 = scaled PSLLD(XMM1, 16); // xmm1 = sign - ANDPS(tempR, M(&exp_infnan[0])); // not rip accessible but bailing above - ORPS(XMM1, R(tempR)); ORPS(XMM0, R(XMM1)); + // Now create a NAN mask, adding in the sign. + ORPS(XMM1, R(tempR)); // xmm1 = sign + original mantissa. + ANDPS(XMM1, nan_mantissa_arg); // xmm1 = original mantissa + PCMPGTD(tempR, was_infnan_arg); // xmm2 = b_wasinfnan + ORPS(XMM1, exp_infnan_arg); // xmm1 = infnan result + ANDPS(XMM1, R(tempR)); // xmm1 = infnan result OR zero if not infnan + ANDNPS(tempR, R(XMM0)); // tempR = result OR zero if infnan + ORPS(XMM1, R(tempR)); + fpr.MapRegsV(dregs, outsize, MAP_NOINIT | MAP_DIRTY); // TODO: Could apply D-prefix in parallel here... - MOVSS(fpr.V(dregs[0]), XMM0); - SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(3, 3, 2, 1)); - MOVSS(fpr.V(dregs[1]), XMM0); + MOVSS(fpr.V(dregs[0]), XMM1); + SHUFPS(XMM1, R(XMM1), _MM_SHUFFLE(3, 3, 2, 1)); + MOVSS(fpr.V(dregs[1]), XMM1); if (sz != V_Single) { - SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(3, 3, 2, 1)); - MOVSS(fpr.V(dregs[2]), XMM0); - SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(3, 3, 2, 1)); - MOVSS(fpr.V(dregs[3]), XMM0); + SHUFPS(XMM1, R(XMM1), _MM_SHUFFLE(3, 3, 2, 1)); + MOVSS(fpr.V(dregs[2]), XMM1); + SHUFPS(XMM1, R(XMM1), _MM_SHUFFLE(3, 3, 2, 1)); + MOVSS(fpr.V(dregs[3]), XMM1); } ApplyPrefixD(dregs, outsize); diff --git a/GPU/Software/DrawPixelX86.cpp b/GPU/Software/DrawPixelX86.cpp index 53f9c94279..c2c7ce9493 100644 --- a/GPU/Software/DrawPixelX86.cpp +++ b/GPU/Software/DrawPixelX86.cpp @@ -31,19 +31,6 @@ using namespace Gen; namespace Rasterizer { -template -static bool Accessible(const T *t1, const T *t2) { - ptrdiff_t diff = (const uint8_t *)t1 - (const uint8_t *)t2; - return diff > -0x7FFFFFE0 && diff < 0x7FFFFFE0; -} - -template -static OpArg MAccessibleDisp(X64Reg r, const T *tbase, const T *t) { - _assert_(Accessible(tbase, t)); - ptrdiff_t diff = (const uint8_t *)t - (const uint8_t *)tbase; - return MDisp(r, (int)diff); -} - SingleFunc PixelJitCache::CompileSingle(const PixelFuncID &id) { // Setup the reg cache and disallow spill for arguments. regCache_.SetupABI({ diff --git a/test.py b/test.py index 4bc6b25ff9..94e501681a 100755 --- a/test.py +++ b/test.py @@ -69,6 +69,7 @@ tests_good = [ "cpu/cpu_alu/cpu_branch", "cpu/cpu_alu/cpu_branch2", "cpu/vfpu/colors", + "cpu/vfpu/convert", "cpu/vfpu/gum", "cpu/vfpu/matrix", "cpu/vfpu/vavg", @@ -368,7 +369,6 @@ tests_good = [ tests_next = [ # These are the next tests up for fixing. These run by default. "cpu/fpu/fcr", - "cpu/vfpu/convert", "cpu/vfpu/prefixes", "cpu/vfpu/vector", "cpu/vfpu/vregs", From 79b1d1d35f2aef9fdbfc841e0bcf28ddfe941189 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 23 Oct 2022 01:15:43 -0700 Subject: [PATCH 234/374] softgpu: Better approximate slope mip level mode (#16276) * samplerjit: Remove unused x/y parameters. Still need to tune the accuracy of filtering, but those were not the right way. * softgpu: Better approximate slope mip level mode. This isn't exactly right, but it's closer. * softgpu: Calculate auto from largest difference. Direction shouldn't matter. --- GPU/Software/Rasterizer.cpp | 41 ++++++----- GPU/Software/RasterizerRectangle.cpp | 7 +- GPU/Software/Sampler.cpp | 28 ++++---- GPU/Software/Sampler.h | 4 +- GPU/Software/SamplerX86.cpp | 104 +++++++++++++-------------- unittest/TestSoftwareGPUJit.cpp | 4 +- 6 files changed, 94 insertions(+), 94 deletions(-) diff --git a/GPU/Software/Rasterizer.cpp b/GPU/Software/Rasterizer.cpp index d75f7f9476..e6d4a5a84f 100644 --- a/GPU/Software/Rasterizer.cpp +++ b/GPU/Software/Rasterizer.cpp @@ -303,18 +303,18 @@ static inline bool IsRightSideOrFlatBottomLine(const Vec2& vertex, const Ve } } -static inline Vec4IntResult SOFTRAST_CALL ApplyTexturing(float s, float t, int x, int y, Vec4IntArg prim_color, int texlevel, int frac_texlevel, bool bilinear, const RasterizerState &state) { +static inline Vec4IntResult SOFTRAST_CALL ApplyTexturing(float s, float t, Vec4IntArg prim_color, int texlevel, int frac_texlevel, bool bilinear, const RasterizerState &state) { const u8 **tptr0 = const_cast(&state.texptr[texlevel]); const uint16_t *bufw0 = &state.texbufw[texlevel]; if (!bilinear) { - return state.nearest(s, t, x, y, prim_color, tptr0, bufw0, texlevel, frac_texlevel, state.samplerID); + return state.nearest(s, t, prim_color, tptr0, bufw0, texlevel, frac_texlevel, state.samplerID); } - return state.linear(s, t, x, y, prim_color, tptr0, bufw0, texlevel, frac_texlevel, state.samplerID); + return state.linear(s, t, prim_color, tptr0, bufw0, texlevel, frac_texlevel, state.samplerID); } -static inline Vec4IntResult SOFTRAST_CALL ApplyTexturingSingle(float s, float t, int x, int y, Vec4IntArg prim_color, int texlevel, int frac_texlevel, bool bilinear, const RasterizerState &state) { - return ApplyTexturing(s, t, ((x & 15) + 1) / 2, ((y & 15) + 1) / 2, prim_color, texlevel, frac_texlevel, bilinear, state); +static inline Vec4IntResult SOFTRAST_CALL ApplyTexturingSingle(float s, float t, Vec4IntArg prim_color, int texlevel, int frac_texlevel, bool bilinear, const RasterizerState &state) { + return ApplyTexturing(s, t, prim_color, texlevel, frac_texlevel, bilinear, state); } // Produces a signed 1.27.4 value. @@ -332,7 +332,7 @@ static int TexLog2(float delta) { return useful - 127 * 16; } -static inline void CalculateSamplingParams(const float ds, const float dt, const RasterizerState &state, int &level, int &levelFrac, bool &filt) { +static inline void CalculateSamplingParams(const float ds, const float dt, float w, const RasterizerState &state, int &level, int &levelFrac, bool &filt) { const int width = 1 << state.samplerID.width0Shift; const int height = 1 << state.samplerID.height0Shift; @@ -340,11 +340,11 @@ static inline void CalculateSamplingParams(const float ds, const float dt, const int detail; switch (state.TexLevelMode()) { case GE_TEXLEVEL_MODE_AUTO: - detail = TexLog2(std::max(ds * width, dt * height)); + detail = TexLog2(std::max(std::abs(ds * width), std::abs(dt * height))); break; case GE_TEXLEVEL_MODE_SLOPE: // This is always offset by an extra texlevel. - detail = 1 * 16 + TexLog2(state.textureLodSlope); + detail = TexLog2(2.0f * w * state.textureLodSlope); break; case GE_TEXLEVEL_MODE_CONST: default: @@ -377,19 +377,19 @@ static inline void CalculateSamplingParams(const float ds, const float dt, const filt = state.magFilt; } -static inline void ApplyTexturing(const RasterizerState &state, Vec4 *prim_color, const Vec4 &mask, const Vec4 &s, const Vec4 &t, int x, int y) { +static inline void ApplyTexturing(const RasterizerState &state, Vec4 *prim_color, const Vec4 &mask, const Vec4 &s, const Vec4 &t, float w) { float ds = s[1] - s[0]; float dt = t[2] - t[0]; int level; int levelFrac; bool bilinear; - CalculateSamplingParams(ds, dt, state, level, levelFrac, bilinear); + CalculateSamplingParams(ds, dt, w, state, level, levelFrac, bilinear); PROFILE_THIS_SCOPE("sampler"); for (int i = 0; i < 4; ++i) { if (mask[i] >= 0) - prim_color[i] = ApplyTexturing(s[i], t[i], ((x & 15) + 1) / 2, ((y & 15) + 1) / 2, ToVec4IntArg(prim_color[i]), level, levelFrac, bilinear, state); + prim_color[i] = ApplyTexturing(s[i], t[i], ToVec4IntArg(prim_color[i]), level, levelFrac, bilinear, state); } } @@ -717,7 +717,13 @@ void DrawTriangleSlice( GetTextureCoordinates(v0, v1, v2, w0, w1, w2, wsum_recip, s, t); } - ApplyTexturing(state, prim_color, mask, s, t, curX, curY); + if (state.TexLevelMode() == GE_TEXLEVEL_MODE_SLOPE) { + // Not sure what's right, but we need one value for the slope. + float clipw = (v0.clipw * w0.x + v1.clipw * w1.x + v2.clipw * w2.x) * wsum_recip.x; + ApplyTexturing(state, prim_color, mask, s, t, clipw); + } else { + ApplyTexturing(state, prim_color, mask, s, t, 0.0f); + } } if (!clearMode) { @@ -923,7 +929,7 @@ void DrawRectangle(const VertexData &v0, const VertexData &v1, const BinCoords & s = Vec4::AssignToAll(st.s()) + sto4; t = Vec4::AssignToAll(st.t()) + tto4; - ApplyTexturing(state, prim_color, mask, s, t, curX, curY); + ApplyTexturing(state, prim_color, mask, s, t, v1.clipw); } if (!state.pixelID.clearMode) { @@ -1014,9 +1020,9 @@ void DrawPoint(const VertexData &v0, const BinCoords &range, const RasterizerSta int texLevel; int texLevelFrac; bool bilinear; - CalculateSamplingParams(0.0f, 0.0f, state, texLevel, texLevelFrac, bilinear); + CalculateSamplingParams(0.0f, 0.0f, v0.clipw, state, texLevel, texLevelFrac, bilinear); PROFILE_THIS_SCOPE("sampler"); - prim_color = ApplyTexturingSingle(s, t, pos.x, pos.y, ToVec4IntArg(prim_color), texLevel, texLevelFrac, bilinear, state); + prim_color = ApplyTexturingSingle(s, t, ToVec4IntArg(prim_color), texLevel, texLevelFrac, bilinear, state); } if (!pixelID.clearMode) @@ -1342,11 +1348,12 @@ void DrawLine(const VertexData &v0, const VertexData &v1, const BinCoords &range // If inc is 0, force the delta to zero. float ds = xinc == 0.0 ? 0.0f : (s1 - s) * (float)SCREEN_SCALE_FACTOR * (1.0f / xinc); float dt = yinc == 0.0 ? 0.0f : (t1 - t) * (float)SCREEN_SCALE_FACTOR * (1.0f / yinc); + float w = (v0.clipw * (float)(steps - i) + v1.clipw * (float)i) / steps1; int texLevel; int texLevelFrac; bool texBilinear; - CalculateSamplingParams(ds, dt, state, texLevel, texLevelFrac, texBilinear); + CalculateSamplingParams(ds, dt, w, state, texLevel, texLevelFrac, texBilinear); if (state.antialiasLines) { // TODO: This is a naive and wrong implementation. @@ -1358,7 +1365,7 @@ void DrawLine(const VertexData &v0, const VertexData &v1, const BinCoords &range } PROFILE_THIS_SCOPE("sampler"); - prim_color = ApplyTexturingSingle(s, t, x, y, ToVec4IntArg(prim_color), texLevel, texLevelFrac, texBilinear, state); + prim_color = ApplyTexturingSingle(s, t, ToVec4IntArg(prim_color), texLevel, texLevelFrac, texBilinear, state); } if (!pixelID.clearMode) diff --git a/GPU/Software/RasterizerRectangle.cpp b/GPU/Software/RasterizerRectangle.cpp index 8d39a2426a..445c36bc32 100644 --- a/GPU/Software/RasterizerRectangle.cpp +++ b/GPU/Software/RasterizerRectangle.cpp @@ -245,9 +245,6 @@ void DrawSprite(const VertexData &v0, const VertexData &v1, const BinCoords &ran } } } else { - int xoff = ((v0.screenpos.x & 15) + 1) / 2; - int yoff = ((v0.screenpos.y & 15) + 1) / 2; - float dsf = ds * (1.0f / (float)(1 << state.samplerID.width0Shift)); float dtf = dt * (1.0f / (float)(1 << state.samplerID.height0Shift)); float sf_start = s_start * (1.0f / (float)(1 << state.samplerID.width0Shift)); @@ -261,7 +258,7 @@ void DrawSprite(const VertexData &v0, const VertexData &v1, const BinCoords &ran // Not really that fast but faster than triangle. for (int x = pos0.x; x < pos1.x; x++) { if (CheckDepthTestPassed(pixelID.DepthTestFunc(), x, y, pixelID.cached.depthbufStride, z)) { - Vec4 prim_color = state.nearest(s, t, xoff, yoff, ToVec4IntArg(c0), &texptr, &texbufw, 0, 0, state.samplerID); + Vec4 prim_color = state.nearest(s, t, ToVec4IntArg(c0), &texptr, &texbufw, 0, 0, state.samplerID); state.drawPixel(x, y, z, fog, ToVec4IntArg(prim_color), pixelID); } @@ -274,7 +271,7 @@ void DrawSprite(const VertexData &v0, const VertexData &v1, const BinCoords &ran float s = sf_start; // Not really that fast but faster than triangle. for (int x = pos0.x; x < pos1.x; x++) { - Vec4 prim_color = state.nearest(s, t, xoff, yoff, ToVec4IntArg(c0), &texptr, &texbufw, 0, 0, state.samplerID); + Vec4 prim_color = state.nearest(s, t, ToVec4IntArg(c0), &texptr, &texbufw, 0, 0, state.samplerID); state.drawPixel(x, y, z, fog, ToVec4IntArg(prim_color), pixelID); s += dsf; } diff --git a/GPU/Software/Sampler.cpp b/GPU/Software/Sampler.cpp index fa3b1a730f..28d83034de 100644 --- a/GPU/Software/Sampler.cpp +++ b/GPU/Software/Sampler.cpp @@ -38,8 +38,8 @@ using namespace Rasterizer; namespace Sampler { -static Vec4IntResult SOFTRAST_CALL SampleNearest(float s, float t, int x, int y, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); -static Vec4IntResult SOFTRAST_CALL SampleLinear(float s, float t, int x, int y, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); +static Vec4IntResult SOFTRAST_CALL SampleNearest(float s, float t, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); +static Vec4IntResult SOFTRAST_CALL SampleLinear(float s, float t, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); static Vec4IntResult SOFTRAST_CALL SampleFetch(int u, int v, const u8 *tptr, int bufw, int level, const SamplerID &samplerID); std::mutex jitCacheLock; @@ -416,7 +416,7 @@ static inline void ApplyTexelClamp(int out_u[N], int out_v[N], const int u[N], c } } -static inline void GetTexelCoordinates(int level, float s, float t, int &out_u, int &out_v, int x, int y, const SamplerID &samplerID) { +static inline void GetTexelCoordinates(int level, float s, float t, int &out_u, int &out_v, const SamplerID &samplerID) { int width = samplerID.cached.sizes[level].w; int height = samplerID.cached.sizes[level].h; @@ -535,15 +535,15 @@ Vec4IntResult SOFTRAST_CALL GetTextureFunctionOutput(Vec4IntArg prim_color_in, V return ToVec4IntResult(Vec4(out_rgb, out_a)); } -static Vec4IntResult SOFTRAST_CALL SampleNearest(float s, float t, int x, int y, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID) { +static Vec4IntResult SOFTRAST_CALL SampleNearest(float s, float t, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID) { int u, v; // Nearest filtering only. Round texcoords. - GetTexelCoordinates(level, s, t, u, v, x, y, samplerID); + GetTexelCoordinates(level, s, t, u, v, samplerID); Vec4 c0 = Vec4::FromRGBA(SampleNearest<1>(&u, &v, tptr[0], bufw[0], level, samplerID).v[0]); if (levelFrac) { - GetTexelCoordinates(level + 1, s, t, u, v, x, y, samplerID); + GetTexelCoordinates(level + 1, s, t, u, v, samplerID); Vec4 c1 = Vec4::FromRGBA(SampleNearest<1>(&u, &v, tptr[1], bufw[1], level + 1, samplerID).v[0]); c0 = (c1 * levelFrac + c0 * (16 - levelFrac)) / 16; @@ -609,7 +609,7 @@ static inline Vec4IntResult SOFTRAST_CALL ApplyTexelClampQuadT(bool clamp, int v #endif } -static inline Vec4IntResult SOFTRAST_CALL GetTexelCoordinatesQuadS(int level, float in_s, int &frac_u, int x, const SamplerID &samplerID) { +static inline Vec4IntResult SOFTRAST_CALL GetTexelCoordinatesQuadS(int level, float in_s, int &frac_u, const SamplerID &samplerID) { int width = samplerID.cached.sizes[level].w; int base_u = (int)(in_s * width * 256) - 128; @@ -620,7 +620,7 @@ static inline Vec4IntResult SOFTRAST_CALL GetTexelCoordinatesQuadS(int level, fl return ApplyTexelClampQuadS(samplerID.clampS, base_u, width); } -static inline Vec4IntResult SOFTRAST_CALL GetTexelCoordinatesQuadT(int level, float in_t, int &frac_v, int y, const SamplerID &samplerID) { +static inline Vec4IntResult SOFTRAST_CALL GetTexelCoordinatesQuadT(int level, float in_t, int &frac_v, const SamplerID &samplerID) { int height = samplerID.cached.sizes[level].h; int base_v = (int)(in_t * height * 256) - 128; @@ -631,10 +631,10 @@ static inline Vec4IntResult SOFTRAST_CALL GetTexelCoordinatesQuadT(int level, fl return ApplyTexelClampQuadT(samplerID.clampT, base_v, height); } -static Vec4IntResult SOFTRAST_CALL SampleLinearLevel(float s, float t, int x, int y, const u8 *const *tptr, const uint16_t *bufw, int texlevel, const SamplerID &samplerID) { +static Vec4IntResult SOFTRAST_CALL SampleLinearLevel(float s, float t, const u8 *const *tptr, const uint16_t *bufw, int texlevel, const SamplerID &samplerID) { int frac_u, frac_v; - const Vec4 u = GetTexelCoordinatesQuadS(texlevel, s, frac_u, x, samplerID); - const Vec4 v = GetTexelCoordinatesQuadT(texlevel, t, frac_v, y, samplerID); + const Vec4 u = GetTexelCoordinatesQuadS(texlevel, s, frac_u, samplerID); + const Vec4 v = GetTexelCoordinatesQuadT(texlevel, t, frac_v, samplerID); Nearest4 c = SampleNearest<4>(u.AsArray(), v.AsArray(), tptr[0], bufw[0], texlevel, samplerID); Vec4 texcolor_tl = Vec4::FromRGBA(c.v[0]); @@ -646,10 +646,10 @@ static Vec4IntResult SOFTRAST_CALL SampleLinearLevel(float s, float t, int x, in return ToVec4IntResult((top * (0x10 - frac_v) + bot * frac_v) / (16 * 16)); } -static Vec4IntResult SOFTRAST_CALL SampleLinear(float s, float t, int x, int y, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int texlevel, int levelFrac, const SamplerID &samplerID) { - Vec4 c0 = SampleLinearLevel(s, t, x, y, tptr, bufw, texlevel, samplerID); +static Vec4IntResult SOFTRAST_CALL SampleLinear(float s, float t, Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int texlevel, int levelFrac, const SamplerID &samplerID) { + Vec4 c0 = SampleLinearLevel(s, t, tptr, bufw, texlevel, samplerID); if (levelFrac) { - const Vec4 c1 = SampleLinearLevel(s, t, x, y, tptr + 1, bufw + 1, texlevel + 1, samplerID); + const Vec4 c1 = SampleLinearLevel(s, t, tptr + 1, bufw + 1, texlevel + 1, samplerID); c0 = (c1 * levelFrac + c0 * (16 - levelFrac)) / 16; } return GetTextureFunctionOutput(prim_color, ToVec4IntArg(c0), samplerID); diff --git a/GPU/Software/Sampler.h b/GPU/Software/Sampler.h index 9af945a9f2..292a93527f 100644 --- a/GPU/Software/Sampler.h +++ b/GPU/Software/Sampler.h @@ -36,10 +36,10 @@ namespace Sampler { typedef Rasterizer::Vec4IntResult(SOFTRAST_CALL *FetchFunc)(int u, int v, const u8 *tptr, int bufw, int level, const SamplerID &samplerID); FetchFunc GetFetchFunc(SamplerID id); -typedef Rasterizer::Vec4IntResult (SOFTRAST_CALL *NearestFunc)(float s, float t, int x, int y, Rasterizer::Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); +typedef Rasterizer::Vec4IntResult (SOFTRAST_CALL *NearestFunc)(float s, float t, Rasterizer::Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); NearestFunc GetNearestFunc(SamplerID id); -typedef Rasterizer::Vec4IntResult (SOFTRAST_CALL *LinearFunc)(float s, float t, int x, int y, Rasterizer::Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); +typedef Rasterizer::Vec4IntResult (SOFTRAST_CALL *LinearFunc)(float s, float t, Rasterizer::Vec4IntArg prim_color, const u8 *const *tptr, const uint16_t *bufw, int level, int levelFrac, const SamplerID &samplerID); LinearFunc GetLinearFunc(SamplerID id); void Init(); diff --git a/GPU/Software/SamplerX86.cpp b/GPU/Software/SamplerX86.cpp index 150856f6f5..7b05debdb5 100644 --- a/GPU/Software/SamplerX86.cpp +++ b/GPU/Software/SamplerX86.cpp @@ -133,8 +133,6 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { regCache_.SetupABI({ RegCache::VEC_ARG_S, RegCache::VEC_ARG_T, - RegCache::GEN_ARG_X, - RegCache::GEN_ARG_Y, RegCache::VEC_ARG_COLOR, RegCache::GEN_ARG_TEXPTR_PTR, RegCache::GEN_ARG_BUFW_PTR, @@ -144,16 +142,16 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { }); #if PPSSPP_PLATFORM(WINDOWS) - // RET + shadow space + 8 byte space for color arg (the Win32 ABI is kinda ugly.) - stackArgPos_ = 8 + 32 + 8; + // RET + shadow space. + stackArgPos_ = 8 + 32; - // Positions: stackArgPos_+0=src, stackArgPos_+8=bufw, stackArgPos_+16=level, stackArgPos_+24=levelFrac - stackIDOffset_ = 32; - stackLevelOffset_ = 16; + // Positions: stackArgPos_+0=bufwptr, stackArgPos_+8=level, stackArgPos_+16=levelFrac + stackIDOffset_ = 24; + stackLevelOffset_ = 8; #else stackArgPos_ = 0; - // This is the only arg that went to the stack, it's after the RET. - stackIDOffset_ = 8; + // No args on the stack. + stackIDOffset_ = -1; stackLevelOffset_ = -1; #endif @@ -182,23 +180,20 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { if (!id.hasAnyMips && regCache_.Has(RegCache::GEN_ARG_LEVELFRAC)) regCache_.ForceRelease(RegCache::GEN_ARG_LEVELFRAC); - if (regCache_.Has(RegCache::GEN_ARG_BUFW_PTR)) { - // On Linux, RCX is currently bufwptr, but we'll need it for other things. + if (regCache_.Has(RegCache::GEN_ARG_LEVELFRAC)) { + // On Linux, RCX is currently levelFrac, but we'll need it for other things. if (!cpu_info.bBMI2) { - X64Reg bufwReg = regCache_.Find(RegCache::GEN_ARG_BUFW_PTR); - MOV(64, R(R15), R(bufwReg)); - regCache_.Unlock(bufwReg, RegCache::GEN_ARG_BUFW_PTR); - regCache_.ForceRelease(RegCache::GEN_ARG_BUFW_PTR); - regCache_.ChangeReg(R15, RegCache::GEN_ARG_BUFW_PTR); - regCache_.ForceRetain(RegCache::GEN_ARG_BUFW_PTR); + X64Reg levelFracReg = regCache_.Find(RegCache::GEN_ARG_LEVELFRAC); + MOV(64, R(R15), R(levelFracReg)); + regCache_.Unlock(levelFracReg, RegCache::GEN_ARG_LEVELFRAC); + regCache_.ForceRelease(RegCache::GEN_ARG_LEVELFRAC); + regCache_.ChangeReg(R15, RegCache::GEN_ARG_LEVELFRAC); + regCache_.ForceRetain(RegCache::GEN_ARG_LEVELFRAC); } - } else { - // Let's load bufwptr/texptrptr into regs. Match Linux just for consistency - RDX is free. + } else if (!regCache_.Has(RegCache::GEN_ARG_BUFW_PTR)) { + // Let's load bufwptr into regs. RDX is free. MOV(64, R(RDX), MDisp(RSP, stackArgPos_ + 0)); - MOV(64, R(R15), MDisp(RSP, stackArgPos_ + 8)); - regCache_.ChangeReg(RDX, RegCache::GEN_ARG_TEXPTR_PTR); - regCache_.ChangeReg(R15, RegCache::GEN_ARG_BUFW_PTR); - regCache_.ForceRetain(RegCache::GEN_ARG_TEXPTR_PTR); + regCache_.ChangeReg(RDX, RegCache::GEN_ARG_BUFW_PTR); regCache_.ForceRetain(RegCache::GEN_ARG_BUFW_PTR); } // Okay, now lock RCX as a shifting reg. @@ -284,7 +279,7 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { CMP(8, R(levelFracReg), Imm8(0)); regCache_.Unlock(levelFracReg, RegCache::GEN_ARG_LEVELFRAC); } else { - CMP(8, MDisp(RSP, stackArgPos_ + 24), Imm8(0)); + CMP(8, MDisp(RSP, stackArgPos_ + 16), Imm8(0)); } FixupBranch skip = J_CC(CC_Z, true); @@ -295,7 +290,7 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { regCache_.Unlock(levelReg, RegCache::GEN_ARG_LEVEL); } else { // It's fine to just modify this in place. - ADD(32, MDisp(RSP, stackArgPos_ + 16), Imm8(1)); + ADD(32, MDisp(RSP, stackArgPos_ + stackLevelOffset_), Imm8(1)); } // This is inside the conditional, but it's okay because we throw it away after. @@ -357,7 +352,7 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { Describe("BlendMips"); if (!regCache_.Has(RegCache::GEN_ARG_LEVELFRAC)) { X64Reg levelFracReg = regCache_.Alloc(RegCache::GEN_ARG_LEVELFRAC); - MOVZX(32, 8, levelFracReg, MDisp(RSP, stackArgPos_ + 24)); + MOVZX(32, 8, levelFracReg, MDisp(RSP, stackArgPos_ + 16)); regCache_.Unlock(levelFracReg, RegCache::GEN_ARG_LEVELFRAC); regCache_.ForceRetain(RegCache::GEN_ARG_LEVELFRAC); } @@ -413,6 +408,8 @@ NearestFunc SamplerJitCache::CompileNearest(const SamplerID &id) { } regCache_.ForceRelease(RegCache::VEC_RESULT); + if (regCache_.Has(RegCache::GEN_ARG_ID)) + regCache_.ForceRelease(RegCache::GEN_ARG_ID); if (!success) { regCache_.Reset(false); @@ -525,8 +522,6 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { regCache_.SetupABI({ RegCache::VEC_ARG_S, RegCache::VEC_ARG_T, - RegCache::GEN_ARG_X, - RegCache::GEN_ARG_Y, RegCache::VEC_ARG_COLOR, RegCache::GEN_ARG_TEXPTR_PTR, RegCache::GEN_ARG_BUFW_PTR, @@ -536,22 +531,21 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { }); #if PPSSPP_PLATFORM(WINDOWS) - // RET + shadow space + 8 byte space for color arg (the Win32 ABI is kinda ugly.) - stackArgPos_ = 8 + 32 + 8; + // RET + shadow space. + stackArgPos_ = 8 + 32; // Free up some more vector regs on Windows too, where we're a bit tight. stackArgPos_ += WriteProlog(0, { XMM6, XMM7, XMM8, XMM9, XMM10, XMM11, XMM12 }, { R15, R14, R13, R12 }); - // Positions: stackArgPos_+0=src, stackArgPos_+8=bufw, stackArgPos_+16=level, stackArgPos_+24=levelFrac - stackIDOffset_ = 32; - stackLevelOffset_ = 16; + // Positions: stackArgPos_+0=bufwptr, stackArgPos_+8=level, stackArgPos_+16=levelFrac + stackIDOffset_ = 24; + stackLevelOffset_ = 8; - // If needed, we could store UV1 data in shadow space, but we no longer due. + // If needed, we could store UV1 data in shadow space, but we no longer do. stackUV1Offset_ = -8; #else stackArgPos_ = 0; stackArgPos_ += WriteProlog(0, {}, { R15, R14, R13, R12 }); - // Just after the RET. - stackIDOffset_ = 8; + stackIDOffset_ = -1; stackLevelOffset_ = -1; // Use the red zone. @@ -591,8 +585,7 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { } // We also want to save src and bufw for later. Might be in a reg already. - if (regCache_.Has(RegCache::GEN_ARG_TEXPTR_PTR)) { - _assert_(regCache_.Has(RegCache::GEN_ARG_BUFW_PTR)); + if (regCache_.Has(RegCache::GEN_ARG_TEXPTR_PTR) && regCache_.Has(RegCache::GEN_ARG_BUFW_PTR)) { X64Reg srcReg = regCache_.Find(RegCache::GEN_ARG_TEXPTR_PTR); X64Reg bufwReg = regCache_.Find(RegCache::GEN_ARG_BUFW_PTR); MOV(64, R(R14), R(srcReg)); @@ -601,6 +594,12 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { regCache_.Unlock(bufwReg, RegCache::GEN_ARG_BUFW_PTR); regCache_.ForceRelease(RegCache::GEN_ARG_TEXPTR_PTR); regCache_.ForceRelease(RegCache::GEN_ARG_BUFW_PTR); + } else if (regCache_.Has(RegCache::GEN_ARG_TEXPTR_PTR)) { + X64Reg srcReg = regCache_.Find(RegCache::GEN_ARG_TEXPTR_PTR); + MOV(64, R(R14), R(srcReg)); + regCache_.Unlock(srcReg, RegCache::GEN_ARG_TEXPTR_PTR); + regCache_.ForceRelease(RegCache::GEN_ARG_TEXPTR_PTR); + MOV(64, R(R15), MDisp(RSP, stackArgPos_ + 0)); } else { MOV(64, R(R14), MDisp(RSP, stackArgPos_ + 0)); MOV(64, R(R15), MDisp(RSP, stackArgPos_ + 8)); @@ -608,9 +607,11 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { // Okay, and now remember we moved to R14/R15. regCache_.ChangeReg(R14, RegCache::GEN_ARG_TEXPTR_PTR); - regCache_.ChangeReg(R15, RegCache::GEN_ARG_BUFW_PTR); regCache_.ForceRetain(RegCache::GEN_ARG_TEXPTR_PTR); - regCache_.ForceRetain(RegCache::GEN_ARG_BUFW_PTR); + if (!regCache_.Has(RegCache::GEN_ARG_BUFW_PTR)) { + regCache_.ChangeReg(R15, RegCache::GEN_ARG_BUFW_PTR); + regCache_.ForceRetain(RegCache::GEN_ARG_BUFW_PTR); + } bool success = true; @@ -758,7 +759,7 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { CMP(8, R(levelFracReg), Imm8(0)); regCache_.Unlock(levelFracReg, RegCache::GEN_ARG_LEVELFRAC); } else { - CMP(8, MDisp(RSP, stackArgPos_ + 24), Imm8(0)); + CMP(8, MDisp(RSP, stackArgPos_ + 16), Imm8(0)); } FixupBranch skip = J_CC(CC_Z, true); @@ -769,7 +770,7 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { regCache_.Unlock(levelReg, RegCache::GEN_ARG_LEVEL); } else { // It's fine to just modify this in place. - ADD(32, MDisp(RSP, stackArgPos_ + 16), Imm8(1)); + ADD(32, MDisp(RSP, stackArgPos_ + stackLevelOffset_), Imm8(1)); } if (nearest != nullptr) { @@ -808,7 +809,7 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { Describe("BlendMips"); if (!regCache_.Has(RegCache::GEN_ARG_LEVELFRAC)) { X64Reg levelFracReg = regCache_.Alloc(RegCache::GEN_ARG_LEVELFRAC); - MOVZX(32, 8, levelFracReg, MDisp(RSP, stackArgPos_ + 24)); + MOVZX(32, 8, levelFracReg, MDisp(RSP, stackArgPos_ + 16)); regCache_.Unlock(levelFracReg, RegCache::GEN_ARG_LEVELFRAC); regCache_.ForceRetain(RegCache::GEN_ARG_LEVELFRAC); } @@ -870,6 +871,8 @@ LinearFunc SamplerJitCache::CompileLinear(const SamplerID &id) { } regCache_.ForceRelease(RegCache::VEC_RESULT); + if (regCache_.Has(RegCache::GEN_ARG_ID)) + regCache_.ForceRelease(RegCache::GEN_ARG_ID); if (!success) { regCache_.Reset(false); @@ -1223,9 +1226,9 @@ bool SamplerJitCache::Jit_ReadClutQuad(const SamplerID &id, bool level1) { } else { #if PPSSPP_PLATFORM(WINDOWS) if (cpu_info.bAVX2) { - VPBROADCASTD(128, vecLevelReg, MDisp(RSP, stackArgPos_ + 16)); + VPBROADCASTD(128, vecLevelReg, MDisp(RSP, stackArgPos_ + stackLevelOffset_)); } else { - MOVD_xmm(vecLevelReg, MDisp(RSP, stackArgPos_ + 16)); + MOVD_xmm(vecLevelReg, MDisp(RSP, stackArgPos_ + stackLevelOffset_)); PSHUFD(vecLevelReg, R(vecLevelReg), _MM_SHUFFLE(0, 0, 0, 0)); } #else @@ -2583,11 +2586,6 @@ bool SamplerJitCache::Jit_GetTexDataSwizzled(const SamplerID &id, int bitsPerTex bool SamplerJitCache::Jit_GetTexelCoords(const SamplerID &id) { Describe("Texel"); - // First, adjust X and Y... - // TODO: Shouldn't do this in the sampler, need to get s/t right. - regCache_.ForceRelease(RegCache::GEN_ARG_X); - regCache_.ForceRelease(RegCache::GEN_ARG_Y); - X64Reg uReg = regCache_.Alloc(RegCache::GEN_ARG_U); X64Reg vReg = regCache_.Alloc(RegCache::GEN_ARG_V); X64Reg sReg = regCache_.Find(RegCache::VEC_ARG_S); @@ -2602,7 +2600,7 @@ bool SamplerJitCache::Jit_GetTexelCoords(const SamplerID &id) { levelReg = regCache_.Find(RegCache::GEN_ARG_LEVEL); } else { levelReg = regCache_.Alloc(RegCache::GEN_ARG_LEVEL); - MOV(32, R(levelReg), MDisp(RSP, stackArgPos_ + 16)); + MOV(32, R(levelReg), MDisp(RSP, stackArgPos_ + stackLevelOffset_)); } // We'll multiply these at the same time, so it's nice to put together. @@ -2774,7 +2772,7 @@ bool SamplerJitCache::Jit_GetTexelCoordsQuad(const SamplerID &id) { } else { releaseLevelReg = true; levelReg = regCache_.Alloc(RegCache::GEN_ARG_LEVEL); - MOV(32, R(levelReg), MDisp(RSP, stackArgPos_ + 16)); + MOV(32, R(levelReg), MDisp(RSP, stackArgPos_ + stackLevelOffset_)); } // This will load the current and next level's sizes, 16x4. @@ -2826,8 +2824,6 @@ bool SamplerJitCache::Jit_GetTexelCoordsQuad(const SamplerID &id) { PSLLD(tempXYReg, 7); PADDD(sReg, R(tempXYReg)); regCache_.Release(tempXYReg, RegCache::VEC_TEMP0); - regCache_.ForceRelease(RegCache::GEN_ARG_X); - regCache_.ForceRelease(RegCache::GEN_ARG_Y); // We do want the fraction, though, so extract that to an XMM for later. X64Reg allFracReg = INVALID_REG; diff --git a/unittest/TestSoftwareGPUJit.cpp b/unittest/TestSoftwareGPUJit.cpp index 54b8ceda52..17d0415264 100644 --- a/unittest/TestSoftwareGPUJit.cpp +++ b/unittest/TestSoftwareGPUJit.cpp @@ -89,8 +89,8 @@ static bool TestSamplerJit() { // Try running each to make sure they don't trivially crash. const auto primArg = Rasterizer::ToVec4IntArg(Math3D::Vec4(127, 127, 127, 127)); - linearFunc(0.0f, 0.0f, 0, 0, primArg, tptr, bufw, 1, 7, id); - nearestFunc(0.0f, 0.0f, 0, 0, primArg, tptr, bufw, 1, 7, id); + linearFunc(0.0f, 0.0f, primArg, tptr, bufw, 1, 7, id); + nearestFunc(0.0f, 0.0f, primArg, tptr, bufw, 1, 7, id); fetchFunc(0, 0, tptr[0], bufw[0], 1, id); } From ecf2797173f5818b4ff0b91f5803304737f50bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Oct 2022 21:50:29 +0200 Subject: [PATCH 235/374] Minor refactor of ShaderWriter flags. Extracted from the stereo PR --- Common/GPU/ShaderWriter.cpp | 16 ++++++++-------- Common/GPU/ShaderWriter.h | 15 +++++++++------ GPU/Common/DepalettizeShaderCommon.cpp | 4 ++-- GPU/Common/Draw2D.cpp | 23 +++++++++++++---------- GPU/Common/GeometryShaderGenerator.cpp | 6 +++--- GPU/Common/ReinterpretFramebuffer.cpp | 4 ++-- GPU/Common/StencilCommon.cpp | 4 ++-- 7 files changed, 39 insertions(+), 33 deletions(-) diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index 0f0d416bf7..5399c6241a 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -252,7 +252,7 @@ void ShaderWriter::BeginVSMain(Slice inputs, Slice uniform } } -void ShaderWriter::BeginFSMain(Slice uniforms, Slice varyings, FSFlags flags) { +void ShaderWriter::BeginFSMain(Slice uniforms, Slice varyings) { _assert_(this->stage_ == ShaderStage::Fragment); switch (lang_.shaderLanguage) { case HLSL_D3D11: @@ -266,13 +266,13 @@ void ShaderWriter::BeginFSMain(Slice uniforms, Slice var C("};\n"); } - if (flags & FSFLAG_WRITEDEPTH) { + if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) { C("float gl_FragDepth;\n"); } C("struct PS_OUT {\n"); C(" vec4 target : SV_Target0;\n"); - if (flags & FSFLAG_WRITEDEPTH) { + if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) { C(" float depth : SV_Depth;\n"); } C("};\n"); @@ -287,14 +287,14 @@ void ShaderWriter::BeginFSMain(Slice uniforms, Slice var F(") {\n"); C(" PS_OUT ps_out;\n"); - if (flags & FSFLAG_WRITEDEPTH) { + if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) { C(" float gl_FragDepth;\n"); } break; case HLSL_D3D9: C("struct PS_OUT {\n"); C(" vec4 target : SV_Target0;\n"); - if (flags & FSFLAG_WRITEDEPTH) { + if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) { C(" float depth : DEPTH;\n"); } C("};\n"); @@ -312,7 +312,7 @@ void ShaderWriter::BeginFSMain(Slice uniforms, Slice var F(") {\n"); C(" PS_OUT ps_out;\n"); - if (flags & FSFLAG_WRITEDEPTH) { + if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) { C(" float gl_FragDepth;\n"); } @@ -406,13 +406,13 @@ void ShaderWriter::EndVSMain(Slice varyings) { C("}\n"); } -void ShaderWriter::EndFSMain(const char *vec4_color_variable, FSFlags flags) { +void ShaderWriter::EndFSMain(const char *vec4_color_variable) { _assert_(this->stage_ == ShaderStage::Fragment); switch (lang_.shaderLanguage) { case HLSL_D3D11: case HLSL_D3D9: F(" ps_out.target = %s;\n", vec4_color_variable); - if (flags & FSFLAG_WRITEDEPTH) { + if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) { C(" ps_out.depth = gl_FragDepth;\n"); } C(" return ps_out;\n"); diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index a957362b70..f9160c0491 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -30,15 +30,16 @@ struct VaryingDef { const char *precision; }; -enum FSFlags { - FSFLAG_NONE = 0, - FSFLAG_WRITEDEPTH = 1, +enum class ShaderWriterFlags { + NONE = 0, + FS_WRITE_DEPTH = 1, }; +ENUM_CLASS_BITOPS(ShaderWriterFlags); class ShaderWriter { public: // Extensions are supported for both OpenGL ES and Vulkan (though of course, they're different). - ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, Slice extensions = Slice()) : p_(buffer), lang_(lang), stage_(stage) { + ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, Slice extensions = Slice(), ShaderWriterFlags flags = ShaderWriterFlags::NONE) : p_(buffer), lang_(lang), stage_(stage) { Preamble(extensions); } ShaderWriter(const ShaderWriter &) = delete; @@ -77,6 +78,7 @@ public: void DeclareSamplers(Slice samplers); void ConstFloat(const char *name, float value); + void SetFlags(ShaderWriterFlags flags) { flags_ |= flags; } ShaderWriter &SampleTexture2D(const char *texName, const char *uv); ShaderWriter &SampleTexture2DOffset(const char *texName, const char *uv, int offX, int offY); @@ -85,12 +87,12 @@ public: // Simple shaders with no special tricks. void BeginVSMain(Slice inputs, Slice uniforms, Slice varyings); - void BeginFSMain(Slice uniforms, Slice varyings, FSFlags flags); + void BeginFSMain(Slice uniforms, Slice varyings); void BeginGSMain(Slice varyings, Slice outVaryings); // For simple shaders that output a single color, we can deal with this generically. void EndVSMain(Slice varyings); - void EndFSMain(const char *vec4_color_variable, FSFlags flags); + void EndFSMain(const char *vec4_color_variable); void EndGSMain(); const ShaderLanguageDesc &Lang() const { @@ -116,4 +118,5 @@ private: char *p_; const ShaderLanguageDesc &lang_; const ShaderStage stage_; + ShaderWriterFlags flags_; }; diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index 628efc787f..7ff6c8b587 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -349,7 +349,7 @@ void GenerateDepalSmoothed(ShaderWriter &writer, const DepalConfig &config) { void GenerateDepalFs(ShaderWriter &writer, const DepalConfig &config) { writer.DeclareSamplers(samplers); writer.HighPrecisionFloat(); - writer.BeginFSMain(config.bufferFormat == GE_FORMAT_DEPTH16 ? g_draw2Duniforms : Slice::empty(), varyings, FSFLAG_NONE); + writer.BeginFSMain(config.bufferFormat == GE_FORMAT_DEPTH16 ? g_draw2Duniforms : Slice::empty(), varyings); if (config.smoothedDepal) { // Handles a limited set of cases, but doesn't need any integer math so we don't // need two variants. @@ -369,5 +369,5 @@ void GenerateDepalFs(ShaderWriter &writer, const DepalConfig &config) { _assert_msg_(false, "Shader language not supported for depal: %d", (int)writer.Lang().shaderLanguage); } } - writer.EndFSMain("outColor", FSFLAG_NONE); + writer.EndFSMain("outColor"); } diff --git a/GPU/Common/Draw2D.cpp b/GPU/Common/Draw2D.cpp index 05bead52e4..93d542bafb 100644 --- a/GPU/Common/Draw2D.cpp +++ b/GPU/Common/Draw2D.cpp @@ -59,9 +59,9 @@ const UniformBufferDesc draw2DUBDesc{ sizeof(Draw2DUB), { Draw2DPipelineInfo GenerateDraw2DCopyColorFs(ShaderWriter &writer) { writer.DeclareSamplers(samplers); - writer.BeginFSMain(Slice::empty(), varyings, FSFLAG_NONE); + writer.BeginFSMain(Slice::empty(), varyings); writer.C(" vec4 outColor = ").SampleTexture2D("tex", "v_texcoord.xy").C(";\n"); - writer.EndFSMain("outColor", FSFLAG_NONE); + writer.EndFSMain("outColor"); return Draw2DPipelineInfo{ "draw2d_copy_color", @@ -72,13 +72,13 @@ Draw2DPipelineInfo GenerateDraw2DCopyColorFs(ShaderWriter &writer) { Draw2DPipelineInfo GenerateDraw2DCopyColorRect2LinFs(ShaderWriter &writer) { writer.DeclareSamplers(samplers); - writer.BeginFSMain(g_draw2Duniforms, varyings, FSFLAG_NONE); + writer.BeginFSMain(g_draw2Duniforms, varyings); writer.C(" vec2 tSize = texSize / scaleFactor;\n"); writer.C(" vec2 pixels = v_texcoord * tSize;\n"); writer.C(" float u = mod(pixels.x, tSize.x);\n"); writer.C(" float v = floor(pixels.x / tSize.x);\n"); writer.C(" vec4 outColor = ").SampleTexture2D("tex", "vec2(u, v) / tSize").C(";\n"); - writer.EndFSMain("outColor", FSFLAG_NONE); + writer.EndFSMain("outColor"); return Draw2DPipelineInfo{ "draw2d_copy_color_rect2lin", @@ -89,10 +89,11 @@ Draw2DPipelineInfo GenerateDraw2DCopyColorRect2LinFs(ShaderWriter &writer) { Draw2DPipelineInfo GenerateDraw2DCopyDepthFs(ShaderWriter &writer) { writer.DeclareSamplers(samplers); - writer.BeginFSMain(Slice::empty(), varyings, FSFLAG_WRITEDEPTH); + writer.SetFlags(ShaderWriterFlags::FS_WRITE_DEPTH); + writer.BeginFSMain(Slice::empty(), varyings); writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n"); writer.C(" gl_FragDepth = ").SampleTexture2D("tex", "v_texcoord.xy").C(".x;\n"); - writer.EndFSMain("outColor", FSFLAG_WRITEDEPTH); + writer.EndFSMain("outColor"); return Draw2DPipelineInfo{ "draw2d_copy_depth", @@ -103,7 +104,8 @@ Draw2DPipelineInfo GenerateDraw2DCopyDepthFs(ShaderWriter &writer) { Draw2DPipelineInfo GenerateDraw2D565ToDepthFs(ShaderWriter &writer) { writer.DeclareSamplers(samplers); - writer.BeginFSMain(Slice::empty(), varyings, FSFLAG_WRITEDEPTH); + writer.SetFlags(ShaderWriterFlags::FS_WRITE_DEPTH); + writer.BeginFSMain(Slice::empty(), varyings); writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n"); // Unlike when just copying a depth buffer, here we're generating new depth values so we'll // have to apply the scaling. @@ -111,7 +113,7 @@ Draw2DPipelineInfo GenerateDraw2D565ToDepthFs(ShaderWriter &writer) { writer.C(" vec3 rgb = ").SampleTexture2D("tex", "v_texcoord.xy").C(".xyz;\n"); writer.F(" highp float depthValue = (floor(rgb.x * 31.99) + floor(rgb.y * 63.99) * 32.0 + floor(rgb.z * 31.99) * 2048.0); \n"); writer.F(" gl_FragDepth = (depthValue / %f) + %f;\n", factors.scale, factors.offset); - writer.EndFSMain("outColor", FSFLAG_WRITEDEPTH); + writer.EndFSMain("outColor"); return Draw2DPipelineInfo{ "draw2d_565_to_depth", @@ -122,7 +124,8 @@ Draw2DPipelineInfo GenerateDraw2D565ToDepthFs(ShaderWriter &writer) { Draw2DPipelineInfo GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) { writer.DeclareSamplers(samplers); - writer.BeginFSMain(g_draw2Duniforms, varyings, FSFLAG_WRITEDEPTH); + writer.SetFlags(ShaderWriterFlags::FS_WRITE_DEPTH); + writer.BeginFSMain(g_draw2Duniforms, varyings); writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n"); // Unlike when just copying a depth buffer, here we're generating new depth values so we'll // have to apply the scaling. @@ -136,7 +139,7 @@ Draw2DPipelineInfo GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) { writer.C(" vec3 rgb = ").SampleTexture2D("tex", "coord").C(".xyz;\n"); writer.F(" highp float depthValue = (floor(rgb.x * 31.99) + floor(rgb.y * 63.99) * 32.0 + floor(rgb.z * 31.99) * 2048.0); \n"); writer.F(" gl_FragDepth = (depthValue / %f) + %f;\n", factors.scale, factors.offset); - writer.EndFSMain("outColor", FSFLAG_WRITEDEPTH); + writer.EndFSMain("outColor"); return Draw2DPipelineInfo{ "draw2d_565_to_depth_deswizzle", diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index fc8a9f9a27..586afdca0f 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -39,16 +39,16 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLanguageDesc &compat, const Draw::Bugs bugs, std::string *errorString) { - std::vector gl_exts; + std::vector extensions; if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { if (gl_extensions.EXT_gpu_shader4) { - gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); + extensions.push_back("#extension GL_EXT_gpu_shader4 : enable"); } } bool vertexRangeCulling = !id.Bit(GS_BIT_CURVE); bool clipClampedDepth = gstate_c.Use(GPU_USE_DEPTH_CLAMP); - ShaderWriter p(buffer, compat, ShaderStage::Geometry, gl_exts); + ShaderWriter p(buffer, compat, ShaderStage::Geometry, extensions); p.C("layout(triangles) in;\n"); if (clipClampedDepth && vertexRangeCulling && !gstate_c.Use(GPU_USE_CLIP_DISTANCE)) { p.C("layout(triangle_strip, max_vertices = 12) out;\n"); diff --git a/GPU/Common/ReinterpretFramebuffer.cpp b/GPU/Common/ReinterpretFramebuffer.cpp index 09f2552a9b..ea80fa8b3d 100644 --- a/GPU/Common/ReinterpretFramebuffer.cpp +++ b/GPU/Common/ReinterpretFramebuffer.cpp @@ -161,7 +161,7 @@ Draw2DPipelineInfo GenerateReinterpretFragmentShader(ShaderWriter &writer, GEBuf } } - writer.BeginFSMain(g_draw2Duniforms, varyings, FSFLAG_NONE); + writer.BeginFSMain(g_draw2Duniforms, varyings); if (IsBufferFormat16Bit(from) && IsBufferFormat16Bit(to)) { writer.C(" vec4 val = ").SampleTexture2D("tex", "v_texcoord.xy").C(";\n"); @@ -182,7 +182,7 @@ Draw2DPipelineInfo GenerateReinterpretFragmentShader(ShaderWriter &writer, GEBuf writer.C(" vec4 outColor = unpackColor(u == 0.0 ? packColor(val.rg) : packColor(val.ba));\n"); } - writer.EndFSMain("outColor", FSFLAG_NONE); + writer.EndFSMain("outColor"); return Draw2DPipelineInfo{ "reinterpret", diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index fd552208f7..c829e40f03 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -94,7 +94,7 @@ void GenerateStencilFs(char *buffer, const ShaderLanguageDesc &lang, const Draw: writer.C("float roundAndScaleTo255f(in float x) { return floor(x * 255.99); }\n"); - writer.BeginFSMain(uniforms, varyings, FSFLAG_NONE); + writer.BeginFSMain(uniforms, varyings); writer.C(" vec4 index = ").SampleTexture2D("tex", "v_texcoord.xy").C(";\n"); writer.C(" vec4 outColor = index.aaaa;\n"); // Only care about a. @@ -106,7 +106,7 @@ void GenerateStencilFs(char *buffer, const ShaderLanguageDesc &lang, const Draw: writer.C(" gl_FragDepth = gl_FragCoord.z;\n"); } - writer.EndFSMain("outColor", FSFLAG_NONE); + writer.EndFSMain("outColor"); } // This can probably be shared with some other shaders, like reinterpret or the future depth upload. From e77ff0281fbc3c5c152143bbe282b98e0be1cba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 24 Oct 2022 00:20:45 +0200 Subject: [PATCH 236/374] Testfix --- Common/GPU/ShaderWriter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index f9160c0491..bcfc2f8263 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -118,5 +118,5 @@ private: char *p_; const ShaderLanguageDesc &lang_; const ShaderStage stage_; - ShaderWriterFlags flags_; + ShaderWriterFlags flags_ = ShaderWriterFlags::NONE; }; From 1d8ab38ce55f8b013ed42ca7b7af80cd7a297c7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Oct 2022 22:05:33 +0200 Subject: [PATCH 237/374] Vulkan: Use v2 feature checks, and add check for multiview features. Extracted from the multiview PR, and renamed some stuff. --- Common/GPU/Vulkan/VulkanContext.cpp | 41 +++++++++++++++++++++-------- Common/GPU/Vulkan/VulkanContext.h | 9 +++++-- Common/GPU/Vulkan/thin3d_vulkan.cpp | 25 ++++++++++-------- GPU/Vulkan/GPU_Vulkan.cpp | 6 ++--- 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index 937276d10f..a3bbf1f0ea 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -585,22 +585,32 @@ void VulkanContext::ChooseDevice(int physical_device) { // Optional features if (extensionsLookup_.KHR_get_physical_device_properties2) { VkPhysicalDeviceFeatures2 features2{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR}; + // Add to chain even if not supported, GetPhysicalDeviceFeatures is supposed to ignore unknown structs. + VkPhysicalDeviceMultiviewFeatures multiViewFeatures{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES }; + features2.pNext = &multiViewFeatures; vkGetPhysicalDeviceFeatures2KHR(physical_devices_[physical_device_], &features2); - deviceFeatures_.available = features2.features; + deviceFeatures_.available.standard = features2.features; + deviceFeatures_.available.multiview = multiViewFeatures; } else { - vkGetPhysicalDeviceFeatures(physical_devices_[physical_device_], &deviceFeatures_.available); + vkGetPhysicalDeviceFeatures(physical_devices_[physical_device_], &deviceFeatures_.available.standard); + deviceFeatures_.available.multiview = {}; } deviceFeatures_.enabled = {}; // Enable a few safe ones if they are available. - deviceFeatures_.enabled.dualSrcBlend = deviceFeatures_.available.dualSrcBlend; - deviceFeatures_.enabled.logicOp = deviceFeatures_.available.logicOp; - deviceFeatures_.enabled.depthClamp = deviceFeatures_.available.depthClamp; - deviceFeatures_.enabled.depthBounds = deviceFeatures_.available.depthBounds; - deviceFeatures_.enabled.samplerAnisotropy = deviceFeatures_.available.samplerAnisotropy; - deviceFeatures_.enabled.shaderClipDistance = deviceFeatures_.available.shaderClipDistance; - deviceFeatures_.enabled.shaderCullDistance = deviceFeatures_.available.shaderCullDistance; - deviceFeatures_.enabled.geometryShader = deviceFeatures_.available.geometryShader; + deviceFeatures_.enabled.standard.dualSrcBlend = deviceFeatures_.available.standard.dualSrcBlend; + deviceFeatures_.enabled.standard.logicOp = deviceFeatures_.available.standard.logicOp; + deviceFeatures_.enabled.standard.depthClamp = deviceFeatures_.available.standard.depthClamp; + deviceFeatures_.enabled.standard.depthBounds = deviceFeatures_.available.standard.depthBounds; + deviceFeatures_.enabled.standard.samplerAnisotropy = deviceFeatures_.available.standard.samplerAnisotropy; + deviceFeatures_.enabled.standard.shaderClipDistance = deviceFeatures_.available.standard.shaderClipDistance; + deviceFeatures_.enabled.standard.shaderCullDistance = deviceFeatures_.available.standard.shaderCullDistance; + deviceFeatures_.enabled.standard.geometryShader = deviceFeatures_.available.standard.geometryShader; + + deviceFeatures_.enabled.multiview = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES }; + // Don't yet enable these. + // deviceFeatures_.enabled.multiview.multiview = deviceFeatures_.available.multiview.multiview; + // deviceFeatures_.enabled.multiview.multiviewGeometryShader = deviceFeatures_.available.multiview.multiviewGeometryShader; GetDeviceLayerExtensionList(nullptr, device_extension_properties_); @@ -671,6 +681,8 @@ VkResult VulkanContext::CreateDevice() { extensionsLookup_.EXT_fragment_shader_interlock = EnableDeviceExtension(VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME); extensionsLookup_.ARM_rasterization_order_attachment_access = EnableDeviceExtension(VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME); + VkPhysicalDeviceFeatures2 features2{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 }; + VkDeviceCreateInfo device_info{ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO }; device_info.queueCreateInfoCount = 1; device_info.pQueueCreateInfos = &queue_info; @@ -678,7 +690,14 @@ VkResult VulkanContext::CreateDevice() { device_info.ppEnabledLayerNames = device_info.enabledLayerCount ? device_layer_names_.data() : nullptr; device_info.enabledExtensionCount = (uint32_t)device_extensions_enabled_.size(); device_info.ppEnabledExtensionNames = device_info.enabledExtensionCount ? device_extensions_enabled_.data() : nullptr; - device_info.pEnabledFeatures = &deviceFeatures_.enabled; + + if (extensionsLookup_.KHR_get_physical_device_properties2) { + device_info.pNext = &features2; + features2.features = deviceFeatures_.enabled.standard; + features2.pNext = &deviceFeatures_.enabled.multiview; + } else { + device_info.pEnabledFeatures = &deviceFeatures_.enabled.standard; + } VkResult res = vkCreateDevice(physical_devices_[physical_device_], &device_info, nullptr, &device_); if (res != VK_SUCCESS) { diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index fb98b5a0db..60ef6d373e 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -252,6 +252,11 @@ public: VkPhysicalDeviceExternalMemoryHostPropertiesEXT externalMemoryHostProperties; }; + struct AllPhysicalDeviceFeatures { + VkPhysicalDeviceFeatures standard; + VkPhysicalDeviceMultiviewFeatures multiview; + }; + const PhysicalDeviceProps &GetPhysicalDeviceProperties(int i = -1) const { if (i < 0) i = GetCurrentPhysicalDeviceIndex(); @@ -276,8 +281,8 @@ public: } struct PhysicalDeviceFeatures { - VkPhysicalDeviceFeatures available{}; - VkPhysicalDeviceFeatures enabled{}; + AllPhysicalDeviceFeatures available{}; + AllPhysicalDeviceFeatures enabled{}; }; const PhysicalDeviceFeatures &GetDeviceFeatures() const { return deviceFeatures_; } diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index adfe90d14c..cedb21b49f 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -777,14 +777,14 @@ VKContext::VKContext(VulkanContext *vulkan) VkFormat depthStencilFormat = vulkan->GetDeviceInfo().preferredDepthStencilFormat; - caps_.anisoSupported = vulkan->GetDeviceFeatures().enabled.samplerAnisotropy != 0; - caps_.geometryShaderSupported = vulkan->GetDeviceFeatures().enabled.geometryShader != 0; - caps_.tesselationShaderSupported = vulkan->GetDeviceFeatures().enabled.tessellationShader != 0; - caps_.multiViewport = vulkan->GetDeviceFeatures().enabled.multiViewport != 0; - caps_.dualSourceBlend = vulkan->GetDeviceFeatures().enabled.dualSrcBlend != 0; - caps_.depthClampSupported = vulkan->GetDeviceFeatures().enabled.depthClamp != 0; - caps_.clipDistanceSupported = vulkan->GetDeviceFeatures().enabled.shaderClipDistance != 0; - caps_.cullDistanceSupported = vulkan->GetDeviceFeatures().enabled.shaderCullDistance != 0; + caps_.anisoSupported = vulkan->GetDeviceFeatures().enabled.standard.samplerAnisotropy != 0; + caps_.geometryShaderSupported = vulkan->GetDeviceFeatures().enabled.standard.geometryShader != 0; + caps_.tesselationShaderSupported = vulkan->GetDeviceFeatures().enabled.standard.tessellationShader != 0; + caps_.multiViewport = vulkan->GetDeviceFeatures().enabled.standard.multiViewport != 0; + caps_.dualSourceBlend = vulkan->GetDeviceFeatures().enabled.standard.dualSrcBlend != 0; + caps_.depthClampSupported = vulkan->GetDeviceFeatures().enabled.standard.depthClamp != 0; + caps_.clipDistanceSupported = vulkan->GetDeviceFeatures().enabled.standard.shaderClipDistance != 0; + caps_.cullDistanceSupported = vulkan->GetDeviceFeatures().enabled.standard.shaderCullDistance != 0; caps_.framebufferBlitSupported = true; caps_.framebufferCopySupported = true; caps_.framebufferDepthBlitSupported = vulkan->GetDeviceInfo().canBlitToPreferredDepthStencilFormat; @@ -798,7 +798,7 @@ VKContext::VKContext(VulkanContext *vulkan) caps_.textureNPOTFullySupported = true; caps_.fragmentShaderDepthWriteSupported = true; caps_.blendMinMaxSupported = true; - caps_.logicOpSupported = vulkan->GetDeviceFeatures().enabled.logicOp != 0; + caps_.logicOpSupported = vulkan->GetDeviceFeatures().enabled.standard.logicOp != 0; auto deviceProps = vulkan->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDeviceIndex()).properties; @@ -1414,8 +1414,8 @@ void AddFeature(std::vector &features, const char *name, VkBool32 a } std::vector VKContext::GetFeatureList() const { - const VkPhysicalDeviceFeatures &available = vulkan_->GetDeviceFeatures().available; - const VkPhysicalDeviceFeatures &enabled = vulkan_->GetDeviceFeatures().enabled; + const VkPhysicalDeviceFeatures &available = vulkan_->GetDeviceFeatures().available.standard; + const VkPhysicalDeviceFeatures &enabled = vulkan_->GetDeviceFeatures().enabled.standard; std::vector features; AddFeature(features, "dualSrcBlend", available.dualSrcBlend, enabled.dualSrcBlend); @@ -1434,6 +1434,9 @@ std::vector VKContext::GetFeatureList() const { AddFeature(features, "occlusionQueryPrecise", available.occlusionQueryPrecise, enabled.occlusionQueryPrecise); AddFeature(features, "multiDrawIndirect", available.multiDrawIndirect, enabled.multiDrawIndirect); + AddFeature(features, "multiview", vulkan_->GetDeviceFeatures().available.multiview.multiview, vulkan_->GetDeviceFeatures().enabled.multiview.multiview); + AddFeature(features, "multiviewGeometryShader", vulkan_->GetDeviceFeatures().available.multiview.multiviewGeometryShader, vulkan_->GetDeviceFeatures().enabled.multiview.multiviewGeometryShader); + features.emplace_back(std::string("Preferred depth buffer format: ") + VulkanFormatToString(vulkan_->GetDeviceInfo().preferredDepthStencilFormat)); return features; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index fbc31a90e3..c46b8b2812 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -227,7 +227,7 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_USE_VERTEX_TEXTURE_FETCH; features |= GPU_USE_TEXTURE_FLOAT; - auto &enabledFeatures = vulkan->GetDeviceFeatures().enabled; + auto &enabledFeatures = vulkan->GetDeviceFeatures().enabled.standard; if (enabledFeatures.depthClamp) { features |= GPU_USE_DEPTH_CLAMP; } @@ -325,9 +325,9 @@ void GPU_Vulkan::EndHostFrame() { void GPU_Vulkan::BuildReportingInfo() { VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT); const auto &props = vulkan->GetPhysicalDeviceProperties().properties; - const auto &features = vulkan->GetDeviceFeatures().available; + const auto &available = vulkan->GetDeviceFeatures().available; -#define CHECK_BOOL_FEATURE(n) do { if (features.n) { featureNames += ", " #n; } } while (false) +#define CHECK_BOOL_FEATURE(n) do { if (available.standard.n) { featureNames += ", " #n; } } while (false) std::string featureNames = ""; CHECK_BOOL_FEATURE(robustBufferAccess); From 7533b649406ab34a4b5911abeeff48344a8bc865 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 23 Oct 2022 22:01:50 -0700 Subject: [PATCH 238/374] GE Debugger: Allow reading tex on D3D11. --- GPU/D3D11/TextureCacheD3D11.cpp | 34 ++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 83c2c4869c..486ad9417f 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -470,8 +470,31 @@ bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level D3D11_TEXTURE2D_DESC desc; texture->GetDesc(&desc); - if (desc.Format != DXGI_FORMAT_B8G8R8A8_UNORM) { - // TODO: Support the other formats + int width = desc.Width >> level; + int height = desc.Height >> level; + + switch (desc.Format) { + case DXGI_FORMAT_B8G8R8A8_UNORM: + buffer.Allocate(width, height, GPU_DBG_FORMAT_8888); + break; + + case DXGI_FORMAT_B5G6R5_UNORM: + buffer.Allocate(width, height, GPU_DBG_FORMAT_565); + break; + + case DXGI_FORMAT_B4G4R4A4_UNORM: + buffer.Allocate(width, height, GPU_DBG_FORMAT_4444); + break; + + case DXGI_FORMAT_B5G5R5A1_UNORM: + buffer.Allocate(width, height, GPU_DBG_FORMAT_5551); + break; + + case DXGI_FORMAT_R8_UNORM: + buffer.Allocate(width, height, GPU_DBG_FORMAT_8BIT); + break; + + default: return false; } @@ -483,18 +506,15 @@ bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level device_->CreateTexture2D(&desc, nullptr, &stagingCopy); context_->CopyResource(stagingCopy, texture); - int width = desc.Width >> level; - int height = desc.Height >> level; - buffer.Allocate(width, height, GPU_DBG_FORMAT_8888); - D3D11_MAPPED_SUBRESOURCE map; if (FAILED(context_->Map(stagingCopy, level, D3D11_MAP_READ, 0, &map))) { stagingCopy->Release(); return false; } + int bufferRowSize = buffer.PixelSize() * width; for (int y = 0; y < height; y++) { - memcpy(buffer.GetData() + 4 * width * y, (const uint8_t *)map.pData + map.RowPitch * y, 4 * width); + memcpy(buffer.GetData() + bufferRowSize * y, (const uint8_t *)map.pData + map.RowPitch * y, bufferRowSize); } context_->Unmap(stagingCopy, level); From 80e1db07a7b388edb7ecf21267e25c3d87326e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 24 Oct 2022 17:41:41 +0200 Subject: [PATCH 239/374] Minor ShaderWriter refactor, prep for later changes --- Common/GPU/Shader.h | 1 + Common/GPU/ShaderWriter.cpp | 28 +++++++++++++++++--------- Common/GPU/ShaderWriter.h | 9 +++++++-- GPU/Common/DepalettizeShaderCommon.cpp | 4 ++-- GPU/Common/Draw2D.cpp | 2 +- GPU/Common/ReinterpretFramebuffer.cpp | 2 +- GPU/Common/StencilCommon.cpp | 2 +- GPU/Common/TextureShaderCommon.cpp | 4 ++-- 8 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Common/GPU/Shader.h b/Common/GPU/Shader.h index 75e1a9b2e9..4020a7b253 100644 --- a/Common/GPU/Shader.h +++ b/Common/GPU/Shader.h @@ -92,6 +92,7 @@ struct UniformDef { }; struct SamplerDef { + int binding; // Might only be used by some backends. const char *name; // TODO: Might need unsigned samplers, 3d samplers, or other types in the future. }; diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index 5399c6241a..e00a468e35 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -456,34 +456,35 @@ void ShaderWriter::ConstFloat(const char *name, float value) { void ShaderWriter::DeclareSamplers(Slice samplers) { for (int i = 0; i < (int)samplers.size(); i++) { - DeclareTexture2D(samplers[i].name, i); - DeclareSampler2D(samplers[i].name, i); + DeclareTexture2D(samplers[i]); + DeclareSampler2D(samplers[i]); } + samplerDefs_ = samplers; } -void ShaderWriter::DeclareTexture2D(const char *name, int binding) { +void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { switch (lang_.shaderLanguage) { case HLSL_D3D11: - F("Texture2D %s : register(t%d);\n", name, binding); + F("Texture2D %s : register(t%d);\n", def.name, def.binding); break; case HLSL_D3D9: - F("sampler %s: register(s%d);\n", name, binding); + F("sampler %s: register(s%d);\n", def.name, def.binding); break; case GLSL_VULKAN: // In the thin3d descriptor set layout, textures start at 1 in set 0. Hence the +1. - F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", binding + 1, name); + F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name); break; default: - F("uniform sampler2D %s;\n", name); + F("uniform sampler2D %s;\n", def.name); break; } } -void ShaderWriter::DeclareSampler2D(const char *name, int binding) { +void ShaderWriter::DeclareSampler2D(const SamplerDef &def) { // We only use separate samplers in HLSL D3D11, where we have no choice. switch (lang_.shaderLanguage) { case HLSL_D3D11: - F("SamplerState %sSamp : register(s%d);\n", name, binding); + F("SamplerState %sSamp : register(s%d);\n", def.name, def.binding); break; default: break; @@ -555,3 +556,12 @@ ShaderWriter &ShaderWriter::GetTextureSize(const char *szVariable, const char *t } return *this; } + +const SamplerDef *ShaderWriter::GetSamplerDef(const char *name) const { + for (int i = 0; i < (int)samplerDefs_.size(); i++) { + if (!strcmp(samplerDefs_[i].name, name)) { + return &samplerDefs_[i]; + } + } + return nullptr; +} diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index bcfc2f8263..6eb42719f0 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -75,10 +75,12 @@ public: void HighPrecisionFloat(); void LowPrecisionFloat(); + // NOTE: samplers must live for the rest of ShaderWriter's lifetime. No way to express that in C++ though :( void DeclareSamplers(Slice samplers); void ConstFloat(const char *name, float value); void SetFlags(ShaderWriterFlags flags) { flags_ |= flags; } + void SetTexBindingBase(int base) { texBindingBase_ = base; } ShaderWriter &SampleTexture2D(const char *texName, const char *uv); ShaderWriter &SampleTexture2DOffset(const char *texName, const char *uv, int offX, int offY); @@ -110,8 +112,9 @@ public: private: // Several of the shader languages ignore samplers, beware of that. - void DeclareSampler2D(const char *name, int binding); - void DeclareTexture2D(const char *name, int binding); + void DeclareSampler2D(const SamplerDef &def); + void DeclareTexture2D(const SamplerDef &def); + const SamplerDef *GetSamplerDef(const char *name) const; void Preamble(Slice extensions); @@ -119,4 +122,6 @@ private: const ShaderLanguageDesc &lang_; const ShaderStage stage_; ShaderWriterFlags flags_ = ShaderWriterFlags::NONE; + Slice samplerDefs_; + int texBindingBase_ = 1; }; diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index 7ff6c8b587..a784d22377 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -35,8 +35,8 @@ static const InputDef vsInputs[2] = { // TODO: Deduplicate with TextureShaderCommon.cpp static const SamplerDef samplers[2] = { - { "tex" }, - { "pal" }, + { 0, "tex" }, + { 1, "pal" }, }; static const VaryingDef varyings[1] = { diff --git a/GPU/Common/Draw2D.cpp b/GPU/Common/Draw2D.cpp index 93d542bafb..9b342e05bc 100644 --- a/GPU/Common/Draw2D.cpp +++ b/GPU/Common/Draw2D.cpp @@ -37,7 +37,7 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[1] = { - { "tex" }, + { 0, "tex" }, }; const UniformDef g_draw2Duniforms[2] = { diff --git a/GPU/Common/ReinterpretFramebuffer.cpp b/GPU/Common/ReinterpretFramebuffer.cpp index ea80fa8b3d..b14e324d0d 100644 --- a/GPU/Common/ReinterpretFramebuffer.cpp +++ b/GPU/Common/ReinterpretFramebuffer.cpp @@ -14,7 +14,7 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[1] = { - { "tex" } + { 0, "tex" } }; // Requires full size integer math. It would be possible to make a floating point-only version with lots of diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index c829e40f03..682d8a1f0c 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -80,7 +80,7 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[1] = { - { "tex" }, + { 0, "tex" }, }; void GenerateStencilFs(char *buffer, const ShaderLanguageDesc &lang, const Draw::Bugs &bugs) { diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index 2860389fc2..5919d5442e 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -34,8 +34,8 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[2] = { - { "tex" }, - { "pal" }, + { 0, "tex" }, + { 1, "pal" }, }; TextureShaderCache::TextureShaderCache(Draw::DrawContext *draw, Draw2D *draw2D) : draw_(draw), draw2D_(draw2D) { } From 1e1c75d5520606ce8f67979519f1a5b51e90d058 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 25 Oct 2022 22:14:16 -0700 Subject: [PATCH 240/374] GE Debugger: Correct UV display with prescale. Sometimes these weren't flushed yet, and it made the texture preview and vertices confusing and wrong (using old factors, not just no factors.) --- GPU/GPUCommon.cpp | 1 + GPU/Software/SoftGpu.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index c80aab881c..b8c80a76ed 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -3204,6 +3204,7 @@ std::vector GPUCommon::GetFramebufferList() const { } bool GPUCommon::GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) { + UpdateUVScaleOffset(); return drawEngineCommon_->GetCurrentSimpleVertices(count, vertices, indices); } diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index ba6da9455c..04e3c1d5c7 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -1423,8 +1423,8 @@ bool SoftGPU::GetCurrentClut(GPUDebugBuffer &buffer) return true; } -bool SoftGPU::GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) -{ +bool SoftGPU::GetCurrentSimpleVertices(int count, std::vector &vertices, std::vector &indices) { + UpdateUVScaleOffset(); return drawEngine_->transformUnit.GetCurrentSimpleVertices(count, vertices, indices); } From deba3d40bc01563d88670b1b06ee7dc095a25fc4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 25 Oct 2022 22:15:47 -0700 Subject: [PATCH 241/374] headless: Update tests. --- pspautotests | 2 +- test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pspautotests b/pspautotests index d40a8e05c3..1790e574bd 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit d40a8e05c3892bd67af71c6f80ea4396f8051541 +Subproject commit 1790e574bd069c7e4883bf097db46094526b0dc9 diff --git a/test.py b/test.py index 7b76dbca07..b9cf9260ca 100755 --- a/test.py +++ b/test.py @@ -192,6 +192,7 @@ tests_good = [ "gpu/textures/mipmap", "gpu/textures/rotate", "gpu/vertices/colors", + "gpu/vertices/morph", "gpu/vertices/texcoords", "hash/hash", "hle/check_not_used_uids", From e7eddab2a1f72639d7d44fbbea51b2351420437b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 26 Oct 2022 00:18:14 -0700 Subject: [PATCH 242/374] Build: Update deprecated actions. There are some deprecations coming and some actions might stop working. It seems softprops/action-gh-release@v1 is not being actively maintained, and isn't updated here. --- .github/workflows/build.yml | 36 +++++++++-------------- .github/workflows/generateDockerLayer.yml | 8 ++--- .github/workflows/manual_generate_apk.yml | 7 +++-- .github/workflows/tarball.yml | 4 +-- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc776d30a0..06392a23f9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,12 +34,12 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1 + uses: microsoft/setup-msbuild@v1.1 - name: Build Windows working-directory: ${{ env.GITHUB_WORKSPACE }} @@ -63,7 +63,7 @@ jobs: run: cp Windows/Release/*.exe ppsspp/ - name: Upload build - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: Windows ${{ matrix.platform }} build path: ppsspp/ @@ -71,12 +71,12 @@ jobs: build-uwp: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - name: Add MSBuild to PATH - uses: microsoft/setup-msbuild@v1 + uses: microsoft/setup-msbuild@v1.1 - name: Build UWP working-directory: ${{ env.GITHUB_WORKSPACE }} @@ -87,7 +87,7 @@ jobs: needs: build-windows timeout-minutes: 30 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: false @@ -97,7 +97,7 @@ jobs: run: git submodule update --init pspautotests assets/lang - name: Download build - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: Windows x64 build path: ppsspp/ @@ -192,7 +192,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive @@ -202,19 +202,11 @@ jobs: run: | git fetch --deepen=15000 --no-recurse-submodules --tags || exit 0 - - name: Cache Qt - uses: actions/cache@v1 - if: matrix.extra == 'qt' - id: cache-qt - with: - path: ${{ runner.workspace }}/Qt - key: ${{ runner.os }}-QtCache - - name: Install Qt - uses: jurplel/install-qt-action@v2 + uses: jurplel/install-qt-action@v3 if: matrix.extra == 'qt' with: - cached: ${{ steps.cache-qt.outputs.cache-hit }} + cache: true - uses: nttld/setup-ndk@v1 if: matrix.extra == 'android' @@ -236,7 +228,7 @@ jobs: echo "#define PPSSPP_GIT_VERSION_NO_UPDATE 1" >> git-version.cpp - name: Setup ccache - uses: hendrikmuhs/ccache-action@v1 + uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ matrix.id }} @@ -279,7 +271,7 @@ jobs: fi - name: Upload build - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 if: matrix.extra == 'test' with: name: ${{ matrix.os }} build @@ -313,7 +305,7 @@ jobs: needs: build timeout-minutes: 30 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: false @@ -335,7 +327,7 @@ jobs: git submodule update --init SDL/macOS - name: Download build - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: ${{ matrix.os }} build path: ppsspp/ diff --git a/.github/workflows/generateDockerLayer.yml b/.github/workflows/generateDockerLayer.yml index 91164f5af8..5e038f398f 100644 --- a/.github/workflows/generateDockerLayer.yml +++ b/.github/workflows/generateDockerLayer.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Extract DOCKER_TAG using tag name if: startsWith(github.ref, 'refs/tags/') @@ -25,13 +25,13 @@ jobs: echo "DOCKER_TAG=latest" >> $GITHUB_ENV - name: Login to Github registry - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io - - uses: docker/build-push-action@v2 + - uses: docker/build-push-action@v3 with: push: true - tags: ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }} \ No newline at end of file + tags: ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }} diff --git a/.github/workflows/manual_generate_apk.yml b/.github/workflows/manual_generate_apk.yml index 3f38055ac5..4c48320259 100644 --- a/.github/workflows/manual_generate_apk.yml +++ b/.github/workflows/manual_generate_apk.yml @@ -19,14 +19,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 submodules: recursive - name: Setup JDK - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: + distribution: 'zulu' java-version: '11' #- name: Setup SDK @@ -54,7 +55,7 @@ jobs: fi - name: Upload APK - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v3 with: name: android-${{ github.event.inputs.buildVariant }} build path: ppsspp/ diff --git a/.github/workflows/tarball.yml b/.github/workflows/tarball.yml index 47c022593e..84fec3625a 100644 --- a/.github/workflows/tarball.yml +++ b/.github/workflows/tarball.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive @@ -40,7 +40,7 @@ jobs: sed -i "s;unknown;${VERSION};" $PKGNAME/git-version.cmake || true TARBALL=$PKGNAME.tar.xz tar cJf $TARBALL $PKGNAME - echo "::set-output name=tarball::$TARBALL" + echo "tarball=$TARBALL" >> $GITHUB_OUTPUT - name: upload tarball uses: softprops/action-gh-release@v1 From d3e99fa3089bd026583b1b5b5b97b9d2eb21b45b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 26 Oct 2022 00:21:55 -0700 Subject: [PATCH 243/374] Build: Fix Android/macOS ccache. --- .github/workflows/build.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06392a23f9..778b601445 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -238,8 +238,20 @@ jobs: CXX: ${{ matrix.cxx }} NDK: ${{ steps.setup-ndk.outputs.ndk-path }} NDK_CCACHE: ccache + USE_CCACHE: 1 run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + export CCACHE_SLOPPINESS=clang_index_store,ivfsoverlay,include_file_ctime,include_file_mtime,modules,system_headers,time_macros + if [ "${{ matrix.extra }}" == "android" ]; then + export CCACHE_FILECLONE=true + export CCACHE_DEPEND=true + export CCACHE_COMPILERCHECK=content + elif [ "$RUNNER_OS" == "macOS" ]; then + export CCACHE_SLOPPINESS=pch_defines,$CCACHE_SLOPPINESS + export CCACHE_FILECLONE=true + export CCACHE_DEPEND=true + export CCACHE_COMPILERCHECK=content + fi ${{ matrix.args }} - name: Package build From 5ad27d07697991ff0ac7c71926b2692e8435b196 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 26 Oct 2022 21:23:40 +0200 Subject: [PATCH 244/374] OpenXR - 6DoF and stereo in Lego Star Wars II fixed --- assets/compatvr.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 92cf0d32d1..30fa562230 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -874,8 +874,8 @@ ULES01370 = 47.0 ULUS10487 = 47.0 # LEGO Star Wars II: The Original Trilogy -ULES00479 = 47.0 -ULUS10155 = 47.0 +ULES00479 = 1.0 +ULUS10155 = 1.0 # Lemmings NPJG00058 = 5.0 From b632b48724830a838a8b0ea823abfd0c451b9dca Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 26 Oct 2022 21:42:58 +0200 Subject: [PATCH 245/374] OpenXR - Lego Star Wars III stereo support added --- assets/compatvr.ini | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 30fa562230..7bfc3e5c94 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -877,6 +877,10 @@ ULUS10487 = 47.0 ULES00479 = 1.0 ULUS10155 = 1.0 +# LEGO Star Wars III: The Clone Wars +ULES01446 = 3.0 +ULUS10531 = 3.0 + # Lemmings NPJG00058 = 5.0 UCAS40076 = 5.0 From d011c02fee27c8cc61b1e836cf2bb300fee08861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E7=9F=A5=E8=83=BD?= <42119227+Kaitul@users.noreply.github.com> Date: Thu, 27 Oct 2022 15:26:11 +0800 Subject: [PATCH 246/374] Update zh_TW.ini --- assets/lang/zh_TW.ini | 1872 ++++++++++++++++++++--------------------- 1 file changed, 929 insertions(+), 943 deletions(-) diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 6f57d92d16..4a7b474d9c 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -1,1207 +1,1195 @@ [Audio] -Alternate speed volume = 自定義速度下的音量 -Audio backend = 音訊引擎(需要重新啟動) +Alternate speed volume = 替代速度音量 +Audio backend = 音訊後端 (需要重新啟動) Audio Error = 音訊錯誤 -AudioBufferingForBluetooth = 藍牙友好緩衝區(較慢) +AudioBufferingForBluetooth = 藍牙友好緩衝區 (更慢) Auto = 自動 -Device = 設備 -Disabled = Disabled -DSound (compatible) = DirectSound(兼容) +Device = 裝置 +Disabled = 已停用 +DSound (compatible) = DSound (相容) Enable Sound = 啟用音效 -Global volume = 全局音量 -Microphone = Microphone +Global volume = 全域音量 +Microphone = 麥克風 Microphone Device = 麥克風裝置 Mute = 靜音 -Reverb volume = 混響音量 -Use new audio devices automatically = 自動開啟新的音頻設備 -Use global volume = 使用全局量 -WASAPI (fast) = WASAPI(快) +Reverb volume = 混響裝置音量 +Use new audio devices automatically = 自動使用新音訊裝置 +Use global volume = 使用全域音量 +WASAPI (fast) = WASAPI (快) [Controls] -Analog Binding = 搖桿綁定 -Analog Settings = 搖桿配置 -Analog Style = 搖桿樣式 -Auto-rotation speed = 模擬自動轉速 -Analog Limiter = 搖桿限制器 +Analog Binding = 類比繫結 +Analog Limiter = 類比限制器 +Analog Settings = 類比設定 Analog Stick = 類比搖桿 -AnalogLimiter Tip = 按下模擬限制器按鈕時 +Analog Style = 類比樣式 +AnalogLimiter Tip = 類比限制器按鈕被按下時 Auto = 自動 -Auto-centering analog stick = 自動定心搖桿 +Auto-centering analog stick = 自動置中類比搖桿 Auto-hide buttons after seconds = 數秒後自動隱藏按鈕 -Auto-switch = 自動轉換 -Base tilt position = 標準體感位置 -Binds = 綁定 -Button Binding = 按鈕綁定 -Button Opacity = 按鈕透明度 +Auto-rotation speed = 自動旋轉速度 +Auto-switch = 自動切換 +Base tilt position = 基準傾斜位置 +Binds = 繫結 +Button Binding = 按鈕繫結 +Button Opacity = 按鈕不透明度 Button style = 按鈕樣式 -Calibrate Analog Stick = 校準搖桿 -Calibrate D-Pad = 校正方向鍵 -Calibrated = 校正後 +Calibrate Analog Stick = 校正類比搖桿 +Calibrate D-Pad = 校正 +Calibrated = 已校正 Calibration = 校正 -Circular stick input = 環形搖桿錄入 +Circular stick input = 圓形搖桿輸入 Classic = 傳統 -Confine Mouse = 在窗口/顯示區域內捕獲鼠標 -Control Mapping = 按鍵對應 -Custom Key Setting = 自訂鍵位配置 +Confine Mouse = 在視窗/顯示區域內截獲滑鼠 +Control Mapping = 控制對應 +Custom Key Setting = 自訂按鍵設定 Customize = 自訂 -Customize Touch Controls = 自訂佈局 -Customize tilt = 自訂傾斜 +Customize Touch Controls = 編輯觸控控制版面配置… +Customize tilt = 自訂傾斜… D-PAD = 方向鍵 Deadzone radius = 死區半徑 -Disable D-Pad diagonals (4-way touch) = 停用方向鍵對角線(四方向觸控) -Disable diagonal input = 停用對角線錄入 -Double tap = 雙擊 -Enable gesture control = 開啓體感控制 -Enable standard shortcut keys = 開啓標準熱鍵 -Gesture = 體感 -Gesture mapping = 體感映射 -Glowing borders = 細邊框 -HapticFeedback = 按鍵反饋(震動) -Hide touch analog stick background circle = 隱藏觸屏搖桿背景圈 -Icon = 圖標 -Ignore gamepads when not focused = 非作用時忽略遊戲手把 -Ignore Windows Key = 忽略Windows鍵 -Invert Axes = 軸反轉 -Invert Tilt along X axis = 沿X軸傾斜反轉 -Invert Tilt along Y axis = 沿Y軸傾斜反轉 -Keep this button pressed when right analog is pressed = 點擊右模擬鍵時保持點擊此按鈕 +Disable D-Pad diagonals (4-way touch) = 停用方向鍵對角線 (4 向觸控) +Disable diagonal input = 停用對角線輸入 +Double tap = 點兩下 +Enable gesture control = 啟用手勢控制 +Enable standard shortcut keys = 啟用標準快速鍵 +Gesture = 手勢 +Gesture mapping = 手勢對應 +Glowing borders = 發光框線 +HapticFeedback = 觸覺回饋 (震動) +Hide touch analog stick background circle = 隱藏觸控式類比搖桿背景圓環 +Icon = 圖示 +Ignore gamepads when not focused = 未聚焦時忽略手把 +Ignore Windows Key = 停用 Windows 按鍵 +Invert Axes = 反轉軸 +Invert Tilt along X axis = 沿 X 軸反轉傾斜 +Invert Tilt along Y axis = 沿 Y 軸反轉傾斜 +Keep this button pressed when right analog is pressed = 右類比搖桿被按下時保持此按鈕按下 Keyboard = 鍵盤控制設定 -L/R Trigger Buttons = L/R觸發按鈕 -#L/R扳机按钮 +L/R Trigger Buttons = L/R 觸發按鈕 Landscape = 橫向 -Landscape Auto = 自動橫向 +Landscape Auto = 橫向自動 Landscape Reversed = 橫向反轉 -Low end radius = 尾端半徑 -Mouse = 鼠標配置 -Mouse sensitivity = 鼠標靈敏度 -Mouse smoothing = 鼠標平滑 -MouseControl Tip = 您現在可以在按鍵映射界面上按“ M”圖標來映射鼠標按鍵。 -None (Disabled) = 無(停用) +Low end radius = 低端半徑 +Mouse = 滑鼠設定 +Mouse sensitivity = 滑鼠敏感度 +Mouse smoothing = 滑鼠平滑 +MouseControl Tip = 您現在可以透過按下「M」圖示在控制對應畫面中對應滑鼠。 +None (Disabled) = 無 (已停用) Off = 關閉 -OnScreen = 顯示虛擬控制器 -Portrait = 縱向 -Portrait Reversed = 縱向反轉 -PSP Action Buttons = PSP功能鍵 -Raw input = 原始錄入 -Repeat mode = Repeat mode -#重复模式 -Reset to defaults = 重置爲默認 -Screen aligned to ground = 屏幕水平地面 -Screen at right angle to ground = 屏幕垂直地面 +OnScreen = 螢幕觸控控制 +Portrait = 直向 +Portrait Reversed = 直向反轉 +PSP Action Buttons = PSP 動作按鈕 +Raw input = 原始輸入 +Reset to defaults = 重設為預設值 +Screen aligned to ground = 螢幕與地面水平對齊 +Screen at right angle to ground = 螢幕與地面垂直對齊 Screen Rotation = 螢幕旋轉 seconds, 0 : off = 秒,0 = 關閉 -Sensitivity (scale) = 靈敏度(倍數) -Sensitivity = 靈敏度 -Shape = 形狀 -Show Touch Pause Menu Button = 顯示觸控暫停選單鍵 +Sensitivity = 敏感度 +Sensitivity (scale) = 敏感度 (比例) +Shape = 圖形 +Show Touch Pause Menu Button = 顯示暫停選單按鈕 Swipe = 滑動 -Swipe sensitivity = 滑動靈敏性 -Swipe smoothing = 滑動光滑度 -Thin borders = 薄邊框 -Tilt Base Radius = 傾斜基本半徑 +Swipe sensitivity = 滑動敏感度 +Swipe smoothing = 滑動平滑 +Thin borders = 特細框線 +Tilt Base Radius = 傾斜基準半徑 Tilt Input Type = 傾斜輸入類型 -Tilt Sensitivity along X axis = 沿X軸傾斜靈敏度 -Tilt Sensitivity along Y axis = 沿Y軸傾斜靈敏度 -To Calibrate = 請將裝置放在平面上,然後按「校正」。 +Tilt Sensitivity along X axis = 沿 X 軸傾斜敏感度 +Tilt Sensitivity along Y axis = 沿 Y 軸傾斜敏感度 +To Calibrate = 若要校正,把裝置放置水平表面,然後按下「校正」。 Toggle mode = 切換模式 -Touch Control Visibility = 觸控可視性 -Use custom right analog = 使用自定義右模擬 -Use Mouse Control = 使用鼠標控制 -Visibility = 可視設定 -Visible = 可視 +Repeat mode = 重複模式 +Touch Control Visibility = 觸控控制可見性 +Use custom right analog = 使用自訂右類比搖桿 +Use Mouse Control = 使用滑鼠控制 +Visibility = 可見性 +Visible = 可見 X = X Y = Y [CwCheats] -Cheats = 金手指 -Edit Cheat File = 編輯金手指文件 -Enable/Disable All = 全部啟用/停用 -Import Cheats = 由cheat.db匯入 +Cheats = 密技 +Edit Cheat File = 編輯密技檔案 +Enable/Disable All = 啟用/停用所有密技 +Import Cheats = 從 cheat.db 匯入 Options = 選項 -Refresh Rate = 刷新率 +Refresh Rate = 重新整理速率 [DesktopUI] # If your language does not show well with the default font, you can use Font to specify a different one. # Just add it to your language's ini file and uncomment it (remove the # by Font). -Auto Max Quality = 自動最高質量 (&Q) Font = Microsoft JhengHei -About PPSSPP... = 關於PPSSPP (&A)... +About PPSSPP... = 關於 PPSSPP (&A)… Auto = 自動 (&A) -Backend = 繪圖引擎(需要重新啟動) (&b) +Auto Max Quality = 自動最高品質 (&Q) +Backend = 轉譯後端 (需要重新啟動) (&b) Bicubic = 雙立方 (&B) -Break = 停止 -Break on Load = 載入后停止 -Buffered Rendering = 緩衝渲染 (&B) +Break = 中斷 +Break on Load = 載入時中斷 +Buffered Rendering = 緩衝轉譯 (&B) Buy Gold = 購買黃金版 (&G) -Control Mapping... = 按鍵對應 (&O)... -Debugging = 除錯 (&D) +Control Mapping... = 控制對應 (&O)… +Debugging = 偵錯 (&D) Deposterize = 色調混合 (&D) Direct3D9 = Direct3D 9 (&9) Direct3D11 = Direct3D 11 (&11) -Disassembly = 反組譯 (&D) +Disassembly = 反組譯碼 (&D)… Discord = Discord -Display Layout Editor = 自訂版面 -Display Rotation = 旋轉畫面 -Dump Next Frame to Log = 轉儲下一幀到除錯日誌 -Emulation = 模擬 (&E) -Enable Cheats = 啓用金手指 (&C) -Enable Sound = 開啟聲音 (&O) +Display Layout Editor = 顯示版面配置編輯器… +Display Rotation = 顯示旋轉 +Dump Next Frame to Log = 傾印下一影格至記錄 (&U) +Emulation = 仿真 (&E) +Enable Cheats = 啟用密技 (&C) +Enable Sound = 啟用音效 (&O) Exit = 離開 (&X) -Extract File... = 提取檔案 (&F)... +Extract File... = 擷取檔案 (&X)… File = 檔案 (&F) -Frame Skipping = 跳幀 (&F) -Frame Skipping Type = 跳幀類型 +Frame Skipping = 影格跳過 (&F) +Frame Skipping Type = 影格跳過類型 Fullscreen = 全螢幕 (&L) Game Settings = 遊戲設定 (&G) -GE Debugger... = GE 除錯器 (&R) +GE Debugger... = GE 偵錯工具 (&R)… GitHub = Git&Hub -Hardware Transform = 硬體幾何轉換 (&H) -Help = 幫助 (&H) +Hardware Transform = 硬體轉換 (&H) +Help = 說明 (&H) Hybrid = 混合 (&H) -Hybrid + Bicubic = 混合+雙立方 (&Y) +Hybrid + Bicubic = 混合 + 雙立方 (&Y) Ignore Illegal Reads/Writes = 忽略非法存取 (&I) -Ignore Windows Key = 忽略Windows鍵 -Keep PPSSPP On Top = 保持PPSSPP視窗在最上層 (&K) -Landscape = 横向 +Ignore Windows Key = 忽略 Windows 按鍵 +Keep PPSSPP On Top = 保持 PPSSPP 視窗在最上層 (&K) +Landscape = 橫向 Landscape reversed = 橫向反轉 -Language... = 語言設定 (&a) +Language... = 語言 (&N)… Linear = 線性 (&L) -Load = 載入遊戲 (&L) -Load .sym File... = 載入.sym檔案 (&A)... -Load Map File... = 載入Map檔案(&M)... -Load State = 載入即時存檔 (&O) -Load State File... = 載入即時存檔檔案 (&L)... -Log Console = 控制台日誌 (&L) -Memory View... = 查看記憶體 (&M)... -More Settings... = 更多設定 (&M) -Nearest = 臨近取樣 (&N) -Non-Buffered Rendering = 跳過緩衝效果 (不緩衝,速度更快) (&S) +Load = 載入 (&L)… +Load .sym File... = 載入 .sym 檔案 (&A)… +Load Map File... = 載入對應檔案 (&M)… +Load State = 載入存檔 (&O) +Load State File... = 載入存檔檔案 (&L)… +Log Console = 記錄主控台 (&L) +Memory View... = 記憶體檢視 (&V)… +More Settings... = 更多設定 (&M)… +Nearest = 鄰近取樣 (&N) +Non-Buffered Rendering = 跳過緩衝區效果 (非緩衝區,更快) (&S) Off = 關閉 (&O) -Open Chat = 打開聊天 -Open Directory... = 打開目錄 (&D)... -Open from MS:/PSP/GAME... = 打開 MS:/PSP/GAME (&P)... -#从MS:/PSP/GAME处打开 (&p)... -Open Memory Stick = 打開記憶卡 (&M) -Open New Instance = 打開新實例 +Open Chat = 開啟聊天 +Open Directory... = 開啟目錄 (&D)… +Open from MS:/PSP/GAME... = 開啟自 MS:/PSP/GAME (&P)… +Open Memory Stick = 開啟記憶棒 (&M) +Open New Instance = 開啟新執行個體 OpenGL = OpenGL (&O) Pause = 暫停 (&P) -Pause When Not Focused = 非使用中時暫停 (&P) -Portrait = 縱向 -Portrait reversed = 縱向反轉 +Pause When Not Focused = 未聚焦時暫停 (&P) +Portrait = 直向 +Portrait reversed = 直向反轉 Postprocessing Shader = 後處理著色器 (&G) -PPSSPP Forums = PPSSPP 官方論壇 (&F) +PPSSPP Forums = PPSSPP 論壇 (&F) Record = 錄製 (&R) -Record Audio = 錄音 (&A) -Record Display = 錄製畫面 (&D) -Rendering Mode = 渲染模式 (&O) -Rendering Resolution = 渲染解析度 (&R) -Reset = 重置 (&E) -Reset Symbol Table = 重置符號表 (&R) +Record Audio = 錄製音訊 (&A) +Record Display = 錄製視訊 (&D) +Rendering Mode = 轉譯模式 (&O) +Rendering Resolution = 轉譯解析度 (&R) +Reset = 重設 (&E) +Reset Symbol Table = 重設符號表 (&Y) Run = 執行 (&R) -Save .sym File... = 保存.sym檔案 (&e)... -Save Map File... = 保存Map檔案 (&S)... -Save State = 即時存檔 (&a) -Save State File... = 保存即時存檔檔案 (&S)... -Savestate Slot = 即時存檔插槽 (&t) -Screen Scaling Filter = 螢幕縮放濾鏡 (&e) -Show Debug Statistics = 顯示除錯數據 (&g) -Show FPS Counter = 顯示FPS計數器 (&F) -Skip Number of Frames = 跳過幀數 -Skip Percent of FPS = 跳過FPS的百分比 +Save .sym File... = 儲存 .sym 檔案 (&E)… +Save Map File... = 儲存對應檔案 (&S)… +Save State = 儲存存檔 (&A) +Save State File... = 儲存存檔檔案 (&S)… +Savestate Slot = 存檔插槽 (&T) +Screen Scaling Filter = 螢幕縮放濾鏡 (&E) +Show Debug Statistics = 顯示偵錯統計資料 (&G) +Show FPS Counter = 顯示 FPS 計數器 (&F) +Skip Number of Frames = 跳過影格數 +Skip Percent of FPS = 跳過 FPS 百分比 Stop = 停止 (&S) -Switch UMD = 切換UMD光碟 -Take Screenshot = 截圖 (&T) -Texture Filtering = 紋理過濾 (&x) +Switch UMD = 切換 UMD +Take Screenshot = 擷取螢幕畫面 (&T) +Texture Filtering = 紋理過濾 (&X) Texture Scaling = 紋理縮放 (&T) -Use Lossless Video Codec (FFV1) = 使用無損視訊轉碼器(FFV1) (&U) -Use output buffer for video = 將輸出緩衝區用於視頻 +Use Lossless Video Codec (FFV1) = 使用不失真視訊轉碼器 (FFV1) (&U) +Use output buffer for video = 為視訊使用輸出緩衝區 Vertex Cache = 頂點快取 (&V) -VSync = 垂直同步 (&y) +VSync = 垂直同步 (&Y) Vulkan = Vulkan Window Size = 視窗大小 (&W) -www.ppsspp.org = 拜訪www.&ppsspp.org +www.ppsspp.org = 造訪 www.&ppsspp.org xBRZ = &xBRZ [Developer] -Allocator Viewer = 分配器查看器(Vulkan) -Allow remote debugger = 允許遠程調試器 -Backspace = 向前刪除 +Allocator Viewer = 配置器檢視器 (Vulkan) +Allow remote debugger = 允許遠端偵錯工具 +Backspace = 退格鍵 Block address = 區塊位址 -By Address = 由位址 -Copy savestates to memstick root = 副本保存狀態,以記憶棒根目錄 -Create/Open textures.ini file for current game = 創建/打開當前游戲的textures.ini文件 +By Address = 依位址 +Copy savestates to memstick root = 複製存檔至記憶棒根目錄 +Create/Open textures.ini file for current game = 為目前遊戲建立/開啟 textures.ini 檔案 Current = 目前 Dev Tools = 開發工具 -DevMenu = 開發菜單 -Disabled JIT functionality = 禁用JIT功能 -Draw Frametimes Graph = 繪製幀時間圖 -Dump Decrypted Eboot = 載入遊戲時,轉儲已解密的EBOOT.BIN -Dump Frame GPU Commands = 轉儲幀GPU指令 -Enable driver bug workarounds = 啟用驅動程序錯誤解決方法 -Enable Logging = 啟用日誌 +DevMenu = 開發選單 +Disabled JIT functionality = 停用 JIT 功能 +Draw Frametimes Graph = 繪製影格時間圖形 +Dump Decrypted Eboot = 遊戲啟動時傾印已解密的 EBOOT.BIN +Dump Frame GPU Commands = 傾印影格 GPU 命令 +Enable driver bug workarounds = 啟用驅動程式錯誤因應措施 +Enable Logging = 啟用偵錯記錄 Enter address = 輸入位址 FPU = FPU -Framedump tests = 幀轉儲測試 -Frame Profiler = 幀分析器 -GPU Driver Test = GPU驅動程序測試 -GPU Log Profiler = GPU日志分析器 -GPU Profile = GPU配置文件 -Jit Compare = Jit比較 -JIT debug tools = JIT調試工具 -Language = 語言設定 -Load language ini = 載入語言設定 -Log Dropped Frame Statistics = 日志丟棄幀統計信息 -Log Level = 日誌級別 -Log View = 查看日誌 -Logging Channels = 記錄頻道 +Framedump tests = 影格傾印測試 +Frame Profiler = 影格分析工具 +GPU Driver Test = GPU 驅動程式測試 +GPU Profile = GPU 設定檔 +GPU Log Profiler = GPU 記錄分析工具 +Jit Compare = JIT 比較 +JIT debug tools = JIT 偵錯工具 +Language = 語言 +Load language ini = 載入語言 ini 檔案 +Log Dropped Frame Statistics = 記錄捨棄影格統計資料 +Log Level = 記錄層級 +Log View = 記錄檢視 +Logging Channels = 記錄通道 Next = 下一個 -No block = 沒有記憶體區塊 +No block = 沒有區塊 Prev = 上一個 Random = 隨機 -Replace textures = 紋理更換 -Reset = 重置 -Reset limited logging = 重置受限日誌 -RestoreDefaultSettings = 你確定要所有設定還原到預設值 (除了按鍵配置)?\n此動作無法恢復。\n需要重新啟動PPSSPP,變更才會生效。 -RestoreGameDefaultSettings = 你確定要恢復特定遊戲的配置,\n回到PPSSPP的預設值? +Replace textures = 取代紋理 +Reset = 重設 +Reset limited logging = 重設受限記錄 +RestoreDefaultSettings = 您確定要將所有設定還原為預設值嗎?\n控制對應設定將不會變更。\n\n您無法復原此動作。\n請重新啟動 PPSSPP 以使變更生效。 +RestoreGameDefaultSettings = 您確定要將遊戲特定設定\n還原為 PPSSPP 預設值嗎? Resume = 恢復 -Run CPU Tests = 執行CPU測試 -Save language ini = 儲存語言設定 -Save new textures = 保存新纹理 -Shader Viewer = 著色器查看器 -Show Developer Menu = 顯示開發者選單 -Show on-screen messages = 顯示屏幕消息 -Stats = 統計 -System Information = 系統資料 -Texture ini file created = 創建紋理INI文件 -Texture Replacement = 纹理更换 -Toggle Audio Debug = 切換音訊除錯 -Toggle Freeze = 切換凍結 -Touchscreen Test = 觸摸屏測試 +Run CPU Tests = 執行 CPU 測試 +Save language ini = 儲存語言 ini 檔案 +Save new textures = 儲存新紋理 +Shader Viewer = 著色器檢視器 +Show Developer Menu = 顯示開發人員選單 +Show on-screen messages = 顯示螢幕訊息 +Stats = 統計資料 +System Information = 系統資訊 +Texture ini file created = 紋理 ini 檔案已建立 +Texture Replacement = 紋理取代 +Toggle Audio Debug = 切換音訊偵錯開關 +Toggle Freeze = 切換凍結開關 +Touchscreen Test = 觸控式螢幕測試 VFPU = VFPU [Dialog] -* PSP res = * PSP解析度 -Active = 激活 +* PSP res = * PSP 解析度 +Active = Active Back = 返回 Cancel = 取消 -Center = 中間 -ChangingGPUBackends = 改變渲染引擎之後需要重新啟動PPSSPP。現在重新啟動嗎? -ChangingInflightFrames = 更改圖形命令緩衝要求PPSSPP重新啟動。 現在重啟? -Channel: = 頻道: -Choose PPSSPP save folder = 選擇PPSSPP的存檔資料夾 -Confirm Overwrite = 你要覆蓋這份檔案嗎? -Confirm Save = 你要儲存這份檔案嗎? -ConfirmLoad = 你要載入這份檔案嗎? -ConnectingAP = 連接到接入點\n請稍候... -ConnectingPleaseWait = 連接中.\n請稍候... -ConnectionName = 連接名稱 -Corrupted Data = 數據損壞 +Center = 中心 +ChangingGPUBackends = 變更 GPU 後端需要重新啟動 PPSSPP,要立即重新啟動嗎? +ChangingInflightFrames = 變更圖形命令緩衝需要重新啟動 PPSSPP,要立即重新啟動嗎? +Channel: = 頻道: +Choose PPSSPP save folder = 選擇 PPSSPP 存檔資料夾 +Confirm Overwrite = 要覆寫這個存檔的資料嗎? +Confirm Save = 要儲存這個存檔的資料嗎? +ConfirmLoad = 要載入這個存檔的資料嗎? +ConnectingAP = 正在連線至存取點\n請稍候… +ConnectingPleaseWait = 正在連線\n請稍候… +ConnectionName = 連線名稱 +Corrupted Data = 已損毀的資料 Delete = 刪除 Delete all = 全部刪除 -Delete completed = 檔案已刪除。 -DeleteConfirm = 這份檔案將被刪除。\n你確定要繼續嗎? -DeleteConfirmAll = 你確定要刪除此遊戲的所有檔案? -DeleteConfirmGame = 你確定要刪除此遊戲?\n此動作無法還原。 -DeleteConfirmGameConfig = 你確定要刪除這個遊戲的配置? -DeleteFailed = 無法刪除資料。 -Deleting = 刪除中\n請稍候... -Disable All = 禁用所有 -Dumps = 轉儲 +Delete completed = 刪除完成 +DeleteConfirm = 這個存檔的資料將被刪除\n仍要繼續嗎? +DeleteConfirmAll = 您確定要刪除\n這個遊戲的全部存檔資料嗎? +DeleteConfirmGame = 您確定要從您的裝置上刪除這個遊戲嗎?\n您無法復原此動作。 +DeleteConfirmGameConfig = 您確定要刪除這個遊戲的全部設定嗎? +DeleteFailed = 無法刪除資料 +Deleting = 正在刪除\n請稍候… +Disable All = 全部停用 +Dumps = 傾印 Edit = 編輯 Enable All = 全部啟用 -Enter = 決定 -Filter = 篩選 +Enter = 輸入 +Filter = 篩選器 Finish = 完成 -GE Frame Dumps = GE幀轉儲 -Grid = 格 -Inactive = 不活躍 -InternalError = 發生了一個內部錯誤. +GE Frame Dumps = GE 影格傾印 +Grid = 格狀 +Inactive = 未啟用 +InternalError = 發生內部錯誤 Load = 載入 -Load completed = 檔案已載入。 -Loading = 載入中\n請稍候... -LoadingFailed = 無法載入資料。 -Move = 位置設定 +Load completed = 載入完成 +Loading = 正在載入\n請稍候… +LoadingFailed = 無法載入資料 +Move = 移動 Network Connection = 網路連線 -NEW DATA = 建立新檔案 +NEW DATA = 新存檔 No = 否 -ObtainingIP = 獲取IP地址.\n請稍候... +ObtainingIP = 正在取得 IP 位址\n請稍候… OK = 確定 -Old savedata detected = 偵測到舊版的存檔資料 +Old savedata detected = 偵測到舊版存檔資料 Options = 選項 Reset = 重設 -Resize = 大小設定 -Retry = 重新嘗試 +Resize = 調整大小 +Retry = 重試 Save = 儲存 -Save completed = 檔案已儲存。 -Saving = 儲存中\n請稍候... -SavingFailed = 無法儲存資料。 +Save completed = 儲存完成 +Saving = 正在儲存\n請稍候… +SavingFailed = 無法儲存資料 Search = 搜尋 -Select = 選擇 -Shift = 翻頁 +Select = 選取 +Shift = 移位 Skip = 跳過 -Snap = 對齊 -Space = 空格鍵 +Snap = 貼齊 +Space = 空白 SSID = SSID Submit = 提交 -Supported = 支持 -There is no data = 沒有檔案。 +Supported = 支援 +There is no data = 沒有資料 Toggle All = 切換全部 -Toggle List = 切換列表 -Unsupported = 不支持 -When you save, it will load on a PSP, but not an older PPSSPP = 當您保存,它會加載一個真正的PSP,但不是舊版本PPSSPP -When you save, it will not work on outdated PSP Firmware anymore = 保存後,它將不再適用於過時的PSP固件 +Toggle List = 切換清單 +Unsupported = 不支援 +When you save, it will load on a PSP, but not an older PPSSPP = 在您儲存後,它將會只能在 PSP 上載入,而非舊版 PPSSPP +When you save, it will not work on outdated PSP Firmware anymore = 在您儲存後,它將無法在已過期的 PSP 韌體上運作 Yes = 是 -Zoom = 放大 +Zoom = 縮放 [Error] -7z file detected (Require 7-Zip) = 檔案是7z壓縮檔。\n請先解壓縮 (使用 7-zip 或 WinRAR)。 -A PSP game couldn't be found on the disc. = 光盤上找不到PSP遊戲. -Cannot boot ELF located outside mountRoot. = 無法引導位於裝載根外部的ELF. -Could not save screenshot file = 無法保存截圖檔案 -D3D9or11 = 使用 Direct3D 9? (或者 "否" 以使用Direct3D 11) -D3D11CompilerMissing = D3DCompiler_47.dll未找到。 請安裝。 或者按“是”,再次嘗試使用Direct3D 9。 -D3D11InitializationError = Direct3D 11初始化錯誤 -D3D11Missing = 您的操作系統版本不包括 D3D11。 請運行Windows Update.\n\n按是,嘗試使用 Direct3D 9. -D3D11NotSupported = 您的GPU似乎不支持Direct3D 11.\n\n您是否想改用Direct3D 9? -Disk full while writing data = 寫入數據時硬碟空間不足 -ELF file truncated - can't load = ELF文件被截斷-無法加載 -Error loading file = 檔案載入錯誤 -Error reading file = 讀取檔案錯誤 -Failed initializing CPU/Memory = 初始化CPU或內存失敗 -Failed to load executable: = 無法加載可執行文件: -File corrupt = 文件損壞 -Game disc read error - ISO corrupt = 遊戲光盤讀取錯誤:ISO損壞. -GenericAllStartupError = PPSSPP無法使用任何圖形後端啟動。 嘗試升級圖形和其他驅動程序. -GenericBackendSwitchCrash = 啟動時PPSSPP 崩潰了.\n\n這通常意味著圖形驅動程序問題。 嘗試升級圖形驅動程序.\n\n圖形後端已切換: -GenericDirect3D9Error = 圖形初始化失敗,請試著更新你的圖形驅動程式與DirectX 9 runtime。\n\n你要切換到 OpenGL 試試看嗎?\n\n錯誤訊息: +7z file detected (Require 7-Zip) = 檔案已壓縮 (7z)\n請先解壓縮 (嘗試 7-Zip 或 WinRAR) +A PSP game couldn't be found on the disc. = 此光碟上找不到 PSP 遊戲 +Cannot boot ELF located outside mountRoot. = 無法啟動位於 mountRoot 外的 ELF +Could not save screenshot file = 無法儲存螢幕截圖檔案 +D3D9or11 = 使用 Direct3D 9?(或「否」以使用 Direct3D 11) +D3D11CompilerMissing = 找不到 D3DCompiler_47.dll,請安裝或按下「是」以改為使用 Direct3D 9 +D3D11InitializationError = Direct3D 11 初始化錯誤 +D3D11Missing = 您的作業系統不包括 D3D11,請執行 Windows 更新\n\n按下「是」以改為使用 Direct3D 9 +D3D11NotSupported = 您的 GPU 似乎不支援 Direct3D 11\n\n要改為使用 Direct3D 9 並重試嗎? +Disk full while writing data = 寫入資料時磁碟已滿 +ELF file truncated - can't load = ELF 檔案已截斷 - 無法載入 +Error loading file = 無法載入遊戲 +Error reading file = 無法讀取檔案 +Failed initializing CPU/Memory = 無法初始化 CPU 或記憶體 +Failed to load executable: = 無法載入可執行檔: +File corrupt = 檔案損毀 +Game disc read error - ISO corrupt = 遊戲光碟讀取錯誤:ISO 損毀 +GenericAllStartupError = PPSSPP 無法以任何圖形後端啟動,請嘗試更新您的圖形和其他驅動程式 +GenericBackendSwitchCrash = PPSSPP 在啟動時當機\n\n這通常表示出現了圖形驅動程式問題,請嘗試升級圖形驅動程式\n\n圖形後端已切換: +GenericDirect3D9Error = 無法初始化圖形,請嘗試更新圖形驅動程式和 DirectX 9 執行階段\n\n要嘗試切換至 OpenGL 嗎?\n\n錯誤訊息: GenericGraphicsError = 圖形錯誤 -GenericOpenGLError = 圖形初始化失敗,請試著更新你的圖形驅動程式。\n\n你要切換到DirectX 9 試試看嗎?\n\n錯誤訊息: -GenericVulkanError = 初始化圖形失敗。 嘗試升級圖形驅動程序.\n\n您想嘗試切換到OpenGL嗎?\n\n錯誤信息: -InsufficientOpenGLDriver = 偵測到OpenGL 驅動程式的支援不足\n\n你想嘗試DirectX嗎?\n\n目前兼容DirectX 的遊戲較少,但對你的GPU而言可能是唯一的選擇。 -Just a directory. = 只是一個目錄。 -Missing key = 缺失密鑰 -MsgErrorCode = 錯誤代碼: -MsgErrorSavedataDataBroken = 保存數據已損壞. -MsgErrorSavedataMSFull = 記憶棒已滿. 檢查您的存儲空間. -MsgErrorSavedataNoData = 警告:未找到保存數據. -MsgErrorSavedataNoMS = 未插入記憶棒. -No EBOOT.PBP, misidentified game = 沒有EBOOT.PBP,錯誤識別遊戲。 -Not a valid disc image. = 無效的光盤映像. +GenericOpenGLError = 無法初始化圖形,請嘗試更新圖形驅動程式\n\n要嘗試切換至 DirectX 9 嗎?\n\n錯誤訊息: +GenericVulkanError = 無法初始化圖形,請嘗試更新圖形驅動程式\n\n要嘗試切換至 OpenGL 嗎?\n\n錯誤訊息: +InsufficientOpenGLDriver = 偵測到 OpenGL 驅動程式支援不足!\n\n您的 GPU 回報其不支援 OpenGL 2.0,要改為使用 DirectX 嗎?\n\nDirectX 目前相容的遊戲較少,但這可能是您的 GPU 的唯一選擇。\n\n造訪 https://forums.ppsspp.org 論壇以取得更多資訊。\n\n +Just a directory. = 只是一個目錄 +Missing key = 遺失金鑰 +MsgErrorCode = 錯誤碼: +MsgErrorSavedataDataBroken = 存檔資料已損毀 +MsgErrorSavedataMSFull = 記憶棒已滿,請檢查您的儲存空間 +MsgErrorSavedataNoData = 警告:找不到存檔資料 +MsgErrorSavedataNoMS = 記憶棒未插入 +No EBOOT.PBP, misidentified game = 沒有 EBOOT.PBP,無法辨識的遊戲 +Not a valid disc image. = 不是有效的光碟映像 OpenGLDriverError = OpenGL 驅動程式錯誤 -PPSSPP doesn't support UMD Music. = PPSSPP不支持UMD音樂 -PPSSPP doesn't support UMD Video. = PPSSPP不支持UMD視頻 -PPSSPP plays PSP games, not PlayStation 1 or 2 games. = PPSSPP玩 PSP遊戲,而不是PlayStation1或2遊戲. -#PPSSPP只能运行PSP游戏, 不能运行PS1或2的游戏 -PPSSPPDoesNotSupportInternet = PPSSPP目前不支援透過網路進行DLC、PSN 或更新遊戲 -PS1 EBOOTs are not supported by PPSSPP. = PPSSPP不支援PS1 EBOOTS -PSX game image detected. = 抱歉,不支援PSX遊戲 -RAR file detected (Require UnRAR) = 檔案是RAR壓縮檔。\ n請先解壓縮(需使用UnRAR)。 -RAR file detected (Require WINRAR) = 檔案是RAR壓縮檔。\ n請先解壓縮(需使用WinRAR)。 -Running slow: try frameskip, sound is choppy when slow = 運行速度慢:嘗試跳幀,聲音不連貫時慢 -Running slow: Try turning off Software Rendering = 運行緩慢:嘗試關閉“軟件渲染” -Save encryption failed. This save won't work on real PSP = 存檔加密失敗。真正的PSP將無法讀取這份存檔 -textures.ini filenames may not be cross-platform = "textures.ini"文件名可能不是跨平台的。 -This is a saved state, not a game. = 這是保存狀態,而不是遊戲。 -This is save data, not a game. = 這是保存數據,而不是遊戲。 -Unable to create cheat file, disk may be full = 無法建立金手指文件,硬碟可能已滿 -Unable to initialize rendering engine. = 無法初始化渲染引擎。 -Unable to write savedata, disk may be full = 無法記錄,硬碟可能已滿 -Warning: Video memory FULL, reducing upscaling and switching to slow caching mode = 警告:視訊記憶體已滿,降低像素提升並切換到慢速快取模式。 -Warning: Video memory FULL, switching to slow caching mode = 警告:視訊記憶體已滿,切換到慢速快取模式。 -ZIP file detected (Require UnRAR) = 檔案是ZIP壓縮檔。\ n請先解壓縮 (需使用UnRAR)。 -ZIP file detected (Require WINRAR) = 檔案是ZIP壓縮檔。\ n請先解壓縮 (需使用WinRAR)。 +PPSSPP doesn't support UMD Music. = PPSSPP 不支援 UMD 音樂 +PPSSPP doesn't support UMD Video. = PPSSPP 不支援 UMD 影片 +PPSSPP plays PSP games, not PlayStation 1 or 2 games. = PPSSPP 僅支援 PSP 遊戲,無法執行 PlayStation 1 或 PlayStation 2 遊戲 +PPSSPPDoesNotSupportInternet = PPSSPP 目前不支援連線至網際網路使用 DLC、PSN 或更新遊戲 +PS1 EBOOTs are not supported by PPSSPP. = PPSSPP 不支援 PS1 EBOOT +PSX game image detected. = 檔案為 MODE2 映像,PPSSPP 不支援 PS1 遊戲 +RAR file detected (Require UnRAR) = 檔案已壓縮 (RAR)\n請先解壓縮 (嘗試 UnRAR) +RAR file detected (Require WINRAR) = 檔案已壓縮 (RAR)\n請先解壓縮 (嘗試 WinRAR) +Running slow: try frameskip, sound is choppy when slow = 執行速度緩慢:嘗試影格跳過,速度緩慢時音效可能會斷斷續續 +Running slow: Try turning off Software Rendering = 執行速度緩慢:嘗試關閉「軟體轉譯」 +Save encryption failed. This save won't work on real PSP = 存檔加密失敗,這個存檔將無法在真實 PSP 中運作 +textures.ini filenames may not be cross-platform = 「textures.ini」檔案名稱可能無法跨平台 +This is a saved state, not a game. = 這是一個存檔,並非遊戲 +This is save data, not a game. = 這是一個存檔資料,並非遊戲 +Unable to create cheat file, disk may be full = 無法建立密技檔案,磁碟可能已滿 +Unable to initialize rendering engine. = 無法初始化轉譯引擎 +Unable to write savedata, disk may be full = 無法寫入存檔資料,磁碟可能已滿 +Warning: Video memory FULL, reducing upscaling and switching to slow caching mode = 警告:視訊記憶體已滿,降低放大倍率並切換至慢速快取模式 +Warning: Video memory FULL, switching to slow caching mode = 警告:視訊記憶體已滿,切換至慢速快取模式 +ZIP file detected (Require UnRAR) = 檔案已壓縮 (ZIP)\n請先解壓縮 (嘗試 UnRAR) +ZIP file detected (Require WINRAR) = 檔案已壓縮 (ZIP)\n請先解壓縮 (嘗試 WinRAR) [Game] -Asia = 亞洲 -Calculate CRC = 計算CRC -ConfirmDelete = 確定 -Create Game Config = 建立遊戲配置 +Asia = 亞州 +Calculate CRC = 計算 CRC +ConfirmDelete = 刪除 +Create Game Config = 建立遊戲組態 Create Shortcut = 建立捷徑 Delete Game = 刪除遊戲 -Delete Game Config = 刪除遊戲配置 -Delete Save Data = 刪除存檔 +Delete Game Config = 刪除遊戲組態 +Delete Save Data = 刪除存檔資料 Europe = 歐洲 Game = 遊戲 Game Settings = 遊戲設定 -Homebrew = 自製游戲 +Homebrew = 自製遊戲 Hong Kong = 香港 -InstallData = 安裝數據 +InstallData = 資料安裝 Japan = 日本 -Korea = 韓國 +Korea = 南韓 MB = MB -One moment please... = 稍等一會兒... +One moment please... = 請稍候… Play = 開始遊戲 -Remove From Recent = 刪除此記錄 -SaveData = 存檔 -Setting Background = 配置背景 -Show In Folder = 顯示資料夾 +Remove From Recent = 從「最近遊玩」中移除 +SaveData = 儲存資料 +Setting Background = 設定背景 +Show In Folder = 在資料夾中顯示 USA = 美國 -Use UI background = 使用UI背景 +Use UI background = 使用 UI 背景 [Graphics] -% of the void = % 的邊框 -% of viewport = % 的視區 -%, 0:unlimited = %,0 = 無限 -(supersampling) = (超級采樣) -(upscaling) = (倍增) -1x PSP = 1倍PSP -2x = 2倍 -2x PSP = 2倍PSP -3x = 3倍 -3x PSP = 3倍PSP -4x = 4倍 -4x PSP = 4倍PSP -5x = 5倍 -5x PSP = 5倍PSP -6x PSP = 6倍PSP -7x PSP = 7倍PSP -8x = 8倍 -8x PSP = 8倍PSP -9x PSP = 9倍PSP -10x PSP = 10倍PSP -16x = 16倍 -Aggressive = 激進 -Alternative Speed = 速度控制(%,0 = 無限) -Alternative Speed 2 = 替代速度2(in %, 0 = 無限) -Anisotropic Filtering = 非等方性過濾 +% of the void = % 的無效區 +% of viewport = % 的檢視區 +%, 0:unlimited = %,0 = 無限制 +(supersampling) = (超級取樣) +(upscaling) = (放大) +1x PSP = 1× PSP +2x = 2× +2x PSP = 2× PSP +3x = 3× +3x PSP = 3× PSP +4x = 4× +4x PSP = 4× PSP +5x = 5× +5x PSP = 5× PSP +6x PSP = 6× PSP +7x PSP = 7× PSP +8x = 8× +8x PSP = 8× PSP +9x PSP = 9× PSP +10x PSP = 10× PSP +16x = 16× +Aggressive = 積極 +Alternative Speed = 替代速度 (於 %,0 = 無限制) +Alternative Speed 2 = 替代速度 2 (於 %,0 = 無限制) +Anisotropic Filtering = 非等向性過濾 Auto = 自動 -Auto (1:1) = 自動(1:1) -Auto (same as Rendering) = 自動(同渲染) -Auto FrameSkip = 自動跳幀 -Auto Max Quality = 自動最高質量 +Auto (1:1) = 自動 (1:1) +Auto (same as Rendering) = 自動 (同於轉譯解析度) +Auto FrameSkip = 自動影格跳過 +Auto Max Quality = 自動最大品質 Auto Scaling = 自動縮放 Backend = 後端 -Balanced = 均衡 +Balanced = 平衡 Bicubic = 雙立方 -BlockTransfer Tip = 有些遊戲需要這樣才能開啟正確的圖形 -BlockTransferRequired = 警告:此遊戲需要將模擬塊傳輸模式配置為開。 -Both = 兩者 -Buffer graphics commands (faster, input lag) = 緩衝區圖形命令(更快,輸入延遲) -Buffered Rendering = 緩衝渲染 -BufferedRenderingRequired = 警告:此遊戲需要將“渲染模式”配置為“緩衝”。 +BlockTransfer Tip = 部分遊戲需要開啟此項以顯示正確的圖形 +BlockTransferRequired = 警告:這個遊戲需要開啟「模擬區塊傳輸效果」 +Both = 全部 +Buffer graphics commands (faster, input lag) = 緩衝圖形命令 (更快,有輸入延遲) +Buffered Rendering = 緩衝轉譯 +BufferedRenderingRequired = 警告:這個遊戲需要將「轉譯模式」設為「緩衝轉譯」 Camera = 相機 -Camera Device = 攝像頭設備 -Cardboard Screen Size = 螢幕大小(視區%) -Cardboard Screen X Shift = 水平% -Cardboard Screen Y Shift = 垂直% +Camera Device = 相機裝置 +Cardboard Screen Size = 螢幕大小 (於 % 的檢視區) +Cardboard Screen X Shift = X 移位 (於 % 的空白區) +Cardboard Screen Y Shift = Y 移位 (於 % 的空白區) Cardboard VR Settings = Google Cardboard VR 設定 -Cheats = 金手指 -CPU Core = CPU 核心模式 -Debugging = 除錯 -DefaultCPUClockRequired = 警告:此遊戲需要將CPU時鐘配置為默認值。 +Cheats = 密技 +CPU Core = CPU 核心 +Debugging = 偵錯 +DefaultCPUClockRequired = 警告:這個遊戲需要將 CPU 時脈設為預設值 Deposterize = 色調混合 -Deposterize Tip = 修復在紋理被放大時可能發生的小紋理內部毛刺 -Device = 設備 +Deposterize Tip = 修正放大化紋理中的視覺帶狀故障 +Device = 裝置 Direct3D 9 = Direct3D 9 Direct3D 11 = Direct3D 11 -Disabled = 已禁用 -Display layout editor = 自訂版面 -Display Resolution (HW scaler) = 顯示解析度(硬體縮放) -Dump next frame to log = 將下一幀儲存到日誌 -Enable Cardboard VR = 啟用Cardboard VR +Disabled = Disabled +Display layout editor = 顯示版面配置編輯器 +Display Resolution (HW scaler) = 顯示解析度 (硬體縮放) +Dump next frame to log = 將下一個影格傾印至記錄 +Enable Cardboard VR = 啟用 Cardboard VR FPS = FPS -Frame Rate Control = 幀速率控制 -Frame Skipping = 跳幀 -Frame Skipping Type = 跳幀類型 +Frame Rate Control = 影格速率控制 +Frame Skipping = 影格跳過 +Frame Skipping Type = 影格跳過類型 FullScreen = 全螢幕 -GPU log profiler = GPU日志分析器 -Hack Settings = 修正設定 -Hardware Tessellation = 硬體曲面細分 -Hardware Transform = 硬體幾何轉換 -hardware transform error - falling back to software = 硬體轉換錯誤,改用軟體轉換 -HardwareTessellation Tip = 使用硬體繪製曲綫,使用固定的質量 +Hack Settings = 駭客設定 (可能會造成故障) +Hardware Tessellation = 硬體鑲嵌式 +Hardware Transform = 硬體轉換 +hardware transform error - falling back to software = 硬體轉換錯誤,將回復到軟體轉換 +HardwareTessellation Tip = 使用硬體繪製曲線 High = 高 Hybrid = 混合 -Hybrid + Bicubic = 混合+雙立方 -Ignore camera notch when centering = 居中時忽略攝像頭缺口 -Internal Resolution = 內部分辨率 -Lazy texture caching = 緩慢紋理快取(提升速度) -Lazy texture caching Tip = 更快,在一些游戲裏會引起文字渲染錯誤更快, 在一些游戏里引起文字渲染錯誤 +Hybrid + Bicubic = 混合 + 雙立方 +Ignore camera notch when centering = 置中時忽略相機凹口 +Internal Resolution = 內部解析度 +Lazy texture caching = 消極式紋理快取 (加速) +Lazy texture caching Tip = 更快,但在某些遊戲中可能會造成文字問題 Linear = 線性 Low = 低 -LowCurves = 樣條函數/貝茲曲線品質 -LowCurves Tip = 此選項將顯著提高/降低渲染樣條和貝塞爾曲線的質量 -Lower resolution for effects (reduces artifacts) = 降低效果的解析度(減少圖像錯誤) +LowCurves = 曲線/貝茲曲線品質 +LowCurves Tip = 僅供少數遊戲使用,控制曲線平滑度 +Lower resolution for effects (reduces artifacts) = 降低效果解析度 (降低假影) Manual Scaling = 手動縮放 Medium = 中 Mode = 模式 -Must Restart = 你必須重新啟動 PPSSPP,此更改才會生效 -Native device resolution = 原生裝置的解析度 +Must Restart = 您必須重新啟動 PPSSPP 以使這項變更生效 +Native device resolution = 原生裝置解析度 Nearest = 鄰近取樣 -No buffer = 不緩衝 -Non-Buffered Rendering = 非緩衝渲染(跳過緩衝效果,較快速) -None = 關閉 -Number of Frames = 幀數 +No buffer = 無緩衝 +Non-Buffered Rendering = 跳過緩衝效果 (無緩衝,更快) +None = 無 +Number of Frames = 影格數 Off = 關閉 OpenGL = OpenGL -Overlay Information = 覆蓋訊息 -Partial Stretch = 局部拉伸 -Percent of FPS = FPS百分比 -Performance = 性能 +Overlay Information = 覆疊資訊 +Partial Stretch = 部分延展 +Percent of FPS = FPS 百分比 +Performance = 效能 Postprocessing effect = 後處理效果 -Postprocessing Shader = 後期處理著色器 -Recreate Activity = 重新創建活動 -Render duplicate frames to 60hz = 渲染重複幀至60Hz -RenderDuplicateFrames Tip = 在以較低幀速率運行的遊戲中可以使幀速率更平滑 -Rendering Mode = 渲染模式 -Rendering Resolution = 渲染解析度 -RenderingMode NonBuffered Tip = 較快速,但在某些遊戲中可能什麼都不會顯示 -Retain changed textures = 保留更改紋理(有時更慢) -RetainChangedTextures Tip = 許多遊戲的速度變慢,但某些遊戲則變快許多 +Postprocessing Shader = 後處理著色器 +Recreate Activity = 重新建立活動 +Render duplicate frames to 60hz = 轉譯重複影格至 60 Hz +RenderDuplicateFrames Tip = 可以使以較低影格速率執行的遊戲更加順暢 +Rendering Mode = 轉譯模式 +Rendering Resolution = 轉譯解析度 +RenderingMode NonBuffered Tip = 更快,但在某些遊戲中可能無法繪圖 +Retain changed textures = 保留變更的紋理 (有時會更慢) +RetainChangedTextures Tip = 使很多遊戲變慢,但某些遊戲會變快許多 Rotation = 旋轉 Safe = 安全 -Screen layout = 屏幕佈局 +Screen layout = 螢幕版面配置 Screen Scaling Filter = 螢幕縮放濾鏡 -Show Debug Statistics = 顯示除錯數據 +Show Debug Statistics = 顯示偵錯統計資料 Show FPS Counter = 顯示 FPS 計數器 -Simulate Block Transfer = 模擬塊傳送的影響 -Software Rendering = 軟體渲染 -Software Skinning = 減少繪圖調用(提升速度) -SoftwareSkinning Tip = 在使用高級皮膚技術的遊戲中減少繪圖和更快,但有些遊戲更慢 +Simulate Block Transfer = 模擬區塊傳輸效果 +Software Rendering = 軟體轉譯 (慢) +Software Skinning = 軟體除皮 +SoftwareSkinning Tip = 結合除皮模組在 CPU 上繪製,在多數遊戲上更快 Speed = 速度 -Stretching = 拉伸 -Texture Filter = 紋理過濾 -Texture Filtering = 紋理過濾 +Stretching = 延伸 +Texture Filter = 紋理濾鏡 +Texture Filtering = 紋理濾鏡 Texture Scaling = 紋理縮放 Texture Shader = 紋理著色器 -Turn off Hardware Tessellation - unsupported = 關閉“硬件曲面細分”:不支持 -Unlimited = 無限 -Up to 1 = 上到1 -Up to 2 = 上到2 -Upscale Level = 縮放倍率 -Upscale Type = 縮放類型 -UpscaleLevel Tip = CPU的負擔大,某些縮放可能會延遲,以免遊戲不流暢 -Use all displays = 使用所有顯示 +Turn off Hardware Tessellation - unsupported = 關閉「硬體鑲嵌式」:不支援 +Unlimited = 無限制 +Up to 1 = 最多至 1 +Up to 2 = 最多至 2 +Upscale Level = 放大層級 +Upscale Type = 放大類型 +UpscaleLevel Tip = CPU 負載過重 - 部分縮放可能會延遲以避免間斷 +Use all displays = 使用所有顯示器 Vertex Cache = 頂點快取 -VertexCache Tip = 速度更快,但可能會造成螢幕暫時閃爍 +VertexCache Tip = 更快,但可能會造成暫時閃爍 VSync = 垂直同步 Vulkan = Vulkan Window Size = 視窗大小 xBRZ = xBRZ +GPU log profiler = GPU 記錄分析工具 [InstallZip] -Delete ZIP file = 刪除ZIP檔案 +Delete ZIP file = 刪除 ZIP 檔案 Install = 安裝 -Install game from ZIP file? = 從ZIP檔案安裝遊戲? -Install textures from ZIP file? = 從ZIP文件安裝紋理? -Installed! = 安裝完成! -Texture pack doesn't support install = 紋理包不支持安裝 -Zip archive corrupt = ZIP檔案損壞 -Zip file does not contain PSP software = ZIP文件不包含PSP軟件 +Install game from ZIP file? = 從 ZIP 檔案安裝遊戲? +Install textures from ZIP file? = 從 ZIP 檔案安裝紋理? +Installed! = 已安裝! +Texture pack doesn't support install = 紋理套件不支援安裝 +Zip archive corrupt = ZIP 封存損毀 +Zip file does not contain PSP software = ZIP 檔案不包含 PSP 軟體 [KeyMapping] -Autoconfigure = 自動配置 -Autoconfigure for device = 設備自動配置 -Bind All = 全部綁定 +Autoconfigure = 自動設定 +Autoconfigure for device = 自動設定裝置 +Bind All = 全部繫結 Clear All = 全部清除 -Default All = 全部恢復預設 -Map a new key for = 你按下的按鈕將會對應到此功能: -Map Key = 按鍵映射 -Map Mouse = 鼠標映射 -Replace = 替換 +Default All = 重設為預設值 +Map a new key for = 對應新按鍵: +Map Key = 對應按鍵 +Map Mouse = 對應滑鼠 +Replace = 取代 Show PSP = 顯示 PSP -You can press ESC to cancel. = 您可以按Esc取消。 +You can press ESC to cancel. = 您可以按下 ESC 取消 [MainMenu] -Browse = 瀏覽... -Buy PPSSPP Gold = 購買PPSSPP黃金版 -Choose folder = 選擇文件夾 -Credits = 製作團隊 -PPSSPP Homebrew Store = 從PPSSPP自製游戲商店下載 +Browse = 瀏覽… +Buy PPSSPP Gold = 購買 PPSSPP 黃金版 +Choose folder = 選擇資料夾 +Credits = 製作名單 +PPSSPP Homebrew Store = PPSSPP 自製遊戲商店 Exit = 離開 -Game Settings = 遊戲設定 +Game Settings = 設定 Games = 遊戲 -Give PPSSPP permission to access storage = 給予PPSSPP存取權限 -Homebrew & Demos = 自製遊戲和試玩 -How to get games = 如何獲得遊戲 -How to get homebrew & demos = 如何獲得自製遊戲和試玩 -Load = 載入遊戲... -Loading... = 載入中... -PinPath = 標記 -PPSSPP can't load games or save right now = PPSSPP現在無法載入遊戲或存檔 -Recent = 最近執行的遊戲 -SavesAreTemporary = PPSSPP正在保存在臨時存儲中 -SavesAreTemporaryGuidance = 將PPSSPP提取到某個地方以永久保存 +Give PPSSPP permission to access storage = 授與 PPSSPP 權限以存取儲存空間 +Homebrew & Demos = 自製遊戲與試玩 +How to get games = 如何取得遊戲? +How to get homebrew & demos = 如何取得自製遊戲與試玩? +Load = 載入… +Loading... = 正在載入… +PinPath = 釘選 +PPSSPP can't load games or save right now = PPSSPP 目前無法載入或儲存遊戲 +Recent = Recent +SavesAreTemporary = PPSSPP 正在儲存於暫時儲存空間 +SavesAreTemporaryGuidance = 將 PPSSPP 擷取至其他位置以永久儲存 SavesAreTemporaryIgnore = 忽略警告 -UnpinPath = 取消標記 -UseBrowseOrLoad = 瀏覽以選擇文件夾,或者加載以載入遊戲文件 +UnpinPath = 取消釘選 +UseBrowseOrLoad = 使用「瀏覽」以選擇資料夾,或載入以選擇檔案 www.ppsspp.org = www.ppsspp.org [MainSettings] -Audio = 聲音設定 -Controls = 控制器設定 -Graphics = 圖形設定 -Networking = 網路連線 -Search = 搜索 -System = 系統設定 +Audio = 音訊 +Controls = 控制 +Graphics = 圖形 +Networking = 網路 +System = 系統 Tools = 工具 +Search = 搜尋 [MappableControls] -Alt speed 1 = 自定義速度1 -Alt speed 2 = 自定義速度2 -An.Down = 左搖桿:下 -An.Left = 左搖桿:左 -An.Right = 左搖桿:右 -An.Up = 左搖桿:上 -Analog limiter = 搖桿限制器 -Analog Stick = 搖桿 -Audio/Video Recording = 音頻/視頻錄製 +Alt speed 1 = 替代速度 1 +Alt speed 2 = 替代速度 2 +An.Down = 類比搖桿:下 +An.Left = 類比搖桿:左 +An.Right = 類比搖桿:右 +An.Up = 類比搖桿:上 +Analog limiter = 類比限制器 +Analog Stick = 類比搖桿 +Audio/Video Recording = 音訊/視訊錄製 AxisSwap = 軸交換 -Circle = 圈 -Cross = 叉 -Custom 1 = 預設1 -Custom 10 = 預設10 -Custom 2 = 預設2 -Custom 3 = 預設3 -Custom 4 = 預設4 -Custom 5 = 預設5 -Custom 6 = 預設6 -Custom 7 = 預設7 -Custom 8 = 預設8 -Custom 9 = 預設9 -D-pad down = 方向鍵:下 -D-pad left = 方向鍵:左 -D-pad right = 方向鍵:右 -D-pad up = 方向鍵:上 -DevMenu = 開發者選單 -Display Landscape = 顯示橫向 -Display Landscape Reversed = 顯示橫向反轉 -Display Portrait = 顯示縱向 -Display Portrait Reversed = 顯示縱向反轉 -Double tap button = 雙擊鍵 -Down = 方向鍵:下 +Circle = ○ +Cross = × +Custom 1 = 自訂 1 +Custom 2 = 自訂 2 +Custom 3 = 自訂 3 +Custom 4 = 自訂 4 +Custom 5 = 自訂 5 +Custom 6 = 自訂 6 +Custom 7 = 自訂 7 +Custom 8 = 自訂 8 +Custom 9 = 自訂 9 +Custom 10 = 自訂 10 +D-pad down = 方向鍵:下 +D-pad left = 方向鍵:左 +D-pad right = 方向鍵:右 +D-pad up = 方向鍵:上 +DevMenu = 開發選單 +Double tap button = 點兩下按鈕 +Down = 方向鍵:下 Dpad = 方向鍵 -Frame Advance = 逐幀播放 -Hold = 短按電源鍵 -Home = Home +Frame Advance = 逐影格 +Hold = 固定 +Home = PS 按鈕 L = L -Left = 方向鍵:左 -Load State = 載入即時存檔 -Mute toggle = 靜音 -Next Slot = 下一槽 +Left = 方向鍵:左 +Load State = 載入存檔 +Mute toggle = 靜音切換 +Next Slot = 下一存檔插槽 None = 無 -Note = Note -OpenChat = 打開聊天 +Note = 聲音按鈕 +OpenChat = 開啟聊天 Pause = 暫停 R = R -RapidFire = 連射 +RapidFire = 快速開火 Record = 錄製 -Remote hold = 長按電源鍵 -Rewind = 倒回 -Right = 方向鍵:右 -Right Analog Stick = 右搖桿 +Remote hold = 遠端固定 +Rewind = 倒轉 +Right = 方向鍵:右 +Right Analog Stick = 右類比搖桿 RightAn.Down = 右搖桿:下 RightAn.Left = 右搖桿:左 RightAn.Right = 右搖桿:右 RightAn.Up = 右搖桿:上 -Rotate Analog (CCW) = 旋轉模擬(CCW) -Rotate Analog (CW) = 旋轉模擬(CW) -Save State = 即時存檔 -Screen = 屏幕 -Screenshot = 屏幕截圖 +Rotate Analog (CCW) = 旋轉類比 (CCW) +Rotate Analog (CW) = 旋轉類比 (CW) +Save State = 儲存存檔 +Screen = 螢幕 +Screenshot = 螢幕截圖 Select = 選擇 SpeedToggle = 速度切換 -Square = 正方 +Square = □ Start = 開始 Swipe Down = 向下滑動 Swipe Left = 向左滑動 Swipe Right = 向右滑動 Swipe Up = 向上滑動 -tap to customize = 點擊並自定義 -Texture Dumping = 紋理轉儲 -Texture Replacement = 紋理替換 -Toggle Fullscreen = 切換全屏 +tap to customize = 點選以自訂 +Texture Dumping = 紋理傾印 +Texture Replacement = 紋理取代 +Toggle Fullscreen = 切換全螢幕 Toggle mode = 切換模式 -Triangle = 三角形 -Fast-forward = 解除速限 +Triangle = △ +Fast-forward = 快轉 Up = 方向鍵:上 -Vol + = 音量+ -Vol - = 音量- -Wlan = 無綫網絡 - -[MemStick] -Already contains PSP data = 已包含PSP數據 -Create or Choose a PSP folder = 創建或選擇PSP文件夾 -Current = 目前 -DataCanBeShared = 數據可在PPSSPP普通版/黃金版共用 -DataCannotBeShared = 數據無法在PPSSPP普通版/黃金版共用! -DataWillBeLostOnUninstall = 警告! 卸載PPSSPP會丟失數據! -DataWillStay = 卸載PPSSPP會保留數據 -Done! = 完成! -EasyUSBAccess = 輕鬆USB訪問 -Failed to move some files! = 無法移動部分文件! -Failed to save config = 無法保存配置 -Free space = 可用空間 -Manually specify PSP folder = 手動指定PSP文件夾 -MemoryStickDescription = 選擇PSP文件存放位置(記憶棒) -Move Data = 移動PSP數據 -Selected PSP Data Folder = 選擇PSP數據文件夾 -No data will be changed = 數據不會更改 -PPSSPP will restart after the change = 完成配置后會重啓PPSSPP -Skip for now = 暫時跳過 -Starting move... = 開始移動... -That folder doesn't work as a memstick folder. = 所選文件夾無法作爲記憶棒目錄您选择的文件夹无法作为记忆棒目录。 -USBAccessThrough = USB連接時請打開 Android/data/org.ppsspp.ppsspp/files -USBAccessThroughGold = USB連接時請打開 Android/data/org.ppsspp.ppssppgold/files -Use App Private Data = 在APP内置的目錄中保存 -Use PSP folder at root of storage = 在手機目錄中保存PSP文件 -Welcome to PPSSPP! = 歡迎使用PPSSPP! -WhatsThis = 這個配置有什麽用? +Vol + = 音量 + +Vol - = 音量 - +Wlan = WLAN +Display Landscape = 顯示器橫向 +Display Landscape Reversed = 顯示器橫向反轉 +Display Portrait = 顯示器直向 +Display Portrait Reversed = 顯示器直向反轉 [Networking] -AdHoc Server = Ad hoc服務器 -AdhocServer Failed to Bind Port = 無法綁定Adhoc服務器端口 -AM: Data from Unknown Port = AM:來自未知端口的數據 +AdHoc Server = 臨機操作伺服器 +AdhocServer Failed to Bind Port = 臨機操作伺服器無法繫結連接埠 +AM: Data from Unknown Port = AM:來自不明連接埠的資料 Auto = 自動 -Bottom Center = 中間下面 -Bottom Left = 下左面 -Bottom Right = 右下面 -Center Left = 中間左面 -Center Right = 中間右面 -Change Mac Address = 改變 Mac 網路位址 -Change proAdhocServer Address = 改變PRO Adhoc網路位址(localhost = 多個實例) -ChangeMacSaveConfirm = Generate a new MAC address? -ChangeMacSaveWarning = Some games verify the MAC address when loading savedata, so this may break old saves. +Bottom Center = 正下 +Bottom Left = 左下 +Bottom Right = 右下 +Center Left = 正左 +Center Right = 正右 +Change Mac Address = 變更 MAC 位址 +ChangeMacSaveConfirm = 產生新的 MAC 位址? +ChangeMacSaveWarning = 某些遊戲在載入儲存資料時會驗證 MAC 位址,這可能會損毀舊存檔 +Change proAdhocServer Address = 變更 PRO 臨機操作伺服器 IP 位址 (本機主機 = 多重執行個體) Chat = 聊天 Chat Button Position = 聊天按鈕位置 Chat Here = 在這裡聊天 -Chat message = 聊天消息 +Chat message = 聊天訊息 Chat Screen Position = 聊天畫面位置 -Disconnected from AdhocServer = 與 dhoc服務器斷開連接 -DNS Error Resolving = DNS錯誤解決 -Enable built-in PRO Adhoc Server = 啟用內建PRO Adhoc伺服器 -Enable network chat = 啟用網絡聊天 -Enable networking = 啟用網路連線/無線區域網路(測試) -Enable UPnP = 啟用UPnP(需要幾秒鐘來檢測) +Disconnected from AdhocServer = 從臨機操作伺服器中斷連線 +DNS Error Resolving = DNS 解析錯誤 +Enable built-in PRO Adhoc Server = 啟用內建 PRO 臨機操作伺服器 +Enable network chat = 啟用網路聊天 +Enable networking = 啟用網路功能/WLAN (測試版,可能損毀遊戲) +Enable UPnP = 啟用 UPnP (需要數秒鐘來偵測) EnableQuickChat = 啟用快速聊天 -Enter a new PSP nickname = 輸入新的PSP暱稱 -Enter Quick Chat 1 = 輸入快速聊天1 -Enter Quick Chat 2 = 輸入快速聊天2 -Enter Quick Chat 3 = 輸入快速聊天3 -Enter Quick Chat 4 = 輸入快速聊天4 -Enter Quick Chat 5 = 輸入快速聊天5 -Error = Error -Failed to Bind Localhost IP = 無法綁定本地主機IP -Failed to Bind Port = 無法綁定端口 -Failed to connect to Adhoc Server = 無法連接Adhoc服務器 -Forced First Connect = 強制首次連接(更快的連接) -GM: Data from Unknown Port = GM:數據來自未知端口 -Hostname = 主機名 -Invalid IP or hostname = 無效的IP或主機名 -Minimum Timeout = 最小超時(以毫秒為單位,0=默認) -Misc = 其他(默認= PSP兼容性) +Enter a new PSP nickname = 輸入新的 PSP 暱稱 +Enter Quick Chat 1 = 輸入快速聊天 1 +Enter Quick Chat 2 = 輸入快速聊天 2 +Enter Quick Chat 3 = 輸入快速聊天 3 +Enter Quick Chat 4 = 輸入快速聊天 4 +Enter Quick Chat 5 = 輸入快速聊天 5 +Error = 錯誤 +Failed to Bind Localhost IP = 無法繫結本機主機 IP +Failed to Bind Port = 無法繫結連接埠 +Failed to connect to Adhoc Server = 無法連線至臨機操作伺服器 +Forced First Connect = 強制首次連線 (更快連線) +GM: Data from Unknown Port = GM:來自不明連接埠的資料 +Hostname = 主機名稱 +Invalid IP or hostname = 無效的 IP 或主機名稱 +Minimum Timeout = 最小逾時 (單位為毫秒,0 = 預設) +Misc = 雜項 (預設 = PSP 相容性) Network Initialized = 網路已初始化 None = 無 -Please change your Port Offset = 請更改您的端口偏移 -Port offset = 端口偏移 (0 = PSP 實機兼容) -Open PPSSPP Multiplayer Wiki Page = 打開PPSSPP多人百科頁面 -#打开PPSSPP多人联机百科页面 -proAdhocServer Address: = Ad hoc服務器地址: -Quick Chat 1 = 快速聊天1 -Quick Chat 2 = 快速聊天2 -Quick Chat 3 = 快速聊天3 -Quick Chat 4 = 快速聊天4 -Quick Chat 5 = 快速聊天5 +Please change your Port Offset = 請變更您的連接埠位移 +Port offset = 連接埠位移 (0 = PSP 相容性) +Open PPSSPP Multiplayer Wiki Page = 開啟 PPSSPP 多人遊戲維基頁面 +proAdhocServer Address: = 臨機操作伺服器位址: +Quick Chat 1 = 快速聊天 1 +Quick Chat 2 = 快速聊天 2 +Quick Chat 3 = 快速聊天 3 +Quick Chat 4 = 快速聊天 4 +Quick Chat 5 = 快速聊天 5 QuickChat = 快速聊天 -Send = 發送 -Send Discord Presence information = 發送Discord "Rich Presence" information -#发送Discord"在线状态"信息 -Top Center = 中間上面 -Top Left = 左上面 -Top Right = 右上面 -Unable to find UPnP device = 找不到UPnP設備 -UPnP (port-forwarding) = UPnP(端口轉發) -UPnP need to be reinitialized = UPnP需要重新初始化 -UPnP use original port = UPnP使用原始端口(已啟用=PSP兼容性) -Validating address... = 驗證地址... +Send = 傳送 +Send Discord Presence information = 傳送 Discord「Rich Presence」資訊 +Top Center = 正上 +Top Left = 左上 +Top Right = 右上 +Unable to find UPnP device = 找不到 UPnP 裝置 +UPnP (port-forwarding) = UPnP (連接埠轉送) +UPnP need to be reinitialized = UPnP 需要重新初始化 +UPnP use original port = UPnP 使用原始連接埠 (已啟用 = PSP 相容性) +Validating address... = 正在驗證位址… WLAN Channel = WLAN 頻道 -You're in Offline Mode, go to lobby or online hall = 您現在是離綫模式,請進入房間或在綫大廳 +You're in Offline Mode, go to lobby or online hall = 您目前處於離線模式,請前往大廳或線上大廳 [Pause] -Cheats = 金手指 +Cheats = 密技 Continue = 繼續 -Create Game Config = 建立遊戲配置 -Delete Game Config = 刪除遊戲配置 -Exit to menu = 返回主選單 +Create Game Config = 建立遊戲組態 +Delete Game Config = 刪除遊戲組態 +Exit to menu = 返回選單 Game Settings = 遊戲設定 Load State = 載入存檔 -Rewind = 倒回 -Save State = 即時存檔 +Rewind = 倒轉 +Save State = 儲存存檔 Settings = 設定 -Switch UMD = 切換光碟 -Undo last load = 撤銷加載 -Undo last save = 撤銷保存 +Switch UMD = 切換 UMD +Undo last load = 復原上次載入 +Undo last save = 復原上次儲存 [PostShaders] -(duplicated setting, previous slider will be used) = (配置重複, 將使用上面滑塊的值) +(duplicated setting, previous slider will be used) = (重複的設定,將使用上一個滑桿) 4xHqGLSL = 4×HQ GLSL 5xBR = 5xBR 5xBR-lv2 = 5xBR-lv2 AAColor = AA-Color Amount = 數量 -Animation speed (0 -> disable) = 動畫速度(0->禁用) -Black border = 黑色描邊 -Bloom = 汎光 +Black border = 黑色框線 +Bloom = 光圈 Brightness = 亮度 Cartoon = 卡通 -CatmullRom = Bicubic 雙三插值縮放 -ColorCorrection = 顔色修正 +ColorCorrection = 色彩修正 Contrast = 對比度 -CRT = CRT 掃描綫 -FXAA = FXAA (快速近似抗鋸齒) -Gamma = 伽馬 -Grayscale = 灰度图 -Intensity = 强度 -InverseColors = 反色 -MitchellNetravali = Bicubic 雙三插值縮放 -Natural = 自然色 -NaturalA = 自然色-無模糊 +CRT = CRT 掃描線 +FXAA = FXAA 消除鋸齒 +Gamma = 色差補正 +Grayscale = 灰階 +Intensity = 濃度 +InverseColors = 反轉色彩 +Natural = 自然色彩 +NaturalA = 自然色彩 (無模糊) Off = 關閉 -Power = 效果强度 -PSPColor = PSP顔色 -Saturation = 色彩 -Scanlines = 掃描綫(CRT) -Sharpen = 銳化 -SSAA(Gauss) = Supersampling AA(超級采樣抗鋸齒:高斯) +Power = Power +PSPColor = PSP 色彩 +Saturation = 飽和度 +Scanlines = 掃描線 (CRT) +Sharpen = 銳利化 +SSAA(Gauss) = 超級取樣 AA (高斯) Tex4xBRZ = 4xBRZ TexMMPX = MMPX -UpscaleSpline36 = Spline36縮放 -VideoSmoothingAA = VideoSmoothingAA(視頻平滑抗鋸齒) -Vignette = 光暈 +UpscaleSpline36 = Spline36 放大 +VideoSmoothingAA = 視訊平滑 AA +Vignette = 暈影 +Animation speed (0 -> disable) = 動畫速度 (0 -> 停用) +CatmullRom = 雙立方 (卡特姆 - 羅姆) 放大 +MitchellNetravali = 雙立方 (密契爾 - 內拉瓦利) 放大 [PSPCredits] -all the forum mods = 論壇上所有的mod -build server = 編譯服務器 +all the forum mods = 所有論壇模組 +build server = 組建伺服器 Buy Gold = 購買黃金版 -check = 也歡迎你試用海豚模擬器,最好用的Wii/GC 模擬器 -CheckOutPPSSPP = 查閲 PPSSPP, 一款超棒的PSP模擬器:https://www.ppsspp.org/ +check = 同樣歡迎使用海豚模擬器,這是最棒的 Wii/GC 模擬器 +CheckOutPPSSPP = 體驗 PPSSPP,一款絕佳的 PSP 模擬器:https://www.ppsspp.org/ contributors = 參與者: -created = 作者: +created = 作者 Discord = Discord -info1 = PPSSPP僅限教學用途 -info2 = 請確認你有權使用該遊戲, -info3 = 例如持有該遊戲的正版光碟, -info4 = 或是透過PSP於PSN商店購買數位版。 -info5 = PSP®是索尼公司的註冊商標。 -iOS builds = iOS builds -license = PPSSPP是遵循GPL 2.0+授權條款的自由軟體 -list = 網站上有相容性列表、官方論壇以及開發動態 -PPSSPP Forums = PPSSPP官方論壇 -Privacy Policy = 隱私政策 -Share PPSSPP = 分享PPSSPP +info1 = PPSSPP 僅適用於教育用途, +info2 = 請確保您擁有遊戲的版權, +info3 = 您擁有遊戲的 UMD 光碟, +info4 = 或是透過 PSP 在 PSN 商店中購買數位版。 +info5 = PSP® 是 Sony, Inc 的註冊商標 +iOS builds = iOS 組建 +license = PPSSPP 是遵循 GPL 2.0+ 授權條款的自由軟體 +list = 瞭解相容性清單、官方論壇和開發資訊 +PPSSPP Forums = PPSSPP 論壇 +Privacy Policy = 隱私權政策 +Share PPSSPP = 分享 PPSSPP specialthanks = 特別感謝: -specialthanksKeithGalocy = 的硬件,建議,他來自NVIDIA -specialthanksMaxim = 的出色Atrac3 +解碼 -testing = 負責測試 -this translation by = 譯者: -title = 快速、方便攜帶的PSP模擬器 -tools = 使用自由工具: +specialthanksKeithGalocy = 的硬體和建議,他來自 NVIDIA +specialthanksMaxim = 的出色的解碼器工作 +testing = 測試人員: +this translation by = 正體中文翻譯: +title = 快速、方便攜帶的 PSP 模擬器 +tools = 使用的自由工具: # Add translators or contributors who translated PPSSPP into your language here. # Add translators1-6 for up to 6 lines of translator credits. # Leave extra lines blank. 4 contributors per line seems to look best. -translators1 = sum2012, kaienfr, raven02, aquanull, xiwo4525 -translators2 = wuspring, zzq920817, W-MS, xzapk, Arthur200000 -translators3 = Playhi, PeaceShi, Nargacuga, driver1998 -translators4 = xujibbs +translators1 = sum2012, xujibbs, leoxxx, Adeptus2 +translators2 = +translators3 = +translators4 = translators5 = translators6 = Twitter @PPSSPP_emu = Twitter @PPSSPP_emu -website = 歡迎參觀我們的網站: -written = 使用C++編寫以保證移植性和速度 +website = 歡迎造訪我們的網站: +written = 使用 C++ 編寫,以保證建置速度和相容性 + +[MemStick] +Already contains PSP data = 已包含 PSP 資料 +Create or Choose a PSP folder = 建立或選擇 PSP 資料夾 +Current = 目前 +DataCanBeShared = 資料可在 PPSSPP 標準版/黃金版之間共用 +DataCannotBeShared = 資料無法在 PPSSPP 標準版/黃金版之間共用! +DataWillBeLostOnUninstall = 警告!資料會在解除安裝 PPSSPP 後遺失! +DataWillStay = 資料會在解除安裝 PPSSPP 後保留 +Done! = 完成! +EasyUSBAccess = USB 輕鬆存取 +Failed to move some files! = 無法移動部分檔案! +Failed to save config = 無法儲存組態 +Free space = 可用空間 +Manually specify PSP folder = 手動指定 PSP 資料夾 +MemoryStickDescription = 選擇 PSP 資料存放位置 (記憶棒) +Move Data = 移動資料 +Selected PSP Data Folder = 選取的 PSP 資料資料夾 +Skip for now = 暫時跳過 +No data will be changed = 沒有要變更的資料 +PPSSPP will restart after the change = PPSSPP 將在完成變更後重新啟動 +Starting move... = 開始移動… +That folder doesn't work as a memstick folder. = 這個資料夾無法作為記憶棒資料夾正常運作 +USBAccessThrough = 透過 USB 存取 Android/data/org.ppsspp.ppsspp/files +USBAccessThroughGold = 透過 USB 存取 Android/data/org.ppsspp.ppssppgold/files +Use App Private Data = 使用應用程式私人資料夾 +Use PSP folder at root of storage = 使用儲存空間 PSP 資料夾 +Welcome to PPSSPP! = 歡迎使用 PPSSPP! +WhatsThis = 這是什麼? [RemoteISO] Browse Games = 瀏覽遊戲 -Local Server Port = 本地服務器端口 -Manual Mode Client = 手動模式客戶端 -Remote disc streaming = 遠程光盤流 -Remote Port = 遠端埠 +Local Server Port = 本機伺服器連接埠 +Manual Mode Client = 手動設定用戶端 +Remote disc streaming = 遠端光碟串流 +Remote Port = 遠端連接埠 Remote Server = 遠端伺服器 -Remote Subdirectory = 遠程子目錄 -RemoteISODesc = 您最近列表中的遊戲將被共享 -RemoteISOLoading = 已連接,正在加載遊戲列表... -RemoteISOScanning = 掃描...單擊服務器設備上的“共享遊戲” -RemoteISOScanningTimeout = 正在掃描...檢查您桌面的防火牆配置 -RemoteISOWifi = 注意:將兩個設備都連接到同一Wi-Fi網絡 -RemoteISOWinFirewall = 警告:Windows防火牆阻止共享 -Settings = 設定值 -Share Games (Server) = 分享遊戲(服務器) -Share on PPSSPP startup = 分享PPSSPP啟動 -Stop Sharing = 停止分享 -Stopping.. = 正在停止... +Remote Subdirectory = 遠端子目錄 +RemoteISODesc = 「最近遊玩」清單中的遊戲將被共用 +RemoteISOLoading = 已連線,正在載入遊戲清單… +RemoteISOScanning = 正在掃描… 在您的伺服器裝置上按一下「共用遊戲」 +RemoteISOScanningTimeout = 正在掃描… 檢查您的桌面防火牆設定 +RemoteISOWifi = 注意:將兩部裝置皆連線至同一 Wi-Fi 網路 +RemoteISOWinFirewall = 警告:Windows 防火牆已封鎖共用 +Settings = 設定 +Share Games (Server) = 共用遊戲 (伺服器) +Share on PPSSPP startup = PPSSPP 啟動時共用 +Stop Sharing = 停止共用 +Stopping.. = 正在停止… [Reporting] -Bad = 壞 -FeedbackCRCCalculating = 光碟CRC: 計算中... -FeedbackCRCValue = 光碟CRC: %1 -FeedbackDelayInfo = 您的數據正在後台提交. -FeedbackDesc = 模擬的效果怎麼樣?說給我們聽聽! -FeedbackDisabled = 兼容性服務器報告必須啟用. -FeedbackIncludeCRC = 注意:電池將用於發送光盤CRC -FeedbackIncludeScreen = 包括屏幕截圖 -FeedbackSubmitDone = 您的數據已提交. -FeedbackSubmitFail = 無法將數據提交到服務器。 嘗試更新PPSSPP。 -FeedbackThanks = 感謝您的反饋意見! -Gameplay = 遊戲過程 +Bad = 不佳 +FeedbackCRCCalculating = 光碟 CRC:正在計算… +FeedbackCRCValue = 光碟 CRC:%1 +FeedbackDelayInfo = 您的資料正在背景提交 +FeedbackDesc = 模擬效果如何?說給我們聽聽! +FeedbackDisabled = 必須啟用相容性伺服器回報 +FeedbackIncludeCRC = 注意:傳送光碟 CRC 將會損耗電池電力 +FeedbackIncludeScreen = 包含螢幕截圖 +FeedbackSubmitDone = 您的資料已提交 +FeedbackSubmitFail = 無法將資料提交至伺服器,嘗試更新 PPSSPP +FeedbackThanks = 感謝您的意見反應 +Gameplay = 遊戲歷程 Graphics = 圖形 -Great = 很好 -In-game = 在遊戲中 -In-game Description = 能進入遊戲玩,但太多問題 +Great = 絕佳 +In-game = 遊戲內 +In-game Description = 可以進入遊戲,但存在很多錯誤 Menu/Intro = 選單/簡介 -Menu/Intro Description = 無法進入遊戲本身 -Nothing = 沒畫面 -Nothing Description = 完全壞了 -OK = 好 -Open Browser = 打開瀏覽器 +Menu/Intro Description = 無法進入遊戲 +Nothing = 沒有畫面 +Nothing Description = 完全損毀 +OK = 確定 +Open Browser = 開啟報告網站 Overall = 整體 Perfect = 完美 -Perfect Description = 完美模擬整個游戲 - 太棒了! +Perfect Description = 完美模擬整個遊戲 - 太棒了! Plays = 可玩 -Plays Description = 基本模擬整個游戲,但有時會出現故障 -ReportButton = 報告反饋 -Show disc CRC = 顯示光碟CRC +Plays Description = 可以遊玩,但可能會出現故障 +ReportButton = 回報意見反應 +Show disc CRC = 顯示光碟 CRC Speed = 速度 -Submit Feedback = 提交反饋 -SuggestionConfig = 請參閱網站上的報告以了解正確的配置。 -SuggestionCPUSpeed0 = 禁用鎖定的CPU速度配置。 -SuggestionDowngrade = 降級到較舊的PPSSPP版本(請報告此錯誤)。 -SuggestionsFound = 其他用戶報告了更好的結果。 點擊“查看反饋”以獲取更多詳細信息。 -SuggestionsNone = 其他用戶也不能運行該游戲。 -SuggestionsWaiting = 提交並檢查其他用戶的反饋... -SuggestionUpgrade = 升級到更新的PPSSPP版本。 -SuggestionVerifyDisc = 檢查您的ISO是否是光盤的良好副本。 +Submit Feedback = 提交意見反應 +SuggestionConfig = 參閱網站上的報告以瞭解最佳設定 +SuggestionCPUSpeed0 = 停用鎖定的 CPU 速度設定 +SuggestionDowngrade = 降級為舊版 PPSSPP (請回報此錯誤) +SuggestionsFound = 其他使用者已回報了更佳的結果,點選「檢視意見反映」以取得更多詳細資料 +SuggestionsNone = 這個遊戲在其他使用者的裝置上也無法運作 +SuggestionsWaiting = 正在提交並檢查其他使用者的意見反應… +SuggestionUpgrade = 升級至新版 PPSSPP 組建 +SuggestionVerifyDisc = 檢查 ISO 是否為您光碟的良好複本 Unselected Overall Description = 這個遊戲的模擬效果如何? -View Feedback = 查看所有反饋 +View Feedback = 檢視所有意見反應 [Savedata] Date = 日期 -Filename = 文件名 -No screenshot = 沒有截圖 -None yet. Things will appear here after you save. = 暫無。在你存檔之後這裡才會出現數據。 -Nothing matching '%1' was found. = 沒有找到符合'%1'的結果。 -Save Data = 存檔資料 -Save States = 即時存檔資料 -Savedata Manager = 管理存檔資料 -Showing matches for '%1'. = 找到符合'%1'的搜尋結果。 +Filename = 檔案名稱 +No screenshot = 沒有螢幕截圖 +None yet. Things will appear here after you save. = 尚無,將在存檔後出現新項目 +Nothing matching '%1' was found. = 找不到與「%1」相符的項目 +Save Data = 儲存資料 +Save States = 存檔 +Savedata Manager = 儲存資料管理員 +Showing matches for '%1'. = 顯示與「%1」相符的項目 Size = 大小 [Screen] -Cardboard VR OFF = Cardboard VR關閉 -Chainfire3DWarning = 警告:偵測到Chainfire3D,可能造成問題 -Failed to load state = 無法載入快速存檔 -Failed to save state = 無法儲存快速存檔 -fixed = 速度:固定 -GLToolsWarning = 警告:偵測到GLTools,可能造成問題 -In menu = In menu -Load savestate failed = 無法載入快速存檔 -Loaded State = 已載入即時存檔 -Loaded. Game may refuse to save over different savedata. = 已加載。游戲可能無法保存在別的存檔。 -Loaded. Game may refuse to save over newer savedata. = 已加載。游戲可能無法保存在進度提前的存檔。 -Loaded. Save in game, restart, and load for less bugs. = 已加載。 保存在遊戲中,重新啟動並加載,以減少錯誤。 -LoadStateDoesntExist = 無法載入:存檔不存在! -LoadStateWrongVersion = 無法載入:存檔為舊版的PPSSPP的! -norewind = 倒带即時存檔不可用 -Playing = 游戲中 -PressESC = 按下ESC鍵以暫停遊戲 -replaceTextures_false = 不再替換紋理. -replaceTextures_true = 啟用紋理替換. -Save State Failed = 即時存檔失敗! -Saved State = 即時存檔完成 -saveNewTextures_false = 紋理保存已禁用. -saveNewTextures_true = 紋理現在將保存到您的存儲中. -SpeedCustom2 = 速度:備用2 +Cardboard VR OFF = Cardboard VR 關閉 +Chainfire3DWarning = 警告:偵測到 Chainfire3D,可能會造成問題 +Failed to load state = 無法載入存檔 +Failed to save state = 無法儲存存檔 +fixed = 速度:替代 +GLToolsWarning = 警告:偵測到 GLTools,可能會造成問題 +In menu = 選單中 +Load savestate failed = 無法載入存檔 +Loaded State = 存檔已載入 +Loaded. Save in game, restart, and load for less bugs. = 已載入,在遊戲中儲存、重新啟動,然後載入,將會減少錯誤 +Loaded. Game may refuse to save over different savedata. = 已載入,遊戲可能會拒絕覆寫不同的存檔 +Loaded. Game may refuse to save over newer savedata. = 已載入,遊戲可能會拒絕覆寫較新的存檔 +LoadStateDoesntExist = 無法載入存檔:存檔不存在! +LoadStateWrongVersion = 無法載入存檔:存檔僅適用於舊版 PPSSPP! +norewind = 沒有可用的倒轉存檔 +Playing = 正在遊玩 +PressESC = 按下 ESC 以開啟暫停選單 +replaceTextures_false = 紋理將不再被取代 +replaceTextures_true = 紋理取代已啟用 +Save State Failed = 無法儲存存檔! +Saved State = 已存檔 +saveNewTextures_false = 紋理儲存已停用 +saveNewTextures_true = 紋理將儲存至您的儲存空間 +SpeedCustom2 = 速度:替代 2 standard = 速度:標準 -State load undone = 撤銷載入存檔 -Untitled PSP game = 無標題的PSP遊戲 - -[Search] -Clear filter = 清楚篩選結果 -Filter = 篩選 -Filtering settings by '%1' = 配置篩選'%1' -Find settings = 搜索配置 -No settings matched '%1' = 未找到配置'%1' +State load undone = 存檔載入復原 +Untitled PSP game = 未命名 PSP 遊戲 [Store] -Already Installed = 已安裝完成 +Already Installed = 已安裝 Connection Error = 連線錯誤 Install = 安裝 -Launch Game = 開始遊戲 -Loading... = 載入中... +Launch Game = 啟動遊戲 +Loading... = 正在載入… MB = MB Size = 大小 Uninstall = 解除安裝 [SysInfo] -%d (%d per core, %d cores) = %d (每核心 %d 綫程, %d 核心) -%d bytes = %d 字節 -(none detected) = (未檢測到) +%d (%d per core, %d cores) = %d (每核心 %d 執行緒,%d 核心) +%d bytes = %d 位元組 +(none detected) = (未偵測到) 3D API = 3D API ABI = ABI -API Version = API版本 -Audio Information = 音頻信息 -Board = 主板 -Build Config = 編譯配置 -Build Configuration = 編譯配置 -Built by = 編譯者 -Core Context = 核心上下文 +API Version = API 版本 +Audio Information = 音訊資訊 +Board = 主機板 +Build Config = 組建組態 +Build Configuration = 組建組態 +Built by = 建置者 +Core Context = 核心內容 Cores = 核心數 -CPU Extensions = CPU擴展 -CPU Information = CPU信息 -CPU Name = CPU名稱 -D3DCompiler Version = D3DCompiler版本 -Debug = 調試 -Debugger Present = 調試器已連接 -Device Info = 設備信息 -Directories = 路徑 -Display Color Formats = 顯示顔色格式 -Display Information = 顯示信息 -Driver Version = 驅動程序版本 -EGL Extensions = EGL擴展 -Frames per buffer = 每緩存區幀數 -GPU Information = GPU信息 -High precision float range = 高精度浮點範圍 -High precision int range = 高精度整數範圍 +CPU Extensions = CPU 擴充 +CPU Information = CPU 資訊 +CPU Name = CPU 名稱 +D3DCompiler Version = D3DCompiler 版本 +Debug = 偵錯 +Debugger Present = 偵錯工具呈現 +Device Info = 裝置資訊 +Directories = 目錄 +Display Information = 顯示器資訊 +Driver bugs = 驅動程式錯誤 +Driver Version = 驅動程式版本 +EGL Extensions = EGL 擴充 +Frames per buffer = 每緩衝區影格數 +GPU Information = GPU 資訊 +High precision float range = 高精確度浮點數範圍 +High precision int range = 高精確度整數範圍 Lang/Region = 語言/區域 -Memory Page Size = 内存頁大小 -Native Resolution = 原生分辨率 -OGL Extensions = OGL 擴展 -OpenGL ES 2.0 Extensions = OpenGL ES 2.0擴展 -OpenGL ES 3.0 Extensions = OpenGL ES 3.0擴展 -OpenGL Extensions = OpenGL擴展 -Optimal frames per buffer = 最佳每緩存區幀數 -Optimal sample rate = 最佳采樣率 -OS Information = OS信息 -PPSSPP build = PPSSPP編譯版本 -Refresh rate = 刷新率 -Release = 發佈 -RW/RX exclusive = RW/RX獨占 -Sample rate = 采樣率 -Shading Language = 著色語言 -Storage = 存儲 -Sustained perf mode = 持久性能模式 -System Information = 系統信息 +Memory Page Size = 記憶體分頁大小 +Native Resolution = 原生解析度 +No GPU driver bugs detected = 未偵測到 GPU 驅動程式錯誤 +OGL Extensions = OGL 擴充 +OpenGL ES 2.0 Extensions = OpenGL ES 2.0 擴充 +OpenGL ES 3.0 Extensions = OpenGL ES 3.0 擴充 +OpenGL Extensions = OpenGL 擴充 +Optimal frames per buffer = 最佳每緩衝區影格數 +Optimal sample rate = 最佳取樣率 +OS Information = OS 資訊 +PPSSPP build = PPSSPP 組建 +Refresh rate = 重新整理速率 +Release = 發行版本 +RW/RX exclusive = RW/RX 排除 +Sample rate = 取樣率 +Shading Language = 網底語言 +Storage = 儲存空間 +Sustained perf mode = 持續效能模式 +System Information = 系統資訊 System Name = 系統名稱 System Version = 系統版本 -Threads = 綫程數 -Vendor = 供應商 -Vendor (detected) = 供應商 (已檢測到的) -Version Information = 版本信息 -Vulkan Extensions = Vulkan擴展 -Vulkan Features = Vulkan特性 -Driver bugs = 驅動錯誤 -No GPU driver bugs detected = 未檢測到GPU驅動錯誤 +Threads = 執行緒 +Vendor = 廠商 +Vendor (detected) = 廠商 (偵測到) +Version Information = 版本資訊 +Vulkan Extensions = Vulkan 擴充 +Vulkan Features = Vulkan 功能 +Display Color Formats = 顯示器色彩格式 [System] -(broken) = (壞了) -12HR = 12小時 -24HR = 24小時 +(broken) = (已損毀) +12HR = 12 小時制 +24HR = 24 小時制 Auto = 自動 -Auto Load Savestate = 自動加載保存狀態 -AVI Dump started. = AVI轉儲開始 -AVI Dump stopped. = AVI轉儲停止 -Cache ISO in RAM = 將整個ISO檔暫存於記憶體中 -Change CPU Clock = 調整CPU時鐘(不穩定) -Color Tint = 色調 -Color Saturation = 顔色飽和度 -Error: load undo state is from a different game = 錯誤: 撤回的即時存檔來自不同游戲 -Failed to load state for load undo. Error in the file system. = 無法撤銷加載的即時存檔,文件系統有錯誤。 -Floating symbols = 漂浮的符號 -Memory Stick folder = 更改記憶棒文件夾 -Memory Stick size = 更改記憶棒大小(GB) -Change Nickname = 更改別名 -ChangingMemstickPath = 游戲存檔、即時存檔以及其他數據不會被複製到新路徑。\n\n確定要修改記憶棒文件嗎? -ChangingMemstickPathInvalid = 目標路徑不能用於保存記憶棒數據。 -Cheats = 金手指 -Clear Recent = 清除最近的游戲 -Clear Recent Games List = 清除最近遊戲清單 -Clear UI background = 清除背景 -Confirmation Button = 確認鍵 +Auto Load Savestate = 自動載入存檔 +AVI Dump started. = AVI 傾印已啟動 +AVI Dump stopped. = AVI 傾印已停止 +Cache ISO in RAM = 將完整 ISO 快取於 RAM +Change CPU Clock = 變更模擬 PSP CPU 時脈 (不穩定) +Memory Stick folder = 記憶棒資料夾 +Memory Stick size = 記憶棒大小 +Change Nickname = 變更暱稱 +ChangingMemstickPath = 遊戲、存檔和其他資料將不會複製到這個資料夾\n\n要變更記憶棒資料夾嗎? +ChangingMemstickPathInvalid = 這個路徑將無法用於儲存記憶棒檔案 +Cheats = 密技 +Clear Recent = 清除「最近遊玩」 +Clear Recent Games List = 清除「最近遊玩」清單 +Clear UI background = 清除 UI 背景 +Confirmation Button = 確認按鈕 Date Format = 日期格式 Day Light Saving = 日光節約時間 -DDMMYYYY = DDMMYYYY -Decrease size = 減少尺寸 -Developer Tools = 開發者工具 -Display Extra Info = 顯示額外信息 -Display Games on a grid = 以方格顯示“游戲” -Display Homebrew on a grid = 以方格顯示 "自製游戲" -Display Recent on a grid = 以方格顯示最近的游戲 -Dynarec (JIT) = 動態重編譯(JIT) +DDMMYYYY = 日/月/年 +Decrease size = 減小尺寸 +Developer Tools = 開發人員工具 +Display Extra Info = 顯示額外資訊 +Display Games on a grid = 以格狀顯示「遊戲」 +Display Homebrew on a grid = 以格狀顯示「自製遊戲與試玩」 +Display Recent on a grid = 以格狀顯示「最近遊玩」 +Dynarec (JIT) = 動態重新編譯 (JIT) Emulation = 模擬 -Enable Cheats = 啓用金手指 -Enable Compatibility Server Reports = 向伺服器回報相容性問題 -Failed to load state. Error in the file system. = 無法讀取即時存檔。檔案系統錯誤。 -Failed to save state. Error in the file system. = 無法儲存即時存檔。檔案系統錯誤。 -Fast (lag on slow storage) = 快速 (存取較慢的系統仍會延遲) -Fast Memory = 快速記憶體存取(不穩定) -Force real clock sync (slower, less lag) = 強制實際時鐘同步(速度較慢,但較少延遲) -frames, 0:off = 幀,0 = 關閉 -Games list settings = 游戲列表配置 +Enable Cheats = 啟用密技 +Enable Compatibility Server Reports = 啟用相容性伺服器回報 +Error: load undo state is from a different game = 錯誤:載入復原存檔來自不同遊戲 +Failed to load state. Error in the file system. = 無法載入存檔,檔案系統錯誤 +Failed to save state. Error in the file system. = 無法儲存存檔,檔案系統錯誤 +Failed to load state for load undo. Error in the file system. = 無法載入復原存檔,檔案系統錯誤 +Fast (lag on slow storage) = 快速 (慢速儲存體延遲) +Fast Memory = 快速記憶體 (不穩定) +Floating symbols = 浮動符號 +Force real clock sync (slower, less lag) = 強制真實時脈同步 (更慢,減少延遲) +frames, 0:off = 影格,0 = 關閉 +Games list settings = 遊戲清單設定 General = 一般 -Grid icon size = 倍率圖標尺寸 -Help the PPSSPP team = 幫助PPSSPP團隊 -Host (bugs, less lag) = 主機(較少延遲,但可能造成問題;有助於魔法少女小圓) -Ignore bad memory accesses = 忽略錯誤的內存訪問 -Increase size = 增加大小 -Interpreter = 解釋器 -IO timing method = I/O計時方法 -IR Interpreter = IR解釋器 -Memory Stick Folder = 記憶棒文件夾 -Memory Stick inserted = 插入記憶棒 -MHz, 0:default = MHz,預設為0 -MMDDYYYY = MMDDYYYY -Moving background = 動態壁紙 -Newest Save = 最新存礑 -No animation = 靜態壁紙 -Not a PSP game = 不是PSP遊戲 +Grid icon size = 格狀圖示大小 +Help the PPSSPP team = 協助 PPSSPP 團隊 +Host (bugs, less lag) = 主機 (更多錯誤,減少延遲) +Ignore bad memory accesses = 忽略損毀的記憶體存取 +Increase size = 加大尺寸 +Interpreter = 解譯器 +IO timing method = I/O 計時方法 +IR Interpreter = IR 解譯器 +Memory Stick Folder = 記憶棒資料夾 +Memory Stick inserted = 記憶棒已插入 +MHz, 0:default = MHz,0 = 預設 +MMDDYYYY = 月/日/年 +Moving background = 動態背景 +Newest Save = 最新存檔 +No animation = 靜態背景 +Not a PSP game = 這不是 PSP 遊戲 Off = 關閉 -Oldest Save = 最早存礑 -Path does not exist! = 路徑不存在! -PSP Memory Stick = PSP記憶棒 -PSP Model = PSP機型 +Oldest Save = 最舊存檔 +Path does not exist! = 路徑不存在! +PSP Memory Stick = PSP 記憶棒 +PSP Model = PSP 型號 PSP Settings = PSP 設定 PSP-1000 = PSP-1000 PSP-2000/3000 = PSP-2000/3000 -Recent games = 最近的游戲 -Record Audio = 錄音 -Record Display = 錄製畫面 -Reset Recording on Save/Load State = 在保存/加載狀態下重置記錄 -Restore Default Settings = 還原出廠設定 -Rewind Snapshot Frequency = 快照倒回頻率 -Save path in installed.txt = 存檔路徑在installed.txt -Save path in My Documents = 存檔路徑在我的文件 -Savestate Slot = 即時存檔插槽 -Savestate slot backups = 即時存檔插槽備份 -Screenshots as PNG = PNG格式截圖 -Set UI background... = 配置UI背景... -Show ID = 顯示ID -Show Memory Stick folder = 顯示記憶棒文件夾 -Show region flag = 顯示區域標誌 -Simulate UMD delays = 模擬UMD延遲(修正紙箱戰機W) -Slot 1 = 插槽1 -Slot 2 = 插槽2 -Slot 3 = 插槽3 -Slot 4 = 插槽4 -Slot 5 = 插槽5 -Storage full = 存儲容量已滿 -Sustained performance mode = 持續性能模式 -Theme = 主題 +Recent games = 最近遊戲 +Record Audio = 錄製音訊 +Record Display = 錄製視訊 +Reset Recording on Save/Load State = 儲存/載入存檔時重設錄製 +Restore Default Settings = 將 PPSSPP 設定重設為預設值 +Rewind Snapshot Frequency = 倒轉快照頻率 +Save path in installed.txt = 儲存路徑於 installed.txt +Save path in My Documents = 儲存路徑於「我的文件」 +Savestate Slot = 存檔插槽 +Savestate slot backups = 存檔插槽備份 +Screenshots as PNG = 以 PNG 格式儲存螢幕截圖 +Set UI background... = 設定 UI 背景… +Show ID = 顯示 ID +Show region flag = 顯示區域旗幟 +Simulate UMD delays = 模擬 UMD 延遲 +Slot 1 = 插槽 1 +Slot 2 = 插槽 2 +Slot 3 = 插槽 3 +Slot 4 = 插槽 4 +Slot 5 = 插槽 5 +Storage full = 儲存空間已滿 +Sustained performance mode = 持續效能模式 Time Format = 時間格式 -UI = 用戶界面 -UI background animation = UI背景效果 -UI Sound = 介面聲音 -undo %c = 備用 %c +UI = UI +UI Sound = UI 音效 +UI background animation = UI 背景動畫 +undo %c = 備份 %c USB = USB -Use Lossless Video Codec (FFV1) = 使用無損視訊轉碼器(FFV1) -Use O to confirm = 使用O確認 -Use output buffer (with overlay) for recording =使用輸出緩衝區(帶有覆蓋)進行記錄 -Use system native keyboard = 使用系統本機鍵盤 -Use X to confirm = 使用X確認 +Use Lossless Video Codec (FFV1) = 使用不失真視訊轉碼器 (FFV1) +Use O to confirm = 使用 O 作為確認按鈕 +Use output buffer (with overlay) for recording = 為錄製使用輸出緩衝區 (覆疊) +Use system native keyboard = 使用系統原生鍵盤 +Use X to confirm = 使用 X 作為確認按鈕 VersionCheck = 檢查 PPSSPP 新版本 -WARNING: Android battery save mode is on = 警告:Android省電模式已開啟 +WARNING: Android battery save mode is on = 警告:Android 省電模式已開啟 WARNING: Battery save mode is on = 警告:省電模式已開啟 Waves = 波浪 -YYYYMMDD = YYYYMMDD +YYYYMMDD = 年/月/日 Theme = 主題 -Show Memory Stick folder = 顯示記憶棒文件夾 +Color Tint = 色彩濃淡 +Color Saturation = 色彩飽和度 +Show Memory Stick folder = 顯示記憶棒資料夾 + +[Themes] +Default = 預設 [TextureShaders] Off = 關閉 @@ -1209,29 +1197,27 @@ TexMMPX = TexMMPX Tex2xBRZ = Tex2xBRZ Tex4xBRZ = Tex4xBRZ -[Themes] -Default = 默認 +[Search] +No settings matched '%1' = 沒有與「%1」相符的設定 +Filtering settings by '%1' = 依「%1」篩選設定 +Find settings = 尋找設定 +Filter = 篩選器 +Clear filter = 清除篩選器 + +[Upgrade] +Details = 詳細資料 +Dismiss = 關閉 +Download = 下載 +New version of PPSSPP available = PPSSPP 有可用的新版本 [UI Elements] %1 button = %1 按鈕 -%1 checkbox = %1 複選框 +%1 checkbox = %1 核取方塊 %1 choice = %1 選擇 -%1 heading = %1 heading -%1 radio button = %1 單選按鈕 -%1 text field = %1 文本域 -Choices: = 選擇: -List: = 列表: -Progress: %1% = 進程: %1% -Screen representation = 屏幕表現 -[Upgrade] -Details = 詳情 -Dismiss = 忽略 -Download = 下載 -New version of PPSSPP available = 已有新版的PPSSPP - -[Search] -Filtering settings by '%1' = 配置篩選 '%1' -Find settings = 搜索配置 -Filter = 篩選 -Clear filter = 清楚篩選 -No settings matched '%1' = 未找到配置 '%1' +%1 heading = %1 標題 +%1 radio button = %1 選項按鈕 +%1 text field = %1 文字欄位 +Choices: = 選擇: +List: = 清單: +Progress: %1% = 進度:%1% +Screen representation = 螢幕呈現 From 7a620962aa9c4d0e5e5fb2851c15b42c11b74dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 Oct 2022 19:17:29 +0200 Subject: [PATCH 247/374] thin3d: Replace hint at future MRT support with basic multi layer support --- Common/GPU/D3D11/thin3d_d3d11.cpp | 61 ++++++++++++----------- Common/GPU/D3D9/thin3d_d3d9.cpp | 3 ++ Common/GPU/OpenGL/thin3d_gl.cpp | 3 ++ Common/GPU/Vulkan/VulkanRenderManager.cpp | 13 +++-- Common/GPU/Vulkan/VulkanRenderManager.h | 6 ++- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- Common/GPU/thin3d.h | 2 +- 7 files changed, 50 insertions(+), 40 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index ddbdecb0aa..45e67adb1d 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -1306,35 +1306,38 @@ public: Framebuffer *D3D11DrawContext::CreateFramebuffer(const FramebufferDesc &desc) { HRESULT hr; D3D11Framebuffer *fb = new D3D11Framebuffer(desc.width, desc.height); - if (desc.numColorAttachments) { - fb->colorFormat = DXGI_FORMAT_R8G8B8A8_UNORM; - D3D11_TEXTURE2D_DESC descColor{}; - descColor.Width = desc.width; - descColor.Height = desc.height; - descColor.MipLevels = 1; - descColor.ArraySize = 1; - descColor.Format = fb->colorFormat; - descColor.SampleDesc.Count = 1; - descColor.SampleDesc.Quality = 0; - descColor.Usage = D3D11_USAGE_DEFAULT; - descColor.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; - descColor.CPUAccessFlags = 0; - descColor.MiscFlags = 0; - hr = device_->CreateTexture2D(&descColor, nullptr, &fb->colorTex); - if (FAILED(hr)) { - delete fb; - return nullptr; - } - hr = device_->CreateRenderTargetView(fb->colorTex, nullptr, &fb->colorRTView); - if (FAILED(hr)) { - delete fb; - return nullptr; - } - hr = device_->CreateShaderResourceView(fb->colorTex, nullptr, &fb->colorSRView); - if (FAILED(hr)) { - delete fb; - return nullptr; - } + + // We don't (yet?) support multiview for D3D11. Not sure if there's a way to do it. + // Texture arrays are supported but we don't have any other use cases yet. + _dbg_assert_(desc.numLayers == 1); + + fb->colorFormat = DXGI_FORMAT_R8G8B8A8_UNORM; + D3D11_TEXTURE2D_DESC descColor{}; + descColor.Width = desc.width; + descColor.Height = desc.height; + descColor.MipLevels = 1; + descColor.ArraySize = 1; + descColor.Format = fb->colorFormat; + descColor.SampleDesc.Count = 1; + descColor.SampleDesc.Quality = 0; + descColor.Usage = D3D11_USAGE_DEFAULT; + descColor.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; + descColor.CPUAccessFlags = 0; + descColor.MiscFlags = 0; + hr = device_->CreateTexture2D(&descColor, nullptr, &fb->colorTex); + if (FAILED(hr)) { + delete fb; + return nullptr; + } + hr = device_->CreateRenderTargetView(fb->colorTex, nullptr, &fb->colorRTView); + if (FAILED(hr)) { + delete fb; + return nullptr; + } + hr = device_->CreateShaderResourceView(fb->colorTex, nullptr, &fb->colorSRView); + if (FAILED(hr)) { + delete fb; + return nullptr; } if (desc.z_stencil) { diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 162c8febec..80ee1bec97 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -1244,6 +1244,9 @@ public: }; Framebuffer *D3D9Context::CreateFramebuffer(const FramebufferDesc &desc) { + // Don't think D3D9 does array layers. + _dbg_assert_(desc.numLayers == 1); + static uint32_t id = 0; D3D9Framebuffer *fbo = new D3D9Framebuffer(desc.width, desc.height); diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 91f89e7807..f3ade40b9a 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -1390,6 +1390,9 @@ void OpenGLInputLayout::Compile(const InputLayoutDesc &desc) { Framebuffer *OpenGLContext::CreateFramebuffer(const FramebufferDesc &desc) { CheckGLExtensions(); + // TODO: Support multiview later. (It's our only use case for multi layers). + _dbg_assert_(desc.numLayers == 1); + GLRFramebuffer *framebuffer = renderManager_.CreateFramebuffer(desc.width, desc.height, desc.z_stencil); OpenGLFramebuffer *fbo = new OpenGLFramebuffer(&renderManager_, framebuffer); return fbo; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 8da78975d2..a3bce70e0d 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -155,15 +155,14 @@ bool VKRComputePipeline::Create(VulkanContext *vulkan) { return success; } -VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, bool createDepthStencilBuffer, const char *tag) : vulkan_(vk), tag_(tag) { - width = _width; - height = _height; +VKRFramebuffer::VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, int _numLayers, bool createDepthStencilBuffer, const char *tag) + : vulkan_(vk), tag_(tag), width(_width), height(_height), numLayers(_numLayers) { _dbg_assert_(tag); - CreateImage(vulkan_, initCmd, color, width, height, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true, tag); + CreateImage(vulkan_, initCmd, color, width, height, numLayers, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, true, tag); if (createDepthStencilBuffer) { - CreateImage(vulkan_, initCmd, depth, width, height, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false, tag); + CreateImage(vulkan_, initCmd, depth, width, height, numLayers, vulkan_->GetDeviceInfo().preferredDepthStencilFormat, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, false, tag); } UpdateTag(tag); @@ -243,9 +242,9 @@ VKRFramebuffer::~VKRFramebuffer() { } } -void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int width, int height, VkFormat format, VkImageLayout initialLayout, bool color, const char *tag) { +void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int width, int height, int numLayers, VkFormat format, VkImageLayout initialLayout, bool color, const char *tag) { VkImageCreateInfo ici{ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; - ici.arrayLayers = 1; + ici.arrayLayers = numLayers; ici.mipLevels = 1; ici.extent.width = width; ici.extent.height = height; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 074e0c1db4..97771514e0 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -40,17 +40,19 @@ struct VKRImage { // For debugging. std::string tag; }; -void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int width, int height, VkFormat format, VkImageLayout initialLayout, bool color, const char *tag); +void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int width, int height, int numLayers, VkFormat format, VkImageLayout initialLayout, bool color, const char *tag); class VKRFramebuffer { public: - VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, bool createDepthStencilBuffer, const char *tag); + VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, int _numLayers, bool createDepthStencilBuffer, const char *tag); ~VKRFramebuffer(); VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType); int width = 0; int height = 0; + int numLayers = 0; + VKRImage color{}; // color.image is always there. VKRImage depth{}; // depth.image is allowed to be VK_NULL_HANDLE. diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index cedb21b49f..0c03d240ed 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1505,7 +1505,7 @@ private: Framebuffer *VKContext::CreateFramebuffer(const FramebufferDesc &desc) { VkCommandBuffer cmd = renderManager_.GetInitCmd(); - VKRFramebuffer *vkrfb = new VKRFramebuffer(vulkan_, cmd, renderManager_.GetQueueRunner()->GetCompatibleRenderPass(), desc.width, desc.height, desc.z_stencil, desc.tag); + VKRFramebuffer *vkrfb = new VKRFramebuffer(vulkan_, cmd, renderManager_.GetQueueRunner()->GetCompatibleRenderPass(), desc.width, desc.height, desc.z_stencil, desc.numLayers, desc.tag); return new VKFramebuffer(vkrfb); } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 2d9ce7f8c5..7c3a6d240d 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -293,7 +293,7 @@ struct FramebufferDesc { int width; int height; int depth; - int numColorAttachments; + int numLayers; bool z_stencil; const char *tag; // For graphics debuggers }; From d3804ec2e593ed9cedaccacf3041689a83ed3fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 9 Oct 2022 20:19:39 +0200 Subject: [PATCH 248/374] Misc multiview hackery --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 18 ++++++++++++++++-- Common/GPU/Vulkan/VulkanQueueRunner.h | 18 +++++++++++++++--- GPU/Common/TextureCacheCommon.cpp | 2 +- GPU/Common/VertexShaderGenerator.cpp | 5 ++++- GPU/Common/VertexShaderGenerator.h | 8 +++++++- GPU/D3D11/ShaderManagerD3D11.cpp | 2 +- GPU/Directx9/ShaderManagerDX9.cpp | 4 ++-- GPU/GLES/ShaderManagerGLES.cpp | 2 +- GPU/Vulkan/PipelineManagerVulkan.cpp | 3 +++ GPU/Vulkan/ShaderManagerVulkan.cpp | 16 +++++++++------- GPU/Vulkan/ShaderManagerVulkan.h | 6 ++++-- unittest/TestShaderGenerators.cpp | 10 +++++----- 12 files changed, 68 insertions(+), 26 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 98bd2e7773..5873c3e974 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -326,9 +326,10 @@ static VkAttachmentStoreOp ConvertStoreAction(VKRRenderPassStoreAction action) { // Also see https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#synchronization-pipeline-barriers-subpass-self-dependencies VkRenderPass CreateRenderPass(VulkanContext *vulkan, const RPKey &key, RenderPassType rpType) { - bool selfDependency = rpType == RP_TYPE_COLOR_INPUT || rpType == RP_TYPE_COLOR_DEPTH_INPUT; + bool selfDependency = RenderPassTypeHasInput(rpType); bool isBackbuffer = rpType == RP_TYPE_BACKBUFFER; - bool hasDepth = rpType == RP_TYPE_BACKBUFFER || rpType == RP_TYPE_COLOR_DEPTH || rpType == RP_TYPE_COLOR_DEPTH_INPUT; + bool hasDepth = RenderPassTypeHasDepth(rpType); + bool multiview = RenderPassTypeHasMultiView(rpType); VkAttachmentDescription attachments[2] = {}; attachments[0].format = isBackbuffer ? vulkan->GetSwapchainFormat() : VK_FORMAT_R8G8B8A8_UNORM; @@ -390,6 +391,19 @@ VkRenderPass CreateRenderPass(VulkanContext *vulkan, const RPKey &key, RenderPas rp.subpassCount = 1; rp.pSubpasses = &subpass; + VkRenderPassMultiviewCreateInfoKHR mv{ VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR }; + uint32_t viewMask = 0x3; // Must be outside the 'if (multiview)' scope! + int viewOffset = 0; + if (multiview) { + rp.pNext = &mv; + mv.subpassCount = 1; + mv.pViewMasks = &viewMask; + mv.dependencyCount = 0; + mv.pCorrelationMasks = &viewMask; // same masks + mv.correlationMaskCount = 1; + mv.pViewOffsets = &viewOffset; + } + if (isBackbuffer) { deps[numDeps].srcSubpass = VK_SUBPASS_EXTERNAL; deps[numDeps].dstSubpass = 0; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index ab0bc3ac71..d5ea7163ed 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -48,18 +48,24 @@ enum class PipelineFlags { USES_DEPTH_STENCIL = (1 << 2), // Reads or writes the depth or stencil buffers. USES_INPUT_ATTACHMENT = (1 << 3), USES_GEOMETRY_SHADER = (1 << 4), + USES_MULTIVIEW = (1 << 5), // Inherited from the render pass it was created with. }; ENUM_CLASS_BITOPS(PipelineFlags); // Pipelines need to be created for the right type of render pass. enum RenderPassType { - // These four are organized so that bit 0 is DEPTH and bit 1 is INPUT, so + // These eight are organized so that bit 0 is DEPTH and bit 1 is INPUT and bit 2 is MULTIVIEW, so // they can be OR-ed together in MergeRPTypes. RP_TYPE_COLOR, RP_TYPE_COLOR_DEPTH, RP_TYPE_COLOR_INPUT, RP_TYPE_COLOR_DEPTH_INPUT, + RP_TYPE_MULTIVIEW_COLOR, + RP_TYPE_MULTIVIEW_COLOR_DEPTH, + RP_TYPE_MULTIVIEW_COLOR_INPUT, + RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT, + // This is the odd one out, and gets special handling in MergeRPTypes. RP_TYPE_BACKBUFFER, // For the backbuffer we can always use CLEAR/DONT_CARE, so bandwidth cost for a depth channel is negligible. @@ -67,12 +73,18 @@ enum RenderPassType { RP_TYPE_COUNT, }; +// Hm, soon time to exploit the bit properties in these.. + inline bool RenderPassTypeHasDepth(RenderPassType type) { - return type == RP_TYPE_BACKBUFFER || type == RP_TYPE_COLOR_DEPTH || type == RP_TYPE_COLOR_DEPTH_INPUT; + return type == RP_TYPE_BACKBUFFER || type == RP_TYPE_COLOR_DEPTH || type == RP_TYPE_COLOR_DEPTH_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT; } inline bool RenderPassTypeHasInput(RenderPassType type) { - return type == RP_TYPE_COLOR_INPUT || type == RP_TYPE_COLOR_DEPTH_INPUT; + return type == RP_TYPE_COLOR_INPUT || type == RP_TYPE_COLOR_DEPTH_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT; +} + +inline bool RenderPassTypeHasMultiView(RenderPassType type) { + return type == RP_TYPE_MULTIVIEW_COLOR || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH || type == RP_TYPE_MULTIVIEW_COLOR_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT; } struct VkRenderData { diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 3877b2df22..a1ed25094b 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -1295,7 +1295,7 @@ void TextureCacheCommon::LoadClut(u32 clutAddr, u32 loadBytes) { desc.height = 1; desc.depth = 1; desc.z_stencil = false; - desc.numColorAttachments = 1; + desc.numLayers = 1; desc.tag = "dynamic_clut"; dynamicClutFbo_ = draw_->CreateFramebuffer(desc); desc.tag = "dynamic_clut_temp"; diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 5b7e321277..b0c3cbca50 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -126,9 +126,12 @@ static const char * const boneWeightDecl[9] = { "layout(location = 3) in vec4 w1;\nlayout(location = 4) in vec4 w2;\n", }; -bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguageDesc &compat, Draw::Bugs bugs, uint32_t *attrMask, uint64_t *uniformMask, std::string *errorString) { +bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguageDesc &compat, Draw::Bugs bugs, uint32_t *attrMask, uint64_t *uniformMask, VertexShaderFlags *vertexShaderFlags, std::string *errorString) { *attrMask = 0; *uniformMask = 0; + if (vertexShaderFlags) { + *vertexShaderFlags = (VertexShaderFlags)0; + } bool highpFog = false; bool highpTexcoord = false; diff --git a/GPU/Common/VertexShaderGenerator.h b/GPU/Common/VertexShaderGenerator.h index c1899001e6..9d3707411c 100644 --- a/GPU/Common/VertexShaderGenerator.h +++ b/GPU/Common/VertexShaderGenerator.h @@ -25,7 +25,13 @@ struct VShaderID; -bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguageDesc &compat, const Draw::Bugs bugs, uint32_t *attrMask, uint64_t *uniformMask, std::string *errorString); +// Can technically be deduced from the vertex shader ID, but this is safer. +enum class VertexShaderFlags : u32 { + MULTI_VIEW = 1, +}; +ENUM_CLASS_BITOPS(VertexShaderFlags); + +bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguageDesc &compat, const Draw::Bugs bugs, uint32_t *attrMask, uint64_t *uniformMask, VertexShaderFlags *vertexShaderFlags, std::string *errorString); // D3D9 constants. enum { diff --git a/GPU/D3D11/ShaderManagerD3D11.cpp b/GPU/D3D11/ShaderManagerD3D11.cpp index 0560b52941..0c9fec1817 100644 --- a/GPU/D3D11/ShaderManagerD3D11.cpp +++ b/GPU/D3D11/ShaderManagerD3D11.cpp @@ -212,7 +212,7 @@ void ShaderManagerD3D11::GetShaders(int prim, u32 vertType, D3D11VertexShader ** std::string genErrorString; uint32_t attrMask; uint64_t uniformMask; - GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, &genErrorString); + GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, nullptr, &genErrorString); _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); vs = new D3D11VertexShader(device_, featureLevel_, VSID, codeBuffer_, vertType, useHWTransform); vsCache_[VSID] = vs; diff --git a/GPU/Directx9/ShaderManagerDX9.cpp b/GPU/Directx9/ShaderManagerDX9.cpp index 6e20ec45e0..1e56e5ab37 100644 --- a/GPU/Directx9/ShaderManagerDX9.cpp +++ b/GPU/Directx9/ShaderManagerDX9.cpp @@ -581,7 +581,7 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat std::string genErrorString; uint32_t attrMask; uint64_t uniformMask; - if (GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, &genErrorString)) { + if (GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, nullptr, &genErrorString)) { vs = new VSShader(device_, VSID, codeBuffer_, useHWTransform); } if (!vs || vs->Failed()) { @@ -606,7 +606,7 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat // Can still work with software transform. uint32_t attrMask; uint64_t uniformMask; - bool success = GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, &genErrorString); + bool success = GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, nullptr, &genErrorString); _assert_(success); vs = new VSShader(device_, VSID, codeBuffer_, false); } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 3bdd9c4f86..e4a6350de1 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -743,7 +743,7 @@ Shader *ShaderManagerGLES::CompileVertexShader(VShaderID VSID) { uint32_t attrMask; uint64_t uniformMask; std::string errorString; - if (!GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, &errorString)) { + if (!GenerateVertexShader(VSID, codeBuffer_, draw_->GetShaderLanguageDesc(), draw_->GetBugs(), &attrMask, &uniformMask, nullptr, &errorString)) { ERROR_LOG(G3D, "Shader gen error: %s", errorString.c_str()); return nullptr; } diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 3d7745b452..95b019483b 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -336,6 +336,9 @@ VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VulkanRenderManager * if (fs->Flags() & FragmentShaderFlags::INPUT_ATTACHMENT) { pipelineFlags |= PipelineFlags::USES_INPUT_ATTACHMENT; } + if (vs->Flags() & VertexShaderFlags::MULTI_VIEW) { + pipelineFlags |= PipelineFlags::USES_MULTIVIEW; + } VulkanPipeline *pipeline = CreateVulkanPipeline( renderManager, pipelineCache_, layout, pipelineFlags, diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 249078cf43..6356f43e0a 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -135,8 +135,8 @@ std::string VulkanFragmentShader::GetShaderString(DebugShaderStringType type) co } } -VulkanVertexShader::VulkanVertexShader(VulkanContext *vulkan, VShaderID id, const char *code, bool useHWTransform) - : vulkan_(vulkan), useHWTransform_(useHWTransform), id_(id) { +VulkanVertexShader::VulkanVertexShader(VulkanContext *vulkan, VShaderID id, VertexShaderFlags flags, const char *code, bool useHWTransform) + : vulkan_(vulkan), useHWTransform_(useHWTransform), flags_(flags), id_(id) { source_ = code; module_ = CompileShaderModuleAsync(vulkan, VK_SHADER_STAGE_VERTEX_BIT, source_.c_str(), new std::string(VertexShaderDesc(id))); if (!module_) { @@ -331,10 +331,11 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader std::string genErrorString; uint64_t uniformMask = 0; // Not used uint32_t attributeMask = 0; // Not used - bool success = GenerateVertexShader(VSID, codeBuffer_, compat_, draw_->GetBugs(), &attributeMask, &uniformMask, &genErrorString); + VertexShaderFlags flags{}; + bool success = GenerateVertexShader(VSID, codeBuffer_, compat_, draw_->GetBugs(), &attributeMask, &uniformMask, &flags, &genErrorString); _assert_msg_(success, "VS gen error: %s", genErrorString.c_str()); _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); - vs = new VulkanVertexShader(vulkan, VSID, codeBuffer_, useHWTransform); + vs = new VulkanVertexShader(vulkan, VSID, flags, codeBuffer_, useHWTransform); vsCache_.Insert(VSID, vs); } @@ -343,7 +344,7 @@ void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader // Fragment shader not in cache. Let's compile it. std::string genErrorString; uint64_t uniformMask = 0; // Not used - FragmentShaderFlags flags; + FragmentShaderFlags flags{}; bool success = GenerateFragmentShader(FSID, codeBuffer_, compat_, draw_->GetBugs(), &uniformMask, &flags, &genErrorString); _assert_msg_(success, "FS gen error: %s", genErrorString.c_str()); _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "FS length error: %d", (int)strlen(codeBuffer_)); @@ -515,11 +516,12 @@ bool ShaderManagerVulkan::LoadCache(FILE *f) { std::string genErrorString; uint32_t attributeMask = 0; uint64_t uniformMask = 0; - if (!GenerateVertexShader(id, codeBuffer_, compat_, draw_->GetBugs(), &attributeMask, &uniformMask, &genErrorString)) { + VertexShaderFlags flags; + if (!GenerateVertexShader(id, codeBuffer_, compat_, draw_->GetBugs(), &attributeMask, &uniformMask, &flags, &genErrorString)) { return false; } _assert_msg_(strlen(codeBuffer_) < CODE_BUFFER_SIZE, "VS length error: %d", (int)strlen(codeBuffer_)); - VulkanVertexShader *vs = new VulkanVertexShader(vulkan, id, codeBuffer_, useHWTransform); + VulkanVertexShader *vs = new VulkanVertexShader(vulkan, id, flags, codeBuffer_, useHWTransform); vsCache_.Insert(id, vs); } uint32_t vendorID = vulkan->GetPhysicalDeviceProperties().properties.vendorID; diff --git a/GPU/Vulkan/ShaderManagerVulkan.h b/GPU/Vulkan/ShaderManagerVulkan.h index 4c89f91ef5..88f138d923 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.h +++ b/GPU/Vulkan/ShaderManagerVulkan.h @@ -61,13 +61,14 @@ protected: class VulkanVertexShader { public: - VulkanVertexShader(VulkanContext *vulkan, VShaderID id, const char *code, bool useHWTransform); + VulkanVertexShader(VulkanContext *vulkan, VShaderID id, VertexShaderFlags flags, const char *code, bool useHWTransform); ~VulkanVertexShader(); const std::string &source() const { return source_; } bool Failed() const { return failed_; } - bool UseHWTransform() const { return useHWTransform_; } + bool UseHWTransform() const { return useHWTransform_; } // TODO: Roll into flags + VertexShaderFlags Flags() const { return flags_; } std::string GetShaderString(DebugShaderStringType type) const; Promise *GetModule() { return module_; } @@ -81,6 +82,7 @@ protected: bool failed_ = false; bool useHWTransform_; VShaderID id_; + VertexShaderFlags flags_; }; class VulkanGeometryShader { diff --git a/unittest/TestShaderGenerators.cpp b/unittest/TestShaderGenerators.cpp index a9546408a5..a420299520 100644 --- a/unittest/TestShaderGenerators.cpp +++ b/unittest/TestShaderGenerators.cpp @@ -67,27 +67,27 @@ bool GenerateVShader(VShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs case ShaderLanguage::GLSL_VULKAN: { ShaderLanguageDesc compat(ShaderLanguage::GLSL_VULKAN); - return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, errorString); + return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, nullptr, errorString); } case ShaderLanguage::GLSL_1xx: { ShaderLanguageDesc compat(ShaderLanguage::GLSL_1xx); - return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, errorString); + return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, nullptr, errorString); } case ShaderLanguage::GLSL_3xx: { ShaderLanguageDesc compat(ShaderLanguage::GLSL_3xx); - return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, errorString); + return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, nullptr, errorString); } case ShaderLanguage::HLSL_D3D9: { ShaderLanguageDesc compat(ShaderLanguage::HLSL_D3D9); - return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, errorString); + return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, nullptr, errorString); } case ShaderLanguage::HLSL_D3D11: { ShaderLanguageDesc compat(ShaderLanguage::HLSL_D3D11); - return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, errorString); + return GenerateVertexShader(id, buffer, compat, bugs, &attrMask, &uniformMask, nullptr, errorString); } default: return false; From fb250c4b29642ae1477073a6aa0033b113f695b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 18 Oct 2022 00:26:10 +0200 Subject: [PATCH 249/374] More multiview work --- Common/GPU/D3D11/thin3d_d3d11.cpp | 15 ++-- Common/GPU/D3D9/thin3d_d3d9.cpp | 17 ++-- Common/GPU/OpenGL/thin3d_gl.cpp | 13 ++- Common/GPU/Vulkan/VulkanContext.cpp | 7 +- Common/GPU/Vulkan/VulkanContext.h | 2 +- Common/GPU/Vulkan/VulkanImage.cpp | 10 +-- Common/GPU/Vulkan/VulkanMemory.h | 10 +++ Common/GPU/Vulkan/VulkanQueueRunner.cpp | 23 +++-- Common/GPU/Vulkan/VulkanQueueRunner.h | 10 ++- Common/GPU/Vulkan/VulkanRenderManager.cpp | 100 ++++++++++++++++------ Common/GPU/Vulkan/VulkanRenderManager.h | 37 ++++++-- Common/GPU/Vulkan/thin3d_vulkan.cpp | 17 ++-- Common/GPU/thin3d.h | 11 ++- Common/UI/UIScreen.cpp | 2 +- GPU/Common/FragmentShaderGenerator.cpp | 7 +- GPU/Common/FramebufferManagerCommon.cpp | 55 +++++++----- GPU/Common/FramebufferManagerCommon.h | 6 +- GPU/Common/PresentationCommon.cpp | 14 +-- GPU/Common/ShaderId.cpp | 9 ++ GPU/Common/ShaderId.h | 2 + GPU/Common/ShaderUniforms.h | 10 +++ GPU/Common/StencilCommon.cpp | 6 +- GPU/Common/TextureCacheCommon.cpp | 16 ++-- GPU/D3D11/StateMappingD3D11.cpp | 2 +- GPU/Directx9/StateMappingDX9.cpp | 4 +- GPU/GLES/DepthBufferGLES.cpp | 8 +- GPU/GLES/FramebufferManagerGLES.cpp | 4 +- GPU/GLES/StateMappingGLES.cpp | 2 +- GPU/GPUState.h | 1 + GPU/Software/SoftGpu.cpp | 2 +- GPU/Vulkan/DrawEngineVulkan.cpp | 7 +- GPU/Vulkan/DrawEngineVulkan.h | 3 +- GPU/Vulkan/GPU_Vulkan.cpp | 5 ++ GPU/Vulkan/StateMappingVulkan.cpp | 2 +- UI/EmuScreen.cpp | 14 +-- Windows/PPSSPP.vcxproj | 1 + Windows/PPSSPP.vcxproj.filters | 3 + headless/Headless.cpp | 2 +- 38 files changed, 302 insertions(+), 157 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index 45e67adb1d..b7972d49ed 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -94,11 +94,8 @@ public: bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; - Framebuffer *GetCurrentRenderTarget() override { - return curRenderTarget_; - } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1658,7 +1655,8 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel return true; } -void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { +void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { + _dbg_assert_(layer == ALL_LAYERS || layer == 0); // No multiple layer support on D3D // TODO: deviceContext1 can actually discard. Useful on Windows Mobile. if (fbo) { D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo; @@ -1704,8 +1702,9 @@ void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const Ren stepId_++; } -void D3D11DrawContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { - _assert_(binding < MAX_BOUND_TEXTURES); +void D3D11DrawContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) { + _dbg_assert_(binding < MAX_BOUND_TEXTURES); + _dbg_assert_(layer == ALL_LAYERS || layer == 0); // No multiple layer support on D3D D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo; switch (channelBit) { case FBChannel::FB_COLOR_BIT: diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 80ee1bec97..ba51fb42fa 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -531,12 +531,9 @@ public: bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; - Framebuffer *GetCurrentRenderTarget() override { - return curRenderTarget_; - } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; - + void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; + uintptr_t GetFramebufferAPITexture(Framebuffer *fbo, int channelBits, int attachment) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1292,7 +1289,8 @@ D3D9Framebuffer::~D3D9Framebuffer() { } } -void D3D9Context::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { +void D3D9Context::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { + _dbg_assert_(layer == ALL_LAYERS || layer == 0); // No stereo support if (fbo) { D3D9Framebuffer *fb = (D3D9Framebuffer *)fbo; device_->SetRenderTarget(0, fb->surf); @@ -1351,8 +1349,9 @@ uintptr_t D3D9Context::GetFramebufferAPITexture(Framebuffer *fbo, int channelBit } } -void D3D9Context::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { - _assert_(binding < MAX_BOUND_TEXTURES); +void D3D9Context::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) { + _dbg_assert_(binding < MAX_BOUND_TEXTURES); + _dbg_assert_(layer == ALL_LAYERS || layer == 0); // No stereo support D3D9Framebuffer *fb = (D3D9Framebuffer *)fbo; switch (channelBit) { case FB_DEPTH_BIT: diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index f3ade40b9a..53f294c35d 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -354,11 +354,8 @@ public: bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; - Framebuffer *GetCurrentRenderTarget() override { - return curRenderTarget_; - } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1398,7 +1395,9 @@ Framebuffer *OpenGLContext::CreateFramebuffer(const FramebufferDesc &desc) { return fbo; } -void OpenGLContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { +void OpenGLContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { + _dbg_assert_(layer == ALL_LAYERS || layer == 0); + OpenGLFramebuffer *fb = (OpenGLFramebuffer *)fbo; GLRRenderPassAction color = (GLRRenderPassAction)rp.color; GLRRenderPassAction depth = (GLRRenderPassAction)rp.depth; @@ -1439,7 +1438,7 @@ bool OpenGLContext::BlitFramebuffer(Framebuffer *fbsrc, int srcX1, int srcY1, in return true; } -void OpenGLContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { +void OpenGLContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) { OpenGLFramebuffer *fb = (OpenGLFramebuffer *)fbo; _assert_(binding < MAX_TEXTURE_SLOTS); diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index a3bbf1f0ea..8a69c0f037 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -608,8 +608,7 @@ void VulkanContext::ChooseDevice(int physical_device) { deviceFeatures_.enabled.standard.geometryShader = deviceFeatures_.available.standard.geometryShader; deviceFeatures_.enabled.multiview = { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES }; - // Don't yet enable these. - // deviceFeatures_.enabled.multiview.multiview = deviceFeatures_.available.multiview.multiview; + deviceFeatures_.enabled.multiview.multiview = deviceFeatures_.available.multiview.multiview; // deviceFeatures_.enabled.multiview.multiviewGeometryShader = deviceFeatures_.available.multiview.multiviewGeometryShader; GetDeviceLayerExtensionList(nullptr, device_extension_properties_); @@ -1246,7 +1245,7 @@ bool VulkanContext::CreateShaderModule(const std::vector &spirv, VkSha } } -void TransitionImageLayout2(VkCommandBuffer cmd, VkImage image, int baseMip, int numMipLevels, VkImageAspectFlags aspectMask, +void TransitionImageLayout2(VkCommandBuffer cmd, VkImage image, int baseMip, int numMipLevels, int numLayers, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask) { @@ -1259,7 +1258,7 @@ void TransitionImageLayout2(VkCommandBuffer cmd, VkImage image, int baseMip, int image_memory_barrier.subresourceRange.aspectMask = aspectMask; image_memory_barrier.subresourceRange.baseMipLevel = baseMip; image_memory_barrier.subresourceRange.levelCount = numMipLevels; - image_memory_barrier.subresourceRange.layerCount = 1; // We never use more than one layer, and old Mali drivers have problems with VK_REMAINING_ARRAY_LAYERS/VK_REMAINING_MIP_LEVELS. + image_memory_barrier.subresourceRange.layerCount = numLayers; // We never use more than one layer, and old Mali drivers have problems with VK_REMAINING_ARRAY_LAYERS/VK_REMAINING_MIP_LEVELS. image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; vkCmdPipelineBarrier(cmd, srcStageMask, dstStageMask, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier); diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index 60ef6d373e..a7622e7a8f 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -441,7 +441,7 @@ private: }; // Detailed control. -void TransitionImageLayout2(VkCommandBuffer cmd, VkImage image, int baseMip, int mipLevels, VkImageAspectFlags aspectMask, +void TransitionImageLayout2(VkCommandBuffer cmd, VkImage image, int baseMip, int mipLevels, int numLayers, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask); diff --git a/Common/GPU/Vulkan/VulkanImage.cpp b/Common/GPU/Vulkan/VulkanImage.cpp index 72eb339c12..ad712b6a0f 100644 --- a/Common/GPU/Vulkan/VulkanImage.cpp +++ b/Common/GPU/Vulkan/VulkanImage.cpp @@ -87,7 +87,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i switch (initialLayout) { case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL: case VK_IMAGE_LAYOUT_GENERAL: - TransitionImageLayout2(cmd, image_, 0, numMips, VK_IMAGE_ASPECT_COLOR_BIT, + TransitionImageLayout2(cmd, image_, 0, numMips, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, initialLayout, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, VK_ACCESS_TRANSFER_WRITE_BIT); @@ -164,7 +164,7 @@ void VulkanTexture::GenerateMips(VkCommandBuffer cmd, int firstMipToGenerate, bo _assert_msg_(firstMipToGenerate < numMips_, "Can't generate levels beyond storage"); // Transition the pre-set levels to GENERAL. - TransitionImageLayout2(cmd, image_, 0, firstMipToGenerate, VK_IMAGE_ASPECT_COLOR_BIT, + TransitionImageLayout2(cmd, image_, 0, firstMipToGenerate, 1, VK_IMAGE_ASPECT_COLOR_BIT, fromCompute ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, fromCompute ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT : VK_PIPELINE_STAGE_TRANSFER_BIT, @@ -173,7 +173,7 @@ void VulkanTexture::GenerateMips(VkCommandBuffer cmd, int firstMipToGenerate, bo VK_ACCESS_TRANSFER_READ_BIT); // Do the same with the uninitialized levels. - TransitionImageLayout2(cmd, image_, firstMipToGenerate, numMips_ - firstMipToGenerate, + TransitionImageLayout2(cmd, image_, firstMipToGenerate, numMips_ - firstMipToGenerate, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, @@ -206,7 +206,7 @@ void VulkanTexture::GenerateMips(VkCommandBuffer cmd, int firstMipToGenerate, bo vkCmdBlitImage(cmd, image_, VK_IMAGE_LAYOUT_GENERAL, image_, VK_IMAGE_LAYOUT_GENERAL, 1, &blit, VK_FILTER_LINEAR); - TransitionImageLayout2(cmd, image_, mip, 1, VK_IMAGE_ASPECT_COLOR_BIT, + TransitionImageLayout2(cmd, image_, mip, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT); @@ -214,7 +214,7 @@ void VulkanTexture::GenerateMips(VkCommandBuffer cmd, int firstMipToGenerate, bo } void VulkanTexture::EndCreate(VkCommandBuffer cmd, bool vertexTexture, VkPipelineStageFlags prevStage, VkImageLayout layout) { - TransitionImageLayout2(cmd, image_, 0, numMips_, + TransitionImageLayout2(cmd, image_, 0, numMips_, 1, VK_IMAGE_ASPECT_COLOR_BIT, layout, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, prevStage, vertexTexture ? VK_PIPELINE_STAGE_VERTEX_SHADER_BIT : VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, diff --git a/Common/GPU/Vulkan/VulkanMemory.h b/Common/GPU/Vulkan/VulkanMemory.h index 79a71d4ce6..c0a9c1ed02 100644 --- a/Common/GPU/Vulkan/VulkanMemory.h +++ b/Common/GPU/Vulkan/VulkanMemory.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -121,6 +122,15 @@ public: return writePtr_ + off; } + template + void PushUBOData(const T &data, VkDescriptorBufferInfo *info) { + uint32_t bindOffset; + void *ptr = PushAligned(sizeof(T), &bindOffset, &info->buffer, vulkan_->GetPhysicalDeviceProperties().properties.limits.minUniformBufferOffsetAlignment); + memcpy(ptr, &data, sizeof(T)); + info->offset = bindOffset; + info->range = sizeof(T); + } + size_t GetTotalSize() const; private: diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 5873c3e974..07371dfba9 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -249,7 +249,7 @@ bool VulkanQueueRunner::InitDepthStencilBuffer(VkCommandBuffer cmd) { vulkan_->SetDebugName(depth_.image, VK_OBJECT_TYPE_IMAGE, "BackbufferDepth"); - TransitionImageLayout2(cmd, depth_.image, 0, 1, + TransitionImageLayout2(cmd, depth_.image, 0, 1, 1, aspectMask, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT, @@ -331,6 +331,10 @@ VkRenderPass CreateRenderPass(VulkanContext *vulkan, const RPKey &key, RenderPas bool hasDepth = RenderPassTypeHasDepth(rpType); bool multiview = RenderPassTypeHasMultiView(rpType); + if (multiview) { + // TODO: Assert that the device has multiview support enabled. + } + VkAttachmentDescription attachments[2] = {}; attachments[0].format = isBackbuffer ? vulkan->GetSwapchainFormat() : VK_FORMAT_R8G8B8A8_UNORM; attachments[0].samples = VK_SAMPLE_COUNT_1_BIT; @@ -905,6 +909,10 @@ std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { case RP_TYPE_COLOR_DEPTH: renderCmd = "RENDER_DEPTH"; break; case RP_TYPE_COLOR_INPUT: renderCmd = "RENDER_INPUT"; break; case RP_TYPE_COLOR_DEPTH_INPUT: renderCmd = "RENDER_DEPTH_INPUT"; break; + case RP_TYPE_MULTIVIEW_COLOR: renderCmd = "MV_RENDER"; break; + case RP_TYPE_MULTIVIEW_COLOR_DEPTH: renderCmd = "MV_RENDER_DEPTH"; break; + case RP_TYPE_MULTIVIEW_COLOR_INPUT: renderCmd = "MV_RENDER_INPUT"; break; + case RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT: renderCmd = "MV_RENDER_DEPTH_INPUT"; break; default: renderCmd = "N/A"; } snprintf(buffer, sizeof(buffer), "%s %s %s (draws: %d, %dx%d/%dx%d)", renderCmd, step.tag, step.render.framebuffer ? step.render.framebuffer->Tag() : "", step.render.numDraws, actual_w, actual_h, w, h); @@ -1565,6 +1573,10 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c vkCmdDraw(cmd, c.draw.count, 1, c.draw.offset, 0); break; + case VKRRenderCommand::BIND_DESCRIPTOR_SET: + vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, c.bindDescSet.setIndex, 1, &c.bindDescSet.descSet, 0, nullptr); + break; + case VKRRenderCommand::CLEAR: { // If we get here, we failed to merge a clear into a render pass load op. This is bad for perf. @@ -1643,7 +1655,8 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR renderPass = GetRenderPass(key); VKRFramebuffer *fb = step.render.framebuffer; - framebuf = fb->Get(renderPass, step.render.renderPassType); + framebuf = fb->Get(renderPass, step.render.renderPassType, step.render.layer); + _dbg_assert_(framebuf != VK_NULL_HANDLE); w = fb->width; h = fb->height; @@ -2014,7 +2027,7 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd if (step.readback.src == nullptr) { // We only take screenshots after the main render pass (anything else would be stupid) so we need to transition out of PRESENT, // and then back into it. - TransitionImageLayout2(cmd, backbufferImage_, 0, 1, VK_IMAGE_ASPECT_COLOR_BIT, + TransitionImageLayout2(cmd, backbufferImage_, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, VK_ACCESS_TRANSFER_READ_BIT); @@ -2048,7 +2061,7 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd if (step.readback.src == nullptr) { // We only take screenshots after the main render pass (anything else would be stupid) so we need to transition out of PRESENT, // and then back into it. - TransitionImageLayout2(cmd, backbufferImage_, 0, 1, VK_IMAGE_ASPECT_COLOR_BIT, + TransitionImageLayout2(cmd, backbufferImage_, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_TRANSFER_READ_BIT, 0); @@ -2079,7 +2092,7 @@ void VulkanQueueRunner::PerformReadbackImage(const VKRStep &step, VkCommandBuffe vkCmdCopyImageToBuffer(cmd, step.readback_image.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, readbackBuffer_, 1, ®ion); // Now transfer it back to a texture. - TransitionImageLayout2(cmd, step.readback_image.image, 0, 1, + TransitionImageLayout2(cmd, step.readback_image.image, 0, 1, 1, // TODO: Handle multiple layers VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index d5ea7163ed..d51f2b638b 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -37,12 +37,13 @@ enum class VKRRenderCommand : uint8_t { DRAW, DRAW_INDEXED, PUSH_CONSTANTS, + BIND_DESCRIPTOR_SET, SELF_DEPENDENCY_BARRIER, DEBUG_ANNOTATION, NUM_RENDER_COMMANDS, }; -enum class PipelineFlags { +enum class PipelineFlags : u8 { NONE = 0, USES_BLEND_CONSTANT = (1 << 1), USES_DEPTH_STENCIL = (1 << 2), // Reads or writes the depth or stencil buffers. @@ -115,7 +116,7 @@ struct VkRenderData { VkDescriptorSet ds; int numUboOffsets; uint32_t uboOffsets[3]; - VkBuffer vbuffer; // might need to increase at some point + VkBuffer vbuffer; VkBuffer ibuffer; uint32_t voffset; uint32_t ioffset; @@ -152,6 +153,10 @@ struct VkRenderData { struct { const char *annotation; } debugAnnotation; + struct { + uint32_t setIndex; + VkDescriptorSet descSet; + } bindDescSet; }; }; @@ -207,6 +212,7 @@ struct VKRStep { VKRRenderPassStoreAction depthStore; VKRRenderPassStoreAction stencilStore; u8 clearStencil; + s8 layer; uint32_t clearColor; float clearDepth; int numDraws; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index a3bce70e0d..b19112f4b2 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -182,43 +182,51 @@ void VKRFramebuffer::UpdateTag(const char *newTag) { vulkan_->SetDebugName(depth.imageView, VK_OBJECT_TYPE_IMAGE_VIEW, name); } for (int rpType = 0; rpType < RP_TYPE_COUNT; rpType++) { - if (framebuf[rpType]) { - snprintf(name, sizeof(name), "fb_%s", tag_.c_str()); - vulkan_->SetDebugName(framebuf[(int)rpType], VK_OBJECT_TYPE_FRAMEBUFFER, name); + for (int i = 0; i < 2; i++) { + if (framebuf[rpType][i]) { + snprintf(name, sizeof(name), "fb_%s_%d", tag_.c_str(), i); + vulkan_->SetDebugName(framebuf[(int)rpType][i], VK_OBJECT_TYPE_FRAMEBUFFER, name); + } } } } -VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType) { - if (framebuf[(int)rpType]) { - return framebuf[(int)rpType]; +VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, int layer) { + bool multiview = RenderPassTypeHasMultiView(rpType); + + if (RenderPassTypeHasMultiView(rpType)) { + _dbg_assert_(layer == -1); + layer = 0; + } + + if (framebuf[(int)rpType][layer]) { + return framebuf[(int)rpType][layer]; } VkFramebufferCreateInfo fbci{ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; VkImageView views[2]{}; - bool hasDepth = rpType == RP_TYPE_BACKBUFFER || rpType == RP_TYPE_COLOR_DEPTH || rpType == RP_TYPE_COLOR_DEPTH_INPUT; - - views[0] = color.imageView; + bool hasDepth = RenderPassTypeHasDepth(rpType); + views[0] = (multiview || numLayers == 0) ? color.imageView : color.layerViews[layer]; if (hasDepth) { _dbg_assert_(depth.imageView != VK_NULL_HANDLE); - views[1] = depth.imageView; + views[1] = (multiview || numLayers == 0) ? depth.imageView : depth.layerViews[layer]; } fbci.renderPass = compatibleRenderPass->Get(vulkan_, rpType); fbci.attachmentCount = hasDepth ? 2 : 1; fbci.pAttachments = views; fbci.width = width; fbci.height = height; - fbci.layers = 1; + fbci.layers = 1; // With multiview, this should be set as 1. - VkResult res = vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf[(int)rpType]); + VkResult res = vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf[(int)rpType][layer]); _assert_(res == VK_SUCCESS); if (!tag_.empty() && vulkan_->Extensions().EXT_debug_utils) { - vulkan_->SetDebugName(framebuf[(int)rpType], VK_OBJECT_TYPE_FRAMEBUFFER, StringFromFormat("fb_%s", tag_.c_str()).c_str()); + vulkan_->SetDebugName(framebuf[(int)rpType][layer], VK_OBJECT_TYPE_FRAMEBUFFER, StringFromFormat("fb_%s_%d", tag_.c_str(), layer).c_str()); } - return framebuf[(int)rpType]; + return framebuf[(int)rpType][layer]; } VKRFramebuffer::~VKRFramebuffer() { @@ -236,13 +244,27 @@ VKRFramebuffer::~VKRFramebuffer() { } if (depth.depthSampleView) vulkan_->Delete().QueueDeleteImageView(depth.depthSampleView); + for (int i = 0; i < 2; i++) { + if (color.layerViews[i]) { + vulkan_->Delete().QueueDeleteImageView(color.layerViews[i]); + } + if (depth.layerViews[i]) { + vulkan_->Delete().QueueDeleteImageView(depth.layerViews[i]); + } + } for (auto &fb : framebuf) { - if (fb) - vulkan_->Delete().QueueDeleteFramebuffer(fb); + for (int i = 0; i < 2; i++) { + if (fb[i]) { + vulkan_->Delete().QueueDeleteFramebuffer(fb[i]); + } + } } } void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int width, int height, int numLayers, VkFormat format, VkImageLayout initialLayout, bool color, const char *tag) { + // We don't support more exotic layer setups for now. Mono or stereo. + _dbg_assert_(numLayers == 1 || numLayers == 2); + VkImageCreateInfo ici{ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; ici.arrayLayers = numLayers; ici.mipLevels = 1; @@ -275,11 +297,12 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ivci.components = { VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY }; ivci.format = ici.format; ivci.image = img.image; - ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; + ivci.viewType = numLayers == 1 ? VK_IMAGE_VIEW_TYPE_2D : VK_IMAGE_VIEW_TYPE_2D_ARRAY; ivci.subresourceRange.aspectMask = aspects; - ivci.subresourceRange.layerCount = 1; + ivci.subresourceRange.layerCount = numLayers; ivci.subresourceRange.levelCount = 1; res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.imageView); + _dbg_assert_(res == VK_SUCCESS); // Separate view for texture sampling that only exposes depth. @@ -291,6 +314,18 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int img.depthSampleView = VK_NULL_HANDLE; } + // Create 2D views for both layers, if layered. + // Useful when multipassing shaders that don't yet exist in a single-pass-stereo version. + if (numLayers == 2) { + ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; + ivci.subresourceRange.layerCount = 1; + res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.layerViews[0]); + _dbg_assert_(res == VK_SUCCESS); + ivci.subresourceRange.baseArrayLayer = 1; + res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.layerViews[1]); + _dbg_assert_(res == VK_SUCCESS); + } + VkPipelineStageFlags dstStage; VkAccessFlagBits dstAccessMask; switch (initialLayout) { @@ -311,12 +346,11 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int return; } - TransitionImageLayout2(cmd, img.image, 0, 1, aspects, + TransitionImageLayout2(cmd, img.image, 0, 1, numLayers, aspects, VK_IMAGE_LAYOUT_UNDEFINED, initialLayout, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, dstStage, 0, dstAccessMask); img.layout = initialLayout; - img.format = format; img.tag = tag ? tag : "N/A"; } @@ -710,10 +744,18 @@ void VulkanRenderManager::EndCurRenderStep() { RenderPassType rpType = depthStencil ? RP_TYPE_COLOR_DEPTH : RP_TYPE_COLOR; if (!curRenderStep_->render.framebuffer) { rpType = RP_TYPE_BACKBUFFER; - } else if (curPipelineFlags_ & PipelineFlags::USES_INPUT_ATTACHMENT) { - // Not allowed on backbuffers. - rpType = depthStencil ? RP_TYPE_COLOR_DEPTH_INPUT : RP_TYPE_COLOR_INPUT; + } else { + if (curPipelineFlags_ & PipelineFlags::USES_INPUT_ATTACHMENT) { + // Not allowed on backbuffers. + rpType = depthStencil ? RP_TYPE_COLOR_DEPTH_INPUT : RP_TYPE_COLOR_INPUT; + } + // Framebuffers can be stereo, and if so, will control the render pass type to match. + // Pipelines can be mono and render fine to stereo etc, so not checking them here. + if (curRenderStep_->render.framebuffer->numLayers > 1) { + rpType = (RenderPassType)(rpType | RP_TYPE_MULTIVIEW_COLOR); + } } + // TODO: Also add render pass types for depth/stencil-less. VKRRenderPass *renderPass = queueRunner_.GetRenderPass(key); @@ -752,7 +794,7 @@ void VulkanRenderManager::BindCurrentFramebufferAsInputAttachment0(VkImageAspect curRenderStep_->commands.push_back(VkRenderData{ VKRRenderCommand::SELF_DEPENDENCY_BARRIER }); } -void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, const char *tag) { +void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, int layer, const char *tag) { _dbg_assert_(insideFrame_); // Eliminate dupes (bind of the framebuffer we already are rendering to), instantly convert to a clear if possible. if (!steps_.empty() && steps_.back()->stepType == VKRStepType::RENDER && steps_.back()->render.framebuffer == fb) { @@ -833,6 +875,7 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR VKRStep *step = new VKRStep{ VKRStepType::RENDER }; step->render.framebuffer = fb; + step->render.layer = layer; step->render.colorLoad = color; step->render.depthLoad = depth; step->render.stencilLoad = stencil; @@ -1175,7 +1218,7 @@ void VulkanRenderManager::BlitFramebuffer(VKRFramebuffer *src, VkRect2D srcRect, steps_.push_back(step); } -VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBit) { +VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBit, int layer) { _dbg_assert_(curRenderStep_ != nullptr); // We don't support texturing from stencil, neither do we support texturing from depth|stencil together (nonsensical). @@ -1210,7 +1253,12 @@ VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, in // Add this pretransition unless we already have it. TransitionRequest rq{ fb, aspectBit, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }; curRenderStep_->preTransitions.insert(rq); // Note that insert avoids inserting duplicates. - return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.imageView : fb->depth.depthSampleView; + + if (layer == -1 || (layer == 0 && fb->numLayers == 1)) { + return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.imageView : fb->depth.depthSampleView; + } else { + return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.layerViews[layer] : fb->depth.layerViews[layer]; + } } // Called on main thread. diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 97771514e0..4247157809 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -24,13 +24,19 @@ // Forward declaration VK_DEFINE_HANDLE(VmaAllocation); -// Simple independent framebuffer image. Gets its own allocation, we don't have that many framebuffers so it's fine -// to let them have individual non-pooled allocations. Until it's not fine. We'll see. +// Simple independent framebuffer image. struct VKRImage { // These four are "immutable". VkImage image; + + // These are 2D if single layer, 2D_ARRAY if multiple. Need to take that into account when picking + // shaders, or use layerViews below and multiple passes to work around it. VkImageView imageView; VkImageView depthSampleView; + + // If it's a layered image (for stereo), this is two 2D views of it, to make it compatible with shaders that don't yet support stereo. + VkImageView layerViews[2]{}; + VmaAllocation alloc; VkFormat format; @@ -40,6 +46,9 @@ struct VKRImage { // For debugging. std::string tag; }; + +// NOTE: If numLayers > 1, it will create an array texture, rather than a normal 2D texture. +// This requires a different sampling path! void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int width, int height, int numLayers, VkFormat format, VkImageLayout initialLayout, bool color, const char *tag); class VKRFramebuffer { @@ -47,7 +56,7 @@ public: VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, int _numLayers, bool createDepthStencilBuffer, const char *tag); ~VKRFramebuffer(); - VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType); + VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, int layer); int width = 0; int height = 0; @@ -65,7 +74,7 @@ public: // TODO: Hide. VulkanContext *vulkan_; private: - VkFramebuffer framebuf[RP_TYPE_COUNT]{}; + VkFramebuffer framebuf[RP_TYPE_COUNT][2]{}; std::string tag_; }; @@ -213,7 +222,7 @@ public: // Zaps queued up commands. Use if you know there's a risk you've queued up stuff that has already been deleted. Can happen during in-game shutdown. void Wipe(); - // This starts a new step containing a render pass. + // This starts a new step containing a render pass (unless it can be trivially merged into the previous one, which is pretty common). // // After a "CopyFramebuffer" or the other functions that start "steps", you need to call this beforce // making any new render state changes or draw calls. @@ -228,11 +237,16 @@ public: // // It can be useful to use GetCurrentStepId() to figure out when you need to send all this state again, if you're // not keeping track of your calls to this function on your own. - void BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, const char *tag); + // + // For layer, we use the same convention as thin3d, where layer = -1 means all layers together. For texturing, that means that you + // get an array texture view. + void BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, int layer, const char *tag); // Returns an ImageView corresponding to a framebuffer. Is called BindFramebufferAsTexture to maintain a similar interface // as the other backends, even though there's no actual binding happening here. - VkImageView BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBits); + // For layer, we use the same convention as thin3d, where layer = -1 means all layers together. For texturing, that means that you + // get an array texture view. + VkImageView BindFramebufferAsTexture(VKRFramebuffer *fb, int binding, VkImageAspectFlags aspectBits, int layer); void BindCurrentFramebufferAsInputAttachment0(VkImageAspectFlags aspectBits); @@ -256,6 +270,15 @@ public: compileMutex_.unlock(); } + // We always pass in desc set 0 directly in draw commands. This is used only to bind higher descriptor sets. + void BindDescriptorSet(int index, const VkDescriptorSet descSet) { + _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); + VkRenderData data{ VKRRenderCommand::BIND_DESCRIPTOR_SET }; + data.bindDescSet.setIndex = index; + data.bindDescSet.descSet = descSet; + curRenderStep_->commands.push_back(data); + } + void BindPipeline(VKRGraphicsPipeline *pipeline, PipelineFlags flags, VkPipelineLayout pipelineLayout) { _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); _dbg_assert_(pipeline != nullptr); diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 0c03d240ed..d3b0d8581c 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -404,11 +404,8 @@ public: DataFormat PreferredFramebufferReadbackFormat(Framebuffer *src) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; - Framebuffer *GetCurrentRenderTarget() override { - return (Framebuffer *)curFramebuffer_.ptr; - } - void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; void BindCurrentFramebufferForColorInput() override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1505,7 +1502,7 @@ private: Framebuffer *VKContext::CreateFramebuffer(const FramebufferDesc &desc) { VkCommandBuffer cmd = renderManager_.GetInitCmd(); - VKRFramebuffer *vkrfb = new VKRFramebuffer(vulkan_, cmd, renderManager_.GetQueueRunner()->GetCompatibleRenderPass(), desc.width, desc.height, desc.z_stencil, desc.numLayers, desc.tag); + VKRFramebuffer *vkrfb = new VKRFramebuffer(vulkan_, cmd, renderManager_.GetQueueRunner()->GetCompatibleRenderPass(), desc.width, desc.height, desc.numLayers, desc.z_stencil, desc.tag); return new VKFramebuffer(vkrfb); } @@ -1556,17 +1553,17 @@ DataFormat VKContext::PreferredFramebufferReadbackFormat(Framebuffer *src) { return DrawContext::PreferredFramebufferReadbackFormat(src); } -void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { +void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { VKFramebuffer *fb = (VKFramebuffer *)fbo; VKRRenderPassLoadAction color = (VKRRenderPassLoadAction)rp.color; VKRRenderPassLoadAction depth = (VKRRenderPassLoadAction)rp.depth; VKRRenderPassLoadAction stencil = (VKRRenderPassLoadAction)rp.stencil; - renderManager_.BindFramebufferAsRenderTarget(fb ? fb->GetFB() : nullptr, color, depth, stencil, rp.clearColor, rp.clearDepth, rp.clearStencil, tag); + renderManager_.BindFramebufferAsRenderTarget(fb ? fb->GetFB() : nullptr, color, depth, stencil, rp.clearColor, rp.clearDepth, rp.clearStencil, layer, tag); curFramebuffer_ = fb; } -void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) { +void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) { VKFramebuffer *fb = (VKFramebuffer *)fbo; _assert_(binding < MAX_BOUND_TEXTURES); @@ -1588,7 +1585,7 @@ void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChanne } boundTextures_[binding] = nullptr; - boundImageView_[binding] = renderManager_.BindFramebufferAsTexture(fb->GetFB(), binding, aspect); + boundImageView_[binding] = renderManager_.BindFramebufferAsTexture(fb->GetFB(), binding, aspect, layer); } void VKContext::BindCurrentFramebufferForColorInput() { diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 7c3a6d240d..f2c886c054 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -415,9 +415,11 @@ class Framebuffer : public RefCountedObject { public: int Width() { return width_; } int Height() { return height_; } + int Layers() { return layers_; } + virtual void UpdateTag(const char *tag) {} protected: - int width_ = -1, height_ = -1; + int width_ = -1, height_ = -1, layers_ = 1; }; class Buffer : public RefCountedObject { @@ -593,6 +595,8 @@ struct RenderPassInfo { const char *tag; }; +const int ALL_LAYERS = -1; + class DrawContext { public: virtual ~DrawContext(); @@ -654,11 +658,10 @@ public: // These functions should be self explanatory. // Binding a zero render target means binding the backbuffer. - virtual void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) = 0; - virtual Framebuffer *GetCurrentRenderTarget() = 0; + virtual void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) = 0; // binding must be < MAX_TEXTURE_SLOTS (0, 1 are okay if it's 2). - virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit) = 0; + virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) = 0; // Framebuffer fetch / input attachment support, needs to be explicit in Vulkan. virtual void BindCurrentFramebufferForColorInput() {} diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 41ec1bb76d..6bdd4382d9 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -85,7 +85,7 @@ void UIScreen::preRender() { } draw->BeginFrame(); // Bind and clear the back buffer - draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "UI"); + draw->BindFramebufferAsRenderTarget(nullptr, ALL_LAYERS, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "UI"); screenManager()->getUIContext()->BeginFrame(); Draw::Viewport viewport; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 223cd7976f..b27aba7334 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -89,6 +89,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool doTextureProjection = id.Bit(FS_BIT_DO_TEXTURE_PROJ); bool doTextureAlpha = id.Bit(FS_BIT_TEXALPHA); + bool arrayTexture = id.Bit(FS_BIT_SAMPLE_ARRAY_TEXTURE); + bool arrayTextureFramebuffer = id.Bit(FS_BIT_FRAMEBUFFER_ARRAY_TEXTURE); + bool flatBug = bugs.Has(Draw::Bugs::BROKEN_FLAT_IN_SHADER) && g_Config.bVendorBugChecksEnabled; bool doFlatShading = id.Bit(FS_BIT_FLATSHADE) && !flatBug; @@ -155,11 +158,11 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseUBO {\n%s};\n", ub_baseStr); if (doTexture) { - WRITE(p, "layout (binding = 0) uniform %s tex;\n", texture3D ? "sampler3D" : "sampler2D"); + WRITE(p, "layout (binding = 0) uniform %s%s tex;\n", texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "array" : ""); } if (readFramebufferTex) { - WRITE(p, "layout (binding = 1) uniform sampler2D fbotex;\n"); + WRITE(p, "layout (binding = 1) uniform sampler2D%s fbotex;\n", arrayTextureFramebuffer ? "array" : ""); } else if (fetchFramebuffer) { WRITE(p, "layout (input_attachment_index = 0, binding = 9) uniform subpassInput inputColor;\n"); if (fragmentShaderFlags) { diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 07f933778f..6809922dd9 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -863,7 +863,7 @@ void FramebufferManagerCommon::CopyToColorFromOverlappingFramebuffers(VirtualFra if (currentRenderVfb_ && dst != currentRenderVfb_ && tookActions) { // Will probably just change the name of the current renderpass, since one was started by the reinterpret itself. - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "After Reinterpret"); + draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "After Reinterpret"); } shaderManager_->DirtyLastShader(); @@ -1011,7 +1011,7 @@ void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffe if (useBufferedRendering_) { if (vfb->fbo) { shaderManager_->DirtyLastShader(); - draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "FBSwitch"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, {Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP}, "FBSwitch"); } else { // This should only happen very briefly when toggling useBufferedRendering_. ResizeFramebufFBO(vfb, vfb->width, vfb->height, true); @@ -1115,7 +1115,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int } else { flags = DRAWTEX_LINEAR; } - draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); SetViewport2D(0, 0, vfb->renderWidth, vfb->renderHeight); draw_->SetScissorRect(0, 0, vfb->renderWidth, vfb->renderHeight); } else { @@ -1153,7 +1153,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int } } -bool FramebufferManagerCommon::BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags) { +bool FramebufferManagerCommon::BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags, int layer) { if (!framebuffer->fbo || !useBufferedRendering_) { draw_->BindTexture(stage, nullptr); gstate_c.skipDrawReason |= SKIPDRAW_BAD_FB_TEXTURE; @@ -1173,17 +1173,17 @@ bool FramebufferManagerCommon::BindFramebufferAsColorTexture(int stage, VirtualF if (renderCopy) { VirtualFramebuffer copyInfo = *framebuffer; copyInfo.fbo = renderCopy; - CopyFramebufferForColorTexture(©Info, framebuffer, flags); + CopyFramebufferForColorTexture(©Info, framebuffer, flags, layer); RebindFramebuffer("After BindFramebufferAsColorTexture"); - draw_->BindFramebufferAsTexture(renderCopy, stage, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(renderCopy, stage, Draw::FB_COLOR_BIT, layer); gpuStats.numCopiesForSelfTex++; } else { // Failed to get temp FBO? Weird. - draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT, layer); } return true; } else if (framebuffer != currentRenderVfb_ || (flags & BINDFBCOLOR_FORCE_SELF) != 0) { - draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(framebuffer->fbo, stage, Draw::FB_COLOR_BIT, layer); return true; } else { ERROR_LOG_REPORT_ONCE(selfTextureFail, G3D, "Attempting to texture from target (src=%08x / target=%08x / flags=%d)", framebuffer->fb_address, currentRenderVfb_->fb_address, flags); @@ -1197,7 +1197,7 @@ bool FramebufferManagerCommon::BindFramebufferAsColorTexture(int stage, VirtualF } } -void FramebufferManagerCommon::CopyFramebufferForColorTexture(VirtualFramebuffer *dst, VirtualFramebuffer *src, int flags) { +void FramebufferManagerCommon::CopyFramebufferForColorTexture(VirtualFramebuffer *dst, VirtualFramebuffer *src, int flags, int layer) { int x = 0; int y = 0; int w = src->drawnWidth; @@ -1369,7 +1369,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) { DEBUG_LOG(FRAMEBUF, "Display disabled, displaying only black"); // No framebuffer to display! Clear to black. if (useBufferedRendering_) { - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput"); + draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput"); } gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); return; @@ -1433,7 +1433,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) { // No framebuffer to display! Clear to black. if (useBufferedRendering_) { // Bind and clear the backbuffer. This should be the first time during the frame that it's bound. - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput_NoFBO"); + draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput_NoFBO"); } gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); return; @@ -1619,7 +1619,7 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, shaderManager_->DirtyLastShader(); char tag[128]; size_t len = FormatFramebufferName(vfb, tag, sizeof(tag)); - vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, tag }); + vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, GetFramebufferLayers(), true, tag }); if (Memory::IsVRAMAddress(vfb->fb_address) && vfb->fb_stride != 0) { NotifyMemInfo(MemBlockFlags::ALLOC, vfb->fb_address, ColorBufferByteSize(vfb), tag, len); } @@ -1631,7 +1631,7 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, if (old.fbo) { INFO_LOG(FRAMEBUF, "Resizing FBO for %08x : %dx%dx%s", vfb->fb_address, w, h, GeBufferFormatToString(vfb->fb_format)); if (vfb->fbo) { - draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); if (!skipCopy) { BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min((u16)oldWidth, std::min(vfb->bufferWidth, vfb->width)), std::min((u16)oldHeight, std::min(vfb->height, vfb->bufferHeight)), 0, RASTER_COLOR, "BlitColor_ResizeFramebufFBO"); } @@ -1640,9 +1640,9 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, } } fbosToDelete_.push_back(old.fbo); - draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "ResizeFramebufFBO"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "ResizeFramebufFBO"); } else { - draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); } currentRenderVfb_ = vfb; @@ -1986,7 +1986,7 @@ VirtualFramebuffer *FramebufferManagerCommon::CreateRAMFramebuffer(uint32_t fbAd char name[64]; snprintf(name, sizeof(name), "%08x_color_RAM", vfb->fb_address); textureCache_->NotifyFramebuffer(vfb, NOTIFY_FB_CREATED); - vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, name }); + vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, GetFramebufferLayers(), true, name }); vfbs_.push_back(vfb); u32 byteSize = ColorBufferByteSize(vfb); @@ -2407,7 +2407,8 @@ Draw::Framebuffer *FramebufferManagerCommon::GetTempFBO(TempFBO reason, u16 w, u bool z_stencil = reason == TempFBO::STENCIL; char name[128]; snprintf(name, sizeof(name), "temp_fbo_%dx%d%s", w / renderScaleFactor_, h / renderScaleFactor_, z_stencil ? "_depth" : ""); - Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, 1, z_stencil, name }); + + Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, GetFramebufferLayers(), z_stencil, name }); if (!fbo) { return nullptr; } @@ -2784,10 +2785,10 @@ void FramebufferManagerCommon::RebindFramebuffer(const char *tag) { draw_->InvalidateCachedState(); shaderManager_->DirtyLastShader(); if (currentRenderVfb_ && currentRenderVfb_->fbo) { - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); + draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, Draw::ALL_LAYERS, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); } else { // Should this even happen? It could while debugging, but maybe we can just skip binding at all. - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "RebindFramebuffer_Bad"); + draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "RebindFramebuffer_Bad"); } } @@ -2906,7 +2907,7 @@ void FramebufferManagerCommon::BlitFramebuffer(VirtualFramebuffer *dst, int dstX // This can happen if they recently switched from non-buffered. if (useBufferedRendering_) { // Just bind the back buffer for rendering, forget about doing anything else as we're in a weird state. - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "BlitFramebuffer"); + draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "BlitFramebuffer"); } return; } @@ -3029,8 +3030,8 @@ void FramebufferManagerCommon::BlitUsingRaster( // Unbind the texture first to avoid the D3D11 hazard check (can't set render target to things bound as textures and vice versa, not even temporarily). draw_->BindTexture(0, nullptr); // This will get optimized away in case it's already bound (in VK and GL at least..) - draw_->BindFramebufferAsRenderTarget(dest, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); - draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT); + draw_->BindFramebufferAsRenderTarget(dest, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); + draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, 0); if (destX1 == 0.0f && destY1 == 0.0f && destX2 >= destW && destY2 >= destH) { // We overwrite the whole channel of the framebuffer, so we can invalidate the current contents. @@ -3046,6 +3047,14 @@ void FramebufferManagerCommon::BlitUsingRaster( gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); } +int FramebufferManagerCommon::GetFramebufferLayers() const { + int layers = 1; + if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { + layers = 2; + } + return layers; +} + VirtualFramebuffer *FramebufferManagerCommon::ResolveFramebufferColorToFormat(VirtualFramebuffer *src, GEBufferFormat newFormat) { // Look for an identical framebuffer with the new format _dbg_assert_(src->fb_format != newFormat); @@ -3089,7 +3098,7 @@ VirtualFramebuffer *FramebufferManagerCommon::ResolveFramebufferColorToFormat(Vi char tag[128]; FormatFramebufferName(vfb, tag, sizeof(tag)); - vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, 1, true, tag }); + vfb->fbo = draw_->CreateFramebuffer({ vfb->renderWidth, vfb->renderHeight, 1, GetFramebufferLayers(), true, tag }); vfbs_.push_back(vfb); } diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index 5a85d93541..d9f635d208 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -322,7 +322,7 @@ public: // Otherwise it doesn't get called. void NotifyBlockTransferAfter(u32 dstBasePtr, int dstStride, int dstX, int dstY, u32 srcBasePtr, int srcStride, int srcX, int srcY, int w, int h, int bpp, u32 skipDrawReason); - bool BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags); + bool BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags, int layer); void ReadFramebufferToMemory(VirtualFramebuffer *vfb, int x, int y, int w, int h, RasterChannel channel); void DownloadFramebufferForClut(u32 fb_address, u32 loadBytes); @@ -460,7 +460,7 @@ protected: // Used by ReadFramebufferToMemory and later framebuffer block copies void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, RasterChannel channel, const char *tag); - void CopyFramebufferForColorTexture(VirtualFramebuffer *dst, VirtualFramebuffer *src, int flags); + void CopyFramebufferForColorTexture(VirtualFramebuffer *dst, VirtualFramebuffer *src, int flags, int layer); void EstimateDrawingSize(u32 fb_address, int fb_stride, GEBufferFormat fb_format, int viewport_width, int viewport_height, int region_width, int region_height, int scissor_width, int scissor_height, int &drawing_width, int &drawing_height); u32 ColorBufferByteSize(const VirtualFramebuffer *vfb) const; @@ -486,6 +486,8 @@ protected: void UpdateFramebufUsage(VirtualFramebuffer *vfb); + int GetFramebufferLayers() const; + static void SetColorUpdated(VirtualFramebuffer *dstBuffer, int skipDrawReason) { dstBuffer->memoryUpdated = false; dstBuffer->clutUpdatedBytes = 0; diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index ce3e155c93..36453def3f 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -566,7 +566,7 @@ void PresentationCommon::BindSource(int binding) { if (srcTexture_) { draw_->BindTexture(binding, srcTexture_); } else if (srcFramebuffer_) { - draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); } else { _assert_(false); } @@ -685,13 +685,13 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u PostShaderUniforms uniforms; const auto performShaderPass = [&](const ShaderInfo *shaderInfo, Draw::Framebuffer *postShaderFramebuffer, Draw::Pipeline *postShaderPipeline) { if (postShaderOutput) { - draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); } else { BindSource(0); } BindSource(1); if (shaderInfo->usePreviousFrame) - draw_->BindFramebufferAsTexture(previousFramebuffer, 2, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(previousFramebuffer, 2, Draw::FB_COLOR_BIT, 0); int nextWidth, nextHeight; draw_->GetFramebufferDimensions(postShaderFramebuffer, &nextWidth, &nextHeight); @@ -743,7 +743,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u postShaderFramebuffer = previousFramebuffers_[previousIndex_]; } - draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "PostShader"); + draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "PostShader"); performShaderPass(shaderInfo, postShaderFramebuffer, postShaderPipeline); } @@ -764,7 +764,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u previousIndex_ = 0; Draw::Framebuffer *postShaderFramebuffer = previousFramebuffers_[previousIndex_]; - draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "InterFrameBlit"); + draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "InterFrameBlit"); performShaderPass(shaderInfo, postShaderFramebuffer, postShaderPipeline); } @@ -773,13 +773,13 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u pipeline = postShaderPipelines_.back(); } - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "FinalBlit"); + draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "FinalBlit"); draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_); draw_->BindPipeline(pipeline); if (postShaderOutput) { - draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); } else { BindSource(0); } diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 78483cf8a5..d7dd5e2c6e 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -362,6 +362,15 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip id.SetBit(FS_BIT_COLOR_WRITEMASK, colorWriteMask); + // Stereo support + if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { + // All framebuffers are array textures in this mode. + if (gstate_c.arrayTexture) { + id.SetBit(FS_BIT_SAMPLE_ARRAY_TEXTURE); + } + id.SetBit(FS_BIT_FRAMEBUFFER_ARRAY_TEXTURE); + } + if (g_Config.bVendorBugChecksEnabled && bugs.Has(Draw::Bugs::NO_DEPTH_CANNOT_DISCARD_STENCIL)) { bool stencilWithoutDepth = !IsStencilTestOutputDisabled() && (!gstate.isDepthTestEnabled() || !gstate.isDepthWriteEnabled()); if (stencilWithoutDepth) { diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 2edf271b6d..120264b628 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -98,6 +98,8 @@ enum FShaderBit : uint8_t { FS_BIT_COLOR_WRITEMASK = 50, FS_BIT_REPLACE_LOGIC_OP = 51, // 4 bits. GE_LOGIC_COPY means no-op/off. FS_BIT_SHADER_DEPAL_MODE = 55, // 2 bits (ShaderDepalMode) + FS_BIT_SAMPLE_ARRAY_TEXTURE = 57, // For multiview, framebuffers are array textures and we need to sample the two layers correctly. + FS_BIT_FRAMEBUFFER_ARRAY_TEXTURE = 58, // Framebuffer texture might also be stereo. }; static inline FShaderBit operator +(FShaderBit bit, int i) { diff --git a/GPU/Common/ShaderUniforms.h b/GPU/Common/ShaderUniforms.h index c746179316..96cfe98411 100644 --- a/GPU/Common/ShaderUniforms.h +++ b/GPU/Common/ShaderUniforms.h @@ -131,6 +131,16 @@ static const char * const ub_vs_bonesStr = R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bone4; mat3x4 u_bone5; mat3x4 u_bone6; mat3x4 u_bone7; mat3x4 u_bone8; )"; + +static const char * const ub_frame_globalstr = +R"( vec4 unused; +)"; + +// VR stuff will go here. +struct UB_FrameGlobal { + float unused[4]; +}; + void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bool hasNegZ); void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering); diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index 682d8a1f0c..dfa36fe0e7 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -187,7 +187,7 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, // Otherwise, we can skip alpha in many cases, in which case we don't even use a shader. if (flags & WriteStencil::IGNORE_ALPHA) { if (dstBuffer->fbo) { - draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Clear"); + draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Clear"); } return true; } @@ -281,9 +281,9 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, Draw::Framebuffer *blitFBO = nullptr; if (useBlit) { blitFBO = GetTempFBO(TempFBO::STENCIL, w, h); - draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Blit"); + draw_->BindFramebufferAsRenderTarget(blitFBO, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Blit"); } else if (dstBuffer->fbo) { - draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_NoBlit"); + draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_NoBlit"); } Draw::Viewport viewport = { 0.0f, 0.0f, (float)w, (float)h, 0.0f, 1.0f }; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index a1ed25094b..3c288b13f4 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2121,7 +2121,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer // Very icky conflation here of native and thin3d rendering. This will need careful work per backend in BindAsClutTexture. BindAsClutTexture(clutTexture.texture, smoothedDepal); - framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); + framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET, 0); // Vulkan needs to do some extra work here to pick out the native handle from Draw. BoundFramebufferTexture(); @@ -2191,13 +2191,13 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(TempFBO::DEPAL, depalWidth, framebuffer->renderHeight); draw_->BindTexture(0, nullptr); draw_->BindTexture(1, nullptr); - draw_->BindFramebufferAsRenderTarget(depalFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); + draw_->BindFramebufferAsRenderTarget(depalFBO, Draw::ALL_LAYERS, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); draw_->InvalidateFramebuffer(Draw::FB_INVALIDATION_STORE, Draw::FB_DEPTH_BIT | Draw::FB_STENCIL_BIT); draw_->SetScissorRect(u1, v1, u2 - u1, v2 - v1); Draw::Viewport vp{ 0.0f, 0.0f, (float)depalWidth, (float)framebuffer->renderHeight, 0.0f, 1.0f }; draw_->SetViewports(1, &vp); - draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, 0); draw_->BindTexture(1, clutTexture.texture); Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false); Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(smoothedDepal); @@ -2213,7 +2213,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer draw_->BindTexture(0, nullptr); framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, 0); BoundFramebufferTexture(); const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); @@ -2226,7 +2226,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer shaderManager_->DirtyLastShader(); } else { framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET); + framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET, 0); BoundFramebufferTexture(); gstate_c.SetUseShaderDepal(ShaderDepalMode::OFF); @@ -2292,14 +2292,14 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(TempFBO::DEPAL, texWidth, texHeight); draw_->BindTexture(0, nullptr); draw_->BindTexture(1, nullptr); - draw_->BindFramebufferAsRenderTarget(depalFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); + draw_->BindFramebufferAsRenderTarget(depalFBO, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); draw_->InvalidateFramebuffer(Draw::FB_INVALIDATION_STORE, Draw::FB_DEPTH_BIT | Draw::FB_STENCIL_BIT); draw_->SetScissorRect(u1, v1, u2 - u1, v2 - v1); Draw::Viewport vp{ 0.0f, 0.0f, (float)texWidth, (float)texHeight, 0.0f, 1.0f }; draw_->SetViewports(1, &vp); draw_->BindNativeTexture(0, GetNativeTextureView(entry)); - draw_->BindFramebufferAsTexture(dynamicClutFbo_, 1, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(dynamicClutFbo_, 1, Draw::FB_COLOR_BIT, 0); Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false); Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(false); draw_->BindSamplerStates(0, 1, &nearest); @@ -2314,7 +2314,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { draw_->BindTexture(0, nullptr); framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT); + draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, 0); BoundFramebufferTexture(); const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index a902401122..efbbcad31b 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -159,7 +159,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { ApplyStencilReplaceAndLogicOpIgnoreBlend(blendState.replaceAlphaWithStencil, blendState); if (fboTexBindState == FBO_TEX_COPY_BIND_TEX) { - framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY); + framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY, 0); // No sampler required, we do a plain Load in the pixel shader. fboTexBound_ = true; fboTexBindState = FBO_TEX_NONE; diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index bc1af41143..951a401189 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -101,7 +101,7 @@ void DrawEngineDX9::ApplyDrawState(int prim) { if (fboTexBindState_ = FBO_TEX_COPY_BIND_TEX) { // Note that this is positions, not UVs, that we need the copy from. - framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY); + framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY, 0); // If we are rendering at a higher resolution, linear is probably best for the dest color. device_->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); device_->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); @@ -139,7 +139,7 @@ void DrawEngineDX9::ApplyDrawState(int prim) { if (fboTexBindState_ == FBO_TEX_COPY_BIND_TEX) { // Note that this is positions, not UVs, that we need the copy from. - framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY); + framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY, Draw::ALL_LAYERS); // If we are rendering at a higher resolution, linear is probably best for the dest color. device_->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); device_->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index 5f783e48c7..e54d249061 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -204,11 +204,11 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int shaderManager_->DirtyLastShader(); auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); - draw_->BindFramebufferAsRenderTarget(blitFBO, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); + draw_->BindFramebufferAsRenderTarget(blitFBO, 0, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); - draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_DEPTH_BIT); + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_DEPTH_BIT, 0); draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &depthReadbackSampler_); // We must bind the program after starting the render pass. @@ -322,11 +322,11 @@ bool FramebufferManagerGLES::ReadbackStencilbufferSync(Draw::Framebuffer *fbo, i shaderManager_->DirtyLastShader(); auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); - draw_->BindFramebufferAsRenderTarget(blitFBO, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackStencilbufferSync"); + draw_->BindFramebufferAsRenderTarget(blitFBO, 0, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackStencilbufferSync"); Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); - draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_STENCIL_BIT); + draw_->BindFramebufferAsTexture(fbo, TEX_SLOT_PSP_TEXTURE, FB_STENCIL_BIT, 0); draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, &stencilReadbackSampler_); // We must bind the program after starting the render pass. diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 9d1dc8d3dd..50ba4bfd99 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -54,9 +54,9 @@ void FramebufferManagerGLES::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) // Discard the previous contents of this buffer where possible. if (gl_extensions.GLES3) { - draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer"); + draw_->BindFramebufferAsRenderTarget(nvfb->fbo, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer"); } else if (gl_extensions.IsGLES) { - draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer"); + draw_->BindFramebufferAsRenderTarget(nvfb->fbo, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer"); gstate_c.Dirty(DIRTY_BLEND_STATE); } } diff --git a/GPU/GLES/StateMappingGLES.cpp b/GPU/GLES/StateMappingGLES.cpp index 0b8f45c3c6..f80a3f5490 100644 --- a/GPU/GLES/StateMappingGLES.cpp +++ b/GPU/GLES/StateMappingGLES.cpp @@ -158,7 +158,7 @@ void DrawEngineGLES::ApplyDrawState(int prim) { // fboTexNeedsBind_ won't be set if we can read directly from the target. if (fboTexBindState == FBO_TEX_COPY_BIND_TEX) { // Note that this is positions, not UVs, that we need the copy from. - framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY); + framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY, 0); // If we are rendering at a higher resolution, linear is probably best for the dest color. renderManager->SetTextureSampler(1, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, GL_LINEAR, GL_LINEAR, 0.0f); fboTexBound_ = true; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index e7a15e9536..b323fc1067 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -583,6 +583,7 @@ struct GPUStateCache { bool bgraTexture; bool needShaderTexClamp; + bool arrayTexture; float morphWeights[8]; u32 deferredVertTypeDirty; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 04e3c1d5c7..5e8087b077 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -618,7 +618,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { u1 = 1.0f; } if (!hasImage) { - draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "CopyToCurrentFboFromDisplayRam"); + draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "CopyToCurrentFboFromDisplayRam"); return; } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index b24e4b0021..a9702731c9 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -42,6 +42,7 @@ #include "GPU/Common/VertexDecoderCommon.h" #include "GPU/Common/SoftwareTransformCommon.h" #include "GPU/Common/DrawEngineCommon.h" +#include "GPU/Common/ShaderUniforms.h" #include "GPU/Debugger/Debugger.h" #include "GPU/Vulkan/DrawEngineVulkan.h" #include "GPU/Vulkan/TextureCacheVulkan.h" @@ -184,8 +185,9 @@ void DrawEngineVulkan::InitDeviceObjects() { VkPipelineLayoutCreateInfo pl{ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = nullptr; pl.pushConstantRangeCount = 0; - pl.setLayoutCount = 1; - pl.pSetLayouts = &descriptorSetLayout_; + VkDescriptorSetLayout layouts[1] = { descriptorSetLayout_ }; + pl.setLayoutCount = ARRAY_SIZE(layouts); + pl.pSetLayouts = layouts; pl.flags = 0; res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); _dbg_assert_(VK_SUCCESS == res); @@ -303,6 +305,7 @@ void DrawEngineVulkan::BeginFrame() { frame->pushIndex->Reset(); VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT); + frame->pushUBO->Begin(vulkan); frame->pushVertex->Begin(vulkan); frame->pushIndex->Begin(vulkan); diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index ebf50e33b5..258f95ae6d 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -211,8 +211,9 @@ private: Draw::DrawContext *draw_; - // We use a single descriptor set layout for all PSP draws. + // We use a shared descriptor set layout for all PSP draws. VkDescriptorSetLayout descriptorSetLayout_; + VkPipelineLayout pipelineLayout_; VulkanPipeline *lastPipeline_; VkDescriptorSet lastDs_ = VK_NULL_HANDLE; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index c46b8b2812..aa5243a8f0 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -268,6 +268,11 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_ROUND_DEPTH_TO_16BIT; } + if (true) { + features |= GPU_USE_SINGLE_PASS_STEREO; + features &= ~GPU_USE_FRAMEBUFFER_FETCH; // Need to figure out if this can be supported with multiview rendering + } + return features; } diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index c29d2317d9..dbf3ce95cd 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -365,7 +365,7 @@ void DrawEngineVulkan::BindShaderBlendTex() { // Set the nearest/linear here (since we correctly know if alpha/color tests are needed)? if (!gstate.isModeClear()) { if (fboTexBindState_ == FBO_TEX_COPY_BIND_TEX) { - bool bindResult = framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY); + bool bindResult = framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY, Draw::ALL_LAYERS); _dbg_assert_(bindResult); boundSecondary_ = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::BOUND_TEXTURE1_IMAGEVIEW); boundSecondaryIsInputAttachment_ = false; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bcf5a47a48..f2425d6c41 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1359,9 +1359,9 @@ void EmuScreen::preRender() { if ((!useBufferedRendering && !g_Config.bSoftwareRendering) || Core_IsStepping()) { // We need to clear here already so that drawing during the frame is done on a clean slate. if (Core_IsStepping() && gpuStats.numFlips != 0) { - draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_BackBuffer"); + draw->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_BackBuffer"); } else { - draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "EmuScreen_BackBuffer"); + draw->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "EmuScreen_BackBuffer"); } Viewport viewport; @@ -1400,7 +1400,7 @@ void EmuScreen::render() { // It's possible this might be set outside PSP_RunLoopFor(). // In this case, we need to double check it here. checkPowerDown(); - thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_Invalid"); + thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_Invalid"); renderUI(); return; } @@ -1439,12 +1439,12 @@ void EmuScreen::render() { // Clear to blue background screen bool dangerousSettings = !Reporting::IsSupported(); uint32_t color = dangerousSettings ? 0xFF900050 : 0xFF900000; - thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE, color }, "EmuScreen_RuntimeError"); + thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE, color }, "EmuScreen_RuntimeError"); // The info is drawn later in renderUI } else { // If we're stepping, it's convenient not to clear the screen entirely, so we copy display to output. // This won't work in non-buffered, but that's fine. - thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_Stepping"); + thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_Stepping"); // Just to make sure. if (PSP_IsInited()) { gpu->CopyDisplayToOutput(true); @@ -1456,7 +1456,7 @@ void EmuScreen::render() { // Didn't actually reach the end of the frame, ran out of the blockTicks cycles. // In this case we need to bind and wipe the backbuffer, at least. // It's possible we never ended up outputted anything - make sure we have the backbuffer cleared - thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame"); + thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame"); break; } @@ -1470,7 +1470,7 @@ void EmuScreen::render() { if (hasVisibleUI()) { // In most cases, this should already be bound and a no-op. - thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_UI"); + thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_UI"); cardboardDisableButton_->SetVisibility(g_Config.bEnableCardboardVR ? UI::V_VISIBLE : UI::V_GONE); screenManager()->getUIContext()->BeginFrame(); renderUI(); diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index 63ecbc1691..67d3f25f66 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -1498,6 +1498,7 @@ + diff --git a/Windows/PPSSPP.vcxproj.filters b/Windows/PPSSPP.vcxproj.filters index 0706f8fb9c..9575308dd8 100644 --- a/Windows/PPSSPP.vcxproj.filters +++ b/Windows/PPSSPP.vcxproj.filters @@ -711,6 +711,9 @@ Other Platforms\SDL + + Resource Files + diff --git a/headless/Headless.cpp b/headless/Headless.cpp index ff5c3f94b4..8d02af8f21 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -240,7 +240,7 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const PSP_EndHostFrame(); if (draw) { - draw->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); + draw->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); // Vulkan may get angry if we don't do a final present. if (gpu) gpu->CopyDisplayToOutput(true); From 12d1f94d47274fb0c6ecff20a942107de1fd0573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 20 Oct 2022 16:16:52 +0200 Subject: [PATCH 250/374] Start stereo postshader work --- GPU/Common/PostShader.cpp | 1 + GPU/Common/PostShader.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index 2d8529f356..bdfce695c3 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -169,6 +169,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct info.vertexShaderFile = path / temp; section.Get("OutputResolution", &info.outputResolution, false); section.Get("Upscaling", &info.isUpscalingFilter, false); + section.Get("Stereo", &info.isStereo, false); section.Get("SSAA", &info.SSAAFilterLevel, 0); section.Get("60fps", &info.requires60fps, false); section.Get("UsePreviousFrame", &info.usePreviousFrame, false); diff --git a/GPU/Common/PostShader.h b/GPU/Common/PostShader.h index 5226638078..849ac884f3 100644 --- a/GPU/Common/PostShader.h +++ b/GPU/Common/PostShader.h @@ -39,6 +39,8 @@ struct ShaderInfo { bool outputResolution; // Use x1 rendering res + nearest screen scaling filter bool isUpscalingFilter; + // Is used to post-process stereo-rendering to mono, like red/blue. + bool isStereo; // Use 2x display resolution for supersampling with blurry shaders. int SSAAFilterLevel; // Force constant/max refresh for animated filters From 3ce8133656186d4ad4dbb557809a7e31f09d46ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Oct 2022 15:44:38 +0200 Subject: [PATCH 251/374] Non-stereo bugfix --- Common/GPU/Vulkan/VulkanRenderManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index b19112f4b2..972bd1ee6e 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -207,10 +207,10 @@ VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPas VkImageView views[2]{}; bool hasDepth = RenderPassTypeHasDepth(rpType); - views[0] = (multiview || numLayers == 0) ? color.imageView : color.layerViews[layer]; + views[0] = (multiview || numLayers == 1) ? color.imageView : color.layerViews[layer]; if (hasDepth) { _dbg_assert_(depth.imageView != VK_NULL_HANDLE); - views[1] = (multiview || numLayers == 0) ? depth.imageView : depth.layerViews[layer]; + views[1] = (multiview || numLayers == 1) ? depth.imageView : depth.layerViews[layer]; } fbci.renderPass = compatibleRenderPass->Get(vulkan_, rpType); fbci.attachmentCount = hasDepth ? 2 : 1; From c66873692449ece758c26bce7dfa1345a32ff021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 21 Oct 2022 12:35:49 +0200 Subject: [PATCH 252/374] Add a couple of stereo display shaders, add infrastructure, compile stereo pipelines --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 1 + Core/Config.cpp | 2 + Core/Config.h | 6 +++ GPU/Common/PostShader.cpp | 17 +++++-- GPU/Common/PresentationCommon.cpp | 74 +++++++++++++++++++++++------ GPU/Common/PresentationCommon.h | 5 +- GPU/GPU.vcxproj | 20 ++++++++ GPU/GPU.vcxproj.filters | 6 +++ UI/GameSettingsScreen.cpp | 22 +++++++-- UI/MiscScreens.cpp | 23 ++++++--- UI/MiscScreens.h | 4 +- assets/shaders/defaultshaders.ini | 17 +++++++ assets/shaders/stereo_red_blue.fsh | 34 +++++++++++++ assets/shaders/stereo_sbs.fsh | 18 +++++++ 14 files changed, 218 insertions(+), 31 deletions(-) create mode 100644 assets/shaders/stereo_red_blue.fsh create mode 100644 assets/shaders/stereo_sbs.fsh diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index d3b0d8581c..03fda5f805 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1483,6 +1483,7 @@ public: _assert_msg_(fb, "Null fb in VKFramebuffer constructor"); width_ = fb->width; height_ = fb->height; + layers_ = fb->numLayers; } ~VKFramebuffer() { _assert_msg_(buf_, "Null buf_ in VKFramebuffer - double delete?"); diff --git a/Core/Config.cpp b/Core/Config.cpp index 1e44ed482b..91457df787 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -888,6 +888,8 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("FrameSkip", &g_Config.iFrameSkip, 0, true, true), ReportedConfigSetting("FrameSkipType", &g_Config.iFrameSkipType, 0, true, true), ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false, true, true), + ConfigSetting("StereoRendering", &g_Config.bStereoRendering, false, true, true), + ConfigSetting("StereoToMonoShader", &g_Config.sStereoToMonoShader, "RedBlue", true, true), ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, true, true), ConfigSetting("FrameRate2", &g_Config.iFpsLimit2, -1, true, true), ConfigSetting("AnalogFrameRate", &g_Config.iAnalogFpsLimit, 240, true, true), diff --git a/Core/Config.h b/Core/Config.h index 497e8266bd..5a89c89732 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -241,6 +241,12 @@ public: std::vector vPostShaderNames; // Off for chain end (only Off for no shader) std::map mPostShaderSetting; + + // Note that this is separate from VR stereo, though it'll share some code paths. + bool bStereoRendering; + // There can only be one, unlike regular post shaders. + std::string sStereoToMonoShader; + bool bShaderChainRequires60FPS; std::string sTextureShaderName; bool bGfxDebugOutput; diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index bdfce695c3..43db9093ac 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -154,9 +154,11 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct continue; } - if (section.Exists("Fragment") && section.Exists("Vertex") && strncasecmp(shaderType.c_str(), "render", shaderType.size()) == 0) { + if (section.Exists("Fragment") && section.Exists("Vertex") && + (strncasecmp(shaderType.c_str(), "render", shaderType.size()) == 0 || + strncasecmp(shaderType.c_str(), "StereoToMono", shaderType.size()) == 0)) { // Valid shader! - ShaderInfo info; + ShaderInfo info{}; std::string temp; info.section = section.name(); @@ -169,7 +171,6 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct info.vertexShaderFile = path / temp; section.Get("OutputResolution", &info.outputResolution, false); section.Get("Upscaling", &info.isUpscalingFilter, false); - section.Get("Stereo", &info.isStereo, false); section.Get("SSAA", &info.SSAAFilterLevel, 0); section.Get("60fps", &info.requires60fps, false); section.Get("UsePreviousFrame", &info.usePreviousFrame, false); @@ -177,6 +178,12 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct if (info.parent == "Off") info.parent.clear(); + if (strncasecmp(shaderType.c_str(), "stereotomono", shaderType.size()) == 0) { + info.isStereo = true; + info.isUpscalingFilter = false; + info.parent.clear(); + } + for (size_t i = 0; i < ARRAY_SIZE(info.settings); ++i) { auto &setting = info.settings[i]; section.Get(StringFromFormat("SettingName%d", i + 1).c_str(), &setting.name, ""); @@ -207,7 +214,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct } } else if (section.Exists("Compute") && strncasecmp(shaderType.c_str(), "texture", shaderType.size()) == 0) { // This is a texture shader. - TextureShaderInfo info; + TextureShaderInfo info{}; std::string temp; info.section = section.name(); section.Get("Name", &info.name, section.name().c_str()); @@ -217,6 +224,8 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct if (info.scaleFactor >= 2 && info.scaleFactor < 8) { appendTextureShader(info); } + } else if (!section.name().empty()) { + WARN_LOG(G3D, "Unrecognized shader type '%s' or invalid shader in section '%s' : %d", shaderType.c_str(), section.name().c_str()); } } } diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 36453def3f..4350c08049 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -226,7 +226,19 @@ static std::string ReadShaderSrc(const Path &filename) { } // Note: called on resize and settings changes. +// Also takes care of making sure the appropriate stereo shader is compiled. bool PresentationCommon::UpdatePostShader() { + DestroyStereoShader(); + + if (g_Config.bStereoRendering) { + const ShaderInfo *stereoShaderInfo = GetPostShaderInfo(g_Config.sStereoToMonoShader); + bool result = CompilePostShader(stereoShaderInfo, &stereoPipeline_); + if (!result) { + // We won't have a stereo shader. We have to check for this later. + stereoPipeline_ = nullptr; + } + } + std::vector shaderInfo; if (!g_Config.vPostShaderNames.empty()) { ReloadAllPostShaderInfo(draw_); @@ -517,6 +529,7 @@ void PresentationCommon::DestroyDeviceObjects() { restorePostShader_ = usePostShader_; DestroyPostShader(); + DestroyStereoShader(); } void PresentationCommon::DestroyPostShader() { @@ -529,6 +542,10 @@ void PresentationCommon::DestroyPostShader() { postShaderFBOUsage_.clear(); } +void PresentationCommon::DestroyStereoShader() { + DoRelease(stereoPipeline_); +} + Draw::ShaderModule *PresentationCommon::CompileShaderModule(ShaderStage stage, ShaderLanguage lang, const std::string &src, std::string *errorString) const { std::string translated = src; if (lang != lang_) { @@ -562,13 +579,28 @@ void PresentationCommon::SourceFramebuffer(Draw::Framebuffer *fb, int bufferWidt srcHeight_ = bufferHeight; } -void PresentationCommon::BindSource(int binding) { +// Return value is if stereo binding succeeded. +bool PresentationCommon::BindSource(int binding, bool bindStereo) { if (srcTexture_) { draw_->BindTexture(binding, srcTexture_); + return false; } else if (srcFramebuffer_) { - draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); + if (bindStereo) { + if (srcFramebuffer_->Layers() > 1) { + draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, Draw::ALL_LAYERS); + return true; + } else { + // Single layer + draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); + return false; + } + } else { + draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); + return false; + } } else { _assert_(false); + return false; } } @@ -584,7 +616,9 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u // This should auto-disable usePostShader_ and call ShowPostShaderError(). bool useNearest = flags & OutputFlags::NEAREST; - const bool usePostShader = usePostShader_ && !(flags & OutputFlags::RB_SWIZZLE); + bool useStereo = g_Config.bStereoRendering && stereoPipeline_ != nullptr; // TODO: Also check that the backend has support for it. + + const bool usePostShader = usePostShader_ && !useStereo && !(flags & OutputFlags::RB_SWIZZLE); const bool isFinalAtOutputResolution = usePostShader && postShaderFramebuffers_.size() < postShaderPipelines_.size(); Draw::Framebuffer *postShaderOutput = nullptr; int lastWidth = srcWidth_; @@ -687,9 +721,9 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u if (postShaderOutput) { draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); } else { - BindSource(0); + BindSource(0, false); } - BindSource(1); + BindSource(1, false); if (shaderInfo->usePreviousFrame) draw_->BindFramebufferAsTexture(previousFramebuffer, 2, Draw::FB_COLOR_BIT, 0); @@ -768,22 +802,30 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u performShaderPass(shaderInfo, postShaderFramebuffer, postShaderPipeline); } - Draw::Pipeline *pipeline = (flags & OutputFlags::RB_SWIZZLE) ? texColorRBSwizzle_ : texColor_; - if (isFinalAtOutputResolution && previousFramebuffers_.empty()) { - pipeline = postShaderPipelines_.back(); - } - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "FinalBlit"); draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_); - draw_->BindPipeline(pipeline); + Draw::Pipeline *pipeline = (flags & OutputFlags::RB_SWIZZLE) ? texColorRBSwizzle_ : texColor_; - if (postShaderOutput) { - draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); + if (useStereo) { + draw_->BindPipeline(stereoPipeline_); + if (!BindSource(0, true)) { + // Fall back + draw_->BindPipeline(texColor_); + } } else { - BindSource(0); + if (isFinalAtOutputResolution && previousFramebuffers_.empty()) { + pipeline = postShaderPipelines_.back(); + } + + draw_->BindPipeline(pipeline); + if (postShaderOutput) { + draw_->BindFramebufferAsTexture(postShaderOutput, 0, Draw::FB_COLOR_BIT, 0); + } else { + BindSource(0, false); + } } - BindSource(1); + BindSource(1, false); if (isFinalAtOutputResolution && previousFramebuffers_.empty()) { CalculatePostShaderUniforms(lastWidth, lastHeight, (int)rc.w, (int)rc.h, &postShaderInfo_.back(), &uniforms); @@ -809,6 +851,8 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u CardboardSettings cardboardSettings; GetCardboardSettings(&cardboardSettings); if (cardboardSettings.enabled) { + // TODO: This could actually support stereo now, with an appropriate shader. + // This is what the left eye sees. setViewport(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight); draw_->DrawIndexed(6, 0); diff --git a/GPU/Common/PresentationCommon.h b/GPU/Common/PresentationCommon.h index c3faff6568..760753b31e 100644 --- a/GPU/Common/PresentationCommon.h +++ b/GPU/Common/PresentationCommon.h @@ -107,7 +107,9 @@ public: protected: void CreateDeviceObjects(); void DestroyDeviceObjects(); + void DestroyPostShader(); + void DestroyStereoShader(); static void ShowPostShaderError(const std::string &errorString); @@ -117,7 +119,7 @@ protected: bool BuildPostShader(const ShaderInfo *shaderInfo, const ShaderInfo *next, Draw::Pipeline **outPipeline); bool AllocateFramebuffer(int w, int h); - void BindSource(int binding); + bool BindSource(int binding, bool bindStereo); void GetCardboardSettings(CardboardSettings *cardboardSettings) const; void CalculatePostShaderUniforms(int bufferWidth, int bufferHeight, int targetWidth, int targetHeight, const ShaderInfo *shaderInfo, PostShaderUniforms *uniforms) const; @@ -131,6 +133,7 @@ protected: Draw::Buffer *idata_ = nullptr; std::vector postShaderPipelines_; + Draw::Pipeline *stereoPipeline_ = nullptr; std::vector postShaderFramebuffers_; std::vector postShaderInfo_; std::vector previousFramebuffers_; diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index 808ce53635..860dbc38f3 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -652,6 +652,26 @@ true true + + true + true + true + true + true + true + true + true + + + true + true + true + true + true + true + true + true + diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index e110c20b8b..b8a990374a 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -534,5 +534,11 @@ Shaders + + Shaders + + + Shaders + \ No newline at end of file diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 158fc547d0..53b54316e8 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -350,6 +350,22 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new ItemHeader(gr->T("Postprocessing effect"))); + if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) { + graphicsSettings->Add(new CheckBox(&g_Config.bStereoRendering, gr->T("Stereo rendering"))); + std::vector stereoShaderNames; + + ChoiceWithValueDisplay *stereoShaderChoice = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sStereoToMonoShader, "Stereo display shader", &PostShaderTranslateName)); + stereoShaderChoice->SetEnabledPtr(&g_Config.bStereoRendering); + stereoShaderChoice->OnClick.Add([=](EventParams &e) { + auto gr = GetI18NCategory("Graphics"); + auto procScreen = new PostProcScreen(gr->T("Stereo display shader"), 0, true); + if (e.v) + procScreen->SetPopupOrigin(e.v); + screenManager()->push(procScreen); + return UI::EVENT_DONE; + }); + } + std::set alreadyAddedShader; for (int i = 0; i < (int)g_Config.vPostShaderNames.size() + 1 && i < ARRAY_SIZE(shaderNames_); ++i) { // Vector element pointer get invalidated on resize, cache name to have always a valid reference in the rendering thread @@ -357,7 +373,7 @@ void GameSettingsScreen::CreateViews() { postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&shaderNames_[i], StringFromFormat("%s #%d", gr->T("Postprocessing Shader"), i + 1), &PostShaderTranslateName)); postProcChoice_->OnClick.Add([=](EventParams &e) { auto gr = GetI18NCategory("Graphics"); - auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i); + auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i, false); procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange); if (e.v) procScreen->SetPopupOrigin(e.v); @@ -365,7 +381,7 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_DONE; }); postProcChoice_->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !g_Config.bStereoRendering; }); // No need for settings on the last one. @@ -388,7 +404,7 @@ void GameSettingsScreen::CreateViews() { } else { PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); settingValue->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !g_Config.bStereoRendering; }); } } diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d90d92f76d..7d5421d0ec 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -521,7 +521,7 @@ void PromptScreen::TriggerFinish(DialogResult result) { UIDialogScreenWithBackground::TriggerFinish(result); } -PostProcScreen::PostProcScreen(const std::string &title, int id) : ListPopupScreen(title), id_(id) { } +PostProcScreen::PostProcScreen(const std::string &title, int id, bool showStereoShaders) : ListPopupScreen(title), id_(id), showStereoShaders_(showStereoShaders) { } void PostProcScreen::CreateViews() { auto ps = GetI18NCategory("PostShaders"); @@ -530,12 +530,16 @@ void PostProcScreen::CreateViews() { std::vector items; int selected = -1; const std::string selectedName = id_ >= (int)g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[id_]; + for (int i = 0; i < (int)shaders_.size(); i++) { if (!shaders_[i].visible) continue; + if (shaders_[i].isStereo != showStereoShaders_) + continue; if (shaders_[i].section == selectedName) - selected = i; + selected = (int)indexTranslation_.size(); items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str())); + indexTranslation_.push_back(i); } adaptor_ = UI::StringVectorListAdaptor(items, selected); ListPopupScreen::CreateViews(); @@ -544,11 +548,16 @@ void PostProcScreen::CreateViews() { void PostProcScreen::OnCompleted(DialogResult result) { if (result != DR_OK) return; - const std::string &value = shaders_[listView_->GetSelected()].section; - if (id_ < (int)g_Config.vPostShaderNames.size()) - g_Config.vPostShaderNames[id_] = value; - else - g_Config.vPostShaderNames.push_back(value); + const std::string &value = shaders_[indexTranslation_[listView_->GetSelected()]].section; + // I feel this logic belongs more in the caller, but eh... + if (showStereoShaders_) { + g_Config.sStereoToMonoShader = value; + } else { + if (id_ < (int)g_Config.vPostShaderNames.size()) + g_Config.vPostShaderNames[id_] = value; + else + g_Config.vPostShaderNames.push_back(value); + } } TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupScreen(title) {} diff --git a/UI/MiscScreens.h b/UI/MiscScreens.h index 164a06cfec..e799c20828 100644 --- a/UI/MiscScreens.h +++ b/UI/MiscScreens.h @@ -110,7 +110,7 @@ private: class PostProcScreen : public ListPopupScreen { public: - PostProcScreen(const std::string &title, int id); + PostProcScreen(const std::string &title, int id, bool showStereoShaders); void CreateViews() override; @@ -121,6 +121,8 @@ private: bool ShowButtons() const override { return true; } std::vector shaders_; int id_; + bool showStereoShaders_; + std::vector indexTranslation_; }; class TextureShaderScreen : public ListPopupScreen { diff --git a/assets/shaders/defaultshaders.ini b/assets/shaders/defaultshaders.ini index a125a09206..dbbcbd5c39 100644 --- a/assets/shaders/defaultshaders.ini +++ b/assets/shaders/defaultshaders.ini @@ -186,3 +186,20 @@ Name=MMPX (2x) Author=Morgan McGuire and Mara Gagiu Compute=tex_mmpx.csh Scale=2 +[RedBlue] +Type=StereoToMono +Name=Red/Blue glasses (anaglyph) +Author=Henrik Rydgård +SettingName1=ColorPreservation +SettingDefaultValue1=0.5 +SettingMaxValue1=1.0 +SettingMinValue1=1.0 +SettingStep1=0.05 +Fragment=stereo_red_blue.fsh +Vertex=fxaa.vsh +[SideBySize] +Type=StereoToMono +Name=SideBySide Stereo +Author=Henrik Rydgård +Fragment=stereo_sbs.fsh +Vertex=fxaa.vsh diff --git a/assets/shaders/stereo_red_blue.fsh b/assets/shaders/stereo_red_blue.fsh new file mode 100644 index 0000000000..9f0a806db3 --- /dev/null +++ b/assets/shaders/stereo_red_blue.fsh @@ -0,0 +1,34 @@ +// Red/Blue glasses stereo, also known as anaglyph. +// +// NOTE: Will only be compiled for Vulkan so doesn't follow all the usual conventions. + +uniform sampler2DArray sampler0; +varying vec2 v_texcoord0; + +uniform vec4 u_setting; + +void main() { + // To be adjusted. Used to desaturate colors. + vec3 grayDot = vec3(0.35, 0.5, 0.15); + // And these are the output color channels. + vec3 red = vec3(1.0, 0.0, 0.0); + vec3 blue = vec3(0.0, 0.0, 1.0); + // We should probably add the ability to tint the blue one between blue and green + // to match whatever glasses the user has. Not sure if there's any win to adjusting red. + + vec3 left = texture(sampler0, vec3(v_texcoord0, 0.0)).xyz; + vec3 right = texture(sampler0, vec3(v_texcoord0, 1.0)).xyz; + + float leftGray = dot(left, grayDot); + float rightGray = dot(right, grayDot); + + float saturation = u_setting.x; + + vec3 leftColor = mix(vec3(leftGray), left, saturation) * red; + vec3 rightColor = mix(vec3(rightGray), right, saturation) * blue; + + // TODO: Do something to gamma, maybe? + + gl_FragColor.rgb = leftColor + rightColor; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/stereo_sbs.fsh b/assets/shaders/stereo_sbs.fsh new file mode 100644 index 0000000000..c308f3aa0d --- /dev/null +++ b/assets/shaders/stereo_sbs.fsh @@ -0,0 +1,18 @@ +// Side by side stereo, useful for old 3D TVs. +// +// NOTE: Will only be compiled for Vulkan so doesn't follow all the usual conventions. + +uniform sampler2DArray sampler0; +varying vec2 v_texcoord0; + +uniform vec4 u_setting; + +void main() { + if (v_texcoord0.x < 0.5) { + gl_FragColor.rgb = texture(sampler0, vec3(v_texcoord0.x * 2.0, v_texcoord0.y, 0.0)).xyz; + } else { + gl_FragColor.rgb = texture(sampler0, vec3((v_texcoord0.x - 0.5) * 2.0, v_texcoord0.y, 1.0)).xyz; + } + + gl_FragColor.a = 1.0; +} From 2e87f0bc0b9e24cf5af05d172af6cf91324106e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 22 Oct 2022 17:34:23 +0200 Subject: [PATCH 253/374] More work. Things are starting to work now. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 1 + GPU/Common/PresentationCommon.cpp | 12 +++++++++++- GPU/Common/PresentationCommon.h | 5 ++++- GPU/Common/ShaderId.cpp | 4 ++++ GPU/Common/ShaderId.h | 2 +- GPU/Common/VertexShaderGenerator.cpp | 26 +++++++++++++++++++------- UI/GameSettingsScreen.cpp | 13 +++++++++++++ assets/shaders/defaultshaders.ini | 7 ++++++- assets/shaders/stereo_red_blue.fsh | 9 ++++----- 9 files changed, 63 insertions(+), 16 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 03fda5f805..87b30311d7 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -270,6 +270,7 @@ public: } void SetDynamicUniformData(const void *data, size_t size) { + _dbg_assert_(size <= uboSize_); memcpy(ubo_, data, size); } diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 4350c08049..fa3ab92c00 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -207,7 +207,7 @@ void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int buffer uniforms->gl_HalfPixel[0] = u_pixel_delta * 0.5f; uniforms->gl_HalfPixel[1] = v_pixel_delta * 0.5f; - uniforms->setting[0] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue1"];; + uniforms->setting[0] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue1"]; uniforms->setting[1] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue2"]; uniforms->setting[2] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue3"]; uniforms->setting[3] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue4"]; @@ -235,7 +235,11 @@ bool PresentationCommon::UpdatePostShader() { bool result = CompilePostShader(stereoShaderInfo, &stereoPipeline_); if (!result) { // We won't have a stereo shader. We have to check for this later. + delete stereoShaderInfo_; + stereoShaderInfo_ = nullptr; stereoPipeline_ = nullptr; + } else { + stereoShaderInfo_ = new ShaderInfo(*stereoShaderInfo); } } @@ -544,6 +548,8 @@ void PresentationCommon::DestroyPostShader() { void PresentationCommon::DestroyStereoShader() { DoRelease(stereoPipeline_); + delete stereoShaderInfo_; + stereoShaderInfo_ = nullptr; } Draw::ShaderModule *PresentationCommon::CompileShaderModule(ShaderStage stage, ShaderLanguage lang, const std::string &src, std::string *errorString) const { @@ -812,6 +818,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u if (!BindSource(0, true)) { // Fall back draw_->BindPipeline(texColor_); + useStereo = false; // Otherwise we end up uploading the wrong uniforms } } else { if (isFinalAtOutputResolution && previousFramebuffers_.empty()) { @@ -830,6 +837,9 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u if (isFinalAtOutputResolution && previousFramebuffers_.empty()) { CalculatePostShaderUniforms(lastWidth, lastHeight, (int)rc.w, (int)rc.h, &postShaderInfo_.back(), &uniforms); draw_->UpdateDynamicUniformBuffer(&uniforms, sizeof(uniforms)); + } else if (useStereo) { + CalculatePostShaderUniforms(lastWidth, lastHeight, (int)rc.w, (int)rc.h, stereoShaderInfo_, &uniforms); + draw_->UpdateDynamicUniformBuffer(&uniforms, sizeof(uniforms)); } else { Draw::VsTexColUB ub{}; memcpy(ub.WorldViewProj, g_display_rot_matrix.m, sizeof(float) * 16); diff --git a/GPU/Common/PresentationCommon.h b/GPU/Common/PresentationCommon.h index 760753b31e..d100230a46 100644 --- a/GPU/Common/PresentationCommon.h +++ b/GPU/Common/PresentationCommon.h @@ -133,10 +133,13 @@ protected: Draw::Buffer *idata_ = nullptr; std::vector postShaderPipelines_; - Draw::Pipeline *stereoPipeline_ = nullptr; std::vector postShaderFramebuffers_; std::vector postShaderInfo_; std::vector previousFramebuffers_; + + Draw::Pipeline *stereoPipeline_ = nullptr; + ShaderInfo *stereoShaderInfo_ = nullptr; + int previousIndex_ = 0; PostShaderUniforms previousUniforms_{}; diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index d7dd5e2c6e..1acad76ab4 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -92,6 +92,10 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, id.SetBit(VS_BIT_HAS_COLOR, hasColor); id.SetBit(VS_BIT_VERTEX_RANGE_CULLING, vertexRangeCulling); + if (!isModeThrough && VS_BIT_SIMPLE_STEREO) { + id.SetBit(VS_BIT_SIMPLE_STEREO); + } + if (doTexture) { id.SetBit(VS_BIT_DO_TEXTURE); diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 120264b628..de1a6b0985 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -15,7 +15,7 @@ enum VShaderBit : uint8_t { VS_BIT_HAS_COLOR = 3, VS_BIT_DO_TEXTURE = 4, VS_BIT_VERTEX_RANGE_CULLING = 5, - // 6 is free, + VS_BIT_SIMPLE_STEREO = 6, // 7 is free. VS_BIT_USE_HW_TRANSFORM = 8, VS_BIT_HAS_NORMAL = 9, // conditioned on hw transform diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index b0c3cbca50..3eb92c4bcd 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -136,27 +136,33 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag bool highpFog = false; bool highpTexcoord = false; - std::vector gl_exts; + std::vector extensions; if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { if (gl_extensions.EXT_gpu_shader4) { - gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); + extensions.push_back("#extension GL_EXT_gpu_shader4 : enable"); } bool useClamp = gstate_c.Use(GPU_USE_DEPTH_CLAMP) && !id.Bit(VS_BIT_IS_THROUGH); if (gl_extensions.EXT_clip_cull_distance && (id.Bit(VS_BIT_VERTEX_RANGE_CULLING) || useClamp)) { - gl_exts.push_back("#extension GL_EXT_clip_cull_distance : enable"); + extensions.push_back("#extension GL_EXT_clip_cull_distance : enable"); } if (gl_extensions.APPLE_clip_distance && (id.Bit(VS_BIT_VERTEX_RANGE_CULLING) || useClamp)) { - gl_exts.push_back("#extension GL_APPLE_clip_distance : enable"); + extensions.push_back("#extension GL_APPLE_clip_distance : enable"); } if (gl_extensions.ARB_cull_distance && id.Bit(VS_BIT_VERTEX_RANGE_CULLING)) { - gl_exts.push_back("#extension GL_ARB_cull_distance : enable"); + extensions.push_back("#extension GL_ARB_cull_distance : enable"); } if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY) && gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { - gl_exts.push_back("#extension GL_OVR_multiview2 : enable\nlayout(num_views=2) in;"); + extensions.push_back("#extension GL_OVR_multiview2 : enable\nlayout(num_views=2) in;"); } } - ShaderWriter p(buffer, compat, ShaderStage::Vertex, gl_exts); + bool useSimpleStereo = id.Bit(VS_BIT_SIMPLE_STEREO); + + if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN && useSimpleStereo) { + extensions.push_back("#extension GL_EXT_multiview : enable"); + } + + ShaderWriter p(buffer, compat, ShaderStage::Vertex, extensions); bool isModeThrough = id.Bit(VS_BIT_IS_THROUGH); bool lmode = id.Bit(VS_BIT_LMODE); @@ -1341,6 +1347,12 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " }\n"); } + if (useSimpleStereo) { + p.C(" float zFactor = 0.2 * float(gl_ViewIndex * 2 - 1);\n"); + p.C(" float zFocus = 0.0;\n"); + p.C(" gl_Position.x += (-gl_Position.z - zFocus) * zFactor;\n"); + } + if (needsZWHack) { // See comment in thin3d_vulkan.cpp. WRITE(p, " if (%sgl_Position.z == %sgl_Position.w) %sgl_Position.z *= 0.999999;\n", diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 53b54316e8..1d1d9c0125 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -364,6 +364,19 @@ void GameSettingsScreen::CreateViews() { screenManager()->push(procScreen); return UI::EVENT_DONE; }); + const ShaderInfo *shaderInfo = GetPostShaderInfo(g_Config.sStereoToMonoShader); + if (shaderInfo) { + for (size_t i = 0; i < ARRAY_SIZE(shaderInfo->settings); ++i) { + auto &setting = shaderInfo->settings[i]; + if (!setting.name.empty()) { + auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)]; + PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); + settingValue->SetEnabledFunc([] { + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && g_Config.bStereoRendering; + }); + } + } + } } std::set alreadyAddedShader; diff --git a/assets/shaders/defaultshaders.ini b/assets/shaders/defaultshaders.ini index dbbcbd5c39..79bb4bb5e6 100644 --- a/assets/shaders/defaultshaders.ini +++ b/assets/shaders/defaultshaders.ini @@ -193,8 +193,13 @@ Author=Henrik Rydgård SettingName1=ColorPreservation SettingDefaultValue1=0.5 SettingMaxValue1=1.0 -SettingMinValue1=1.0 +SettingMinValue1=0.0 SettingStep1=0.05 +SettingName2=GreenLevel +SettingDefaultValue2=0.5 +SettingMaxValue2=1.0 +SettingMinValue2=0.0 +SettingStep2=0.05 Fragment=stereo_red_blue.fsh Vertex=fxaa.vsh [SideBySize] diff --git a/assets/shaders/stereo_red_blue.fsh b/assets/shaders/stereo_red_blue.fsh index 9f0a806db3..b8156ee458 100644 --- a/assets/shaders/stereo_red_blue.fsh +++ b/assets/shaders/stereo_red_blue.fsh @@ -8,13 +8,14 @@ varying vec2 v_texcoord0; uniform vec4 u_setting; void main() { + float saturation = u_setting.x; + float greenMix = u_setting.y; + // To be adjusted. Used to desaturate colors. vec3 grayDot = vec3(0.35, 0.5, 0.15); // And these are the output color channels. vec3 red = vec3(1.0, 0.0, 0.0); - vec3 blue = vec3(0.0, 0.0, 1.0); - // We should probably add the ability to tint the blue one between blue and green - // to match whatever glasses the user has. Not sure if there's any win to adjusting red. + vec3 blue = vec3(0.0, greenMix, 1.0); vec3 left = texture(sampler0, vec3(v_texcoord0, 0.0)).xyz; vec3 right = texture(sampler0, vec3(v_texcoord0, 1.0)).xyz; @@ -22,8 +23,6 @@ void main() { float leftGray = dot(left, grayDot); float rightGray = dot(right, grayDot); - float saturation = u_setting.x; - vec3 leftColor = mix(vec3(leftGray), left, saturation) * red; vec3 rightColor = mix(vec3(rightGray), right, saturation) * blue; From 0de12f5ca979207088789cbcf6330f979d657c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Oct 2022 11:21:35 +0200 Subject: [PATCH 254/374] Some refactoring of framebuffer views, layer issues, more work. --- Common/GPU/D3D11/thin3d_d3d11.cpp | 5 +- Common/GPU/D3D9/thin3d_d3d9.cpp | 5 +- Common/GPU/OpenGL/thin3d_gl.cpp | 6 +- Common/GPU/Vulkan/VulkanBarrier.h | 8 +- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 121 ++++++++++++---------- Common/GPU/Vulkan/VulkanQueueRunner.h | 2 +- Common/GPU/Vulkan/VulkanRenderManager.cpp | 105 +++++++++---------- Common/GPU/Vulkan/VulkanRenderManager.h | 22 ++-- Common/GPU/Vulkan/thin3d_vulkan.cpp | 15 ++- Common/GPU/thin3d.h | 10 +- Common/UI/UIScreen.cpp | 2 +- GPU/Common/FragmentShaderGenerator.cpp | 26 +++-- GPU/Common/FramebufferManagerCommon.cpp | 37 ++++--- GPU/Common/FramebufferManagerCommon.h | 2 - GPU/Common/PresentationCommon.cpp | 6 +- GPU/Common/ShaderId.cpp | 10 +- GPU/Common/ShaderId.h | 2 +- GPU/Common/StencilCommon.cpp | 6 +- GPU/Common/TextureCacheCommon.cpp | 4 +- GPU/GLES/DepthBufferGLES.cpp | 4 +- GPU/GLES/FramebufferManagerGLES.cpp | 4 +- GPU/Software/SoftGpu.cpp | 2 +- GPU/Vulkan/DrawEngineVulkan.cpp | 13 ++- GPU/Vulkan/StateMappingVulkan.cpp | 5 +- UI/EmuScreen.cpp | 14 +-- assets/shaders/stereo_red_blue.fsh | 2 - headless/Headless.cpp | 2 +- 27 files changed, 237 insertions(+), 203 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index b7972d49ed..aca3aaae93 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -94,7 +94,7 @@ public: bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1655,8 +1655,7 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel return true; } -void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { - _dbg_assert_(layer == ALL_LAYERS || layer == 0); // No multiple layer support on D3D +void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { // TODO: deviceContext1 can actually discard. Useful on Windows Mobile. if (fbo) { D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo; diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index ba51fb42fa..4c3a83c2f5 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -531,7 +531,7 @@ public: bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; uintptr_t GetFramebufferAPITexture(Framebuffer *fbo, int channelBits, int attachment) override; @@ -1289,8 +1289,7 @@ D3D9Framebuffer::~D3D9Framebuffer() { } } -void D3D9Context::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { - _dbg_assert_(layer == ALL_LAYERS || layer == 0); // No stereo support +void D3D9Context::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { if (fbo) { D3D9Framebuffer *fb = (D3D9Framebuffer *)fbo; device_->SetRenderTarget(0, fb->surf); diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 53f294c35d..fe26e38591 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -354,7 +354,7 @@ public: bool CopyFramebufferToMemorySync(Framebuffer *src, int channelBits, int x, int y, int w, int h, Draw::DataFormat format, void *pixels, int pixelStride, const char *tag) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; @@ -1395,9 +1395,7 @@ Framebuffer *OpenGLContext::CreateFramebuffer(const FramebufferDesc &desc) { return fbo; } -void OpenGLContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { - _dbg_assert_(layer == ALL_LAYERS || layer == 0); - +void OpenGLContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { OpenGLFramebuffer *fb = (OpenGLFramebuffer *)fbo; GLRRenderPassAction color = (GLRRenderPassAction)rp.color; GLRRenderPassAction depth = (GLRRenderPassAction)rp.depth; diff --git a/Common/GPU/Vulkan/VulkanBarrier.h b/Common/GPU/Vulkan/VulkanBarrier.h index 19edc548ba..1fefb5adfa 100644 --- a/Common/GPU/Vulkan/VulkanBarrier.h +++ b/Common/GPU/Vulkan/VulkanBarrier.h @@ -14,7 +14,7 @@ class VulkanContext; class VulkanBarrier { public: void TransitionImage( - VkImage image, int baseMip, int numMipLevels, VkImageAspectFlags aspectMask, + VkImage image, int baseMip, int numMipLevels, int numLayers, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask @@ -36,7 +36,7 @@ public: imageBarrier.subresourceRange.aspectMask = aspectMask; imageBarrier.subresourceRange.baseMipLevel = baseMip; imageBarrier.subresourceRange.levelCount = numMipLevels; - imageBarrier.subresourceRange.layerCount = 1; // We never use more than one layer, and old Mali drivers have problems with VK_REMAINING_ARRAY_LAYERS/VK_REMAINING_MIP_LEVELS. + imageBarrier.subresourceRange.layerCount = numLayers; // NOTE: We could usually use VK_REMAINING_ARRAY_LAYERS/VK_REMAINING_MIP_LEVELS, but really old Mali drivers have problems with those. imageBarrier.subresourceRange.baseArrayLayer = 0; imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; @@ -46,7 +46,7 @@ public: // Automatically determines access and stage masks from layouts. // Not universally usable, but works for PPSSPP's use. void TransitionImageAuto( - VkImage image, int baseMip, int numMipLevels, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout + VkImage image, int baseMip, int numMipLevels, int numLayers, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, VkImageLayout newImageLayout ) { _dbg_assert_(image != VK_NULL_HANDLE); @@ -104,7 +104,7 @@ public: imageBarrier.subresourceRange.aspectMask = aspectMask; imageBarrier.subresourceRange.baseMipLevel = baseMip; imageBarrier.subresourceRange.levelCount = numMipLevels; - imageBarrier.subresourceRange.layerCount = 1; // We never use more than one layer, and old Mali drivers have problems with VK_REMAINING_ARRAY_LAYERS/VK_REMAINING_MIP_LEVELS. + imageBarrier.subresourceRange.layerCount = numLayers; // NOTE: We could usually use VK_REMAINING_ARRAY_LAYERS/VK_REMAINING_MIP_LEVELS, but really old Mali drivers have problems with those. imageBarrier.subresourceRange.baseArrayLayer = 0; imageBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; imageBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 07371dfba9..7b314cc0d1 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -37,6 +37,8 @@ RenderPassType MergeRPTypes(RenderPassType a, RenderPassType b) { return a; } + _dbg_assert_((a & RP_TYPE_MULTIVIEW_COLOR) == (b & RP_TYPE_MULTIVIEW_COLOR)); + // The rest we can just OR together to get the maximum feature set. return (RenderPassType)((u32)a | (u32)b); } @@ -166,7 +168,7 @@ bool VulkanQueueRunner::CreateSwapchain(VkCommandBuffer cmdInit) { color_image_view.subresourceRange.baseMipLevel = 0; color_image_view.subresourceRange.levelCount = 1; color_image_view.subresourceRange.baseArrayLayer = 0; - color_image_view.subresourceRange.layerCount = 1; + color_image_view.subresourceRange.layerCount = 1; // TODO: Investigate hw-assisted stereo. color_image_view.viewType = VK_IMAGE_VIEW_TYPE_2D; color_image_view.flags = 0; color_image_view.image = sc_buffer.image; @@ -475,6 +477,7 @@ void VulkanQueueRunner::SelfDependencyBarrier(VKRImage &img, VkImageAspectFlags img.image, 0, 1, + img.numLayers, aspect, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL, @@ -1167,7 +1170,7 @@ void VulkanQueueRunner::LogReadbackImage(const VKRStep &step) { INFO_LOG(G3D, "%s", StepToString(step).c_str()); } -void TransitionToOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout colorLayout, VkImage depthStencilImage, VkImageLayout depthStencilLayout, VulkanBarrier *recordBarrier) { +void TransitionToOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout colorLayout, VkImage depthStencilImage, VkImageLayout depthStencilLayout, int numLayers, VulkanBarrier *recordBarrier) { if (colorLayout != VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) { VkPipelineStageFlags srcStageMask = 0; VkAccessFlags srcAccessMask = 0; @@ -1200,7 +1203,7 @@ void TransitionToOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout break; } recordBarrier->TransitionImage( - colorImage, 0, 1, VK_IMAGE_ASPECT_COLOR_BIT, + colorImage, 0, 1, numLayers, VK_IMAGE_ASPECT_COLOR_BIT, colorLayout, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, srcAccessMask, @@ -1236,7 +1239,7 @@ void TransitionToOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout break; } recordBarrier->TransitionImage( - depthStencilImage, 0, 1, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, + depthStencilImage, 0, 1, numLayers, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, depthStencilLayout, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, srcAccessMask, @@ -1246,7 +1249,7 @@ void TransitionToOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout } } -void TransitionFromOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout colorLayout, VkImage depthStencilImage, VkImageLayout depthStencilLayout) { +void TransitionFromOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayout colorLayout, VkImage depthStencilImage, int numLayers, VkImageLayout depthStencilLayout) { VkPipelineStageFlags srcStageMask = 0; VkPipelineStageFlags dstStageMask = 0; @@ -1288,7 +1291,7 @@ void TransitionFromOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayou barrier[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; barrier[0].subresourceRange.baseMipLevel = 0; barrier[0].subresourceRange.levelCount = 1; - barrier[0].subresourceRange.layerCount = 1; + barrier[0].subresourceRange.layerCount = numLayers; barrier[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrier[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrierCount++; @@ -1327,7 +1330,7 @@ void TransitionFromOptimal(VkCommandBuffer cmd, VkImage colorImage, VkImageLayou barrier[barrierCount].subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; barrier[barrierCount].subresourceRange.baseMipLevel = 0; barrier[barrierCount].subresourceRange.levelCount = 1; - barrier[barrierCount].subresourceRange.layerCount = 1; + barrier[barrierCount].subresourceRange.layerCount = numLayers; barrier[barrierCount].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrier[barrierCount].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barrierCount++; @@ -1345,6 +1348,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c iter.fb->color.image, 0, 1, + iter.fb->numLayers, VK_IMAGE_ASPECT_COLOR_BIT, iter.fb->color.layout, iter.targetLayout @@ -1355,6 +1359,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c iter.fb->depth.image, 0, 1, + iter.fb->numLayers, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, iter.fb->depth.layout, iter.targetLayout @@ -1384,6 +1389,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c step.render.framebuffer->color.image, 0, 1, + step.render.framebuffer->numLayers, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, @@ -1398,6 +1404,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c step.render.framebuffer->depth.image, 0, 1, + step.render.framebuffer->numLayers, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, @@ -1583,7 +1590,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c int numAttachments = 0; VkClearRect rc{}; rc.baseArrayLayer = 0; - rc.layerCount = 1; + rc.layerCount = c.clear.numLayers; rc.rect.extent.width = (uint32_t)curWidth; rc.rect.extent.height = (uint32_t)curHeight; VkClearAttachment attachments[2]{}; @@ -1627,7 +1634,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c if (fb) { // If the desired final layout aren't the optimal layout for rendering, transition. - TransitionFromOptimal(cmd, fb->color.image, step.render.finalColorLayout, fb->depth.image, step.render.finalDepthStencilLayout); + TransitionFromOptimal(cmd, fb->color.image, step.render.finalColorLayout, fb->depth.image, fb->numLayers, step.render.finalDepthStencilLayout); fb->color.layout = step.render.finalColorLayout; fb->depth.layout = step.render.finalDepthStencilLayout; @@ -1655,7 +1662,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR renderPass = GetRenderPass(key); VKRFramebuffer *fb = step.render.framebuffer; - framebuf = fb->Get(renderPass, step.render.renderPassType, step.render.layer); + framebuf = fb->Get(renderPass, step.render.renderPassType); _dbg_assert_(framebuf != VK_NULL_HANDLE); w = fb->width; h = fb->height; @@ -1668,7 +1675,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR step.render.colorLoad == VKRRenderPassLoadAction::CLEAR && vulkan_->GetPhysicalDeviceProperties().properties.driverVersion == 0xaa9c4b29; if (maliBugWorkaround) { - recordBarrier_.TransitionImage(step.render.framebuffer->color.image, 0, 1, VK_IMAGE_ASPECT_COLOR_BIT, + recordBarrier_.TransitionImage(fb->color.image, 0, 1, fb->numLayers, VK_IMAGE_ASPECT_COLOR_BIT, fb->color.layout, VK_IMAGE_LAYOUT_GENERAL, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, @@ -1676,7 +1683,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR fb->color.layout = VK_IMAGE_LAYOUT_GENERAL; } - TransitionToOptimal(cmd, fb->color.image, fb->color.layout, fb->depth.image, fb->depth.layout, &recordBarrier_); + TransitionToOptimal(cmd, fb->color.image, fb->color.layout, fb->depth.image, fb->depth.layout, fb->numLayers, &recordBarrier_); // The transition from the optimal format happens after EndRenderPass, now that we don't // do it as part of the renderpass itself anymore. @@ -1746,20 +1753,11 @@ void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) { VKRFramebuffer *src = step.copy.src; VKRFramebuffer *dst = step.copy.dst; - VkImageCopy copy{}; - copy.srcOffset.x = step.copy.srcRect.offset.x; - copy.srcOffset.y = step.copy.srcRect.offset.y; - copy.srcOffset.z = 0; - copy.srcSubresource.mipLevel = 0; - copy.srcSubresource.layerCount = 1; - copy.dstOffset.x = step.copy.dstPos.x; - copy.dstOffset.y = step.copy.dstPos.y; - copy.dstOffset.z = 0; - copy.dstSubresource.mipLevel = 0; - copy.dstSubresource.layerCount = 1; - copy.extent.width = step.copy.srcRect.extent.width; - copy.extent.height = step.copy.srcRect.extent.height; - copy.extent.depth = 1; + int layerCount = std::min(step.copy.src->numLayers, step.copy.dst->numLayers); + _dbg_assert_(step.copy.src->numLayers >= step.copy.dst->numLayers); + + // TODO: If dst covers exactly the whole destination, we can set up a UNDEFINED->TRANSFER_DST_OPTIMAL transition, + // which can potentially be more efficient. // First source barriers. if (step.copy.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { @@ -1790,6 +1788,21 @@ void VulkanQueueRunner::PerformCopy(const VKRStep &step, VkCommandBuffer cmd) { recordBarrier_.Flush(cmd); + VkImageCopy copy{}; + copy.srcOffset.x = step.copy.srcRect.offset.x; + copy.srcOffset.y = step.copy.srcRect.offset.y; + copy.srcOffset.z = 0; + copy.srcSubresource.mipLevel = 0; + copy.srcSubresource.layerCount = layerCount; + copy.dstOffset.x = step.copy.dstPos.x; + copy.dstOffset.y = step.copy.dstPos.y; + copy.dstOffset.z = 0; + copy.dstSubresource.mipLevel = 0; + copy.dstSubresource.layerCount = layerCount; + copy.extent.width = step.copy.srcRect.extent.width; + copy.extent.height = step.copy.srcRect.extent.height; + copy.extent.depth = 1; + if (step.copy.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { copy.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copy.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1808,35 +1821,12 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { // The barrier code doesn't handle this case. We'd need to transition to GENERAL to do an intra-image copy. _dbg_assert_(step.blit.src != step.blit.dst); + int layerCount = std::min(step.blit.src->numLayers, step.blit.dst->numLayers); + _dbg_assert_(step.blit.src->numLayers >= step.blit.dst->numLayers); + VKRFramebuffer *src = step.blit.src; VKRFramebuffer *dst = step.blit.dst; - // If any validation needs to be performed here, it should probably have been done - // already when the blit was queued. So don't validate here. - VkImageBlit blit{}; - blit.srcOffsets[0].x = step.blit.srcRect.offset.x; - blit.srcOffsets[0].y = step.blit.srcRect.offset.y; - blit.srcOffsets[0].z = 0; - blit.srcOffsets[1].x = step.blit.srcRect.offset.x + step.blit.srcRect.extent.width; - blit.srcOffsets[1].y = step.blit.srcRect.offset.y + step.blit.srcRect.extent.height; - blit.srcOffsets[1].z = 1; - blit.srcSubresource.mipLevel = 0; - blit.srcSubresource.layerCount = 1; - blit.dstOffsets[0].x = step.blit.dstRect.offset.x; - blit.dstOffsets[0].y = step.blit.dstRect.offset.y; - blit.dstOffsets[0].z = 0; - blit.dstOffsets[1].x = step.blit.dstRect.offset.x + step.blit.dstRect.extent.width; - blit.dstOffsets[1].y = step.blit.dstRect.offset.y + step.blit.dstRect.extent.height; - blit.dstOffsets[1].z = 1; - blit.dstSubresource.mipLevel = 0; - blit.dstSubresource.layerCount = 1; - - VkPipelineStageFlags srcStage = 0; - VkPipelineStageFlags dstStage = 0; - - int srcCount = 0; - int dstCount = 0; - // First source barriers. if (step.blit.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { if (src->color.layout != VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) { @@ -1862,6 +1852,26 @@ void VulkanQueueRunner::PerformBlit(const VKRStep &step, VkCommandBuffer cmd) { recordBarrier_.Flush(cmd); + // If any validation needs to be performed here, it should probably have been done + // already when the blit was queued. So don't validate here. + VkImageBlit blit{}; + blit.srcOffsets[0].x = step.blit.srcRect.offset.x; + blit.srcOffsets[0].y = step.blit.srcRect.offset.y; + blit.srcOffsets[0].z = 0; + blit.srcOffsets[1].x = step.blit.srcRect.offset.x + step.blit.srcRect.extent.width; + blit.srcOffsets[1].y = step.blit.srcRect.offset.y + step.blit.srcRect.extent.height; + blit.srcOffsets[1].z = 1; + blit.srcSubresource.mipLevel = 0; + blit.srcSubresource.layerCount = layerCount; + blit.dstOffsets[0].x = step.blit.dstRect.offset.x; + blit.dstOffsets[0].y = step.blit.dstRect.offset.y; + blit.dstOffsets[0].z = 0; + blit.dstOffsets[1].x = step.blit.dstRect.offset.x + step.blit.dstRect.extent.width; + blit.dstOffsets[1].y = step.blit.dstRect.offset.y + step.blit.dstRect.extent.height; + blit.dstOffsets[1].z = 1; + blit.dstSubresource.mipLevel = 0; + blit.dstSubresource.layerCount = layerCount; + if (step.blit.aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) { blit.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; blit.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; @@ -1922,6 +1932,7 @@ void VulkanQueueRunner::SetupTransitionToTransferSrc(VKRImage &img, VkImageAspec img.image, 0, 1, + img.numLayers, imageAspect, img.layout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, @@ -1970,6 +1981,7 @@ void VulkanQueueRunner::SetupTransitionToTransferDst(VKRImage &img, VkImageAspec img.image, 0, 1, + img.numLayers, aspect, img.layout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -1999,6 +2011,7 @@ void VulkanQueueRunner::SetupTransferDstWriteAfterWrite(VKRImage &img, VkImageAs img.image, 0, 1, + img.numLayers, aspect, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -2027,6 +2040,7 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd if (step.readback.src == nullptr) { // We only take screenshots after the main render pass (anything else would be stupid) so we need to transition out of PRESENT, // and then back into it. + // Regarding layers, backbuffer currently only has one layer. TransitionImageLayout2(cmd, backbufferImage_, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, @@ -2061,6 +2075,7 @@ void VulkanQueueRunner::PerformReadback(const VKRStep &step, VkCommandBuffer cmd if (step.readback.src == nullptr) { // We only take screenshots after the main render pass (anything else would be stupid) so we need to transition out of PRESENT, // and then back into it. + // Regarding layers, backbuffer currently only has one layer. TransitionImageLayout2(cmd, backbufferImage_, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, @@ -2092,7 +2107,7 @@ void VulkanQueueRunner::PerformReadbackImage(const VKRStep &step, VkCommandBuffe vkCmdCopyImageToBuffer(cmd, step.readback_image.image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, readbackBuffer_, 1, ®ion); // Now transfer it back to a texture. - TransitionImageLayout2(cmd, step.readback_image.image, 0, 1, 1, // TODO: Handle multiple layers + TransitionImageLayout2(cmd, step.readback_image.image, 0, 1, 1, // I don't think we have any multilayer cases for regular textures. Above in PerformReadback, though.. VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index d51f2b638b..ffac3003fa 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -129,6 +129,7 @@ struct VkRenderData { float clearZ; int clearStencil; int clearMask; // VK_IMAGE_ASPECT_COLOR_BIT etc + int numLayers; } clear; struct { VkViewport vp; @@ -212,7 +213,6 @@ struct VKRStep { VKRRenderPassStoreAction depthStore; VKRRenderPassStoreAction stencilStore; u8 clearStencil; - s8 layer; uint32_t clearColor; float clearDepth; int numDraws; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 972bd1ee6e..8c82fa00d1 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -175,42 +175,34 @@ void VKRFramebuffer::UpdateTag(const char *newTag) { char name[128]; snprintf(name, sizeof(name), "fb_color_%s", tag_.c_str()); vulkan_->SetDebugName(color.image, VK_OBJECT_TYPE_IMAGE, name); - vulkan_->SetDebugName(color.imageView, VK_OBJECT_TYPE_IMAGE_VIEW, name); + vulkan_->SetDebugName(color.rtView, VK_OBJECT_TYPE_IMAGE_VIEW, name); if (depth.image) { snprintf(name, sizeof(name), "fb_depth_%s", tag_.c_str()); vulkan_->SetDebugName(depth.image, VK_OBJECT_TYPE_IMAGE, name); - vulkan_->SetDebugName(depth.imageView, VK_OBJECT_TYPE_IMAGE_VIEW, name); + vulkan_->SetDebugName(depth.rtView, VK_OBJECT_TYPE_IMAGE_VIEW, name); } for (int rpType = 0; rpType < RP_TYPE_COUNT; rpType++) { - for (int i = 0; i < 2; i++) { - if (framebuf[rpType][i]) { - snprintf(name, sizeof(name), "fb_%s_%d", tag_.c_str(), i); - vulkan_->SetDebugName(framebuf[(int)rpType][i], VK_OBJECT_TYPE_FRAMEBUFFER, name); - } + if (framebuf[rpType]) { + snprintf(name, sizeof(name), "fb_%s", tag_.c_str()); + vulkan_->SetDebugName(framebuf[(int)rpType], VK_OBJECT_TYPE_FRAMEBUFFER, name); } } } -VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, int layer) { +VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType) { bool multiview = RenderPassTypeHasMultiView(rpType); - - if (RenderPassTypeHasMultiView(rpType)) { - _dbg_assert_(layer == -1); - layer = 0; - } - if (framebuf[(int)rpType][layer]) { - return framebuf[(int)rpType][layer]; + if (framebuf[(int)rpType]) { + return framebuf[(int)rpType]; } VkFramebufferCreateInfo fbci{ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; VkImageView views[2]{}; bool hasDepth = RenderPassTypeHasDepth(rpType); - views[0] = (multiview || numLayers == 1) ? color.imageView : color.layerViews[layer]; + views[0] = color.rtView; // 2D array texture if multilayered. if (hasDepth) { - _dbg_assert_(depth.imageView != VK_NULL_HANDLE); - views[1] = (multiview || numLayers == 1) ? depth.imageView : depth.layerViews[layer]; + views[1] = depth.rtView; } fbci.renderPass = compatibleRenderPass->Get(vulkan_, rpType); fbci.attachmentCount = hasDepth ? 2 : 1; @@ -219,21 +211,35 @@ VkFramebuffer VKRFramebuffer::Get(VKRRenderPass *compatibleRenderPass, RenderPas fbci.height = height; fbci.layers = 1; // With multiview, this should be set as 1. - VkResult res = vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf[(int)rpType][layer]); + VkResult res = vkCreateFramebuffer(vulkan_->GetDevice(), &fbci, nullptr, &framebuf[(int)rpType]); _assert_(res == VK_SUCCESS); if (!tag_.empty() && vulkan_->Extensions().EXT_debug_utils) { - vulkan_->SetDebugName(framebuf[(int)rpType][layer], VK_OBJECT_TYPE_FRAMEBUFFER, StringFromFormat("fb_%s_%d", tag_.c_str(), layer).c_str()); + vulkan_->SetDebugName(framebuf[(int)rpType], VK_OBJECT_TYPE_FRAMEBUFFER, StringFromFormat("fb_%s", tag_.c_str()).c_str()); } - return framebuf[(int)rpType][layer]; + return framebuf[(int)rpType]; } VKRFramebuffer::~VKRFramebuffer() { - if (color.imageView) - vulkan_->Delete().QueueDeleteImageView(color.imageView); - if (depth.imageView) - vulkan_->Delete().QueueDeleteImageView(depth.imageView); + // Get rid of the views first, feels cleaner (but in reality doesn't matter). + if (color.rtView) + vulkan_->Delete().QueueDeleteImageView(color.rtView); + if (depth.rtView) + vulkan_->Delete().QueueDeleteImageView(depth.rtView); + if (color.texAllLayersView) + vulkan_->Delete().QueueDeleteImageView(color.texAllLayersView); + if (depth.texAllLayersView) + vulkan_->Delete().QueueDeleteImageView(depth.texAllLayersView); + for (int i = 0; i < 2; i++) { + if (color.texLayerViews[i]) { + vulkan_->Delete().QueueDeleteImageView(color.texLayerViews[i]); + } + if (depth.texLayerViews[i]) { + vulkan_->Delete().QueueDeleteImageView(depth.texLayerViews[i]); + } + } + if (color.image) { _dbg_assert_(color.alloc); vulkan_->Delete().QueueDeleteImageAllocation(color.image, color.alloc); @@ -242,21 +248,9 @@ VKRFramebuffer::~VKRFramebuffer() { _dbg_assert_(depth.alloc); vulkan_->Delete().QueueDeleteImageAllocation(depth.image, depth.alloc); } - if (depth.depthSampleView) - vulkan_->Delete().QueueDeleteImageView(depth.depthSampleView); - for (int i = 0; i < 2; i++) { - if (color.layerViews[i]) { - vulkan_->Delete().QueueDeleteImageView(color.layerViews[i]); - } - if (depth.layerViews[i]) { - vulkan_->Delete().QueueDeleteImageView(depth.layerViews[i]); - } - } for (auto &fb : framebuf) { - for (int i = 0; i < 2; i++) { - if (fb[i]) { - vulkan_->Delete().QueueDeleteFramebuffer(fb[i]); - } + if (fb) { + vulkan_->Delete().QueueDeleteFramebuffer(fb); } } } @@ -301,28 +295,25 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ivci.subresourceRange.aspectMask = aspects; ivci.subresourceRange.layerCount = numLayers; ivci.subresourceRange.levelCount = 1; - res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.imageView); + res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.rtView); _dbg_assert_(res == VK_SUCCESS); - // Separate view for texture sampling that only exposes depth. + // Separate view for texture sampling all layers together. if (!color) { ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT; - res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.depthSampleView); - _dbg_assert_(res == VK_SUCCESS); - } else { - img.depthSampleView = VK_NULL_HANDLE; } - // Create 2D views for both layers, if layered. + ivci.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; // layered for consistency, even if single image. + res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.texAllLayersView); + + // Create 2D views for both layers. // Useful when multipassing shaders that don't yet exist in a single-pass-stereo version. - if (numLayers == 2) { + for (int i = 0; i < numLayers; i++) { ivci.viewType = VK_IMAGE_VIEW_TYPE_2D; ivci.subresourceRange.layerCount = 1; - res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.layerViews[0]); - _dbg_assert_(res == VK_SUCCESS); - ivci.subresourceRange.baseArrayLayer = 1; - res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.layerViews[1]); + ivci.subresourceRange.baseArrayLayer = i; + res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.texLayerViews[i]); _dbg_assert_(res == VK_SUCCESS); } @@ -353,6 +344,7 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int img.layout = initialLayout; img.format = format; img.tag = tag ? tag : "N/A"; + img.numLayers = numLayers; } VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) @@ -751,6 +743,7 @@ void VulkanRenderManager::EndCurRenderStep() { } // Framebuffers can be stereo, and if so, will control the render pass type to match. // Pipelines can be mono and render fine to stereo etc, so not checking them here. + // Note that we don't support rendering to just one layer of a multilayer framebuffer! if (curRenderStep_->render.framebuffer->numLayers > 1) { rpType = (RenderPassType)(rpType | RP_TYPE_MULTIVIEW_COLOR); } @@ -794,7 +787,7 @@ void VulkanRenderManager::BindCurrentFramebufferAsInputAttachment0(VkImageAspect curRenderStep_->commands.push_back(VkRenderData{ VKRRenderCommand::SELF_DEPENDENCY_BARRIER }); } -void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, int layer, const char *tag) { +void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, const char *tag) { _dbg_assert_(insideFrame_); // Eliminate dupes (bind of the framebuffer we already are rendering to), instantly convert to a clear if possible. if (!steps_.empty() && steps_.back()->stepType == VKRStepType::RENDER && steps_.back()->render.framebuffer == fb) { @@ -833,6 +826,7 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR data.clear.clearZ = clearDepth; data.clear.clearStencil = clearStencil; data.clear.clearMask = clearMask; + data.clear.numLayers = curRenderStep_->render.framebuffer ? curRenderStep_->render.framebuffer->numLayers : 1; curRenderStep_->commands.push_back(data); curRenderArea_.SetRect(0, 0, curWidth_, curHeight_); } @@ -875,7 +869,6 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR VKRStep *step = new VKRStep{ VKRStepType::RENDER }; step->render.framebuffer = fb; - step->render.layer = layer; step->render.colorLoad = color; step->render.depthLoad = depth; step->render.stencilLoad = stencil; @@ -1254,10 +1247,10 @@ VkImageView VulkanRenderManager::BindFramebufferAsTexture(VKRFramebuffer *fb, in TransitionRequest rq{ fb, aspectBit, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL }; curRenderStep_->preTransitions.insert(rq); // Note that insert avoids inserting duplicates. - if (layer == -1 || (layer == 0 && fb->numLayers == 1)) { - return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.imageView : fb->depth.depthSampleView; + if (layer == -1) { + return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.texAllLayersView : fb->depth.texAllLayersView; } else { - return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.layerViews[layer] : fb->depth.layerViews[layer]; + return aspectBit == VK_IMAGE_ASPECT_COLOR_BIT ? fb->color.texLayerViews[layer] : fb->depth.texLayerViews[layer]; } } diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 4247157809..cd1e843454 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -29,13 +29,14 @@ struct VKRImage { // These four are "immutable". VkImage image; - // These are 2D if single layer, 2D_ARRAY if multiple. Need to take that into account when picking - // shaders, or use layerViews below and multiple passes to work around it. - VkImageView imageView; - VkImageView depthSampleView; + VkImageView rtView; // Used for rendering to, and readbacks of stencil. 2D if single layer, 2D_ARRAY if multiple. Includes both depth and stencil if depth/stencil. + + // This is for texturing all layers at once. If aspect is depth/stencil, does not include stencil. + VkImageView texAllLayersView; // If it's a layered image (for stereo), this is two 2D views of it, to make it compatible with shaders that don't yet support stereo. - VkImageView layerViews[2]{}; + // If there's only one layer, layerViews[0] only is initialized. + VkImageView texLayerViews[2]{}; VmaAllocation alloc; VkFormat format; @@ -43,6 +44,8 @@ struct VKRImage { // This one is used by QueueRunner's Perform functions to keep track. CANNOT be used anywhere else due to sync issues. VkImageLayout layout; + int numLayers; + // For debugging. std::string tag; }; @@ -56,7 +59,7 @@ public: VKRFramebuffer(VulkanContext *vk, VkCommandBuffer initCmd, VKRRenderPass *compatibleRenderPass, int _width, int _height, int _numLayers, bool createDepthStencilBuffer, const char *tag); ~VKRFramebuffer(); - VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType, int layer); + VkFramebuffer Get(VKRRenderPass *compatibleRenderPass, RenderPassType rpType); int width = 0; int height = 0; @@ -74,7 +77,7 @@ public: // TODO: Hide. VulkanContext *vulkan_; private: - VkFramebuffer framebuf[RP_TYPE_COUNT][2]{}; + VkFramebuffer framebuf[RP_TYPE_COUNT]{}; std::string tag_; }; @@ -237,10 +240,7 @@ public: // // It can be useful to use GetCurrentStepId() to figure out when you need to send all this state again, if you're // not keeping track of your calls to this function on your own. - // - // For layer, we use the same convention as thin3d, where layer = -1 means all layers together. For texturing, that means that you - // get an array texture view. - void BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, int layer, const char *tag); + void BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRRenderPassLoadAction color, VKRRenderPassLoadAction depth, VKRRenderPassLoadAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, const char *tag); // Returns an ImageView corresponding to a framebuffer. Is called BindFramebufferAsTexture to maintain a similar interface // as the other backends, even though there's no actual binding happening here. diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 87b30311d7..fbcc288aa2 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -405,7 +405,7 @@ public: DataFormat PreferredFramebufferReadbackFormat(Framebuffer *src) override; // These functions should be self explanatory. - void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) override; + void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) override; void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) override; void BindCurrentFramebufferForColorInput() override; @@ -1555,13 +1555,13 @@ DataFormat VKContext::PreferredFramebufferReadbackFormat(Framebuffer *src) { return DrawContext::PreferredFramebufferReadbackFormat(src); } -void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) { +void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) { VKFramebuffer *fb = (VKFramebuffer *)fbo; VKRRenderPassLoadAction color = (VKRRenderPassLoadAction)rp.color; VKRRenderPassLoadAction depth = (VKRRenderPassLoadAction)rp.depth; VKRRenderPassLoadAction stencil = (VKRRenderPassLoadAction)rp.stencil; - renderManager_.BindFramebufferAsRenderTarget(fb ? fb->GetFB() : nullptr, color, depth, stencil, rp.clearColor, rp.clearDepth, rp.clearStencil, layer, tag); + renderManager_.BindFramebufferAsRenderTarget(fb ? fb->GetFB() : nullptr, color, depth, stencil, rp.clearColor, rp.clearDepth, rp.clearStencil, tag); curFramebuffer_ = fb; } @@ -1650,8 +1650,13 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) { return (uint64_t)GetNullTexture()->GetImageView(); case NativeObject::TEXTURE_VIEW: return (uint64_t)(((VKTexture *)srcObject)->GetImageView()); - case NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW: - return (uint64_t)curFramebuffer_->GetFB()->color.imageView; + case NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_ALL_LAYERS: + return (uint64_t)curFramebuffer_->GetFB()->color.texAllLayersView; + case NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_LAYER: { + size_t layer = (size_t)srcObject; + _dbg_assert_(layer < curFramebuffer_->Layers()); + return (uint64_t)curFramebuffer_->GetFB()->color.texLayerViews[layer]; + } default: Crash(); return 0; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index f2c886c054..947c89aae0 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -241,9 +241,10 @@ enum class NativeObject { BACKBUFFER_DEPTH_TEX, FEATURE_LEVEL, INIT_COMMANDBUFFER, - BOUND_TEXTURE0_IMAGEVIEW, - BOUND_TEXTURE1_IMAGEVIEW, - BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW, + BOUND_TEXTURE0_IMAGEVIEW, // Layer etc depends on how you bound it... + BOUND_TEXTURE1_IMAGEVIEW, // Layer etc depends on how you bound it... + BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_ALL_LAYERS, + BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_LAYER, // use an int cast to void *srcObject to specify layer. RENDER_MANAGER, TEXTURE_VIEW, NULL_IMAGEVIEW, @@ -658,7 +659,8 @@ public: // These functions should be self explanatory. // Binding a zero render target means binding the backbuffer. - virtual void BindFramebufferAsRenderTarget(Framebuffer *fbo, int layer, const RenderPassInfo &rp, const char *tag) = 0; + // If an fbo has two layers, we bind for stereo rendering ALWAYS. There's no rendering to one layer anymore. + virtual void BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) = 0; // binding must be < MAX_TEXTURE_SLOTS (0, 1 are okay if it's 2). virtual void BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) = 0; diff --git a/Common/UI/UIScreen.cpp b/Common/UI/UIScreen.cpp index 6bdd4382d9..41ec1bb76d 100644 --- a/Common/UI/UIScreen.cpp +++ b/Common/UI/UIScreen.cpp @@ -85,7 +85,7 @@ void UIScreen::preRender() { } draw->BeginFrame(); // Bind and clear the back buffer - draw->BindFramebufferAsRenderTarget(nullptr, ALL_LAYERS, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "UI"); + draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "UI"); screenManager()->getUIContext()->BeginFrame(); Draw::Viewport viewport; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index b27aba7334..e6ce4a0f94 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -43,6 +43,8 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } errorString->clear(); + bool useStereo = id.Bit(FS_BIT_STEREO); + bool highpFog = false; bool highpTexcoord = false; bool enableFragmentTestCache = gstate_c.Use(GPU_USE_FRAGMENT_TEST_CACHE); @@ -58,23 +60,27 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu ReplaceAlphaType stencilToAlpha = static_cast(id.Bits(FS_BIT_STENCIL_TO_ALPHA, 2)); - std::vector gl_exts; + std::vector extensions; if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { if (stencilToAlpha == REPLACE_ALPHA_DUALSOURCE && gl_extensions.EXT_blend_func_extended) { - gl_exts.push_back("#extension GL_EXT_blend_func_extended : require"); + extensions.push_back("#extension GL_EXT_blend_func_extended : require"); } if (gl_extensions.EXT_gpu_shader4) { - gl_exts.push_back("#extension GL_EXT_gpu_shader4 : enable"); + extensions.push_back("#extension GL_EXT_gpu_shader4 : enable"); } if (compat.framebufferFetchExtension) { - gl_exts.push_back(compat.framebufferFetchExtension); + extensions.push_back(compat.framebufferFetchExtension); } if (gl_extensions.OES_texture_3D && texture3D) { - gl_exts.push_back("#extension GL_OES_texture_3D: enable"); + extensions.push_back("#extension GL_OES_texture_3D: enable"); } + } + + if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN && useStereo) { + extensions.push_back("#extension GL_EXT_multiview : enable"); } - ShaderWriter p(buffer, compat, ShaderStage::Fragment, gl_exts); + ShaderWriter p(buffer, compat, ShaderStage::Fragment, extensions); bool lmode = id.Bit(FS_BIT_LMODE); bool doTexture = id.Bit(FS_BIT_DO_TEXTURE); @@ -90,7 +96,6 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool doTextureAlpha = id.Bit(FS_BIT_TEXALPHA); bool arrayTexture = id.Bit(FS_BIT_SAMPLE_ARRAY_TEXTURE); - bool arrayTextureFramebuffer = id.Bit(FS_BIT_FRAMEBUFFER_ARRAY_TEXTURE); bool flatBug = bugs.Has(Draw::Bugs::BROKEN_FLAT_IN_SHADER) && g_Config.bVendorBugChecksEnabled; @@ -162,9 +167,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } if (readFramebufferTex) { - WRITE(p, "layout (binding = 1) uniform sampler2D%s fbotex;\n", arrayTextureFramebuffer ? "array" : ""); + // The framebuffer texture is always bound as an array. + p.C("layout (binding = 1) uniform sampler2DArray fbotex;\n"); } else if (fetchFramebuffer) { - WRITE(p, "layout (input_attachment_index = 0, binding = 9) uniform subpassInput inputColor;\n"); + p.C("layout (input_attachment_index = 0, binding = 9) uniform subpassInput inputColor;\n"); if (fragmentShaderFlags) { *fragmentShaderFlags |= FragmentShaderFlags::INPUT_ATTACHMENT; } @@ -517,6 +523,8 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " vec4 destColor = fbotex.Load(int3((int)gl_FragCoord.x, (int)gl_FragCoord.y, 0));\n"); } else if (compat.shaderLanguage == HLSL_D3D9) { WRITE(p, " vec4 destColor = tex2D(fbotex, gl_FragCoord.xy * u_fbotexSize.xy);\n", compat.texture); + } else if (compat.shaderLanguage == GLSL_VULKAN) { + WRITE(p, " lowp vec4 destColor = %s(fbotex, ivec3(gl_FragCoord.x, gl_FragCoord.y, %s), 0);\n", compat.texelFetch, useStereo ? "float(gl_ViewIndex)" : "0"); } else if (!compat.texelFetch) { WRITE(p, " lowp vec4 destColor = %s(fbotex, gl_FragCoord.xy * u_fbotexSize.xy);\n", compat.texture); } else { diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 6809922dd9..4558d63b2b 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -863,7 +863,7 @@ void FramebufferManagerCommon::CopyToColorFromOverlappingFramebuffers(VirtualFra if (currentRenderVfb_ && dst != currentRenderVfb_ && tookActions) { // Will probably just change the name of the current renderpass, since one was started by the reinterpret itself. - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "After Reinterpret"); + draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "After Reinterpret"); } shaderManager_->DirtyLastShader(); @@ -1011,7 +1011,7 @@ void FramebufferManagerCommon::NotifyRenderFramebufferSwitched(VirtualFramebuffe if (useBufferedRendering_) { if (vfb->fbo) { shaderManager_->DirtyLastShader(); - draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, {Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP}, "FBSwitch"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, {Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP}, "FBSwitch"); } else { // This should only happen very briefly when toggling useBufferedRendering_. ResizeFramebufFBO(vfb, vfb->width, vfb->height, true); @@ -1115,7 +1115,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int } else { flags = DRAWTEX_LINEAR; } - draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); SetViewport2D(0, 0, vfb->renderWidth, vfb->renderHeight); draw_->SetScissorRect(0, 0, vfb->renderWidth, vfb->renderHeight); } else { @@ -1369,7 +1369,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) { DEBUG_LOG(FRAMEBUF, "Display disabled, displaying only black"); // No framebuffer to display! Clear to black. if (useBufferedRendering_) { - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput"); + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput"); } gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); return; @@ -1433,7 +1433,7 @@ void FramebufferManagerCommon::CopyDisplayToOutput(bool reallyDirty) { // No framebuffer to display! Clear to black. if (useBufferedRendering_) { // Bind and clear the backbuffer. This should be the first time during the frame that it's bound. - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput_NoFBO"); + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "CopyDisplayToOutput_NoFBO"); } gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE); return; @@ -1631,7 +1631,7 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, if (old.fbo) { INFO_LOG(FRAMEBUF, "Resizing FBO for %08x : %dx%dx%s", vfb->fb_address, w, h, GeBufferFormatToString(vfb->fb_format)); if (vfb->fbo) { - draw_->BindFramebufferAsRenderTarget(vfb->fbo, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); if (!skipCopy) { BlitFramebuffer(vfb, 0, 0, &old, 0, 0, std::min((u16)oldWidth, std::min(vfb->bufferWidth, vfb->width)), std::min((u16)oldHeight, std::min(vfb->height, vfb->bufferHeight)), 0, RASTER_COLOR, "BlitColor_ResizeFramebufFBO"); } @@ -1640,9 +1640,9 @@ void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, } } fbosToDelete_.push_back(old.fbo); - draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "ResizeFramebufFBO"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "ResizeFramebufFBO"); } else { - draw_->BindFramebufferAsRenderTarget(vfb->fbo, Draw::ALL_LAYERS, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); + draw_->BindFramebufferAsRenderTarget(vfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "ResizeFramebufFBO"); } currentRenderVfb_ = vfb; @@ -2396,6 +2396,17 @@ void FramebufferManagerCommon::DestroyAllFBOs() { fbosToDelete_.clear(); } +static const char *TempFBOReasonToString(TempFBO reason) { + switch (reason) { + case TempFBO::DEPAL: return "depal"; + case TempFBO::BLIT: return "blit"; + case TempFBO::COPY: return "copy"; + case TempFBO::STENCIL: return "stencil"; + default: break; + } + return ""; +} + Draw::Framebuffer *FramebufferManagerCommon::GetTempFBO(TempFBO reason, u16 w, u16 h) { u64 key = ((u64)reason << 48) | ((u32)w << 16) | h; auto it = tempFBOs_.find(key); @@ -2406,7 +2417,7 @@ Draw::Framebuffer *FramebufferManagerCommon::GetTempFBO(TempFBO reason, u16 w, u bool z_stencil = reason == TempFBO::STENCIL; char name[128]; - snprintf(name, sizeof(name), "temp_fbo_%dx%d%s", w / renderScaleFactor_, h / renderScaleFactor_, z_stencil ? "_depth" : ""); + snprintf(name, sizeof(name), "tempfbo_%s_%dx%d", TempFBOReasonToString(reason), w / renderScaleFactor_, h / renderScaleFactor_); Draw::Framebuffer *fbo = draw_->CreateFramebuffer({ w, h, 1, GetFramebufferLayers(), z_stencil, name }); if (!fbo) { @@ -2785,10 +2796,10 @@ void FramebufferManagerCommon::RebindFramebuffer(const char *tag) { draw_->InvalidateCachedState(); shaderManager_->DirtyLastShader(); if (currentRenderVfb_ && currentRenderVfb_->fbo) { - draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, Draw::ALL_LAYERS, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); + draw_->BindFramebufferAsRenderTarget(currentRenderVfb_->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag); } else { // Should this even happen? It could while debugging, but maybe we can just skip binding at all. - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "RebindFramebuffer_Bad"); + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "RebindFramebuffer_Bad"); } } @@ -2907,7 +2918,7 @@ void FramebufferManagerCommon::BlitFramebuffer(VirtualFramebuffer *dst, int dstX // This can happen if they recently switched from non-buffered. if (useBufferedRendering_) { // Just bind the back buffer for rendering, forget about doing anything else as we're in a weird state. - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "BlitFramebuffer"); + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, "BlitFramebuffer"); } return; } @@ -3030,7 +3041,7 @@ void FramebufferManagerCommon::BlitUsingRaster( // Unbind the texture first to avoid the D3D11 hazard check (can't set render target to things bound as textures and vice versa, not even temporarily). draw_->BindTexture(0, nullptr); // This will get optimized away in case it's already bound (in VK and GL at least..) - draw_->BindFramebufferAsRenderTarget(dest, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); + draw_->BindFramebufferAsRenderTarget(dest, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, 0); if (destX1 == 0.0f && destY1 == 0.0f && destX2 >= destW && destY2 >= destH) { diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index d9f635d208..76ad0bd8f6 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -204,8 +204,6 @@ enum class TempFBO { BLIT, // For copies of framebuffers (e.g. shader blending.) COPY, - // For another type of framebuffers that can happen together with COPY (see Outrun) - REINTERPRET, // Used to copy stencil data, means we need a stencil backing. STENCIL, }; diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index fa3ab92c00..4feb0bd21c 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -783,7 +783,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u postShaderFramebuffer = previousFramebuffers_[previousIndex_]; } - draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "PostShader"); + draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "PostShader"); performShaderPass(shaderInfo, postShaderFramebuffer, postShaderPipeline); } @@ -804,11 +804,11 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u previousIndex_ = 0; Draw::Framebuffer *postShaderFramebuffer = previousFramebuffers_[previousIndex_]; - draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "InterFrameBlit"); + draw_->BindFramebufferAsRenderTarget(postShaderFramebuffer, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "InterFrameBlit"); performShaderPass(shaderInfo, postShaderFramebuffer, postShaderPipeline); } - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "FinalBlit"); + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "FinalBlit"); draw_->SetScissorRect(0, 0, pixelWidth_, pixelHeight_); Draw::Pipeline *pipeline = (flags & OutputFlags::RB_SWIZZLE) ? texColorRBSwizzle_ : texColor_; diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 1acad76ab4..40b31393c9 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -62,6 +62,8 @@ std::string VertexShaderDesc(const VShaderID &id) { if (id.Bit(VS_BIT_NORM_REVERSE_TESS)) desc << "TessRevN "; if (id.Bit(VS_BIT_VERTEX_RANGE_CULLING)) desc << "Cull "; + if (id.Bit(VS_BIT_SIMPLE_STEREO)) desc << "SimpleStereo "; + return desc.str(); } @@ -92,7 +94,7 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, id.SetBit(VS_BIT_HAS_COLOR, hasColor); id.SetBit(VS_BIT_VERTEX_RANGE_CULLING, vertexRangeCulling); - if (!isModeThrough && VS_BIT_SIMPLE_STEREO) { + if (!isModeThrough && gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { id.SetBit(VS_BIT_SIMPLE_STEREO); } @@ -255,7 +257,8 @@ std::string FragmentShaderDesc(const FShaderID &id) { if (id.Bit(FS_BIT_TEST_DISCARD_TO_ZERO)) desc << "TestDiscardToZero "; if (id.Bit(FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL)) desc << "StencilDiscardWorkaround "; if (id.Bits(FS_BIT_REPLACE_LOGIC_OP, 4) != GE_LOGIC_COPY) desc << "ReplaceLogic "; - + if (id.Bit(FS_BIT_SAMPLE_ARRAY_TEXTURE)) desc << "TexArray "; + if (id.Bit(FS_BIT_STEREO)) desc << "Stereo "; return desc.str(); } @@ -363,7 +366,6 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip id.SetBits(FS_BIT_BLENDFUNC_B, 4, gstate.getBlendFuncB()); } id.SetBit(FS_BIT_FLATSHADE, doFlatShading); - id.SetBit(FS_BIT_COLOR_WRITEMASK, colorWriteMask); // Stereo support @@ -372,7 +374,7 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip if (gstate_c.arrayTexture) { id.SetBit(FS_BIT_SAMPLE_ARRAY_TEXTURE); } - id.SetBit(FS_BIT_FRAMEBUFFER_ARRAY_TEXTURE); + id.SetBit(FS_BIT_STEREO); } if (g_Config.bVendorBugChecksEnabled && bugs.Has(Draw::Bugs::NO_DEPTH_CANNOT_DISCARD_STENCIL)) { diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index de1a6b0985..effe330763 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -99,7 +99,7 @@ enum FShaderBit : uint8_t { FS_BIT_REPLACE_LOGIC_OP = 51, // 4 bits. GE_LOGIC_COPY means no-op/off. FS_BIT_SHADER_DEPAL_MODE = 55, // 2 bits (ShaderDepalMode) FS_BIT_SAMPLE_ARRAY_TEXTURE = 57, // For multiview, framebuffers are array textures and we need to sample the two layers correctly. - FS_BIT_FRAMEBUFFER_ARRAY_TEXTURE = 58, // Framebuffer texture might also be stereo. + FS_BIT_STEREO = 58, }; static inline FShaderBit operator +(FShaderBit bit, int i) { diff --git a/GPU/Common/StencilCommon.cpp b/GPU/Common/StencilCommon.cpp index dfa36fe0e7..682d8a1f0c 100644 --- a/GPU/Common/StencilCommon.cpp +++ b/GPU/Common/StencilCommon.cpp @@ -187,7 +187,7 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, // Otherwise, we can skip alpha in many cases, in which case we don't even use a shader. if (flags & WriteStencil::IGNORE_ALPHA) { if (dstBuffer->fbo) { - draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Clear"); + draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Clear"); } return true; } @@ -281,9 +281,9 @@ bool FramebufferManagerCommon::PerformWriteStencilFromMemory(u32 addr, int size, Draw::Framebuffer *blitFBO = nullptr; if (useBlit) { blitFBO = GetTempFBO(TempFBO::STENCIL, w, h); - draw_->BindFramebufferAsRenderTarget(blitFBO, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Blit"); + draw_->BindFramebufferAsRenderTarget(blitFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_Blit"); } else if (dstBuffer->fbo) { - draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, 0, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_NoBlit"); + draw_->BindFramebufferAsRenderTarget(dstBuffer->fbo, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::CLEAR }, "WriteStencilFromMemory_NoBlit"); } Draw::Viewport viewport = { 0.0f, 0.0f, (float)w, (float)h, 0.0f, 1.0f }; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 3c288b13f4..4e04144c96 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2191,7 +2191,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(TempFBO::DEPAL, depalWidth, framebuffer->renderHeight); draw_->BindTexture(0, nullptr); draw_->BindTexture(1, nullptr); - draw_->BindFramebufferAsRenderTarget(depalFBO, Draw::ALL_LAYERS, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); + draw_->BindFramebufferAsRenderTarget(depalFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); draw_->InvalidateFramebuffer(Draw::FB_INVALIDATION_STORE, Draw::FB_DEPTH_BIT | Draw::FB_STENCIL_BIT); draw_->SetScissorRect(u1, v1, u2 - u1, v2 - v1); Draw::Viewport vp{ 0.0f, 0.0f, (float)depalWidth, (float)framebuffer->renderHeight, 0.0f, 1.0f }; @@ -2292,7 +2292,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(TempFBO::DEPAL, texWidth, texHeight); draw_->BindTexture(0, nullptr); draw_->BindTexture(1, nullptr); - draw_->BindFramebufferAsRenderTarget(depalFBO, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); + draw_->BindFramebufferAsRenderTarget(depalFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Depal"); draw_->InvalidateFramebuffer(Draw::FB_INVALIDATION_STORE, Draw::FB_DEPTH_BIT | Draw::FB_STENCIL_BIT); draw_->SetScissorRect(u1, v1, u2 - u1, v2 - v1); Draw::Viewport vp{ 0.0f, 0.0f, (float)texWidth, (float)texHeight, 0.0f, 1.0f }; diff --git a/GPU/GLES/DepthBufferGLES.cpp b/GPU/GLES/DepthBufferGLES.cpp index e54d249061..7be1adf9d3 100644 --- a/GPU/GLES/DepthBufferGLES.cpp +++ b/GPU/GLES/DepthBufferGLES.cpp @@ -204,7 +204,7 @@ bool FramebufferManagerGLES::ReadbackDepthbufferSync(Draw::Framebuffer *fbo, int shaderManager_->DirtyLastShader(); auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); - draw_->BindFramebufferAsRenderTarget(blitFBO, 0, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); + draw_->BindFramebufferAsRenderTarget(blitFBO, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackDepthbufferSync"); Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); @@ -322,7 +322,7 @@ bool FramebufferManagerGLES::ReadbackStencilbufferSync(Draw::Framebuffer *fbo, i shaderManager_->DirtyLastShader(); auto *blitFBO = GetTempFBO(TempFBO::COPY, fbo->Width(), fbo->Height()); - draw_->BindFramebufferAsRenderTarget(blitFBO, 0, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackStencilbufferSync"); + draw_->BindFramebufferAsRenderTarget(blitFBO, { RPAction::DONT_CARE, RPAction::DONT_CARE, RPAction::DONT_CARE }, "ReadbackStencilbufferSync"); Draw::Viewport viewport = { 0.0f, 0.0f, (float)fbo->Width(), (float)fbo->Height(), 0.0f, 1.0f }; draw_->SetViewports(1, &viewport); diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 50ba4bfd99..9d1dc8d3dd 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -54,9 +54,9 @@ void FramebufferManagerGLES::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) // Discard the previous contents of this buffer where possible. if (gl_extensions.GLES3) { - draw_->BindFramebufferAsRenderTarget(nvfb->fbo, 0, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer"); + draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer"); } else if (gl_extensions.IsGLES) { - draw_->BindFramebufferAsRenderTarget(nvfb->fbo, 0, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer"); + draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer"); gstate_c.Dirty(DIRTY_BLEND_STATE); } } diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 5e8087b077..04e3c1d5c7 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -618,7 +618,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { u1 = 1.0f; } if (!hasImage) { - draw_->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "CopyToCurrentFboFromDisplayRam"); + draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "CopyToCurrentFboFromDisplayRam"); return; } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index a9702731c9..335fc29ad9 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -582,10 +582,6 @@ void DrawEngineVulkan::DoFlush() { // Always use software for flat shading to fix the provoking index. bool useHWTransform = CanUseHardwareTransform(prim) && (tess || gstate.getShadeMode() != GE_SHADE_FLAT); - VulkanVertexShader *vshader = nullptr; - VulkanFragmentShader *fshader = nullptr; - VulkanGeometryShader *gshader = nullptr; - uint32_t ibOffset; uint32_t vbOffset; @@ -779,6 +775,10 @@ void DrawEngineVulkan::DoFlush() { ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey_, dynState_); } + VulkanVertexShader *vshader = nullptr; + VulkanFragmentShader *fshader = nullptr; + VulkanGeometryShader *gshader = nullptr; + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, true, useHWTessellation_, decOptions_.expandAllWeightsToFloat); // usehwtransform if (!vshader) { // We're screwed. @@ -909,6 +909,11 @@ void DrawEngineVulkan::DoFlush() { if (prim != lastPrim_ || gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_RASTER_STATE | DIRTY_DEPTHSTENCIL_STATE)) { ConvertStateToVulkanKey(*framebufferManager_, shaderManager_, prim, pipelineKey_, dynState_); } + + VulkanVertexShader *vshader = nullptr; + VulkanFragmentShader *fshader = nullptr; + VulkanGeometryShader *gshader = nullptr; + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat); // usehwtransform _dbg_assert_msg_(!vshader->UseHWTransform(), "Bad vshader"); VulkanPipeline *pipeline = pipelineManager_->GetOrCreatePipeline(renderManager, pipelineLayout_, pipelineKey_, &dec_->decFmt, vshader, fshader, gshader, false, 0); diff --git a/GPU/Vulkan/StateMappingVulkan.cpp b/GPU/Vulkan/StateMappingVulkan.cpp index dbf3ce95cd..4e877d335a 100644 --- a/GPU/Vulkan/StateMappingVulkan.cpp +++ b/GPU/Vulkan/StateMappingVulkan.cpp @@ -365,7 +365,8 @@ void DrawEngineVulkan::BindShaderBlendTex() { // Set the nearest/linear here (since we correctly know if alpha/color tests are needed)? if (!gstate.isModeClear()) { if (fboTexBindState_ == FBO_TEX_COPY_BIND_TEX) { - bool bindResult = framebufferManager_->BindFramebufferAsColorTexture(1, framebufferManager_->GetCurrentRenderVFB(), BINDFBCOLOR_MAY_COPY, Draw::ALL_LAYERS); + VirtualFramebuffer *curRenderVfb = framebufferManager_->GetCurrentRenderVFB(); + bool bindResult = framebufferManager_->BindFramebufferAsColorTexture(1, curRenderVfb, BINDFBCOLOR_MAY_COPY, Draw::ALL_LAYERS); _dbg_assert_(bindResult); boundSecondary_ = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::BOUND_TEXTURE1_IMAGEVIEW); boundSecondaryIsInputAttachment_ = false; @@ -376,7 +377,7 @@ void DrawEngineVulkan::BindShaderBlendTex() { dirtyRequiresRecheck_ |= DIRTY_BLEND_STATE; } else if (fboTexBindState_ == FBO_TEX_READ_FRAMEBUFFER) { draw_->BindCurrentFramebufferForColorInput(); - boundSecondary_ = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW); + boundSecondary_ = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_LAYER, (void *)0); boundSecondaryIsInputAttachment_ = true; fboTexBindState_ = FBO_TEX_NONE; } else { diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f2425d6c41..bcf5a47a48 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1359,9 +1359,9 @@ void EmuScreen::preRender() { if ((!useBufferedRendering && !g_Config.bSoftwareRendering) || Core_IsStepping()) { // We need to clear here already so that drawing during the frame is done on a clean slate. if (Core_IsStepping() && gpuStats.numFlips != 0) { - draw->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_BackBuffer"); + draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_BackBuffer"); } else { - draw->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "EmuScreen_BackBuffer"); + draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, 0xFF000000 }, "EmuScreen_BackBuffer"); } Viewport viewport; @@ -1400,7 +1400,7 @@ void EmuScreen::render() { // It's possible this might be set outside PSP_RunLoopFor(). // In this case, we need to double check it here. checkPowerDown(); - thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_Invalid"); + thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_Invalid"); renderUI(); return; } @@ -1439,12 +1439,12 @@ void EmuScreen::render() { // Clear to blue background screen bool dangerousSettings = !Reporting::IsSupported(); uint32_t color = dangerousSettings ? 0xFF900050 : 0xFF900000; - thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE, color }, "EmuScreen_RuntimeError"); + thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE, color }, "EmuScreen_RuntimeError"); // The info is drawn later in renderUI } else { // If we're stepping, it's convenient not to clear the screen entirely, so we copy display to output. // This won't work in non-buffered, but that's fine. - thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_Stepping"); + thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_Stepping"); // Just to make sure. if (PSP_IsInited()) { gpu->CopyDisplayToOutput(true); @@ -1456,7 +1456,7 @@ void EmuScreen::render() { // Didn't actually reach the end of the frame, ran out of the blockTicks cycles. // In this case we need to bind and wipe the backbuffer, at least. // It's possible we never ended up outputted anything - make sure we have the backbuffer cleared - thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame"); + thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR }, "EmuScreen_NoFrame"); break; } @@ -1470,7 +1470,7 @@ void EmuScreen::render() { if (hasVisibleUI()) { // In most cases, this should already be bound and a no-op. - thin3d->BindFramebufferAsRenderTarget(nullptr, 0, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_UI"); + thin3d->BindFramebufferAsRenderTarget(nullptr, { RPAction::KEEP, RPAction::DONT_CARE, RPAction::DONT_CARE }, "EmuScreen_UI"); cardboardDisableButton_->SetVisibility(g_Config.bEnableCardboardVR ? UI::V_VISIBLE : UI::V_GONE); screenManager()->getUIContext()->BeginFrame(); renderUI(); diff --git a/assets/shaders/stereo_red_blue.fsh b/assets/shaders/stereo_red_blue.fsh index b8156ee458..1ad875b6b3 100644 --- a/assets/shaders/stereo_red_blue.fsh +++ b/assets/shaders/stereo_red_blue.fsh @@ -26,8 +26,6 @@ void main() { vec3 leftColor = mix(vec3(leftGray), left, saturation) * red; vec3 rightColor = mix(vec3(rightGray), right, saturation) * blue; - // TODO: Do something to gamma, maybe? - gl_FragColor.rgb = leftColor + rightColor; gl_FragColor.a = 1.0; } diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 8d02af8f21..ff5c3f94b4 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -240,7 +240,7 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const PSP_EndHostFrame(); if (draw) { - draw->BindFramebufferAsRenderTarget(nullptr, 0, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); + draw->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "Headless"); // Vulkan may get angry if we don't do a final present. if (gpu) gpu->CopyDisplayToOutput(true); From 6af4644ab274503b6dcf24c43c78e3ace07ceca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Oct 2022 21:50:00 +0200 Subject: [PATCH 255/374] Stereo on mobile fixes --- GPU/Common/PresentationCommon.cpp | 2 +- GPU/Vulkan/GPU_Vulkan.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 4feb0bd21c..d72eb55a2c 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -699,7 +699,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u } } - if (isFinalAtOutputResolution) { + if (isFinalAtOutputResolution || useStereo) { // In this mode, we ignore the g_display_rot_matrix. Apply manually. if (g_display_rotation != DisplayRotation::ROTATE_0) { for (int i = 0; i < 4; i++) { diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index aa5243a8f0..29c5e1e459 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -268,9 +268,15 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_ROUND_DEPTH_TO_16BIT; } - if (true) { + if (g_Config.bStereoRendering) { features |= GPU_USE_SINGLE_PASS_STEREO; features &= ~GPU_USE_FRAMEBUFFER_FETCH; // Need to figure out if this can be supported with multiview rendering + if (features & GPU_USE_GS_CULLING) { + // Many devices that support stereo and GS don't support GS during stereo. + // So we revert back to VS range culling. + features &= ~GPU_USE_GS_CULLING; + features |= GPU_USE_VS_RANGE_CULLING; + } } return features; From f1b515caafbe4187ffc9715a4ae6d47d2b191b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 23 Oct 2022 21:50:29 +0200 Subject: [PATCH 256/374] Minor shaderwriter refactor --- Common/GPU/ShaderWriter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 6eb42719f0..610a7fe0ec 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -33,6 +33,7 @@ struct VaryingDef { enum class ShaderWriterFlags { NONE = 0, FS_WRITE_DEPTH = 1, + FS_AUTO_STEREO = 2, }; ENUM_CLASS_BITOPS(ShaderWriterFlags); From 2bea495981ffb3a8b164e9f73dd72276fae6cc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 24 Oct 2022 17:36:54 +0200 Subject: [PATCH 257/374] wip --- Common/GPU/Shader.h | 1 + Common/GPU/ShaderWriter.cpp | 43 +++++++++++++++++++++++--- Common/GPU/ShaderWriter.h | 5 ++- GPU/Common/FragmentShaderGenerator.cpp | 18 ++++++++++- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/Common/GPU/Shader.h b/Common/GPU/Shader.h index 4020a7b253..4daa5717d1 100644 --- a/Common/GPU/Shader.h +++ b/Common/GPU/Shader.h @@ -94,6 +94,7 @@ struct UniformDef { struct SamplerDef { int binding; // Might only be used by some backends. const char *name; + bool array; // TODO: Might need unsigned samplers, 3d samplers, or other types in the future. }; diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index e00a468e35..238ce848ed 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -114,6 +114,9 @@ void ShaderWriter::Preamble(Slice extensions) { switch (lang_.shaderLanguage) { case GLSL_VULKAN: C("#version 450\n"); + if (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) { + C("#extension GL_EXT_multiview : enable\n"); + } // IMPORTANT! Extensions must be the first thing after #version. for (size_t i = 0; i < extensions.size(); i++) { F("%s\n", extensions[i]); @@ -462,6 +465,15 @@ void ShaderWriter::DeclareSamplers(Slice samplers) { samplerDefs_ = samplers; } +const SamplerDef *ShaderWriter::GetSamplerDef(const char *name) const { + for (int i = 0; i < (int)samplers_.size(); i++) { + if (!strcmp(samplers_[i].name, name)) { + return &samplers_[i]; + } + } + return nullptr; +} + void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { switch (lang_.shaderLanguage) { case HLSL_D3D11: @@ -472,7 +484,11 @@ void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { break; case GLSL_VULKAN: // In the thin3d descriptor set layout, textures start at 1 in set 0. Hence the +1. - F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name); + if ((flags_ & ShaderWriterFlags::FS_AUTO_STEREO) && def.array) { + F("layout(set = 0, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name); + } else { + F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name); + } break; default: F("uniform sampler2D %s;\n", def.name); @@ -492,6 +508,7 @@ void ShaderWriter::DeclareSampler2D(const SamplerDef &def) { } ShaderWriter &ShaderWriter::SampleTexture2D(const char *sampName, const char *uv) { + const SamplerDef *samp = GetSamplerDef(sampName); switch (lang_.shaderLanguage) { case HLSL_D3D11: F("%s.Sample(%sSamp, %s)", sampName, sampName, uv); @@ -501,13 +518,20 @@ ShaderWriter &ShaderWriter::SampleTexture2D(const char *sampName, const char *uv break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - F("%s(%s, %s)", lang_.texture, sampName, uv); + if (samp && samp->array) { + const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; + F("%s(%s, vec3(%s, %s))", lang_.texture, sampName, uv, index); + } else { + F("%s(%s, %s)", lang_.texture, sampName, uv); + } break; } return *this; } ShaderWriter &ShaderWriter::SampleTexture2DOffset(const char *sampName, const char *uv, int offX, int offY) { + const SamplerDef *samp = GetSamplerDef(sampName); + switch (lang_.shaderLanguage) { case HLSL_D3D11: F("%s.Sample(%sSamp, %s, int2(%d, %d))", sampName, sampName, uv, offX, offY); @@ -518,13 +542,20 @@ ShaderWriter &ShaderWriter::SampleTexture2DOffset(const char *sampName, const ch break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - F("%sOffset(%s, %s, ivec2(%d, %d))", lang_.texture, sampName, uv, offX, offY); + if (samp->array) { + const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; + F("%sOffset(%s, vec3(%s, %s), ivec3(%d, %d))", lang_.texture, sampName, uv, index, offX, offY); + } else { + F("%sOffset(%s, %s, ivec2(%d, %d))", lang_.texture, sampName, uv, offX, offY); + } break; } return *this; } ShaderWriter &ShaderWriter::LoadTexture2D(const char *sampName, const char *uv, int level) { + const SamplerDef *samp = GetSamplerDef(sampName); + switch (lang_.shaderLanguage) { case HLSL_D3D11: F("%s.Load(ivec3(%s, %d))", sampName, uv, level); @@ -535,7 +566,11 @@ ShaderWriter &ShaderWriter::LoadTexture2D(const char *sampName, const char *uv, break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - F("texelFetch(%s, %s, %d)", sampName, uv, level); + if ((flags_ & ShaderWriterFlags::FS_AUTO_STEREO) && samp->array) { + F("texelFetch(%s, %s, %d)", sampName, uv, level); + } else { + F("texelFetch(%s, %s, %d)", sampName, uv, level); + } break; } return *this; diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 610a7fe0ec..567e4c33a5 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -33,7 +33,7 @@ struct VaryingDef { enum class ShaderWriterFlags { NONE = 0, FS_WRITE_DEPTH = 1, - FS_AUTO_STEREO = 2, + FS_AUTO_STEREO = 2, // Automatically makes sampler 0 an array sampler, and samples it by gl_ViewIndex. Useful for stereo rendering. }; ENUM_CLASS_BITOPS(ShaderWriterFlags); @@ -119,9 +119,12 @@ private: void Preamble(Slice extensions); + const SamplerDef *GetSamplerDef(const char *name) const; + char *p_; const ShaderLanguageDesc &lang_; const ShaderStage stage_; + Slice samplers_; ShaderWriterFlags flags_ = ShaderWriterFlags::NONE; Slice samplerDefs_; int texBindingBase_ = 1; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index e6ce4a0f94..64693097a4 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -96,6 +96,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool doTextureAlpha = id.Bit(FS_BIT_TEXALPHA); bool arrayTexture = id.Bit(FS_BIT_SAMPLE_ARRAY_TEXTURE); + if (texture3D && arrayTexture) { + *errorString = "Invalid combination of 3D texture and array texture, shouldn't happen"; + return false; + } bool flatBug = bugs.Has(Draw::Bugs::BROKEN_FLAT_IN_SHADER) && g_Config.bVendorBugChecksEnabled; @@ -156,6 +160,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu return false; } + // Currently only used by Vulkan. + std::vector samplers; + if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN) { if (useDiscardStencilBugWorkaround && !gstate_c.Use(GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT)) { WRITE(p, "layout (depth_unchanged) out float gl_FragDepth;\n"); @@ -163,7 +170,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseUBO {\n%s};\n", ub_baseStr); if (doTexture) { - WRITE(p, "layout (binding = 0) uniform %s%s tex;\n", texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "array" : ""); + WRITE(p, "layout (binding = 0) uniform %s%s tex;\n", texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "Array" : ""); } if (readFramebufferTex) { @@ -639,6 +646,15 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } else { WRITE(p, " vec4 t = %s(tex, vec3(%s.xy, u_mipBias));\n", compat.texture3D, texcoord); } + } else if (arrayTexture) { + // Used for stereo rendering. + if (doTextureProjection) { + if (doTextureProjection) { + WRITE(p, " vec4 t = %sProj(tex, %s);\n", compat.texture, texcoord); + } else { + WRITE(p, " vec4 t = %s(tex, %s.xy);\n", compat.texture, texcoord); + } + } } else { if (doTextureProjection) { WRITE(p, " vec4 t = %sProj(tex, %s);\n", compat.texture, texcoord); From 91259aaad7138bb3424076a2367c79e88e62e9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 25 Oct 2022 23:32:28 +0200 Subject: [PATCH 258/374] Always use array textures for framebuffers in Vulkan for simplicity. --- Common/GPU/D3D11/thin3d_d3d11.cpp | 4 +-- Common/GPU/D3D9/thin3d_d3d9.cpp | 4 +-- Common/GPU/OpenGL/thin3d_gl.cpp | 4 +-- Common/GPU/Shader.h | 12 ++++++--- Common/GPU/ShaderWriter.cpp | 20 +++++--------- Common/GPU/ShaderWriter.h | 4 +-- Common/GPU/Vulkan/VulkanImage.cpp | 10 +++++++ Common/GPU/Vulkan/VulkanImage.h | 4 +++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 35 ++++++++++++++++++++----- Common/GPU/thin3d.h | 9 ++++++- GPU/Common/Draw2D.cpp | 13 ++++++--- GPU/Common/FramebufferManagerCommon.cpp | 4 +-- 12 files changed, 83 insertions(+), 40 deletions(-) diff --git a/Common/GPU/D3D11/thin3d_d3d11.cpp b/Common/GPU/D3D11/thin3d_d3d11.cpp index aca3aaae93..428e86fdb3 100644 --- a/Common/GPU/D3D11/thin3d_d3d11.cpp +++ b/Common/GPU/D3D11/thin3d_d3d11.cpp @@ -101,7 +101,7 @@ public: void InvalidateCachedState() override; - void BindTextures(int start, int count, Texture **textures) override; + void BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) override; void BindNativeTexture(int index, void *nativeTexture) override; void BindSamplerStates(int start, int count, SamplerState **states) override; void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) override; @@ -1381,7 +1381,7 @@ Framebuffer *D3D11DrawContext::CreateFramebuffer(const FramebufferDesc &desc) { return fb; } -void D3D11DrawContext::BindTextures(int start, int count, Texture **textures) { +void D3D11DrawContext::BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) { // Collect the resource views from the textures. ID3D11ShaderResourceView *views[MAX_BOUND_TEXTURES]; _assert_(start + count <= ARRAY_SIZE(views)); diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index 4c3a83c2f5..ec524c8dab 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -538,7 +538,7 @@ public: void GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h) override; - void BindTextures(int start, int count, Texture **textures) override; + void BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) override; void BindNativeTexture(int index, void *nativeTexture) override; void BindSamplerStates(int start, int count, SamplerState **states) override { @@ -912,7 +912,7 @@ Texture *D3D9Context::CreateTexture(const TextureDesc &desc) { return tex; } -void D3D9Context::BindTextures(int start, int count, Texture **textures) { +void D3D9Context::BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) { _assert_(start + count <= MAX_BOUND_TEXTURES); for (int i = start; i < start + count; i++) { D3D9Texture *tex = static_cast(textures[i - start]); diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index fe26e38591..bd8a252e10 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -397,7 +397,7 @@ public: curPipeline_->depthStencil->stencilPass); } - void BindTextures(int start, int count, Texture **textures) override; + void BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) override; void BindNativeTexture(int sampler, void *nativeTexture) override; void BindPipeline(Pipeline *pipeline) override; @@ -1127,7 +1127,7 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc, const } } -void OpenGLContext::BindTextures(int start, int count, Texture **textures) { +void OpenGLContext::BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) { _assert_(start + count <= MAX_TEXTURE_SLOTS); for (int i = start; i < start + count; i++) { OpenGLTexture *glTex = static_cast(textures[i - start]); diff --git a/Common/GPU/Shader.h b/Common/GPU/Shader.h index 4daa5717d1..6e29445734 100644 --- a/Common/GPU/Shader.h +++ b/Common/GPU/Shader.h @@ -4,9 +4,12 @@ #include #include // for size_t +#include "Common/Common.h" + // GLSL_1xx and GLSL_3xx each cover a lot of sub variants. All the little quirks // that differ are covered in ShaderLanguageDesc. // Defined as a bitmask so stuff like GetSupportedShaderLanguages can return combinations. +// TODO: We can probably move away from this distinction soon, now that we mostly generate/translate shaders. enum ShaderLanguage { GLSL_1xx = 1, GLSL_3xx = 2, @@ -30,7 +33,6 @@ enum class ShaderStage { const char *ShaderStageAsString(ShaderStage lang); - struct ShaderLanguageDesc { ShaderLanguageDesc() {} explicit ShaderLanguageDesc(ShaderLanguage lang); @@ -91,14 +93,18 @@ struct UniformDef { int index; }; +enum class SamplerFlags { + ARRAY_ON_VULKAN = 1, +}; +ENUM_CLASS_BITOPS(SamplerFlags); + struct SamplerDef { int binding; // Might only be used by some backends. const char *name; - bool array; + SamplerFlags flags; // TODO: Might need unsigned samplers, 3d samplers, or other types in the future. }; - // For passing error messages from shader compilation (and other critical issues) back to the host. // This can run on any thread - be aware! // TODO: See if we can find a less generic name for this. diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index 238ce848ed..4e98e17d0c 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -465,15 +465,6 @@ void ShaderWriter::DeclareSamplers(Slice samplers) { samplerDefs_ = samplers; } -const SamplerDef *ShaderWriter::GetSamplerDef(const char *name) const { - for (int i = 0; i < (int)samplers_.size(); i++) { - if (!strcmp(samplers_[i].name, name)) { - return &samplers_[i]; - } - } - return nullptr; -} - void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { switch (lang_.shaderLanguage) { case HLSL_D3D11: @@ -484,7 +475,7 @@ void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { break; case GLSL_VULKAN: // In the thin3d descriptor set layout, textures start at 1 in set 0. Hence the +1. - if ((flags_ & ShaderWriterFlags::FS_AUTO_STEREO) && def.array) { + if (def.flags & SamplerFlags::ARRAY_ON_VULKAN) { F("layout(set = 0, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name); } else { F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name); @@ -518,7 +509,7 @@ ShaderWriter &ShaderWriter::SampleTexture2D(const char *sampName, const char *uv break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - if (samp && samp->array) { + if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; F("%s(%s, vec3(%s, %s))", lang_.texture, sampName, uv, index); } else { @@ -542,7 +533,7 @@ ShaderWriter &ShaderWriter::SampleTexture2DOffset(const char *sampName, const ch break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - if (samp->array) { + if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; F("%sOffset(%s, vec3(%s, %s), ivec3(%d, %d))", lang_.texture, sampName, uv, index, offX, offY); } else { @@ -566,8 +557,9 @@ ShaderWriter &ShaderWriter::LoadTexture2D(const char *sampName, const char *uv, break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - if ((flags_ & ShaderWriterFlags::FS_AUTO_STEREO) && samp->array) { - F("texelFetch(%s, %s, %d)", sampName, uv, level); + if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { + const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "gl_ViewIndex" : "0"; + F("texelFetch(%s, vec3(%s, %s), %d)", sampName, uv, index, level); } else { F("texelFetch(%s, %s, %d)", sampName, uv, level); } diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 567e4c33a5..761eacd867 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -33,7 +33,7 @@ struct VaryingDef { enum class ShaderWriterFlags { NONE = 0, FS_WRITE_DEPTH = 1, - FS_AUTO_STEREO = 2, // Automatically makes sampler 0 an array sampler, and samples it by gl_ViewIndex. Useful for stereo rendering. + FS_AUTO_STEREO = 2, // Automatically indexes makes samplers tagged with `array` by gl_ViewIndex. Useful for stereo rendering. }; ENUM_CLASS_BITOPS(ShaderWriterFlags); @@ -119,8 +119,6 @@ private: void Preamble(Slice extensions); - const SamplerDef *GetSamplerDef(const char *name) const; - char *p_; const ShaderLanguageDesc &lang_; const ShaderStage stage_; diff --git a/Common/GPU/Vulkan/VulkanImage.cpp b/Common/GPU/Vulkan/VulkanImage.cpp index ad712b6a0f..8a439d4d3e 100644 --- a/Common/GPU/Vulkan/VulkanImage.cpp +++ b/Common/GPU/Vulkan/VulkanImage.cpp @@ -123,6 +123,13 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); return false; } + + // Additionally, create an array view, but only if it's a 2D texture. + if (view_info.viewType == VK_IMAGE_VIEW_TYPE_2D) { + view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; + res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &arrayView_); + _assert_(res == VK_SUCCESS); + } return true; } @@ -245,6 +252,9 @@ void VulkanTexture::Destroy() { if (view_ != VK_NULL_HANDLE) { vulkan_->Delete().QueueDeleteImageView(view_); } + if (arrayView_ != VK_NULL_HANDLE) { + vulkan_->Delete().QueueDeleteImageView(arrayView_); + } if (image_ != VK_NULL_HANDLE) { _dbg_assert_(allocation_ != VK_NULL_HANDLE); vulkan_->Delete().QueueDeleteImageAllocation(image_, allocation_); diff --git a/Common/GPU/Vulkan/VulkanImage.h b/Common/GPU/Vulkan/VulkanImage.h index 50d7e0c7f5..e0aa32d385 100644 --- a/Common/GPU/Vulkan/VulkanImage.h +++ b/Common/GPU/Vulkan/VulkanImage.h @@ -51,6 +51,9 @@ public: // Used for sampling, generally. VkImageView GetImageView() const { return view_; } + // For use with some shaders, we might want to view it as a single entry array for convenience. + VkImageView GetImageArrayView() const { return arrayView_; } + int32_t GetWidth() const { return width_; } int32_t GetHeight() const { return height_; } int32_t GetNumMips() const { return numMips_; } @@ -62,6 +65,7 @@ private: VulkanContext *vulkan_; VkImage image_ = VK_NULL_HANDLE; VkImageView view_ = VK_NULL_HANDLE; + VkImageView arrayView_ = VK_NULL_HANDLE; VmaAllocation allocation_ = VK_NULL_HANDLE; int16_t width_ = 0; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index fbcc288aa2..e673ba5ff9 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -338,10 +338,16 @@ public: if (vkTex_) { vkTex_->Touch(); return vkTex_->GetImageView(); - } else { - // This would be bad. - return VK_NULL_HANDLE; } + return VK_NULL_HANDLE; // This would be bad. + } + + VkImageView GetImageArrayView() { + if (vkTex_) { + vkTex_->Touch(); + return vkTex_->GetImageArrayView(); + } + return VK_NULL_HANDLE; // This would be bad. } private: @@ -417,7 +423,7 @@ public: void SetStencilParams(uint8_t refValue, uint8_t writeMask, uint8_t compareMask) override; void BindSamplerStates(int start, int count, SamplerState **state) override; - void BindTextures(int start, int count, Texture **textures) override; + void BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) override; void BindNativeTexture(int sampler, void *nativeTexture) override; void BindPipeline(Pipeline *pipeline) override { @@ -520,6 +526,7 @@ private: MAX_FRAME_COMMAND_BUFFERS = 256, }; AutoRef boundTextures_[MAX_BOUND_TEXTURES]; + TextureBindFlags boundTextureFlags_[MAX_BOUND_TEXTURES]; AutoRef boundSamplers_[MAX_BOUND_TEXTURES]; VkImageView boundImageView_[MAX_BOUND_TEXTURES]{}; @@ -994,7 +1001,11 @@ VkDescriptorSet VKContext::GetOrCreateDescriptorSet(VkBuffer buf) { FrameData *frame = &frame_[vulkan_->GetCurFrame()]; for (int i = 0; i < MAX_BOUND_TEXTURES; ++i) { - key.imageViews_[i] = boundTextures_[i] ? boundTextures_[i]->GetImageView() : boundImageView_[i]; + if (boundTextures_[i]) { + key.imageViews_[i] = (boundTextureFlags_[i] & TextureBindFlags::VULKAN_BIND_ARRAY) ? boundTextures_[i]->GetImageArrayView() : boundTextures_[i]->GetImageView(); + } else { + key.imageViews_[i] = boundImageView_[i]; + } key.samplers_[i] = boundSamplers_[i]; } key.buffer_ = buf; @@ -1296,11 +1307,21 @@ void VKContext::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offset, memcpy(buf->data_ + offset, data, size); } -void VKContext::BindTextures(int start, int count, Texture **textures) { +void VKContext::BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) { _assert_(start + count <= MAX_BOUND_TEXTURES); for (int i = start; i < start + count; i++) { boundTextures_[i] = static_cast(textures[i - start]); - boundImageView_[i] = boundTextures_[i] ? boundTextures_[i]->GetImageView() : GetNullTexture()->GetImageView(); + boundTextureFlags_[i] = flags; + if (boundTextures_[i]) { + // NOTE: These image views are actually not used, it seems - they get overridden in GetOrCreateDescriptorSet + if (flags & TextureBindFlags::VULKAN_BIND_ARRAY) { + boundImageView_[i] = boundTextures_[i]->GetImageArrayView(); + } else { + boundImageView_[i] = boundTextures_[i]->GetImageView(); + } + } else { + boundImageView_[i] = GetNullTexture()->GetImageView(); + } } } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 947c89aae0..2097debe46 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -13,6 +13,7 @@ #include #include +#include "Common/Common.h" #include "Common/GPU/DataFormat.h" #include "Common/GPU/Shader.h" #include "Common/Data/Collections/Slice.h" @@ -598,6 +599,12 @@ struct RenderPassInfo { const int ALL_LAYERS = -1; +enum class TextureBindFlags { + NONE = 0, + VULKAN_BIND_ARRAY = 1, +}; +ENUM_CLASS_BITOPS(TextureBindFlags); + class DrawContext { public: virtual ~DrawContext(); @@ -688,7 +695,7 @@ public: virtual void SetStencilParams(uint8_t refValue, uint8_t writeMask, uint8_t compareMask) = 0; virtual void BindSamplerStates(int start, int count, SamplerState **state) = 0; - virtual void BindTextures(int start, int count, Texture **textures) = 0; + virtual void BindTextures(int start, int count, Texture **textures, TextureBindFlags flags = TextureBindFlags::NONE) = 0; virtual void BindVertexBuffers(int start, int count, Buffer **buffers, const int *offsets) = 0; virtual void BindIndexBuffer(Buffer *indexBuffer, int offset) = 0; diff --git a/GPU/Common/Draw2D.cpp b/GPU/Common/Draw2D.cpp index 9b342e05bc..06560282d8 100644 --- a/GPU/Common/Draw2D.cpp +++ b/GPU/Common/Draw2D.cpp @@ -37,7 +37,7 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[1] = { - { 0, "tex" }, + { 0, "tex", SamplerFlags::ARRAY_ON_VULKAN }, }; const UniformDef g_draw2Duniforms[2] = { @@ -88,8 +88,8 @@ Draw2DPipelineInfo GenerateDraw2DCopyColorRect2LinFs(ShaderWriter &writer) { } Draw2DPipelineInfo GenerateDraw2DCopyDepthFs(ShaderWriter &writer) { - writer.DeclareSamplers(samplers); writer.SetFlags(ShaderWriterFlags::FS_WRITE_DEPTH); + writer.DeclareSamplers(samplers); writer.BeginFSMain(Slice::empty(), varyings); writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n"); writer.C(" gl_FragDepth = ").SampleTexture2D("tex", "v_texcoord.xy").C(".x;\n"); @@ -103,8 +103,8 @@ Draw2DPipelineInfo GenerateDraw2DCopyDepthFs(ShaderWriter &writer) { } Draw2DPipelineInfo GenerateDraw2D565ToDepthFs(ShaderWriter &writer) { - writer.DeclareSamplers(samplers); writer.SetFlags(ShaderWriterFlags::FS_WRITE_DEPTH); + writer.DeclareSamplers(samplers); writer.BeginFSMain(Slice::empty(), varyings); writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n"); // Unlike when just copying a depth buffer, here we're generating new depth values so we'll @@ -123,8 +123,8 @@ Draw2DPipelineInfo GenerateDraw2D565ToDepthFs(ShaderWriter &writer) { } Draw2DPipelineInfo GenerateDraw2D565ToDepthDeswizzleFs(ShaderWriter &writer) { - writer.DeclareSamplers(samplers); writer.SetFlags(ShaderWriterFlags::FS_WRITE_DEPTH); + writer.DeclareSamplers(samplers); writer.BeginFSMain(g_draw2Duniforms, varyings); writer.C(" vec4 outColor = vec4(0.0, 0.0, 0.0, 0.0);\n"); // Unlike when just copying a depth buffer, here we're generating new depth values so we'll @@ -182,6 +182,10 @@ void Draw2D::Ensure2DResources() { if (!draw2DVs_) { char *vsCode = new char[8192]; + ShaderWriterFlags flags = ShaderWriterFlags::NONE; + if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { + flags = ShaderWriterFlags::FS_AUTO_STEREO; + } ShaderWriter writer(vsCode, shaderLanguageDesc, ShaderStage::Vertex); GenerateDraw2DVS(writer); _assert_msg_(strlen(vsCode) < 8192, "Draw2D VS length error: %d", (int)strlen(vsCode)); @@ -315,6 +319,7 @@ void Draw2D::DrawStrip2D(Draw::Texture *tex, Draw2DVertex *verts, int vertexCoun draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub)); if (tex) { + // This won't work since all the shaders above expect array textures on Vulkan. draw_->BindTextures(TEX_SLOT_PSP_TEXTURE, 1, &tex); } draw_->BindSamplerStates(TEX_SLOT_PSP_TEXTURE, 1, linearFilter ? &draw2DSamplerLinear_ : &draw2DSamplerNearest_); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 4558d63b2b..a2b60d231b 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1140,7 +1140,7 @@ void FramebufferManagerCommon::DrawPixels(VirtualFramebuffer *vfb, int dstX, int Draw::Texture *pixelsTex = MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height); if (pixelsTex) { - draw_->BindTextures(0, 1, &pixelsTex); + draw_->BindTextures(0, 1, &pixelsTex, Draw::TextureBindFlags::VULKAN_BIND_ARRAY); // TODO: Replace with draw2D_.Blit() directly. DrawActiveTexture(dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, u0, v0, u1, v1, ROTATION_LOCKED_HORIZONTAL, flags); @@ -3042,7 +3042,7 @@ void FramebufferManagerCommon::BlitUsingRaster( draw_->BindTexture(0, nullptr); // This will get optimized away in case it's already bound (in VK and GL at least..) draw_->BindFramebufferAsRenderTarget(dest, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); - draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, 0); + draw_->BindFramebufferAsTexture(src, Draw::ALL_LAYERS, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, 0); if (destX1 == 0.0f && destY1 == 0.0f && destX2 >= destW && destY2 >= destH) { // We overwrite the whole channel of the framebuffer, so we can invalidate the current contents. From 524e92374f0443d5070c028d79498ef3ddc642af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 25 Oct 2022 23:59:42 +0200 Subject: [PATCH 259/374] Use arrays more consistently. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 12 +++++++++--- Common/GPU/thin3d.h | 10 ++++++++++ GPU/Common/DepalettizeShaderCommon.cpp | 2 +- GPU/Common/Draw2D.cpp | 7 ++++++- GPU/Common/FramebufferManagerCommon.cpp | 2 +- GPU/Common/PresentationCommon.cpp | 2 +- GPU/Common/ReinterpretFramebuffer.cpp | 3 +-- GPU/Vulkan/TextureCacheVulkan.cpp | 2 +- 8 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index e673ba5ff9..d49f1d51a6 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -526,9 +526,9 @@ private: MAX_FRAME_COMMAND_BUFFERS = 256, }; AutoRef boundTextures_[MAX_BOUND_TEXTURES]; - TextureBindFlags boundTextureFlags_[MAX_BOUND_TEXTURES]; AutoRef boundSamplers_[MAX_BOUND_TEXTURES]; VkImageView boundImageView_[MAX_BOUND_TEXTURES]{}; + TextureBindFlags boundTextureFlags_[MAX_BOUND_TEXTURES]; struct FrameData { FrameData() : descriptorPool("VKContext", false) { @@ -1310,6 +1310,7 @@ void VKContext::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offset, void VKContext::BindTextures(int start, int count, Texture **textures, TextureBindFlags flags) { _assert_(start + count <= MAX_BOUND_TEXTURES); for (int i = start; i < start + count; i++) { + _dbg_assert_(i >= 0 && i < MAX_BOUND_TEXTURES); boundTextures_[i] = static_cast(textures[i - start]); boundTextureFlags_[i] = flags; if (boundTextures_[i]) { @@ -1326,6 +1327,7 @@ void VKContext::BindTextures(int start, int count, Texture **textures, TextureBi } void VKContext::BindNativeTexture(int sampler, void *nativeTexture) { + _dbg_assert_(sampler >= 0 && sampler < MAX_BOUND_TEXTURES); boundTextures_[sampler] = nullptr; boundImageView_[sampler] = (VkImageView)nativeTexture; } @@ -1587,8 +1589,12 @@ void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPass } void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) { + if (layer != ALL_LAYERS) { + layer = layer; + } + VKFramebuffer *fb = (VKFramebuffer *)fbo; - _assert_(binding < MAX_BOUND_TEXTURES); + _assert_(binding >= 0 && binding < MAX_BOUND_TEXTURES); // TODO: There are cases where this is okay, actually. But requires layout transitions and stuff - // we're not ready for this. @@ -1607,7 +1613,7 @@ void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChanne break; } - boundTextures_[binding] = nullptr; + boundTextures_[binding].clear(); boundImageView_[binding] = renderManager_.BindFramebufferAsTexture(fb->GetFB(), binding, aspect, layer); } diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 2097debe46..226270f8c9 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -397,6 +397,16 @@ struct AutoRef { operator T *() { return ptr; } + operator bool() const { + return ptr != nullptr; + } + + void clear() { + if (ptr) { + ptr->Release(); + ptr = nullptr; + } + } T *ptr = nullptr; }; diff --git a/GPU/Common/DepalettizeShaderCommon.cpp b/GPU/Common/DepalettizeShaderCommon.cpp index a784d22377..52c67152ef 100644 --- a/GPU/Common/DepalettizeShaderCommon.cpp +++ b/GPU/Common/DepalettizeShaderCommon.cpp @@ -35,7 +35,7 @@ static const InputDef vsInputs[2] = { // TODO: Deduplicate with TextureShaderCommon.cpp static const SamplerDef samplers[2] = { - { 0, "tex" }, + { 0, "tex", SamplerFlags::ARRAY_ON_VULKAN }, { 1, "pal" }, }; diff --git a/GPU/Common/Draw2D.cpp b/GPU/Common/Draw2D.cpp index 06560282d8..2b81178233 100644 --- a/GPU/Common/Draw2D.cpp +++ b/GPU/Common/Draw2D.cpp @@ -184,6 +184,7 @@ void Draw2D::Ensure2DResources() { char *vsCode = new char[8192]; ShaderWriterFlags flags = ShaderWriterFlags::NONE; if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { + // Hm, we're compiling the vertex shader here, probably don't need this... flags = ShaderWriterFlags::FS_AUTO_STEREO; } ShaderWriter writer(vsCode, shaderLanguageDesc, ShaderStage::Vertex); @@ -224,7 +225,11 @@ Draw2DPipeline *Draw2D::Create2DPipeline(std::functionGetShaderLanguageDesc(); char *fsCode = new char[8192]; - ShaderWriter writer(fsCode, shaderLanguageDesc, ShaderStage::Fragment); + ShaderWriterFlags flags = ShaderWriterFlags::NONE; + if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { + flags = ShaderWriterFlags::FS_AUTO_STEREO; + } + ShaderWriter writer(fsCode, shaderLanguageDesc, ShaderStage::Fragment, Slice::empty(), flags); Draw2DPipelineInfo info = generate(writer); _assert_msg_(strlen(fsCode) < 8192, "Draw2D FS length error: %d", (int)strlen(fsCode)); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index a2b60d231b..f7a470bb7d 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -3042,7 +3042,7 @@ void FramebufferManagerCommon::BlitUsingRaster( draw_->BindTexture(0, nullptr); // This will get optimized away in case it's already bound (in VK and GL at least..) draw_->BindFramebufferAsRenderTarget(dest, { Draw::RPAction::KEEP, Draw::RPAction::KEEP, Draw::RPAction::KEEP }, tag ? tag : "BlitUsingRaster"); - draw_->BindFramebufferAsTexture(src, Draw::ALL_LAYERS, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, 0); + draw_->BindFramebufferAsTexture(src, 0, pipeline->info.readChannel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, Draw::ALL_LAYERS); if (destX1 == 0.0f && destY1 == 0.0f && destX2 >= destW && destY2 >= destH) { // We overwrite the whole channel of the framebuffer, so we can invalidate the current contents. diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index d72eb55a2c..1cd86101d5 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -596,7 +596,7 @@ bool PresentationCommon::BindSource(int binding, bool bindStereo) { draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, Draw::ALL_LAYERS); return true; } else { - // Single layer + // Single layer. This might be from a post shader and those don't yet support stereo. draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); return false; } diff --git a/GPU/Common/ReinterpretFramebuffer.cpp b/GPU/Common/ReinterpretFramebuffer.cpp index b14e324d0d..ccb58c1c9b 100644 --- a/GPU/Common/ReinterpretFramebuffer.cpp +++ b/GPU/Common/ReinterpretFramebuffer.cpp @@ -14,14 +14,13 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[1] = { - { 0, "tex" } + { 0, "tex", SamplerFlags::ARRAY_ON_VULKAN } }; // Requires full size integer math. It would be possible to make a floating point-only version with lots of // modulo and stuff, might do it one day. Draw2DPipelineInfo GenerateReinterpretFragmentShader(ShaderWriter &writer, GEBufferFormat from, GEBufferFormat to) { writer.HighPrecisionFloat(); - writer.DeclareSamplers(samplers); if (writer.Lang().bitwiseOps) { diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index c465aa31c2..8f80aa8474 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -846,6 +846,6 @@ std::string TextureCacheVulkan::DebugGetSamplerString(std::string id, DebugShade } void *TextureCacheVulkan::GetNativeTextureView(const TexCacheEntry *entry) { - VkImageView view = entry->vkTex->GetImageView(); + VkImageView view = entry->vkTex->GetImageArrayView(); return (void *)view; } From 8413473fa4e2448be9e97ac716aa5acf902bde5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 00:24:43 +0200 Subject: [PATCH 260/374] Fix more cases, GTA works now. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 3 ++- GPU/Common/FragmentShaderGenerator.cpp | 9 ++++----- GPU/Common/TextureCacheCommon.cpp | 13 ++++++++++--- GPU/Common/TextureShaderCommon.cpp | 2 +- GPU/GPUState.h | 6 ++++++ GPU/Vulkan/PipelineManagerVulkan.cpp | 8 +++++++- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 7b314cc0d1..cee212ee98 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1444,7 +1444,8 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c const RenderPassType rpType = step.render.renderPassType; - for (const auto &c : commands) { + for (size_t i = 0; i < commands.size(); i++) { + const VkRenderData &c = commands[i]; switch (c.cmd) { case VKRRenderCommand::REMOVED: break; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 64693097a4..7b29c19cf0 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -648,12 +648,11 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } } else if (arrayTexture) { // Used for stereo rendering. + const char *arrayIndex = useStereo ? "float(gl_ViewIndex)" : "0.0"; if (doTextureProjection) { - if (doTextureProjection) { - WRITE(p, " vec4 t = %sProj(tex, %s);\n", compat.texture, texcoord); - } else { - WRITE(p, " vec4 t = %s(tex, %s.xy);\n", compat.texture, texcoord); - } + WRITE(p, " vec4 t = %sProj(tex, vec4(%s, %s));\n", compat.texture, texcoord, arrayIndex); + } else { + WRITE(p, " vec4 t = %s(tex, vec3(%s.xy, %s));\n", compat.texture, texcoord, arrayIndex); } } else { if (doTextureProjection) { diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 4e04144c96..fdfc874fda 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -371,6 +371,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { if (!Memory::IsValidAddress(texaddr)) { // Bind a null texture and return. Unbind(); + gstate_c.arrayTexture = false; return nullptr; } @@ -528,6 +529,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { gstate_c.curTextureWidth = w; gstate_c.curTextureHeight = h; gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0); + gstate_c.SetTextureIsArray(false); if (rehash) { // Update in case any of these changed. entry->sizeInRAM = (textureBitsPerPixel[texFormat] * bufw * h / 2) / 8; @@ -636,6 +638,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { gstate_c.curTextureWidth = w; gstate_c.curTextureHeight = h; gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0); + gstate_c.SetTextureIsArray(false); // Ordinary 2D textures still aren't used by array view in VK. We probably might as well, though, at this point.. failedTexture_ = false; nextTexture_ = entry; @@ -1126,6 +1129,7 @@ void TextureCacheCommon::SetTextureFramebuffer(const AttachCandidate &candidate) } gstate_c.SetTextureIs3D(false); + gstate_c.SetTextureIsArray(true); nextNeedsRehash_ = false; nextNeedsChange_ = false; @@ -2020,11 +2024,13 @@ void TextureCacheCommon::ApplyTexture() { entry->lastFrame = gpuStats.numFlips; gstate_c.SetTextureFullAlpha(false); gstate_c.SetTextureIs3D(false); + gstate_c.SetTextureIsArray(false); } else { entry->lastFrame = gpuStats.numFlips; BindTexture(entry); gstate_c.SetTextureFullAlpha(entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL); gstate_c.SetTextureIs3D((entry->status & TexCacheEntry::STATUS_3D) != 0); + gstate_c.SetTextureIsArray(false); } } @@ -2121,7 +2127,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer // Very icky conflation here of native and thin3d rendering. This will need careful work per backend in BindAsClutTexture. BindAsClutTexture(clutTexture.texture, smoothedDepal); - framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET, 0); + framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET, Draw::ALL_LAYERS); // Vulkan needs to do some extra work here to pick out the native handle from Draw. BoundFramebufferTexture(); @@ -2197,7 +2203,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer Draw::Viewport vp{ 0.0f, 0.0f, (float)depalWidth, (float)framebuffer->renderHeight, 0.0f, 1.0f }; draw_->SetViewports(1, &vp); - draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, Draw::ALL_LAYERS); draw_->BindTexture(1, clutTexture.texture); Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false); Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(smoothedDepal); @@ -2226,7 +2232,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer shaderManager_->DirtyLastShader(); } else { framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET, 0); + framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET, Draw::ALL_LAYERS); BoundFramebufferTexture(); gstate_c.SetUseShaderDepal(ShaderDepalMode::OFF); @@ -2331,6 +2337,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { // Since we've drawn using thin3d, might need these. gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); + } void TextureCacheCommon::Clear(bool delete_them) { diff --git a/GPU/Common/TextureShaderCommon.cpp b/GPU/Common/TextureShaderCommon.cpp index 5919d5442e..a1ba51de53 100644 --- a/GPU/Common/TextureShaderCommon.cpp +++ b/GPU/Common/TextureShaderCommon.cpp @@ -34,7 +34,7 @@ static const VaryingDef varyings[1] = { }; static const SamplerDef samplers[2] = { - { 0, "tex" }, + { 0, "tex", SamplerFlags::ARRAY_ON_VULKAN }, { 1, "pal" }, }; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index b323fc1067..0347371212 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -562,6 +562,12 @@ struct GPUStateCache { Dirty(DIRTY_FRAGMENTSHADER_STATE | (is3D ? DIRTY_MIPBIAS : 0)); } } + void SetTextureIsArray(bool isArrayTexture) { // VK only + if (arrayTexture != isArrayTexture) { + arrayTexture = isArrayTexture; + Dirty(DIRTY_FRAGMENTSHADER_STATE); + } + } u32 useFlags; diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 95b019483b..d9ae5ddd70 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -12,6 +12,7 @@ #include "GPU/Vulkan/PipelineManagerVulkan.h" #include "GPU/Vulkan/ShaderManagerVulkan.h" #include "GPU/Common/DrawEngineCommon.h" +#include "GPU/Common/ShaderId.h" #include "Common/GPU/thin3d.h" #include "Common/GPU/Vulkan/VulkanRenderManager.h" #include "Common/GPU/Vulkan/VulkanQueueRunner.h" @@ -296,7 +297,12 @@ static VulkanPipeline *CreateVulkanPipeline(VulkanRenderManager *renderManager, desc->pipelineLayout = layout; - VKRGraphicsPipeline *pipeline = renderManager->CreateGraphicsPipeline(desc, pipelineFlags, variantBitmask, "game"); + std::string tag = "game"; +#ifdef _DEBUG + tag = FragmentShaderDesc(fs->GetID()) + " VS " + VertexShaderDesc(vs->GetID()); +#endif + + VKRGraphicsPipeline *pipeline = renderManager->CreateGraphicsPipeline(desc, pipelineFlags, variantBitmask, tag.c_str()); vulkanPipeline->pipeline = pipeline; if (useBlendConstant) { From 390a136cb5c743f1adbe1a475d5c6bb7d088d836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 00:34:28 +0200 Subject: [PATCH 261/374] Stereo now works through shader depal too --- Common/GPU/ShaderWriter.cpp | 6 +++++- Common/GPU/ShaderWriter.h | 6 +++++- GPU/Common/FragmentShaderGenerator.cpp | 22 ++++++++++++++++++++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index 4e98e17d0c..495267ce48 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -465,6 +465,10 @@ void ShaderWriter::DeclareSamplers(Slice samplers) { samplerDefs_ = samplers; } +void ShaderWriter::ApplySamplerMetadata(Slice samplers) { + samplerDefs_ = samplers; +} + void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { switch (lang_.shaderLanguage) { case HLSL_D3D11: @@ -535,7 +539,7 @@ ShaderWriter &ShaderWriter::SampleTexture2DOffset(const char *sampName, const ch // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; - F("%sOffset(%s, vec3(%s, %s), ivec3(%d, %d))", lang_.texture, sampName, uv, index, offX, offY); + F("%sOffset(%s, vec3(%s, %s), ivec2(%d, %d))", lang_.texture, sampName, uv, index, offX, offY); } else { F("%sOffset(%s, %s, ivec2(%d, %d))", lang_.texture, sampName, uv, offX, offY); } diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 761eacd867..48b0bff9e5 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -40,7 +40,7 @@ ENUM_CLASS_BITOPS(ShaderWriterFlags); class ShaderWriter { public: // Extensions are supported for both OpenGL ES and Vulkan (though of course, they're different). - ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, Slice extensions = Slice(), ShaderWriterFlags flags = ShaderWriterFlags::NONE) : p_(buffer), lang_(lang), stage_(stage) { + ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, Slice extensions = Slice(), ShaderWriterFlags flags = ShaderWriterFlags::NONE) : p_(buffer), lang_(lang), stage_(stage), flags_(flags) { Preamble(extensions); } ShaderWriter(const ShaderWriter &) = delete; @@ -79,6 +79,10 @@ public: // NOTE: samplers must live for the rest of ShaderWriter's lifetime. No way to express that in C++ though :( void DeclareSamplers(Slice samplers); + // Same as DeclareSamplers, but doesn't actually declare them. + // This is currently only required by FragmentShaderGenerator. + void ApplySamplerMetadata(Slice samplers); + void ConstFloat(const char *name, float value); void SetFlags(ShaderWriterFlags flags) { flags_ |= flags; } void SetTexBindingBase(int base) { texBindingBase_ = base; } diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 7b29c19cf0..e218746fcb 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -36,6 +36,19 @@ #define WRITE(p, ...) p.F(__VA_ARGS__) +// This is only used in stereo mode, so okay to declare "tex" as ARRAY_ON_ +static const SamplerDef samplersMono[3] = { + { 0, "tex" }, + { 1, "fbotex", SamplerFlags::ARRAY_ON_VULKAN }, + { 2, "pal" }, +}; + +static const SamplerDef samplersStereo[3] = { + { 0, "tex", SamplerFlags::ARRAY_ON_VULKAN }, + { 1, "fbotex", SamplerFlags::ARRAY_ON_VULKAN }, + { 2, "pal" }, +}; + bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLanguageDesc &compat, Draw::Bugs bugs, uint64_t *uniformMask, FragmentShaderFlags *fragmentShaderFlags, std::string *errorString) { *uniformMask = 0; if (fragmentShaderFlags) { @@ -44,7 +57,6 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu errorString->clear(); bool useStereo = id.Bit(FS_BIT_STEREO); - bool highpFog = false; bool highpTexcoord = false; bool enableFragmentTestCache = gstate_c.Use(GPU_USE_FRAGMENT_TEST_CACHE); @@ -80,7 +92,13 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu extensions.push_back("#extension GL_EXT_multiview : enable"); } - ShaderWriter p(buffer, compat, ShaderStage::Fragment, extensions); + ShaderWriterFlags flags = ShaderWriterFlags::NONE; + if (useStereo) { + flags |= ShaderWriterFlags::FS_AUTO_STEREO; + } + + ShaderWriter p(buffer, compat, ShaderStage::Fragment, extensions, flags); + p.ApplySamplerMetadata(useStereo ? samplersStereo : samplersMono); bool lmode = id.Bit(FS_BIT_LMODE); bool doTexture = id.Bit(FS_BIT_DO_TEXTURE); From 2a1526c352a2bdf836ed67190fa46f29d3f7f860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 10:45:58 +0200 Subject: [PATCH 262/374] Address feedback --- Common/GPU/ShaderWriter.cpp | 2 +- Common/GPU/Vulkan/thin3d_vulkan.cpp | 7 ++----- GPU/Common/FragmentShaderGenerator.cpp | 5 ----- GPU/Common/TextureCacheCommon.cpp | 4 ++-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index 495267ce48..d7e0d16856 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -478,7 +478,7 @@ void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { F("sampler %s: register(s%d);\n", def.name, def.binding); break; case GLSL_VULKAN: - // In the thin3d descriptor set layout, textures start at 1 in set 0. Hence the +1. + // texBindingBase_ is used for the thin3d descriptor set layout, where they start at 1. if (def.flags & SamplerFlags::ARRAY_ON_VULKAN) { F("layout(set = 0, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name); } else { diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index d49f1d51a6..8b7144927b 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1314,7 +1314,8 @@ void VKContext::BindTextures(int start, int count, Texture **textures, TextureBi boundTextures_[i] = static_cast(textures[i - start]); boundTextureFlags_[i] = flags; if (boundTextures_[i]) { - // NOTE: These image views are actually not used, it seems - they get overridden in GetOrCreateDescriptorSet + // If a texture is bound, we set these up in GetOrCreateDescriptorSet too. + // But we might need to set the view here anyway so it can be queried using GetNativeObject. if (flags & TextureBindFlags::VULKAN_BIND_ARRAY) { boundImageView_[i] = boundTextures_[i]->GetImageArrayView(); } else { @@ -1589,10 +1590,6 @@ void VKContext::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPass } void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChannel channelBit, int layer) { - if (layer != ALL_LAYERS) { - layer = layer; - } - VKFramebuffer *fb = (VKFramebuffer *)fbo; _assert_(binding >= 0 && binding < MAX_BOUND_TEXTURES); diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index e218746fcb..10c516f45d 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -36,7 +36,6 @@ #define WRITE(p, ...) p.F(__VA_ARGS__) -// This is only used in stereo mode, so okay to declare "tex" as ARRAY_ON_ static const SamplerDef samplersMono[3] = { { 0, "tex" }, { 1, "fbotex", SamplerFlags::ARRAY_ON_VULKAN }, @@ -88,10 +87,6 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } } - if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN && useStereo) { - extensions.push_back("#extension GL_EXT_multiview : enable"); - } - ShaderWriterFlags flags = ShaderWriterFlags::NONE; if (useStereo) { flags |= ShaderWriterFlags::FS_AUTO_STEREO; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index fdfc874fda..8e60f8e5aa 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -371,7 +371,8 @@ TexCacheEntry *TextureCacheCommon::SetTexture() { if (!Memory::IsValidAddress(texaddr)) { // Bind a null texture and return. Unbind(); - gstate_c.arrayTexture = false; + gstate_c.SetTextureIs3D(false); + gstate_c.SetTextureIsArray(false); return nullptr; } @@ -2337,7 +2338,6 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) { // Since we've drawn using thin3d, might need these. gstate_c.Dirty(DIRTY_ALL_RENDER_STATE); - } void TextureCacheCommon::Clear(bool delete_them) { From 15d4495f76d79591c290038908069c854e3080ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 11:02:58 +0200 Subject: [PATCH 263/374] Pass shadergen tests --- Common/GPU/ShaderWriter.cpp | 6 +++--- Common/GPU/ShaderWriter.h | 1 + GPU/Common/FragmentShaderGenerator.cpp | 4 ++-- GPU/Common/VertexShaderGenerator.cpp | 6 +++++- unittest/TestShaderGenerators.cpp | 6 ++++++ 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index d7e0d16856..ed7a3612f9 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -513,7 +513,7 @@ ShaderWriter &ShaderWriter::SampleTexture2D(const char *sampName, const char *uv break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { + if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN) && lang_.shaderLanguage == GLSL_VULKAN) { const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; F("%s(%s, vec3(%s, %s))", lang_.texture, sampName, uv, index); } else { @@ -537,7 +537,7 @@ ShaderWriter &ShaderWriter::SampleTexture2DOffset(const char *sampName, const ch break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { + if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN) && lang_.shaderLanguage == GLSL_VULKAN) { const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "float(gl_ViewIndex)" : "0.0"; F("%sOffset(%s, vec3(%s, %s), ivec2(%d, %d))", lang_.texture, sampName, uv, index, offX, offY); } else { @@ -561,7 +561,7 @@ ShaderWriter &ShaderWriter::LoadTexture2D(const char *sampName, const char *uv, break; default: // Note: we ignore the sampler. make sure you bound samplers to the textures correctly. - if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN)) { + if (samp && (samp->flags & SamplerFlags::ARRAY_ON_VULKAN) && lang_.shaderLanguage == GLSL_VULKAN) { const char *index = (flags_ & ShaderWriterFlags::FS_AUTO_STEREO) ? "gl_ViewIndex" : "0"; F("texelFetch(%s, vec3(%s, %s), %d)", sampName, uv, index, level); } else { diff --git a/Common/GPU/ShaderWriter.h b/Common/GPU/ShaderWriter.h index 48b0bff9e5..379e704319 100644 --- a/Common/GPU/ShaderWriter.h +++ b/Common/GPU/ShaderWriter.h @@ -41,6 +41,7 @@ class ShaderWriter { public: // Extensions are supported for both OpenGL ES and Vulkan (though of course, they're different). ShaderWriter(char *buffer, const ShaderLanguageDesc &lang, ShaderStage stage, Slice extensions = Slice(), ShaderWriterFlags flags = ShaderWriterFlags::NONE) : p_(buffer), lang_(lang), stage_(stage), flags_(flags) { + buffer[0] = '\0'; Preamble(extensions); } ShaderWriter(const ShaderWriter &) = delete; diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 10c516f45d..93b1e20464 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -68,6 +68,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } bool texture3D = id.Bit(FS_BIT_3D_TEXTURE); + bool arrayTexture = id.Bit(FS_BIT_SAMPLE_ARRAY_TEXTURE); ReplaceAlphaType stencilToAlpha = static_cast(id.Bits(FS_BIT_STENCIL_TO_ALPHA, 2)); @@ -93,7 +94,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu } ShaderWriter p(buffer, compat, ShaderStage::Fragment, extensions, flags); - p.ApplySamplerMetadata(useStereo ? samplersStereo : samplersMono); + p.ApplySamplerMetadata(arrayTexture ? samplersStereo : samplersMono); bool lmode = id.Bit(FS_BIT_LMODE); bool doTexture = id.Bit(FS_BIT_DO_TEXTURE); @@ -108,7 +109,6 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu bool doTextureProjection = id.Bit(FS_BIT_DO_TEXTURE_PROJ); bool doTextureAlpha = id.Bit(FS_BIT_TEXALPHA); - bool arrayTexture = id.Bit(FS_BIT_SAMPLE_ARRAY_TEXTURE); if (texture3D && arrayTexture) { *errorString = "Invalid combination of 3D texture and array texture, shouldn't happen"; return false; diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 3eb92c4bcd..9e6ab317b0 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -158,7 +158,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag bool useSimpleStereo = id.Bit(VS_BIT_SIMPLE_STEREO); - if (compat.shaderLanguage == ShaderLanguage::GLSL_VULKAN && useSimpleStereo) { + if (useSimpleStereo) { + if (compat.shaderLanguage != ShaderLanguage::GLSL_VULKAN) { + *errorString = "Multiview only supported with Vulkan for now"; + return false; + } extensions.push_back("#extension GL_EXT_multiview : enable"); } diff --git a/unittest/TestShaderGenerators.cpp b/unittest/TestShaderGenerators.cpp index a420299520..6701e162fd 100644 --- a/unittest/TestShaderGenerators.cpp +++ b/unittest/TestShaderGenerators.cpp @@ -28,6 +28,8 @@ static constexpr size_t CODE_BUFFER_SIZE = 32768; bool GenerateFShader(FShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs bugs, std::string *errorString) { + buffer[0] = '\0'; + uint64_t uniformMask; switch (lang) { case ShaderLanguage::GLSL_VULKAN: @@ -61,6 +63,8 @@ bool GenerateFShader(FShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs } bool GenerateVShader(VShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs bugs, std::string *errorString) { + buffer[0] = '\0'; + uint32_t attrMask; uint64_t uniformMask; switch (lang) { @@ -95,6 +99,8 @@ bool GenerateVShader(VShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs } bool GenerateGShader(GShaderID id, char *buffer, ShaderLanguage lang, Draw::Bugs bugs, std::string *errorString) { + buffer[0] = '\0'; + errorString->clear(); switch (lang) { From cd203291ba20332fb0746e1366b5df066fa42602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 11:23:12 +0200 Subject: [PATCH 264/374] Fix rendering in non-stereo mode --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 1 + GPU/Common/ShaderId.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index cee212ee98..fef2673d0a 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1629,6 +1629,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c default: ERROR_LOG(G3D, "Unimpl queue command"); + break; } } vkCmdEndRenderPass(cmd); diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 40b31393c9..9110ca7443 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -368,12 +368,13 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip id.SetBit(FS_BIT_FLATSHADE, doFlatShading); id.SetBit(FS_BIT_COLOR_WRITEMASK, colorWriteMask); + // All framebuffers are array textures now. + if (gstate_c.arrayTexture) { + id.SetBit(FS_BIT_SAMPLE_ARRAY_TEXTURE); + } + // Stereo support if (gstate_c.Use(GPU_USE_SINGLE_PASS_STEREO)) { - // All framebuffers are array textures in this mode. - if (gstate_c.arrayTexture) { - id.SetBit(FS_BIT_SAMPLE_ARRAY_TEXTURE); - } id.SetBit(FS_BIT_STEREO); } From 31fd928a5c6b7813aa8e6c5b59c002b1e7200ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 13:29:56 +0200 Subject: [PATCH 265/374] Name more image views. Very useful with a little patch to the Vulkan debug layers. --- Common/GPU/Vulkan/VulkanContext.h | 3 +++ Common/GPU/Vulkan/VulkanImage.cpp | 4 ++++ Common/GPU/Vulkan/VulkanMemory.cpp | 11 +++++++---- Common/GPU/Vulkan/VulkanMemory.h | 2 +- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 2 ++ Common/GPU/Vulkan/VulkanRenderManager.cpp | 7 +++++++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- GPU/Vulkan/DrawEngineVulkan.cpp | 2 +- GPU/Vulkan/VulkanUtil.cpp | 2 +- 9 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index a7622e7a8f..7baf795717 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -222,6 +222,9 @@ public: SetDebugNameImpl((uint64_t)handle, type, name); } } + bool DebugLayerEnabled() const { + return extensionsLookup_.EXT_debug_utils; + } bool MemoryTypeFromProperties(uint32_t typeBits, VkFlags requirements_mask, uint32_t *typeIndex); diff --git a/Common/GPU/Vulkan/VulkanImage.cpp b/Common/GPU/Vulkan/VulkanImage.cpp index 8a439d4d3e..47b1432360 100644 --- a/Common/GPU/Vulkan/VulkanImage.cpp +++ b/Common/GPU/Vulkan/VulkanImage.cpp @@ -123,13 +123,16 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); return false; } + vulkan_->SetDebugName(view_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_.c_str()); // Additionally, create an array view, but only if it's a 2D texture. if (view_info.viewType == VK_IMAGE_VIEW_TYPE_2D) { view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &arrayView_); _assert_(res == VK_SUCCESS); + vulkan_->SetDebugName(arrayView_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_.c_str()); } + return true; } @@ -244,6 +247,7 @@ VkImageView VulkanTexture::CreateViewForMip(int mip) { view_info.subresourceRange.layerCount = 1; VkImageView view; VkResult res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &view); + vulkan_->SetDebugName(view, VK_OBJECT_TYPE_IMAGE_VIEW, "mipview"); _assert_(res == VK_SUCCESS); return view; } diff --git a/Common/GPU/Vulkan/VulkanMemory.cpp b/Common/GPU/Vulkan/VulkanMemory.cpp index 8206c80c91..d8184098a5 100644 --- a/Common/GPU/Vulkan/VulkanMemory.cpp +++ b/Common/GPU/Vulkan/VulkanMemory.cpp @@ -153,7 +153,7 @@ void VulkanDescSetPool::Create(VulkanContext *vulkan, const VkDescriptorPoolCrea _assert_msg_(res == VK_SUCCESS, "Could not create VulkanDescSetPool %s", tag_); } -VkDescriptorSet VulkanDescSetPool::Allocate(int n, const VkDescriptorSetLayout *layouts) { +VkDescriptorSet VulkanDescSetPool::Allocate(int n, const VkDescriptorSetLayout *layouts, const char *tag) { if (descPool_ == VK_NULL_HANDLE || usage_ + n >= info_.maxSets) { // Missing or out of space, need to recreate. VkResult res = Recreate(grow_); @@ -180,9 +180,12 @@ VkDescriptorSet VulkanDescSetPool::Allocate(int n, const VkDescriptorSetLayout * _assert_msg_(result == VK_SUCCESS, "Ran out of descriptor space (frag?) and failed to allocate after recreating a descriptor pool. res=%d", (int)result); } - if (result == VK_SUCCESS) - return desc; - return VK_NULL_HANDLE; + if (result != VK_SUCCESS) { + return VK_NULL_HANDLE; + } + + vulkan_->SetDebugName(desc, VK_OBJECT_TYPE_DESCRIPTOR_SET, tag); + return desc; } void VulkanDescSetPool::Reset() { diff --git a/Common/GPU/Vulkan/VulkanMemory.h b/Common/GPU/Vulkan/VulkanMemory.h index c0a9c1ed02..275ca4bb78 100644 --- a/Common/GPU/Vulkan/VulkanMemory.h +++ b/Common/GPU/Vulkan/VulkanMemory.h @@ -163,7 +163,7 @@ public: void Create(VulkanContext *vulkan, const VkDescriptorPoolCreateInfo &info, const std::vector &sizes); // Allocate a new set, which may resize and empty the current sets. // Use only for the current frame, unless in a cache cleared by clear_. - VkDescriptorSet Allocate(int n, const VkDescriptorSetLayout *layouts); + VkDescriptorSet Allocate(int n, const VkDescriptorSetLayout *layouts, const char *tag); void Reset(); void Destroy(); diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index fef2673d0a..ead24a47fe 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -178,6 +178,7 @@ bool VulkanQueueRunner::CreateSwapchain(VkCommandBuffer cmdInit) { // Also, turns out it's illegal to transition un-acquired images, thanks Hans-Kristian. See #11417. res = vkCreateImageView(vulkan_->GetDevice(), &color_image_view, nullptr, &sc_buffer.view); + vulkan_->SetDebugName(sc_buffer.view, VK_OBJECT_TYPE_IMAGE_VIEW, "swapchain_view"); swapchainImages_.push_back(sc_buffer); _dbg_assert_(res == VK_SUCCESS); } @@ -276,6 +277,7 @@ bool VulkanQueueRunner::InitDepthStencilBuffer(VkCommandBuffer cmd) { VkDevice device = vulkan_->GetDevice(); res = vkCreateImageView(device, &depth_view_info, NULL, &depth_.view); + vulkan_->SetDebugName(depth_.view, VK_OBJECT_TYPE_IMAGE_VIEW, "depth_stencil_backbuffer"); _dbg_assert_(res == VK_SUCCESS); if (res != VK_SUCCESS) return false; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 8c82fa00d1..a83ff65539 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -296,6 +296,7 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ivci.subresourceRange.layerCount = numLayers; ivci.subresourceRange.levelCount = 1; res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.rtView); + vulkan->SetDebugName(img.rtView, VK_OBJECT_TYPE_IMAGE_VIEW, tag); _dbg_assert_(res == VK_SUCCESS); @@ -306,6 +307,7 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ivci.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY; // layered for consistency, even if single image. res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.texAllLayersView); + vulkan->SetDebugName(img.texAllLayersView, VK_OBJECT_TYPE_IMAGE_VIEW, tag); // Create 2D views for both layers. // Useful when multipassing shaders that don't yet exist in a single-pass-stereo version. @@ -314,6 +316,11 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ivci.subresourceRange.layerCount = 1; ivci.subresourceRange.baseArrayLayer = i; res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.texLayerViews[i]); + if (vulkan->DebugLayerEnabled()) { + char temp[128]; + snprintf(temp, sizeof(temp), "%s_layer%d", tag, i); + vulkan->SetDebugName(img.texLayerViews[i], VK_OBJECT_TYPE_IMAGE_VIEW, temp); + } _dbg_assert_(res == VK_SUCCESS); } diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 8b7144927b..285f08a757 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1015,7 +1015,7 @@ VkDescriptorSet VKContext::GetOrCreateDescriptorSet(VkBuffer buf) { return iter->second; } - VkDescriptorSet descSet = frame->descriptorPool.Allocate(1, &descriptorSetLayout_); + VkDescriptorSet descSet = frame->descriptorPool.Allocate(1, &descriptorSetLayout_, "thin3d_descset"); if (descSet == VK_NULL_HANDLE) { ERROR_LOG(G3D, "GetOrCreateDescriptorSet failed"); return VK_NULL_HANDLE; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 335fc29ad9..8af2727736 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -404,7 +404,7 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView // Didn't find one in the frame descriptor set cache, let's make a new one. // We wipe the cache on every frame. - VkDescriptorSet desc = frame.descPool.Allocate(1, &descriptorSetLayout_); + VkDescriptorSet desc = frame.descPool.Allocate(1, &descriptorSetLayout_, "game_descset"); // Even in release mode, this is bad. _assert_msg_(desc != VK_NULL_HANDLE, "Ran out of descriptor space in pool. sz=%d", (int)frame.descSets.size()); diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index fb82f9a474..d23f2ad9b2 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -136,7 +136,7 @@ void VulkanComputeShaderManager::DestroyDeviceObjects() { VkDescriptorSet VulkanComputeShaderManager::GetDescriptorSet(VkImageView image, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize range, VkBuffer buffer2, VkDeviceSize offset2, VkDeviceSize range2) { int curFrame = vulkan_->GetCurFrame(); FrameData &frameData = frameData_[curFrame]; - VkDescriptorSet desc = frameData.descPool.Allocate(1, &descriptorSetLayout_); + VkDescriptorSet desc = frameData.descPool.Allocate(1, &descriptorSetLayout_, "compute_descset"); _assert_(desc != VK_NULL_HANDLE); VkWriteDescriptorSet writes[2]{}; From 7d5bb7925747d3f6ac5ebdf41895961ba93275a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 13:32:38 +0200 Subject: [PATCH 266/374] Fix depal texture binding bug --- GPU/Common/TextureCacheCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index 8e60f8e5aa..e660bb20f8 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -2220,7 +2220,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer draw_->BindTexture(0, nullptr); framebufferManager_->RebindFramebuffer("ApplyTextureFramebuffer"); - draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, 0); + draw_->BindFramebufferAsTexture(depalFBO, 0, Draw::FB_COLOR_BIT, Draw::ALL_LAYERS); BoundFramebufferTexture(); const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16); From 931c869ca9a61dd6957ca603d30caed33e521d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 13:40:13 +0200 Subject: [PATCH 267/374] Fix for stereo with textureProj (emulated projection). --- GPU/Common/FragmentShaderGenerator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 93b1e20464..879552e253 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -663,7 +663,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu // Used for stereo rendering. const char *arrayIndex = useStereo ? "float(gl_ViewIndex)" : "0.0"; if (doTextureProjection) { - WRITE(p, " vec4 t = %sProj(tex, vec4(%s, %s));\n", compat.texture, texcoord, arrayIndex); + // There's no textureProj for array textures, so we need to emulate it. + // Should be fine on any Vulkan-compatible hardware. + WRITE(p, " vec2 uv_proj = (%s.xy) / (%s.z);\n", texcoord, texcoord); + WRITE(p, " vec4 t = %s(tex, vec3(uv_proj, %s));\n", compat.texture, texcoord, arrayIndex); } else { WRITE(p, " vec4 t = %s(tex, vec3(%s.xy, %s));\n", compat.texture, texcoord, arrayIndex); } From 763afd4a8e8125c157c1168ab0641a043ae768a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 16:02:18 +0200 Subject: [PATCH 268/374] Improve compatibility checks for stereo rendering. --- Common/GPU/D3D9/thin3d_d3d9.cpp | 1 - Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- Common/GPU/thin3d.h | 2 +- GPU/Common/PresentationCommon.cpp | 5 +++-- GPU/Vulkan/GPU_Vulkan.cpp | 5 +++-- UI/GameSettingsScreen.cpp | 23 ++++++++++++++--------- UI/GameSettingsScreen.h | 2 ++ 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Common/GPU/D3D9/thin3d_d3d9.cpp b/Common/GPU/D3D9/thin3d_d3d9.cpp index ec524c8dab..8de75b09d0 100644 --- a/Common/GPU/D3D9/thin3d_d3d9.cpp +++ b/Common/GPU/D3D9/thin3d_d3d9.cpp @@ -746,7 +746,6 @@ D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, ID } caps_.deviceID = identifier_.DeviceId; - caps_.multiViewport = false; caps_.depthRangeMinusOneToOne = false; caps_.preferredDepthBufferFormat = DataFormat::D24_S8; caps_.dualSourceBlend = false; diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 285f08a757..c5dcc65f40 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -785,7 +785,6 @@ VKContext::VKContext(VulkanContext *vulkan) caps_.anisoSupported = vulkan->GetDeviceFeatures().enabled.standard.samplerAnisotropy != 0; caps_.geometryShaderSupported = vulkan->GetDeviceFeatures().enabled.standard.geometryShader != 0; caps_.tesselationShaderSupported = vulkan->GetDeviceFeatures().enabled.standard.tessellationShader != 0; - caps_.multiViewport = vulkan->GetDeviceFeatures().enabled.standard.multiViewport != 0; caps_.dualSourceBlend = vulkan->GetDeviceFeatures().enabled.standard.dualSrcBlend != 0; caps_.depthClampSupported = vulkan->GetDeviceFeatures().enabled.standard.depthClamp != 0; caps_.clipDistanceSupported = vulkan->GetDeviceFeatures().enabled.standard.shaderClipDistance != 0; @@ -804,6 +803,7 @@ VKContext::VKContext(VulkanContext *vulkan) caps_.fragmentShaderDepthWriteSupported = true; caps_.blendMinMaxSupported = true; caps_.logicOpSupported = vulkan->GetDeviceFeatures().enabled.standard.logicOp != 0; + caps_.multiViewSupported = vulkan->GetDeviceFeatures().enabled.multiview.multiview != 0; auto deviceProps = vulkan->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDeviceIndex()).properties; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 226270f8c9..e617954010 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -548,7 +548,6 @@ struct DeviceCaps { bool depthRangeMinusOneToOne; // OpenGL style depth bool geometryShaderSupported; bool tesselationShaderSupported; - bool multiViewport; bool dualSourceBlend; bool logicOpSupported; bool depthClampSupported; @@ -567,6 +566,7 @@ struct DeviceCaps { bool fragmentShaderDepthWriteSupported; bool textureDepthSupported; bool blendMinMaxSupported; + bool multiViewSupported; std::string deviceName; // The device name to use when creating the thin3d context, to get the same one. }; diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 1cd86101d5..025888896c 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -34,6 +34,7 @@ #include "Core/HW/Display.h" #include "GPU/Common/PostShader.h" #include "GPU/Common/PresentationCommon.h" +#include "GPU/GPUState.h" #include "Common/GPU/ShaderTranslation.h" struct Vertex { @@ -230,7 +231,7 @@ static std::string ReadShaderSrc(const Path &filename) { bool PresentationCommon::UpdatePostShader() { DestroyStereoShader(); - if (g_Config.bStereoRendering) { + if (gstate_c.Use(GPU_USE_SIMPLE_STEREO_PERSPECTIVE)) { const ShaderInfo *stereoShaderInfo = GetPostShaderInfo(g_Config.sStereoToMonoShader); bool result = CompilePostShader(stereoShaderInfo, &stereoPipeline_); if (!result) { @@ -622,7 +623,7 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u // This should auto-disable usePostShader_ and call ShowPostShaderError(). bool useNearest = flags & OutputFlags::NEAREST; - bool useStereo = g_Config.bStereoRendering && stereoPipeline_ != nullptr; // TODO: Also check that the backend has support for it. + bool useStereo = gstate_c.Use(GPU_USE_SIMPLE_STEREO_PERSPECTIVE) && stereoPipeline_ != nullptr; // TODO: Also check that the backend has support for it. const bool usePostShader = usePostShader_ && !useStereo && !(flags & OutputFlags::RB_SWIZZLE); const bool isFinalAtOutputResolution = usePostShader && postShaderFramebuffers_.size() < postShaderPipelines_.size(); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 29c5e1e459..d7ac28d3c6 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -268,12 +268,13 @@ u32 GPU_Vulkan::CheckGPUFeatures() const { features |= GPU_ROUND_DEPTH_TO_16BIT; } - if (g_Config.bStereoRendering) { + if (g_Config.bStereoRendering && draw_->GetDeviceCaps().multiViewSupported) { features |= GPU_USE_SINGLE_PASS_STEREO; + features |= GPU_USE_SIMPLE_STEREO_PERSPECTIVE; + features &= ~GPU_USE_FRAMEBUFFER_FETCH; // Need to figure out if this can be supported with multiview rendering if (features & GPU_USE_GS_CULLING) { // Many devices that support stereo and GS don't support GS during stereo. - // So we revert back to VS range culling. features &= ~GPU_USE_GS_CULLING; features |= GPU_USE_VS_RANGE_CULLING; } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1d1d9c0125..822f566221 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -350,12 +350,17 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new ItemHeader(gr->T("Postprocessing effect"))); - if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN) { - graphicsSettings->Add(new CheckBox(&g_Config.bStereoRendering, gr->T("Stereo rendering"))); + enableStereo_ = g_Config.bStereoRendering && draw->GetDeviceCaps().multiViewSupported; + + if (draw->GetDeviceCaps().multiViewSupported) { + graphicsSettings->Add(new CheckBox(&g_Config.bStereoRendering, gr->T("Stereo rendering")))->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { + enableStereo_ = g_Config.bStereoRendering && draw->GetDeviceCaps().multiViewSupported; + return UI::EVENT_DONE; + }); std::vector stereoShaderNames; ChoiceWithValueDisplay *stereoShaderChoice = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sStereoToMonoShader, "Stereo display shader", &PostShaderTranslateName)); - stereoShaderChoice->SetEnabledPtr(&g_Config.bStereoRendering); + stereoShaderChoice->SetEnabledPtr(&enableStereo_); stereoShaderChoice->OnClick.Add([=](EventParams &e) { auto gr = GetI18NCategory("Graphics"); auto procScreen = new PostProcScreen(gr->T("Stereo display shader"), 0, true); @@ -371,8 +376,8 @@ void GameSettingsScreen::CreateViews() { if (!setting.name.empty()) { auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)]; PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); - settingValue->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && g_Config.bStereoRendering; + settingValue->SetEnabledFunc([&] { + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && enableStereo_; }); } } @@ -393,8 +398,8 @@ void GameSettingsScreen::CreateViews() { screenManager()->push(procScreen); return UI::EVENT_DONE; }); - postProcChoice_->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !g_Config.bStereoRendering; + postProcChoice_->SetEnabledFunc([&] { + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo_; }); // No need for settings on the last one. @@ -416,8 +421,8 @@ void GameSettingsScreen::CreateViews() { settingValue->SetEnabled(false); } else { PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); - settingValue->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !g_Config.bStereoRendering; + settingValue->SetEnabledFunc([&] { + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo_; }); } } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 82b4cd859e..9a9456cf4f 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -142,6 +142,8 @@ private: bool enableReports_ = false; bool enableReportsSet_ = false; bool analogSpeedMapped_ = false; + bool enableStereo_ = false; + std::string shaderNames_[256]; std::string searchFilter_; From e0bbebc65e8ca7c7c07bf3fb150aa3ad5747fcf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 18:39:43 +0200 Subject: [PATCH 269/374] Clean up GPU_Vulkan::BuildReportingInfo a bit --- GPU/Vulkan/GPU_Vulkan.cpp | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index d7ac28d3c6..12d0328f98 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -340,14 +340,11 @@ void GPU_Vulkan::BuildReportingInfo() { const auto &available = vulkan->GetDeviceFeatures().available; #define CHECK_BOOL_FEATURE(n) do { if (available.standard.n) { featureNames += ", " #n; } } while (false) +#define CHECK_BOOL_FEATURE_MULTIVIEW(n) do { if (available.multiview.n) { featureNames += ", " #n; } } while (false) std::string featureNames = ""; - CHECK_BOOL_FEATURE(robustBufferAccess); CHECK_BOOL_FEATURE(fullDrawIndexUint32); - CHECK_BOOL_FEATURE(imageCubeArray); - CHECK_BOOL_FEATURE(independentBlend); CHECK_BOOL_FEATURE(geometryShader); - CHECK_BOOL_FEATURE(tessellationShader); CHECK_BOOL_FEATURE(sampleRateShading); CHECK_BOOL_FEATURE(dualSrcBlend); CHECK_BOOL_FEATURE(logicOp); @@ -355,46 +352,23 @@ void GPU_Vulkan::BuildReportingInfo() { CHECK_BOOL_FEATURE(drawIndirectFirstInstance); CHECK_BOOL_FEATURE(depthClamp); CHECK_BOOL_FEATURE(depthBiasClamp); - CHECK_BOOL_FEATURE(fillModeNonSolid); CHECK_BOOL_FEATURE(depthBounds); - CHECK_BOOL_FEATURE(alphaToOne); - CHECK_BOOL_FEATURE(multiViewport); CHECK_BOOL_FEATURE(samplerAnisotropy); CHECK_BOOL_FEATURE(textureCompressionETC2); CHECK_BOOL_FEATURE(textureCompressionASTC_LDR); CHECK_BOOL_FEATURE(textureCompressionBC); CHECK_BOOL_FEATURE(occlusionQueryPrecise); CHECK_BOOL_FEATURE(pipelineStatisticsQuery); - CHECK_BOOL_FEATURE(vertexPipelineStoresAndAtomics); CHECK_BOOL_FEATURE(fragmentStoresAndAtomics); CHECK_BOOL_FEATURE(shaderTessellationAndGeometryPointSize); - CHECK_BOOL_FEATURE(shaderImageGatherExtended); - CHECK_BOOL_FEATURE(shaderStorageImageExtendedFormats); CHECK_BOOL_FEATURE(shaderStorageImageMultisample); - CHECK_BOOL_FEATURE(shaderStorageImageReadWithoutFormat); - CHECK_BOOL_FEATURE(shaderStorageImageWriteWithoutFormat); - CHECK_BOOL_FEATURE(shaderUniformBufferArrayDynamicIndexing); CHECK_BOOL_FEATURE(shaderSampledImageArrayDynamicIndexing); - CHECK_BOOL_FEATURE(shaderStorageBufferArrayDynamicIndexing); - CHECK_BOOL_FEATURE(shaderStorageImageArrayDynamicIndexing); CHECK_BOOL_FEATURE(shaderClipDistance); CHECK_BOOL_FEATURE(shaderCullDistance); - CHECK_BOOL_FEATURE(shaderFloat64); CHECK_BOOL_FEATURE(shaderInt64); CHECK_BOOL_FEATURE(shaderInt16); - CHECK_BOOL_FEATURE(shaderResourceResidency); - CHECK_BOOL_FEATURE(shaderResourceMinLod); - CHECK_BOOL_FEATURE(sparseBinding); - CHECK_BOOL_FEATURE(sparseResidencyBuffer); - CHECK_BOOL_FEATURE(sparseResidencyImage2D); - CHECK_BOOL_FEATURE(sparseResidencyImage3D); - CHECK_BOOL_FEATURE(sparseResidency2Samples); - CHECK_BOOL_FEATURE(sparseResidency4Samples); - CHECK_BOOL_FEATURE(sparseResidency8Samples); - CHECK_BOOL_FEATURE(sparseResidency16Samples); - CHECK_BOOL_FEATURE(sparseResidencyAliased); - CHECK_BOOL_FEATURE(variableMultisampleRate); - CHECK_BOOL_FEATURE(inheritedQueries); + CHECK_BOOL_FEATURE_MULTIVIEW(multiview); + CHECK_BOOL_FEATURE_MULTIVIEW(multiviewGeometryShader); #undef CHECK_BOOL_FEATURE From 6d9008dab572fc63a4360a32f8c472612b2a6247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 20:26:30 +0200 Subject: [PATCH 270/374] Fix validation issue with clears, remove redundant code --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 6 +----- Common/GPU/Vulkan/VulkanQueueRunner.h | 6 ------ Common/GPU/Vulkan/VulkanRenderManager.cpp | 1 - Common/GPU/Vulkan/VulkanRenderManager.h | 9 --------- GPU/Common/VertexShaderGenerator.cpp | 2 +- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index ead24a47fe..1e31ca8525 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1583,17 +1583,13 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c vkCmdDraw(cmd, c.draw.count, 1, c.draw.offset, 0); break; - case VKRRenderCommand::BIND_DESCRIPTOR_SET: - vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, c.bindDescSet.setIndex, 1, &c.bindDescSet.descSet, 0, nullptr); - break; - case VKRRenderCommand::CLEAR: { // If we get here, we failed to merge a clear into a render pass load op. This is bad for perf. int numAttachments = 0; VkClearRect rc{}; rc.baseArrayLayer = 0; - rc.layerCount = c.clear.numLayers; + rc.layerCount = 1; // In multiview mode, 1 means to replicate to all the active layers. rc.rect.extent.width = (uint32_t)curWidth; rc.rect.extent.height = (uint32_t)curHeight; VkClearAttachment attachments[2]{}; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index ffac3003fa..effc3645bc 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -37,7 +37,6 @@ enum class VKRRenderCommand : uint8_t { DRAW, DRAW_INDEXED, PUSH_CONSTANTS, - BIND_DESCRIPTOR_SET, SELF_DEPENDENCY_BARRIER, DEBUG_ANNOTATION, NUM_RENDER_COMMANDS, @@ -129,7 +128,6 @@ struct VkRenderData { float clearZ; int clearStencil; int clearMask; // VK_IMAGE_ASPECT_COLOR_BIT etc - int numLayers; } clear; struct { VkViewport vp; @@ -154,10 +152,6 @@ struct VkRenderData { struct { const char *annotation; } debugAnnotation; - struct { - uint32_t setIndex; - VkDescriptorSet descSet; - } bindDescSet; }; }; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index a83ff65539..314e1920c3 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -833,7 +833,6 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR data.clear.clearZ = clearDepth; data.clear.clearStencil = clearStencil; data.clear.clearMask = clearMask; - data.clear.numLayers = curRenderStep_->render.framebuffer ? curRenderStep_->render.framebuffer->numLayers : 1; curRenderStep_->commands.push_back(data); curRenderArea_.SetRect(0, 0, curWidth_, curHeight_); } diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index cd1e843454..afe8ac15fe 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -270,15 +270,6 @@ public: compileMutex_.unlock(); } - // We always pass in desc set 0 directly in draw commands. This is used only to bind higher descriptor sets. - void BindDescriptorSet(int index, const VkDescriptorSet descSet) { - _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); - VkRenderData data{ VKRRenderCommand::BIND_DESCRIPTOR_SET }; - data.bindDescSet.setIndex = index; - data.bindDescSet.descSet = descSet; - curRenderStep_->commands.push_back(data); - } - void BindPipeline(VKRGraphicsPipeline *pipeline, PipelineFlags flags, VkPipelineLayout pipelineLayout) { _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); _dbg_assert_(pipeline != nullptr); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 9e6ab317b0..cbf51f1b24 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -1351,7 +1351,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " }\n"); } - if (useSimpleStereo) { + if (useSimpleStereo && useHWTransform) { p.C(" float zFactor = 0.2 * float(gl_ViewIndex * 2 - 1);\n"); p.C(" float zFocus = 0.0;\n"); p.C(" gl_Position.x += (-gl_Position.z - zFocus) * zFactor;\n"); From 1da6d29a0f704abfc45902af55d339b32d1b58a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 20:39:53 +0200 Subject: [PATCH 271/374] Crashfix in settings menu (Android only, for whatever reason) --- UI/GameSettingsScreen.cpp | 19 ++++++++++--------- UI/GameSettingsScreen.h | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 822f566221..95bd12d276 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -350,17 +350,18 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new ItemHeader(gr->T("Postprocessing effect"))); - enableStereo_ = g_Config.bStereoRendering && draw->GetDeviceCaps().multiViewSupported; + bool multiViewSupported = draw->GetDeviceCaps().multiViewSupported; + + auto enableStereo = [=]() -> bool { + return g_Config.bStereoRendering && multiViewSupported; + }; if (draw->GetDeviceCaps().multiViewSupported) { - graphicsSettings->Add(new CheckBox(&g_Config.bStereoRendering, gr->T("Stereo rendering")))->OnClick.Add([&](UI::EventParams &) -> UI::EventReturn { - enableStereo_ = g_Config.bStereoRendering && draw->GetDeviceCaps().multiViewSupported; - return UI::EVENT_DONE; - }); + graphicsSettings->Add(new CheckBox(&g_Config.bStereoRendering, gr->T("Stereo rendering"))); std::vector stereoShaderNames; ChoiceWithValueDisplay *stereoShaderChoice = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sStereoToMonoShader, "Stereo display shader", &PostShaderTranslateName)); - stereoShaderChoice->SetEnabledPtr(&enableStereo_); + stereoShaderChoice->SetEnabledFunc(enableStereo); stereoShaderChoice->OnClick.Add([=](EventParams &e) { auto gr = GetI18NCategory("Graphics"); auto procScreen = new PostProcScreen(gr->T("Stereo display shader"), 0, true); @@ -377,7 +378,7 @@ void GameSettingsScreen::CreateViews() { auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)]; PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); settingValue->SetEnabledFunc([&] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && enableStereo_; + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && enableStereo(); }); } } @@ -399,7 +400,7 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_DONE; }); postProcChoice_->SetEnabledFunc([&] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo_; + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo(); }); // No need for settings on the last one. @@ -422,7 +423,7 @@ void GameSettingsScreen::CreateViews() { } else { PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); settingValue->SetEnabledFunc([&] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo_; + return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo(); }); } } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 9a9456cf4f..2fd7d6e59d 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -142,7 +142,6 @@ private: bool enableReports_ = false; bool enableReportsSet_ = false; bool analogSpeedMapped_ = false; - bool enableStereo_ = false; std::string shaderNames_[256]; std::string searchFilter_; From e058f8aee61d6e1963a8a2e046cd3e713c25ff9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 23:48:45 +0200 Subject: [PATCH 272/374] Shadergen fix for OpenGL --- GPU/Common/FragmentShaderGenerator.cpp | 5 +++++ GPU/Common/ShaderId.cpp | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 879552e253..7f09f7c390 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -113,6 +113,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu *errorString = "Invalid combination of 3D texture and array texture, shouldn't happen"; return false; } + if (compat.shaderLanguage != ShaderLanguage::GLSL_VULKAN && arrayTexture) { + *errorString = "We only do array textures for framebuffers in Vulkan."; + return false; + } bool flatBug = bugs.Has(Draw::Bugs::BROKEN_FLAT_IN_SHADER) && g_Config.bVendorBugChecksEnabled; @@ -660,6 +664,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, " vec4 t = %s(tex, vec3(%s.xy, u_mipBias));\n", compat.texture3D, texcoord); } } else if (arrayTexture) { + _dbg_assert_(compat.shaderLanguage == GLSL_VULKAN); // Used for stereo rendering. const char *arrayIndex = useStereo ? "float(gl_ViewIndex)" : "0.0"; if (doTextureProjection) { diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index 9110ca7443..aee52476cf 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -368,8 +368,8 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip id.SetBit(FS_BIT_FLATSHADE, doFlatShading); id.SetBit(FS_BIT_COLOR_WRITEMASK, colorWriteMask); - // All framebuffers are array textures now. - if (gstate_c.arrayTexture) { + // All framebuffers are array textures in Vulkan now. + if (gstate_c.arrayTexture && g_Config.iGPUBackend == (int)GPUBackend::VULKAN) { id.SetBit(FS_BIT_SAMPLE_ARRAY_TEXTURE); } From 85e7933e7a4ba806c4349fe86d434cbd194f976d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 27 Oct 2022 11:05:38 +0200 Subject: [PATCH 273/374] Format string fix --- GPU/Common/PostShader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/PostShader.cpp b/GPU/Common/PostShader.cpp index 43db9093ac..6b0b94387a 100644 --- a/GPU/Common/PostShader.cpp +++ b/GPU/Common/PostShader.cpp @@ -225,7 +225,7 @@ void LoadPostShaderInfo(Draw::DrawContext *draw, const std::vector &direct appendTextureShader(info); } } else if (!section.name().empty()) { - WARN_LOG(G3D, "Unrecognized shader type '%s' or invalid shader in section '%s' : %d", shaderType.c_str(), section.name().c_str()); + WARN_LOG(G3D, "Unrecognized shader type '%s' or invalid shader in section '%s'", shaderType.c_str(), section.name().c_str()); } } } From 3454ea9c1dfcac6c668cdebc3349e54fed77a04b Mon Sep 17 00:00:00 2001 From: iota97 Date: Thu, 27 Oct 2022 14:57:19 +0200 Subject: [PATCH 274/374] Fix UB --- UI/GameSettingsScreen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 95bd12d276..706eb07cfe 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -377,7 +377,7 @@ void GameSettingsScreen::CreateViews() { if (!setting.name.empty()) { auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)]; PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); - settingValue->SetEnabledFunc([&] { + settingValue->SetEnabledFunc([=] { return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && enableStereo(); }); } @@ -399,7 +399,7 @@ void GameSettingsScreen::CreateViews() { screenManager()->push(procScreen); return UI::EVENT_DONE; }); - postProcChoice_->SetEnabledFunc([&] { + postProcChoice_->SetEnabledFunc([=] { return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo(); }); @@ -422,7 +422,7 @@ void GameSettingsScreen::CreateViews() { settingValue->SetEnabled(false); } else { PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); - settingValue->SetEnabledFunc([&] { + settingValue->SetEnabledFunc([=] { return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo(); }); } From 906f8b5d8bcb857b5dfa5cbc02e979de3c105a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E7=9F=A5=E8=83=BD?= <42119227+Kaitul@users.noreply.github.com> Date: Thu, 27 Oct 2022 23:47:53 +0800 Subject: [PATCH 275/374] Update zh_TW.ini --- assets/lang/zh_TW.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 4a7b474d9c..b99a218f01 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -819,7 +819,7 @@ InverseColors = 反轉色彩 Natural = 自然色彩 NaturalA = 自然色彩 (無模糊) Off = 關閉 -Power = Power +Power = 強度 PSPColor = PSP 色彩 Saturation = 飽和度 Scanlines = 掃描線 (CRT) From 28229e28867a690470f795b9170eb00eb4c1c305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=BA=E5=B7=A5=E7=9F=A5=E8=83=BD?= <42119227+Kaitul@users.noreply.github.com> Date: Thu, 27 Oct 2022 23:54:37 +0800 Subject: [PATCH 276/374] Update zh_TW.ini --- assets/lang/zh_TW.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index b99a218f01..e94959fd9e 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -278,7 +278,7 @@ VFPU = VFPU [Dialog] * PSP res = * PSP 解析度 -Active = Active +Active = 啟用 Back = 返回 Cancel = 取消 Center = 中心 From b9de1a44df3eb4586a24f825f35c5085fa3db640 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 27 Oct 2022 23:26:44 -0700 Subject: [PATCH 277/374] jit: Reduce some include pollution. Usually no need for all of MIPSAnalyst. --- Core/MIPS/ARM/ArmCompALU.cpp | 1 + Core/MIPS/ARM/ArmJit.cpp | 1 + Core/MIPS/ARM/ArmRegCache.h | 7 +++++-- Core/MIPS/ARM/ArmRegCacheFPU.h | 7 +++++-- Core/MIPS/ARM64/Arm64CompALU.cpp | 1 + Core/MIPS/ARM64/Arm64Jit.cpp | 1 + Core/MIPS/ARM64/Arm64RegCache.h | 5 ++++- Core/MIPS/ARM64/Arm64RegCacheFPU.h | 7 +++++-- Core/MIPS/JitCommon/JitBlockCache.h | 1 - Core/MIPS/x86/CompALU.cpp | 1 + Core/MIPS/x86/Jit.cpp | 1 + Core/MIPS/x86/JitSafeMem.cpp | 1 + Core/MIPS/x86/RegCache.h | 5 ++++- Core/MIPS/x86/RegCacheFPU.h | 5 ++++- unittest/TestArmEmitter.cpp | 1 + 15 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Core/MIPS/ARM/ArmCompALU.cpp b/Core/MIPS/ARM/ArmCompALU.cpp index 0b5bf067f8..01bf94203e 100644 --- a/Core/MIPS/ARM/ArmCompALU.cpp +++ b/Core/MIPS/ARM/ArmCompALU.cpp @@ -24,6 +24,7 @@ #include "Common/CPUDetect.h" #include "Common/Data/Convert/SmallDataConvert.h" #include "Core/MIPS/MIPS.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/ARM/ArmJit.h" #include "Core/MIPS/ARM/ArmRegCache.h" diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index 74675a6ae4..3048773bb6 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -33,6 +33,7 @@ #include "Core/MemMap.h" #include "Core/MIPS/MIPS.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/MIPSInt.h" #include "Core/MIPS/MIPSTables.h" diff --git a/Core/MIPS/ARM/ArmRegCache.h b/Core/MIPS/ARM/ArmRegCache.h index bd85cc10b2..0a405a7158 100644 --- a/Core/MIPS/ARM/ArmRegCache.h +++ b/Core/MIPS/ARM/ArmRegCache.h @@ -17,8 +17,7 @@ #pragma once -#include "../MIPS.h" -#include "../MIPSAnalyst.h" +#include "Core/MIPS/MIPS.h" #include "ArmEmitter.h" namespace ArmJitConstants { @@ -52,6 +51,10 @@ enum { } +namespace MIPSAnalyst { +struct AnalysisResults; +}; + // R1 to R6: mapped MIPS regs // R8 = flags (maybe we could do better here?) // R9 = code pointers diff --git a/Core/MIPS/ARM/ArmRegCacheFPU.h b/Core/MIPS/ARM/ArmRegCacheFPU.h index 3e08d719bb..f572c84a97 100644 --- a/Core/MIPS/ARM/ArmRegCacheFPU.h +++ b/Core/MIPS/ARM/ArmRegCacheFPU.h @@ -19,8 +19,7 @@ #pragma once -#include "../MIPS.h" -#include "../MIPSAnalyst.h" +#include "Core/MIPS/MIPS.h" #include "Core/MIPS/ARM/ArmRegCache.h" #include "Core/MIPS/MIPSVFPUUtils.h" #include "Common/ArmEmitter.h" @@ -46,6 +45,10 @@ enum { } +namespace MIPSAnalyst { +struct AnalysisResults; +}; + struct FPURegARM { int mipsReg; // if -1, no mipsreg attached. bool isDirty; // Should the register be written back? diff --git a/Core/MIPS/ARM64/Arm64CompALU.cpp b/Core/MIPS/ARM64/Arm64CompALU.cpp index afb8d2b4a8..13a2361d86 100644 --- a/Core/MIPS/ARM64/Arm64CompALU.cpp +++ b/Core/MIPS/ARM64/Arm64CompALU.cpp @@ -24,6 +24,7 @@ #include "Common/CPUDetect.h" #include "Common/Data/Convert/SmallDataConvert.h" #include "Core/MIPS/MIPS.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/ARM64/Arm64Jit.h" #include "Core/MIPS/ARM64/Arm64RegCache.h" diff --git a/Core/MIPS/ARM64/Arm64Jit.cpp b/Core/MIPS/ARM64/Arm64Jit.cpp index b111784c1a..f9d7e2d684 100644 --- a/Core/MIPS/ARM64/Arm64Jit.cpp +++ b/Core/MIPS/ARM64/Arm64Jit.cpp @@ -34,6 +34,7 @@ #include "Core/MemMap.h" #include "Core/MIPS/MIPS.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/MIPSInt.h" #include "Core/MIPS/MIPSTables.h" diff --git a/Core/MIPS/ARM64/Arm64RegCache.h b/Core/MIPS/ARM64/Arm64RegCache.h index 62f7771192..5528120098 100644 --- a/Core/MIPS/ARM64/Arm64RegCache.h +++ b/Core/MIPS/ARM64/Arm64RegCache.h @@ -18,7 +18,6 @@ #pragma once #include "Core/MIPS/MIPS.h" -#include "Core/MIPS/MIPSAnalyst.h" #include "Common/Arm64Emitter.h" namespace Arm64JitConstants { @@ -55,6 +54,10 @@ enum { } // namespace +namespace MIPSAnalyst { +struct AnalysisResults; +}; + typedef int MIPSReg; struct RegARM64 { diff --git a/Core/MIPS/ARM64/Arm64RegCacheFPU.h b/Core/MIPS/ARM64/Arm64RegCacheFPU.h index 13284d2389..657d218611 100644 --- a/Core/MIPS/ARM64/Arm64RegCacheFPU.h +++ b/Core/MIPS/ARM64/Arm64RegCacheFPU.h @@ -19,8 +19,7 @@ #pragma once -#include "../MIPS.h" -#include "../MIPSAnalyst.h" +#include "Core/MIPS/MIPS.h" #include "Core/MIPS/ARM64/Arm64RegCache.h" #include "Core/MIPS/MIPSVFPUUtils.h" #include "Common/Arm64Emitter.h" @@ -46,6 +45,10 @@ enum { } +namespace MIPSAnalyst { +struct AnalysisResults; +}; + struct FPURegARM64 { int mipsReg; // if -1, no mipsreg attached. bool isDirty; // Should the register be written back? diff --git a/Core/MIPS/JitCommon/JitBlockCache.h b/Core/MIPS/JitCommon/JitBlockCache.h index 28a432fafe..f8836160ea 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.h +++ b/Core/MIPS/JitCommon/JitBlockCache.h @@ -26,7 +26,6 @@ #include "ppsspp_config.h" #include "Common/CommonTypes.h" #include "Common/CodeBlock.h" -#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPS.h" #if PPSSPP_ARCH(ARM) || PPSSPP_ARCH(ARM64) diff --git a/Core/MIPS/x86/CompALU.cpp b/Core/MIPS/x86/CompALU.cpp index e3534b39fe..c8319efcb0 100644 --- a/Core/MIPS/x86/CompALU.cpp +++ b/Core/MIPS/x86/CompALU.cpp @@ -23,6 +23,7 @@ #include "Common/BitSet.h" #include "Common/CommonTypes.h" #include "Common/CPUDetect.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/x86/Jit.h" #include "Core/MIPS/x86/RegCache.h" diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index c27ee3b502..266b97da00 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -34,6 +34,7 @@ #include "Core/Reporting.h" #include "Core/Debugger/SymbolMap.h" #include "Core/MIPS/MIPS.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSCodeUtils.h" #include "Core/MIPS/MIPSInt.h" #include "Core/MIPS/MIPSTables.h" diff --git a/Core/MIPS/x86/JitSafeMem.cpp b/Core/MIPS/x86/JitSafeMem.cpp index 38c6c75554..0fedb39882 100644 --- a/Core/MIPS/x86/JitSafeMem.cpp +++ b/Core/MIPS/x86/JitSafeMem.cpp @@ -23,6 +23,7 @@ #include "Core/Debugger/Breakpoints.h" #include "Core/MemMap.h" #include "Core/MIPS/JitCommon/JitCommon.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/x86/Jit.h" #include "Core/MIPS/x86/JitSafeMem.h" #include "Core/System.h" diff --git a/Core/MIPS/x86/RegCache.h b/Core/MIPS/x86/RegCache.h index 218677485d..f852401f8d 100644 --- a/Core/MIPS/x86/RegCache.h +++ b/Core/MIPS/x86/RegCache.h @@ -20,7 +20,6 @@ #include "ppsspp_config.h" #include "Common/x64Emitter.h" #include "Core/MIPS/MIPS.h" -#include "Core/MIPS/MIPSAnalyst.h" namespace X64JitConstants { #if PPSSPP_ARCH(AMD64) @@ -42,6 +41,10 @@ namespace X64JitConstants { #endif } +namespace MIPSAnalyst { +struct AnalysisResults; +}; + struct MIPSCachedReg { Gen::OpArg location; bool away; // value not in source register diff --git a/Core/MIPS/x86/RegCacheFPU.h b/Core/MIPS/x86/RegCacheFPU.h index 04faf64cdd..0e63de5a68 100644 --- a/Core/MIPS/x86/RegCacheFPU.h +++ b/Core/MIPS/x86/RegCacheFPU.h @@ -19,7 +19,6 @@ #include "Common/x64Emitter.h" #include "Core/MIPS/MIPS.h" -#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSVFPUUtils.h" #undef MAP_NOINIT @@ -56,6 +55,10 @@ enum { #define NUM_X_FPREGS 8 #endif +namespace MIPSAnalyst { +struct AnalysisResults; +}; + struct X64CachedFPReg { union { int mipsReg; diff --git a/unittest/TestArmEmitter.cpp b/unittest/TestArmEmitter.cpp index 94acdbdb1f..8932ba7c9c 100644 --- a/unittest/TestArmEmitter.cpp +++ b/unittest/TestArmEmitter.cpp @@ -2,6 +2,7 @@ #include "Core/MIPS/ARM/ArmRegCacheFPU.h" #include "Core/MIPS/ARM/ArmJit.h" #include "Core/MIPS/JitCommon/JitState.h" +#include "Core/MIPS/MIPSAnalyst.h" #include "Core/MIPS/MIPSVFPUUtils.h" #include "ext/disarm.h" From 96a5c520373d53febf3825395abdfb37905a51a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 09:23:44 +0200 Subject: [PATCH 278/374] Vulkan: Reserve descriptor set 0 for frame-global data, move everything else to set 1 --- Common/GPU/ShaderTranslation.cpp | 8 ++--- Common/GPU/ShaderWriter.cpp | 6 ++-- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 8 +++-- Common/GPU/Vulkan/VulkanQueueRunner.h | 6 ++++ Common/GPU/Vulkan/VulkanRenderManager.h | 10 ++++++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 44 ++++++++++++++++++++----- Common/GPU/thin3d.cpp | 8 ++--- Common/GPU/thin3d.h | 2 ++ GPU/Common/FragmentShaderGenerator.cpp | 10 +++--- GPU/Common/VertexShaderGenerator.cpp | 12 +++---- GPU/Vulkan/DrawEngineVulkan.cpp | 4 ++- GPU/Vulkan/DrawEngineVulkan.h | 3 +- GPU/Vulkan/TextureCacheVulkan.cpp | 8 ++--- GPU/Vulkan/VulkanUtil.cpp | 14 ++++---- GPU/Vulkan/VulkanUtil.h | 9 ++--- UI/GPUDriverTestScreen.cpp | 10 +++--- 16 files changed, 108 insertions(+), 54 deletions(-) diff --git a/Common/GPU/ShaderTranslation.cpp b/Common/GPU/ShaderTranslation.cpp index 9391d1b7da..732ef68633 100644 --- a/Common/GPU/ShaderTranslation.cpp +++ b/Common/GPU/ShaderTranslation.cpp @@ -98,7 +98,7 @@ R"(#version 450 )"; static const char *vulkanUboDecl = R"( -layout (std140, set = 0, binding = 0) uniform Data { +layout (std140, set = 1, binding = 0) uniform Data { vec2 u_texelDelta; vec2 u_pixelDelta; vec4 u_time; @@ -187,11 +187,11 @@ bool ConvertToVulkanGLSL(std::string *dest, TranslatedShaderMetadata *destMetada continue; } else if (line.find("uniform sampler2D") == 0) { if (sscanf(line.c_str(), "uniform sampler2D sampler%d", &num) == 1) - line = StringFromFormat("layout(set = 0, binding = %d) ", num + 1) + line; + line = StringFromFormat("layout(set = 1, binding = %d) ", num + 1) + line; else if (line.find("sampler0") != line.npos) - line = "layout(set = 0, binding = 1) " + line; + line = "layout(set = 1, binding = 1) " + line; else - line = "layout(set = 0, binding = 2) " + line; + line = "layout(set = 1, binding = 2) " + line; } else if (line.find("uniform ") != std::string::npos) { continue; } else if (2 == sscanf(line.c_str(), "varying vec%d v_texcoord%d;", &vecSize, &num)) { diff --git a/Common/GPU/ShaderWriter.cpp b/Common/GPU/ShaderWriter.cpp index ed7a3612f9..01132b11de 100644 --- a/Common/GPU/ShaderWriter.cpp +++ b/Common/GPU/ShaderWriter.cpp @@ -326,7 +326,7 @@ void ShaderWriter::BeginFSMain(Slice uniforms, Slice var } C("layout(location = 0, index = 0) out vec4 fragColor0;\n"); if (!uniforms.is_empty()) { - C("layout(std140, set = 0, binding = 0) uniform bufferVals {\n"); + C("layout(std140, set = 1, binding = 0) uniform bufferVals {\n"); for (auto &uniform : uniforms) { F("%s %s;\n", uniform.type, uniform.name); } @@ -480,9 +480,9 @@ void ShaderWriter::DeclareTexture2D(const SamplerDef &def) { case GLSL_VULKAN: // texBindingBase_ is used for the thin3d descriptor set layout, where they start at 1. if (def.flags & SamplerFlags::ARRAY_ON_VULKAN) { - F("layout(set = 0, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name); + F("layout(set = 1, binding = %d) uniform sampler2DArray %s;\n", def.binding + texBindingBase_, def.name); } else { - F("layout(set = 0, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name); + F("layout(set = 1, binding = %d) uniform sampler2D %s;\n", def.binding + texBindingBase_, def.name); } break; default: diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 1e31ca8525..47e5b94046 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1567,7 +1567,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c case VKRRenderCommand::DRAW_INDEXED: { - vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &c.drawIndexed.ds, c.drawIndexed.numUboOffsets, c.drawIndexed.uboOffsets); + vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &c.drawIndexed.ds, c.drawIndexed.numUboOffsets, c.drawIndexed.uboOffsets); vkCmdBindIndexBuffer(cmd, c.drawIndexed.ibuffer, c.drawIndexed.ioffset, (VkIndexType)c.drawIndexed.indexType); VkDeviceSize voffset = c.drawIndexed.voffset; vkCmdBindVertexBuffers(cmd, 0, 1, &c.drawIndexed.vbuffer, &voffset); @@ -1576,7 +1576,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c } case VKRRenderCommand::DRAW: - vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &c.draw.ds, c.draw.numUboOffsets, c.draw.uboOffsets); + vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &c.draw.ds, c.draw.numUboOffsets, c.draw.uboOffsets); if (c.draw.vbuffer) { vkCmdBindVertexBuffers(cmd, 0, 1, &c.draw.vbuffer, &c.draw.voffset); } @@ -1625,6 +1625,10 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c } break; + case VKRRenderCommand::BIND_DESCRIPTOR_SET: + vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, c.bindDescSet.pipelineLayout, c.bindDescSet.setNumber, 1, &c.bindDescSet.set, 0, nullptr); + break; + default: ERROR_LOG(G3D, "Unimpl queue command"); break; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index effc3645bc..2466e576f7 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -39,6 +39,7 @@ enum class VKRRenderCommand : uint8_t { PUSH_CONSTANTS, SELF_DEPENDENCY_BARRIER, DEBUG_ANNOTATION, + BIND_DESCRIPTOR_SET, NUM_RENDER_COMMANDS, }; @@ -152,6 +153,11 @@ struct VkRenderData { struct { const char *annotation; } debugAnnotation; + struct { + int setNumber; + VkDescriptorSet set; + VkPipelineLayout pipelineLayout; + } bindDescSet; }; }; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index afe8ac15fe..26e1eb5220 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -270,6 +270,16 @@ public: compileMutex_.unlock(); } + // Mainly used to bind the frame-global desc set. + // Can be done before binding a pipeline, so not asserting on that. + void BindDescriptorSet(int setNumber, VkDescriptorSet set, VkPipelineLayout pipelineLayout) { + _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); + VkRenderData data{ VKRRenderCommand::BIND_DESCRIPTOR_SET }; + data.bindDescSet.setNumber = setNumber; + data.bindDescSet.set = set; + curRenderStep_->commands.push_back(data); + } + void BindPipeline(VKRGraphicsPipeline *pipeline, PipelineFlags flags, VkPipelineLayout pipelineLayout) { _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); _dbg_assert_(pipeline != nullptr); diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index c5dcc65f40..fda775f1d0 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -35,15 +35,22 @@ #include "Core/Config.h" -// We use a simple descriptor set for all rendering: 1 sampler, 1 texture, 1 UBO binding point. -// binding 0 - uniform data -// binding 1 - sampler -// binding 2 - sampler -// -// Vertex data lives in a separate namespace (location = 0, 1, etc) - #include "Common/GPU/Vulkan/VulkanLoader.h" +// We support a frame-global descriptor set, which can be optionally used by other code, +// but is not directly used by thin3d. It has to be defined here though, be in set 0 +// and specified in every pipeline layout, otherwise it can't sit undisturbed when other +// descriptor sets are bound on top. + +// For descriptor set 1, we use a simple descriptor set for all thin3d rendering: 1 UBO binding point, 3 combined texture/samples. +// +// binding 0 - uniform buffer +// binding 1 - texture/sampler +// binding 2 - texture/sampler +// binding 3 - texture/sampler +// +// Vertex data lives in a separate namespace (location = 0, 1, etc). + using namespace PPSSPP_VK; namespace Draw { @@ -514,6 +521,7 @@ private: int curIBufferOffset_ = 0; VkDescriptorSetLayout descriptorSetLayout_ = VK_NULL_HANDLE; + VkDescriptorSetLayout frameDescSetLayout_ = VK_NULL_HANDLE; VkPipelineLayout pipelineLayout_ = VK_NULL_HANDLE; VkPipelineCache pipelineCache_ = VK_NULL_HANDLE; AutoRef curFramebuffer_; @@ -921,13 +929,25 @@ VKContext::VKContext(VulkanContext *vulkan) VkResult res = vkCreateDescriptorSetLayout(device_, &dsl, nullptr, &descriptorSetLayout_); _assert_(VK_SUCCESS == res); + VkDescriptorSetLayoutBinding frameBindings[1]{}; + frameBindings[0].descriptorCount = 1; + frameBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + frameBindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; + frameBindings[0].binding = 0; + + dsl.bindingCount = ARRAY_SIZE(frameBindings); + dsl.pBindings = frameBindings; + res = vkCreateDescriptorSetLayout(device_, &dsl, nullptr, &frameDescSetLayout_); + _dbg_assert_(VK_SUCCESS == res); + vulkan_->SetDebugName(descriptorSetLayout_, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT, "thin3d_d_layout"); VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = nullptr; pl.pushConstantRangeCount = 0; - pl.setLayoutCount = 1; - pl.pSetLayouts = &descriptorSetLayout_; + VkDescriptorSetLayout setLayouts[2] = { frameDescSetLayout_, descriptorSetLayout_ }; + pl.setLayoutCount = ARRAY_SIZE(setLayouts); + pl.pSetLayouts = setLayouts; res = vkCreatePipelineLayout(device_, &pl, nullptr, &pipelineLayout_); _assert_(VK_SUCCESS == res); @@ -947,6 +967,7 @@ VKContext::~VKContext() { delete frame_[i].pushBuffer; } vulkan_->Delete().QueueDeleteDescriptorSetLayout(descriptorSetLayout_); + vulkan_->Delete().QueueDeleteDescriptorSetLayout(frameDescSetLayout_); vulkan_->Delete().QueueDeletePipelineLayout(pipelineLayout_); vulkan_->Delete().QueueDeletePipelineCache(pipelineCache_); } @@ -1681,6 +1702,11 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) { _dbg_assert_(layer < curFramebuffer_->Layers()); return (uint64_t)curFramebuffer_->GetFB()->color.texLayerViews[layer]; } + case NativeObject::FRAME_DATA_DESC_SET_LAYOUT: + return (uint64_t)frameDescSetLayout_; + case NativeObject::THIN3D_PIPELINE_LAYOUT: + return (uint64_t)pipelineLayout_; + default: Crash(); return 0; diff --git a/Common/GPU/thin3d.cpp b/Common/GPU/thin3d.cpp index ac2daa68c7..3aad02abc6 100644 --- a/Common/GPU/thin3d.cpp +++ b/Common/GPU/thin3d.cpp @@ -137,7 +137,7 @@ static const std::vector fsTexCol = { "layout(location = 0) in vec4 oColor0;\n" "layout(location = 1) in vec2 oTexCoord0;\n" "layout(location = 0) out vec4 fragColor0;\n" - "layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n" + "layout(set = 1, binding = 1) uniform sampler2D Sampler0;\n" "void main() { fragColor0 = texture(Sampler0, oTexCoord0) * oColor0; }\n" } }; @@ -181,7 +181,7 @@ static const std::vector fsTexColRBSwizzle = { "layout(location = 0) in vec4 oColor0;\n" "layout(location = 1) in vec2 oTexCoord0;\n" "layout(location = 0) out vec4 fragColor0\n;" - "layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n" + "layout(set = 1, binding = 1) uniform sampler2D Sampler0;\n" "void main() { fragColor0 = texture(Sampler0, oTexCoord0).bgra * oColor0; }\n" } }; @@ -270,7 +270,7 @@ static const std::vector vsCol = { R"(#version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable -layout (std140, set = 0, binding = 0) uniform bufferVals { +layout (std140, set = 1, binding = 0) uniform bufferVals { mat4 WorldViewProj; vec2 TintSaturation; } myBufferVals; @@ -416,7 +416,7 @@ VS_OUTPUT main(VS_INPUT input) { R"(#version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable -layout (std140, set = 0, binding = 0) uniform bufferVals { +layout (std140, set = 1, binding = 0) uniform bufferVals { mat4 WorldViewProj; vec2 TintSaturation; } myBufferVals; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index e617954010..695e1c83c8 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -249,6 +249,8 @@ enum class NativeObject { RENDER_MANAGER, TEXTURE_VIEW, NULL_IMAGEVIEW, + FRAME_DATA_DESC_SET_LAYOUT, + THIN3D_PIPELINE_LAYOUT, }; enum FBChannel { diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 7f09f7c390..1cfd750540 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -185,23 +185,23 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu WRITE(p, "layout (depth_unchanged) out float gl_FragDepth;\n"); } - WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseUBO {\n%s};\n", ub_baseStr); + WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseUBO {\n%s};\n", ub_baseStr); if (doTexture) { - WRITE(p, "layout (binding = 0) uniform %s%s tex;\n", texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "Array" : ""); + WRITE(p, "layout (set = 1, binding = 0) uniform %s%s tex;\n", texture3D ? "sampler3D" : "sampler2D", arrayTexture ? "Array" : ""); } if (readFramebufferTex) { // The framebuffer texture is always bound as an array. - p.C("layout (binding = 1) uniform sampler2DArray fbotex;\n"); + p.C("layout (set = 1, binding = 1) uniform sampler2DArray fbotex;\n"); } else if (fetchFramebuffer) { - p.C("layout (input_attachment_index = 0, binding = 9) uniform subpassInput inputColor;\n"); + p.C("layout (input_attachment_index = 0, set = 1, binding = 9) uniform subpassInput inputColor;\n"); if (fragmentShaderFlags) { *fragmentShaderFlags |= FragmentShaderFlags::INPUT_ATTACHMENT; } } if (shaderDepalMode != ShaderDepalMode::OFF) { - WRITE(p, "layout (binding = 2) uniform sampler2D pal;\n"); + WRITE(p, "layout (set = 1, binding = 2) uniform sampler2D pal;\n"); } // Note: the precision qualifiers must match the vertex shader! diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index cbf51f1b24..6c6cc57ab2 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -249,11 +249,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); - WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); + WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); if (enableLighting || doShadeMapping) - WRITE(p, "layout (std140, set = 0, binding = 4) uniform lightVars {\n%s};\n", ub_vs_lightsStr); + WRITE(p, "layout (std140, set = 1, binding = 4) uniform lightVars {\n%s};\n", ub_vs_lightsStr); if (enableBones) - WRITE(p, "layout (std140, set = 0, binding = 5) uniform boneVars {\n%s};\n", ub_vs_bonesStr); + WRITE(p, "layout (std140, set = 1, binding = 5) uniform boneVars {\n%s};\n", ub_vs_bonesStr); if (enableBones) { WRITE(p, "%s", boneWeightDecl[numBoneWeights]); @@ -631,7 +631,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " vec4 tex;\n"); WRITE(p, " vec4 col;\n"); WRITE(p, "};\n"); - WRITE(p, "layout (std430, set = 0, binding = 6) readonly buffer s_tess_data {\n"); + WRITE(p, "layout (std430, set = 1, binding = 6) readonly buffer s_tess_data {\n"); WRITE(p, " TessData tess_data[];\n"); WRITE(p, "};\n"); @@ -639,10 +639,10 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag WRITE(p, " vec4 basis;\n"); WRITE(p, " vec4 deriv;\n"); WRITE(p, "};\n"); - WRITE(p, "layout (std430, set = 0, binding = 7) readonly buffer s_tess_weights_u {\n"); + WRITE(p, "layout (std430, set = 1, binding = 7) readonly buffer s_tess_weights_u {\n"); WRITE(p, " TessWeight tess_weights_u[];\n"); WRITE(p, "};\n"); - WRITE(p, "layout (std430, set = 0, binding = 8) readonly buffer s_tess_weights_v {\n"); + WRITE(p, "layout (std430, set = 1, binding = 8) readonly buffer s_tess_weights_v {\n"); WRITE(p, " TessWeight tess_weights_v[];\n"); WRITE(p, "};\n"); } else if (ShaderLanguageIsOpenGL(compat.shaderLanguage)) { diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 8af2727736..71d601d805 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -185,10 +185,12 @@ void DrawEngineVulkan::InitDeviceObjects() { VkPipelineLayoutCreateInfo pl{ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = nullptr; pl.pushConstantRangeCount = 0; - VkDescriptorSetLayout layouts[1] = { descriptorSetLayout_ }; + VkDescriptorSetLayout frameDescSetLayout = (VkDescriptorSetLayout)draw_->GetNativeObject(Draw::NativeObject::FRAME_DATA_DESC_SET_LAYOUT); + VkDescriptorSetLayout layouts[2] = { frameDescSetLayout, descriptorSetLayout_}; pl.setLayoutCount = ARRAY_SIZE(layouts); pl.pSetLayouts = layouts; pl.flags = 0; + res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); _dbg_assert_(VK_SUCCESS == res); diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 258f95ae6d..0cf03f275c 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -211,7 +211,8 @@ private: Draw::DrawContext *draw_; - // We use a shared descriptor set layout for all PSP draws. + // We use a shared descriptor set layouts for all PSP draws. + // Descriptors created from descriptorSetLayout_ is rebound all the time at set 1. VkDescriptorSetLayout descriptorSetLayout_; VkPipelineLayout pipelineLayout_; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 8f80aa8474..d536bedabd 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -65,9 +65,9 @@ const char *uploadShader = R"( // hardware vendors. layout (local_size_x = 8, local_size_y = 8, local_size_z = 1) in; -uniform layout(binding = 0, rgba8) writeonly image2D img; +uniform layout(set = 1, binding = 0, rgba8) writeonly image2D img; -layout(std430, binding = 1) buffer Buf { +layout(std430, set = 1, binding = 1) buffer Buf { uint data[]; } buf; @@ -251,7 +251,7 @@ void TextureCacheVulkan::DeviceRestore(Draw::DrawContext *draw) { CompileScalingShader(); - computeShaderManager_.DeviceRestore(vulkan); + computeShaderManager_.DeviceRestore(draw); } void TextureCacheVulkan::NotifyConfigChanged() { @@ -626,7 +626,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) { VK_PROFILE_BEGIN(vulkan, cmdInit, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, "Compute Upload: %dx%d->%dx%d", mipUnscaledWidth, mipUnscaledHeight, mipWidth, mipHeight); vkCmdBindPipeline(cmdInit, VK_PIPELINE_BIND_POINT_COMPUTE, computeShaderManager_.GetPipeline(uploadCS_)); - vkCmdBindDescriptorSets(cmdInit, VK_PIPELINE_BIND_POINT_COMPUTE, computeShaderManager_.GetPipelineLayout(), 0, 1, &descSet, 0, nullptr); + vkCmdBindDescriptorSets(cmdInit, VK_PIPELINE_BIND_POINT_COMPUTE, computeShaderManager_.GetPipelineLayout(), 1, 1, &descSet, 0, nullptr); vkCmdPushConstants(cmdInit, computeShaderManager_.GetPipelineLayout(), VK_SHADER_STAGE_COMPUTE_BIT, 0, sizeof(params), ¶ms); vkCmdDispatch(cmdInit, (mipUnscaledWidth + 7) / 8, (mipUnscaledHeight + 7) / 8, 1); VK_PROFILE_END(vulkan, cmdInit, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT); diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index d23f2ad9b2..27149b2be1 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -56,7 +56,7 @@ VulkanComputeShaderManager::VulkanComputeShaderManager(VulkanContext *vulkan) : } VulkanComputeShaderManager::~VulkanComputeShaderManager() {} -void VulkanComputeShaderManager::InitDeviceObjects() { +void VulkanComputeShaderManager::InitDeviceObjects(Draw::DrawContext *draw) { VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; VkResult res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_); _assert_(VK_SUCCESS == res); @@ -85,14 +85,14 @@ void VulkanComputeShaderManager::InitDeviceObjects() { std::vector dpTypes; dpTypes.resize(2); - dpTypes[0].descriptorCount = 8192; + dpTypes[0].descriptorCount = 4096; dpTypes[0].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; - dpTypes[1].descriptorCount = 4096; + dpTypes[1].descriptorCount = 2048; dpTypes[1].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; dp.flags = 0; // Don't want to mess around with individually freeing these, let's go fixed each frame and zap the whole array. Might try the dynamic approach later. - dp.maxSets = 4096; // GTA can end up creating more than 1000 textures in the first frame! + dp.maxSets = 2048; // GTA can end up creating more than 1000 textures in the first frame! for (int i = 0; i < ARRAY_SIZE(frameData_); i++) { frameData_[i].descPool.Create(vulkan_, dp, dpTypes); @@ -106,8 +106,10 @@ void VulkanComputeShaderManager::InitDeviceObjects() { VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = &push; pl.pushConstantRangeCount = 1; - pl.setLayoutCount = 1; - pl.pSetLayouts = &descriptorSetLayout_; + VkDescriptorSetLayout frameDescSetLayout = (VkDescriptorSetLayout)draw->GetNativeObject(Draw::NativeObject::FRAME_DATA_DESC_SET_LAYOUT); + VkDescriptorSetLayout setLayouts[2] = { frameDescSetLayout, descriptorSetLayout_ }; + pl.setLayoutCount = ARRAY_SIZE(setLayouts); + pl.pSetLayouts = setLayouts; pl.flags = 0; res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); _assert_(VK_SUCCESS == res); diff --git a/GPU/Vulkan/VulkanUtil.h b/GPU/Vulkan/VulkanUtil.h index b31fdb75f9..8663d3ce1e 100644 --- a/GPU/Vulkan/VulkanUtil.h +++ b/GPU/Vulkan/VulkanUtil.h @@ -25,6 +25,7 @@ #include "Common/GPU/Vulkan/VulkanImage.h" #include "Common/GPU/Vulkan/VulkanLoader.h" #include "Common/GPU/Vulkan/VulkanMemory.h" +#include "Common/GPU/thin3d.h" extern const VkComponentMapping VULKAN_4444_SWIZZLE; extern const VkComponentMapping VULKAN_1555_SWIZZLE; @@ -47,9 +48,9 @@ public: void DeviceLost() { DestroyDeviceObjects(); } - void DeviceRestore(VulkanContext *vulkan) { - vulkan_ = vulkan; - InitDeviceObjects(); + void DeviceRestore(Draw::DrawContext *draw) { + vulkan_ = (VulkanContext *)draw->GetNativeObject(Draw::NativeObject::CONTEXT); + InitDeviceObjects(draw); } // Note: This doesn't cache. The descriptor is for immediate use only. @@ -63,7 +64,7 @@ public: void EndFrame(); private: - void InitDeviceObjects(); + void InitDeviceObjects(Draw::DrawContext *draw); void DestroyDeviceObjects(); VulkanContext *vulkan_ = nullptr; diff --git a/UI/GPUDriverTestScreen.cpp b/UI/GPUDriverTestScreen.cpp index 023b9e1def..ab0a11d300 100644 --- a/UI/GPUDriverTestScreen.cpp +++ b/UI/GPUDriverTestScreen.cpp @@ -44,7 +44,7 @@ static const std::vector fsDiscard = { layout(location = 0) in vec4 oColor0; layout(location = 1) in vec2 oTexCoord0; layout(location = 0) out vec4 fragColor0; - layout(set = 0, binding = 1) uniform sampler2D Sampler0; + layout(set = 1, binding = 1) uniform sampler2D Sampler0; void main() { vec4 color = texture(Sampler0, oTexCoord0) * oColor0; if (color.a <= 0.0) @@ -86,7 +86,7 @@ static const std::vector fsAdrenoLogicTest = { layout(location = 0) in vec4 oColor0; layout(location = 1) in highp vec2 oTexCoord0; layout(location = 0) out vec4 fragColor0; - layout(set = 0, binding = 1) uniform sampler2D Sampler0; + layout(set = 1, binding = 1) uniform sampler2D Sampler0; void main() { vec4 v = texture(Sampler0, oTexCoord0).aaaa * oColor0; if (v.r < 0.2 && v.g < 0.2 && v.b < 0.2) discard; @@ -117,7 +117,7 @@ static const std::vector vsAdrenoLogicTest = { "#version 450\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" - "layout (std140, set = 0, binding = 0) uniform bufferVals {\n" + "layout (std140, set = 1, binding = 0) uniform bufferVals {\n" " mat4 WorldViewProj;\n" "} myBufferVals;\n" "layout (location = 0) in vec4 pos;\n" @@ -173,7 +173,7 @@ static const std::vector fsFlat = { "layout(location = 0) flat in lowp vec4 oColor0;\n" "layout(location = 1) in highp vec2 oTexCoord0;\n" "layout(location = 0) out vec4 fragColor0;\n" - "layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n" + "layout(set = 1, binding = 1) uniform sampler2D Sampler0;\n" "void main() { fragColor0 = texture(Sampler0, oTexCoord0) * oColor0; }\n" } }; @@ -214,7 +214,7 @@ static const std::vector vsFlat = { "#version 450\n" "#extension GL_ARB_separate_shader_objects : enable\n" "#extension GL_ARB_shading_language_420pack : enable\n" - "layout (std140, set = 0, binding = 0) uniform bufferVals {\n" + "layout (std140, set = 1, binding = 0) uniform bufferVals {\n" " mat4 WorldViewProj;\n" "} myBufferVals;\n" "layout (location = 0) in vec4 pos;\n" From ab1cebec5190e7d9826d895144e1ed1855a89f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 10:15:36 +0200 Subject: [PATCH 279/374] Actually bind a global uniform buffer, too. Not yet used. --- Common/GPU/Vulkan/VulkanRenderManager.h | 2 +- GPU/Common/ShaderUniforms.h | 6 +++--- GPU/Vulkan/DrawEngineVulkan.cpp | 27 ++++++++++++++++++++++++- GPU/Vulkan/DrawEngineVulkan.h | 2 ++ 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 26e1eb5220..c8ca219d17 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -273,10 +273,10 @@ public: // Mainly used to bind the frame-global desc set. // Can be done before binding a pipeline, so not asserting on that. void BindDescriptorSet(int setNumber, VkDescriptorSet set, VkPipelineLayout pipelineLayout) { - _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); VkRenderData data{ VKRRenderCommand::BIND_DESCRIPTOR_SET }; data.bindDescSet.setNumber = setNumber; data.bindDescSet.set = set; + data.bindDescSet.pipelineLayout = pipelineLayout; curRenderStep_->commands.push_back(data); } diff --git a/GPU/Common/ShaderUniforms.h b/GPU/Common/ShaderUniforms.h index 96cfe98411..12bc273da3 100644 --- a/GPU/Common/ShaderUniforms.h +++ b/GPU/Common/ShaderUniforms.h @@ -133,12 +133,12 @@ R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bon static const char * const ub_frame_globalstr = -R"( vec4 unused; +R"( vec4 stereoParams; )"; -// VR stuff will go here. +// Frame-global uniforms. struct UB_FrameGlobal { - float unused[4]; + float stereoParams[4]; }; void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bool hasNegZ); diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 71d601d805..4d933b09d7 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -312,7 +312,8 @@ void DrawEngineVulkan::BeginFrame() { frame->pushVertex->Begin(vulkan); frame->pushIndex->Begin(vulkan); - // TODO: How can we make this nicer... + frame->frameDescSetUpdated = false; + tessDataTransferVulkan->SetPushBuffer(frame->pushUBO); DirtyAllUBOs(); @@ -1016,6 +1017,30 @@ void DrawEngineVulkan::DoFlush() { } void DrawEngineVulkan::UpdateUBOs(FrameData *frame) { + if (!frame->frameDescSetUpdated) { + // Push frame global constants. + UB_FrameGlobal frameConstants{}; + VkDescriptorBufferInfo frameConstantsBufInfo; + frame->pushUBO->PushUBOData(frameConstants, &frameConstantsBufInfo); + + VulkanContext *vulkan = (VulkanContext *)draw_->GetNativeObject(Draw::NativeObject::CONTEXT); + VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); + VkDescriptorSetLayout frameDescSetLayout = (VkDescriptorSetLayout)draw_->GetNativeObject(Draw::NativeObject::FRAME_DATA_DESC_SET_LAYOUT); + + VkDescriptorSet frameDescSet = frame->descPool.Allocate(1, &frameDescSetLayout, "frame_desc_set"); + + VkWriteDescriptorSet descWrite{ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; + descWrite.descriptorCount = 1; + descWrite.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + descWrite.dstBinding = 0; + descWrite.dstSet = frameDescSet; + descWrite.pBufferInfo = &frameConstantsBufInfo; + vkUpdateDescriptorSets(vulkan->GetDevice(), 1, &descWrite, 0, nullptr); + renderManager->BindDescriptorSet(0, frameDescSet, pipelineLayout_); + + frame->frameDescSetUpdated = true; + } + if ((dirtyUniforms_ & DIRTY_BASE_UNIFORMS) || baseBuf == VK_NULL_HANDLE) { baseUBOOffset = shaderManager_->PushBaseBuffer(frame->pushUBO, &baseBuf); dirtyUniforms_ &= ~DIRTY_BASE_UNIFORMS; diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 0cf03f275c..035bc595df 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -255,6 +255,8 @@ private: VulkanPushBuffer *pushVertex = nullptr; VulkanPushBuffer *pushIndex = nullptr; + bool frameDescSetUpdated = false; + // We do rolling allocation and reset instead of caching across frames. That we might do later. DenseHashMap descSets; From 10eb21d3b3705419b0582d0a4fbc0e12d23bd11b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 10:17:29 +0200 Subject: [PATCH 280/374] Add some extra checking for valid stereo shader. --- GPU/Common/PresentationCommon.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 025888896c..756bce0873 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -233,14 +233,21 @@ bool PresentationCommon::UpdatePostShader() { if (gstate_c.Use(GPU_USE_SIMPLE_STEREO_PERSPECTIVE)) { const ShaderInfo *stereoShaderInfo = GetPostShaderInfo(g_Config.sStereoToMonoShader); - bool result = CompilePostShader(stereoShaderInfo, &stereoPipeline_); - if (!result) { + if (stereoShaderInfo) { + bool result = CompilePostShader(stereoShaderInfo, &stereoPipeline_); + if (!result) { + // We won't have a stereo shader. We have to check for this later. + delete stereoShaderInfo_; + stereoShaderInfo_ = nullptr; + stereoPipeline_ = nullptr; + } else { + stereoShaderInfo_ = new ShaderInfo(*stereoShaderInfo); + } + } else { // We won't have a stereo shader. We have to check for this later. delete stereoShaderInfo_; stereoShaderInfo_ = nullptr; stereoPipeline_ = nullptr; - } else { - stereoShaderInfo_ = new ShaderInfo(*stereoShaderInfo); } } @@ -296,6 +303,8 @@ bool PresentationCommon::UpdatePostShader() { } bool PresentationCommon::CompilePostShader(const ShaderInfo *shaderInfo, Draw::Pipeline **outPipeline) const { + _assert_(shaderInfo); + std::string vsSourceGLSL = ReadShaderSrc(shaderInfo->vertexShaderFile); std::string fsSourceGLSL = ReadShaderSrc(shaderInfo->fragmentShaderFile); if (vsSourceGLSL.empty() || fsSourceGLSL.empty()) { From d9cfcf215e8758e16e4c134a87c371bc8202734b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 10:20:47 +0200 Subject: [PATCH 281/374] Need to request the proper type of uniform buffer descriptors. Otherwise, assert on Mali. --- GPU/Vulkan/DrawEngineVulkan.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 4d933b09d7..68108fe107 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -154,7 +154,7 @@ void DrawEngineVulkan::InitDeviceObjects() { static constexpr int DEFAULT_DESC_POOL_SIZE = 512; std::vector dpTypes; - dpTypes.resize(4); + dpTypes.resize(5); dpTypes[0].descriptorCount = DEFAULT_DESC_POOL_SIZE * 3; dpTypes[0].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; dpTypes[1].descriptorCount = DEFAULT_DESC_POOL_SIZE * 3; // Don't use these for tess anymore, need max three per set. @@ -163,6 +163,8 @@ void DrawEngineVulkan::InitDeviceObjects() { dpTypes[2].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; dpTypes[3].descriptorCount = DEFAULT_DESC_POOL_SIZE; // TODO: Use a separate layout when no spline stuff is needed to reduce the need for these. dpTypes[3].type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; + dpTypes[4].descriptorCount = 1; // For the frame global uniform buffer. + dpTypes[4].type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; VkDescriptorPoolCreateInfo dp{ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; // Don't want to mess around with individually freeing these. From f4f7dc570f23ddd855213bcd140f0ae73e40bba0 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 28 Oct 2022 14:59:12 +0200 Subject: [PATCH 282/374] OpenXR - Make VR camera parameters floating numbers --- Common/VR/PPSSPPVR.cpp | 6 +++--- Common/VR/VRRenderer.cpp | 2 +- Core/Config.cpp | 6 +++--- Core/Config.h | 6 +++--- UI/GameSettingsScreen.cpp | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index a3f550bee3..b2daa2fb8a 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -319,9 +319,9 @@ bool StartVRRender() { // Set customizations VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); - VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.iCameraDistance); - VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.iCanvasDistance); - VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage); + VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); + VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance); + VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); return true; } diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 5a8084941b..a43b169f8e 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -339,7 +339,7 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix].M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; } if (abs(vrConfig[VR_CONFIG_CAMERA_DISTANCE]) > 0) { - XrVector3f forward = {0.0f, 0.0f, (float)vrConfig[VR_CONFIG_CAMERA_DISTANCE] * scale}; + XrVector3f forward = {0.0f, 0.0f, (float)vrConfig[VR_CONFIG_CAMERA_DISTANCE] * 0.001f * scale}; forward = XrQuaternionf_Rotate(invView.orientation, forward); forward = XrVector3f_ScalarMultiply(forward, vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f); vrMatrix[matrix].M[0][3] += forward.x; diff --git a/Core/Config.cpp b/Core/Config.cpp index 91457df787..da71b8bfff 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1208,9 +1208,9 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable", &g_Config.bEnableVR, true), ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), - ConfigSetting("VRCameraDistance", &g_Config.iCameraDistance, 0), - ConfigSetting("VRCanvasDistance", &g_Config.iCanvasDistance, 6), - ConfigSetting("VRFieldOfView", &g_Config.iFieldOfViewPercentage, 100), + ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), + ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), + ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 5a89c89732..f42fd77720 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -463,9 +463,9 @@ public: bool bEnableVR; bool bEnable6DoF; bool bEnableStereo; - int iCameraDistance; - int iCanvasDistance; - int iFieldOfViewPercentage; + float fCameraDistance; + float fCanvasDistance; + float fFieldOfViewPercentage; // Debugger int iDisasmWindowX; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 706eb07cfe..5dce2e89cd 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1165,9 +1165,9 @@ void GameSettingsScreen::CreateViews() { vrStereo->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); - vrSettings->Add(new PopupSliderChoice(&g_Config.iCameraDistance, -10, 10, vr->T("Camera distance adjust", "Camera distance adjust"), 1, screenManager(), "")); - vrSettings->Add(new PopupSliderChoice(&g_Config.iCanvasDistance, 1, 10, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1, screenManager(), "")); - vrSettings->Add(new PopupSliderChoice(&g_Config.iFieldOfViewPercentage, 100, 200, vr->T("Field of view scale", "Headset's field of view scale"), 10, screenManager(), vr->T("% of native FoV"))); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Headset's field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); } } From 96f89f4bd74aa77307e570b2f0db5eb225797a6b Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 28 Oct 2022 15:50:00 +0200 Subject: [PATCH 283/374] OpenXR - Allow updating camera in realtime --- Common/VR/PPSSPPVR.cpp | 22 ++++++++++++++++++++-- Common/VR/PPSSPPVR.h | 4 ++-- Common/VR/VRRenderer.h | 2 +- UI/NativeApp.cpp | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index b2daa2fb8a..704eba7422 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -221,11 +221,16 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con } } -void UpdateVRScreenKey(const KeyInput &key) { +void UpdateVRSpecialKeys(const KeyInput &key) { std::vector nativeKeys; if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { - if (nativeKey == CTRL_SCREEN) { + // adjust camera parameters + if (nativeKey == CTRL_HOLD) { + VR_SetConfig(VR_CONFIG_CAMERA_CONTROL, key.flags & KEY_DOWN); + } + // force 2D rendering + else if (nativeKey == CTRL_SCREEN) { VR_SetConfig(VR_CONFIG_FORCE_2D, key.flags & KEY_DOWN); } } @@ -317,6 +322,19 @@ bool StartVRRender() { // Set compatibility vrCompat[VR_COMPAT_SKYPLANE] = PSP_CoreParameter().compat.vrCompat().Skyplane; + // Camera control + if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) { + float dst = g_Config.fCameraDistance; + float fov = g_Config.fFieldOfViewPercentage; + int status = IN_VRGetButtonState(1); + if (status & ovrButton_Left) fov -= 1.0f; + if (status & ovrButton_Right) fov += 1.0f; + if (status & ovrButton_Down) dst -= 0.1f; + if (status & ovrButton_Up) dst += 0.1f; + g_Config.fCameraDistance = std::clamp(dst, -10.0f, 10.0f); + g_Config.fFieldOfViewPercentage = std::clamp(fov, 100.0f, 200.0f); + } + // Set customizations VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 91f5862ff0..440f27859d 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -25,7 +25,7 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); -void UpdateVRScreenKey(const KeyInput &key); +void UpdateVRSpecialKeys(const KeyInput &key); // VR games compatibility void PreprocessStepVR(void* step); @@ -53,7 +53,7 @@ inline void InitVROnAndroid(void* vm, void* activity, int version, const char* n inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} -inline void UpdateVRScreenKey(const KeyInput &key) {} +inline void UpdateVRSpecialKeys(const KeyInput &key) {} // VR games compatibility inline void PreprocessStepVR(void* step) {} diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 1c93f98752..7ba37ae407 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -7,7 +7,7 @@ enum VRConfig { //switching between 2D and 3D VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup - VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_DISTANCE, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, VR_CONFIG_CANVAS_DISTANCE, //6DoF VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 36ce962ea4..0f4cac7f37 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1296,9 +1296,9 @@ bool NativeTouch(const TouchInput &touch) { } bool NativeKey(const KeyInput &key) { - // Hack to quickly enable 2D mode in VR game mode. + // Special key VR actions if (IsVRBuild()) { - UpdateVRScreenKey(key); + UpdateVRSpecialKeys(key); } // INFO_LOG(SYSTEM, "Key code: %i flags: %i", key.keyCode, key.flags); From 8e0b82f92e8b7312e08de0edd5d0634362a14b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 17:42:21 +0200 Subject: [PATCH 284/374] Address feedback --- GPU/Common/PresentationCommon.cpp | 12 ++---------- GPU/Vulkan/VulkanUtil.cpp | 6 +++--- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 756bce0873..b4e05d8d50 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -235,19 +235,11 @@ bool PresentationCommon::UpdatePostShader() { const ShaderInfo *stereoShaderInfo = GetPostShaderInfo(g_Config.sStereoToMonoShader); if (stereoShaderInfo) { bool result = CompilePostShader(stereoShaderInfo, &stereoPipeline_); - if (!result) { - // We won't have a stereo shader. We have to check for this later. - delete stereoShaderInfo_; - stereoShaderInfo_ = nullptr; - stereoPipeline_ = nullptr; - } else { + if (result) { stereoShaderInfo_ = new ShaderInfo(*stereoShaderInfo); } } else { - // We won't have a stereo shader. We have to check for this later. - delete stereoShaderInfo_; - stereoShaderInfo_ = nullptr; - stereoPipeline_ = nullptr; + WARN_LOG(G3D, "Failed to get info about stereo shader '%s'", g_Config.sStereoToMonoShader.c_str()); } } diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 27149b2be1..fbfb8ad3fa 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -85,14 +85,14 @@ void VulkanComputeShaderManager::InitDeviceObjects(Draw::DrawContext *draw) { std::vector dpTypes; dpTypes.resize(2); - dpTypes[0].descriptorCount = 4096; + dpTypes[0].descriptorCount = 8192; dpTypes[0].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; - dpTypes[1].descriptorCount = 2048; + dpTypes[1].descriptorCount = 4096; dpTypes[1].type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; dp.flags = 0; // Don't want to mess around with individually freeing these, let's go fixed each frame and zap the whole array. Might try the dynamic approach later. - dp.maxSets = 2048; // GTA can end up creating more than 1000 textures in the first frame! + dp.maxSets = 4096; // GTA can end up creating more than 1000 textures in the first frame! for (int i = 0; i < ARRAY_SIZE(frameData_); i++) { frameData_[i].descPool.Create(vulkan_, dp, dpTypes); From c6fe91224a6422f4bceeac035f2c778d3a6e1ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 18:40:55 +0200 Subject: [PATCH 285/374] Vulkan: Fixes validation errors with "null" textures These arise in non-buffered rendering when we don't have a framebuffer to texture from. --- Common/GPU/Vulkan/thin3d_vulkan.cpp | 8 +++++++- Common/GPU/thin3d.h | 1 + GPU/Vulkan/DrawEngineVulkan.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index fda775f1d0..17d6ed113c 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1343,7 +1343,11 @@ void VKContext::BindTextures(int start, int count, Texture **textures, TextureBi boundImageView_[i] = boundTextures_[i]->GetImageView(); } } else { - boundImageView_[i] = GetNullTexture()->GetImageView(); + if (flags & TextureBindFlags::VULKAN_BIND_ARRAY) { + boundImageView_[i] = GetNullTexture()->GetImageArrayView(); + } else { + boundImageView_[i] = GetNullTexture()->GetImageView(); + } } } } @@ -1693,6 +1697,8 @@ uint64_t VKContext::GetNativeObject(NativeObject obj, void *srcObject) { return (uint64_t)(uintptr_t)&renderManager_; case NativeObject::NULL_IMAGEVIEW: return (uint64_t)GetNullTexture()->GetImageView(); + case NativeObject::NULL_IMAGEVIEW_ARRAY: + return (uint64_t)GetNullTexture()->GetImageArrayView(); case NativeObject::TEXTURE_VIEW: return (uint64_t)(((VKTexture *)srcObject)->GetImageView()); case NativeObject::BOUND_FRAMEBUFFER_COLOR_IMAGEVIEW_ALL_LAYERS: diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 695e1c83c8..9bc0c3a14a 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -249,6 +249,7 @@ enum class NativeObject { RENDER_MANAGER, TEXTURE_VIEW, NULL_IMAGEVIEW, + NULL_IMAGEVIEW_ARRAY, FRAME_DATA_DESC_SET_LAYOUT, THIN3D_PIPELINE_LAYOUT, }; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 68108fe107..f54afee3a9 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -770,7 +770,7 @@ void DrawEngineVulkan::DoFlush() { textureCache_->ApplyTexture(); textureCache_->GetVulkanHandles(imageView, sampler); if (imageView == VK_NULL_HANDLE) - imageView = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::NULL_IMAGEVIEW); + imageView = (VkImageView)draw_->GetNativeObject(gstate_c.arrayTexture ? Draw::NativeObject::NULL_IMAGEVIEW_ARRAY : Draw::NativeObject::NULL_IMAGEVIEW); if (sampler == VK_NULL_HANDLE) sampler = nullSampler_; } @@ -906,7 +906,7 @@ void DrawEngineVulkan::DoFlush() { textureCache_->ApplyTexture(); textureCache_->GetVulkanHandles(imageView, sampler); if (imageView == VK_NULL_HANDLE) - imageView = (VkImageView)draw_->GetNativeObject(Draw::NativeObject::NULL_IMAGEVIEW); + imageView = (VkImageView)draw_->GetNativeObject(gstate_c.arrayTexture ? Draw::NativeObject::NULL_IMAGEVIEW_ARRAY : Draw::NativeObject::NULL_IMAGEVIEW); if (sampler == VK_NULL_HANDLE) sampler = nullSampler_; } From f9c6f0a39e47d8660c3d9ada8733570c34149548 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 08:53:19 -0700 Subject: [PATCH 286/374] headless: Update tests. --- pspautotests | 2 +- test.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pspautotests b/pspautotests index 1790e574bd..a886587cc2 160000 --- a/pspautotests +++ b/pspautotests @@ -1 +1 @@ -Subproject commit 1790e574bd069c7e4883bf097db46094526b0dc9 +Subproject commit a886587cc29ffadc93f5533a0f8dc329ae355b9a diff --git a/test.py b/test.py index b9cf9260ca..dbfe4d1ad7 100755 --- a/test.py +++ b/test.py @@ -201,6 +201,7 @@ tests_good = [ "intr/suspended", "intr/vblank/vblank", "io/cwd/cwd", + "io/open/badparent", "jpeg/create", "jpeg/delete", "jpeg/finish", From 79d53552a5467790f1041148cbe9a9a27412e350 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 09:02:12 -0700 Subject: [PATCH 287/374] armips: Update to latest. --- UWP/Armips_UWP/Armips_UWP.vcxproj | 12 +++++++ UWP/Armips_UWP/Armips_UWP.vcxproj.filters | 39 +++++++++++++++++++++++ android/jni/Android.mk | 6 ++++ ext/armips | 2 +- ext/libarmips.vcxproj | 12 +++++++ ext/libarmips.vcxproj.filters | 39 +++++++++++++++++++++++ 6 files changed, 109 insertions(+), 1 deletion(-) diff --git a/UWP/Armips_UWP/Armips_UWP.vcxproj b/UWP/Armips_UWP/Armips_UWP.vcxproj index a836263550..4610681d23 100644 --- a/UWP/Armips_UWP/Armips_UWP.vcxproj +++ b/UWP/Armips_UWP/Armips_UWP.vcxproj @@ -278,6 +278,12 @@ + + + + + + @@ -329,6 +335,12 @@ + + + + + + diff --git a/UWP/Armips_UWP/Armips_UWP.vcxproj.filters b/UWP/Armips_UWP/Armips_UWP.vcxproj.filters index 37d23a6b09..0ba78a266d 100644 --- a/UWP/Armips_UWP/Armips_UWP.vcxproj.filters +++ b/UWP/Armips_UWP/Armips_UWP.vcxproj.filters @@ -56,6 +56,24 @@ Archs\MIPS + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + Archs @@ -202,6 +220,24 @@ Archs\MIPS + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + Archs @@ -300,6 +336,9 @@ {bef7b4a2-b049-4d00-810c-6d8d6605c2a3} + + {bef7b4a2-b049-4d00-810c-6d8d6605c2a4} + {2ce1016b-f93c-48b9-abe5-d3fbbcd24780} diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 333733382e..8913f641e5 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -584,6 +584,12 @@ LIBARMIPS_FILES := \ $(SRC)/ext/armips/Archs/MIPS/MipsOpcodes.cpp \ $(SRC)/ext/armips/Archs/MIPS/MipsParser.cpp \ $(SRC)/ext/armips/Archs/MIPS/PsxRelocator.cpp \ + $(SRC)/ext/armips/Archs/SuperH/CShInstruction.cpp \ + $(SRC)/ext/armips/Archs/SuperH/ShElfRelocator.cpp \ + $(SRC)/ext/armips/Archs/SuperH/ShExpressionFunctions.cpp \ + $(SRC)/ext/armips/Archs/SuperH/ShOpcodes.cpp \ + $(SRC)/ext/armips/Archs/SuperH/ShParser.cpp \ + $(SRC)/ext/armips/Archs/SuperH/SuperH.cpp \ $(SRC)/ext/armips/Archs/Architecture.cpp \ $(SRC)/ext/armips/Commands/CAssemblerCommand.cpp \ $(SRC)/ext/armips/Commands/CAssemblerLabel.cpp \ diff --git a/ext/armips b/ext/armips index b4335f04fa..6719edebaa 160000 --- a/ext/armips +++ b/ext/armips @@ -1 +1 @@ -Subproject commit b4335f04fa62c1b4f7833c70fbb15505b6772274 +Subproject commit 6719edebaae03330ee5441d9b28280672edf00d5 diff --git a/ext/libarmips.vcxproj b/ext/libarmips.vcxproj index c0484e63d1..bd9f5c9911 100644 --- a/ext/libarmips.vcxproj +++ b/ext/libarmips.vcxproj @@ -502,6 +502,12 @@ + + + + + + @@ -554,6 +560,12 @@ + + + + + + diff --git a/ext/libarmips.vcxproj.filters b/ext/libarmips.vcxproj.filters index 61282421bb..4a9b54143c 100644 --- a/ext/libarmips.vcxproj.filters +++ b/ext/libarmips.vcxproj.filters @@ -31,6 +31,9 @@ {d1037c70-bb54-46fc-8b0c-a47c4ea4a252} + + {496988ff-1b2f-4046-bc02-b5ad9a1952b4} + @@ -183,6 +186,24 @@ Core + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + @@ -341,5 +362,23 @@ Core + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + + + Archs\SuperH + \ No newline at end of file From 0bc2bb9efb19754f14ca42448400e4e840fab623 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 09:05:14 -0700 Subject: [PATCH 288/374] Vulkan: Log additional queue command. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 47e5b94046..bce57f549d 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1145,6 +1145,9 @@ void VulkanQueueRunner::LogRenderPass(const VKRStep &pass, bool verbose) { case VKRRenderCommand::DEBUG_ANNOTATION: INFO_LOG(G3D, " DebugAnnotation(%s)", cmd.debugAnnotation.annotation); break; + case VKRRenderCommand::BIND_DESCRIPTOR_SET: + INFO_LOG(G3D, " BindDescSet(%d)", cmd.bindDescSet.setNumber); + break; case VKRRenderCommand::NUM_RENDER_COMMANDS: break; From 48f9c98559949aa1492d1cc154ea337325a3c282 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 29 Oct 2022 18:50:51 +0200 Subject: [PATCH 289/374] OpenXR - Do not process key actions during camera adjust --- Common/VR/PPSSPPVR.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 704eba7422..2c3e730bfc 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -150,22 +150,42 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con KeyInput keyInput = {}; for (int j = 0; j < 2; j++) { int status = IN_VRGetButtonState(j); + bool cameraControl = VR_GetConfig(VR_CONFIG_CAMERA_CONTROL); for (ButtonMapping& m : controllerMapping[j]) { + + //check if camera key was pressed + bool cameraKey = false; + std::vector nativeKeys; + if (KeyMap::KeyToPspButton(controllerIds[j], m.keycode, &nativeKeys)) { + for (int& nativeKey : nativeKeys) { + if (nativeKey == CTRL_HOLD) { + cameraKey = true; + break; + } + } + } + + //fill KeyInput structure bool pressed = status & m.ovr; keyInput.flags = pressed ? KEY_DOWN : KEY_UP; keyInput.keyCode = m.keycode; keyInput.deviceId = controllerIds[j]; + //process the key action if (m.pressed != pressed) { if (pressed && haptics) { INVR_Vibrate(100, j, 1000); } - NativeKey(keyInput); + if (!cameraControl || cameraKey) { + NativeKey(keyInput); + } m.pressed = pressed; m.repeat = 0; } else if (pressed && (m.repeat > 30)) { keyInput.flags |= KEY_IS_REPEAT; - NativeKey(keyInput); + if (!cameraControl || cameraKey) { + NativeKey(keyInput); + } m.repeat = 0; } else { m.repeat++; @@ -331,6 +351,10 @@ bool StartVRRender() { if (status & ovrButton_Right) fov += 1.0f; if (status & ovrButton_Down) dst -= 0.1f; if (status & ovrButton_Up) dst += 0.1f; + if (status & ovrButton_RThumb) { + fov = 100; + dst = 0; + } g_Config.fCameraDistance = std::clamp(dst, -10.0f, 10.0f); g_Config.fFieldOfViewPercentage = std::clamp(fov, 100.0f, 200.0f); } From b7da6f7e45bf8a9f09c5a2dd4fbb935a73b21ace Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 29 Oct 2022 19:19:25 +0200 Subject: [PATCH 290/374] OpenXR - Camera height adjust added --- Common/VR/PPSSPPVR.cpp | 14 +++++++++++++- Common/VR/VRRenderer.cpp | 8 ++++++++ Common/VR/VRRenderer.h | 3 ++- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 1 + 6 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 2c3e730bfc..84ce7274fd 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -344,9 +344,20 @@ bool StartVRRender() { // Camera control if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) { + //light joystick controls height + float height = g_Config.fCameraHeight; + int status = IN_VRGetButtonState(0); + if (status & ovrButton_Down) height -= 0.05f; + if (status & ovrButton_Up) height += 0.05f; + if (status & ovrButton_LThumb) { + height = 0; + } + g_Config.fCameraHeight = std::clamp(height, -10.0f, 10.0f); + + //right joystick controls distance and fov float dst = g_Config.fCameraDistance; float fov = g_Config.fFieldOfViewPercentage; - int status = IN_VRGetButtonState(1); + status = IN_VRGetButtonState(1); if (status & ovrButton_Left) fov -= 1.0f; if (status & ovrButton_Right) fov += 1.0f; if (status & ovrButton_Down) dst -= 0.1f; @@ -362,6 +373,7 @@ bool StartVRRender() { // Set customizations VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); + VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000); VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index a43b169f8e..aba7c4def0 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -346,6 +346,14 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix].M[1][3] += forward.y; vrMatrix[matrix].M[2][3] += forward.z; } + if (abs(vrConfig[VR_CONFIG_CAMERA_HEIGHT]) > 0) { + XrVector3f up = {0.0f, -(float)vrConfig[VR_CONFIG_CAMERA_HEIGHT] * 0.001f * scale, 0.0f}; + up = XrQuaternionf_Rotate(invView.orientation, up); + up = XrVector3f_ScalarMultiply(up, vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f); + vrMatrix[matrix].M[0][3] += up.x; + vrMatrix[matrix].M[1][3] += up.y; + vrMatrix[matrix].M[2][3] += up.z; + } if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 7ba37ae407..95671fc0c2 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -7,7 +7,8 @@ enum VRConfig { //switching between 2D and 3D VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup - VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, + VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CANVAS_DISTANCE, //6DoF VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, diff --git a/Core/Config.cpp b/Core/Config.cpp index da71b8bfff..f52738b8bd 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1209,6 +1209,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), + ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), diff --git a/Core/Config.h b/Core/Config.h index f42fd77720..2a66f73fa2 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -464,6 +464,7 @@ public: bool bEnable6DoF; bool bEnableStereo; float fCameraDistance; + float fCameraHeight; float fCanvasDistance; float fFieldOfViewPercentage; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5dce2e89cd..a6311ab4ef 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1166,6 +1166,7 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust", "Camera height adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Headset's field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); } From 92422160a0f4248ab055bf8d5f3dccca01d909db Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 29 Oct 2022 19:31:57 +0200 Subject: [PATCH 291/374] OpenXR - Camera side adjust added --- Common/VR/PPSSPPVR.cpp | 8 +++++++- Common/VR/VRRenderer.cpp | 8 ++++++++ Common/VR/VRRenderer.h | 2 +- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 1 + 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 84ce7274fd..7c8c522ec0 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -344,15 +344,20 @@ bool StartVRRender() { // Camera control if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) { - //light joystick controls height + //light joystick controls height and side float height = g_Config.fCameraHeight; + float side = g_Config.fCameraSide; int status = IN_VRGetButtonState(0); + if (status & ovrButton_Left) side -= 0.05f; + if (status & ovrButton_Right) side += 0.05f; if (status & ovrButton_Down) height -= 0.05f; if (status & ovrButton_Up) height += 0.05f; if (status & ovrButton_LThumb) { height = 0; + side = 0; } g_Config.fCameraHeight = std::clamp(height, -10.0f, 10.0f); + g_Config.fCameraSide = std::clamp(side, -10.0f, 10.0f); //right joystick controls distance and fov float dst = g_Config.fCameraDistance; @@ -374,6 +379,7 @@ bool StartVRRender() { VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000); + VR_SetConfig(VR_CONFIG_CAMERA_SIDE, g_Config.fCameraSide * 1000); VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance); VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index aba7c4def0..3d4cce0222 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -354,6 +354,14 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix].M[1][3] += up.y; vrMatrix[matrix].M[2][3] += up.z; } + if (abs(vrConfig[VR_CONFIG_CAMERA_SIDE]) > 0) { + XrVector3f side = {-(float)vrConfig[VR_CONFIG_CAMERA_SIDE] * 0.001f * scale, 0.0f, 0.0f}; + side = XrQuaternionf_Rotate(invView.orientation, side); + side = XrVector3f_ScalarMultiply(side, vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f); + vrMatrix[matrix].M[0][3] += side.x; + vrMatrix[matrix].M[1][3] += side.y; + vrMatrix[matrix].M[2][3] += side.z; + } if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 95671fc0c2..863212bd7d 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -8,7 +8,7 @@ enum VRConfig { VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, - VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CAMERA_SIDE, VR_CONFIG_CANVAS_DISTANCE, //6DoF VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, diff --git a/Core/Config.cpp b/Core/Config.cpp index f52738b8bd..f62a4baaae 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1210,6 +1210,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), + ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), diff --git a/Core/Config.h b/Core/Config.h index 2a66f73fa2..a494cf4c61 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -465,6 +465,7 @@ public: bool bEnableStereo; float fCameraDistance; float fCameraHeight; + float fCameraSide; float fCanvasDistance; float fFieldOfViewPercentage; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a6311ab4ef..6b68d9c866 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1167,6 +1167,7 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust", "Camera height adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraSide, -10.0f, 10.0f, vr->T("Camera side adjust", "Camera side adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Headset's field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); } From 363f102cc5139ee1155035353870fd91ae73b2eb Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 29 Oct 2022 20:47:29 +0200 Subject: [PATCH 292/374] OpenXR - Add new virtual key for camera adjust --- Common/VR/PPSSPPVR.cpp | 4 ++-- Core/KeyMap.cpp | 4 ++++ Core/KeyMap.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 7c8c522ec0..ba6ff6ba64 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -158,7 +158,7 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con std::vector nativeKeys; if (KeyMap::KeyToPspButton(controllerIds[j], m.keycode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { - if (nativeKey == CTRL_HOLD) { + if (nativeKey == VIRTKEY_VR_CAMERA_ADJUST) { cameraKey = true; break; } @@ -246,7 +246,7 @@ void UpdateVRSpecialKeys(const KeyInput &key) { if (KeyMap::KeyToPspButton(key.deviceId, key.keyCode, &nativeKeys)) { for (int& nativeKey : nativeKeys) { // adjust camera parameters - if (nativeKey == CTRL_HOLD) { + if (nativeKey == VIRTKEY_VR_CAMERA_ADJUST) { VR_SetConfig(VR_CONFIG_CAMERA_CONTROL, key.flags & KEY_DOWN); } // force 2D rendering diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index b0a3b69c7e..30b005d86f 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -399,10 +399,14 @@ const KeyMap_IntStrPair psp_button_names[] = { {VIRTKEY_ANALOG_ROTATE_CW, "Rotate Analog (CW)"}, {VIRTKEY_ANALOG_ROTATE_CCW, "Rotate Analog (CCW)"}, +#ifdef OPENXR + {VIRTKEY_VR_CAMERA_ADJUST, "VR camera adjust"}, +#else {VIRTKEY_SCREEN_ROTATION_VERTICAL, "Display Portrait"}, {VIRTKEY_SCREEN_ROTATION_VERTICAL180, "Display Portrait Reversed"}, {VIRTKEY_SCREEN_ROTATION_HORIZONTAL, "Display Landscape"}, {VIRTKEY_SCREEN_ROTATION_HORIZONTAL180, "Display Landscape Reversed"}, +#endif {CTRL_HOME, "Home"}, {CTRL_HOLD, "Hold"}, diff --git a/Core/KeyMap.h b/Core/KeyMap.h index a8ae9f672a..74859d3628 100644 --- a/Core/KeyMap.h +++ b/Core/KeyMap.h @@ -68,6 +68,7 @@ enum { VIRTKEY_SCREEN_ROTATION_HORIZONTAL = 0x40000022, VIRTKEY_SCREEN_ROTATION_HORIZONTAL180 = 0x40000023, VIRTKEY_SPEED_ANALOG = 0x40000024, + VIRTKEY_VR_CAMERA_ADJUST = 0x40000025, VIRTKEY_LAST, VIRTKEY_COUNT = VIRTKEY_LAST - VIRTKEY_FIRST }; From d44315a2ec0d453d224fe299c0e3d039cc3fb10a Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 29 Oct 2022 21:00:10 +0200 Subject: [PATCH 293/374] OpenXR - Stereo support for Outrun 2006 added --- assets/compatvr.ini | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 7bfc3e5c94..79b1c04678 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -1006,6 +1006,11 @@ NPJH50625 = 1.0 ULJM06113 = 1.0 ULJM08069 = 1.0 +# OutRun 2006: Coast 2 Coast +ULES00262 = 10.0 +ULKS46087 = 10.0 +ULUS10064 = 10.0 + # Patapon 1 NPJG00054 = 80.0 UCAS40193 = 80.0 From cbf93d586c8b81c504445a9fbb95bc7adf4c673a Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 29 Oct 2022 21:39:46 +0200 Subject: [PATCH 294/374] typo fixed --- Common/VR/PPSSPPVR.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index ba6ff6ba64..0c496d55e0 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -344,7 +344,7 @@ bool StartVRRender() { // Camera control if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) { - //light joystick controls height and side + //left joystick controls height and side float height = g_Config.fCameraHeight; float side = g_Config.fCameraSide; int status = IN_VRGetButtonState(0); From 0cc94ceb15256a4b642fdda449903a6b1a837adf Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 12:52:00 -0700 Subject: [PATCH 295/374] Draw: Correct ambiguous comparison overload. --- Common/GPU/thin3d.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 9bc0c3a14a..7a2c012f89 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -393,6 +393,9 @@ struct AutoRef { *this = p.ptr; return *this; } + bool operator !=(const AutoRef &p) const { + return ptr != p.ptr; + } T *operator->() const { return ptr; From 485249a83e1f7945354f9786a34fdb0e6fc06223 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 12:52:24 -0700 Subject: [PATCH 296/374] Windows: Avoid compile param conflict warning. --- ext/native/tools/atlastool/atlastool.vcxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/native/tools/atlastool/atlastool.vcxproj b/ext/native/tools/atlastool/atlastool.vcxproj index 65b315ebdc..9ad9d35117 100644 --- a/ext/native/tools/atlastool/atlastool.vcxproj +++ b/ext/native/tools/atlastool/atlastool.vcxproj @@ -97,7 +97,6 @@ true ../../../../;../../ext;../../;../../../../ext;../prebuilt;../../../../ext/zstd/lib MultiThreaded - false Console From 10a356c23bf70df1701855cc74db645f6503d48c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 13:00:12 -0700 Subject: [PATCH 297/374] UWP: Avoid some float conversion warnings. --- UWP/Common/DeviceResources.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UWP/Common/DeviceResources.cpp b/UWP/Common/DeviceResources.cpp index 8527d77f51..ab1bbcbf40 100644 --- a/UWP/Common/DeviceResources.cpp +++ b/UWP/Common/DeviceResources.cpp @@ -470,13 +470,13 @@ void DX::DeviceResources::SetWindow(CoreWindow^ window) try { const auto dm = hdi->GetCurrentDisplayMode(); - const unsigned int hdmi_width = dm->ResolutionWidthInRawPixels; - const unsigned int hdmi_height = dm->ResolutionHeightInRawPixels; + const float hdmi_width = (float)dm->ResolutionWidthInRawPixels; + const float hdmi_height = (float)dm->ResolutionHeightInRawPixels; // If we're running on Xbox, use the HDMI mode instead of the CoreWindow size. // In UWP, the CoreWindow is always 1920x1080, even when running at 4K. m_logicalSize = Windows::Foundation::Size(hdmi_width, hdmi_height); - m_dpi = currentDisplayInformation->LogicalDpi * 1.5; + m_dpi = currentDisplayInformation->LogicalDpi * 1.5f; } catch (const Platform::Exception^) { From 8cefb98e97ee30e8a765a572823c914fe6a9b22e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 17:35:14 -0700 Subject: [PATCH 298/374] Debugger: Fix input.analog.send validation. --- Core/Debugger/WebSocket/InputSubscriber.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Debugger/WebSocket/InputSubscriber.cpp b/Core/Debugger/WebSocket/InputSubscriber.cpp index 36278eea0e..fd0f478e76 100644 --- a/Core/Debugger/WebSocket/InputSubscriber.cpp +++ b/Core/Debugger/WebSocket/InputSubscriber.cpp @@ -227,7 +227,7 @@ static bool AnalogValue(DebuggerRequest &req, float *value, const char *name) { } double val = node->value.toNumber(); - if (val < 1.0 || val > 1.0) { + if (val < -1.0 || val > 1.0) { req.Fail(StringFromFormat("Parameter '%s' must be between -1.0 and 1.0", name)); return false; } From 0a98ac43fa9656b4bf9d4b811fb3d5235d6d09ed Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 17:43:35 -0700 Subject: [PATCH 299/374] Debugger: Allow currently-invalid memory reference. --- Core/MIPS/MIPSDebugInterface.cpp | 38 +++++++++++--------------------- GPU/Common/GPUDebugInterface.cpp | 13 +++++------ 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Core/MIPS/MIPSDebugInterface.cpp b/Core/MIPS/MIPSDebugInterface.cpp index f81b55ca98..bffdee83b6 100644 --- a/Core/MIPS/MIPSDebugInterface.cpp +++ b/Core/MIPS/MIPSDebugInterface.cpp @@ -159,37 +159,25 @@ public: return EXPR_TYPE_UINT; } - bool getMemoryValue(uint32_t address, int size, uint32_t& dest, char* error) override - { - switch (size) - { - case 1: case 2: case 4: - break; - default: - sprintf(error,"Invalid memory access size %d",size); - return false; - } + bool getMemoryValue(uint32_t address, int size, uint32_t& dest, char* error) override { + // We allow, but ignore, bad access. + // If we didn't, log/condition statements that reference registers couldn't be configured. + bool valid = Memory::IsValidRange(address, size); - if (address % size) - { - sprintf(error,"Invalid memory access (unaligned)"); - return false; - } - - switch (size) - { + switch (size) { case 1: - dest = Memory::Read_U8(address); - break; + dest = valid ? Memory::Read_U8(address) : 0; + return true; case 2: - dest = Memory::Read_U16(address); - break; + dest = valid ? Memory::Read_U16(address) : 0; + return true; case 4: - dest = Memory::Read_U32(address); - break; + dest = valid ? Memory::Read_U32(address) : 0; + return true; } - return true; + sprintf(error, "Unexpected memory access size %d", size); + return false; } private: diff --git a/GPU/Common/GPUDebugInterface.cpp b/GPU/Common/GPUDebugInterface.cpp index a94a3b46a1..4d80d4b83c 100644 --- a/GPU/Common/GPUDebugInterface.cpp +++ b/GPU/Common/GPUDebugInterface.cpp @@ -916,20 +916,19 @@ ExpressionType GEExpressionFunctions::getFieldType(GECmdFormat fmt, GECmdField f } bool GEExpressionFunctions::getMemoryValue(uint32_t address, int size, uint32_t &dest, char *error) { - if (!Memory::IsValidRange(address, size)) { - sprintf(error, "Invalid address or size %08x + %d", address, size); - return false; - } + // We allow, but ignore, bad access. + // If we didn't, log/condition statements that reference registers couldn't be configured. + bool valid = Memory::IsValidRange(address, size); switch (size) { case 1: - dest = Memory::Read_U8(address); + dest = valid ? Memory::Read_U8(address) : 0; return true; case 2: - dest = Memory::Read_U16(address); + dest = valid ? Memory::Read_U16(address) : 0; return true; case 4: - dest = Memory::Read_U32(address); + dest = valid ? Memory::Read_U32(address) : 0; return true; } From 17d94cd3586223aa023a0ef998868727bf24af9f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 17:56:47 -0700 Subject: [PATCH 300/374] SaveState: Restore replacements in only one place. --- Core/HLE/ReplaceTables.cpp | 3 ++- Core/MIPS/x86/Jit.cpp | 2 +- Core/SaveState.cpp | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 85817a49e3..3797e660e2 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -1652,7 +1652,8 @@ std::map SaveAndClearReplacements() { std::map saved; for (auto it = replacedInstructions.begin(), end = replacedInstructions.end(); it != end; ++it) { const u32 addr = it->first; - const u32 curInstr = Memory::Read_U32(addr); + // This will not retain jit blocks. + const u32 curInstr = Memory::Read_Opcode_JIT(addr).encoding; if (MIPS_IS_REPLACEMENT(curInstr)) { saved[addr] = curInstr; Memory::Write_U32(it->second, addr); diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index 266b97da00..97f32b7b72 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -591,7 +591,7 @@ void Jit::Comp_ReplacementFunc(MIPSOpcode op) { // Not sure about the cause. Memory::Opcode origInstruction = Memory::Read_Instruction(GetCompilerPC(), true); if (origInstruction.encoding == op.encoding) { - ERROR_LOG(HLE, "Replacement broken (savestate problem?): %08x", op.encoding); + ERROR_LOG(HLE, "Replacement broken (savestate problem?): %08x at %08x", op.encoding, GetCompilerPC()); return; } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index bf9f3070ca..148e4307d1 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -316,7 +316,11 @@ namespace SaveState } else { Memory::DoState(p); } - RestoreSavedReplacements(savedReplacements); + + // Don't bother restoring if reading, we'll deal with that in KernelModuleDoState. + // In theory, different functions might have been runtime loaded in the state. + if (p.mode != p.MODE_READ) + RestoreSavedReplacements(savedReplacements); MemoryStick_DoState(p); currentMIPS->DoState(p); From 3f997518f36097cf36570a8a7eca8b9b0997b26e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 22:24:05 -0700 Subject: [PATCH 301/374] irjit: Handle vrot overlap more correctly. Sine ignores overlap, cosine does not. --- Core/MIPS/IR/IRCompVFPU.cpp | 35 ++++++++++++++++++++++++++++------- Core/MIPS/MIPSIntVFPU.cpp | 19 ++++++++++++++++++- Core/MIPS/MIPSVFPUUtils.cpp | 4 ++++ 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 4fffc6765d..42cc1970a1 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -1848,33 +1848,54 @@ namespace MIPSComp { int imm = (op >> 16) & 0x1f; VectorSize sz = GetVecSize(op); int n = GetNumVectorElements(sz); + int sineLane = (imm >> 2) & 3; + int cosineLane = imm & 3; bool negSin = (imm & 0x10) ? true : false; + bool broadcastSine = sineLane == cosineLane; char d[4] = { '0', '0', '0', '0' }; - if (((imm >> 2) & 3) == (imm & 3)) { + if (broadcastSine) { for (int i = 0; i < 4; i++) d[i] = 's'; } - d[(imm >> 2) & 3] = 's'; - d[imm & 3] = 'c'; + d[sineLane] = 's'; + d[cosineLane] = 'c'; u8 dregs[4]; GetVectorRegs(dregs, sz, vd); u8 sreg[1]; GetVectorRegs(sreg, V_Single, vs); + + // If there's overlap, sin is calculated without it, but cosine uses the result. + // This corresponds with prefix handling, where cosine doesn't get in prefixes. + if (broadcastSine || !IsOverlapSafe(n, dregs, 1, sreg)) { + ir.Write(IROp::FSin, IRVTEMP_0, sreg[0]); + if (negSin) + ir.Write(IROp::FNeg, IRVTEMP_0, IRVTEMP_0); + } + for (int i = 0; i < n; i++) { switch (d[i]) { case '0': ir.Write(IROp::SetConstF, dregs[i], ir.AddConstantFloat(0.0f)); break; case 's': - ir.Write(IROp::FSin, dregs[i], sreg[0]); - if (negSin) { - ir.Write(IROp::FNeg, dregs[i], dregs[i]); + if (broadcastSine || !IsOverlapSafe(n, dregs, 1, sreg)) { + ir.Write(IROp::FMov, dregs[i], IRVTEMP_0); + } else { + ir.Write(IROp::FSin, dregs[i], sreg[0]); + if (negSin) { + ir.Write(IROp::FNeg, dregs[i], dregs[i]); + } } break; case 'c': - ir.Write(IROp::FCos, dregs[i], sreg[0]); + if (IsOverlapSafe(n, dregs, 1, sreg)) + ir.Write(IROp::FCos, dregs[i], sreg[0]); + else if (dregs[sineLane] == sreg[0]) + ir.Write(IROp::FCos, dregs[i], IRVTEMP_0); + else + ir.Write(IROp::SetConstF, dregs[i], ir.AddConstantFloat(1.0f)); break; } } diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index c8df6b21dc..5e6d5ad54c 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -1607,7 +1607,24 @@ namespace MIPSInt } else { d[sineLane] = sine; } - d[cosineLane] = cosine; + + if (((vd >> 2) & 7) == ((vs >> 2) & 7)) { + u8 dregs[4]{}; + GetVectorRegs(dregs, sz, vd); + // Calculate cosine based on sine/zero result. + bool written = false; + for (int i = 0; i < 4; i++) { + if (vs == dregs[i]) { + d[cosineLane] = vfpu_cos(d[i]); + written = true; + break; + } + } + if (!written) + d[cosineLane] = cosine; + } else { + d[cosineLane] = cosine; + } // D prefix works, just not for x. currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] &= 0xFFEFC; diff --git a/Core/MIPS/MIPSVFPUUtils.cpp b/Core/MIPS/MIPSVFPUUtils.cpp index 0f1d6688ab..e7f7bf7a7f 100644 --- a/Core/MIPS/MIPSVFPUUtils.cpp +++ b/Core/MIPS/MIPSVFPUUtils.cpp @@ -343,6 +343,10 @@ void WriteMatrix(const float *rd, MatrixSize size, int reg) { } int GetVectorOverlap(int vec1, VectorSize size1, int vec2, VectorSize size2) { + // Different matrices? Can't overlap, return early. + if (((vec1 >> 2) & 7) != ((vec2 >> 2) & 7)) + return 0; + int n1 = GetNumVectorElements(size1); int n2 = GetNumVectorElements(size2); u8 regs1[4]; From bbdc8a8f9847ba777056e8f11f9406cc1c8e18c0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Oct 2022 22:43:30 -0700 Subject: [PATCH 302/374] interp: Correct vscl/vmscl t prefix handling. This makes more sense. Fixes Dissidia 012 issues. --- Core/MIPS/IR/IRCompVFPU.cpp | 4 ++-- Core/MIPS/MIPSIntVFPU.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 42cc1970a1..4694986cf7 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -1185,8 +1185,8 @@ namespace MIPSComp { int vt = _VT; u8 sregs[4], dregs[4], treg; GetVectorRegsPrefixS(sregs, sz, vs); - // TODO: Prefixes seem strange... - GetVectorRegsPrefixT(&treg, V_Single, vt); + // T prefixes handled by interp. + GetVectorRegs(&treg, V_Single, vt); GetVectorRegsPrefixD(dregs, sz, vd); bool overlap = false; diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index 5e6d5ad54c..bc1120921e 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -540,8 +540,10 @@ namespace MIPSInt ApplySwizzleS(&s[(n - 1) * 4], V_Quad); // T prefix applies only for the last row, and is used per element. // This is like vscl, but instead of zzzz it uses xxxx. + int tlane = (vt >> 5) & 3; + t[tlane] = t[0]; u32 tprefixRemove = VFPU_ANY_SWIZZLE(); - u32 tprefixAdd = VFPU_SWIZZLE(0, 0, 0, 0); + u32 tprefixAdd = VFPU_SWIZZLE(tlane, tlane, tlane, tlane); ApplyPrefixST(t, VFPURewritePrefix(VFPU_CTRL_TPREFIX, tprefixRemove, tprefixAdd), V_Quad); for (int b = 0; b < n; b++) { @@ -1518,9 +1520,10 @@ namespace MIPSInt // T prefix forces swizzle (zzzz for some reason, so we force V_Quad.) // That means negate still works, but constants are a bit weird. - t[2] = V(vt); + int tlane = (vt >> 5) & 3; + t[tlane] = V(vt); u32 tprefixRemove = VFPU_ANY_SWIZZLE(); - u32 tprefixAdd = VFPU_SWIZZLE(2, 2, 2, 2); + u32 tprefixAdd = VFPU_SWIZZLE(tlane, tlane, tlane, tlane); ApplyPrefixST(t, VFPURewritePrefix(VFPU_CTRL_TPREFIX, tprefixRemove, tprefixAdd), V_Quad); int n = GetNumVectorElements(sz); From e504f0db8f69a7c202765451258bd3ec9c5f3580 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 07:50:57 -0700 Subject: [PATCH 303/374] Replacement: Avoid needless exists check per tex. --- Core/TextureReplacer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index fb6b436661..8dc2ae01b7 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -410,7 +410,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, for (int i = 0; i < MAX_MIP_LEVELS; ++i) { const std::string hashfile = LookupHashFile(cachekey, hash, i); const Path filename = basePath_ / hashfile; - if (hashfile.empty() || !File::Exists(filename)) { + if (hashfile.empty()) { // Out of valid mip levels. Bail out. break; } From 11d0be1fd2346870ef586eb6278839da2e01beef Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 07:55:17 -0700 Subject: [PATCH 304/374] Replacement: Reduce IO checks on startup. --- Core/TextureReplacer.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 8dc2ae01b7..450fb0adb2 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -76,7 +76,7 @@ void TextureReplacer::NotifyConfigChanged() { File::CreateEmptyFile(newTextureDir / ".nomedia"); } - enabled_ = File::Exists(basePath_) && File::IsDirectory(basePath_); + enabled_ = File::IsDirectory(basePath_); } else if (wasEnabled) { Decimate(ReplacerDecimateMode::ALL); } @@ -101,10 +101,8 @@ bool TextureReplacer::LoadIni() { // Prevents dumping the mipmaps. ignoreMipmap_ = false; - if (File::Exists(basePath_ / INI_FILENAME)) { - IniFile ini; - ini.LoadFromVFS((basePath_ / INI_FILENAME).ToString()); - + IniFile ini; + if (ini.LoadFromVFS((basePath_ / INI_FILENAME).ToString())) { if (!LoadIniValues(ini)) { return false; } @@ -113,10 +111,13 @@ bool TextureReplacer::LoadIni() { std::string overrideFilename; if (ini.GetOrCreateSection("games")->Get(gameID_.c_str(), &overrideFilename, "")) { if (!overrideFilename.empty() && overrideFilename != INI_FILENAME) { - INFO_LOG(G3D, "Loading extra texture ini: %s", overrideFilename.c_str()); IniFile overrideIni; - overrideIni.LoadFromVFS((basePath_ / overrideFilename).ToString()); + if (!overrideIni.LoadFromVFS((basePath_ / overrideFilename).ToString())) { + ERROR_LOG(G3D, "Failed to load extra texture ini: %s", overrideFilename.c_str()); + return false; + } + INFO_LOG(G3D, "Loading extra texture ini: %s", overrideFilename.c_str()); if (!LoadIniValues(overrideIni, true)) { return false; } From 0db48c956ca4179f3bde0572b178ddf3670b76f5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 08:15:37 -0700 Subject: [PATCH 305/374] Replacement: Decimate aggressively with high usage. --- Core/TextureReplacer.cpp | 33 ++++++++++++++++++++++++++++----- Core/TextureReplacer.h | 4 +++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 450fb0adb2..56bc897a47 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -47,6 +47,7 @@ static const std::string INI_FILENAME = "textures.ini"; static const std::string NEW_TEXTURE_DIR = "new/"; static const int VERSION = 1; static const int MAX_MIP_LEVELS = 12; // 12 should be plenty, 8 is the max mip levels supported by the PSP. +static const double MAX_CACHE_SIZE = 4.0; TextureReplacer::TextureReplacer() { none_.initDone_ = true; @@ -674,15 +675,27 @@ void TextureReplacer::NotifyTextureDecoded(const ReplacedTextureDecodeInfo &repl void TextureReplacer::Decimate(ReplacerDecimateMode mode) { // Allow replacements to be cached for a long time, although they're large. double age = 1800.0; - if (mode == ReplacerDecimateMode::FORCE_PRESSURE) + if (mode == ReplacerDecimateMode::FORCE_PRESSURE) { age = 90.0; - else if (mode == ReplacerDecimateMode::ALL) + } else if (mode == ReplacerDecimateMode::ALL) { age = 0.0; + } else if (lastTextureCacheSizeGB_ > 1.0) { + double pressure = std::min(MAX_CACHE_SIZE, lastTextureCacheSizeGB_) / MAX_CACHE_SIZE; + // Get more aggressive the closer we are to the max. + age = 90.0 + (1.0 - pressure) * 1710.0; + } const double threshold = time_now_d() - age; + size_t totalSize = 0; for (auto &item : cache_) { - item.second.PurgeIfOlder(threshold); + totalSize += item.second.PurgeIfOlder(threshold); } + + double totalSizeGB = totalSize / (1024.0 * 1024.0 * 1024.0); + if (totalSizeGB >= 1.0) { + WARN_LOG(G3D, "Decimated replacements older than %fs, currently using %f GB of RAM", age, totalSizeGB); + } + lastTextureCacheSizeGB_ = totalSizeGB; } template @@ -968,11 +981,21 @@ void ReplacedTexture::PrepareData(int level) { fclose(fp); } -void ReplacedTexture::PurgeIfOlder(double t) { - if (lastUsed_ < t && (!threadWaitable_ || threadWaitable_->WaitFor(0.0))) { +size_t ReplacedTexture::PurgeIfOlder(double t) { + if (threadWaitable_ && !threadWaitable_->WaitFor(0.0)) + return 0; + + if (lastUsed_ < t) { levelData_.clear(); initDone_ = false; + return 0; } + + size_t s = 0; + for (auto &l : levelData_) { + s += l.size(); + } + return s; } ReplacedTexture::~ReplacedTexture() { diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index b32d31a7d3..f64c9d9b7f 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -166,7 +166,8 @@ struct ReplacedTexture { protected: void Prepare(); void PrepareData(int level); - void PurgeIfOlder(double t); + // Returns size of data not purged. + size_t PurgeIfOlder(double t); std::vector levels_; std::vector> levelData_; @@ -248,6 +249,7 @@ protected: bool reduceHash_ = false; float reduceHashSize = 1.0; // default value with reduceHash to false float reduceHashGlobalValue = 0.5; // Global value for textures dump pngs of all sizes, 0.5 by default but can be set in textures.ini + double lastTextureCacheSizeGB_ = 0.0; bool ignoreMipmap_ = false; std::string gameID_; Path basePath_; From b78c310b477b43852410326743bbd2b8c208e831 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 08:53:24 -0700 Subject: [PATCH 306/374] Replacement: Log only missing explicit filenames. --- Core/TextureReplacer.cpp | 7 ++++--- Core/TextureReplacer.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 56bc897a47..bb854b3d92 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -420,7 +420,7 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, ReplacedTextureLevel level; level.fmt = Draw::DataFormat::R8G8B8A8_UNORM; level.file = filename; - bool good = PopulateLevel(level); + bool good = PopulateLevel(level, hashfile == HashName(cachekey, hash, i) + ".png"); // We pad files that have been hashrange'd so they are the same texture size. level.w = (level.w * w) / newW; @@ -463,12 +463,13 @@ static ReplacedImageType Identify(FILE *fp) { return ReplacedImageType::INVALID; } -bool TextureReplacer::PopulateLevel(ReplacedTextureLevel &level) { +bool TextureReplacer::PopulateLevel(ReplacedTextureLevel &level, bool ignoreError) { bool good = false; FILE *fp = File::OpenCFile(level.file, "rb"); if (!fp) { - ERROR_LOG(G3D, "Error opening replacement texture file '%s'", level.file.c_str()); + if (!ignoreError) + ERROR_LOG(G3D, "Error opening replacement texture file '%s'", level.file.c_str()); return false; } diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index f64c9d9b7f..62aceee7fa 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -241,7 +241,7 @@ protected: std::string LookupHashFile(u64 cachekey, u32 hash, int level); std::string HashName(u64 cachekey, u32 hash, int level); void PopulateReplacement(ReplacedTexture *result, u64 cachekey, u32 hash, int w, int h); - bool PopulateLevel(ReplacedTextureLevel &level); + bool PopulateLevel(ReplacedTextureLevel &level, bool ignoreError); bool enabled_ = false; bool allowVideo_ = false; From 0048dc2bb8a76abc1c33bca12dcdc3f002d7ab8c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 08:54:52 -0700 Subject: [PATCH 307/374] Replacement: Cache file data across cache keys. --- Core/TextureReplacer.cpp | 34 +++++++++++++++++++++++++++------- Core/TextureReplacer.h | 32 +++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index bb854b3d92..b0a473f20e 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -441,6 +441,12 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, break; } + // Populate the level data pointers for each level. + result->levelData_.resize(result->levels_.size()); + for (size_t i = 0; i < result->levels_.size(); ++i) { + result->levelData_[i] = &levelCache_[result->levels_[i]]; + } + result->prepareDone_ = true; } @@ -836,8 +842,11 @@ bool ReplacedTexture::IsReady(double budget) { } // Loaded already, or not yet on a thread? - if (initDone_ && !levelData_.empty()) + if (initDone_ && !levelData_.empty()) { + for (auto &l : levelData_) + l->lastUsed = lastUsed_; return true; + } // Let's not even start a new texture if we're already behind. if (budget < 0.0) return false; @@ -871,7 +880,6 @@ void ReplacedTexture::Prepare() { return; } - levelData_.resize(levels_.size()); for (int i = 0; i < (int)levels_.size(); ++i) { if (cancelPrepare_) break; @@ -885,9 +893,14 @@ void ReplacedTexture::Prepare() { void ReplacedTexture::PrepareData(int level) { _assert_msg_((size_t)level < levels_.size(), "Invalid miplevel"); + _assert_msg_(levelData_[level] != nullptr, "Level cache not set for miplevel"); const ReplacedTextureLevel &info = levels_[level]; - std::vector &out = levelData_[level]; + std::vector &out = levelData_[level]->data; + + // Already populated from cache. + if (!out.empty()) + return; FILE *fp = File::OpenCFile(info.file, "rb"); if (!fp) { @@ -987,14 +1000,19 @@ size_t ReplacedTexture::PurgeIfOlder(double t) { return 0; if (lastUsed_ < t) { - levelData_.clear(); - initDone_ = false; + for (auto &l : levelData_) { + if (l->lastUsed < t) { + l->data.clear(); + // This means we have to reload. If we never purge any, there's no need. + initDone_ = false; + } + } return 0; } size_t s = 0; for (auto &l : levelData_) { - s += l.size(); + s += l->data.size(); } return s; } @@ -1018,8 +1036,10 @@ bool ReplacedTexture::Load(int level, void *out, int rowPitch) { if (levelData_.empty()) return false; + _assert_msg_(levelData_[level] != nullptr, "Level cache not set for miplevel"); + const ReplacedTextureLevel &info = levels_[level]; - const std::vector &data = levelData_[level]; + const std::vector &data = levelData_[level]->data; if (data.empty()) return false; diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index 62aceee7fa..347e987f16 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -17,11 +17,13 @@ #pragma once +#include "ppsspp_config.h" #include #include #include #include +#include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/MemoryUtil.h" #include "Common/File/Path.h" @@ -54,6 +56,33 @@ struct ReplacedTextureLevel { int h; Draw::DataFormat fmt; // NOTE: Right now, the only supported format is Draw::DataFormat::R8G8B8A8_UNORM. Path file; + + bool operator ==(const ReplacedTextureLevel &other) const { + if (w != other.w || h != other.h || fmt != other.fmt) + return false; + return file == other.file; + } +}; + +namespace std { + template <> + struct hash { + std::size_t operator()(const ReplacedTextureLevel &k) const { +#if PPSSPP_ARCH(64BIT) + uint64_t v = (uint64_t)k.w | ((uint64_t)k.h << 32); + v = __rotl64(v ^ (uint64_t)k.fmt, 13); +#else + uint32_t v = k.w ^ (uint32_t)k.fmt; + v = __rotl(__rotl(v, 13) ^ k.h, 13); +#endif + return v ^ hash()(k.file.ToString()); + } + }; +} + +struct ReplacedLevelCache { + std::vector data; + double lastUsed = 0.0; }; struct ReplacementCacheKey { @@ -170,7 +199,7 @@ protected: size_t PurgeIfOlder(double t); std::vector levels_; - std::vector> levelData_; + std::vector levelData_; ReplacedTextureAlpha alphaStatus_ = ReplacedTextureAlpha::UNKNOWN; double lastUsed_ = 0.0; LimitedWaitable *threadWaitable_ = nullptr; @@ -263,4 +292,5 @@ protected: ReplacedTexture none_; std::unordered_map cache_; std::unordered_map> savedCache_; + std::unordered_map levelCache_; }; From b1a087345a818f5c0a0da851f04d7648f2d01fdb Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 10:39:28 -0700 Subject: [PATCH 308/374] Replacement: Lock around shared data access. --- Core/TextureReplacer.cpp | 9 +++++++++ Core/TextureReplacer.h | 1 + 2 files changed, 10 insertions(+) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index b0a473f20e..d70e03919b 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -895,6 +895,9 @@ void ReplacedTexture::PrepareData(int level) { _assert_msg_((size_t)level < levels_.size(), "Invalid miplevel"); _assert_msg_(levelData_[level] != nullptr, "Level cache not set for miplevel"); + // We must lock around access to levelData_ in case two textures try to load it at once. + std::lock_guard guard(levelData_[level]->lock); + const ReplacedTextureLevel &info = levels_[level]; std::vector &out = levelData_[level]->data; @@ -1002,6 +1005,8 @@ size_t ReplacedTexture::PurgeIfOlder(double t) { if (lastUsed_ < t) { for (auto &l : levelData_) { if (l->lastUsed < t) { + // We have to lock since multiple textures might reference this same data. + std::lock_guard guard(l->lock); l->data.clear(); // This means we have to reload. If we never purge any, there's no need. initDone_ = false; @@ -1012,6 +1017,7 @@ size_t ReplacedTexture::PurgeIfOlder(double t) { size_t s = 0; for (auto &l : levelData_) { + std::lock_guard guard(l->lock); s += l->data.size(); } return s; @@ -1038,6 +1044,9 @@ bool ReplacedTexture::Load(int level, void *out, int rowPitch) { _assert_msg_(levelData_[level] != nullptr, "Level cache not set for miplevel"); + // We probably could avoid this lock, but better to play it safe. + std::lock_guard guard(levelData_[level]->lock); + const ReplacedTextureLevel &info = levels_[level]; const std::vector &data = levelData_[level]->data; diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index 347e987f16..b306b09182 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -81,6 +81,7 @@ namespace std { } struct ReplacedLevelCache { + std::mutex lock; std::vector data; double lastUsed = 0.0; }; From c89823ce9219ae107494016abe28b21a546a9901 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 10:34:25 -0700 Subject: [PATCH 309/374] Replacement: Allow use of textures.zip for Android. Will work on all platforms, but intended for situations like Android where random access to files on storage is horribly slow. --- Core/TextureReplacer.cpp | 277 ++++++++++++++++++++++++++++++++++----- Core/TextureReplacer.h | 10 +- ext/libzip/config.h | 4 +- 3 files changed, 256 insertions(+), 35 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index d70e03919b..6c6e78d579 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -21,6 +21,11 @@ #include #include #include +#ifdef SHARED_LIBZIP +#include +#else +#include "ext/libzip/zip.h" +#endif #include "ext/xxhash.h" @@ -44,6 +49,7 @@ #include "GPU/Common/TextureDecoder.h" static const std::string INI_FILENAME = "textures.ini"; +static const std::string ZIP_FILENAME = "textures.zip"; static const std::string NEW_TEXTURE_DIR = "new/"; static const int VERSION = 1; static const int MAX_MIP_LEVELS = 12; // 12 should be plenty, 8 is the max mip levels supported by the PSP. @@ -55,6 +61,8 @@ TextureReplacer::TextureReplacer() { } TextureReplacer::~TextureReplacer() { + if (zip_) + zip_close(zip_); } void TextureReplacer::Init() { @@ -79,6 +87,9 @@ void TextureReplacer::NotifyConfigChanged() { enabled_ = File::IsDirectory(basePath_); } else if (wasEnabled) { + if (zip_) + zip_close(zip_); + zip_ = nullptr; Decimate(ReplacerDecimateMode::ALL); } @@ -87,6 +98,44 @@ void TextureReplacer::NotifyConfigChanged() { } } +static struct zip *ZipOpenPath(Path fileName) { + int error = 0; + if (fileName.Type() == PathType::CONTENT_URI) { + int fd = File::OpenFD(fileName, File::OPEN_READ); + return zip_fdopen(fd, 0, &error); + } + return zip_open(fileName.c_str(), 0, &error); +} + +static constexpr zip_uint64_t INVALID_ZIP_SIZE = 0xFFFFFFFFFFFFFFFFULL; +static zip_uint64_t ZipFileSize(zip *z, zip_int64_t i) { + zip_stat_t zstat; + if (zip_stat_index(z, i, 0, &zstat) != 0) + return INVALID_ZIP_SIZE; + if ((zstat.valid & ZIP_STAT_SIZE) == 0) + return INVALID_ZIP_SIZE; + return zstat.size; +} + +static bool LoadIniZip(IniFile &ini, zip *z, const std::string &filename) { + zip_int64_t i = zip_name_locate(z, filename.c_str(), ZIP_FL_NOCASE); + if (i < 0) + return false; + + std::string inistr; + zip_uint64_t sz = ZipFileSize(z, i); + if (sz == INVALID_ZIP_SIZE) + return false; + inistr.resize(sz); + + zip_file_t *zf = zip_fopen_index(z, i, 0); + inistr.resize(zip_fread(zf, &inistr[0], inistr.size())); + zip_fclose(zf); + + std::stringstream sstream(inistr); + return ini.Load(sstream); +} + bool TextureReplacer::LoadIni() { // TODO: Use crc32c? hash_ = ReplacedTextureHash::QUICK; @@ -102,8 +151,32 @@ bool TextureReplacer::LoadIni() { // Prevents dumping the mipmaps. ignoreMipmap_ = false; + if (zip_) + zip_close(zip_); + zip_ = nullptr; + IniFile ini; - if (ini.LoadFromVFS((basePath_ / INI_FILENAME).ToString())) { + bool iniLoaded = false; + + // First, check for textures.zip, which is used to reduce IO. + zip *z = ZipOpenPath(basePath_ / ZIP_FILENAME); + if (z) { + iniLoaded = LoadIniZip(ini, z, INI_FILENAME); + // Require the zip have textures.ini to use it. + if (iniLoaded) { + iniLoaded = true; + zip_ = z; + } else { + zip_close(z); + z = nullptr; + } + } + + if (!iniLoaded) { + iniLoaded = ini.LoadFromVFS((basePath_ / INI_FILENAME).ToString()); + } + + if (iniLoaded) { if (!LoadIniValues(ini)) { return false; } @@ -113,7 +186,11 @@ bool TextureReplacer::LoadIni() { if (ini.GetOrCreateSection("games")->Get(gameID_.c_str(), &overrideFilename, "")) { if (!overrideFilename.empty() && overrideFilename != INI_FILENAME) { IniFile overrideIni; - if (!overrideIni.LoadFromVFS((basePath_ / overrideFilename).ToString())) { + if (zip_) + iniLoaded = LoadIniZip(overrideIni, zip_, overrideFilename); + else + iniLoaded = overrideIni.LoadFromVFS((basePath_ / overrideFilename).ToString()); + if (!iniLoaded) { ERROR_LOG(G3D, "Failed to load extra texture ini: %s", overrideFilename.c_str()); return false; } @@ -420,7 +497,16 @@ void TextureReplacer::PopulateReplacement(ReplacedTexture *result, u64 cachekey, ReplacedTextureLevel level; level.fmt = Draw::DataFormat::R8G8B8A8_UNORM; level.file = filename; - bool good = PopulateLevel(level, hashfile == HashName(cachekey, hash, i) + ".png"); + + bool good; + bool logError = hashfile != HashName(cachekey, hash, i) + ".png"; + if (zip_) { + level.z = zip_; + level.zi = zip_name_locate(zip_, hashfile.c_str(), ZIP_FL_NOCASE); + good = PopulateLevelFromZip(level, !logError); + } else { + good = PopulateLevelFromPath(level, !logError); + } // We pad files that have been hashrange'd so they are the same texture size. level.w = (level.w * w) / newW; @@ -456,12 +542,7 @@ enum class ReplacedImageType { INVALID, }; -static ReplacedImageType Identify(FILE *fp) { - uint8_t magic[4]; - if (fread(magic, 1, 4, fp) != 4) - return ReplacedImageType::INVALID; - rewind(fp); - +static ReplacedImageType Identify(const uint8_t magic[4]) { if (strncmp((const char *)magic, "ZIMG", 4) == 0) return ReplacedImageType::ZIM; if (magic[0] == 0x89 && strncmp((const char *)&magic[1], "PNG", 3) == 0) @@ -469,7 +550,24 @@ static ReplacedImageType Identify(FILE *fp) { return ReplacedImageType::INVALID; } -bool TextureReplacer::PopulateLevel(ReplacedTextureLevel &level, bool ignoreError) { +static ReplacedImageType Identify(FILE *fp) { + uint8_t magic[4]; + if (fread(magic, 1, 4, fp) != 4) + return ReplacedImageType::INVALID; + rewind(fp); + + return Identify(magic); +} + +static ReplacedImageType Identify(zip_file_t *zf) { + uint8_t magic[4]; + if (zip_fread(zf, magic, 4) != 4) + return ReplacedImageType::INVALID; + + return Identify(magic); +} + +bool TextureReplacer::PopulateLevelFromPath(ReplacedTextureLevel &level, bool ignoreError) { bool good = false; FILE *fp = File::OpenCFile(level.file, "rb"); @@ -508,6 +606,62 @@ bool TextureReplacer::PopulateLevel(ReplacedTextureLevel &level, bool ignoreErro return good; } +bool TextureReplacer::PopulateLevelFromZip(ReplacedTextureLevel &level, bool ignoreError) { + bool good = false; + + if (!level.z || level.zi < 0) { + if (!ignoreError) + ERROR_LOG(G3D, "Error opening replacement texture file '%s' in textures.zip", level.file.c_str()); + return false; + } + + zip_file_t *zf = zip_fopen_index(level.z, level.zi, 0); + if (!zf) + return false; + + auto imageType = Identify(zf); + zip_fclose(zf); + + zf = zip_fopen_index(level.z, level.zi, 0); + if (imageType == ReplacedImageType::ZIM) { + uint32_t ignore = 0; + good = zip_fread(zf, &ignore, 4) == 4; + good = good && zip_fread(zf, &level.w, 4) == 4; + good = good && zip_fread(zf, &level.h, 4) == 4; + int flags; + if (good && zip_fread(zf, &flags, 4) == 4) { + good = (flags & ZIM_FORMAT_MASK) == ZIM_RGBA8888; + } + } else if (imageType == ReplacedImageType::PNG) { + png_image png = {}; + png.version = PNG_IMAGE_VERSION; + + // TODO: Use some way to stream data into libpng. Better than the IO lookups on Android... + zip_uint64_t zsize = ZipFileSize(level.z, level.zi); + std::string pngdata; + if (zsize != INVALID_ZIP_SIZE) + pngdata.resize(zsize); + if (!pngdata.empty()) { + pngdata.resize(zip_fread(zf, pngdata.data(), pngdata.size())); + } + + if (png_image_begin_read_from_memory(&png, pngdata.data(), pngdata.size())) { + // We pad files that have been hashrange'd so they are the same texture size. + level.w = png.width; + level.h = png.height; + good = true; + } else { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s (zip)", level.file.ToVisualString().c_str(), png.message); + } + png_image_free(&png); + } else { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - unsupported format (zip)", level.file.ToVisualString().c_str()); + } + zip_fclose(zf); + + return good; +} + static bool WriteTextureToPNG(png_imagep image, const Path &filename, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap) { FILE *fp = File::OpenCFile(filename, "wb"); if (!fp) { @@ -905,35 +1059,75 @@ void ReplacedTexture::PrepareData(int level) { if (!out.empty()) return; - FILE *fp = File::OpenCFile(info.file, "rb"); - if (!fp) { - // Leaving the data sized at zero means failure. - return; - } + FILE *fp = nullptr; + zip_file_t *zf = nullptr; + ReplacedImageType imageType; + if (info.z) { + zf = zip_fopen_index(info.z, info.zi, 0); + if (!zf) + return; - auto imageType = Identify(fp); - if (imageType == ReplacedImageType::ZIM) { - size_t zimSize = File::GetFileSize(fp); - std::unique_ptr zim(new uint8_t[zimSize]); - if (!zim) { - ERROR_LOG(G3D, "Failed to allocate memory for texture replacement"); - fclose(fp); + imageType = Identify(zf); + // Can't assume we can seek. Reopen. + zip_fclose(zf); + zf = zip_fopen_index(info.z, info.zi, 0); + } else { + fp = File::OpenCFile(info.file, "rb"); + if (!fp) { + // Leaving the data sized at zero means failure. return; } - if (fread(&zim[0], 1, zimSize, fp) != zimSize) { - ERROR_LOG(G3D, "Could not load texture replacement: %s - failed to read ZIM", info.file.c_str()); + imageType = Identify(fp); + } + + auto cleanup = [&] { + if (zf) + zip_fclose(zf); + if (fp) fclose(fp); + }; + + if (imageType == ReplacedImageType::ZIM) { + size_t zimSize; + if (fp) { + zimSize = File::GetFileSize(fp); + } else if (zf) { + zip_uint64_t zsize = ZipFileSize(info.z, info.zi); + zimSize = zsize == INVALID_ZIP_SIZE ? 0 : (size_t)zsize; + } else { + _assert_(false); + } + std::unique_ptr zim(new uint8_t[zimSize]); + if (!zim) { + ERROR_LOG(G3D, "Failed to allocate memory for texture replacement"); + cleanup(); return; } + if (fp) { + if (fread(&zim[0], 1, zimSize, fp) != zimSize) { + ERROR_LOG(G3D, "Could not load texture replacement: %s - failed to read ZIM", info.file.c_str()); + cleanup(); + return; + } + } else if (zf) { + if (zip_fread(zf, &zim[0], zimSize) != zimSize) { + ERROR_LOG(G3D, "Could not load texture replacement: %s - failed to read ZIM (zip)", info.file.c_str()); + cleanup(); + return; + } + } else { + _assert_(false); + } + int w, h, f; uint8_t *image; if (LoadZIMPtr(&zim[0], zimSize, &w, &h, &f, &image)) { if (w > info.w || h > info.h) { ERROR_LOG(G3D, "Texture replacement changed since header read: %s", info.file.c_str()); - fclose(fp); + cleanup(); return; } @@ -956,14 +1150,33 @@ void ReplacedTexture::PrepareData(int level) { png_image png = {}; png.version = PNG_IMAGE_VERSION; - if (!png_image_begin_read_from_stdio(&png, fp)) { - ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s", info.file.c_str(), png.message); - fclose(fp); - return; + // Needs to survive for a little while, used for zip only. + std::string pngdata; + if (fp) { + if (!png_image_begin_read_from_stdio(&png, fp)) { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s", info.file.c_str(), png.message); + cleanup(); + return; + } + } else if (zf) { + zip_uint64_t zsize = ZipFileSize(info.z, info.zi); + if (zsize != INVALID_ZIP_SIZE) + pngdata.resize(zsize); + if (!pngdata.empty()) { + pngdata.resize(zip_fread(zf, pngdata.data(), pngdata.size())); + } + + if (!png_image_begin_read_from_memory(&png, pngdata.data(), pngdata.size())) { + ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s (zip)", info.file.c_str(), png.message); + cleanup(); + return; + } + } else { + _assert_(false); } if (png.width > (uint32_t)info.w || png.height > (uint32_t)info.h) { ERROR_LOG(G3D, "Texture replacement changed since header read: %s", info.file.c_str()); - fclose(fp); + cleanup(); return; } @@ -980,7 +1193,7 @@ void ReplacedTexture::PrepareData(int level) { out.resize(info.w * info.h * 4); if (!png_image_finish_read(&png, nullptr, &out[0], info.w * 4, nullptr)) { ERROR_LOG(G3D, "Could not load texture replacement: %s - %s", info.file.c_str(), png.message); - fclose(fp); + cleanup(); out.resize(0); return; } @@ -995,7 +1208,7 @@ void ReplacedTexture::PrepareData(int level) { } } - fclose(fp); + cleanup(); } size_t ReplacedTexture::PurgeIfOlder(double t) { diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index b306b09182..05d1488851 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -37,6 +37,7 @@ class TextureCacheCommon; class TextureReplacer; class ReplacedTextureTask; class LimitedWaitable; +struct zip; // These must match the constants in TextureCacheCommon. enum class ReplacedTextureAlpha { @@ -56,6 +57,10 @@ struct ReplacedTextureLevel { int h; Draw::DataFormat fmt; // NOTE: Right now, the only supported format is Draw::DataFormat::R8G8B8A8_UNORM. Path file; + // Can be ignored for hashing/equal, since file has all uniqueness. + // To be able to reload, we need to be able to reopen, unfortunate we can't use zip_file_t. + zip *z = nullptr; + int64_t zi = -1; bool operator ==(const ReplacedTextureLevel &other) const { if (w != other.w || h != other.h || fmt != other.fmt) @@ -271,7 +276,8 @@ protected: std::string LookupHashFile(u64 cachekey, u32 hash, int level); std::string HashName(u64 cachekey, u32 hash, int level); void PopulateReplacement(ReplacedTexture *result, u64 cachekey, u32 hash, int w, int h); - bool PopulateLevel(ReplacedTextureLevel &level, bool ignoreError); + bool PopulateLevelFromPath(ReplacedTextureLevel &level, bool ignoreError); + bool PopulateLevelFromZip(ReplacedTextureLevel &level, bool ignoreError); bool enabled_ = false; bool allowVideo_ = false; @@ -284,6 +290,8 @@ protected: std::string gameID_; Path basePath_; ReplacedTextureHash hash_ = ReplacedTextureHash::QUICK; + zip *zip_ = nullptr; + typedef std::pair WidthHeightPair; std::unordered_map hashranges_; std::unordered_map reducehashranges_; diff --git a/ext/libzip/config.h b/ext/libzip/config.h index a5d26ea015..77c373b611 100644 --- a/ext/libzip/config.h +++ b/ext/libzip/config.h @@ -27,11 +27,11 @@ #endif #ifndef MS_UWP #define HAVE_FILENO -#define HAVE_FSEEKO -#define HAVE_FTELLO #define HAVE_GETPROGNAME #endif #ifndef _WIN32 +#define HAVE_FSEEKO +#define HAVE_FTELLO #define HAVE_LOCALTIME_R #define HAVE_MKSTEMP 1 #endif From a1a484163f1b13298c4aa5c772f3bf1805eb3cb8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 10:44:33 -0700 Subject: [PATCH 310/374] Replacement: Don't double count memory usage. --- Core/TextureReplacer.cpp | 39 ++++++++++++++++++--------------------- Core/TextureReplacer.h | 3 +-- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index 6c6e78d579..a234ada347 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -847,9 +847,14 @@ void TextureReplacer::Decimate(ReplacerDecimateMode mode) { } const double threshold = time_now_d() - age; - size_t totalSize = 0; for (auto &item : cache_) { - totalSize += item.second.PurgeIfOlder(threshold); + item.second.PurgeIfOlder(threshold); + } + + size_t totalSize = 0; + for (auto &item : levelCache_) { + std::lock_guard guard(item.second.lock); + totalSize += item.second.data.size(); } double totalSizeGB = totalSize / (1024.0 * 1024.0 * 1024.0); @@ -1211,29 +1216,21 @@ void ReplacedTexture::PrepareData(int level) { cleanup(); } -size_t ReplacedTexture::PurgeIfOlder(double t) { +void ReplacedTexture::PurgeIfOlder(double t) { if (threadWaitable_ && !threadWaitable_->WaitFor(0.0)) - return 0; + return; + if (lastUsed_ >= t) + return; - if (lastUsed_ < t) { - for (auto &l : levelData_) { - if (l->lastUsed < t) { - // We have to lock since multiple textures might reference this same data. - std::lock_guard guard(l->lock); - l->data.clear(); - // This means we have to reload. If we never purge any, there's no need. - initDone_ = false; - } - } - return 0; - } - - size_t s = 0; for (auto &l : levelData_) { - std::lock_guard guard(l->lock); - s += l->data.size(); + if (l->lastUsed < t) { + // We have to lock since multiple textures might reference this same data. + std::lock_guard guard(l->lock); + l->data.clear(); + // This means we have to reload. If we never purge any, there's no need. + initDone_ = false; + } } - return s; } ReplacedTexture::~ReplacedTexture() { diff --git a/Core/TextureReplacer.h b/Core/TextureReplacer.h index 05d1488851..4fb5bf5224 100644 --- a/Core/TextureReplacer.h +++ b/Core/TextureReplacer.h @@ -201,8 +201,7 @@ struct ReplacedTexture { protected: void Prepare(); void PrepareData(int level); - // Returns size of data not purged. - size_t PurgeIfOlder(double t); + void PurgeIfOlder(double t); std::vector levels_; std::vector levelData_; From 56ff555309ac740d8b6c70eae5a8be8f8c3eaae3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 21:12:59 -0700 Subject: [PATCH 311/374] irjit: Fix unordered float compares. --- Core/MIPS/IR/IRCompALU.cpp | 4 ++-- Core/MIPS/IR/IRCompFPU.cpp | 2 +- Core/MIPS/IR/IRCompVFPU.cpp | 1 + Core/MIPS/IR/IRInterpreter.cpp | 12 +++++++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Core/MIPS/IR/IRCompALU.cpp b/Core/MIPS/IR/IRCompALU.cpp index 62d813f3b2..e8fe1c46b6 100644 --- a/Core/MIPS/IR/IRCompALU.cpp +++ b/Core/MIPS/IR/IRCompALU.cpp @@ -118,7 +118,7 @@ void IRFrontend::Comp_RType3(MIPSOpcode op) { MIPSGPReg rd = _RD; // noop, won't write to ZERO. - if (rd == 0) + if (rd == MIPS_REG_ZERO) return; switch (op & 63) { @@ -298,7 +298,7 @@ void IRFrontend::Comp_Allegrex2(MIPSOpcode op) { MIPSGPReg rd = _RD; // Don't change $zr. - if (rd == 0) + if (rd == MIPS_REG_ZERO) return; switch (op & 0x3ff) { diff --git a/Core/MIPS/IR/IRCompFPU.cpp b/Core/MIPS/IR/IRCompFPU.cpp index c0aac3f3f1..cf6b4faa75 100644 --- a/Core/MIPS/IR/IRCompFPU.cpp +++ b/Core/MIPS/IR/IRCompFPU.cpp @@ -118,7 +118,7 @@ void IRFrontend::Comp_FPUComp(MIPSOpcode op) { break; case 3: // ueq, ngl (equal, unordered) mode = IRFpCompareMode::EqualUnordered; - return; + break; case 4: // olt, lt (less than, ordered) mode = IRFpCompareMode::LessOrdered; break; diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 4694986cf7..92b1171692 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -464,6 +464,7 @@ namespace MIPSComp { init = Vec4Init::AllONE; break; default: + INVALIDOP; return; } ir.Write(IROp::Vec4Init, vec[0], (int)init); diff --git a/Core/MIPS/IR/IRInterpreter.cpp b/Core/MIPS/IR/IRInterpreter.cpp index 27b0ba0ca3..da1e643888 100644 --- a/Core/MIPS/IR/IRInterpreter.cpp +++ b/Core/MIPS/IR/IRInterpreter.cpp @@ -881,17 +881,23 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) { break; } case IRFpCompareMode::EqualOrdered: - case IRFpCompareMode::EqualUnordered: mips->fpcond = mips->f[inst->src1] == mips->f[inst->src2]; break; + case IRFpCompareMode::EqualUnordered: + mips->fpcond = mips->f[inst->src1] == mips->f[inst->src2] || my_isnan(mips->f[inst->src1]) || my_isnan(mips->f[inst->src2]); + break; case IRFpCompareMode::LessEqualOrdered: - case IRFpCompareMode::LessEqualUnordered: mips->fpcond = mips->f[inst->src1] <= mips->f[inst->src2]; break; + case IRFpCompareMode::LessEqualUnordered: + mips->fpcond = !(mips->f[inst->src1] > mips->f[inst->src2]); + break; case IRFpCompareMode::LessOrdered: - case IRFpCompareMode::LessUnordered: mips->fpcond = mips->f[inst->src1] < mips->f[inst->src2]; break; + case IRFpCompareMode::LessUnordered: + mips->fpcond = !(mips->f[inst->src1] >= mips->f[inst->src2]); + break; } break; From 2da1bf7ffc564c7ff62e05e98ad8b5662a18318f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 21:47:28 -0700 Subject: [PATCH 312/374] interp: Correct dprefix accuracy for vrot. Ignores cosine lane, not always x. --- Core/MIPS/MIPSIntVFPU.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index bc1120921e..1b2c8d60ec 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -1629,8 +1629,9 @@ namespace MIPSInt d[cosineLane] = cosine; } - // D prefix works, just not for x. - currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] &= 0xFFEFC; + // D prefix works, just not for the cosine lane. + uint32_t dprefixRemove = (3 << cosineLane) | (1 << (8 + cosineLane)); + currentMIPS->vfpuCtrl[VFPU_CTRL_DPREFIX] &= 0xFFFFF ^ dprefixRemove; ApplyPrefixD(d, sz); WriteVector(d, sz, vd); PC += 4; From eef29d5e952a4af88a9c039e7129b08e89d39484 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 22:34:41 -0700 Subject: [PATCH 313/374] irjit: Correct prefix validation. Some vcmps, etc. were perfectly valid but were forcing to interp. This also catches more cases that should go to interp correctly. --- Core/MIPS/IR/IRCompVFPU.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Core/MIPS/IR/IRCompVFPU.cpp b/Core/MIPS/IR/IRCompVFPU.cpp index 4694986cf7..cd17e5b7b9 100644 --- a/Core/MIPS/IR/IRCompVFPU.cpp +++ b/Core/MIPS/IR/IRCompVFPU.cpp @@ -117,8 +117,9 @@ namespace MIPSComp { int abs = (prefix >> (8 + i)) & 1; int negate = (prefix >> (16 + i)) & 1; int constants = (prefix >> (12 + i)) & 1; - if (regnum < n || abs || negate || constants) { - return false; + if (regnum >= n && !constants) { + if (abs || negate || regnum != i) + return false; } } @@ -472,7 +473,7 @@ namespace MIPSComp { void IRFrontend::Comp_VHdp(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) { + if (js.HasUnknownPrefix() || js.HasSPrefix() || !IsPrefixWithinSize(js.prefixT, op)) { DISABLE; } @@ -754,8 +755,15 @@ namespace MIPSComp { void IRFrontend::Comp_VV2Op(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) - DISABLE; + int optype = (op >> 16) & 0x1f; + if (optype == 0) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op)) + DISABLE; + } else { + // Many of these apply the D prefix strangely or override parts of the S prefix. + if (!js.HasNoPrefix()) + DISABLE; + } // Vector unary operation // d[N] = OP(s[N]) (see below) @@ -763,7 +771,6 @@ namespace MIPSComp { int vs = _VS; int vd = _VD; - int optype = (op >> 16) & 0x1f; if (optype >= 16 && !js.HasNoPrefix()) { DISABLE; } else if ((optype == 1 || optype == 2) && js.HasSPrefix()) { @@ -1458,7 +1465,7 @@ namespace MIPSComp { void IRFrontend::Comp_VDet(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || (js.prefixT & 0x000CFCF0) != 0x000E0) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix()) { DISABLE; } @@ -1903,7 +1910,7 @@ namespace MIPSComp { void IRFrontend::Comp_Vsgn(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || !IsPrefixWithinSize(js.prefixT, op)) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix()) { DISABLE; } @@ -1999,7 +2006,7 @@ namespace MIPSComp { void IRFrontend::Comp_Vbfy(MIPSOpcode op) { CONDITIONAL_DISABLE(VFPU_VEC); - if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix()) { + if (js.HasUnknownPrefix() || !IsPrefixWithinSize(js.prefixS, op) || js.HasTPrefix() || (js.prefixS & VFPU_NEGATE(1, 1, 1, 1)) != 0) { DISABLE; } From b740bfbcfb67a724f84893c34eba74a1c09a7e07 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 31 Oct 2022 11:59:07 +0100 Subject: [PATCH 314/374] OpenXR - Map controller motions on keys --- Common/Input/KeyCodes.h | 9 +++++++- Common/VR/PPSSPPVR.cpp | 51 +++++++++++++++++++++++++++++++++++++++++ Core/KeyMap.cpp | 7 ++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/Common/Input/KeyCodes.h b/Common/Input/KeyCodes.h index f00dbe8091..15f42c07c1 100644 --- a/Common/Input/KeyCodes.h +++ b/Common/Input/KeyCodes.h @@ -261,7 +261,14 @@ typedef enum _keycode_t { NKCODE_EXT_MOUSEBUTTON_4 = 1006, NKCODE_EXT_MOUSEBUTTON_5 = 1007, NKCODE_EXT_MOUSEWHEEL_UP = 1008, - NKCODE_EXT_MOUSEWHEEL_DOWN = 1009 + NKCODE_EXT_MOUSEWHEEL_DOWN = 1009, + + // Virtual reality controller motion + NKCODE_EXT_MOTION_UP = 1101, + NKCODE_EXT_MOTION_DOWN = 1102, + NKCODE_EXT_MOTION_LEFT = 1103, + NKCODE_EXT_MOTION_RIGHT = 1104, + NKCODE_EXT_MOTION_FORWARD = 1105, } keycode_t; enum AndroidJoystickAxis { diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 0c496d55e0..8c3ae30169 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -78,6 +78,7 @@ static std::vector controllerMapping[2] = { leftControllerMapping, rightControllerMapping }; +static bool controllerMotion[2][5]; static int mouseController = -1; static bool mousePressed[] = {false, false}; @@ -203,6 +204,56 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con } } + //motion control + bool activate; + for (int j = 0; j < 2; j++) { + float limit = 0.5f; //length of needed movement in meters + XrVector3f axis = {0, 1, 0}; + float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); + XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); + XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position); + + //up + activate = position.y > limit; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_UP; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][0] != activate) NativeKey(keyInput); + controllerMotion[j][0] = activate; + + //down + activate = position.y < -limit * 1.5f; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_DOWN; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][1] != activate) NativeKey(keyInput); + controllerMotion[j][1] = activate; + + //left + activate = position.x < -limit * (j == 0 ? 1.0f : 0.25f); + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_LEFT; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][2] != activate) NativeKey(keyInput); + controllerMotion[j][2] = activate; + + //right + activate = position.x > limit * (j == 1 ? 1.0f : 0.25f); + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][3] != activate) NativeKey(keyInput); + controllerMotion[j][3] = activate; + + //forward + activate = position.z < -limit; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][4] != activate) NativeKey(keyInput); + controllerMotion[j][4] = activate; + } + //mouse cursor if (mouseController >= 0) { //get position on screen diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index 30b005d86f..0be4dd7182 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -304,6 +304,13 @@ static const KeyMap_IntStrPair key_names[] = { {NKCODE_EXT_MOUSEWHEEL_UP, "MWheelU"}, {NKCODE_EXT_MOUSEWHEEL_DOWN, "MWheelD"}, + + {NKCODE_EXT_MOTION_UP, "MotionUp"}, + {NKCODE_EXT_MOTION_DOWN, "MotionDown"}, + {NKCODE_EXT_MOTION_LEFT, "MotionLeft"}, + {NKCODE_EXT_MOTION_RIGHT, "MotionRight"}, + {NKCODE_EXT_MOTION_FORWARD, "MotionFwd"}, + {NKCODE_START_QUESTION, "¿"}, {NKCODE_LEFTBRACE, "{"}, {NKCODE_RIGHTBRACE, "}"}, From 0101c464a5f3090fd21a2cdde5eefd56ccf5c585 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 31 Oct 2022 12:17:30 +0100 Subject: [PATCH 315/374] OpenXR - Option to disable controller mapping --- Common/VR/PPSSPPVR.cpp | 86 ++++++++++++++++++++------------------- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 2 + 4 files changed, 48 insertions(+), 42 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 8c3ae30169..4c85590107 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -205,53 +205,55 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con } //motion control - bool activate; - for (int j = 0; j < 2; j++) { - float limit = 0.5f; //length of needed movement in meters - XrVector3f axis = {0, 1, 0}; - float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); - XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); - XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position); + if (g_Config.bEnableMotions) { + for (int j = 0; j < 2; j++) { + bool activate; + float limit = 0.5f; //length of needed movement in meters + XrVector3f axis = {0, 1, 0}; + float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); + XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); + XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position); - //up - activate = position.y > limit; - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_UP; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][0] != activate) NativeKey(keyInput); - controllerMotion[j][0] = activate; + //up + activate = position.y > limit; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_UP; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][0] != activate) NativeKey(keyInput); + controllerMotion[j][0] = activate; - //down - activate = position.y < -limit * 1.5f; - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_DOWN; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][1] != activate) NativeKey(keyInput); - controllerMotion[j][1] = activate; + //down + activate = position.y < -limit * 1.5f; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_DOWN; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][1] != activate) NativeKey(keyInput); + controllerMotion[j][1] = activate; - //left - activate = position.x < -limit * (j == 0 ? 1.0f : 0.25f); - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_LEFT; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][2] != activate) NativeKey(keyInput); - controllerMotion[j][2] = activate; + //left + activate = position.x < -limit * (j == 0 ? 1.0f : 0.25f); + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_LEFT; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][2] != activate) NativeKey(keyInput); + controllerMotion[j][2] = activate; - //right - activate = position.x > limit * (j == 1 ? 1.0f : 0.25f); - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][3] != activate) NativeKey(keyInput); - controllerMotion[j][3] = activate; + //right + activate = position.x > limit * (j == 1 ? 1.0f : 0.25f); + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_RIGHT; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][3] != activate) NativeKey(keyInput); + controllerMotion[j][3] = activate; - //forward - activate = position.z < -limit; - keyInput.flags = activate ? KEY_DOWN : KEY_UP; - keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD; - keyInput.deviceId = controllerIds[j]; - if (controllerMotion[j][4] != activate) NativeKey(keyInput); - controllerMotion[j][4] = activate; + //forward + activate = position.z < -limit; + keyInput.flags = activate ? KEY_DOWN : KEY_UP; + keyInput.keyCode = NKCODE_EXT_MOTION_FORWARD; + keyInput.deviceId = controllerIds[j]; + if (controllerMotion[j][4] != activate) NativeKey(keyInput); + controllerMotion[j][4] = activate; + } } //mouse cursor diff --git a/Core/Config.cpp b/Core/Config.cpp index f62a4baaae..94f96d15ad 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1208,6 +1208,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable", &g_Config.bEnableVR, true), ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), + ConfigSetting("VREnableMotions", &g_Config.bEnableMotions, true), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), diff --git a/Core/Config.h b/Core/Config.h index a494cf4c61..3415cc55e0 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -463,6 +463,7 @@ public: bool bEnableVR; bool bEnable6DoF; bool bEnableStereo; + bool bEnableMotions; float fCameraDistance; float fCameraHeight; float fCameraSide; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 6b68d9c866..a7044d946f 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1163,6 +1163,8 @@ void GameSettingsScreen::CreateViews() { vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); vrStereo->SetEnabledPtr(&g_Config.bEnableVR); + CheckBox *vrMotions = vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys"))); + vrMotions->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); From 3c87e7117707e45f7f8c892a9f02c17ae7e9a83d Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 31 Oct 2022 13:19:06 +0100 Subject: [PATCH 316/374] OpenXR - Let users set the movement length --- Common/VR/PPSSPPVR.cpp | 2 +- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 9 ++++++--- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 4c85590107..a3b2506f88 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -208,7 +208,7 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con if (g_Config.bEnableMotions) { for (int j = 0; j < 2; j++) { bool activate; - float limit = 0.5f; //length of needed movement in meters + float limit = g_Config.fMotionLength; //length of needed movement in meters XrVector3f axis = {0, 1, 0}; float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); diff --git a/Core/Config.cpp b/Core/Config.cpp index 94f96d15ad..e3aa3a5707 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1214,6 +1214,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f), ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f), + ConfigSetting("VRMotionLength", &g_Config.fMotionLength, 0.5f), ConfigSetting(false), }; diff --git a/Core/Config.h b/Core/Config.h index 3415cc55e0..4f212646d3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -469,6 +469,7 @@ public: float fCameraSide; float fCanvasDistance; float fFieldOfViewPercentage; + float fMotionLength; // Debugger int iDisasmWindowX; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index a7044d946f..7fed6c3c18 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1163,15 +1163,18 @@ void GameSettingsScreen::CreateViews() { vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); vrStereo->SetEnabledPtr(&g_Config.bEnableVR); - CheckBox *vrMotions = vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys"))); - vrMotions->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust", "Camera height adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraSide, -10.0f, 10.0f, vr->T("Camera side adjust", "Camera side adjust"), 1.0f, screenManager(), "")); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Headset's field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); + + vrSettings->Add(new ItemHeader(vr->T("VR controllers"))); + vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys"))); + PopupSliderChoiceFloat *vrMotions = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMotionLength, 0.3f, 1.0f, vr->T("Motion needed to generate action", "Motion needed to generate action"), 0.1f, screenManager(), vr->T("m"))); + vrMotions->SetEnabledPtr(&g_Config.bEnableMotions); } } From 823bfae5eaaa074f83830ef0374316bf25e56fb5 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 31 Oct 2022 15:00:09 +0100 Subject: [PATCH 317/374] Memory initialization fixed --- Common/VR/PPSSPPVR.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index a3b2506f88..4dc3974761 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -78,7 +78,7 @@ static std::vector controllerMapping[2] = { leftControllerMapping, rightControllerMapping }; -static bool controllerMotion[2][5]; +static bool controllerMotion[2][5] = {}; static int mouseController = -1; static bool mousePressed[] = {false, false}; From d2a79f9ea3d1315ec0bfdd0ced799fad7dcd5089 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 31 Oct 2022 17:34:01 +0100 Subject: [PATCH 318/374] OpenXR - Workaround for not working inputbox --- android/src/org/ppsspp/ppsspp/NativeActivity.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/src/org/ppsspp/ppsspp/NativeActivity.java b/android/src/org/ppsspp/ppsspp/NativeActivity.java index 5de8a70b77..8727f39dc3 100644 --- a/android/src/org/ppsspp/ppsspp/NativeActivity.java +++ b/android/src/org/ppsspp/ppsspp/NativeActivity.java @@ -1235,6 +1235,12 @@ public abstract class NativeActivity extends Activity { // The return value is sent to C++ via seqID. public void inputBox(final String seqID, final String title, String defaultText, String defaultAction) { + // Workaround for issue #13363 to fix Split/Second game start + if (isVRDevice()) { + NativeApp.sendInputBox(seqID, false, defaultText); + return; + } + final FrameLayout fl = new FrameLayout(this); final EditText input = new EditText(this); input.setGravity(Gravity.CENTER); From a06c51b419cc6c7b648d530bfc14ec52fdef375a Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 31 Oct 2022 17:44:05 +0100 Subject: [PATCH 319/374] OpenXR - Enable stereo for Split/Second --- assets/compatvr.ini | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 79b1c04678..430fb80e47 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -1120,6 +1120,12 @@ ULJM05162 = 1.0 ULJM05599 = 1.0 ULUS10076 = 1.0 +# Split/Second +NPJH50371 = 10.0 +ULES01402 = 10.0 +ULJM05812 = 10.0 +ULUS10513 = 10.0 + # Spot the Differences! NPEZ00107 = 1.0 NPEZ00108 = 1.0 From 6105688c32a7944a51031ed74235fcaa1a9a72e5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 30 Oct 2022 12:18:43 -0700 Subject: [PATCH 320/374] UI: Install textures as a zip if supported. --- Core/Util/GameManager.cpp | 57 +++++++++++++++++++++++++++++++++++++++ Core/Util/GameManager.h | 1 + 2 files changed, 58 insertions(+) diff --git a/Core/Util/GameManager.cpp b/Core/Util/GameManager.cpp index e808f07b6c..63952a5d81 100644 --- a/Core/Util/GameManager.cpp +++ b/Core/Util/GameManager.cpp @@ -325,6 +325,9 @@ bool GameManager::InstallGame(Path url, Path fileName, bool deleteAfter) { if (DetectTexturePackDest(z, info.textureIniIndex, dest)) { INFO_LOG(HLE, "Installing '%s' into '%s'", fileName.c_str(), dest.c_str()); File::CreateFullPath(dest); + // Install as a zip file if textures.ini is in the root. Performs better on Android. + if (info.stripChars == 0) + return InstallMemstickZip(z, fileName, dest / "textures.zip", info, deleteAfter); File::CreateEmptyFile(dest / ".nomedia"); return InstallMemstickGame(z, fileName, dest, info, true, deleteAfter); } else { @@ -617,6 +620,60 @@ bail: return false; } +bool GameManager::InstallMemstickZip(struct zip *z, const Path &zipfile, const Path &dest, const ZipFileInfo &info, bool deleteAfter) { + size_t allBytes = 0; + size_t bytesCopied = 0; + + auto sy = GetI18NCategory("System"); + + // We don't need the zip anymore, as we're going to copy it as-is. + zip_close(z); + z = nullptr; + + // Not using File::Copy() so we can report progress. + FILE *inf = File::OpenCFile(zipfile, "rb"); + if (!inf) + return false; + + allBytes = (size_t)File::GetFileSize(inf); + FILE *outf = File::OpenCFile(dest, "wb"); + if (!outf) { + SetInstallError(sy->T("Storage full")); + fclose(inf); + return false; + } + + const size_t blockSize = 1024 * 128; + u8 *buffer = new u8[blockSize]; + while (bytesCopied < allBytes) { + size_t readSize = std::min(blockSize, allBytes - bytesCopied); + if (fread(buffer, readSize, 1, inf) != 1) + break; + if (fwrite(buffer, readSize, 1, outf) != 1) + break; + bytesCopied += readSize; + installProgress_ = (float)allBytes / (float)allBytes; + } + + delete[] buffer; + fclose(inf); + fclose(outf); + + if (bytesCopied < allBytes) { + File::Delete(dest); + SetInstallError(sy->T("Storage full")); + return false; + } + + installProgress_ = 1.0f; + if (deleteAfter) { + File::Delete(zipfile); + } + InstallDone(); + ResetInstallError(); + return true; +} + bool GameManager::InstallZippedISO(struct zip *z, int isoFileIndex, const Path &zipfile, bool deleteAfter) { // Let's place the output file in the currently selected Games directory. diff --git a/Core/Util/GameManager.h b/Core/Util/GameManager.h index df74af2fd7..f7fc8ff7b5 100644 --- a/Core/Util/GameManager.h +++ b/Core/Util/GameManager.h @@ -79,6 +79,7 @@ public: private: bool InstallGame(Path url, Path tempFileName, bool deleteAfter); bool InstallMemstickGame(struct zip *z, const Path &zipFile, const Path &dest, const ZipFileInfo &info, bool allowRoot, bool deleteAfter); + bool InstallMemstickZip(struct zip *z, const Path &zipFile, const Path &dest, const ZipFileInfo &info, bool deleteAfter); bool InstallZippedISO(struct zip *z, int isoFileIndex, const Path &zipfile, bool deleteAfter); bool InstallRawISO(const Path &zipFile, const std::string &originalName, bool deleteAfter); void InstallDone(); From 15645ca480044b5eec20bcf680e60ac3258b6224 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 31 Oct 2022 20:17:18 -0700 Subject: [PATCH 321/374] Replacement: Avoid issues with c++14 data(). --- Core/TextureReplacer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/TextureReplacer.cpp b/Core/TextureReplacer.cpp index a234ada347..dcd413ff2b 100644 --- a/Core/TextureReplacer.cpp +++ b/Core/TextureReplacer.cpp @@ -642,10 +642,10 @@ bool TextureReplacer::PopulateLevelFromZip(ReplacedTextureLevel &level, bool ign if (zsize != INVALID_ZIP_SIZE) pngdata.resize(zsize); if (!pngdata.empty()) { - pngdata.resize(zip_fread(zf, pngdata.data(), pngdata.size())); + pngdata.resize(zip_fread(zf, &pngdata[0], pngdata.size())); } - if (png_image_begin_read_from_memory(&png, pngdata.data(), pngdata.size())) { + if (png_image_begin_read_from_memory(&png, &pngdata[0], pngdata.size())) { // We pad files that have been hashrange'd so they are the same texture size. level.w = png.width; level.h = png.height; @@ -1168,10 +1168,10 @@ void ReplacedTexture::PrepareData(int level) { if (zsize != INVALID_ZIP_SIZE) pngdata.resize(zsize); if (!pngdata.empty()) { - pngdata.resize(zip_fread(zf, pngdata.data(), pngdata.size())); + pngdata.resize(zip_fread(zf, &pngdata[0], pngdata.size())); } - if (!png_image_begin_read_from_memory(&png, pngdata.data(), pngdata.size())) { + if (!png_image_begin_read_from_memory(&png, &pngdata[0], pngdata.size())) { ERROR_LOG(G3D, "Could not load texture replacement info: %s - %s (zip)", info.file.c_str(), png.message); cleanup(); return; From 67af5baf3ead3b7201c3b1c49bd93d342a466809 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 1 Nov 2022 10:08:43 +0100 Subject: [PATCH 322/374] OpenXR - Settings code cleanup --- UI/GameSettingsScreen.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 7fed6c3c18..a3195adfc5 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1165,15 +1165,15 @@ void GameSettingsScreen::CreateViews() { vrStereo->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust", "Camera height adjust"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraSide, -10.0f, 10.0f, vr->T("Camera side adjust", "Camera side adjust"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); - vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraSide, -10.0f, 10.0f, vr->T("Camera side adjust"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes"), 1.0f, screenManager(), "")); + vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV"))); vrSettings->Add(new ItemHeader(vr->T("VR controllers"))); vrSettings->Add(new CheckBox(&g_Config.bEnableMotions, vr->T("Map controller movements to keys"))); - PopupSliderChoiceFloat *vrMotions = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMotionLength, 0.3f, 1.0f, vr->T("Motion needed to generate action", "Motion needed to generate action"), 0.1f, screenManager(), vr->T("m"))); + PopupSliderChoiceFloat *vrMotions = vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMotionLength, 0.3f, 1.0f, vr->T("Motion needed to generate action"), 0.1f, screenManager(), vr->T("m"))); vrMotions->SetEnabledPtr(&g_Config.bEnableMotions); } } From 7967da0f6fb3806546acd6703fa6ce68614aa9b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 1 Nov 2022 13:43:48 +0100 Subject: [PATCH 323/374] Vulkan: Fix descriptor set binding in geometry shader generator. Should fix #16315 --- GPU/Common/GeometryShaderGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/GeometryShaderGenerator.cpp b/GPU/Common/GeometryShaderGenerator.cpp index 586afdca0f..1438cbb6f5 100644 --- a/GPU/Common/GeometryShaderGenerator.cpp +++ b/GPU/Common/GeometryShaderGenerator.cpp @@ -58,7 +58,7 @@ bool GenerateGeometryShader(const GShaderID &id, char *buffer, const ShaderLangu if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); - WRITE(p, "layout (std140, set = 0, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); + WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); } else if (compat.shaderLanguage == HLSL_D3D11) { WRITE(p, "cbuffer base : register(b0) {\n%s};\n", ub_baseStr); } From e7185f93b3f5f29d3bb379c615d080c332d148ef Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 1 Nov 2022 22:14:23 -0700 Subject: [PATCH 324/374] GE Debugger: Restrict marking of dirty VRAM better. --- GPU/Debugger/Record.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index 6058546b0f..f27464a48a 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -123,10 +123,10 @@ static void DirtyVRAM(u32 start, u32 sz, DirtyVRAMFlag flag) { } static void DirtyDrawnVRAM() { - int w = std::max(gstate.getScissorX2(), gstate.getRegionX2()) + 1; - int h = std::max(gstate.getScissorY2(), gstate.getRegionY2()) + 1; + int w = std::min(gstate.getScissorX2(), gstate.getRegionX2()) + 1; + int h = std::min(gstate.getScissorY2(), gstate.getRegionY2()) + 1; - bool drawZ = gstate.isDepthWriteEnabled() && gstate.isDepthTestEnabled(); + bool drawZ = !gstate.isModeClear() && gstate.isDepthWriteEnabled() && gstate.isDepthTestEnabled(); bool clearZ = gstate.isModeClear() && gstate.isClearModeDepthMask(); if (drawZ || clearZ) { int bytes = 2 * gstate.DepthBufStride() * h; From 5afb009b56caedf4f41444afbc4730408fd90716 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 1 Nov 2022 22:15:11 -0700 Subject: [PATCH 325/374] GE Debugger: Dump textures only if possibly used. --- GPU/Debugger/Record.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index f27464a48a..e6decebedc 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -420,9 +420,12 @@ static void FlushPrimState(int vcount) { // We re-flush textures always in case the game changed them... kinda expensive. // TODO: Dirty textures on transfer/stall/etc. somehow? // TODO: Or maybe de-dup by validating if it has changed? + bool textureEnabled = gstate.isTextureMapEnabled() || gstate.isAntiAliasEnabled(); + // Play it safe and allow texture coords to emit data too. + bool textureCoords = (gstate.vertType & GE_VTYPE_TC_MASK) != 0; for (int level = 0; level < 8; ++level) { u32 texaddr = gstate.getTextureAddress(level); - if (texaddr) { + if (texaddr && (textureEnabled || textureCoords)) { EmitTextureData(level, texaddr); } } From 00e8720749512518dee676a0209d2a44dd8b1e1d Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 1 Nov 2022 22:47:46 -0700 Subject: [PATCH 326/374] GE Debugger: Try harder to identify unchanged VRAM. If we exit to the CPU (stall), we don't know if VRAM gets changed by the CPU. We can check to avoid making the dump require unnecessary copying. --- GPU/Debugger/Record.cpp | 62 +++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/GPU/Debugger/Record.cpp b/GPU/Debugger/Record.cpp index e6decebedc..97ed107470 100644 --- a/GPU/Debugger/Record.cpp +++ b/GPU/Debugger/Record.cpp @@ -60,11 +60,13 @@ static std::vector commands; static std::vector lastRegisters; static std::vector lastTextures; static std::set lastRenderTargets; +static std::vector lastVRAM; enum class DirtyVRAMFlag : uint8_t { CLEAN = 0, - DIRTY = 1, - DRAWN = 2, + UNKNOWN = 1, + DIRTY = 2, + DRAWN = 3, }; static constexpr uint32_t DIRTY_VRAM_SHIFT = 8; static constexpr uint32_t DIRTY_VRAM_ROUND = (1 << DIRTY_VRAM_SHIFT) - 1; @@ -106,8 +108,15 @@ static Path GenRecordingFilename() { } static void DirtyAllVRAM(DirtyVRAMFlag flag) { - for (uint32_t i = 0; i < DIRTY_VRAM_SIZE; ++i) - dirtyVRAM[i] = flag; + if (flag == DirtyVRAMFlag::UNKNOWN) { + for (uint32_t i = 0; i < DIRTY_VRAM_SIZE; ++i) { + if (dirtyVRAM[i] == DirtyVRAMFlag::CLEAN) + dirtyVRAM[i] = DirtyVRAMFlag::UNKNOWN; + } + } else { + for (uint32_t i = 0; i < DIRTY_VRAM_SIZE; ++i) + dirtyVRAM[i] = flag; + } } static void DirtyVRAM(u32 start, u32 sz, DirtyVRAMFlag flag) { @@ -155,6 +164,7 @@ static void BeginRecording() { pushbuf.resize(pushbuf.size() + sz); gstate.Save((u32_le *)(pushbuf.data() + ptr)); commands.push_back({CommandType::INIT, sz, ptr}); + lastVRAM.resize(2 * 1024 * 1024); // Also save the initial CLUT. GPUDebugBuffer clut; @@ -325,6 +335,7 @@ static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) { addr &= 0x041FFFFF; const bool isTarget = lastRenderTargets.find(addr) != lastRenderTargets.end(); + bool isUnknownVRAM = false; bool isDirtyVRAM = false; bool isDrawnVRAM = false; uint32_t start = (addr >> DIRTY_VRAM_SHIFT) & DIRTY_VRAM_MASK; @@ -333,16 +344,25 @@ static u32 GetTargetFlags(u32 addr, u32 sizeInRAM) { bool endEven = ((addr + sizeInRAM) & DIRTY_VRAM_ROUND) == 0; for (uint32_t i = 0; i < blocks; ++i) { DirtyVRAMFlag flag = dirtyVRAM[start + i]; + isUnknownVRAM = (isUnknownVRAM || flag == DirtyVRAMFlag::UNKNOWN) && flag != DirtyVRAMFlag::DIRTY && flag != DirtyVRAMFlag::DRAWN; isDirtyVRAM = isDirtyVRAM || flag != DirtyVRAMFlag::CLEAN; isDrawnVRAM = isDrawnVRAM || flag == DirtyVRAMFlag::DRAWN; // Mark the VRAM clean now that it's been copied to VRAM. - if (flag == DirtyVRAMFlag::DIRTY) { + if (flag == DirtyVRAMFlag::UNKNOWN || flag == DirtyVRAMFlag::DIRTY) { if ((i > 0 || startEven) && (i < blocks || endEven)) dirtyVRAM[start + i] = DirtyVRAMFlag::CLEAN; } } + if (isUnknownVRAM && isDirtyVRAM) { + // This means it's only UNKNOWN/CLEAN and not known to be actually dirty. + // Let's check our shadow copy of what we last sent for this VRAM. + int diff = memcmp(&lastVRAM[addr & 0x001FFFFF], Memory::GetPointerUnchecked(addr), sizeInRAM); + if (diff == 0) + isDirtyVRAM = false; + } + // The isTarget flag is mostly used for replay of dumps on a PSP. u32 flags = isTarget ? 1 : 0; // The unchangedVRAM flag tells us we can skip recopying. @@ -376,13 +396,16 @@ static void EmitTextureData(int level, u32 texaddr) { u32 pad; }; - u32 flags = GetTargetFlags(texaddr, sizeInRAM); + u32 flags = GetTargetFlags(texaddr, bytes); FramebufData framebuf{ texaddr, bufw, flags }; framebufData.resize(sizeof(framebuf) + bytes); memcpy(&framebufData[0], &framebuf, sizeof(framebuf)); memcpy(&framebufData[sizeof(framebuf)], p, bytes); p = &framebufData[0]; + if ((flags & 2) == 0) + memcpy(&lastVRAM[texaddr & 0x001FFFFF], Memory::GetPointerUnchecked(texaddr), bytes); + // Okay, now we'll just emit this instead. type = CommandType((int)CommandType::FRAMEBUF0 + level); bytes += (u32)sizeof(framebuf); @@ -418,8 +441,6 @@ static void FlushPrimState(int vcount) { lastRenderTargets.insert(PSP_GetVidMemBase() | gstate.getDepthBufRawAddress()); // We re-flush textures always in case the game changed them... kinda expensive. - // TODO: Dirty textures on transfer/stall/etc. somehow? - // TODO: Or maybe de-dup by validating if it has changed? bool textureEnabled = gstate.isTextureMapEnabled() || gstate.isAntiAliasEnabled(); // Play it safe and allow texture coords to emit data too. bool textureCoords = (gstate.vertType & GE_VTYPE_TC_MASK) != 0; @@ -511,6 +532,9 @@ static void EmitClut(u32 op) { pushbuf.resize(pushbuf.size() + sizeof(data)); memcpy(pushbuf.data() + cmd.ptr, &data, sizeof(data)); commands.push_back(cmd); + + if ((flags & 2) == 0) + memcpy(&lastVRAM[addr & 0x001FFFFF], Memory::GetPointerUnchecked(addr), bytes); } EmitCommandWithRAM(CommandType::CLUT, Memory::GetPointerUnchecked(addr), bytes, 16); } @@ -561,6 +585,7 @@ static void FinishRecording() { Path filename = WriteRecording(); commands.clear(); pushbuf.clear(); + lastVRAM.clear(); NOTICE_LOG(SYSTEM, "Recording finished"); active = false; @@ -658,8 +683,9 @@ void NotifyMemcpy(u32 dest, u32 src, u32 sz) { sz = Memory::ValidSize(dest, sz); if (sz != 0) { - EmitCommandWithRAM(CommandType::MEMCPYDATA, Memory::GetPointer(dest), sz, 1); - DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); + EmitCommandWithRAM(CommandType::MEMCPYDATA, Memory::GetPointerUnchecked(dest), sz, 1); + memcpy(&lastVRAM[dest & 0x001FFFFF], Memory::GetPointerUnchecked(dest), sz); + DirtyVRAM(dest, sz, DirtyVRAMFlag::CLEAN); } } } @@ -685,20 +711,14 @@ void NotifyMemset(u32 dest, int v, u32 sz) { pushbuf.resize(pushbuf.size() + sizeof(data)); memcpy(pushbuf.data() + cmd.ptr, &data, sizeof(data)); commands.push_back(cmd); - DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); + memset(&lastVRAM[dest & 0x001FFFFF], v, sz); + DirtyVRAM(dest, sz, DirtyVRAMFlag::CLEAN); } } void NotifyUpload(u32 dest, u32 sz) { - if (!active) { - return; - } - - if (Memory::IsVRAMAddress(dest)) { - // This also checks the edram translation value. - NotifyMemcpy(dest, dest, sz); - DirtyVRAM(dest, sz, DirtyVRAMFlag::DIRTY); - } + // This also checks the edram translation value and dirties VRAM. + NotifyMemcpy(dest, dest, sz); } static bool HasDrawCommands() { @@ -793,7 +813,7 @@ void NotifyCPU() { return; } - DirtyAllVRAM(DirtyVRAMFlag::DIRTY); + DirtyAllVRAM(DirtyVRAMFlag::UNKNOWN); } }; From 1ffdf0d5b8811e6598390d06fc608b1a3299e72a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 1 Nov 2022 22:56:29 -0700 Subject: [PATCH 327/374] GE Debugger: Respect unchanged VRAM each frame. Oops, wasn't setting the version each run after caching the frame dump data. --- GPU/Debugger/Playback.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Debugger/Playback.cpp b/GPU/Debugger/Playback.cpp index eb3f9fa2bc..03472ba834 100644 --- a/GPU/Debugger/Playback.cpp +++ b/GPU/Debugger/Playback.cpp @@ -46,6 +46,7 @@ namespace GPURecord { static std::string lastExecFilename; +static uint32_t lastExecVersion; static std::vector lastExecCommands; static std::vector lastExecPushbuf; static std::mutex executeLock; @@ -761,6 +762,7 @@ static void ReplayStop() { lastExecFilename.clear(); lastExecCommands.clear(); lastExecPushbuf.clear(); + lastExecVersion = 0; } bool RunMountedReplay(const std::string &filename) { @@ -769,7 +771,7 @@ bool RunMountedReplay(const std::string &filename) { std::lock_guard guard(executeLock); Core_ListenStopRequest(&ReplayStop); - uint32_t version = 0; + uint32_t version = lastExecVersion; if (lastExecFilename != filename) { PROFILE_THIS_SCOPE("ReplayLoad"); u32 fp = pspFileSystem.OpenFile(filename, FILEACCESS_READ); @@ -812,6 +814,7 @@ bool RunMountedReplay(const std::string &filename) { } lastExecFilename = filename; + lastExecVersion = version; } DumpExecute executor(lastExecPushbuf, lastExecCommands, version); From 404f67be8afa08fa27927a0160e98f09908296a4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 1 Nov 2022 23:08:24 -0700 Subject: [PATCH 328/374] Build: Enable libzip on libretro. --- libretro/Makefile.common | 250 +++++++++++++++++++-------------------- 1 file changed, 124 insertions(+), 126 deletions(-) diff --git a/libretro/Makefile.common b/libretro/Makefile.common index cd9f7f04d7..7d858e0129 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -37,133 +37,131 @@ INCFLAGS += \ -I$(EXTDIR)/xxhash \ -I$(EXTDIR)/glew -ifeq ($(PLATFORM_EXT), android) - INCFLAGS += -I$(EXTDIR)/libzip - SOURCES_C += \ - $(EXTDIR)/libzip/zip_add.c \ - $(EXTDIR)/libzip/zip_add_dir.c \ - $(EXTDIR)/libzip/zip_add_entry.c \ - $(EXTDIR)/libzip/zip_algorithm_deflate.c \ - $(EXTDIR)/libzip/zip_buffer.c \ - $(EXTDIR)/libzip/zip_close.c \ - $(EXTDIR)/libzip/zip_delete.c \ - $(EXTDIR)/libzip/zip_dir_add.c \ - $(EXTDIR)/libzip/zip_dirent.c \ - $(EXTDIR)/libzip/zip_discard.c \ - $(EXTDIR)/libzip/zip_entry.c \ - $(EXTDIR)/libzip/zip_error.c \ - $(EXTDIR)/libzip/zip_error_clear.c \ - $(EXTDIR)/libzip/zip_error_get.c \ - $(EXTDIR)/libzip/zip_error_get_sys_type.c \ - $(EXTDIR)/libzip/zip_error_strerror.c \ - $(EXTDIR)/libzip/zip_error_to_str.c \ - $(EXTDIR)/libzip/zip_extra_field.c \ - $(EXTDIR)/libzip/zip_extra_field_api.c \ - $(EXTDIR)/libzip/zip_fclose.c \ - $(EXTDIR)/libzip/zip_fdopen.c \ - $(EXTDIR)/libzip/zip_file_add.c \ - $(EXTDIR)/libzip/zip_file_error_clear.c \ - $(EXTDIR)/libzip/zip_file_error_get.c \ - $(EXTDIR)/libzip/zip_file_get_comment.c \ - $(EXTDIR)/libzip/zip_file_get_external_attributes.c \ - $(EXTDIR)/libzip/zip_file_get_offset.c \ - $(EXTDIR)/libzip/zip_file_rename.c \ - $(EXTDIR)/libzip/zip_file_replace.c \ - $(EXTDIR)/libzip/zip_file_set_comment.c \ - $(EXTDIR)/libzip/zip_file_set_encryption.c \ - $(EXTDIR)/libzip/zip_file_set_external_attributes.c \ - $(EXTDIR)/libzip/zip_file_set_mtime.c \ - $(EXTDIR)/libzip/zip_file_strerror.c \ - $(EXTDIR)/libzip/zip_fopen.c \ - $(EXTDIR)/libzip/zip_fopen_encrypted.c \ - $(EXTDIR)/libzip/zip_fopen_index.c \ - $(EXTDIR)/libzip/zip_fopen_index_encrypted.c \ - $(EXTDIR)/libzip/zip_fread.c \ - $(EXTDIR)/libzip/zip_fseek.c \ - $(EXTDIR)/libzip/zip_ftell.c \ - $(EXTDIR)/libzip/zip_get_archive_comment.c \ - $(EXTDIR)/libzip/zip_get_archive_flag.c \ - $(EXTDIR)/libzip/zip_get_encryption_implementation.c \ - $(EXTDIR)/libzip/zip_get_file_comment.c \ - $(EXTDIR)/libzip/zip_get_name.c \ - $(EXTDIR)/libzip/zip_get_num_entries.c \ - $(EXTDIR)/libzip/zip_get_num_files.c \ - $(EXTDIR)/libzip/zip_hash.c \ - $(EXTDIR)/libzip/zip_io_util.c \ - $(EXTDIR)/libzip/zip_libzip_version.c \ - $(EXTDIR)/libzip/zip_memdup.c \ - $(EXTDIR)/libzip/zip_name_locate.c \ - $(EXTDIR)/libzip/zip_new.c \ - $(EXTDIR)/libzip/zip_open.c \ - $(EXTDIR)/libzip/zip_pkware.c \ - $(EXTDIR)/libzip/zip_progress.c \ - $(EXTDIR)/libzip/zip_rename.c \ - $(EXTDIR)/libzip/zip_replace.c \ - $(EXTDIR)/libzip/zip_set_archive_comment.c \ - $(EXTDIR)/libzip/zip_set_archive_flag.c \ - $(EXTDIR)/libzip/zip_set_default_password.c \ - $(EXTDIR)/libzip/zip_set_file_comment.c \ - $(EXTDIR)/libzip/zip_set_file_compression.c \ - $(EXTDIR)/libzip/zip_set_name.c \ - $(EXTDIR)/libzip/zip_source_accept_empty.c \ - $(EXTDIR)/libzip/zip_source_begin_write.c \ - $(EXTDIR)/libzip/zip_source_begin_write_cloning.c \ - $(EXTDIR)/libzip/zip_source_buffer.c \ - $(EXTDIR)/libzip/zip_source_call.c \ - $(EXTDIR)/libzip/zip_source_close.c \ - $(EXTDIR)/libzip/zip_source_commit_write.c \ - $(EXTDIR)/libzip/zip_source_compress.c \ - $(EXTDIR)/libzip/zip_source_crc.c \ - $(EXTDIR)/libzip/zip_source_error.c \ - $(EXTDIR)/libzip/zip_source_file_common.c \ - $(EXTDIR)/libzip/zip_source_file_stdio.c \ - $(EXTDIR)/libzip/zip_source_free.c \ - $(EXTDIR)/libzip/zip_source_function.c \ - $(EXTDIR)/libzip/zip_source_get_file_attributes.c \ - $(EXTDIR)/libzip/zip_source_is_deleted.c \ - $(EXTDIR)/libzip/zip_source_layered.c \ - $(EXTDIR)/libzip/zip_source_open.c \ - $(EXTDIR)/libzip/zip_source_pkware_decode.c \ - $(EXTDIR)/libzip/zip_source_pkware_encode.c \ - $(EXTDIR)/libzip/zip_source_read.c \ - $(EXTDIR)/libzip/zip_source_remove.c \ - $(EXTDIR)/libzip/zip_source_rollback_write.c \ - $(EXTDIR)/libzip/zip_source_seek.c \ - $(EXTDIR)/libzip/zip_source_seek_write.c \ - $(EXTDIR)/libzip/zip_source_stat.c \ - $(EXTDIR)/libzip/zip_source_supports.c \ - $(EXTDIR)/libzip/zip_source_tell.c \ - $(EXTDIR)/libzip/zip_source_tell_write.c \ - $(EXTDIR)/libzip/zip_source_window.c \ - $(EXTDIR)/libzip/zip_source_write.c \ - $(EXTDIR)/libzip/zip_source_zip.c \ - $(EXTDIR)/libzip/zip_source_zip_new.c \ - $(EXTDIR)/libzip/zip_stat.c \ - $(EXTDIR)/libzip/zip_stat_index.c \ - $(EXTDIR)/libzip/zip_stat_init.c \ - $(EXTDIR)/libzip/zip_strerror.c \ - $(EXTDIR)/libzip/zip_string.c \ - $(EXTDIR)/libzip/zip_unchange.c \ - $(EXTDIR)/libzip/zip_unchange_all.c \ - $(EXTDIR)/libzip/zip_unchange_archive.c \ - $(EXTDIR)/libzip/zip_unchange_data.c \ - $(EXTDIR)/libzip/zip_utf-8.c \ - $(EXTDIR)/libzip/zip_err_str.c +INCFLAGS += -I$(EXTDIR)/libzip +SOURCES_C += \ + $(EXTDIR)/libzip/zip_add.c \ + $(EXTDIR)/libzip/zip_add_dir.c \ + $(EXTDIR)/libzip/zip_add_entry.c \ + $(EXTDIR)/libzip/zip_algorithm_deflate.c \ + $(EXTDIR)/libzip/zip_buffer.c \ + $(EXTDIR)/libzip/zip_close.c \ + $(EXTDIR)/libzip/zip_delete.c \ + $(EXTDIR)/libzip/zip_dir_add.c \ + $(EXTDIR)/libzip/zip_dirent.c \ + $(EXTDIR)/libzip/zip_discard.c \ + $(EXTDIR)/libzip/zip_entry.c \ + $(EXTDIR)/libzip/zip_error.c \ + $(EXTDIR)/libzip/zip_error_clear.c \ + $(EXTDIR)/libzip/zip_error_get.c \ + $(EXTDIR)/libzip/zip_error_get_sys_type.c \ + $(EXTDIR)/libzip/zip_error_strerror.c \ + $(EXTDIR)/libzip/zip_error_to_str.c \ + $(EXTDIR)/libzip/zip_extra_field.c \ + $(EXTDIR)/libzip/zip_extra_field_api.c \ + $(EXTDIR)/libzip/zip_fclose.c \ + $(EXTDIR)/libzip/zip_fdopen.c \ + $(EXTDIR)/libzip/zip_file_add.c \ + $(EXTDIR)/libzip/zip_file_error_clear.c \ + $(EXTDIR)/libzip/zip_file_error_get.c \ + $(EXTDIR)/libzip/zip_file_get_comment.c \ + $(EXTDIR)/libzip/zip_file_get_external_attributes.c \ + $(EXTDIR)/libzip/zip_file_get_offset.c \ + $(EXTDIR)/libzip/zip_file_rename.c \ + $(EXTDIR)/libzip/zip_file_replace.c \ + $(EXTDIR)/libzip/zip_file_set_comment.c \ + $(EXTDIR)/libzip/zip_file_set_encryption.c \ + $(EXTDIR)/libzip/zip_file_set_external_attributes.c \ + $(EXTDIR)/libzip/zip_file_set_mtime.c \ + $(EXTDIR)/libzip/zip_file_strerror.c \ + $(EXTDIR)/libzip/zip_fopen.c \ + $(EXTDIR)/libzip/zip_fopen_encrypted.c \ + $(EXTDIR)/libzip/zip_fopen_index.c \ + $(EXTDIR)/libzip/zip_fopen_index_encrypted.c \ + $(EXTDIR)/libzip/zip_fread.c \ + $(EXTDIR)/libzip/zip_fseek.c \ + $(EXTDIR)/libzip/zip_ftell.c \ + $(EXTDIR)/libzip/zip_get_archive_comment.c \ + $(EXTDIR)/libzip/zip_get_archive_flag.c \ + $(EXTDIR)/libzip/zip_get_encryption_implementation.c \ + $(EXTDIR)/libzip/zip_get_file_comment.c \ + $(EXTDIR)/libzip/zip_get_name.c \ + $(EXTDIR)/libzip/zip_get_num_entries.c \ + $(EXTDIR)/libzip/zip_get_num_files.c \ + $(EXTDIR)/libzip/zip_hash.c \ + $(EXTDIR)/libzip/zip_io_util.c \ + $(EXTDIR)/libzip/zip_libzip_version.c \ + $(EXTDIR)/libzip/zip_memdup.c \ + $(EXTDIR)/libzip/zip_name_locate.c \ + $(EXTDIR)/libzip/zip_new.c \ + $(EXTDIR)/libzip/zip_open.c \ + $(EXTDIR)/libzip/zip_pkware.c \ + $(EXTDIR)/libzip/zip_progress.c \ + $(EXTDIR)/libzip/zip_rename.c \ + $(EXTDIR)/libzip/zip_replace.c \ + $(EXTDIR)/libzip/zip_set_archive_comment.c \ + $(EXTDIR)/libzip/zip_set_archive_flag.c \ + $(EXTDIR)/libzip/zip_set_default_password.c \ + $(EXTDIR)/libzip/zip_set_file_comment.c \ + $(EXTDIR)/libzip/zip_set_file_compression.c \ + $(EXTDIR)/libzip/zip_set_name.c \ + $(EXTDIR)/libzip/zip_source_accept_empty.c \ + $(EXTDIR)/libzip/zip_source_begin_write.c \ + $(EXTDIR)/libzip/zip_source_begin_write_cloning.c \ + $(EXTDIR)/libzip/zip_source_buffer.c \ + $(EXTDIR)/libzip/zip_source_call.c \ + $(EXTDIR)/libzip/zip_source_close.c \ + $(EXTDIR)/libzip/zip_source_commit_write.c \ + $(EXTDIR)/libzip/zip_source_compress.c \ + $(EXTDIR)/libzip/zip_source_crc.c \ + $(EXTDIR)/libzip/zip_source_error.c \ + $(EXTDIR)/libzip/zip_source_file_common.c \ + $(EXTDIR)/libzip/zip_source_file_stdio.c \ + $(EXTDIR)/libzip/zip_source_free.c \ + $(EXTDIR)/libzip/zip_source_function.c \ + $(EXTDIR)/libzip/zip_source_get_file_attributes.c \ + $(EXTDIR)/libzip/zip_source_is_deleted.c \ + $(EXTDIR)/libzip/zip_source_layered.c \ + $(EXTDIR)/libzip/zip_source_open.c \ + $(EXTDIR)/libzip/zip_source_pkware_decode.c \ + $(EXTDIR)/libzip/zip_source_pkware_encode.c \ + $(EXTDIR)/libzip/zip_source_read.c \ + $(EXTDIR)/libzip/zip_source_remove.c \ + $(EXTDIR)/libzip/zip_source_rollback_write.c \ + $(EXTDIR)/libzip/zip_source_seek.c \ + $(EXTDIR)/libzip/zip_source_seek_write.c \ + $(EXTDIR)/libzip/zip_source_stat.c \ + $(EXTDIR)/libzip/zip_source_supports.c \ + $(EXTDIR)/libzip/zip_source_tell.c \ + $(EXTDIR)/libzip/zip_source_tell_write.c \ + $(EXTDIR)/libzip/zip_source_window.c \ + $(EXTDIR)/libzip/zip_source_write.c \ + $(EXTDIR)/libzip/zip_source_zip.c \ + $(EXTDIR)/libzip/zip_source_zip_new.c \ + $(EXTDIR)/libzip/zip_stat.c \ + $(EXTDIR)/libzip/zip_stat_index.c \ + $(EXTDIR)/libzip/zip_stat_init.c \ + $(EXTDIR)/libzip/zip_strerror.c \ + $(EXTDIR)/libzip/zip_string.c \ + $(EXTDIR)/libzip/zip_unchange.c \ + $(EXTDIR)/libzip/zip_unchange_all.c \ + $(EXTDIR)/libzip/zip_unchange_archive.c \ + $(EXTDIR)/libzip/zip_unchange_data.c \ + $(EXTDIR)/libzip/zip_utf-8.c \ + $(EXTDIR)/libzip/zip_err_str.c - ifeq ($(PLATFORM_EXT), win32) - SOURCES_C += \ - $(EXTDIR)/libzip/zip_source_file_win32.c \ - $(EXTDIR)/libzip/zip_source_file_win32_named.c \ - $(EXTDIR)/libzip/zip_source_file_win32_utf16.c \ - $(EXTDIR)/libzip/zip_source_file_win32_utf8.c \ - $(EXTDIR)/libzip/zip_source_file_win32_ansi.c \ - $(EXTDIR)/libzip/zip_random_win32.c - else - SOURCES_C += \ - $(EXTDIR)/libzip/zip_mkstempm.c \ - $(EXTDIR)/libzip/zip_source_file_stdio_named.c \ - $(EXTDIR)/libzip/zip_random_unix.c - endif +ifeq ($(PLATFORM_EXT), win32) + SOURCES_C += \ + $(EXTDIR)/libzip/zip_source_file_win32.c \ + $(EXTDIR)/libzip/zip_source_file_win32_named.c \ + $(EXTDIR)/libzip/zip_source_file_win32_utf16.c \ + $(EXTDIR)/libzip/zip_source_file_win32_utf8.c \ + $(EXTDIR)/libzip/zip_source_file_win32_ansi.c \ + $(EXTDIR)/libzip/zip_random_win32.c +else + SOURCES_C += \ + $(EXTDIR)/libzip/zip_mkstempm.c \ + $(EXTDIR)/libzip/zip_source_file_stdio_named.c \ + $(EXTDIR)/libzip/zip_random_unix.c endif SOURCES_C += $(LIBRETRODIR)/ext/glew/glew.c From 46bb065b7e7449093fc56e86bd1d8b34e87ffc79 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 1 Nov 2022 23:37:37 -0700 Subject: [PATCH 329/374] Build: Use Makefile for libretro. --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 778b601445..d38a1ac0db 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -168,13 +168,13 @@ jobs: extra: libretro cc: gcc cxx: g++ - args: ./b.sh --libretro + args: make -C libretro -f Makefile -j2 id: gcc-libretro - os: ubuntu-latest extra: libretro cc: clang cxx: clang++ - args: ./b.sh --libretro + args: make -C libretro -f Makefile -j2 id: clang-libretro - os: macos-latest From 26a66dc37f1d1bdb1ffe741877fa8463fdce8a27 Mon Sep 17 00:00:00 2001 From: bslenul <33353403+bslenul@users.noreply.github.com> Date: Sun, 30 Oct 2022 13:29:53 +0100 Subject: [PATCH 330/374] [Libretro] Update core options to v2 + add a few new ones Updated core options to v2 + added the following options: "Cache Full ISO in RAM", "PSP Model" and "Hardware Tesselation". --- libretro/libretro.cpp | 908 +++++++++++------ libretro/libretro.h | 45 + libretro/libretro_core_options.h | 1359 +++++++++++++++++++++++++ libretro/libretro_core_options_intl.h | 91 ++ libretro/retro_inline.h | 39 + 5 files changed, 2104 insertions(+), 338 deletions(-) create mode 100644 libretro/libretro_core_options.h create mode 100644 libretro/libretro_core_options_intl.h create mode 100644 libretro/retro_inline.h diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 9b4a20bd97..3716f1989e 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -45,6 +45,7 @@ #include "libretro/libretro.h" #include "libretro/LibretroGraphicsContext.h" +#include "libretro/libretro_core_options.h" #if PPSSPP_PLATFORM(ANDROID) #include @@ -81,6 +82,10 @@ #define VSYNC_SWAP_INTERVAL_RUN_SPEED_THRESHOLD 5.0f static bool libretro_supports_bitmasks = false; +static bool libretro_supports_option_categories = false; +static bool show_ip_address_options = true; +static bool show_upnp_port_option = true; +static bool show_detect_frame_rate_option = true; static std::string changeProAdhocServer; namespace Libretro @@ -428,239 +433,72 @@ class PrintfLogger : public LogListener }; static PrintfLogger *printfLogger; -template class RetroOption -{ - public: - RetroOption(const char *id, const char *name, std::initializer_list> list) : id_(id), name_(name), list_(list.begin(), list.end()) {} - RetroOption(const char *id, const char *name, std::initializer_list list) : id_(id), name_(name) { - for (auto option : list) - list_.push_back({ option, (T)list_.size() }); - } - RetroOption(const char *id, const char *name, T first, std::initializer_list list) : id_(id), name_(name) { - for (auto option : list) - list_.push_back({ option, first + (int)list_.size() }); - } - RetroOption(const char *id, const char *name, T first, int count, int step = 1) : id_(id), name_(name) { - for (T i = first; i < first + count; i += step) - list_.push_back({ std::to_string(i), i }); - } - RetroOption(const char *id, const char *name, bool initial) : id_(id), name_(name) { - list_.push_back({ initial ? "enabled" : "disabled", initial }); - list_.push_back({ !initial ? "enabled" : "disabled", !initial }); - } - - retro_variable GetOptions() - { - if (options_.empty()) - { - options_ = name_; - options_.push_back(';'); - for (auto &option : list_) - { - if (option.first == list_.begin()->first) - options_ += std::string(" ") + option.first; - else - options_ += std::string("|") + option.first; - } - } - return { id_, options_.c_str() }; - } - - bool Update(T *dest) - { - retro_variable var{ id_ }; - T val = list_.front().second; - - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - for (auto option : list_) - { - if (option.first == var.value) - { - val = option.second; - break; - } - } - } - - if (*dest != val) - { - *dest = val; - return true; - } - - return false; - } - - void Show(bool show) - { - struct retro_core_option_display optionDisplay{id_, show}; - environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &optionDisplay); - } - - void Set(const char *val) - { - struct retro_variable var{id_, val}; - environ_cb(RETRO_ENVIRONMENT_SET_VARIABLE, &var); - } - - private: - const char *id_; - const char *name_; - std::string options_; - std::vector> list_; -}; - -#define MAC_INITIALIZER_LIST \ -{ \ - {"0", "0"}, \ - {"1", "1"}, \ - {"2", "2"}, \ - {"3", "3"}, \ - {"4", "4"}, \ - {"5", "5"}, \ - {"6", "6"}, \ - {"7", "7"}, \ - {"8", "8"}, \ - {"9", "9"}, \ - {"a", "a"}, \ - {"b", "b"}, \ - {"c", "c"}, \ - {"d", "d"}, \ - {"e", "e"}, \ - {"f", "f"} \ -} - -static RetroOption ppsspp_cpu_core("ppsspp_cpu_core", "CPU Core", { { "JIT", CPUCore::JIT }, { "IR JIT", CPUCore::IR_JIT }, { "Interpreter", CPUCore::INTERPRETER } }); -static RetroOption ppsspp_locked_cpu_speed("ppsspp_locked_cpu_speed", "Locked CPU Speed", { { "off", 0 }, { "222MHz", 222 }, { "266MHz", 266 }, { "333MHz", 333 } }); -static RetroOption ppsspp_language("ppsspp_language", "Language", { { "Automatic", -1 }, { "English", PSP_SYSTEMPARAM_LANGUAGE_ENGLISH }, { "Japanese", PSP_SYSTEMPARAM_LANGUAGE_JAPANESE }, { "French", PSP_SYSTEMPARAM_LANGUAGE_FRENCH }, { "Spanish", PSP_SYSTEMPARAM_LANGUAGE_SPANISH }, { "German", PSP_SYSTEMPARAM_LANGUAGE_GERMAN }, { "Italian", PSP_SYSTEMPARAM_LANGUAGE_ITALIAN }, { "Dutch", PSP_SYSTEMPARAM_LANGUAGE_DUTCH }, { "Portuguese", PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE }, { "Russian", PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN }, { "Korean", PSP_SYSTEMPARAM_LANGUAGE_KOREAN }, { "Chinese Traditional", PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL }, { "Chinese Simplified", PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED } }); -static RetroOption ppsspp_rendering_mode("ppsspp_rendering_mode", "Rendering Mode", { { "Buffered", FB_BUFFERED_MODE }, { "Skip Buffer Effects", FB_NON_BUFFERED_MODE } }); -static RetroOption ppsspp_auto_frameskip("ppsspp_auto_frameskip", "Auto Frameskip", false); -static RetroOption ppsspp_frameskip("ppsspp_frameskip", "Frameskip", { "Off", "1", "2", "3", "4", "5", "6", "7", "8" }); -static RetroOption ppsspp_frameskiptype("ppsspp_frameskiptype", "Frameskip Type", { {"Number of frames", 0}, {"Percent of FPS", 1} }); -static RetroOption ppsspp_internal_resolution("ppsspp_internal_resolution", "Internal Resolution (Restart)", 1, { "480x272", "960x544", "1440x816", "1920x1088", "2400x1360", "2880x1632", "3360x1904", "3840x2176", "4320x2448", "4800x2720" }); -static RetroOption ppsspp_button_preference("ppsspp_button_preference", "Confirmation Button", { { "Cross", PSP_SYSTEMPARAM_BUTTON_CROSS }, { "Circle", PSP_SYSTEMPARAM_BUTTON_CIRCLE } }); -static RetroOption ppsspp_fast_memory("ppsspp_fast_memory", "Fast Memory (Speedhack)", true); -static RetroOption ppsspp_block_transfer_gpu("ppsspp_block_transfer_gpu", "Block Transfer GPU", true); -static RetroOption ppsspp_inflight_frames("ppsspp_inflight_frames", "Buffered frames (Slower, less lag, restart)", { { "Up to 2", 2 }, { "Up to 1", 1 }, { "No buffer", 0 }, }); -static RetroOption ppsspp_texture_scaling_level("ppsspp_texture_scaling_level", "Texture Scaling Level", { { "Off", 1 }, { "2x", 2 }, { "3x", 3 }, { "4x", 4 }, { "5x", 5 } }); -static RetroOption ppsspp_texture_scaling_type("ppsspp_texture_scaling_type", "Texture Scaling Type", { { "xbrz", TextureScalerCommon::XBRZ }, { "hybrid", TextureScalerCommon::HYBRID }, { "bicubic", TextureScalerCommon::BICUBIC }, { "hybrid_bicubic", TextureScalerCommon::HYBRID_BICUBIC } }); -static RetroOption ppsspp_texture_shader("ppsspp_texture_shader", "Texture Shader (Vulkan only, overrides Texture Scaling Type)", { {"Off", "Off"}, {"2xBRZ", "Tex2xBRZ"}, {"4xBRZ", "Tex4xBRZ"}, {"MMPX", "TexMMPX"} }); -static RetroOption ppsspp_texture_filtering("ppsspp_texture_filtering", "Texture Filtering", { { "Auto", 1 }, { "Nearest", 2 }, { "Linear", 3 }, {"Auto max quality", 4}}); -static RetroOption ppsspp_texture_anisotropic_filtering("ppsspp_texture_anisotropic_filtering", "Anisotropic Filtering", { "off", "2x", "4x", "8x", "16x" }); -static RetroOption ppsspp_lower_resolution_for_effects("ppsspp_lower_resolution_for_effects", "Lower resolution for effects", { {"Off", 0}, {"Safe", 1}, {"Balanced", 2}, {"Aggressive", 3} }); -static RetroOption ppsspp_texture_deposterize("ppsspp_texture_deposterize", "Texture Deposterize", false); -static RetroOption ppsspp_texture_replacement("ppsspp_texture_replacement", "Texture Replacement", false); -static RetroOption ppsspp_gpu_hardware_transform("ppsspp_gpu_hardware_transform", "GPU Hardware T&L", true); -static RetroOption ppsspp_vertex_cache("ppsspp_vertex_cache", "Vertex Cache (Speedhack)", false); -static RetroOption ppsspp_cheats("ppsspp_cheats", "Internal Cheats Support", false); -static RetroOption ppsspp_io_timing_method("ppsspp_io_timing_method", "IO Timing Method", { { "Fast", IOTimingMethods::IOTIMING_FAST }, { "Host", IOTimingMethods::IOTIMING_HOST }, { "Simulate UMD delays", IOTimingMethods::IOTIMING_REALISTIC } }); -static RetroOption ppsspp_frame_duplication("ppsspp_frame_duplication", "Duplicate Frames in 30 Hz Games", false); -static RetroOption ppsspp_detect_vsync_swap_interval("ppsspp_detect_vsync_swap_interval", "Detect Frame Rate Changes (Notify Frontend)", false); -static RetroOption ppsspp_software_skinning("ppsspp_software_skinning", "Software Skinning", true); -static RetroOption ppsspp_ignore_bad_memory_access("ppsspp_ignore_bad_memory_access", "Ignore bad memory accesses", true); -static RetroOption ppsspp_lazy_texture_caching("ppsspp_lazy_texture_caching", "Lazy texture caching (Speedup)", false); -static RetroOption ppsspp_retain_changed_textures("ppsspp_retain_changed_textures", "Retain changed textures (Speedup, mem hog)", false); -static RetroOption ppsspp_force_lag_sync("ppsspp_force_lag_sync", "Force real clock sync (Slower, less lag)", false); -static RetroOption ppsspp_spline_quality("ppsspp_spline_quality", "Spline/Bezier curves quality", { {"Low", 0}, {"Medium", 1}, {"High", 2} }); -static RetroOption ppsspp_enable_wlan("ppsspp_enable_wlan", "Enable Networking/WLAN (beta, may break games)", false); -static RetroOption ppsspp_change_mac_address[] = { - {"ppsspp_change_mac_address01", "MAC address Pt 1: X-:--:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address02", "MAC address Pt 2: -X:--:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address03", "MAC address Pt 3: --:X-:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address04", "MAC address Pt 4: --:-X:--:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address05", "MAC address Pt 5: --:--:X-:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address06", "MAC address Pt 6: --:--:-X:--:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address07", "MAC address Pt 7: --:--:--:X-:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address08", "MAC address Pt 8: --:--:--:-X:--:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address09", "MAC address Pt 9: --:--:--:--:X-:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address10", "MAC address Pt 10: --:--:--:--:-X:--", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address11", "MAC address Pt 11: --:--:--:--:--:X-", MAC_INITIALIZER_LIST}, - {"ppsspp_change_mac_address12", "MAC address Pt 12: --:--:--:--:--:-X", MAC_INITIALIZER_LIST} -}; -static RetroOption ppsspp_wlan_channel("ppsspp_wlan_channel", "WLAN channel", {{"Auto", 0}, {"1", 1}, {"6", 6}, {"11", 11}} ); -static RetroOption ppsspp_enable_builtin_pro_ad_hoc_server("ppsspp_enable_builtin_pro_ad_hoc_server", "Enable built-in PRO ad hoc server", false); -static RetroOption ppsspp_change_pro_ad_hoc_server_address("ppsspp_change_pro_ad_hoc_server_address", "Change PRO ad hoc server IP address (localhost = multiple instances)", { - {"socom.cc", "socom.cc"}, - {"psp.gameplayer.club", "psp.gameplayer.club"}, - {"myneighborsushicat.com", "myneighborsushicat.com"}, - {"localhost", "localhost"}, - {"IP address", "IP address"} -}); -static RetroOption ppsspp_pro_ad_hoc_ipv4[] = { - {"ppsspp_pro_ad_hoc_server_address01", "PRO ad hoc server IP address Pt 1: x--.---.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address02", "PRO ad hoc server IP address Pt 2: -x-.---.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address03", "PRO ad hoc server IP address Pt 3: --x.---.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address04", "PRO ad hoc server IP address Pt 4: ---.x--.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address05", "PRO ad hoc server IP address Pt 5: ---.-x-.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address06", "PRO ad hoc server IP address Pt 6: ---.--x.---.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address07", "PRO ad hoc server IP address Pt 7: ---.---.x--.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address08", "PRO ad hoc server IP address Pt 8: ---.---.-x-.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address09", "PRO ad hoc server IP address Pt 9: ---.---.--x.--- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address10", "PRO ad hoc server IP address Pt 10: ---.---.---.x-- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address11", "PRO ad hoc server IP address Pt 11: ---.---.---.-x- ", 0, 10, 1}, - {"ppsspp_pro_ad_hoc_server_address12", "PRO ad hoc server IP address Pt 12: ---.---.---.--x ", 0, 10, 1} -}; -static RetroOption ppsspp_enable_upnp("ppsspp_enable_upnp", "Enable UPnP (need a few seconds to detect)", false); -static RetroOption ppsspp_upnp_use_original_port("ppsspp_upnp_use_original_port", "UPnP use original port (enabled = PSP compatibility)", true); -static RetroOption ppsspp_port_offset("ppsspp_port_offset", "Port offset (0 = PSP compatibility)", 0, 65001, 1000); -static RetroOption ppsspp_minimum_timeout("ppsspp_minimum timeout", "Minimum timeout (override in ms, 0 = default))", 0, 5001, 100); -static RetroOption ppsspp_forced_first_connect("ppsspp_forced_first_connect", "Forced first connect (faster connect)", false); - static bool set_variable_visibility(void) { + struct retro_core_option_display option_display; + struct retro_variable var; bool updated = false; - if (ppsspp_change_pro_ad_hoc_server_address.Update(&changeProAdhocServer)) - updated = true; + // Show/hide IP address options + bool show_ip_address_options_prev = show_ip_address_options; + show_ip_address_options = true; - if (changeProAdhocServer == "IP address") + var.key = "ppsspp_change_pro_ad_hoc_server_address"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && strcmp(var.value, "IP address")) + show_ip_address_options = false; + + if (show_ip_address_options != show_ip_address_options_prev) { - g_Config.proAdhocServer = ""; - for (int i = 0;;) + option_display.visible = show_ip_address_options; + for (int i = 0; i < 12; i++) { - int addressPt = 0; - ppsspp_pro_ad_hoc_ipv4[i].Show(true); - ppsspp_pro_ad_hoc_ipv4[i].Update(&addressPt); - g_Config.proAdhocServer += static_cast('0' + addressPt); - - if (++i == 12) - break; - - if (i % 3 == 0) - g_Config.proAdhocServer += '.'; + char key[64] = {0}; + option_display.key = key; + snprintf(key, sizeof(key), "ppsspp_pro_ad_hoc_server_address%02d", i + 1); + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); } - } - else - { - g_Config.proAdhocServer = changeProAdhocServer; - - for (int i = 0; i < 12; ++i) - ppsspp_pro_ad_hoc_ipv4[i].Show(false); - } - - if (ppsspp_enable_upnp.Update(&g_Config.bEnableUPnP)) updated = true; + } - ppsspp_upnp_use_original_port.Show(g_Config.bEnableUPnP); + // Show/hide 'UPnP Use Original Port' option + bool show_upnp_port_option_prev = show_upnp_port_option; + show_upnp_port_option = true; - bool detectVsyncSwapIntervalOptShownLast = detectVsyncSwapIntervalOptShown; - bool autoFrameSkip = false; - int frameSkip = 0; - bool renderDuplicateFrames = false; + var.key = "ppsspp_enable_upnp"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "disabled")) + show_upnp_port_option = false; - ppsspp_auto_frameskip.Update(&autoFrameSkip); - ppsspp_frameskip.Update(&frameSkip); - ppsspp_frame_duplication.Update(&renderDuplicateFrames); - - detectVsyncSwapIntervalOptShown = - !autoFrameSkip && - (frameSkip == 0) && - !renderDuplicateFrames; - - if (detectVsyncSwapIntervalOptShown != detectVsyncSwapIntervalOptShownLast) + if (show_upnp_port_option != show_upnp_port_option_prev) { - ppsspp_detect_vsync_swap_interval.Show(detectVsyncSwapIntervalOptShown); + option_display.visible = show_upnp_port_option; + option_display.key = "ppsspp_upnp_use_original_port"; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + updated = true; + } + + // Show/hide 'Detect Frame Rate Changes' option + bool show_detect_frame_rate_option_prev = show_detect_frame_rate_option; + int frameskip = 0; + bool auto_frameskip = false; + bool dupe_frames = false; + show_detect_frame_rate_option = true; + + var.key = "ppsspp_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && strcmp(var.value, "disabled")) + frameskip = atoi(var.value); + var.key = "ppsspp_auto_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "enabled")) + auto_frameskip = true; + var.key = "ppsspp_frame_duplication"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "enabled")) + dupe_frames = true; + + show_detect_frame_rate_option = (frameskip == 0) && !auto_frameskip && !dupe_frames; + if (show_detect_frame_rate_option != show_detect_frame_rate_option_prev) + { + option_display.visible = show_detect_frame_rate_option; + option_display.key = "ppsspp_detect_vsync_swap_interval"; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); updated = true; } @@ -671,59 +509,10 @@ void retro_set_environment(retro_environment_t cb) { environ_cb = cb; + libretro_set_core_options(environ_cb, &libretro_supports_option_categories); struct retro_core_options_update_display_callback update_display_cb; update_display_cb.callback = set_variable_visibility; environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK, &update_display_cb); - - std::vector vars; - vars.push_back(ppsspp_internal_resolution.GetOptions()); - vars.push_back(ppsspp_cpu_core.GetOptions()); - vars.push_back(ppsspp_locked_cpu_speed.GetOptions()); - vars.push_back(ppsspp_language.GetOptions()); - vars.push_back(ppsspp_button_preference.GetOptions()); - vars.push_back(ppsspp_rendering_mode.GetOptions()); - vars.push_back(ppsspp_gpu_hardware_transform.GetOptions()); - vars.push_back(ppsspp_texture_anisotropic_filtering.GetOptions()); - vars.push_back(ppsspp_spline_quality.GetOptions()); - vars.push_back(ppsspp_auto_frameskip.GetOptions()); - vars.push_back(ppsspp_frameskip.GetOptions()); - vars.push_back(ppsspp_frameskiptype.GetOptions()); - vars.push_back(ppsspp_frame_duplication.GetOptions()); - vars.push_back(ppsspp_detect_vsync_swap_interval.GetOptions()); - vars.push_back(ppsspp_vertex_cache.GetOptions()); - vars.push_back(ppsspp_fast_memory.GetOptions()); - vars.push_back(ppsspp_block_transfer_gpu.GetOptions()); - vars.push_back(ppsspp_inflight_frames.GetOptions()); - vars.push_back(ppsspp_software_skinning.GetOptions()); - vars.push_back(ppsspp_lazy_texture_caching.GetOptions()); - vars.push_back(ppsspp_retain_changed_textures.GetOptions()); - vars.push_back(ppsspp_force_lag_sync.GetOptions()); - vars.push_back(ppsspp_lower_resolution_for_effects.GetOptions()); - vars.push_back(ppsspp_texture_scaling_level.GetOptions()); - vars.push_back(ppsspp_texture_scaling_type.GetOptions()); - vars.push_back(ppsspp_texture_shader.GetOptions()); - vars.push_back(ppsspp_texture_filtering.GetOptions()); - vars.push_back(ppsspp_texture_deposterize.GetOptions()); - vars.push_back(ppsspp_texture_replacement.GetOptions()); - vars.push_back(ppsspp_io_timing_method.GetOptions()); - vars.push_back(ppsspp_ignore_bad_memory_access.GetOptions()); - vars.push_back(ppsspp_cheats.GetOptions()); - vars.push_back(ppsspp_enable_wlan.GetOptions()); - for (int i = 0; i < 12; ++i) - vars.push_back(ppsspp_change_mac_address[i].GetOptions()); - vars.push_back(ppsspp_wlan_channel.GetOptions()); - vars.push_back(ppsspp_enable_builtin_pro_ad_hoc_server.GetOptions()); - vars.push_back(ppsspp_change_pro_ad_hoc_server_address.GetOptions()); - for (int i = 0; i < 12; ++i) - vars.push_back(ppsspp_pro_ad_hoc_ipv4[i].GetOptions()); - vars.push_back(ppsspp_enable_upnp.GetOptions()); - vars.push_back(ppsspp_upnp_use_original_port.GetOptions()); - vars.push_back(ppsspp_port_offset.GetOptions()); - vars.push_back(ppsspp_minimum_timeout.GetOptions()); - vars.push_back(ppsspp_forced_first_connect.GetOptions()); - vars.push_back({}); - - environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void *)vars.data()); } static int get_language_auto(void) @@ -803,46 +592,522 @@ static void check_variables(CoreParameter &coreParam) && !updated) return; - ppsspp_button_preference.Update(&g_Config.iButtonPreference); - ppsspp_fast_memory.Update(&g_Config.bFastMemory); - ppsspp_vertex_cache.Update(&g_Config.bVertexCache); - ppsspp_gpu_hardware_transform.Update(&g_Config.bHardwareTransform); - ppsspp_frameskip.Update(&g_Config.iFrameSkip); - ppsspp_frameskiptype.Update(&g_Config.iFrameSkipType); - ppsspp_auto_frameskip.Update(&g_Config.bAutoFrameSkip); - ppsspp_block_transfer_gpu.Update(&g_Config.bBlockTransferGPU); - ppsspp_texture_filtering.Update(&g_Config.iTexFiltering); - ppsspp_texture_anisotropic_filtering.Update(&g_Config.iAnisotropyLevel); - ppsspp_texture_deposterize.Update(&g_Config.bTexDeposterize); - ppsspp_texture_replacement.Update(&g_Config.bReplaceTextures); - ppsspp_cheats.Update(&g_Config.bEnableCheats); - ppsspp_locked_cpu_speed.Update(&g_Config.iLockedCPUSpeed); - ppsspp_rendering_mode.Update(&g_Config.iRenderingMode); - ppsspp_cpu_core.Update((CPUCore *)&g_Config.iCpuCore); - ppsspp_io_timing_method.Update((IOTimingMethods *)&g_Config.iIOTimingMethod); - ppsspp_lower_resolution_for_effects.Update(&g_Config.iBloomHack); - ppsspp_frame_duplication.Update(&g_Config.bRenderDuplicateFrames); - ppsspp_detect_vsync_swap_interval.Update(&detectVsyncSwapInterval); - ppsspp_software_skinning.Update(&g_Config.bSoftwareSkinning); - ppsspp_ignore_bad_memory_access.Update(&g_Config.bIgnoreBadMemAccess); - ppsspp_lazy_texture_caching.Update(&g_Config.bTextureBackoffCache); - ppsspp_retain_changed_textures.Update(&g_Config.bTextureSecondaryCache); - ppsspp_force_lag_sync.Update(&g_Config.bForceLagSync); - ppsspp_spline_quality.Update(&g_Config.iSplineBezierQuality); - ppsspp_inflight_frames.Update(&g_Config.iInflightFrames); - const bool do_scaling_type_update = ppsspp_texture_scaling_type.Update(&g_Config.iTexScalingType); - const bool do_scaling_level_update = ppsspp_texture_scaling_level.Update(&g_Config.iTexScalingLevel); - const bool do_texture_shader_update = ppsspp_texture_shader.Update(&g_Config.sTextureShaderName); + struct retro_variable var = {0}; + std::string sTextureShaderName_prev; + int iInternalResolution_prev; + int iTexScalingType_prev; + int iTexScalingLevel_prev; - g_Config.bTexHardwareScaling = "Off" != g_Config.sTextureShaderName; + var.key = "ppsspp_language"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Automatic")) + g_Config.iLanguage = -1; + else if (!strcmp(var.value, "English")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH; + else if (!strcmp(var.value, "Japanese")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_JAPANESE; + else if (!strcmp(var.value, "French")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_FRENCH; + else if (!strcmp(var.value, "Spanish")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_SPANISH; + else if (!strcmp(var.value, "German")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_GERMAN; + else if (!strcmp(var.value, "Italian")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_ITALIAN; + else if (!strcmp(var.value, "Dutch")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_DUTCH; + else if (!strcmp(var.value, "Portuguese")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_PORTUGUESE; + else if (!strcmp(var.value, "Russian")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_RUSSIAN; + else if (!strcmp(var.value, "Korean")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_KOREAN; + else if (!strcmp(var.value, "Chinese Traditional")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_TRADITIONAL; + else if (!strcmp(var.value, "Chinese Simplified")) + g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_CHINESE_SIMPLIFIED; + } - if (gpu && (do_scaling_type_update || do_scaling_level_update || do_texture_shader_update)) + var.key = "ppsspp_cpu_core"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "JIT")) + g_Config.iCpuCore = (int)CPUCore::JIT; + else if (!strcmp(var.value, "IR JIT")) + g_Config.iCpuCore = (int)CPUCore::IR_JIT; + else if (!strcmp(var.value, "Interpreter")) + g_Config.iCpuCore = (int)CPUCore::INTERPRETER; + } + + var.key = "ppsspp_fast_memory"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bFastMemory = false; + else + g_Config.bFastMemory = true; + } + + var.key = "ppsspp_ignore_bad_memory_access"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bIgnoreBadMemAccess = false; + else + g_Config.bIgnoreBadMemAccess = true; + } + + var.key = "ppsspp_io_timing_method"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Fast")) + g_Config.iIOTimingMethod = IOTIMING_FAST; + else if (!strcmp(var.value, "Host")) + g_Config.iIOTimingMethod = IOTIMING_HOST; + else if (!strcmp(var.value, "Simulate UMD delays")) + g_Config.iIOTimingMethod = IOTIMING_REALISTIC; + } + + var.key = "ppsspp_force_lag_sync"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bForceLagSync = false; + else + g_Config.bForceLagSync = true; + } + + var.key = "ppsspp_locked_cpu_speed"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iLockedCPUSpeed = atoi(var.value); + + var.key = "ppsspp_cache_iso"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bCacheFullIsoInRam = false; + else + g_Config.bCacheFullIsoInRam = true; + } + + var.key = "ppsspp_cheats"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableCheats = false; + else + g_Config.bEnableCheats = true; + } + + var.key = "ppsspp_psp_model"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "psp_1000")) + g_Config.iPSPModel = PSP_MODEL_FAT; + else if (!strcmp(var.value, "psp_2000_3000")) + g_Config.iPSPModel = PSP_MODEL_SLIM; + } + + var.key = "ppsspp_button_preference"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Cross")) + g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CROSS; + else if (!strcmp(var.value, "Circle")) + g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CIRCLE; + } + + var.key = "ppsspp_internal_resolution"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + iInternalResolution_prev = g_Config.iInternalResolution; + + if (!strcmp(var.value, "480x272")) + g_Config.iInternalResolution = 1; + else if (!strcmp(var.value, "960x544")) + g_Config.iInternalResolution = 2; + else if (!strcmp(var.value, "1440x816")) + g_Config.iInternalResolution = 3; + else if (!strcmp(var.value, "1920x1088")) + g_Config.iInternalResolution = 4; + else if (!strcmp(var.value, "2400x1360")) + g_Config.iInternalResolution = 5; + else if (!strcmp(var.value, "2880x1632")) + g_Config.iInternalResolution = 6; + else if (!strcmp(var.value, "3360x1904")) + g_Config.iInternalResolution = 7; + else if (!strcmp(var.value, "3840x2176")) + g_Config.iInternalResolution = 8; + else if (!strcmp(var.value, "4320x2448")) + g_Config.iInternalResolution = 9; + else if (!strcmp(var.value, "4800x2720")) + g_Config.iInternalResolution = 10; + } + + var.key = "ppsspp_rendering_mode"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Buffered")) + g_Config.iRenderingMode = FB_BUFFERED_MODE; + else if (!strcmp(var.value, "Skip Buffer Effects")) + g_Config.iRenderingMode = FB_NON_BUFFERED_MODE; + } + + var.key = "ppsspp_block_transfer_gpu"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bBlockTransferGPU = false; + else + g_Config.bBlockTransferGPU = true; + } + + var.key = "ppsspp_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iFrameSkip = atoi(var.value); + + var.key = "ppsspp_frameskiptype"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Number of frames")) + g_Config.iFrameSkipType = 0; + else if (!strcmp(var.value, "Percent of FPS")) + g_Config.iFrameSkipType = 1; + } + + var.key = "ppsspp_auto_frameskip"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bAutoFrameSkip = false; + else + g_Config.bAutoFrameSkip = true; + } + + var.key = "ppsspp_frame_duplication"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bRenderDuplicateFrames = false; + else + g_Config.bRenderDuplicateFrames = true; + } + + var.key = "ppsspp_detect_vsync_swap_interval"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + detectVsyncSwapInterval = false; + else + detectVsyncSwapInterval = true; + } + + var.key = "ppsspp_inflight_frames"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "No buffer")) + g_Config.iInflightFrames = 0; + else if (!strcmp(var.value, "Up to 1")) + g_Config.iInflightFrames = 1; + else if (!strcmp(var.value, "Up to 2")) + g_Config.iInflightFrames = 2; + } + + var.key = "ppsspp_gpu_hardware_transform"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bHardwareTransform = false; + else + g_Config.bHardwareTransform = true; + } + + var.key = "ppsspp_software_skinning"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bSoftwareSkinning = false; + else + g_Config.bSoftwareSkinning = true; + } + + var.key = "ppsspp_vertex_cache"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bVertexCache = false; + else + g_Config.bVertexCache = true; + } + + var.key = "ppsspp_lazy_texture_caching"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bTextureBackoffCache = false; + else + g_Config.bTextureBackoffCache = true; + } + + var.key = "ppsspp_retain_changed_textures"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bTextureSecondaryCache = false; + else + g_Config.bTextureSecondaryCache = true; + } + + var.key = "ppsspp_spline_quality"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Low")) + g_Config.iSplineBezierQuality = 0; + else if (!strcmp(var.value, "Medium")) + g_Config.iSplineBezierQuality = 1; + else if (!strcmp(var.value, "High")) + g_Config.iSplineBezierQuality = 2; + } + + var.key = "ppsspp_hardware_tesselation"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bHardwareTessellation = false; + else + g_Config.bHardwareTessellation = true; + } + + var.key = "ppsspp_lower_resolution_for_effects"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.iBloomHack = 0; + else if (!strcmp(var.value, "Safe")) + g_Config.iBloomHack = 1; + else if (!strcmp(var.value, "Balanced")) + g_Config.iBloomHack = 2; + else if (!strcmp(var.value, "Aggressive")) + g_Config.iBloomHack = 3; + } + + var.key = "ppsspp_texture_scaling_type"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + iTexScalingType_prev = g_Config.iTexScalingType; + + if (!strcmp(var.value, "xbrz")) + g_Config.iTexScalingType = TextureScalerCommon::XBRZ; + else if (!strcmp(var.value, "hybrid")) + g_Config.iTexScalingType = TextureScalerCommon::HYBRID; + else if (!strcmp(var.value, "bicubic")) + g_Config.iTexScalingType = TextureScalerCommon::BICUBIC; + else if (!strcmp(var.value, "hybrid_bicubic")) + g_Config.iTexScalingType = TextureScalerCommon::HYBRID_BICUBIC; + } + + var.key = "ppsspp_texture_scaling_level"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + iTexScalingLevel_prev = g_Config.iTexScalingLevel; + + if (!strcmp(var.value, "disabled")) + g_Config.iTexScalingLevel = 1; + else if (!strcmp(var.value, "2x")) + g_Config.iTexScalingLevel = 2; + else if (!strcmp(var.value, "3x")) + g_Config.iTexScalingLevel = 3; + else if (!strcmp(var.value, "4x")) + g_Config.iTexScalingLevel = 4; + else if (!strcmp(var.value, "5x")) + g_Config.iTexScalingLevel = 5; + } + + var.key = "ppsspp_texture_deposterize"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bTexDeposterize = false; + else + g_Config.bTexDeposterize = true; + } + + var.key = "ppsspp_texture_shader"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + sTextureShaderName_prev = g_Config.sTextureShaderName; + + if (!strcmp(var.value, "disabled")) + g_Config.sTextureShaderName = "Off"; + else if (!strcmp(var.value, "2xBRZ")) + g_Config.sTextureShaderName = "Tex2xBRZ"; + else if (!strcmp(var.value, "4xBRZ")) + g_Config.sTextureShaderName = "Tex4xBRZ"; + else if (!strcmp(var.value, "MMPX")) + g_Config.sTextureShaderName = "TexMMPX"; + } + + var.key = "ppsspp_texture_anisotropic_filtering"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.iAnisotropyLevel = 0; + else if (!strcmp(var.value, "2x")) + g_Config.iAnisotropyLevel = 1; + else if (!strcmp(var.value, "4x")) + g_Config.iAnisotropyLevel = 2; + else if (!strcmp(var.value, "8x")) + g_Config.iAnisotropyLevel = 3; + else if (!strcmp(var.value, "16x")) + g_Config.iAnisotropyLevel = 4; + } + + var.key = "ppsspp_texture_filtering"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "Auto")) + g_Config.iTexFiltering = 1; + else if (!strcmp(var.value, "Nearest")) + g_Config.iTexFiltering = 2; + else if (!strcmp(var.value, "Linear")) + g_Config.iTexFiltering = 3; + else if (!strcmp(var.value, "Auto max quality")) + g_Config.iTexFiltering = 4; + } + + var.key = "ppsspp_texture_replacement"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bReplaceTextures = false; + else + g_Config.bReplaceTextures = true; + } + + var.key = "ppsspp_enable_wlan"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableWlan = false; + else + g_Config.bEnableWlan = true; + } + + var.key = "ppsspp_wlan_channel"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iWlanAdhocChannel = atoi(var.value); + + var.key = "ppsspp_enable_builtin_pro_ad_hoc_server"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableAdhocServer = false; + else + g_Config.bEnableAdhocServer = true; + } + + var.key = "ppsspp_change_pro_ad_hoc_server_address"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + changeProAdhocServer = var.value; + + var.key = "ppsspp_enable_upnp"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bEnableUPnP = false; + else + g_Config.bEnableUPnP = true; + } + + var.key = "ppsspp_upnp_use_original_port"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bUPnPUseOriginalPort = false; + else + g_Config.bUPnPUseOriginalPort = true; + } + + var.key = "ppsspp_port_offset"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iPortOffset = atoi(var.value); + + var.key = "ppsspp_minimum_timeout"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + g_Config.iMinTimeout = atoi(var.value); + + var.key = "ppsspp_forced_first_connect"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bForcedFirstConnect = false; + else + g_Config.bForcedFirstConnect = true; + } + + std::string ppsspp_change_mac_address[12]; + int ppsspp_pro_ad_hoc_ipv4[12]; + char key[64] = {0}; + var.key = key; + g_Config.sMACAddress = ""; + g_Config.proAdhocServer = ""; + for (int i = 0; i < 12; i++) + { + snprintf(key, sizeof(key), "ppsspp_change_mac_address%02d", i + 1); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + ppsspp_change_mac_address[i] = var.value; + + if (i && i % 2 == 0) + g_Config.sMACAddress += ":"; + + g_Config.sMACAddress += ppsspp_change_mac_address[i]; + } + + snprintf(key, sizeof(key), "ppsspp_pro_ad_hoc_server_address%02d", i + 1); + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + ppsspp_pro_ad_hoc_ipv4[i] = atoi(var.value); + } + + if (g_Config.sMACAddress == "00:00:00:00:00:00") + { + g_Config.sMACAddress = CreateRandMAC(); + + for (int i = 0; i < 12; i++) + { + snprintf(key, sizeof(key), "ppsspp_change_mac_address%02d", i + 1); + std::string digit = {g_Config.sMACAddress[i + i / 2]}; + var.value = digit.c_str(); + environ_cb(RETRO_ENVIRONMENT_SET_VARIABLE, &var); + } + } + + if (changeProAdhocServer == "IP address") + { + g_Config.proAdhocServer = ""; + for (int i = 0; i < 12; i++) + { + if (i && i % 3 == 0) + g_Config.proAdhocServer += '.'; + + int addressPt = ppsspp_pro_ad_hoc_ipv4[i]; + g_Config.proAdhocServer += static_cast('0' + addressPt); + } + } + else + g_Config.proAdhocServer = changeProAdhocServer; + + g_Config.bTexHardwareScaling = g_Config.sTextureShaderName != "Off"; + + if (gpu && (g_Config.iTexScalingType != iTexScalingType_prev + || g_Config.iTexScalingLevel != iTexScalingLevel_prev + || g_Config.sTextureShaderName != sTextureShaderName_prev)) { gpu->ClearCacheNextFrame(); gpu->Resized(); } - ppsspp_language.Update(&g_Config.iLanguage); if (g_Config.iLanguage < 0) g_Config.iLanguage = get_language_auto(); @@ -864,7 +1129,7 @@ static void check_variables(CoreParameter &coreParam) updateAvInfo = true; } - if (ppsspp_internal_resolution.Update(&g_Config.iInternalResolution) && !PSP_IsInited()) + if (g_Config.iInternalResolution != iInternalResolution_prev && !PSP_IsInited()) { coreParam.pixelWidth = coreParam.renderWidth = g_Config.iInternalResolution * 480; coreParam.pixelHeight = coreParam.renderHeight = g_Config.iInternalResolution * 272; @@ -889,40 +1154,6 @@ static void check_variables(CoreParameter &coreParam) bool isFastForwarding = environ_cb(RETRO_ENVIRONMENT_GET_FASTFORWARDING, &isFastForwarding); coreParam.fastForward = isFastForwarding; - ppsspp_enable_wlan.Update(&g_Config.bEnableWlan); - ppsspp_wlan_channel.Update(&g_Config.iWlanAdhocChannel); - ppsspp_enable_builtin_pro_ad_hoc_server.Update(&g_Config.bEnableAdhocServer); - - ppsspp_upnp_use_original_port.Update(&g_Config.bUPnPUseOriginalPort); - ppsspp_port_offset.Update(&g_Config.iPortOffset); - ppsspp_minimum_timeout.Update(&g_Config.iMinTimeout); - ppsspp_forced_first_connect.Update(&g_Config.bForcedFirstConnect); - - g_Config.sMACAddress = ""; - for (int i = 0; i < 12;) - { - std::string digit; - ppsspp_change_mac_address[i].Update(&digit); - g_Config.sMACAddress += digit; - - if (++i == 12) - break; - - if (i % 2 == 0) - g_Config.sMACAddress += ":"; - } - - if (g_Config.sMACAddress == "00:00:00:00:00:00") - { - g_Config.sMACAddress = CreateRandMAC(); - - for (int i = 0; i < 12; ++i) - { - std::string digit = {g_Config.sMACAddress[i + i / 2]}; - ppsspp_change_mac_address[i].Set(digit.c_str()); - } - } - set_variable_visibility(); } @@ -1018,6 +1249,7 @@ void retro_deinit(void) host = nullptr; libretro_supports_bitmasks = false; + libretro_supports_option_categories = false; VsyncSwapIntervalReset(); AudioBufferDeinit(); diff --git a/libretro/libretro.h b/libretro/libretro.h index 2f17483701..bb114aed35 100644 --- a/libretro/libretro.h +++ b/libretro/libretro.h @@ -283,6 +283,12 @@ enum retro_language RETRO_LANGUAGE_HEBREW = 21, RETRO_LANGUAGE_ASTURIAN = 22, RETRO_LANGUAGE_FINNISH = 23, + RETRO_LANGUAGE_INDONESIAN = 24, + RETRO_LANGUAGE_SWEDISH = 25, + RETRO_LANGUAGE_UKRAINIAN = 26, + RETRO_LANGUAGE_CZECH = 27, + RETRO_LANGUAGE_CATALAN_VALENCIA = 28, + RETRO_LANGUAGE_CATALAN = 29, RETRO_LANGUAGE_LAST, /* Ensure sizeof(enum) == sizeof(int) */ @@ -1753,6 +1759,12 @@ enum retro_mod * the frontend is attempting to call retro_run(). */ +#define RETRO_ENVIRONMENT_GET_SAVESTATE_CONTEXT (72 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* int * -- + * Tells the core about the context the frontend is asking for savestate. + * (see enum retro_savestate_context) + */ + /* VFS functionality */ /* File paths: @@ -2990,6 +3002,35 @@ enum retro_pixel_format RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX }; +enum retro_savestate_context +{ + /* Standard savestate written to disk. */ + RETRO_SAVESTATE_CONTEXT_NORMAL = 0, + + /* Savestate where you are guaranteed that the same instance will load the save state. + * You can store internal pointers to code or data. + * It's still a full serialization and deserialization, and could be loaded or saved at any time. + * It won't be written to disk or sent over the network. + */ + RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_INSTANCE = 1, + + /* Savestate where you are guaranteed that the same emulator binary will load that savestate. + * You can skip anything that would slow down saving or loading state but you can not store internal pointers. + * It won't be written to disk or sent over the network. + * Example: "Second Instance" runahead + */ + RETRO_SAVESTATE_CONTEXT_RUNAHEAD_SAME_BINARY = 2, + + /* Savestate used within a rollback netplay feature. + * You should skip anything that would unnecessarily increase bandwidth usage. + * It won't be written to disk but it will be sent over the network. + */ + RETRO_SAVESTATE_CONTEXT_ROLLBACK_NETPLAY = 3, + + /* Ensure sizeof() == sizeof(int). */ + RETRO_SAVESTATE_CONTEXT_UNKNOWN = INT_MAX +}; + struct retro_message { const char *msg; /* Message to be displayed. */ @@ -3461,6 +3502,10 @@ struct retro_core_option_definition const char *default_value; }; +#ifdef __PS3__ +#undef local +#endif + struct retro_core_options_intl { /* Pointer to an array of retro_core_option_definition structs diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h new file mode 100644 index 0000000000..78cab61d7d --- /dev/null +++ b/libretro/libretro_core_options.h @@ -0,0 +1,1359 @@ +#ifndef LIBRETRO_CORE_OPTIONS_H__ +#define LIBRETRO_CORE_OPTIONS_H__ + +#include +#include + +#include "libretro.h" +#include "retro_inline.h" + +#ifndef HAVE_NO_LANGEXTRA +#include "libretro_core_options_intl.h" +#endif + +#define BOOL_OPTIONS \ +{ \ + { "disabled", NULL }, \ + { "enabled", NULL }, \ + { NULL, NULL }, \ +} + +#define MAC_ADDRESS_OPTIONS \ +{ \ + { "0", NULL }, \ + { "1", NULL }, \ + { "2", NULL }, \ + { "3", NULL }, \ + { "4", NULL }, \ + { "5", NULL }, \ + { "6", NULL }, \ + { "7", NULL }, \ + { "8", NULL }, \ + { "9", NULL }, \ + { "a", NULL }, \ + { "b", NULL }, \ + { "c", NULL }, \ + { "d", NULL }, \ + { "e", NULL }, \ + { "f", NULL }, \ + { NULL, NULL }, \ +} + +#define IP_ADDRESS_OPTIONS \ +{ \ + { "0", NULL }, \ + { "1", NULL }, \ + { "2", NULL }, \ + { "3", NULL }, \ + { "4", NULL }, \ + { "5", NULL }, \ + { "6", NULL }, \ + { "7", NULL }, \ + { "8", NULL }, \ + { "9", NULL }, \ + { NULL, NULL }, \ +} + +/* + ******************************** + * VERSION: 2.0 + ******************************** + * + * - 2.0: Add support for core options v2 interface + * - 1.3: Move translations to libretro_core_options_intl.h + * - libretro_core_options_intl.h includes BOM and utf-8 + * fix for MSVC 2010-2013 + * - Added HAVE_NO_LANGEXTRA flag to disable translations + * on platforms/compilers without BOM support + * - 1.2: Use core options v1 interface when + * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1 + * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1) + * - 1.1: Support generation of core options v0 retro_core_option_value + * arrays containing options with a single value + * - 1.0: First commit +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ******************************** + * Core Option Definitions + ******************************** +*/ + +/* RETRO_LANGUAGE_ENGLISH */ + +/* Default language: + * - All other languages must include the same keys and values + * - Will be used as a fallback in the event that frontend language + * is not available + * - Will be used as a fallback for any missing entries in + * frontend language definition */ + +struct retro_core_option_v2_category option_cats_us[] = { + { + "system", + "System", + "Configure system options." + }, + { + "video", + "Video", + "Configure video options." + }, + { + "network", + "Network", + "Configure network options." + }, + { NULL, NULL, NULL }, +}; + +struct retro_core_option_v2_definition option_defs_us[] = { + { + "ppsspp_language", + "Language", + NULL, + "Choose language, 'Automatic' will use the frontend language.", + NULL, + "system", + { + { "Automatic", NULL }, + { "English", NULL }, + { "Japanese", NULL }, + { "French", NULL }, + { "Spanish", NULL }, + { "German", NULL }, + { "Italian", NULL }, + { "Dutch", NULL }, + { "Portuguese", NULL }, + { "Russian", NULL }, + { "Korean", NULL }, + { "Chinese Traditional", NULL }, + { "Chinese Simplified", NULL }, + { NULL, NULL }, + }, + "Automatic" + }, + { + "ppsspp_cpu_core", + "CPU Core", + NULL, + NULL, + NULL, + "system", + { + { "JIT", "Dynarec (JIT)" }, + { "IR JIT", "IR Interpreter" }, + { "Interpreter", NULL }, + { NULL, NULL }, + }, + "JIT" + }, + { + "ppsspp_fast_memory", + "Fast Memory", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_ignore_bad_memory_access", + "Ignore Bad Memory Accesses", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_io_timing_method", + "I/O Timing Method", + NULL, + NULL, + NULL, + "system", + { + { "Fast", NULL }, + { "Host", NULL }, + { "Simulate UMD delays", NULL }, + { NULL, NULL }, + }, + "Fast" + }, + { + "ppsspp_force_lag_sync", + "Force Real Clock Sync (Slower, less lag)", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_locked_cpu_speed", + "Locked CPU Speed", + NULL, + NULL, + NULL, + "system", + { + { "disabled", NULL }, + { "222MHz", NULL }, + { "266MHz", NULL }, + { "333MHz", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_cache_iso", + "Cache Full ISO in RAM", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_cheats", + "Internal Cheats Support", + NULL, + NULL, + NULL, + "system", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_psp_model", + "PSP Model", + NULL, + NULL, + NULL, + "system", + { + { "psp_1000", "PSP-1000" }, + { "psp_2000_3000", "PSP-2000/3000" }, + { NULL, NULL }, + }, + "psp_2000_3000" + }, + { + "ppsspp_button_preference", + "Confirmation Button", + NULL, + NULL, + NULL, + "system", + { + { "Cross", NULL }, + { "Circle", NULL }, + { NULL, NULL }, + }, + "Cross" + }, + { + "ppsspp_internal_resolution", + "Internal Resolution (Restart)", + NULL, + NULL, + NULL, + "video", + { + { "480x272", NULL }, + { "960x544", NULL }, + { "1440x816", NULL }, + { "1920x1088", NULL }, + { "2400x1360", NULL }, + { "2880x1632", NULL }, + { "3360x1904", NULL }, + { "3840x2176", NULL }, + { "4320x2448", NULL }, + { "4800x2720", NULL }, + { NULL, NULL }, + }, + "480x272" + }, + { + "ppsspp_rendering_mode", + "Rendering Mode", + NULL, + "'Skip Buffer Effects' is faster, but nothing may draw in some games.", + NULL, + "video", + { + { "Buffered", NULL }, + { "Skip Buffer Effects", NULL }, + { NULL, NULL }, + }, + "Buffered" + }, + { + "ppsspp_block_transfer_gpu", + "Block Transfer GPU", + NULL, + "Some games require this to be enabled for correct graphics.", + NULL, + "video", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_frameskip", + "Frameskip", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "1", NULL }, + { "2", NULL }, + { "3", NULL }, + { "4", NULL }, + { "5", NULL }, + { "6", NULL }, + { "7", NULL }, + { "8", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_frameskiptype", + "Frameskip Type", + NULL, + NULL, + NULL, + "video", + { + { "Number of frames", NULL }, + { "Percent of FPS", NULL }, + { NULL, NULL }, + }, + "Number of frames" + }, + { + "ppsspp_auto_frameskip", + "Auto Frameskip", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_frame_duplication", + "Duplicate Frames in 30 Hz Games", + NULL, + "Can make framerate smoother in games that run at lower framerates.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_detect_vsync_swap_interval", + "Detect Frame Rate Changes (Notify frontend)", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_inflight_frames", + "Buffered Frames (GL/Vulkan only, slower, less lag, restart)", + NULL, + NULL, + NULL, + "video", + { + { "No buffer", NULL }, + { "Up to 1", NULL }, + { "Up to 2", NULL }, + { NULL, NULL }, + }, + "Up to 2" + }, + { + "ppsspp_gpu_hardware_transform", + "Hardware Transform", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_software_skinning", + "Software Skinning", + NULL, + "Combine skinned model draws on the CPU, faster in most games.", + NULL, + "video", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_vertex_cache", + "Vertex Cache", + NULL, + "Faster, but may cause temporary flicker.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_lazy_texture_caching", + "Lazy Texture Caching (Speedup)", + NULL, + "Faster, but can cause text problems in a few games.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_retain_changed_textures", + "Retain Changed Textures (Speedup, mem hog)", + NULL, + "Makes many games slower, but some games a lot faster.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_spline_quality", + "Spline/Bezier Curves Quality", + NULL, + "Only used by some games, controls smoothness of curves.", + NULL, + "video", + { + { "Low", NULL }, + { "Medium", NULL }, + { "High", NULL }, + { NULL, NULL }, + }, + "High" + }, + { + "ppsspp_hardware_tesselation", + "Hardware Tesselation", + NULL, + "Uses hardware to make curves.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_lower_resolution_for_effects", + "Lower Resolution for Effects", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "Safe", NULL }, + { "Balanced", NULL }, + { "Aggressive", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_texture_scaling_type", + "Texture Scaling Type", + NULL, + NULL, + NULL, + "video", + { + { "xbrz", "xBRZ" }, + { "hybrid", "Hybrid" }, + { "bicubic", "Bicubic" }, + { "hybrid_bicubic", "Hybrid + Bicubic" }, + { NULL, NULL }, + }, + "xbrz" + }, + { + "ppsspp_texture_scaling_level", + "Texture Scaling Level", + NULL, + "CPU heavy, some scaling may be delayed to avoid stutter.", + NULL, + "video", + { + { "disabled", NULL }, + { "2x", NULL }, + { "3x", NULL }, + { "4x", NULL }, + { "5x", NULL }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_texture_deposterize", + "Texture Deposterize", + NULL, + "Fixes visual banding glitches in upscaled textures.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_texture_shader", + "Texture Shader (Vulkan only, overrides 'Texture Scaling Type')", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "2xBRZ", "Tex2xBRZ" }, + { "4xBRZ", "Tex4xBRZ" }, + { "MMPX", "TexMMPX" }, + { NULL, NULL }, + }, + "disabled" + }, + { + "ppsspp_texture_anisotropic_filtering", + "Anisotropic Filtering", + NULL, + NULL, + NULL, + "video", + { + { "disabled", NULL }, + { "2x", NULL }, + { "4x", NULL }, + { "8x", NULL }, + { "16x", NULL }, + { NULL, NULL }, + }, + "16x" + }, + { + "ppsspp_texture_filtering", + "Texture Filtering", + NULL, + NULL, + NULL, + "video", + { + { "Auto", NULL }, + { "Nearest", NULL }, + { "Linear", NULL }, + { "Auto max quality", NULL }, + { NULL, NULL }, + }, + "Auto" + }, + { + "ppsspp_texture_replacement", + "Texture Replacement", + NULL, + NULL, + NULL, + "video", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_enable_wlan", + "Enable Networking/WLAN (Beta, may break games)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_change_mac_address01", + "MAC Address Pt 1: X-:--:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address02", + "MAC Address Pt 2: -X:--:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address03", + "MAC Address Pt 3: --:X-:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address04", + "MAC Address Pt 4: --:-X:--:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address05", + "MAC Address Pt 5: --:--:X-:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address06", + "MAC Address Pt 6: --:--:-X:--:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address07", + "MAC Address Pt 7: --:--:--:X-:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address08", + "MAC Address Pt 8: --:--:--:-X:--:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address09", + "MAC Address Pt 9: --:--:--:--:X-:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address10", + "MAC Address Pt 10: --:--:--:--:-X:--", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address11", + "MAC Address Pt 11: --:--:--:--:--:X-", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_change_mac_address12", + "MAC Address Pt 12: --:--:--:--:--:-X", + NULL, + NULL, + NULL, + "network", + MAC_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_wlan_channel", + "WLAN Channel", + NULL, + NULL, + NULL, + "network", + { + { "Auto", NULL }, + { "1", NULL }, + { "6", NULL }, + { "11", NULL }, + { NULL, NULL }, + }, + "Auto" + }, + { + "ppsspp_enable_builtin_pro_ad_hoc_server", + "Enable Built-in PRO Ad Hoc Server", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_change_pro_ad_hoc_server_address", + "Change PRO Ad Hoc Server IP Address ('localhost' = multiple instances)", + NULL, + NULL, + NULL, + "network", + { + { "socom.cc", NULL }, + { "psp.gameplayer.club", NULL }, + { "myneighborsushicat.com", NULL }, + { "localhost", NULL }, + { "IP address", NULL }, + { NULL, NULL }, + }, + "socom.cc" + }, + { + "ppsspp_pro_ad_hoc_server_address01", + "PRO Ad Hoc Server IP Address Pt 1: x--.---.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address02", + "PRO Ad Hoc Server IP Address Pt 2: -x-.---.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address03", + "PRO Ad Hoc Server IP Address Pt 3: --x.---.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address04", + "PRO Ad Hoc Server IP Address Pt 4: ---.x--.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address05", + "PRO Ad Hoc Server IP Address Pt 5: ---.-x-.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address06", + "PRO Ad Hoc Server IP Address Pt 6: ---.--x.---.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address07", + "PRO Ad Hoc Server IP Address Pt 7: ---.---.x--.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address08", + "PRO Ad Hoc Server IP Address Pt 8: ---.---.-x-.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address09", + "PRO Ad Hoc Server IP Address Pt 9: ---.---.--x.---", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address10", + "PRO Ad Hoc Server IP Address Pt 10: ---.---.---.x--", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address11", + "PRO Ad Hoc Server IP Address Pt 11: ---.---.---.-x-", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_pro_ad_hoc_server_address12", + "PRO Ad Hoc Server IP Address Pt 12: ---.---.---.--x", + NULL, + NULL, + NULL, + "network", + IP_ADDRESS_OPTIONS, + "0" + }, + { + "ppsspp_enable_upnp", + "Enable UPnP (Need a few seconds to detect)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { + "ppsspp_upnp_use_original_port", + "UPnP Use Original Port ('ON' = PSP compatibility)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "enabled" + }, + { + "ppsspp_port_offset", + "Port Offset ('0' = PSP compatibility)", + NULL, + NULL, + NULL, + "network", + { + { "0", NULL }, + { "1000", NULL }, + { "2000", NULL }, + { "3000", NULL }, + { "4000", NULL }, + { "5000", NULL }, + { "6000", NULL }, + { "7000", NULL }, + { "8000", NULL }, + { "9000", NULL }, + { "10000", NULL }, + { "11000", NULL }, + { "12000", NULL }, + { "13000", NULL }, + { "14000", NULL }, + { "15000", NULL }, + { "16000", NULL }, + { "17000", NULL }, + { "18000", NULL }, + { "19000", NULL }, + { "20000", NULL }, + { "31000", NULL }, + { "32000", NULL }, + { "33000", NULL }, + { "34000", NULL }, + { "35000", NULL }, + { "36000", NULL }, + { "37000", NULL }, + { "38000", NULL }, + { "39000", NULL }, + { "40000", NULL }, + { "41000", NULL }, + { "42000", NULL }, + { "43000", NULL }, + { "44000", NULL }, + { "45000", NULL }, + { "46000", NULL }, + { "47000", NULL }, + { "48000", NULL }, + { "49000", NULL }, + { "50000", NULL }, + { "51000", NULL }, + { "52000", NULL }, + { "53000", NULL }, + { "54000", NULL }, + { "55000", NULL }, + { "56000", NULL }, + { "57000", NULL }, + { "58000", NULL }, + { "59000", NULL }, + { "60000", NULL }, + { "61000", NULL }, + { "62000", NULL }, + { "63000", NULL }, + { "64000", NULL }, + { "65000", NULL }, + { NULL, NULL }, + }, + "0" + }, + { + "ppsspp_minimum_timeout", + "Minimum Timeout (Override in ms, '0' = default)", + NULL, + NULL, + NULL, + "network", + { + { "0", NULL }, + { "100", NULL }, + { "200", NULL }, + { "300", NULL }, + { "400", NULL }, + { "500", NULL }, + { "600", NULL }, + { "700", NULL }, + { "800", NULL }, + { "900", NULL }, + { "1000", NULL }, + { "1100", NULL }, + { "1200", NULL }, + { "1300", NULL }, + { "1400", NULL }, + { "1500", NULL }, + { "1600", NULL }, + { "1700", NULL }, + { "1800", NULL }, + { "1900", NULL }, + { "2000", NULL }, + { "3100", NULL }, + { "3200", NULL }, + { "3300", NULL }, + { "3400", NULL }, + { "3500", NULL }, + { "3600", NULL }, + { "3700", NULL }, + { "3800", NULL }, + { "3900", NULL }, + { "4000", NULL }, + { "4100", NULL }, + { "4200", NULL }, + { "4300", NULL }, + { "4400", NULL }, + { "4500", NULL }, + { "4600", NULL }, + { "4700", NULL }, + { "4800", NULL }, + { "4900", NULL }, + { "5000", NULL }, + { NULL, NULL }, + }, + "0" + }, + { + "ppsspp_forced_first_connect", + "Forced First Connect (Faster connect)", + NULL, + NULL, + NULL, + "network", + BOOL_OPTIONS, + "disabled" + }, + { NULL, NULL, NULL, NULL, NULL, NULL, {{0}}, NULL }, +}; + +struct retro_core_options_v2 options_us = { + option_cats_us, + option_defs_us +}; + +/* + ******************************** + * Language Mapping + ******************************** +*/ + +#ifndef HAVE_NO_LANGEXTRA +struct retro_core_options_v2 *options_intl[RETRO_LANGUAGE_LAST] = { + &options_us, /* RETRO_LANGUAGE_ENGLISH */ + NULL, /* RETRO_LANGUAGE_JAPANESE */ + NULL, /* RETRO_LANGUAGE_FRENCH */ + NULL, /* RETRO_LANGUAGE_SPANISH */ + NULL, /* RETRO_LANGUAGE_GERMAN */ + NULL, /* RETRO_LANGUAGE_ITALIAN */ + NULL, /* RETRO_LANGUAGE_DUTCH */ + NULL, /* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ + NULL, /* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ + NULL, /* RETRO_LANGUAGE_RUSSIAN */ + NULL, /* RETRO_LANGUAGE_KOREAN */ + NULL, /* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ + NULL, /* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ + NULL, /* RETRO_LANGUAGE_ESPERANTO */ + NULL, /* RETRO_LANGUAGE_POLISH */ + NULL, /* RETRO_LANGUAGE_VIETNAMESE */ + NULL, /* RETRO_LANGUAGE_ARABIC */ + NULL, /* RETRO_LANGUAGE_GREEK */ + NULL, /* RETRO_LANGUAGE_TURKISH */ + NULL, /* RETRO_LANGUAGE_SLOVAK */ + NULL, /* RETRO_LANGUAGE_PERSIAN */ + NULL, /* RETRO_LANGUAGE_HEBREW */ + NULL, /* RETRO_LANGUAGE_ASTURIAN */ + NULL, /* RETRO_LANGUAGE_FINNISH */ + NULL, /* RETRO_LANGUAGE_INDONESIAN */ + NULL, /* RETRO_LANGUAGE_SWEDISH */ + NULL, /* RETRO_LANGUAGE_UKRAINIAN */ + NULL, /* RETRO_LANGUAGE_CZECH */ +}; +#endif + +/* + ******************************** + * Functions + ******************************** +*/ + +/* Handles configuration/setting of core options. + * Should be called as early as possible - ideally inside + * retro_set_environment(), and no later than retro_load_game() + * > We place the function body in the header to avoid the + * necessity of adding more .c files (i.e. want this to + * be as painless as possible for core devs) + */ + +static INLINE void libretro_set_core_options(retro_environment_t environ_cb, + bool *categories_supported) +{ + unsigned version = 0; +#ifndef HAVE_NO_LANGEXTRA + unsigned language = 0; +#endif + + if (!environ_cb || !categories_supported) + return; + + *categories_supported = false; + + if (!environ_cb(RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION, &version)) + version = 0; + + if (version >= 2) + { +#ifndef HAVE_NO_LANGEXTRA + struct retro_core_options_v2_intl core_options_intl; + + core_options_intl.us = &options_us; + core_options_intl.local = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && + (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH)) + core_options_intl.local = options_intl[language]; + + *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2_INTL, + &core_options_intl); +#else + *categories_supported = environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_V2, + &options_us); +#endif + } + else + { + size_t i, j; + size_t option_index = 0; + size_t num_options = 0; + struct retro_core_option_definition + *option_v1_defs_us = NULL; +#ifndef HAVE_NO_LANGEXTRA + size_t num_options_intl = 0; + struct retro_core_option_v2_definition + *option_defs_intl = NULL; + struct retro_core_option_definition + *option_v1_defs_intl = NULL; + struct retro_core_options_intl + core_options_v1_intl; +#endif + struct retro_variable *variables = NULL; + char **values_buf = NULL; + + /* Determine total number of options */ + while (true) + { + if (option_defs_us[num_options].key) + num_options++; + else + break; + } + + if (version >= 1) + { + /* Allocate US array */ + option_v1_defs_us = (struct retro_core_option_definition *) + calloc(num_options + 1, sizeof(struct retro_core_option_definition)); + + /* Copy parameters from option_defs_us array */ + for (i = 0; i < num_options; i++) + { + struct retro_core_option_v2_definition *option_def_us = &option_defs_us[i]; + struct retro_core_option_value *option_values = option_def_us->values; + struct retro_core_option_definition *option_v1_def_us = &option_v1_defs_us[i]; + struct retro_core_option_value *option_v1_values = option_v1_def_us->values; + + option_v1_def_us->key = option_def_us->key; + option_v1_def_us->desc = option_def_us->desc; + option_v1_def_us->info = option_def_us->info; + option_v1_def_us->default_value = option_def_us->default_value; + + /* Values must be copied individually... */ + while (option_values->value) + { + option_v1_values->value = option_values->value; + option_v1_values->label = option_values->label; + + option_values++; + option_v1_values++; + } + } + +#ifndef HAVE_NO_LANGEXTRA + if (environ_cb(RETRO_ENVIRONMENT_GET_LANGUAGE, &language) && + (language < RETRO_LANGUAGE_LAST) && (language != RETRO_LANGUAGE_ENGLISH) && + options_intl[language]) + option_defs_intl = options_intl[language]->definitions; + + if (option_defs_intl) + { + /* Determine number of intl options */ + while (true) + { + if (option_defs_intl[num_options_intl].key) + num_options_intl++; + else + break; + } + + /* Allocate intl array */ + option_v1_defs_intl = (struct retro_core_option_definition *) + calloc(num_options_intl + 1, sizeof(struct retro_core_option_definition)); + + /* Copy parameters from option_defs_intl array */ + for (i = 0; i < num_options_intl; i++) + { + struct retro_core_option_v2_definition *option_def_intl = &option_defs_intl[i]; + struct retro_core_option_value *option_values = option_def_intl->values; + struct retro_core_option_definition *option_v1_def_intl = &option_v1_defs_intl[i]; + struct retro_core_option_value *option_v1_values = option_v1_def_intl->values; + + option_v1_def_intl->key = option_def_intl->key; + option_v1_def_intl->desc = option_def_intl->desc; + option_v1_def_intl->info = option_def_intl->info; + option_v1_def_intl->default_value = option_def_intl->default_value; + + /* Values must be copied individually... */ + while (option_values->value) + { + option_v1_values->value = option_values->value; + option_v1_values->label = option_values->label; + + option_values++; + option_v1_values++; + } + } + } + + core_options_v1_intl.us = option_v1_defs_us; + core_options_v1_intl.local = option_v1_defs_intl; + + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL, &core_options_v1_intl); +#else + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS, option_v1_defs_us); +#endif + } + else + { + /* Allocate arrays */ + variables = (struct retro_variable *)calloc(num_options + 1, + sizeof(struct retro_variable)); + values_buf = (char **)calloc(num_options, sizeof(char *)); + + if (!variables || !values_buf) + goto error; + + /* Copy parameters from option_defs_us array */ + for (i = 0; i < num_options; i++) + { + const char *key = option_defs_us[i].key; + const char *desc = option_defs_us[i].desc; + const char *default_value = option_defs_us[i].default_value; + struct retro_core_option_value *values = option_defs_us[i].values; + size_t buf_len = 3; + size_t default_index = 0; + + values_buf[i] = NULL; + + if (desc) + { + size_t num_values = 0; + + /* Determine number of values */ + while (true) + { + if (values[num_values].value) + { + /* Check if this is the default value */ + if (default_value) + if (strcmp(values[num_values].value, default_value) == 0) + default_index = num_values; + + buf_len += strlen(values[num_values].value); + num_values++; + } + else + break; + } + + /* Build values string */ + if (num_values > 0) + { + buf_len += num_values - 1; + buf_len += strlen(desc); + + values_buf[i] = (char *)calloc(buf_len, sizeof(char)); + if (!values_buf[i]) + goto error; + + strcpy(values_buf[i], desc); + strcat(values_buf[i], "; "); + + /* Default value goes first */ + strcat(values_buf[i], values[default_index].value); + + /* Add remaining values */ + for (j = 0; j < num_values; j++) + { + if (j != default_index) + { + strcat(values_buf[i], "|"); + strcat(values_buf[i], values[j].value); + } + } + } + } + + variables[option_index].key = key; + variables[option_index].value = values_buf[i]; + option_index++; + } + + /* Set variables */ + environ_cb(RETRO_ENVIRONMENT_SET_VARIABLES, variables); + } + +error: + /* Clean up */ + + if (option_v1_defs_us) + { + free(option_v1_defs_us); + option_v1_defs_us = NULL; + } + +#ifndef HAVE_NO_LANGEXTRA + if (option_v1_defs_intl) + { + free(option_v1_defs_intl); + option_v1_defs_intl = NULL; + } +#endif + + if (values_buf) + { + for (i = 0; i < num_options; i++) + { + if (values_buf[i]) + { + free(values_buf[i]); + values_buf[i] = NULL; + } + } + + free(values_buf); + values_buf = NULL; + } + + if (variables) + { + free(variables); + variables = NULL; + } + } +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libretro/libretro_core_options_intl.h b/libretro/libretro_core_options_intl.h new file mode 100644 index 0000000000..b2649b6b5e --- /dev/null +++ b/libretro/libretro_core_options_intl.h @@ -0,0 +1,91 @@ +#ifndef LIBRETRO_CORE_OPTIONS_INTL_H__ +#define LIBRETRO_CORE_OPTIONS_INTL_H__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1500 && _MSC_VER < 1900) +/* https://support.microsoft.com/en-us/kb/980263 */ +#pragma execution_character_set("utf-8") +#pragma warning(disable:4566) +#endif + +#include "libretro.h" + +/* + ******************************** + * VERSION: 2.0 + ******************************** + * + * - 2.0: Add support for core options v2 interface + * - 1.3: Move translations to libretro_core_options_intl.h + * - libretro_core_options_intl.h includes BOM and utf-8 + * fix for MSVC 2010-2013 + * - Added HAVE_NO_LANGEXTRA flag to disable translations + * on platforms/compilers without BOM support + * - 1.2: Use core options v1 interface when + * RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION is >= 1 + * (previously required RETRO_ENVIRONMENT_GET_CORE_OPTIONS_VERSION == 1) + * - 1.1: Support generation of core options v0 retro_core_option_value + * arrays containing options with a single value + * - 1.0: First commit +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + ******************************** + * Core Option Definitions + ******************************** +*/ + +/* RETRO_LANGUAGE_JAPANESE */ + +/* RETRO_LANGUAGE_FRENCH */ + +/* RETRO_LANGUAGE_SPANISH */ + +/* RETRO_LANGUAGE_GERMAN */ + +/* RETRO_LANGUAGE_ITALIAN */ + +/* RETRO_LANGUAGE_DUTCH */ + +/* RETRO_LANGUAGE_PORTUGUESE_BRAZIL */ + +/* RETRO_LANGUAGE_PORTUGUESE_PORTUGAL */ + +/* RETRO_LANGUAGE_RUSSIAN */ + +/* RETRO_LANGUAGE_KOREAN */ + +/* RETRO_LANGUAGE_CHINESE_TRADITIONAL */ + +/* RETRO_LANGUAGE_CHINESE_SIMPLIFIED */ + +/* RETRO_LANGUAGE_ESPERANTO */ + +/* RETRO_LANGUAGE_POLISH */ + +/* RETRO_LANGUAGE_VIETNAMESE */ + +/* RETRO_LANGUAGE_ARABIC */ + +/* RETRO_LANGUAGE_GREEK */ + +/* RETRO_LANGUAGE_TURKISH */ + +/* RETRO_LANGUAGE_SLOVAK */ + +/* RETRO_LANGUAGE_PERSIAN */ + +/* RETRO_LANGUAGE_HEBREW */ + +/* RETRO_LANGUAGE_ASTURIAN */ + +/* RETRO_LANGUAGE_FINNISH */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libretro/retro_inline.h b/libretro/retro_inline.h new file mode 100644 index 0000000000..b27d6dd6d4 --- /dev/null +++ b/libretro/retro_inline.h @@ -0,0 +1,39 @@ +/* Copyright (C) 2010-2020 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (retro_inline.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LIBRETRO_SDK_INLINE_H +#define __LIBRETRO_SDK_INLINE_H + +#ifndef INLINE + +#if defined(_WIN32) || defined(__INTEL_COMPILER) +#define INLINE __inline +#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L +#define INLINE inline +#elif defined(__GNUC__) +#define INLINE __inline__ +#else +#define INLINE +#endif + +#endif +#endif From c6b83dd9d8687fa012899ec355e19509115ad4dd Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 3 Nov 2022 20:00:30 +0100 Subject: [PATCH 331/374] OpenXR - Enable camera movement and stereo in flatscreen mode --- Common/VR/PPSSPPVR.cpp | 33 +++++++++++++++++---------------- Common/VR/PPSSPPVR.h | 2 ++ Common/VR/VRRenderer.cpp | 8 +++++++- GPU/GLES/ShaderManagerGLES.cpp | 3 ++- UI/GameSettingsScreen.cpp | 3 +-- 5 files changed, 29 insertions(+), 20 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 0c496d55e0..ead9690173 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -453,22 +453,7 @@ bool Is2DVRObject(float* projMatrix, bool ortho) { return identity; } -void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { - - // Update project matrices - float* dst[] = {leftEye, rightEye}; - VRMatrix enums[] = {VR_PROJECTION_MATRIX_LEFT_EYE, VR_PROJECTION_MATRIX_RIGHT_EYE}; - for (int index = 0; index < 2; index++) { - ovrMatrix4f hmdProjection = VR_GetMatrix(enums[index]); - for (int i = 0; i < 4; i++) { - for (int j = 0; j < 4; j++) { - if ((hmdProjection.M[i][j] > 0) != (projMatrix[i * 4 + j] > 0)) { - hmdProjection.M[i][j] *= -1.0f; - } - } - } - memcpy(dst[index], hmdProjection.M, 16 * sizeof(float)); - } +void UpdateVRParams(float* projMatrix) { // Set mirroring of axes if (!VR_GetConfig(VR_CONFIG_MIRROR_UPDATED)) { @@ -506,6 +491,22 @@ void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { VR_SetConfig(VR_CONFIG_6DOF_SCALE, (int)(scale * 1000000)); } +void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { + float* dst[] = {leftEye, rightEye}; + VRMatrix enums[] = {VR_PROJECTION_MATRIX_LEFT_EYE, VR_PROJECTION_MATRIX_RIGHT_EYE}; + for (int index = 0; index < 2; index++) { + ovrMatrix4f hmdProjection = VR_GetMatrix(enums[index]); + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + if ((hmdProjection.M[i][j] > 0) != (projMatrix[i * 4 + j] > 0)) { + hmdProjection.M[i][j] *= -1.0f; + } + } + } + memcpy(dst[index], hmdProjection.M, 16 * sizeof(float)); + } +} + void UpdateVRView(float* leftEye, float* rightEye) { float* dst[] = {leftEye, rightEye}; VRMatrix enums[] = {VR_VIEW_MATRIX_LEFT_EYE, VR_VIEW_MATRIX_RIGHT_EYE}; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 440f27859d..e926b9957a 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -42,6 +42,7 @@ int GetVRPassesCount(); bool IsMultiviewSupported(); bool IsFlatVRScene(); bool Is2DVRObject(float* projMatrix, bool ortho); +void UpdateVRParams(float* projMatrix); void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye); void UpdateVRView(float* leftEye, float* rightEye); @@ -70,6 +71,7 @@ inline int GetVRPassesCount() { return 1; } inline bool IsMultiviewSupported() { return false; } inline bool IsFlatVRScene() { return true; } inline bool Is2DVRObject(float* projMatrix, bool ortho) { return false; } +inline void UpdateVRParams(float* projMatrix) {} inline void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) {} inline void UpdateVRView(float* leftEye, float* rightEye) {} diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 3d4cce0222..c91d2f045f 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -306,7 +306,13 @@ bool VR_InitFrame( engine_t* engine ) { float nearPlane = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; vrMatrix[matrix] = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, nearPlane, 0.0f ); } else if ((matrix == VR_VIEW_MATRIX_LEFT_EYE) || (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { + bool flatScreen = false; XrPosef invView = invViewTransform[0]; + int vrMode = vrConfig[VR_CONFIG_MODE]; + if ((vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN)) { + invView = XrPosef_Identity(); + flatScreen = true; + } // get axis mirroring configuration float mx = vrConfig[VR_CONFIG_MIRROR_PITCH] ? -1 : 1; @@ -333,7 +339,7 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix] = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.000001f; - if (vrConfig[VR_CONFIG_6DOF_ENABLED]) { + if (!flatScreen && vrConfig[VR_CONFIG_6DOF_ENABLED]) { vrMatrix[matrix].M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index e4a6350de1..118c8c3fed 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -411,6 +411,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu } else { UpdateVRProjection(gstate.projMatrix, leftEyeMatrix.m, rightEyeMatrix.m); } + UpdateVRParams(gstate.projMatrix); FlipProjMatrix(leftEyeMatrix, useBufferedRendering); FlipProjMatrix(rightEyeMatrix, useBufferedRendering); @@ -542,7 +543,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu float rightEyeView[16]; ConvertMatrix4x3To4x4Transposed(leftEyeView, gstate.viewMatrix); ConvertMatrix4x3To4x4Transposed(rightEyeView, gstate.viewMatrix); - if (!flatScreen && !is2D) { + if (!is2D) { UpdateVRView(leftEyeView, rightEyeView); } render_->SetUniformM4x4Stereo("u_view", &u_view, leftEyeView, rightEyeView); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 6b68d9c866..78a162f3b3 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1161,8 +1161,7 @@ void GameSettingsScreen::CreateViews() { vrSettings->Add(new CheckBox(&g_Config.bEnableVR, vr->T("Virtual reality"))); CheckBox *vr6DoF = vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("6DoF movement"))); vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); - CheckBox *vrStereo = vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); - vrStereo->SetEnabledPtr(&g_Config.bEnableVR); + vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); From 1d452a2e0148a74a405ba388b33aba6b3d167fd9 Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 3 Nov 2022 21:33:46 +0100 Subject: [PATCH 332/374] OpenXR - Add an option to disable 72Hz update --- Common/VR/PPSSPPVR.cpp | 3 +-- Core/Config.cpp | 1 + Core/Config.h | 1 + UI/GameSettingsScreen.cpp | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index ead9690173..5a81f71eec 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -111,8 +111,6 @@ void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { java.AppVersion = version; strcpy(java.AppName, name); VR_Init(java, useVulkan); - - __DisplaySetFramerate(72); } #endif @@ -376,6 +374,7 @@ bool StartVRRender() { } // Set customizations + __DisplaySetFramerate(g_Config.bForce72Hz ? 72 : 60); VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000); diff --git a/Core/Config.cpp b/Core/Config.cpp index f62a4baaae..03a5bb26ee 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1208,6 +1208,7 @@ static ConfigSetting vrSettings[] = { ConfigSetting("VREnable", &g_Config.bEnableVR, true), ConfigSetting("VREnable6DoF", &g_Config.bEnable6DoF, true), ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false), + ConfigSetting("VRbForce72Hz", &g_Config.bForce72Hz, true), ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f), ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f), ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f), diff --git a/Core/Config.h b/Core/Config.h index a494cf4c61..4e15c3bb4b 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -463,6 +463,7 @@ public: bool bEnableVR; bool bEnable6DoF; bool bEnableStereo; + bool bForce72Hz; float fCameraDistance; float fCameraHeight; float fCameraSide; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 78a162f3b3..b6c3e06a8e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1162,6 +1162,7 @@ void GameSettingsScreen::CreateViews() { CheckBox *vr6DoF = vrSettings->Add(new CheckBox(&g_Config.bEnable6DoF, vr->T("6DoF movement"))); vr6DoF->SetEnabledPtr(&g_Config.bEnableVR); vrSettings->Add(new CheckBox(&g_Config.bEnableStereo, vr->T("Stereoscopic vision (Experimental)"))); + vrSettings->Add(new CheckBox(&g_Config.bForce72Hz, vr->T("Force 72Hz update"))); vrSettings->Add(new ItemHeader(vr->T("VR camera"))); vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), "")); From f8d29e0d19799ca78d8f14432956c46919e54fb7 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 4 Nov 2022 13:52:32 +0100 Subject: [PATCH 333/374] OpenXR - Fix ifdef ANDROID --- Common/VR/PPSSPPVR.cpp | 6 ++--- Common/VR/PPSSPPVR.h | 4 ++-- Common/VR/VRBase.cpp | 51 +++++++++++++++++++++--------------------- Common/VR/VRBase.h | 10 +-------- 4 files changed, 30 insertions(+), 41 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index ead9690173..26dd5a3137 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -102,15 +102,13 @@ bool IsVRBuild() { } #if PPSSPP_PLATFORM(ANDROID) -void InitVROnAndroid(void* vm, void* activity, int version, const char* name) { +void InitVROnAndroid(void* vm, void* activity, int version, char* name) { bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN; ovrJava java; java.Vm = (JavaVM*)vm; java.ActivityObject = (jobject)activity; - java.AppVersion = version; - strcpy(java.AppName, name); - VR_Init(java, useVulkan); + VR_Init(&java, useVulkan, name, version); __DisplaySetFramerate(72); } diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index e926b9957a..153dce24af 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -21,7 +21,7 @@ enum VRCompatFlag { // VR app flow integration bool IsVRBuild(); -void InitVROnAndroid(void* vm, void* activity, int version, const char* name); +void InitVROnAndroid(void* vm, void* activity, int version, char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); @@ -50,7 +50,7 @@ void UpdateVRView(float* leftEye, float* rightEye); // VR app flow integration inline bool IsVRBuild() { return false; } -inline void InitVROnAndroid(void* vm, void* activity, int version, const char* name) {} +inline void InitVROnAndroid(void* vm, void* activity, int version, char* name) {} inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index e0301bb6e6..7b8ad509ec 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -5,11 +5,10 @@ #include #include -#if defined(ANDROID) && defined(OPENXR) +#if defined(OPENXR) #include -#ifdef OPENXR_PLATFORM_PICO enum ConfigsSetEXT { UNREAL_VERSION = 0, TRACKING_ORIGIN, @@ -37,29 +36,30 @@ PFN_xrSetConfigPICO pfnXrSetConfigPICO = nullptr; PFN_xrSetEngineVersionPico pfnXrSetEngineVersionPico = nullptr; PFN_xrStartCVControllerThreadPico pfnXrStartCVControllerThreadPico = nullptr; PFN_xrStopCVControllerThreadPico pfnXrStopCVControllerThreadPico = nullptr; -#endif static engine_t vr_engine; int vr_initialized = 0; -void VR_Init( ovrJava java, bool useVulkan ) { +void VR_Init( void* system, bool useVulkan, char* name, int version ) { if (vr_initialized) return; ovrApp_Clear(&vr_engine.appState); +#ifdef ANDROID PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR; - xrGetInstanceProcAddr( - XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR); + xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR); if (xrInitializeLoaderKHR != NULL) { - XrLoaderInitInfoAndroidKHR loaderInitializeInfoAndroid; - memset(&loaderInitializeInfoAndroid, 0, sizeof(loaderInitializeInfoAndroid)); - loaderInitializeInfoAndroid.type = XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR; - loaderInitializeInfoAndroid.next = NULL; - loaderInitializeInfoAndroid.applicationVM = java.Vm; - loaderInitializeInfoAndroid.applicationContext = java.ActivityObject; - xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfoAndroid); + ovrJava* java = (ovrJava*)system; + XrLoaderInitInfoAndroidKHR loaderInitializeInfo; + memset(&loaderInitializeInfo, 0, sizeof(loaderInitializeInfo)); + loaderInitializeInfo.type = XR_TYPE_LOADER_INIT_INFO_ANDROID_KHR; + loaderInitializeInfo.next = NULL; + loaderInitializeInfo.applicationVM = java->Vm; + loaderInitializeInfo.applicationContext = java->ActivityObject; + xrInitializeLoaderKHR((XrLoaderInitInfoBaseHeaderKHR*)&loaderInitializeInfo); } +#endif std::vector extensions; if (useVulkan) { @@ -84,23 +84,16 @@ void VR_Init( ovrJava java, bool useVulkan ) { // Create the OpenXR instance. XrApplicationInfo appInfo; memset(&appInfo, 0, sizeof(appInfo)); - strcpy(appInfo.applicationName, java.AppName); - strcpy(appInfo.engineName, java.AppName); - appInfo.applicationVersion = java.AppVersion; - appInfo.engineVersion = java.AppVersion; + strcpy(appInfo.applicationName, name); + strcpy(appInfo.engineName, name); + appInfo.applicationVersion = version; + appInfo.engineVersion = version; appInfo.apiVersion = XR_CURRENT_API_VERSION; XrInstanceCreateInfo instanceCreateInfo; memset(&instanceCreateInfo, 0, sizeof(instanceCreateInfo)); instanceCreateInfo.type = XR_TYPE_INSTANCE_CREATE_INFO; -#ifdef OPENXR_PLATFORM_PICO - XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; - instanceCreateInfoAndroid.applicationVM = java.Vm; - instanceCreateInfoAndroid.applicationActivity = java.ActivityObject; - instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid; -#else instanceCreateInfo.next = NULL; -#endif instanceCreateInfo.createFlags = 0; instanceCreateInfo.applicationInfo = appInfo; instanceCreateInfo.enabledApiLayerCount = 0; @@ -108,6 +101,14 @@ void VR_Init( ovrJava java, bool useVulkan ) { instanceCreateInfo.enabledExtensionCount = extensions.size(); instanceCreateInfo.enabledExtensionNames = extensions.data(); +#if defined(ANDROID) && defined(OPENXR_PLATFORM_PICO) + ovrJava* java = (ovrJava*)system; + XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; + instanceCreateInfoAndroid.applicationVM = java->Vm; + instanceCreateInfoAndroid.applicationActivity = java->ActivityObject; + instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid; +#endif + XrResult initResult; OXR(initResult = xrCreateInstance(&instanceCreateInfo, &vr_engine.appState.Instance)); if (initResult != XR_SUCCESS) { @@ -173,8 +174,6 @@ void VR_Init( ovrJava java, bool useVulkan ) { vr_engine.appState.MainThreadTid = gettid(); vr_engine.appState.SystemId = systemId; - - vr_engine.java = java; vr_engine.useVulkan = useVulkan; vr_initialized = 1; } diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 40c377ec84..efff9acc39 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -171,26 +171,18 @@ typedef struct { JavaVM* Vm; jobject ActivityObject; JNIEnv* Env; - char AppName[64]; - int AppVersion; } ovrJava; #endif typedef struct { uint64_t frameIndex; ovrApp appState; -#ifdef ANDROID - ovrJava java; -#endif float predictedDisplayTime; bool useVulkan; XrGraphicsBindingVulkanKHR graphicsBindingVulkan; } engine_t; -#ifdef ANDROID -void VR_Init( ovrJava java, bool useVulkan ); -#endif - +void VR_Init( void* system, bool useVulkan, char* name, int version ); void VR_Destroy( engine_t* engine ); void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ); void VR_LeaveVR( engine_t* engine ); From aafa17fa7332f051c8bd37743a8ee7f6ae963446 Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 4 Nov 2022 14:22:42 +0100 Subject: [PATCH 334/374] OpenXR - Introduce platform flags --- Common/VR/PPSSPPVR.cpp | 13 ++++- Common/VR/VRBase.cpp | 109 +++++++++++++++++++++--------------- Common/VR/VRBase.h | 20 ++++--- Common/VR/VRFramebuffer.cpp | 20 ++----- Common/VR/VRInput.cpp | 32 ++++++----- Common/VR/VRRenderer.cpp | 16 +++--- 6 files changed, 120 insertions(+), 90 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 26dd5a3137..8bdcbf6688 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -103,12 +103,21 @@ bool IsVRBuild() { #if PPSSPP_PLATFORM(ANDROID) void InitVROnAndroid(void* vm, void* activity, int version, char* name) { - bool useVulkan = (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN; + + //TODO:get the flags in runtime +#ifdef OPENXR_PLATFORM_PICO + VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO, true); + VR_SetPlatformFLag(VR_PLATFORM_PICO_INIT, true); +#elifdef OPENXR_PLATFORM_QUEST + VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST, true); + VR_SetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT, true); +#endif + VR_SetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN, (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN); ovrJava java; java.Vm = (JavaVM*)vm; java.ActivityObject = (jobject)activity; - VR_Init(&java, useVulkan, name, version); + VR_Init(&java, name, version); __DisplaySetFramerate(72); } diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index 7b8ad509ec..129d42880f 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -37,10 +37,11 @@ PFN_xrSetEngineVersionPico pfnXrSetEngineVersionPico = nullptr; PFN_xrStartCVControllerThreadPico pfnXrStartCVControllerThreadPico = nullptr; PFN_xrStopCVControllerThreadPico pfnXrStopCVControllerThreadPico = nullptr; +static bool vr_platform[VR_PLATFORM_MAX]; static engine_t vr_engine; int vr_initialized = 0; -void VR_Init( void* system, bool useVulkan, char* name, int version ) { +void VR_Init( void* system, char* name, int version ) { if (vr_initialized) return; @@ -62,24 +63,24 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) { #endif std::vector extensions; - if (useVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); } else { extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME); } extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME); -#ifdef OPENXR_HAS_PERFORMANCE_EXTENSION - extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); - extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME); -#endif -#ifdef OPENXR_PLATFORM_PICO - extensions.push_back(XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME); - extensions.push_back("XR_PICO_android_controller_function_ext_enable"); - extensions.push_back("XR_PICO_view_state_ext_enable"); - extensions.push_back("XR_PICO_frame_end_info_ext"); - extensions.push_back("XR_PICO_configs_ext"); - extensions.push_back("XR_PICO_reset_sensor"); -#endif + if (VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) { + extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); + extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME); + } + if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + extensions.push_back(XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME); + extensions.push_back("XR_PICO_android_controller_function_ext_enable"); + extensions.push_back("XR_PICO_view_state_ext_enable"); + extensions.push_back("XR_PICO_frame_end_info_ext"); + extensions.push_back("XR_PICO_configs_ext"); + extensions.push_back("XR_PICO_reset_sensor"); + } // Create the OpenXR instance. XrApplicationInfo appInfo; @@ -101,12 +102,14 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) { instanceCreateInfo.enabledExtensionCount = extensions.size(); instanceCreateInfo.enabledExtensionNames = extensions.data(); -#if defined(ANDROID) && defined(OPENXR_PLATFORM_PICO) - ovrJava* java = (ovrJava*)system; - XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; - instanceCreateInfoAndroid.applicationVM = java->Vm; - instanceCreateInfoAndroid.applicationActivity = java->ActivityObject; - instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid; +#ifdef ANDROID + if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + ovrJava* java = (ovrJava*)system; + XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; + instanceCreateInfoAndroid.applicationVM = java->Vm; + instanceCreateInfoAndroid.applicationActivity = java->ActivityObject; + instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid; + } #endif XrResult initResult; @@ -116,14 +119,14 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) { exit(1); } -#ifdef OPENXR_PLATFORM_PICO - xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico)); - xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico)); - xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStopCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStopCVControllerThreadPico)); - xrGetInstanceProcAddr(vr_engine.appState.Instance,"xrSetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrSetConfigPICO)); - if (pfnXrSetEngineVersionPico != nullptr) pfnXrSetEngineVersionPico(vr_engine.appState.Instance, "2.8.0.1"); - if (pfnXrStartCVControllerThreadPico != nullptr) pfnXrStartCVControllerThreadPico(vr_engine.appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF); -#endif + if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico)); + xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico)); + xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStopCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStopCVControllerThreadPico)); + xrGetInstanceProcAddr(vr_engine.appState.Instance,"xrSetConfigPICO", (PFN_xrVoidFunction*)(&pfnXrSetConfigPICO)); + if (pfnXrSetEngineVersionPico != nullptr) pfnXrSetEngineVersionPico(vr_engine.appState.Instance, "2.8.0.1"); + if (pfnXrStartCVControllerThreadPico != nullptr) pfnXrStartCVControllerThreadPico(vr_engine.appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF); + } XrInstanceProperties instanceInfo; instanceInfo.type = XR_TYPE_INSTANCE_PROPERTIES; @@ -150,7 +153,7 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) { } // Get the graphics requirements. - if (useVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { PFN_xrGetVulkanGraphicsRequirementsKHR pfnGetVulkanGraphicsRequirementsKHR = NULL; OXR(xrGetInstanceProcAddr( vr_engine.appState.Instance, @@ -174,17 +177,17 @@ void VR_Init( void* system, bool useVulkan, char* name, int version ) { vr_engine.appState.MainThreadTid = gettid(); vr_engine.appState.SystemId = systemId; - vr_engine.useVulkan = useVulkan; vr_initialized = 1; } void VR_Destroy( engine_t* engine ) { if (engine == &vr_engine) { -#ifdef OPENXR_PLATFORM_PICO - if (pfnXrStopCVControllerThreadPico != nullptr) { - pfnXrStopCVControllerThreadPico(engine->appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF); + if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + if (pfnXrStopCVControllerThreadPico != nullptr) { + pfnXrStopCVControllerThreadPico(engine->appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF); + } } -#endif + xrDestroyInstance(engine->appState.Instance); ovrApp_Destroy(&engine->appState); } @@ -199,17 +202,25 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu // Create the OpenXR Session. XrSessionCreateInfo sessionCreateInfo = {}; - XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {}; +#ifdef ANDROID + XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingGL = {}; +#else + XrGraphicsBindingOpenGLWin32KHR graphicsBindingGL = {}; +#endif memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo)); - if (engine->useVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { sessionCreateInfo.next = graphicsBindingVulkan; } else { - graphicsBindingAndroidGLES.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; - graphicsBindingAndroidGLES.next = NULL; - graphicsBindingAndroidGLES.display = eglGetCurrentDisplay(); - graphicsBindingAndroidGLES.config = eglGetCurrentSurface(EGL_DRAW); - graphicsBindingAndroidGLES.context = eglGetCurrentContext(); - sessionCreateInfo.next = &graphicsBindingAndroidGLES; +#ifdef ANDROID + graphicsBindingGL.type = XR_TYPE_GRAPHICS_BINDING_OPENGL_ES_ANDROID_KHR; + graphicsBindingGL.next = NULL; + graphicsBindingGL.display = eglGetCurrentDisplay(); + graphicsBindingGL.config = eglGetCurrentSurface(EGL_DRAW); + graphicsBindingGL.context = eglGetCurrentContext(); +#else + //TODO:PCVR definition +#endif + sessionCreateInfo.next = &graphicsBindingGL; } sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO; sessionCreateInfo.createFlags = 0; @@ -221,9 +232,9 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu ALOGE("Failed to create XR session: %d.", initResult); exit(1); } -#ifdef OPENXR_PLATFORM_PICO - pfnXrSetConfigPICO(engine->appState.Session, TRACKING_ORIGIN, "1"); -#endif + if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + pfnXrSetConfigPICO(engine->appState.Session, TRACKING_ORIGIN, "1"); + } // Create a space to the first path XrReferenceSpaceCreateInfo spaceCreateInfo = {}; @@ -251,4 +262,12 @@ engine_t* VR_GetEngine( void ) { return &vr_engine; } +bool VR_GetPlatformFLag(VRPlatformFlag flag) { + return vr_platform[flag]; +} + +void VR_SetPlatformFLag(VRPlatformFlag flag, bool value) { + vr_platform[flag] = value; +} + #endif diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index efff9acc39..f87778e99e 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -100,10 +100,6 @@ static void OXR_CheckErrors(XrInstance instance, XrResult result, const char* fu #define OXR(func) func; #endif -#ifdef OPENXR_PLATFORM_QUEST -#define OPENXR_HAS_PERFORMANCE_EXTENSION -#endif - enum { ovrMaxLayerCount = 2 }; enum { ovrMaxNumEyes = 2 }; @@ -133,7 +129,6 @@ typedef struct { VkImageView* VKDepthImages; bool Acquired; - bool UseVulkan; XrGraphicsBindingVulkanKHR* VKContext; } ovrFramebuffer; @@ -178,16 +173,27 @@ typedef struct { uint64_t frameIndex; ovrApp appState; float predictedDisplayTime; - bool useVulkan; XrGraphicsBindingVulkanKHR graphicsBindingVulkan; } engine_t; -void VR_Init( void* system, bool useVulkan, char* name, int version ); +enum VRPlatformFlag { + VR_PLATFORM_CONTROLLER_PICO, + VR_PLATFORM_CONTROLLER_QUEST, + VR_PLATFORM_PERFORMANCE_EXT, + VR_PLATFORM_PICO_INIT, + VR_PLATFORM_RENDERER_VULKAN, + VR_PLATFORM_TRACKING_FLOOR, + VR_PLATFORM_MAX +}; + +void VR_Init( void* system, char* name, int version ); void VR_Destroy( engine_t* engine ); void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ); void VR_LeaveVR( engine_t* engine ); engine_t* VR_GetEngine( void ); +bool VR_GetPlatformFLag(VRPlatformFlag flag); +void VR_SetPlatformFLag(VRPlatformFlag flag, bool value); void ovrApp_Clear(ovrApp* app); void ovrApp_Destroy(ovrApp* app); diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 34e3a3cbb4..be4b14c3e0 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -49,7 +49,6 @@ bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int frameBuffer->Width = width; frameBuffer->Height = height; - frameBuffer->UseVulkan = false; if (strstr((const char*)glGetString(GL_EXTENSIONS), "GL_OVR_multiview2") == nullptr) { @@ -142,7 +141,6 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int frameBuffer->Width = width; frameBuffer->Height = height; - frameBuffer->UseVulkan = true; frameBuffer->VKContext = (XrGraphicsBindingVulkanKHR*)context; XrSwapchainCreateInfo swapChainCreateInfo; @@ -242,7 +240,7 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int } void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { - if (frameBuffer->UseVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { for (int i = 0; i < frameBuffer->TextureSwapChainLength; i++) { vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr); vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKDepthImages[i], nullptr); @@ -266,7 +264,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { } void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { - if (frameBuffer->UseVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { #ifdef XR_USE_GRAPHICS_API_OPENGL_ES @@ -298,7 +296,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { ovrFramebuffer_SetCurrent(frameBuffer); - if (frameBuffer->UseVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { #ifdef XR_USE_GRAPHICS_API_OPENGL_ES @@ -320,7 +318,7 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = false; // Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully - if (frameBuffer->UseVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { #ifdef XR_USE_GRAPHICS_API_OPENGL_ES @@ -369,7 +367,7 @@ void ovrRenderer_Destroy(ovrRenderer* renderer) { } void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { - if (renderer->FrameBuffer[0].UseVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { #ifdef XR_USE_GRAPHICS_API_OPENGL_ES @@ -428,14 +426,9 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { XrResult result; OXR(result = xrBeginSession(app->Session, &sessionBeginInfo)); - app->SessionActive = (result == XR_SUCCESS); - // Set session state once we have entered VR mode and have a valid session object. - - // TODO: This should be a runtime check of the extension's presence, no? -#ifdef OPENXR_HAS_PERFORMANCE_EXTENSION - if (app->SessionActive) { + if (app->SessionActive && VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) { XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; @@ -457,7 +450,6 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR, app->MainThreadTid)); OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, app->RenderThreadTid)); } -#endif } else if (state == XR_SESSION_STATE_STOPPING) { assert(app->SessionActive); diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 7ea64f9674..27cf0eb2fd 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -268,25 +268,27 @@ void IN_VRInit( engine_t *engine ) { handPoseRightAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_right", NULL, 1, &rightHandPath); XrPath interactionProfilePath = XR_NULL_PATH; -#ifdef OPENXR_PLATFORM_QUEST - OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/oculus/touch_controller", &interactionProfilePath)); -#elif OPENXR_PLATFORM_PICO - OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/pico/neo3_controller", &interactionProfilePath)); -#endif + if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST)) { + OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/oculus/touch_controller", &interactionProfilePath)); + } else if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO)) { + OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/pico/neo3_controller", &interactionProfilePath)); + } + // Map bindings XrActionSuggestedBinding bindings[32]; // large enough for all profiles int currBinding = 0; -#ifdef OPENXR_PLATFORM_QUEST - bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger"); - bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger"); - bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/menu/click"); -#elif OPENXR_PLATFORM_PICO - bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger/click"); - bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger/click"); - bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/back/click"); - bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/right/input/back/click"); -#endif + + if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST)) { + bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger"); + bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger"); + bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/menu/click"); + } else if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO)) { + bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger/click"); + bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger/click"); + bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/back/click"); + bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/right/input/back/click"); + } bindings[currBinding++] = ActionSuggestedBinding(buttonXAction, "/user/hand/left/input/x/click"); bindings[currBinding++] = ActionSuggestedBinding(buttonYAction, "/user/hand/left/input/y/click"); bindings[currBinding++] = ActionSuggestedBinding(buttonAAction, "/user/hand/right/input/a/click"); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index c91d2f045f..020eae9ae9 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -152,9 +152,10 @@ void VR_Recenter(engine_t* engine) { // Create a default stage space to use if SPACE_TYPE_STAGE is not // supported, or calls to xrGetReferenceSpaceBoundsRect fail. spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL; -#ifdef OPENXR_FLOOR_STAGE - spaceCreateInfo.poseInReferenceSpace.position.y = -1.6750f; -#endif + if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) + { + spaceCreateInfo.poseInReferenceSpace.position.y = -1.6750f; + } OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.FakeStageSpace)); ALOGV("Created fake stage space from local space with offset"); engine->appState.CurrentSpace = engine->appState.FakeStageSpace; @@ -164,9 +165,10 @@ void VR_Recenter(engine_t* engine) { spaceCreateInfo.poseInReferenceSpace.position.y = 0.0; OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.StageSpace)); ALOGV("Created stage space"); -#ifdef OPENXR_FLOOR_STAGE - engine->appState.CurrentSpace = engine->appState.StageSpace; -#endif + if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) + { + engine->appState.CurrentSpace = engine->appState.StageSpace; + } } // Update menu orientation @@ -209,7 +211,7 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView))); void* vulkanContext = nullptr; - if (engine->useVulkan) { + if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { vulkanContext = &engine->graphicsBindingVulkan; } ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer, From aacbe4f4a3b4f2b3a7e6dcb9b3b076c142411d1e Mon Sep 17 00:00:00 2001 From: Lubos Date: Fri, 4 Nov 2022 14:53:07 +0100 Subject: [PATCH 335/374] OpenXR - Get platform flags in runtime --- Common/VR/PPSSPPVR.cpp | 28 +++++++++++++++++++--------- Common/VR/PPSSPPVR.h | 4 ++-- Common/VR/VRBase.cpp | 2 +- android/jni/app-android.cpp | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 8bdcbf6688..5184183864 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -102,18 +102,28 @@ bool IsVRBuild() { } #if PPSSPP_PLATFORM(ANDROID) -void InitVROnAndroid(void* vm, void* activity, int version, char* name) { +void InitVROnAndroid(void* vm, void* activity, const char* system, int version, char* name) { - //TODO:get the flags in runtime -#ifdef OPENXR_PLATFORM_PICO - VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO, true); - VR_SetPlatformFLag(VR_PLATFORM_PICO_INIT, true); -#elifdef OPENXR_PLATFORM_QUEST - VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST, true); - VR_SetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT, true); -#endif + //Get device vendor (uppercase) + char vendor[64]; + sscanf(system, "%[^:]", vendor); + for (unsigned int i = 0; i < strlen(vendor); i++) { + if ((vendor[i] >= 'a') && (vendor[i] <= 'z')) { + vendor[i] = vendor[i] - 'a' + 'A'; + } + } + + //Set platform flags + if (strcmp(vendor, "PICO") == 0) { + VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO, true); + VR_SetPlatformFLag(VR_PLATFORM_PICO_INIT, true); + } else if ((strcmp(vendor, "META") == 0) || (strcmp(vendor, "OCULUS") == 0)) { + VR_SetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST, true); + VR_SetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT, true); + } VR_SetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN, (GPUBackend)g_Config.iGPUBackend == GPUBackend::VULKAN); + //Init VR ovrJava java; java.Vm = (JavaVM*)vm; java.ActivityObject = (jobject)activity; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 153dce24af..f6e2eefb27 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -21,7 +21,7 @@ enum VRCompatFlag { // VR app flow integration bool IsVRBuild(); -void InitVROnAndroid(void* vm, void* activity, int version, char* name); +void InitVROnAndroid(void* vm, void* activity, const char* system, int version, char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); @@ -50,7 +50,7 @@ void UpdateVRView(float* leftEye, float* rightEye); // VR app flow integration inline bool IsVRBuild() { return false; } -inline void InitVROnAndroid(void* vm, void* activity, int version, char* name) {} +inline void InitVROnAndroid(void* vm, void* activity, const char* system, int version, char* name) {} inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index 129d42880f..a548c8a168 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -103,9 +103,9 @@ void VR_Init( void* system, char* name, int version ) { instanceCreateInfo.enabledExtensionNames = extensions.data(); #ifdef ANDROID + XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { ovrJava* java = (ovrJava*)system; - XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; instanceCreateInfoAndroid.applicationVM = java->Vm; instanceCreateInfoAndroid.applicationActivity = java->ActivityObject; instanceCreateInfo.next = (XrBaseInStructure*)&instanceCreateInfoAndroid; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 365bbef903..9e685cfaaf 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -759,7 +759,7 @@ retry: if (IsVRBuild()) { Version gitVer(PPSSPP_GIT_VERSION); - InitVROnAndroid(gJvm, nativeActivity, gitVer.ToInteger(), "PPSSPP"); + InitVROnAndroid(gJvm, nativeActivity, systemName.c_str(), gitVer.ToInteger(), "PPSSPP"); } } From 22980c8b9f51d944a0f36cab4f3c40c71d45ae02 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 5 Nov 2022 10:16:24 +0100 Subject: [PATCH 336/374] Code formatting fixed --- Common/VR/VRRenderer.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 020eae9ae9..2cc95c73c2 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -152,8 +152,7 @@ void VR_Recenter(engine_t* engine) { // Create a default stage space to use if SPACE_TYPE_STAGE is not // supported, or calls to xrGetReferenceSpaceBoundsRect fail. spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL; - if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) - { + if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) { spaceCreateInfo.poseInReferenceSpace.position.y = -1.6750f; } OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.FakeStageSpace)); @@ -165,8 +164,7 @@ void VR_Recenter(engine_t* engine) { spaceCreateInfo.poseInReferenceSpace.position.y = 0.0; OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.StageSpace)); ALOGV("Created stage space"); - if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) - { + if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) { engine->appState.CurrentSpace = engine->appState.StageSpace; } } From a5100d2de0292fed626206bae76ba49cf34b42f3 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sat, 5 Nov 2022 21:44:21 +0100 Subject: [PATCH 337/374] Support Android file intents with up to 3 dots in path --- android/AndroidManifest.xml | 53 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index bee1ccda15..7ce80a7a45 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -70,37 +70,28 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + From 7742fbdeb6aeab258d2ad828c1f0a6a70881ad63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 5 Nov 2022 22:06:53 +0100 Subject: [PATCH 338/374] Switch RenderPassType to be a "proper" bitfield enum. --- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 40 +++++++++++------------ Common/GPU/Vulkan/VulkanQueueRunner.h | 37 +++++++++++---------- Common/GPU/Vulkan/VulkanRenderManager.cpp | 28 ++++++++-------- Common/GPU/Vulkan/VulkanRenderManager.h | 8 ++--- Common/GPU/Vulkan/thin3d_vulkan.cpp | 2 +- 5 files changed, 58 insertions(+), 57 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index bce57f549d..4038c991d1 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -32,12 +32,12 @@ static void MergeRenderAreaRectInto(VkRect2D *dest, VkRect2D &src) { RenderPassType MergeRPTypes(RenderPassType a, RenderPassType b) { // Either both are backbuffer type, or neither are. // These can't merge with other renderpasses - if (a == RP_TYPE_BACKBUFFER || b == RP_TYPE_BACKBUFFER) { + if (a == RenderPassType::BACKBUFFER || b == RenderPassType::BACKBUFFER) { _dbg_assert_(a == b); return a; } - _dbg_assert_((a & RP_TYPE_MULTIVIEW_COLOR) == (b & RP_TYPE_MULTIVIEW_COLOR)); + _dbg_assert_((a & RenderPassType::MULTIVIEW) == (b & RenderPassType::MULTIVIEW)); // The rest we can just OR together to get the maximum feature set. return (RenderPassType)((u32)a | (u32)b); @@ -198,7 +198,7 @@ bool VulkanQueueRunner::InitBackbufferFramebuffers(int width, int height) { VkImageView attachments[2] = { VK_NULL_HANDLE, depth_.view }; VkFramebufferCreateInfo fb_info = { VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; - fb_info.renderPass = GetCompatibleRenderPass()->Get(vulkan_, RP_TYPE_BACKBUFFER); + fb_info.renderPass = GetCompatibleRenderPass()->Get(vulkan_, RenderPassType::BACKBUFFER); fb_info.attachmentCount = 2; fb_info.pAttachments = attachments; fb_info.width = width; @@ -331,7 +331,7 @@ static VkAttachmentStoreOp ConvertStoreAction(VKRRenderPassStoreAction action) { VkRenderPass CreateRenderPass(VulkanContext *vulkan, const RPKey &key, RenderPassType rpType) { bool selfDependency = RenderPassTypeHasInput(rpType); - bool isBackbuffer = rpType == RP_TYPE_BACKBUFFER; + bool isBackbuffer = rpType == RenderPassType::BACKBUFFER; bool hasDepth = RenderPassTypeHasDepth(rpType); bool multiview = RenderPassTypeHasMultiView(rpType); @@ -898,6 +898,18 @@ const char *AspectToString(VkImageAspectFlags aspect) { } } +static const char *rpTypeDebugNames[] = { + "RENDER", + "RENDER_DEPTH", + "RENDER_INPUT", + "RENDER_DEPTH_INPUT", + "MV_RENDER", + "MV_RENDER_DEPTH", + "MV_RENDER_INPUT", + "MV_RENDER_DEPTH_INPUT", + "BACKBUF", +}; + std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { char buffer[256]; switch (step.stepType) { @@ -907,19 +919,7 @@ std::string VulkanQueueRunner::StepToString(const VKRStep &step) const { int h = step.render.framebuffer ? step.render.framebuffer->height : vulkan_->GetBackbufferHeight(); int actual_w = step.render.renderArea.extent.width; int actual_h = step.render.renderArea.extent.height; - const char *renderCmd; - switch (step.render.renderPassType) { - case RP_TYPE_BACKBUFFER: renderCmd = "BACKBUF"; break; - case RP_TYPE_COLOR: renderCmd = "RENDER"; break; - case RP_TYPE_COLOR_DEPTH: renderCmd = "RENDER_DEPTH"; break; - case RP_TYPE_COLOR_INPUT: renderCmd = "RENDER_INPUT"; break; - case RP_TYPE_COLOR_DEPTH_INPUT: renderCmd = "RENDER_DEPTH_INPUT"; break; - case RP_TYPE_MULTIVIEW_COLOR: renderCmd = "MV_RENDER"; break; - case RP_TYPE_MULTIVIEW_COLOR_DEPTH: renderCmd = "MV_RENDER_DEPTH"; break; - case RP_TYPE_MULTIVIEW_COLOR_INPUT: renderCmd = "MV_RENDER_INPUT"; break; - case RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT: renderCmd = "MV_RENDER_DEPTH_INPUT"; break; - default: renderCmd = "N/A"; - } + const char *renderCmd = rpTypeDebugNames[(size_t)step.render.renderPassType]; snprintf(buffer, sizeof(buffer), "%s %s %s (draws: %d, %dx%d/%dx%d)", renderCmd, step.tag, step.render.framebuffer ? step.render.framebuffer->Tag() : "", step.render.numDraws, actual_w, actual_h, w, h); break; } @@ -1459,17 +1459,17 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c { VKRGraphicsPipeline *graphicsPipeline = c.graphics_pipeline.pipeline; if (graphicsPipeline != lastGraphicsPipeline) { - if (!graphicsPipeline->pipeline[rpType]) { + if (!graphicsPipeline->pipeline[(size_t)rpType]) { // NOTE: If render steps got merged, it can happen that, as they ended during recording, // they didn't know their final render pass type so they created the wrong pipelines in EndCurRenderStep(). // Unfortunately I don't know if we can fix it in any more sensible place than here. // Maybe a middle pass. But let's try to just block and compile here for now, this doesn't // happen all that much. - graphicsPipeline->pipeline[rpType] = Promise::CreateEmpty(); + graphicsPipeline->pipeline[(size_t)rpType] = Promise::CreateEmpty(); graphicsPipeline->Create(vulkan_, renderPass->Get(vulkan_, rpType), rpType); } - VkPipeline pipeline = graphicsPipeline->pipeline[rpType]->BlockUntilReady(); + VkPipeline pipeline = graphicsPipeline->pipeline[(size_t)rpType]->BlockUntilReady(); if (pipeline != VK_NULL_HANDLE) { vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); pipelineLayout = c.pipeline.pipelineLayout; diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index 2466e576f7..a3b120e60b 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -54,38 +54,38 @@ enum class PipelineFlags : u8 { ENUM_CLASS_BITOPS(PipelineFlags); // Pipelines need to be created for the right type of render pass. -enum RenderPassType { +// TODO: Rename to RenderPassType? It is currently a bitfield. +// When you add more flags, don't forget to update rpTypeDebugNames[]. +enum class RenderPassType { + DEFAULT = 0, // These eight are organized so that bit 0 is DEPTH and bit 1 is INPUT and bit 2 is MULTIVIEW, so // they can be OR-ed together in MergeRPTypes. - RP_TYPE_COLOR, - RP_TYPE_COLOR_DEPTH, - RP_TYPE_COLOR_INPUT, - RP_TYPE_COLOR_DEPTH_INPUT, - - RP_TYPE_MULTIVIEW_COLOR, - RP_TYPE_MULTIVIEW_COLOR_DEPTH, - RP_TYPE_MULTIVIEW_COLOR_INPUT, - RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT, + HAS_DEPTH = 1, + COLOR_INPUT = 2, // input attachment + MULTIVIEW = 4, // This is the odd one out, and gets special handling in MergeRPTypes. - RP_TYPE_BACKBUFFER, // For the backbuffer we can always use CLEAR/DONT_CARE, so bandwidth cost for a depth channel is negligible. + // If this flag is set, none of the other flags can be set. + // For the backbuffer we can always use CLEAR/DONT_CARE, so bandwidth cost for a depth channel is negligible + // so we don't bother with a non-depth version. + BACKBUFFER = 8, - // Later will add pure-color render passes. - RP_TYPE_COUNT, + TYPE_COUNT = BACKBUFFER + 1, }; +ENUM_CLASS_BITOPS(RenderPassType); // Hm, soon time to exploit the bit properties in these.. inline bool RenderPassTypeHasDepth(RenderPassType type) { - return type == RP_TYPE_BACKBUFFER || type == RP_TYPE_COLOR_DEPTH || type == RP_TYPE_COLOR_DEPTH_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT; + return (type & RenderPassType::HAS_DEPTH) || type == RenderPassType::BACKBUFFER; } inline bool RenderPassTypeHasInput(RenderPassType type) { - return type == RP_TYPE_COLOR_INPUT || type == RP_TYPE_COLOR_DEPTH_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT; + return (type & RenderPassType::COLOR_INPUT) != 0; } inline bool RenderPassTypeHasMultiView(RenderPassType type) { - return type == RP_TYPE_MULTIVIEW_COLOR || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH || type == RP_TYPE_MULTIVIEW_COLOR_INPUT || type == RP_TYPE_MULTIVIEW_COLOR_DEPTH_INPUT; + return (type & RenderPassType::MULTIVIEW) != 0; } struct VkRenderData { @@ -270,7 +270,7 @@ public: VkRenderPass Get(VulkanContext *vulkan, RenderPassType rpType); void Destroy(VulkanContext *vulkan) { - for (int i = 0; i < RP_TYPE_COUNT; i++) { + for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) { if (pass[i]) { vulkan->Delete().QueueDeleteRenderPass(pass[i]); } @@ -278,7 +278,8 @@ public: } private: - VkRenderPass pass[RP_TYPE_COUNT]{}; + // TODO: Might be better off with a hashmap once the render pass type count grows really large.. + VkRenderPass pass[(size_t)RenderPassType::TYPE_COUNT]{}; RPKey key_; }; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 314e1920c3..3c1ea6f07f 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -93,10 +93,10 @@ bool VKRGraphicsPipeline::Create(VulkanContext *vulkan, VkRenderPass compatibleR // Would really like to log more here, we could probably attach more info to desc. // // At least create a null placeholder to avoid creating over and over if something is broken. - pipeline[rpType]->Post(VK_NULL_HANDLE); + pipeline[(size_t)rpType]->Post(VK_NULL_HANDLE); success = false; } else if (result != VK_SUCCESS) { - pipeline[rpType]->Post(VK_NULL_HANDLE); + pipeline[(size_t)rpType]->Post(VK_NULL_HANDLE); ERROR_LOG(G3D, "Failed creating graphics pipeline! result='%s'", VulkanResultToString(result)); success = false; } else { @@ -104,14 +104,14 @@ bool VKRGraphicsPipeline::Create(VulkanContext *vulkan, VkRenderPass compatibleR if (!tag.empty()) { vulkan->SetDebugName(vkpipeline, VK_OBJECT_TYPE_PIPELINE, tag.c_str()); } - pipeline[rpType]->Post(vkpipeline); + pipeline[(size_t)rpType]->Post(vkpipeline); } return success; } void VKRGraphicsPipeline::QueueForDeletion(VulkanContext *vulkan) { - for (int i = 0; i < RP_TYPE_COUNT; i++) { + for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) { if (!pipeline[i]) continue; VkPipeline pipeline = this->pipeline[i]->BlockUntilReady(); @@ -125,7 +125,7 @@ void VKRGraphicsPipeline::QueueForDeletion(VulkanContext *vulkan) { u32 VKRGraphicsPipeline::GetVariantsBitmask() const { u32 bitmask = 0; - for (int i = 0; i < RP_TYPE_COUNT; i++) { + for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) { if (pipeline[i]) { bitmask |= 1 << i; } @@ -181,7 +181,7 @@ void VKRFramebuffer::UpdateTag(const char *newTag) { vulkan_->SetDebugName(depth.image, VK_OBJECT_TYPE_IMAGE, name); vulkan_->SetDebugName(depth.rtView, VK_OBJECT_TYPE_IMAGE_VIEW, name); } - for (int rpType = 0; rpType < RP_TYPE_COUNT; rpType++) { + for (size_t rpType = 0; rpType < (size_t)RenderPassType::TYPE_COUNT; rpType++) { if (framebuf[rpType]) { snprintf(name, sizeof(name), "fb_%s", tag_.c_str()); vulkan_->SetDebugName(framebuf[(int)rpType], VK_OBJECT_TYPE_FRAMEBUFFER, name); @@ -688,7 +688,7 @@ VKRGraphicsPipeline *VulkanRenderManager::CreateGraphicsPipeline(VKRGraphicsPipe VKRRenderPass *compatibleRenderPass = queueRunner_.GetRenderPass(key); compileMutex_.lock(); bool needsCompile = false; - for (int i = 0; i < RP_TYPE_COUNT; i++) { + for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) { if (!(variantBitmask & (1 << i))) continue; RenderPassType rpType = (RenderPassType)i; @@ -707,7 +707,7 @@ VKRGraphicsPipeline *VulkanRenderManager::CreateGraphicsPipeline(VKRGraphicsPipe } } - pipeline->pipeline[rpType] = Promise::CreateEmpty(); + pipeline->pipeline[i] = Promise::CreateEmpty(); compileQueue_.push_back(CompileQueueEntry(pipeline, compatibleRenderPass->Get(vulkan_, rpType), rpType)); needsCompile = true; } @@ -740,19 +740,19 @@ void VulkanRenderManager::EndCurRenderStep() { // We'll often be able to avoid loading/saving the depth/stencil buffer. curRenderStep_->render.pipelineFlags = curPipelineFlags_; bool depthStencil = (curPipelineFlags_ & PipelineFlags::USES_DEPTH_STENCIL) != 0; - RenderPassType rpType = depthStencil ? RP_TYPE_COLOR_DEPTH : RP_TYPE_COLOR; + RenderPassType rpType = depthStencil ? RenderPassType::HAS_DEPTH : RenderPassType::DEFAULT; if (!curRenderStep_->render.framebuffer) { - rpType = RP_TYPE_BACKBUFFER; + rpType = RenderPassType::BACKBUFFER; } else { if (curPipelineFlags_ & PipelineFlags::USES_INPUT_ATTACHMENT) { // Not allowed on backbuffers. - rpType = depthStencil ? RP_TYPE_COLOR_DEPTH_INPUT : RP_TYPE_COLOR_INPUT; + rpType = depthStencil ? (RenderPassType::HAS_DEPTH | RenderPassType::COLOR_INPUT) : RenderPassType::COLOR_INPUT; } // Framebuffers can be stereo, and if so, will control the render pass type to match. // Pipelines can be mono and render fine to stereo etc, so not checking them here. // Note that we don't support rendering to just one layer of a multilayer framebuffer! if (curRenderStep_->render.framebuffer->numLayers > 1) { - rpType = (RenderPassType)(rpType | RP_TYPE_MULTIVIEW_COLOR); + rpType = (RenderPassType)(rpType | RenderPassType::MULTIVIEW); } } @@ -764,8 +764,8 @@ void VulkanRenderManager::EndCurRenderStep() { compileMutex_.lock(); bool needsCompile = false; for (VKRGraphicsPipeline *pipeline : pipelinesToCheck_) { - if (!pipeline->pipeline[rpType]) { - pipeline->pipeline[rpType] = Promise::CreateEmpty(); + if (!pipeline->pipeline[(size_t)rpType]) { + pipeline->pipeline[(size_t)rpType] = Promise::CreateEmpty(); compileQueue_.push_back(CompileQueueEntry(pipeline, renderPass->Get(vulkan_, rpType), rpType)); needsCompile = true; } diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index c8ca219d17..f9b1f68be6 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -77,7 +77,7 @@ public: // TODO: Hide. VulkanContext *vulkan_; private: - VkFramebuffer framebuf[RP_TYPE_COUNT]{}; + VkFramebuffer framebuf[(size_t)RenderPassType::TYPE_COUNT]{}; std::string tag_; }; @@ -167,7 +167,7 @@ struct VKRComputePipelineDesc { // Wrapped pipeline. Doesn't own desc. struct VKRGraphicsPipeline { ~VKRGraphicsPipeline() { - for (int i = 0; i < RP_TYPE_COUNT; i++) { + for (size_t i = 0; i < (size_t)RenderPassType::TYPE_COUNT; i++) { delete pipeline[i]; } } @@ -180,7 +180,7 @@ struct VKRGraphicsPipeline { u32 GetVariantsBitmask() const; VKRGraphicsPipelineDesc *desc = nullptr; // not owned! - Promise *pipeline[RP_TYPE_COUNT]{}; + Promise *pipeline[(size_t)RenderPassType::TYPE_COUNT]{}; std::string tag; }; @@ -201,7 +201,7 @@ struct VKRComputePipeline { struct CompileQueueEntry { CompileQueueEntry(VKRGraphicsPipeline *p, VkRenderPass _compatibleRenderPass, RenderPassType _renderPassType) : type(Type::GRAPHICS), graphics(p), compatibleRenderPass(_compatibleRenderPass), renderPassType(_renderPassType) {} - CompileQueueEntry(VKRComputePipeline *p) : type(Type::COMPUTE), compute(p), renderPassType(RP_TYPE_COLOR_DEPTH) {} + CompileQueueEntry(VKRComputePipeline *p) : type(Type::COMPUTE), compute(p), renderPassType(RenderPassType::HAS_DEPTH) {} // renderpasstype here shouldn't matter enum class Type { GRAPHICS, COMPUTE, diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 17d6ed113c..97e6a6c80a 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -1178,7 +1178,7 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char VkPipelineRasterizationStateCreateInfo rs{ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO }; raster->ToVulkan(&gDesc.rs); - pipeline->pipeline = renderManager_.CreateGraphicsPipeline(&gDesc, pipelineFlags, 1 << RP_TYPE_BACKBUFFER, tag ? tag : "thin3d"); + pipeline->pipeline = renderManager_.CreateGraphicsPipeline(&gDesc, pipelineFlags, 1 << (size_t)RenderPassType::BACKBUFFER, tag ? tag : "thin3d"); if (desc.uniformDesc) { pipeline->dynamicUniformSize = (int)desc.uniformDesc->uniformBufferSize; From ad6725b68443f197be0693884f77ead849343bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 28 Oct 2022 18:26:59 +0200 Subject: [PATCH 339/374] VK/D3D11: Move the rarely used "u_rotation" uniform to the frame uniform buffer. This uniform is used in two cases: * Non-buffered rendering in Vulkan, software transform * Non-buffered rendering in D3D11 level 9 on Windows Phone, software transform - which I don't think anyone builds for anymore Nice to not have it in the main uniform buffer, but mainly a demonstrator/test of moving stuff to the new frame-global buffer, and setting up the infrastructure. --- GPU/Common/ShaderUniforms.cpp | 6 ++++-- GPU/Common/ShaderUniforms.h | 15 ++++++++------- GPU/Common/VertexShaderGenerator.cpp | 5 +++++ GPU/Vulkan/DrawEngineVulkan.cpp | 4 +++- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/GPU/Common/ShaderUniforms.cpp b/GPU/Common/ShaderUniforms.cpp index 3c56d833e5..724fd26080 100644 --- a/GPU/Common/ShaderUniforms.cpp +++ b/GPU/Common/ShaderUniforms.cpp @@ -72,6 +72,10 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo maxValues[3] = NAN; } +void FrameUpdateUniforms(UB_Frame *ub, bool useBufferedRendering) { + ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation; +} + void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering) { if (dirtyUniforms & DIRTY_TEXENV) { Uint8x3ToFloat3(ub->texEnvColor, gstate.texenvcolor); @@ -139,7 +143,6 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView flippedMatrix = flippedMatrix * g_display_rot_matrix; } CopyMatrix4x4(ub->proj, flippedMatrix.getReadPtr()); - ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation; } if (dirtyUniforms & DIRTY_PROJTHROUGHMATRIX) { @@ -160,7 +163,6 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView } CopyMatrix4x4(ub->proj_through, proj_through.getReadPtr()); - ub->rotation = useBufferedRendering ? 0 : (float)g_display_rotation; } // Transform diff --git a/GPU/Common/ShaderUniforms.h b/GPU/Common/ShaderUniforms.h index 12bc273da3..ecddc4b3ca 100644 --- a/GPU/Common/ShaderUniforms.h +++ b/GPU/Common/ShaderUniforms.h @@ -27,7 +27,6 @@ struct alignas(16) UB_VS_FS_Base { float tex[12]; float uvScaleOffset[4]; float depthRange[4]; - // Rotation is used only for software transform. float matAmbient[4]; float cullRangeMin[4]; float cullRangeMax[4]; @@ -37,7 +36,7 @@ struct alignas(16) UB_VS_FS_Base { float fogColor[3]; uint32_t alphaColorRef; float texEnvColor[3]; uint32_t colorTestMask; float blendFixA[3]; float stencil; - float blendFixB[3]; float rotation; + float blendFixB[3]; float padUnused; float texClamp[4]; float texClampOffset[2]; float fogCoef[2]; // VR stuff is to go here, later. For normal drawing, we can then get away @@ -62,7 +61,7 @@ R"( mat4 u_proj; vec3 u_fogcolor; uint u_alphacolorref; vec3 u_texenv; uint u_alphacolormask; vec3 u_blendFixA; float u_stencilReplaceValue; - vec3 u_blendFixB; float u_rotation; + vec3 u_blendFixB; float u_padUnused; vec4 u_texclamp; vec2 u_texclampoff; vec2 u_fogcoef; @@ -132,13 +131,14 @@ R"( mat3x4 u_bone0; mat3x4 u_bone1; mat3x4 u_bone2; mat3x4 u_bone3; mat3x4 u_bon )"; -static const char * const ub_frame_globalstr = -R"( vec4 stereoParams; +static const char * const ub_frameStr = +R"( + float u_rotation; )"; // Frame-global uniforms. -struct UB_FrameGlobal { - float stereoParams[4]; +struct UB_Frame { + float rotation; // This is only used when using software transform, and non-buffered, to support native screen rotation. }; void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bool hasNegZ); @@ -146,5 +146,6 @@ void CalcCullRange(float minValues[4], float maxValues[4], bool flipViewport, bo void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipViewport, bool useBufferedRendering); void LightUpdateUniforms(UB_VS_Lights *ub, uint64_t dirtyUniforms); void BoneUpdateUniforms(UB_VS_Bones *ub, uint64_t dirtyUniforms); +void FrameUpdateUniforms(UB_Frame *ub, bool useBufferedRendering); uint32_t PackLightControlBits(); diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 6c6cc57ab2..155731ddd1 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -249,6 +249,11 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag if (compat.shaderLanguage == GLSL_VULKAN) { WRITE(p, "\n"); + + if (!useHWTransform) { + WRITE(p, "layout (std140, set = 0, binding = 0) uniform frameVars {\n%s};\n", ub_frameStr); + } + WRITE(p, "layout (std140, set = 1, binding = 3) uniform baseVars {\n%s};\n", ub_baseStr); if (enableLighting || doShadeMapping) WRITE(p, "layout (std140, set = 1, binding = 4) uniform lightVars {\n%s};\n", ub_vs_lightsStr); diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index f54afee3a9..30a223f983 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -1021,7 +1021,9 @@ void DrawEngineVulkan::DoFlush() { void DrawEngineVulkan::UpdateUBOs(FrameData *frame) { if (!frame->frameDescSetUpdated) { // Push frame global constants. - UB_FrameGlobal frameConstants{}; + UB_Frame frameConstants{}; + FrameUpdateUniforms(&frameConstants, framebufferManager_->UseBufferedRendering()); + VkDescriptorBufferInfo frameConstantsBufInfo; frame->pushUBO->PushUBOData(frameConstants, &frameConstantsBufInfo); From 0f37854ef9e17eb86b29b327288f946761c8ed06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 5 Nov 2022 22:17:06 +0100 Subject: [PATCH 340/374] Drop some D3D11 screen rotation support (was only used on Windows Phone) --- GPU/Common/VertexShaderGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/VertexShaderGenerator.cpp b/GPU/Common/VertexShaderGenerator.cpp index 155731ddd1..fd99a52cd9 100644 --- a/GPU/Common/VertexShaderGenerator.cpp +++ b/GPU/Common/VertexShaderGenerator.cpp @@ -851,7 +851,7 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag // The proj_through matrix already has the rotation, if needed. WRITE(p, " vec4 outPos = mul(u_proj_through, vec4(position.xyz, 1.0));\n"); } else { - if (compat.shaderLanguage == GLSL_VULKAN || compat.shaderLanguage == HLSL_D3D11) { + if (compat.shaderLanguage == GLSL_VULKAN) { // Apply rotation from the uniform. WRITE(p, " mat2 displayRotation = mat2(\n"); WRITE(p, " u_rotation == 0.0 ? 1.0 : (u_rotation == 2.0 ? -1.0 : 0.0), u_rotation == 1.0 ? 1.0 : (u_rotation == 3.0 ? -1.0 : 0.0),\n"); From 675a0467593756ab6f7937f83af76e2dd4a7a0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 5 Nov 2022 23:31:30 +0100 Subject: [PATCH 341/374] Fix parsing ampersands in server listings for streaming Fixes #16263 , or so I hope - haven't actually tested it, but seems straightforward enough. --- Common/StringUtils.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp index 3a9e29c61a..3115e1f03c 100644 --- a/Common/StringUtils.cpp +++ b/Common/StringUtils.cpp @@ -286,6 +286,25 @@ void SplitString(const std::string& str, const char delim, std::vector& output) { size_t next = 0; @@ -294,7 +313,7 @@ void GetQuotedStrings(const std::string& str, std::vector& output) if (str[pos] == '\"' || str[pos] == '\'') { if (even) { //quoted text - output.emplace_back(str.substr(next, pos - next)); + output.emplace_back(ApplyHtmlEscapes(str.substr(next, pos - next))); even = 0; } else { //non quoted text From 439b38f705b548617b7e9c7865d9398ee1ca7bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 00:11:04 +0100 Subject: [PATCH 342/374] Comment fixes (feedback) --- Common/GPU/Vulkan/VulkanQueueRunner.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.h b/Common/GPU/Vulkan/VulkanQueueRunner.h index a3b120e60b..6b7242cadf 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.h +++ b/Common/GPU/Vulkan/VulkanQueueRunner.h @@ -54,7 +54,7 @@ enum class PipelineFlags : u8 { ENUM_CLASS_BITOPS(PipelineFlags); // Pipelines need to be created for the right type of render pass. -// TODO: Rename to RenderPassType? It is currently a bitfield. +// TODO: Rename to RenderPassFlags? // When you add more flags, don't forget to update rpTypeDebugNames[]. enum class RenderPassType { DEFAULT = 0, @@ -74,8 +74,6 @@ enum class RenderPassType { }; ENUM_CLASS_BITOPS(RenderPassType); -// Hm, soon time to exploit the bit properties in these.. - inline bool RenderPassTypeHasDepth(RenderPassType type) { return (type & RenderPassType::HAS_DEPTH) || type == RenderPassType::BACKBUFFER; } From d575151a6e6d7982186facef5f56282595c8cc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 09:24:35 +0100 Subject: [PATCH 343/374] Yet another gradle upgrade --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index bfad5c1419..d9fc3ebd95 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.2.1' + classpath 'com.android.tools.build:gradle:7.3.1' } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0b74ce0881..86463708b7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,6 +3,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip android.useAndroidX=true android.enableJetifier=true From 4d815060469eb15aabf64144df923ae678bfa5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 09:44:06 +0100 Subject: [PATCH 344/374] Upgrade gradle, specify NDK version in android/build.gradle Also fix a warning. --- Common/VR/PPSSPPVR.cpp | 2 +- Common/VR/PPSSPPVR.h | 4 ++-- android/build.gradle | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 5007672b01..712ee9290d 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -103,7 +103,7 @@ bool IsVRBuild() { } #if PPSSPP_PLATFORM(ANDROID) -void InitVROnAndroid(void* vm, void* activity, const char* system, int version, char* name) { +void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name) { //Get device vendor (uppercase) char vendor[64]; diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index f6e2eefb27..65a14158ff 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -21,7 +21,7 @@ enum VRCompatFlag { // VR app flow integration bool IsVRBuild(); -void InitVROnAndroid(void* vm, void* activity, const char* system, int version, char* name); +void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale); @@ -50,7 +50,7 @@ void UpdateVRView(float* leftEye, float* rightEye); // VR app flow integration inline bool IsVRBuild() { return false; } -inline void InitVROnAndroid(void* vm, void* activity, const char* system, int version, char* name) {} +inline void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name) {} inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} diff --git a/android/build.gradle b/android/build.gradle index 47eef16fd7..3ee429208b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -45,6 +45,8 @@ android { } } compileSdkVersion 32 + ndkVersion "21.4.7075529" + defaultConfig { applicationId 'org.ppsspp.ppsspp' if (androidGitVersion.name() != "unknown" && androidGitVersion.code() >= 14000000) { From 8bb2313f5d5145908bc8a0343ec4842360e92e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 11:32:42 +0100 Subject: [PATCH 345/374] Finish previous buildfix... --- Common/VR/VRBase.cpp | 2 +- Common/VR/VRBase.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index a548c8a168..9c36fab0db 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -41,7 +41,7 @@ static bool vr_platform[VR_PLATFORM_MAX]; static engine_t vr_engine; int vr_initialized = 0; -void VR_Init( void* system, char* name, int version ) { +void VR_Init( void* system, const char* name, int version ) { if (vr_initialized) return; diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index f87778e99e..73870ab7dd 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -186,7 +186,7 @@ enum VRPlatformFlag { VR_PLATFORM_MAX }; -void VR_Init( void* system, char* name, int version ); +void VR_Init( void* system, const char* name, int version ); void VR_Destroy( engine_t* engine ); void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVulkan ); void VR_LeaveVR( engine_t* engine ); From 9b619b8c0bcaf8ee5d51aa03797283099d74ea32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 11:30:27 +0100 Subject: [PATCH 346/374] Remove ugly float conversion hacks from VR config --- Common/VR/PPSSPPVR.cpp | 20 ++++++------ Common/VR/VRRenderer.cpp | 68 +++++++++++++++++++++++----------------- Common/VR/VRRenderer.h | 22 ++++++++++--- 3 files changed, 67 insertions(+), 43 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 712ee9290d..86c8fdd545 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -225,7 +225,7 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con bool activate; float limit = g_Config.fMotionLength; //length of needed movement in meters XrVector3f axis = {0, 1, 0}; - float center = ToRadians((float)VR_GetConfig(VR_CONFIG_MENU_YAW)); + float center = ToRadians(VR_GetConfigFloat(VR_CONFIG_MENU_YAW)); XrQuaternionf orientation = XrQuaternionf_CreateFromVectorAngle(axis, center); XrVector3f position = XrQuaternionf_Rotate(orientation, IN_VRGetPose(j).position); @@ -281,13 +281,13 @@ void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(con float cx = width / 2; float cy = height / 2; float speed = (cx + cy) / 2; - float x = cx - tan(ToRadians(angles.y - (float)VR_GetConfig(VR_CONFIG_MENU_YAW))) * speed; + float x = cx - tan(ToRadians(angles.y - VR_GetConfigFloat(VR_CONFIG_MENU_YAW))) * speed; float y = cy - tan(ToRadians(angles.x)) * speed; //set renderer VR_SetConfig(VR_CONFIG_MOUSE_X, (int)x); VR_SetConfig(VR_CONFIG_MOUSE_Y, (int)y); - VR_SetConfig(VR_CONFIG_MOUSE_SIZE, 6 * (int)pow(VR_GetConfig(VR_CONFIG_CANVAS_DISTANCE), 0.25f)); + VR_SetConfig(VR_CONFIG_MOUSE_SIZE, 6 * (int)pow(VR_GetConfigFloat(VR_CONFIG_CANVAS_DISTANCE), 0.25f)); //inform engine about the status TouchInput touch; @@ -446,11 +446,11 @@ bool StartVRRender() { // Set customizations __DisplaySetFramerate(g_Config.bForce72Hz ? 72 : 60); VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF); - VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000); - VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000); - VR_SetConfig(VR_CONFIG_CAMERA_SIDE, g_Config.fCameraSide * 1000); - VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance); - VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage); + VR_SetConfigFloat(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance); + VR_SetConfigFloat(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight); + VR_SetConfigFloat(VR_CONFIG_CAMERA_SIDE, g_Config.fCameraSide); + VR_SetConfigFloat(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance); + VR_SetConfigFloat(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage); VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false); return true; } @@ -550,14 +550,14 @@ void UpdateVRParams(float* projMatrix) { } // Set 6DoF scale - float scale = pow(fabs(projMatrix[14]), 1.15f); + float scale = 1.0f; if (PSP_CoreParameter().compat.vrCompat().UnitsPerMeter > 0) { scale = PSP_CoreParameter().compat.vrCompat().UnitsPerMeter; VR_SetConfig(VR_CONFIG_6DOF_PRECISE, true); } else { VR_SetConfig(VR_CONFIG_6DOF_PRECISE, false); } - VR_SetConfig(VR_CONFIG_6DOF_SCALE, (int)(scale * 1000000)); + VR_SetConfigFloat(VR_CONFIG_6DOF_SCALE, scale); } void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) { diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 2cc95c73c2..0a18a840f1 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -1,3 +1,6 @@ +#define _USE_MATH_DEFINES +#include + #include "VRBase.h" #include "VRInput.h" #include "VRRenderer.h" @@ -12,8 +15,9 @@ XrPosef invViewTransform[2]; XrFrameState frameState = {}; bool initialized = false; bool stageSupported = false; -int vrConfig[VR_CONFIG_MAX] = {}; ovrMatrix4f vrMatrix[VR_MATRIX_COUNT]; +int vrConfig[VR_CONFIG_MAX] = {}; +float vrConfigFloat[VR_CONFIG_FLOAT_MAX] = {}; XrVector3f hmdorientation; XrVector3f hmdposition; @@ -133,12 +137,12 @@ void VR_Recenter(engine_t* engine) { OXR(xrLocateSpace(engine->appState.HeadSpace, engine->appState.CurrentSpace, engine->predictedDisplayTime, &loc)); hmdorientation = XrQuaternionf_ToEulerAngles(loc.pose.orientation); - vrConfig[VR_CONFIG_RECENTER_YAW] += (int)hmdorientation.y; - float recenterYaw = ToRadians((float)vrConfig[VR_CONFIG_RECENTER_YAW]); + VR_SetConfigFloat(VR_CONFIG_RECENTER_YAW, VR_GetConfigFloat(VR_CONFIG_RECENTER_YAW) + hmdorientation.y); + float recenterYaw = ToRadians(VR_GetConfigFloat(VR_CONFIG_RECENTER_YAW)); spaceCreateInfo.poseInReferenceSpace.orientation.x = 0; - spaceCreateInfo.poseInReferenceSpace.orientation.y = sin(recenterYaw / 2); + spaceCreateInfo.poseInReferenceSpace.orientation.y = sinf(recenterYaw / 2); spaceCreateInfo.poseInReferenceSpace.orientation.z = 0; - spaceCreateInfo.poseInReferenceSpace.orientation.w = cos(recenterYaw / 2); + spaceCreateInfo.poseInReferenceSpace.orientation.w = cosf(recenterYaw / 2); } // Delete previous space instances @@ -170,8 +174,8 @@ void VR_Recenter(engine_t* engine) { } // Update menu orientation - vrConfig[VR_CONFIG_MENU_PITCH] = (int)hmdorientation.x; - vrConfig[VR_CONFIG_MENU_YAW] = 0; + VR_SetConfigFloat(VR_CONFIG_MENU_PITCH, hmdorientation.x); + VR_SetConfigFloat(VR_CONFIG_MENU_YAW, 0.0f); } void VR_InitRenderer( engine_t* engine, bool multiview ) { @@ -181,8 +185,8 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { int eyeW, eyeH; VR_GetResolution(engine, &eyeW, &eyeH); - vrConfig[VR_CONFIG_VIEWPORT_WIDTH] = eyeW; - vrConfig[VR_CONFIG_VIEWPORT_HEIGHT] = eyeH; + VR_SetConfig(VR_CONFIG_VIEWPORT_WIDTH, eyeW); + VR_SetConfig(VR_CONFIG_VIEWPORT_HEIGHT, eyeH); // Get the viewport configuration info for the chosen viewport configuration type. engine->appState.ViewportConfig.type = XR_TYPE_VIEW_CONFIGURATION_PROPERTIES; @@ -303,7 +307,7 @@ bool VR_InitFrame( engine_t* engine ) { // Update matrices for (int matrix = 0; matrix < VR_MATRIX_COUNT; matrix++) { if ((matrix == VR_PROJECTION_MATRIX_LEFT_EYE) || (matrix == VR_PROJECTION_MATRIX_RIGHT_EYE)) { - float nearPlane = (float)vrConfig[VR_CONFIG_FOV_SCALE] / 200.0f; + float nearPlane = VR_GetConfigFloat(VR_CONFIG_FOV_SCALE) / 200.0f; vrMatrix[matrix] = ovrMatrix4f_CreateProjectionFov(fov.angleLeft, fov.angleRight, fov.angleUp, fov.angleDown, nearPlane, 0.0f ); } else if ((matrix == VR_VIEW_MATRIX_LEFT_EYE) || (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { bool flatScreen = false; @@ -315,9 +319,9 @@ bool VR_InitFrame( engine_t* engine ) { } // get axis mirroring configuration - float mx = vrConfig[VR_CONFIG_MIRROR_PITCH] ? -1 : 1; - float my = vrConfig[VR_CONFIG_MIRROR_YAW] ? -1 : 1; - float mz = vrConfig[VR_CONFIG_MIRROR_ROLL] ? -1 : 1; + float mx = vrConfig[VR_CONFIG_MIRROR_PITCH] ? -1.0f : 1.0f; + float my = vrConfig[VR_CONFIG_MIRROR_YAW] ? -1.0f : 1.0f; + float mz = vrConfig[VR_CONFIG_MIRROR_ROLL] ? -1.0f : 1.0f; // ensure there is maximally one axis to mirror rotation if (mx + my + mz < 0) { @@ -338,30 +342,30 @@ bool VR_InitFrame( engine_t* engine ) { } vrMatrix[matrix] = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); - float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.000001f; + float scale = VR_GetConfigFloat(VR_CONFIG_6DOF_SCALE) * 0.000001f; if (!flatScreen && vrConfig[VR_CONFIG_6DOF_ENABLED]) { vrMatrix[matrix].M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale; } - if (abs(vrConfig[VR_CONFIG_CAMERA_DISTANCE]) > 0) { - XrVector3f forward = {0.0f, 0.0f, (float)vrConfig[VR_CONFIG_CAMERA_DISTANCE] * 0.001f * scale}; + if (fabsf(VR_GetConfigFloat(VR_CONFIG_CAMERA_DISTANCE)) > 0.0f) { + XrVector3f forward = {0.0f, 0.0f, VR_GetConfigFloat(VR_CONFIG_CAMERA_DISTANCE) * scale}; forward = XrQuaternionf_Rotate(invView.orientation, forward); forward = XrVector3f_ScalarMultiply(forward, vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f); vrMatrix[matrix].M[0][3] += forward.x; vrMatrix[matrix].M[1][3] += forward.y; vrMatrix[matrix].M[2][3] += forward.z; } - if (abs(vrConfig[VR_CONFIG_CAMERA_HEIGHT]) > 0) { - XrVector3f up = {0.0f, -(float)vrConfig[VR_CONFIG_CAMERA_HEIGHT] * 0.001f * scale, 0.0f}; + if (fabsf(VR_GetConfigFloat(VR_CONFIG_CAMERA_HEIGHT)) > 0.0f) { + XrVector3f up = {0.0f, -VR_GetConfigFloat(VR_CONFIG_CAMERA_HEIGHT) * scale, 0.0f}; up = XrQuaternionf_Rotate(invView.orientation, up); up = XrVector3f_ScalarMultiply(up, vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f); vrMatrix[matrix].M[0][3] += up.x; vrMatrix[matrix].M[1][3] += up.y; vrMatrix[matrix].M[2][3] += up.z; } - if (abs(vrConfig[VR_CONFIG_CAMERA_SIDE]) > 0) { - XrVector3f side = {-(float)vrConfig[VR_CONFIG_CAMERA_SIDE] * 0.001f * scale, 0.0f, 0.0f}; + if (fabsf(VR_GetConfigFloat(VR_CONFIG_CAMERA_SIDE)) > 0.0f) { + XrVector3f side = {-VR_GetConfigFloat(VR_CONFIG_CAMERA_SIDE) * scale, 0.0f, 0.0f}; side = XrQuaternionf_Rotate(invView.orientation, side); side = XrVector3f_ScalarMultiply(side, vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f); vrMatrix[matrix].M[0][3] += side.x; @@ -414,7 +418,7 @@ void VR_FinishFrame( engine_t* engine ) { int vrMode = vrConfig[VR_CONFIG_MODE]; XrCompositionLayerProjectionView projection_layer_elements[2] = {}; if ((vrMode == VR_MODE_MONO_6DOF) || (vrMode == VR_MODE_STEREO_6DOF)) { - vrConfig[VR_CONFIG_MENU_YAW] = (int)hmdorientation.y; + VR_SetConfigFloat(VR_CONFIG_MENU_YAW, hmdorientation.y); for (int eye = 0; eye < ovrMaxNumEyes; eye++) { int imageLayer = engine->appState.Renderer.Multiview ? eye : 0; @@ -453,13 +457,13 @@ void VR_FinishFrame( engine_t* engine ) { } else if ((vrMode == VR_MODE_MONO_SCREEN) || (vrMode == VR_MODE_STEREO_SCREEN)) { // Flat screen pose - float distance = (float)vrConfig[VR_CONFIG_CANVAS_DISTANCE]; - float menuPitch = ToRadians((float)vrConfig[VR_CONFIG_MENU_PITCH]); - float menuYaw = ToRadians((float)vrConfig[VR_CONFIG_MENU_YAW]); + float distance = VR_GetConfigFloat(VR_CONFIG_CANVAS_DISTANCE); + float menuPitch = ToRadians(VR_GetConfigFloat(VR_CONFIG_MENU_PITCH)); + float menuYaw = ToRadians(VR_GetConfigFloat(VR_CONFIG_MENU_YAW)); XrVector3f pos = { - invViewTransform[0].position.x - sin(menuYaw) * distance, + invViewTransform[0].position.x - sinf(menuYaw) * distance, invViewTransform[0].position.y, - invViewTransform[0].position.z - cos(menuYaw) * distance + invViewTransform[0].position.z - cosf(menuYaw) * distance }; XrQuaternionf pitch = XrQuaternionf_CreateFromVectorAngle({1, 0, 0}, -menuPitch); XrQuaternionf yaw = XrQuaternionf_CreateFromVectorAngle({0, 1, 0}, menuYaw); @@ -479,7 +483,7 @@ void VR_FinishFrame( engine_t* engine ) { cylinder_layer.pose.orientation = XrQuaternionf_Multiply(pitch, yaw); cylinder_layer.pose.position = pos; cylinder_layer.radius = 12.0f; - cylinder_layer.centralAngle = M_PI * 0.5f; + cylinder_layer.centralAngle = (float)(M_PI * 0.5); cylinder_layer.aspectRatio = 1; // Build the cylinder layer @@ -533,9 +537,17 @@ void VR_SetConfig( VRConfig config, int value) { vrConfig[config] = value; } +float VR_GetConfigFloat(VRConfigFloat config) { + return vrConfigFloat[config]; +} + +void VR_SetConfigFloat(VRConfigFloat config, float value) { + vrConfigFloat[config] = value; +} + void* VR_BindFramebuffer(engine_t *engine) { if (!initialized) return nullptr; - int fboIndex = vrConfig[VR_CONFIG_CURRENT_FBO]; + int fboIndex = VR_GetConfig(VR_CONFIG_CURRENT_FBO); return ovrFramebuffer_SetCurrent(&engine->appState.Renderer.FrameBuffer[fboIndex]); } diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 863212bd7d..70b1ac1018 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -7,14 +7,11 @@ enum VRConfig { //switching between 2D and 3D VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup - VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE, - VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CAMERA_SIDE, VR_CONFIG_CANVAS_DISTANCE, + VR_CONFIG_CAMERA_CONTROL, //6DoF - VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, + VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, VR_CONFIG_MIRROR_PITCH, VR_CONFIG_MIRROR_YAW, VR_CONFIG_MIRROR_ROLL, - //2D canvas positioning - VR_CONFIG_MENU_PITCH, VR_CONFIG_MENU_YAW, VR_CONFIG_RECENTER_YAW, //mouse cursor VR_CONFIG_MOUSE_SIZE, VR_CONFIG_MOUSE_X, VR_CONFIG_MOUSE_Y, //viewport setup @@ -26,6 +23,18 @@ enum VRConfig { VR_CONFIG_MAX }; +enum VRConfigFloat { + // 6dof + VR_CONFIG_6DOF_SCALE, + //camera setup + VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_DISTANCE, + VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CAMERA_SIDE, VR_CONFIG_CANVAS_DISTANCE, + //2D canvas positioning + VR_CONFIG_MENU_PITCH, VR_CONFIG_MENU_YAW, VR_CONFIG_RECENTER_YAW, + + VR_CONFIG_FLOAT_MAX +}; + enum VRMatrix { VR_PROJECTION_MATRIX_LEFT_EYE, VR_PROJECTION_MATRIX_RIGHT_EYE, @@ -53,5 +62,8 @@ void VR_FinishFrame( engine_t* engine ); int VR_GetConfig( VRConfig config ); void VR_SetConfig( VRConfig config, int value); +float VR_GetConfigFloat( VRConfigFloat config ); +void VR_SetConfigFloat( VRConfigFloat config, float value ); + void* VR_BindFramebuffer(engine_t *engine); ovrMatrix4f VR_GetMatrix( VRMatrix matrix ); From ef3b0607efaf4696493695ab1251a08d3fa4e988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 11:39:41 +0100 Subject: [PATCH 347/374] Rename 6DOF_PRECISE to HAS_UNIT_SCALE --- Common/VR/PPSSPPVR.cpp | 6 +++--- Common/VR/VRRenderer.cpp | 2 +- Common/VR/VRRenderer.h | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 86c8fdd545..ec20865e7b 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -400,7 +400,7 @@ bool StartVRRender() { // Decide if the scene is 3D or not if (g_Config.bEnableVR && !VR_GetConfig(VR_CONFIG_FORCE_2D) && (VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) > 15)) { - bool stereo = VR_GetConfig(VR_CONFIG_6DOF_PRECISE) && g_Config.bEnableStereo; + bool stereo = VR_GetConfig(VR_CONFIG_HAS_UNIT_SCALE) && g_Config.bEnableStereo; VR_SetConfig(VR_CONFIG_MODE, stereo ? VR_MODE_STEREO_6DOF : VR_MODE_MONO_6DOF); } else { VR_SetConfig(VR_CONFIG_MODE, g_Config.bEnableStereo ? VR_MODE_STEREO_SCREEN : VR_MODE_MONO_SCREEN); @@ -553,9 +553,9 @@ void UpdateVRParams(float* projMatrix) { float scale = 1.0f; if (PSP_CoreParameter().compat.vrCompat().UnitsPerMeter > 0) { scale = PSP_CoreParameter().compat.vrCompat().UnitsPerMeter; - VR_SetConfig(VR_CONFIG_6DOF_PRECISE, true); + VR_SetConfig(VR_CONFIG_HAS_UNIT_SCALE, true); } else { - VR_SetConfig(VR_CONFIG_6DOF_PRECISE, false); + VR_SetConfig(VR_CONFIG_HAS_UNIT_SCALE, false); } VR_SetConfigFloat(VR_CONFIG_6DOF_SCALE, scale); } diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 0a18a840f1..70b0acbd57 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -372,7 +372,7 @@ bool VR_InitFrame( engine_t* engine ) { vrMatrix[matrix].M[1][3] += side.y; vrMatrix[matrix].M[2][3] += side.z; } - if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { + if (vrConfig[VR_CONFIG_HAS_UNIT_SCALE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) { float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x); float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y); float dz = fabs(invViewTransform[1].position.z - invViewTransform[0].position.z); diff --git a/Common/VR/VRRenderer.h b/Common/VR/VRRenderer.h index 70b1ac1018..bd041ca366 100644 --- a/Common/VR/VRRenderer.h +++ b/Common/VR/VRRenderer.h @@ -8,8 +8,9 @@ enum VRConfig { VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D, //camera setup VR_CONFIG_CAMERA_CONTROL, + VR_CONFIG_HAS_UNIT_SCALE, //6DoF - VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED, + VR_CONFIG_6DOF_ENABLED, VR_CONFIG_MIRROR_UPDATED, VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z, VR_CONFIG_MIRROR_PITCH, VR_CONFIG_MIRROR_YAW, VR_CONFIG_MIRROR_ROLL, //mouse cursor @@ -26,10 +27,10 @@ enum VRConfig { enum VRConfigFloat { // 6dof VR_CONFIG_6DOF_SCALE, - //camera setup + // camera setup VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_DISTANCE, VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CAMERA_SIDE, VR_CONFIG_CANVAS_DISTANCE, - //2D canvas positioning + // 2D canvas positioning VR_CONFIG_MENU_PITCH, VR_CONFIG_MENU_YAW, VR_CONFIG_RECENTER_YAW, VR_CONFIG_FLOAT_MAX From 8398b779fbf75447d0f8c43f1aeb17b4a8cfd726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 11:51:28 +0100 Subject: [PATCH 348/374] 6dof fix --- Common/VR/VRRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 70b0acbd57..f04a3c15c8 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -342,7 +342,7 @@ bool VR_InitFrame( engine_t* engine ) { } vrMatrix[matrix] = ovrMatrix4f_CreateFromQuaternion(&invView.orientation); - float scale = VR_GetConfigFloat(VR_CONFIG_6DOF_SCALE) * 0.000001f; + float scale = VR_GetConfigFloat(VR_CONFIG_6DOF_SCALE); if (!flatScreen && vrConfig[VR_CONFIG_6DOF_ENABLED]) { vrMatrix[matrix].M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale; vrMatrix[matrix].M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale; From 5d3ec6c8ff43b2e0a5122aa5cea52f5a7983d223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 14:35:28 +0100 Subject: [PATCH 349/374] Fix type of predictedDisplayTime --- Common/VR/VRBase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 73870ab7dd..b77e6dc7d0 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -172,7 +172,7 @@ typedef struct { typedef struct { uint64_t frameIndex; ovrApp appState; - float predictedDisplayTime; + XrTime predictedDisplayTime; XrGraphicsBindingVulkanKHR graphicsBindingVulkan; } engine_t; From b4507cd5cca1133a44a782658568590e854a7ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 14:36:51 +0100 Subject: [PATCH 350/374] Make a lot more code VR build for all platforms --- Common/GPU/OpenGL/GLQueueRunner.cpp | 6 ++-- Common/GPU/OpenGL/GLRenderManager.cpp | 2 +- Common/GPU/Vulkan/VulkanLoader.cpp | 2 +- Common/GPU/Vulkan/VulkanQueueRunner.cpp | 2 +- Common/GPU/Vulkan/VulkanRenderManager.cpp | 2 +- Common/VR/PPSSPPVR.cpp | 8 ++++- Common/VR/PPSSPPVR.h | 4 +-- Common/VR/VRBase.cpp | 6 ++-- Common/VR/VRBase.h | 4 +-- Common/VR/VRFramebuffer.cpp | 40 +++++++++++++---------- Common/VR/VRInput.cpp | 4 --- Common/VR/VRRenderer.cpp | 4 --- Core/Compatibility.cpp | 3 ++ Core/Config.cpp | 2 +- Core/KeyMap.cpp | 2 +- GPU/Common/PresentationCommon.cpp | 2 +- GPU/GLES/GPU_GLES.cpp | 2 +- GPU/GLES/ShaderManagerGLES.cpp | 2 +- UI/NativeApp.cpp | 2 +- android/jni/AndroidEGLContext.cpp | 2 +- android/jni/app-android.cpp | 12 +++---- assets/compatvr.ini | 18 +++++----- 22 files changed, 69 insertions(+), 62 deletions(-) diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index 84f1b1a375..bf27a4fcfa 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -280,7 +280,7 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski _dbg_assert_(query.name); int location = -1; - if (IsVRBuild() && IsMultiviewSupported()) { + if (IsVREnabled() && IsMultiviewSupported()) { int index = GetStereoBufferIndex(query.name); if (index >= 0) { std::string layout = GetStereoBufferLayout(query.name); @@ -707,7 +707,7 @@ void GLQueueRunner::RunSteps(const std::vector &steps, bool skipGLCal switch (step.stepType) { case GLRStepType::RENDER: renderCount++; - if (IsVRBuild()) { + if (IsVREnabled()) { GLRStep vrStep = step; PreprocessStepVR(&vrStep); PerformRenderPass(vrStep, renderCount == 1, renderCount == totalRenderCount); @@ -1603,7 +1603,7 @@ void GLQueueRunner::PerformBindFramebufferAsRenderTarget(const GLRStep &pass) { fbo_bind_fb_target(false, curFB_->handle); } else { fbo_unbind(); - if (IsVRBuild()) { + if (IsVREnabled()) { BindVRFramebuffer(); } // Backbuffer is now bound. diff --git a/Common/GPU/OpenGL/GLRenderManager.cpp b/Common/GPU/OpenGL/GLRenderManager.cpp index 23c133272d..f3eb5f59eb 100644 --- a/Common/GPU/OpenGL/GLRenderManager.cpp +++ b/Common/GPU/OpenGL/GLRenderManager.cpp @@ -577,7 +577,7 @@ void GLRenderManager::Run(int frame) { } } - if (IsVRBuild()) { + if (IsVREnabled()) { int passes = GetVRPassesCount(); for (int i = 0; i < passes; i++) { PreVRFrameRender(i); diff --git a/Common/GPU/Vulkan/VulkanLoader.cpp b/Common/GPU/Vulkan/VulkanLoader.cpp index 52ece65731..32984494ce 100644 --- a/Common/GPU/Vulkan/VulkanLoader.cpp +++ b/Common/GPU/Vulkan/VulkanLoader.cpp @@ -309,7 +309,7 @@ void VulkanSetAvailable(bool available) { bool VulkanMayBeAvailable() { // Unsupported in VR at the moment - if (IsVRBuild()) { + if (IsVREnabled()) { return false; } diff --git a/Common/GPU/Vulkan/VulkanQueueRunner.cpp b/Common/GPU/Vulkan/VulkanQueueRunner.cpp index 4038c991d1..ae231d63df 100644 --- a/Common/GPU/Vulkan/VulkanQueueRunner.cpp +++ b/Common/GPU/Vulkan/VulkanQueueRunner.cpp @@ -1711,7 +1711,7 @@ VKRRenderPass *VulkanQueueRunner::PerformBindFramebufferAsRenderTarget(const VKR }; renderPass = GetRenderPass(key); - if (IsVRBuild()) { + if (IsVREnabled()) { framebuf = (VkFramebuffer)BindVRFramebuffer(); } else { framebuf = backbuffer_; diff --git a/Common/GPU/Vulkan/VulkanRenderManager.cpp b/Common/GPU/Vulkan/VulkanRenderManager.cpp index 3c1ea6f07f..732aa2a0fd 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.cpp +++ b/Common/GPU/Vulkan/VulkanRenderManager.cpp @@ -1325,7 +1325,7 @@ void VulkanRenderManager::Run(VKRRenderThreadTask &task) { if (task.steps.empty() && !frameData.hasAcquired) frameData.skipSwap = true; //queueRunner_.LogSteps(stepsOnThread, false); - if (IsVRBuild()) { + if (IsVREnabled()) { int passes = GetVRPassesCount(); for (int i = 0; i < passes; i++) { PreVRFrameRender(i); diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index ec20865e7b..e133ebd277 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -98,8 +98,14 @@ VR app flow integration ================================================================================ */ -bool IsVRBuild() { +bool IsVREnabled() { + // For now, let the OPENXR build flag control enablement. + // This will change. +#ifdef OPENXR return true; +#else + return false; +#endif } #if PPSSPP_PLATFORM(ANDROID) diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index 65a14158ff..dfb38471b1 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -20,7 +20,7 @@ enum VRCompatFlag { #ifdef OPENXR // VR app flow integration -bool IsVRBuild(); +bool IsVREnabled(); void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name); void EnterVR(bool firstStart, void* vulkanContext); void GetVRResolutionPerEye(int* width, int* height); @@ -49,7 +49,7 @@ void UpdateVRView(float* leftEye, float* rightEye); #else //dummy integration // VR app flow integration -inline bool IsVRBuild() { return false; } +inline bool IsVREnabled() { return false; } inline void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name) {} inline void EnterVR(bool firstTime, void* vulkanContext) {} inline void GetVRResolutionPerEye(int* width, int* height) {} diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index 9c36fab0db..c6661f1cf0 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -5,9 +5,9 @@ #include #include -#if defined(OPENXR) - +#ifndef _WIN32 #include +#endif enum ConfigsSetEXT { UNREAL_VERSION = 0, @@ -41,6 +41,8 @@ static bool vr_platform[VR_PLATFORM_MAX]; static engine_t vr_engine; int vr_initialized = 0; +#if defined(OPENXR) + void VR_Init( void* system, const char* name, int version ) { if (vr_initialized) return; diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index b77e6dc7d0..4e0e1e266a 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -28,12 +28,12 @@ using namespace PPSSPP_VK; #include #elif defined(_WIN32) #include "Common/CommonWindows.h" +#include "Common/GPU/OpenGL/GLCommon.h" #include #define XR_USE_PLATFORM_WIN32 1 -#define XR_USE_GRAPHICS_API_OPENGL_ES 1 +#define XR_USE_GRAPHICS_API_OPENGL 1 #define XR_USE_GRAPHICS_API_VULKAN 1 #else -#define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_GRAPHICS_API_VULKAN 1 #endif diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index be4b14c3e0..2122191bec 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -43,9 +43,9 @@ void ovrFramebuffer_Clear(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = false; } -#ifdef OPENXR +#if XR_USE_GRAPHICS_API_OPENGL_ES -bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview) { +static bool ovrFramebuffer_CreateGLES(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview) { frameBuffer->Width = width; frameBuffer->Height = height; @@ -56,12 +56,11 @@ bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int } typedef void (*PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR)(GLenum, GLenum, GLuint, GLint, GLint, GLsizei); - auto glFramebufferTextureMultiviewOVR = (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR)eglGetProcAddress ("glFramebufferTextureMultiviewOVR"); - if (!glFramebufferTextureMultiviewOVR) - { + PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR glFramebufferTextureMultiviewOVR = nullptr; + glFramebufferTextureMultiviewOVR = (PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVR)eglGetProcAddress ("glFramebufferTextureMultiviewOVR"); + if (!glFramebufferTextureMultiviewOVR) { ALOGE("Can not get proc address for glFramebufferTextureMultiviewOVR.\n"); } - XrSwapchainCreateInfo swapChainCreateInfo; memset(&swapChainCreateInfo, 0, sizeof(swapChainCreateInfo)); swapChainCreateInfo.type = XR_TYPE_SWAPCHAIN_CREATE_INFO; @@ -136,8 +135,10 @@ bool ovrFramebuffer_CreateGL(XrSession session, ovrFramebuffer* frameBuffer, int return true; } -bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, - bool multiview, void* context) { +#endif + +static bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, + bool multiview, void* context) { frameBuffer->Width = width; frameBuffer->Height = height; @@ -241,7 +242,7 @@ bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { - for (int i = 0; i < frameBuffer->TextureSwapChainLength; i++) { + for (int i = 0; i < (int)frameBuffer->TextureSwapChainLength; i++) { vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr); vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKDepthImages[i], nullptr); vkDestroyFramebuffer(frameBuffer->VKContext->device, frameBuffer->VKFrameBuffers[i], nullptr); @@ -250,7 +251,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { delete[] frameBuffer->VKDepthImages; delete[] frameBuffer->VKFrameBuffers; } else { -#ifdef XR_USE_GRAPHICS_API_OPENGL_ES +#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL GL(glDeleteFramebuffers(frameBuffer->TextureSwapChainLength, frameBuffer->GLFrameBuffers)); free(frameBuffer->GLFrameBuffers); #endif @@ -267,7 +268,7 @@ void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { -#ifdef XR_USE_GRAPHICS_API_OPENGL_ES +#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer->GLFrameBuffers[frameBuffer->TextureSwapChainIndex])); #endif return nullptr; @@ -299,7 +300,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { -#ifdef XR_USE_GRAPHICS_API_OPENGL_ES +#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL GL(glEnable( GL_SCISSOR_TEST )); GL(glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height )); GL(glClearColor( 0.0f, 0.0f, 0.0f, 1.0f )); @@ -321,7 +322,7 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { -#ifdef XR_USE_GRAPHICS_API_OPENGL_ES +#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL GL(glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)); GL(glClearColor(0.0f, 0.0f, 0.0f, 1.0f)); GL(glClear(GL_COLOR_BUFFER_BIT)); @@ -352,8 +353,10 @@ void ovrRenderer_Create(XrSession session, ovrRenderer* renderer, int width, int if (vulkanContext) { ovrFramebuffer_CreateVK(session, &renderer->FrameBuffer[i], width, height, multiview, vulkanContext); } else { -#ifdef XR_USE_GRAPHICS_API_OPENGL_ES - ovrFramebuffer_CreateGL(session, &renderer->FrameBuffer[i], width, height, multiview); +#if XR_USE_GRAPHICS_API_OPENGL_ES + ovrFramebuffer_CreateGLES(session, &renderer->FrameBuffer[i], width, height, multiview); +#elif XR_USE_GRAPHICS_API_OPENGL + // TODO #endif } } @@ -370,7 +373,7 @@ void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { -#ifdef XR_USE_GRAPHICS_API_OPENGL_ES +#if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL GL(glEnable(GL_SCISSOR_TEST)); GL(glScissor(x, y, size, size)); GL(glViewport(x, y, size, size)); @@ -414,6 +417,7 @@ void ovrApp_Destroy(ovrApp* app) { ovrApp_Clear(app); } + void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { if (state == XR_SESSION_STATE_READY) { assert(app->SessionActive == false); @@ -428,6 +432,7 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { OXR(result = xrBeginSession(app->Session, &sessionBeginInfo)); app->SessionActive = (result == XR_SUCCESS); +#ifdef ANDROID if (app->SessionActive && VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) { XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; @@ -450,6 +455,7 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_APPLICATION_MAIN_KHR, app->MainThreadTid)); OXR(pfnSetAndroidApplicationThreadKHR(app->Session, XR_ANDROID_THREAD_TYPE_RENDERER_MAIN_KHR, app->RenderThreadTid)); } +#endif } else if (state == XR_SESSION_STATE_STOPPING) { assert(app->SessionActive); @@ -538,5 +544,3 @@ int ovrApp_HandleXrEvents(ovrApp* app) { } return recenter; } - -#endif diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 27cf0eb2fd..912bbca17f 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -1,8 +1,6 @@ #include "VRInput.h" #include -#ifdef OPENXR - //OpenXR XrPath leftHandPath; XrPath rightHandPath; @@ -464,5 +462,3 @@ XrPosef IN_VRGetPose( int controllerIndex ) { xrLocateSpace(aimSpace[controllerIndex], engine->appState.CurrentSpace, (XrTime)(engine->predictedDisplayTime), &loc); return loc.pose; } - -#endif diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index f04a3c15c8..50fc4c0003 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -22,8 +22,6 @@ float vrConfigFloat[VR_CONFIG_FLOAT_MAX] = {}; XrVector3f hmdorientation; XrVector3f hmdposition; -#ifdef OPENXR - void VR_UpdateStageBounds(ovrApp* pappState) { XrExtent2Df stageBounds = {}; @@ -554,5 +552,3 @@ void* VR_BindFramebuffer(engine_t *engine) { ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) { return vrMatrix[matrix]; } - -#endif diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index f59a0da45b..4ce6b322e5 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -17,6 +17,7 @@ #include +#include "Common/Log.h" #include "Common/Data/Format/IniFile.h" #include "Common/StringUtils.h" #include "Core/Compatibility.h" @@ -122,6 +123,8 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "Skyplane", &vrCompat_.Skyplane); CheckSetting(iniFile, gameID, "UnitsPerMeter", &vrCompat_.UnitsPerMeter); + + NOTICE_LOG(G3D, "UnitsPerMeter for %s: %f", gameID.c_str(), vrCompat_.UnitsPerMeter); } void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) { diff --git a/Core/Config.cpp b/Core/Config.cpp index b8d1408144..b1f22523f4 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -697,7 +697,7 @@ const char * const vulkanDefaultBlacklist[] = { }; static int DefaultGPUBackend() { - if (IsVRBuild()) { + if (IsVREnabled()) { return (int)GPUBackend::OPENGL; } diff --git a/Core/KeyMap.cpp b/Core/KeyMap.cpp index 0be4dd7182..8c84be11e1 100644 --- a/Core/KeyMap.cpp +++ b/Core/KeyMap.cpp @@ -667,7 +667,7 @@ void RestoreDefault() { g_controllerMap.clear(); g_controllerMapGeneration++; - if (IsVRBuild()) { + if (IsVREnabled()) { SetDefaultKeyMap(DEFAULT_MAPPING_VR_HEADSET, false); return; } diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index b4e05d8d50..aec95318ec 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -77,7 +77,7 @@ void CenterDisplayOutputRect(FRect *rc, float origW, float origH, const FRect &f SmallDisplayZoom zoomType = (SmallDisplayZoom)g_Config.iSmallDisplayZoomType; - if (IsVRBuild()) { + if (IsVREnabled()) { if (IsFlatVRScene()) { zoomType = SmallDisplayZoom::AUTO; } else { diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index b6b2b6a661..f67e90d335 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -210,7 +210,7 @@ u32 GPU_GLES::CheckGPUFeatures() const { features |= GPU_USE_FRAGMENT_TEST_CACHE; } - if (IsVRBuild()) { + if (IsVREnabled()) { features |= GPU_USE_VIRTUAL_REALITY; } if (IsMultiviewSupported()) { diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index 118c8c3fed..04a1a85974 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -457,7 +457,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu } if (dirty & DIRTY_FOGCOLOR) { SetColorUniform3(render_, &u_fogcolor, gstate.fogcolor); - if (IsVRBuild()) { + if (IsVREnabled()) { SetVRCompat(VR_COMPAT_FOG_COLOR, gstate.fogcolor); } } diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 0f4cac7f37..d387e7064b 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1297,7 +1297,7 @@ bool NativeTouch(const TouchInput &touch) { bool NativeKey(const KeyInput &key) { // Special key VR actions - if (IsVRBuild()) { + if (IsVREnabled()) { UpdateVRSpecialKeys(key); } diff --git a/android/jni/AndroidEGLContext.cpp b/android/jni/AndroidEGLContext.cpp index 9507c217e6..0cddc2b7f3 100644 --- a/android/jni/AndroidEGLContext.cpp +++ b/android/jni/AndroidEGLContext.cpp @@ -47,7 +47,7 @@ bool AndroidEGLGraphicsContext::InitFromRenderThread(ANativeWindow *wnd, int des } gl->MakeCurrent(); if (gl->GetMode() == GLInterfaceMode::MODE_OPENGL) - SetGLCoreContext(!IsVRBuild()); + SetGLCoreContext(!IsVREnabled()); CheckGLExtensions(); draw_ = Draw::T3DCreateGLContext(); SetGPUBackend(GPUBackend::OPENGL); diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 9e685cfaaf..b74d345dc4 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -757,7 +757,7 @@ retry: EmuThreadStart(); } - if (IsVRBuild()) { + if (IsVREnabled()) { Version gitVer(PPSSPP_GIT_VERSION); InitVROnAndroid(gJvm, nativeActivity, systemName.c_str(), gitVer.ToInteger(), "PPSSPP"); } @@ -939,7 +939,7 @@ extern "C" bool Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env, } NativeMessageReceived("recreateviews", ""); - if (IsVRBuild()) { + if (IsVREnabled()) { EnterVR(firstStart, graphicsContext->GetAPIContext()); } @@ -982,7 +982,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_backbufferResize(JNIEnv pixel_yres = bufh; backbuffer_format = format; - if (IsVRBuild()) { + if (IsVREnabled()) { GetVRResolutionPerEye(&pixel_xres, &pixel_yres); } @@ -1057,7 +1057,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, SetCurrentThreadName("AndroidRender"); } - if (IsVRBuild() && !StartVRRender()) + if (IsVREnabled() && !StartVRRender()) return; if (useCPUThread) { @@ -1068,7 +1068,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeRenderer_displayRender(JNIEnv *env, UpdateRunLoopAndroid(env); } - if (IsVRBuild()) { + if (IsVREnabled()) { UpdateVRInput(NativeKey, NativeTouch, g_Config.bHapticFeedback, dp_xscale, dp_yscale); FinishVRRender(); } @@ -1291,7 +1291,7 @@ void getDesiredBackbufferSize(int &sz_x, int &sz_y) { extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_setDisplayParameters(JNIEnv *, jclass, jint xres, jint yres, jint dpi, jfloat refreshRate) { INFO_LOG(G3D, "NativeApp.setDisplayParameters(%d x %d, dpi=%d, refresh=%0.2f)", xres, yres, dpi, refreshRate); - if (IsVRBuild()) { + if (IsVREnabled()) { int width, height; GetVRResolutionPerEye(&width, &height); xres = width; diff --git a/assets/compatvr.ini b/assets/compatvr.ini index 430fb80e47..bc4e1a6dd1 100644 --- a/assets/compatvr.ini +++ b/assets/compatvr.ini @@ -313,15 +313,6 @@ ULUS10319 = 10.0 # Bowling 3D NPUZ00002 = 1.0 -# Burnout Legends -NPJH50305 = 1.0 -ULAS42019 = 1.0 -ULES00125 = 1.0 -ULJM05049 = 1.0 -ULJM05228 = 1.0 -ULKS46027 = 1.0 -ULUS10025 = 1.0 - # Brain Challenge NPEH00003 = 30.0 NPJH00002 = 30.0 @@ -335,6 +326,15 @@ NPUZ00031 = 1.0 NPEZ00023 = 1.0 NPUZ00007 = 1.0 +# Burnout Legends +ULES00125 = 2.0 +ULUS10025 = 2.0 +ULJM05228 = 2.0 +NPJH50305 = 2.0 +ULJM05049 = 2.0 +ULKS46027 = 2.0 +ULAS42019 = 2.0 + # Bust-A-Move Deluxe NPJH50087 = 1.0 ULES00233 = 1.0 From c44afcf462195f8eee0b7b60750f2b2727ed1a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 14:37:56 +0100 Subject: [PATCH 351/374] Typo fix --- Common/VR/VRBase.cpp | 24 ++++++++++++------------ Common/VR/VRBase.h | 2 +- Common/VR/VRFramebuffer.cpp | 12 ++++++------ Common/VR/VRInput.cpp | 8 ++++---- Common/VR/VRRenderer.cpp | 6 +++--- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index c6661f1cf0..ec4a44c703 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -65,17 +65,17 @@ void VR_Init( void* system, const char* name, int version ) { #endif std::vector extensions; - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); } else { extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME); } extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME); - if (VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) { + if (VR_GetPlatformFlag(VR_PLATFORM_PERFORMANCE_EXT)) { extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME); } - if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { extensions.push_back(XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME); extensions.push_back("XR_PICO_android_controller_function_ext_enable"); extensions.push_back("XR_PICO_view_state_ext_enable"); @@ -106,7 +106,7 @@ void VR_Init( void* system, const char* name, int version ) { #ifdef ANDROID XrInstanceCreateInfoAndroidKHR instanceCreateInfoAndroid = {XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR}; - if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { ovrJava* java = (ovrJava*)system; instanceCreateInfoAndroid.applicationVM = java->Vm; instanceCreateInfoAndroid.applicationActivity = java->ActivityObject; @@ -121,7 +121,7 @@ void VR_Init( void* system, const char* name, int version ) { exit(1); } - if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico)); xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico)); xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStopCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStopCVControllerThreadPico)); @@ -155,7 +155,7 @@ void VR_Init( void* system, const char* name, int version ) { } // Get the graphics requirements. - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { PFN_xrGetVulkanGraphicsRequirementsKHR pfnGetVulkanGraphicsRequirementsKHR = NULL; OXR(xrGetInstanceProcAddr( vr_engine.appState.Instance, @@ -182,9 +182,11 @@ void VR_Init( void* system, const char* name, int version ) { vr_initialized = 1; } +#endif + void VR_Destroy( engine_t* engine ) { if (engine == &vr_engine) { - if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { if (pfnXrStopCVControllerThreadPico != nullptr) { pfnXrStopCVControllerThreadPico(engine->appState.Instance, PXR_TRACKING_6DOF, PXR_TRACKING_6DOF); } @@ -210,7 +212,7 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu XrGraphicsBindingOpenGLWin32KHR graphicsBindingGL = {}; #endif memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo)); - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { sessionCreateInfo.next = graphicsBindingVulkan; } else { #ifdef ANDROID @@ -234,7 +236,7 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu ALOGE("Failed to create XR session: %d.", initResult); exit(1); } - if (VR_GetPlatformFLag(VR_PLATFORM_PICO_INIT)) { + if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { pfnXrSetConfigPICO(engine->appState.Session, TRACKING_ORIGIN, "1"); } @@ -264,12 +266,10 @@ engine_t* VR_GetEngine( void ) { return &vr_engine; } -bool VR_GetPlatformFLag(VRPlatformFlag flag) { +bool VR_GetPlatformFlag(VRPlatformFlag flag) { return vr_platform[flag]; } void VR_SetPlatformFLag(VRPlatformFlag flag, bool value) { vr_platform[flag] = value; } - -#endif diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 4e0e1e266a..0893ac7f84 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -192,7 +192,7 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu void VR_LeaveVR( engine_t* engine ); engine_t* VR_GetEngine( void ); -bool VR_GetPlatformFLag(VRPlatformFlag flag); +bool VR_GetPlatformFlag(VRPlatformFlag flag); void VR_SetPlatformFLag(VRPlatformFlag flag, bool value); void ovrApp_Clear(ovrApp* app); diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 2122191bec..1739e1a0de 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -241,7 +241,7 @@ static bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuff } void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { for (int i = 0; i < (int)frameBuffer->TextureSwapChainLength; i++) { vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKColorImages[i], nullptr); vkDestroyImageView(frameBuffer->VKContext->device, frameBuffer->VKDepthImages[i], nullptr); @@ -265,7 +265,7 @@ void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { } void* ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer) { - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { return (void *)frameBuffer->VKFrameBuffers[frameBuffer->TextureSwapChainIndex]; } else { #if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL @@ -297,7 +297,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer) { ovrFramebuffer_SetCurrent(frameBuffer); - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { #if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL @@ -319,7 +319,7 @@ void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer) { frameBuffer->Acquired = false; // Clear the alpha channel, other way OpenXR would not transfer the framebuffer fully - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { #if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL @@ -370,7 +370,7 @@ void ovrRenderer_Destroy(ovrRenderer* renderer) { } void ovrRenderer_MouseCursor(ovrRenderer* renderer, int x, int y, int size) { - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { //TODO:implement } else { #if XR_USE_GRAPHICS_API_OPENGL_ES || XR_USE_GRAPHICS_API_OPENGL @@ -433,7 +433,7 @@ void ovrApp_HandleSessionStateChanges(ovrApp* app, XrSessionState state) { app->SessionActive = (result == XR_SUCCESS); #ifdef ANDROID - if (app->SessionActive && VR_GetPlatformFLag(VR_PLATFORM_PERFORMANCE_EXT)) { + if (app->SessionActive && VR_GetPlatformFlag(VR_PLATFORM_PERFORMANCE_EXT)) { XrPerfSettingsLevelEXT cpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; XrPerfSettingsLevelEXT gpuPerfLevel = XR_PERF_SETTINGS_LEVEL_BOOST_EXT; diff --git a/Common/VR/VRInput.cpp b/Common/VR/VRInput.cpp index 912bbca17f..dec132ab34 100644 --- a/Common/VR/VRInput.cpp +++ b/Common/VR/VRInput.cpp @@ -266,9 +266,9 @@ void IN_VRInit( engine_t *engine ) { handPoseRightAction = CreateAction(runningActionSet, XR_ACTION_TYPE_POSE_INPUT, "hand_pose_right", NULL, 1, &rightHandPath); XrPath interactionProfilePath = XR_NULL_PATH; - if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST)) { + if (VR_GetPlatformFlag(VR_PLATFORM_CONTROLLER_QUEST)) { OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/oculus/touch_controller", &interactionProfilePath)); - } else if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO)) { + } else if (VR_GetPlatformFlag(VR_PLATFORM_CONTROLLER_PICO)) { OXR(xrStringToPath(engine->appState.Instance, "/interaction_profiles/pico/neo3_controller", &interactionProfilePath)); } @@ -277,11 +277,11 @@ void IN_VRInit( engine_t *engine ) { int currBinding = 0; - if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_QUEST)) { + if (VR_GetPlatformFlag(VR_PLATFORM_CONTROLLER_QUEST)) { bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger"); bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger"); bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/menu/click"); - } else if (VR_GetPlatformFLag(VR_PLATFORM_CONTROLLER_PICO)) { + } else if (VR_GetPlatformFlag(VR_PLATFORM_CONTROLLER_PICO)) { bindings[currBinding++] = ActionSuggestedBinding(indexLeftAction, "/user/hand/left/input/trigger/click"); bindings[currBinding++] = ActionSuggestedBinding(indexRightAction, "/user/hand/right/input/trigger/click"); bindings[currBinding++] = ActionSuggestedBinding(menuAction, "/user/hand/left/input/back/click"); diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 50fc4c0003..6895ad024f 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -154,7 +154,7 @@ void VR_Recenter(engine_t* engine) { // Create a default stage space to use if SPACE_TYPE_STAGE is not // supported, or calls to xrGetReferenceSpaceBoundsRect fail. spaceCreateInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL; - if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) { + if (VR_GetPlatformFlag(VR_PLATFORM_TRACKING_FLOOR)) { spaceCreateInfo.poseInReferenceSpace.position.y = -1.6750f; } OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.FakeStageSpace)); @@ -166,7 +166,7 @@ void VR_Recenter(engine_t* engine) { spaceCreateInfo.poseInReferenceSpace.position.y = 0.0; OXR(xrCreateReferenceSpace(engine->appState.Session, &spaceCreateInfo, &engine->appState.StageSpace)); ALOGV("Created stage space"); - if (VR_GetPlatformFLag(VR_PLATFORM_TRACKING_FLOOR)) { + if (VR_GetPlatformFlag(VR_PLATFORM_TRACKING_FLOOR)) { engine->appState.CurrentSpace = engine->appState.StageSpace; } } @@ -211,7 +211,7 @@ void VR_InitRenderer( engine_t* engine, bool multiview ) { projections = (XrView*)(malloc(ovrMaxNumEyes * sizeof(XrView))); void* vulkanContext = nullptr; - if (VR_GetPlatformFLag(VR_PLATFORM_RENDERER_VULKAN)) { + if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { vulkanContext = &engine->graphicsBindingVulkan; } ovrRenderer_Create(engine->appState.Session, &engine->appState.Renderer, From 0ef39d11d8b2cd56cf70731ae67e3cfe0ba8726d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 15:37:58 +0100 Subject: [PATCH 352/374] Add a dynamic loader for OpenXR so the VR code can link. Make it all build on Windows. --- CMakeLists.txt | 2 + Common/Common.vcxproj | 4 +- Common/Common.vcxproj.filters | 8 +- Common/VR/OpenXRLoader.cpp | 160 ++++++++++++++++++++++++++++++++++ Common/VR/OpenXRLoader.h | 109 +++++++++++++++++++++++ Common/VR/PPSSPPVR.cpp | 18 ++-- Common/VR/PPSSPPVR.h | 33 ------- Common/VR/VRBase.cpp | 20 +++-- Common/VR/VRBase.h | 32 +------ Common/VR/VRRenderer.cpp | 1 + android/jni/Android.mk | 1 + libretro/Makefile.common | 1 + 12 files changed, 312 insertions(+), 77 deletions(-) create mode 100644 Common/VR/OpenXRLoader.cpp create mode 100644 Common/VR/OpenXRLoader.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b9084bea3a..12c75eaff3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -507,6 +507,8 @@ if(WIN32) endif() set(CommonVR + Common/VR/OpenXRLoader.cpp + Common/VR/OpenXRLoader.h Common/VR/PPSSPPVR.cpp Common/VR/PPSSPPVR.h Common/VR/VRBase.cpp diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index 5c085bd0ed..39e804db79 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -557,6 +557,7 @@ + @@ -995,6 +996,7 @@ + @@ -1015,4 +1017,4 @@ - + \ No newline at end of file diff --git a/Common/Common.vcxproj.filters b/Common/Common.vcxproj.filters index 5c58a6453f..33468b43d8 100644 --- a/Common/Common.vcxproj.filters +++ b/Common/Common.vcxproj.filters @@ -443,6 +443,9 @@ VR + + VR + @@ -839,6 +842,9 @@ VR + + VR + @@ -952,4 +958,4 @@ ext\libpng17 - + \ No newline at end of file diff --git a/Common/VR/OpenXRLoader.cpp b/Common/VR/OpenXRLoader.cpp new file mode 100644 index 0000000000..57b39f85f1 --- /dev/null +++ b/Common/VR/OpenXRLoader.cpp @@ -0,0 +1,160 @@ +#include "Common/VR/OpenXRLoader.h" +#ifdef _WIN32 +#include "Common/CommonWindows.h" +#endif + +#ifdef XR_NO_PROTOTYPES + +PFN_xrGetInstanceProcAddr xrGetInstanceProcAddr; +PFN_xrEnumerateApiLayerProperties xrEnumerateApiLayerProperties; +PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties; +PFN_xrCreateInstance xrCreateInstance; +PFN_xrDestroyInstance xrDestroyInstance; +PFN_xrGetInstanceProperties xrGetInstanceProperties; +PFN_xrPollEvent xrPollEvent; +PFN_xrResultToString xrResultToString; +PFN_xrStructureTypeToString xrStructureTypeToString; +PFN_xrGetSystem xrGetSystem; +PFN_xrGetSystemProperties xrGetSystemProperties; +PFN_xrEnumerateEnvironmentBlendModes xrEnumerateEnvironmentBlendModes; +PFN_xrCreateSession xrCreateSession; +PFN_xrDestroySession xrDestroySession; +PFN_xrEnumerateReferenceSpaces xrEnumerateReferenceSpaces; +PFN_xrCreateReferenceSpace xrCreateReferenceSpace; +PFN_xrGetReferenceSpaceBoundsRect xrGetReferenceSpaceBoundsRect; +PFN_xrCreateActionSpace xrCreateActionSpace; +PFN_xrLocateSpace xrLocateSpace; +PFN_xrDestroySpace xrDestroySpace; +PFN_xrEnumerateViewConfigurations xrEnumerateViewConfigurations; +PFN_xrGetViewConfigurationProperties xrGetViewConfigurationProperties; +PFN_xrEnumerateViewConfigurationViews xrEnumerateViewConfigurationViews; +PFN_xrEnumerateSwapchainFormats xrEnumerateSwapchainFormats; +PFN_xrCreateSwapchain xrCreateSwapchain; +PFN_xrDestroySwapchain xrDestroySwapchain; +PFN_xrEnumerateSwapchainImages xrEnumerateSwapchainImages; +PFN_xrAcquireSwapchainImage xrAcquireSwapchainImage; +PFN_xrWaitSwapchainImage xrWaitSwapchainImage; +PFN_xrReleaseSwapchainImage xrReleaseSwapchainImage; +PFN_xrBeginSession xrBeginSession; +PFN_xrEndSession xrEndSession; +PFN_xrRequestExitSession xrRequestExitSession; +PFN_xrWaitFrame xrWaitFrame; +PFN_xrBeginFrame xrBeginFrame; +PFN_xrEndFrame xrEndFrame; +PFN_xrLocateViews xrLocateViews; +PFN_xrStringToPath xrStringToPath; +PFN_xrPathToString xrPathToString; +PFN_xrCreateActionSet xrCreateActionSet; +PFN_xrDestroyActionSet xrDestroyActionSet; +PFN_xrCreateAction xrCreateAction; +PFN_xrDestroyAction xrDestroyAction; +PFN_xrSuggestInteractionProfileBindings xrSuggestInteractionProfileBindings; +PFN_xrAttachSessionActionSets xrAttachSessionActionSets; +PFN_xrGetCurrentInteractionProfile xrGetCurrentInteractionProfile; +PFN_xrGetActionStateBoolean xrGetActionStateBoolean; +PFN_xrGetActionStateFloat xrGetActionStateFloat; +PFN_xrGetActionStateVector2f xrGetActionStateVector2f; +PFN_xrGetActionStatePose xrGetActionStatePose; +PFN_xrSyncActions xrSyncActions; +PFN_xrEnumerateBoundSourcesForAction xrEnumerateBoundSourcesForAction; +PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName; +PFN_xrApplyHapticFeedback xrApplyHapticFeedback; +PFN_xrStopHapticFeedback xrStopHapticFeedback; + +#ifdef _WIN32 +#define dlsym(x, y) GetProcAddress(x, y) +static HMODULE g_xrLibrary; +#else +#define dlsym(x, y) nullptr +void *xrLibrary; +#endif + +#define LOAD_INSTANCE_FUNC(name) (PFN_ ## name)xrGetInstanceProcAddr(instance, #name, (PFN_xrVoidFunction *)(&name)) + + +bool XRLoad() { + if (g_xrLibrary) { + // Already loaded. That's OK. + return true; + } + +#ifdef _WIN32 + g_xrLibrary = LoadLibrary(L"openxr_loader.dll"); + if (!g_xrLibrary) { + return false; + } +#else + void *library = nullptr; +#endif + + // Load the three basic functions. + xrGetInstanceProcAddr = (PFN_xrGetInstanceProcAddr)dlsym(g_xrLibrary, "xrGetInstanceProcAddr"); + xrEnumerateApiLayerProperties = (PFN_xrEnumerateApiLayerProperties)dlsym(g_xrLibrary, "xrEnumerateApiLayerProperties"); + xrEnumerateInstanceExtensionProperties = (PFN_xrEnumerateInstanceExtensionProperties)dlsym(g_xrLibrary, "xrEnumerateInstanceExtensionProperties"); + + // Load the rest. + return true; +} + +void XRLoadInstanceFunctions(XrInstance instance) { + LOAD_INSTANCE_FUNC(xrCreateInstance); + LOAD_INSTANCE_FUNC(xrGetInstanceProcAddr); + LOAD_INSTANCE_FUNC(xrEnumerateApiLayerProperties); + LOAD_INSTANCE_FUNC(xrEnumerateInstanceExtensionProperties); + LOAD_INSTANCE_FUNC(xrCreateInstance); + LOAD_INSTANCE_FUNC(xrDestroyInstance); + LOAD_INSTANCE_FUNC(xrGetInstanceProperties); + LOAD_INSTANCE_FUNC(xrPollEvent); + LOAD_INSTANCE_FUNC(xrResultToString); + LOAD_INSTANCE_FUNC(xrStructureTypeToString); + LOAD_INSTANCE_FUNC(xrGetSystem); + LOAD_INSTANCE_FUNC(xrGetSystemProperties); + LOAD_INSTANCE_FUNC(xrEnumerateEnvironmentBlendModes); + LOAD_INSTANCE_FUNC(xrCreateSession); + LOAD_INSTANCE_FUNC(xrDestroySession); + LOAD_INSTANCE_FUNC(xrEnumerateReferenceSpaces); + LOAD_INSTANCE_FUNC(xrCreateReferenceSpace); + LOAD_INSTANCE_FUNC(xrGetReferenceSpaceBoundsRect); + LOAD_INSTANCE_FUNC(xrCreateActionSpace); + LOAD_INSTANCE_FUNC(xrLocateSpace); + LOAD_INSTANCE_FUNC(xrDestroySpace); + LOAD_INSTANCE_FUNC(xrEnumerateViewConfigurations); + LOAD_INSTANCE_FUNC(xrGetViewConfigurationProperties); + LOAD_INSTANCE_FUNC(xrEnumerateViewConfigurationViews); + LOAD_INSTANCE_FUNC(xrEnumerateSwapchainFormats); + LOAD_INSTANCE_FUNC(xrCreateSwapchain); + LOAD_INSTANCE_FUNC(xrDestroySwapchain); + LOAD_INSTANCE_FUNC(xrEnumerateSwapchainImages); + LOAD_INSTANCE_FUNC(xrAcquireSwapchainImage); + LOAD_INSTANCE_FUNC(xrWaitSwapchainImage); + LOAD_INSTANCE_FUNC(xrReleaseSwapchainImage); + LOAD_INSTANCE_FUNC(xrBeginSession); + LOAD_INSTANCE_FUNC(xrEndSession); + LOAD_INSTANCE_FUNC(xrRequestExitSession); + LOAD_INSTANCE_FUNC(xrWaitFrame); + LOAD_INSTANCE_FUNC(xrBeginFrame); + LOAD_INSTANCE_FUNC(xrEndFrame); + LOAD_INSTANCE_FUNC(xrLocateViews); + LOAD_INSTANCE_FUNC(xrStringToPath); + LOAD_INSTANCE_FUNC(xrPathToString); + LOAD_INSTANCE_FUNC(xrCreateActionSet); + LOAD_INSTANCE_FUNC(xrDestroyActionSet); + LOAD_INSTANCE_FUNC(xrCreateAction); + LOAD_INSTANCE_FUNC(xrDestroyAction); + LOAD_INSTANCE_FUNC(xrSuggestInteractionProfileBindings); + LOAD_INSTANCE_FUNC(xrAttachSessionActionSets); + LOAD_INSTANCE_FUNC(xrGetCurrentInteractionProfile); + LOAD_INSTANCE_FUNC(xrGetActionStateBoolean); + LOAD_INSTANCE_FUNC(xrGetActionStateFloat); + LOAD_INSTANCE_FUNC(xrGetActionStateVector2f); + LOAD_INSTANCE_FUNC(xrGetActionStatePose); + LOAD_INSTANCE_FUNC(xrSyncActions); + LOAD_INSTANCE_FUNC(xrEnumerateBoundSourcesForAction); + LOAD_INSTANCE_FUNC(xrGetInputSourceLocalizedName); + LOAD_INSTANCE_FUNC(xrApplyHapticFeedback); + LOAD_INSTANCE_FUNC(xrStopHapticFeedback); + + // TODO: Load any extensions we need, too. +} + +#endif diff --git a/Common/VR/OpenXRLoader.h b/Common/VR/OpenXRLoader.h new file mode 100644 index 0000000000..e8b4822d86 --- /dev/null +++ b/Common/VR/OpenXRLoader.h @@ -0,0 +1,109 @@ +#pragma once + +//Vulkan +#ifdef VK_USE_NATIVE_LIB +#include +#else +#include "Common/GPU/Vulkan/VulkanLoader.h" +using namespace PPSSPP_VK; +#endif + +#ifdef ANDROID +//OpenXR +#define XR_USE_PLATFORM_ANDROID 1 +#define XR_USE_GRAPHICS_API_OPENGL_ES 1 +#define XR_USE_GRAPHICS_API_VULKAN 1 +#include +#include +#include +#elif defined(_WIN32) +#include "Common/CommonWindows.h" +#include "Common/GPU/OpenGL/GLCommon.h" +#include "Common/VR/OpenXRLoader.h" +#include +#define XR_USE_PLATFORM_WIN32 1 +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_GRAPHICS_API_VULKAN 1 +#define XR_NO_PROTOTYPES 1 +#else +#define XR_USE_GRAPHICS_API_VULKAN 1 +#define XR_NO_PROTOTYPES 1 +#endif + +#include +#include + +#ifdef XR_NO_PROTOTYPES + +extern PFN_xrGetInstanceProcAddr xrGetInstanceProcAddr; +extern PFN_xrEnumerateApiLayerProperties xrEnumerateApiLayerProperties; +extern PFN_xrEnumerateInstanceExtensionProperties xrEnumerateInstanceExtensionProperties; +extern PFN_xrCreateInstance xrCreateInstance; +extern PFN_xrDestroyInstance xrDestroyInstance; +extern PFN_xrGetInstanceProperties xrGetInstanceProperties; +extern PFN_xrPollEvent xrPollEvent; +extern PFN_xrResultToString xrResultToString; +extern PFN_xrStructureTypeToString xrStructureTypeToString; +extern PFN_xrGetSystem xrGetSystem; +extern PFN_xrGetSystemProperties xrGetSystemProperties; +extern PFN_xrEnumerateEnvironmentBlendModes xrEnumerateEnvironmentBlendModes; +extern PFN_xrCreateSession xrCreateSession; +extern PFN_xrDestroySession xrDestroySession; +extern PFN_xrEnumerateReferenceSpaces xrEnumerateReferenceSpaces; +extern PFN_xrCreateReferenceSpace xrCreateReferenceSpace; +extern PFN_xrGetReferenceSpaceBoundsRect xrGetReferenceSpaceBoundsRect; +extern PFN_xrCreateActionSpace xrCreateActionSpace; +extern PFN_xrLocateSpace xrLocateSpace; +extern PFN_xrDestroySpace xrDestroySpace; +extern PFN_xrEnumerateViewConfigurations xrEnumerateViewConfigurations; +extern PFN_xrGetViewConfigurationProperties xrGetViewConfigurationProperties; +extern PFN_xrEnumerateViewConfigurationViews xrEnumerateViewConfigurationViews; +extern PFN_xrEnumerateSwapchainFormats xrEnumerateSwapchainFormats; +extern PFN_xrCreateSwapchain xrCreateSwapchain; +extern PFN_xrDestroySwapchain xrDestroySwapchain; +extern PFN_xrEnumerateSwapchainImages xrEnumerateSwapchainImages; +extern PFN_xrAcquireSwapchainImage xrAcquireSwapchainImage; +extern PFN_xrWaitSwapchainImage xrWaitSwapchainImage; +extern PFN_xrReleaseSwapchainImage xrReleaseSwapchainImage; +extern PFN_xrBeginSession xrBeginSession; +extern PFN_xrEndSession xrEndSession; +extern PFN_xrRequestExitSession xrRequestExitSession; +extern PFN_xrWaitFrame xrWaitFrame; +extern PFN_xrBeginFrame xrBeginFrame; +extern PFN_xrEndFrame xrEndFrame; +extern PFN_xrLocateViews xrLocateViews; +extern PFN_xrStringToPath xrStringToPath; +extern PFN_xrPathToString xrPathToString; +extern PFN_xrCreateActionSet xrCreateActionSet; +extern PFN_xrDestroyActionSet xrDestroyActionSet; +extern PFN_xrCreateAction xrCreateAction; +extern PFN_xrDestroyAction xrDestroyAction; +extern PFN_xrSuggestInteractionProfileBindings xrSuggestInteractionProfileBindings; +extern PFN_xrAttachSessionActionSets xrAttachSessionActionSets; +extern PFN_xrGetCurrentInteractionProfile xrGetCurrentInteractionProfile; +extern PFN_xrGetActionStateBoolean xrGetActionStateBoolean; +extern PFN_xrGetActionStateFloat xrGetActionStateFloat; +extern PFN_xrGetActionStateVector2f xrGetActionStateVector2f; +extern PFN_xrGetActionStatePose xrGetActionStatePose; +extern PFN_xrSyncActions xrSyncActions; +extern PFN_xrEnumerateBoundSourcesForAction xrEnumerateBoundSourcesForAction; +extern PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName; +extern PFN_xrApplyHapticFeedback xrApplyHapticFeedback; +extern PFN_xrStopHapticFeedback xrStopHapticFeedback; + +// Dynamic loader for OpenXR on desktop platforms. +// On Quest/Pico, we use statically linked loaders provided by the platform owners. +// On Windows (and Linux etc), we're not so lucky - we could link to static libraries, but we really +// don't want to as we still want to function when one is not present. +// +// Similar to our dynamic Vulkan loader. + +bool XRLoad(); +void XRLoadInstanceFunctions(XrInstance instance); + +#else + +inline bool XRLoad() { return true; } +inline void XRLoadInstanceFunctions(XrInstance instance) {} + +#endif diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index e133ebd277..4cec7c42c9 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -1,5 +1,3 @@ -#ifdef OPENXR - #include "Common/GPU/OpenGL/GLRenderManager.h" #include "Common/GPU/Vulkan/VulkanContext.h" @@ -396,6 +394,12 @@ void* BindVRFramebuffer() { return VR_BindFramebuffer(VR_GetEngine()); } +inline float clampFloat(float x, float minValue, float maxValue) { + if (x < minValue) return minValue; + if (x > maxValue) return maxValue; + return x; +} + bool StartVRRender() { if (!VR_GetConfig(VR_CONFIG_VIEWPORT_VALID)) { VR_InitRenderer(VR_GetEngine(), IsMultiviewSupported()); @@ -430,8 +434,8 @@ bool StartVRRender() { height = 0; side = 0; } - g_Config.fCameraHeight = std::clamp(height, -10.0f, 10.0f); - g_Config.fCameraSide = std::clamp(side, -10.0f, 10.0f); + g_Config.fCameraHeight = clampFloat(height, -10.0f, 10.0f); + g_Config.fCameraSide = clampFloat(side, -10.0f, 10.0f); //right joystick controls distance and fov float dst = g_Config.fCameraDistance; @@ -445,8 +449,8 @@ bool StartVRRender() { fov = 100; dst = 0; } - g_Config.fCameraDistance = std::clamp(dst, -10.0f, 10.0f); - g_Config.fFieldOfViewPercentage = std::clamp(fov, 100.0f, 200.0f); + g_Config.fCameraDistance = clampFloat(dst, -10.0f, 10.0f); + g_Config.fFieldOfViewPercentage = clampFloat(fov, 100.0f, 200.0f); } // Set customizations @@ -599,5 +603,3 @@ void UpdateVRView(float* leftEye, float* rightEye) { memcpy(dst[index], renderView.M, 16 * sizeof(float)); } } - -#endif diff --git a/Common/VR/PPSSPPVR.h b/Common/VR/PPSSPPVR.h index dfb38471b1..2dd2d1c11f 100644 --- a/Common/VR/PPSSPPVR.h +++ b/Common/VR/PPSSPPVR.h @@ -17,8 +17,6 @@ enum VRCompatFlag { VR_COMPAT_MAX }; -#ifdef OPENXR - // VR app flow integration bool IsVREnabled(); void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name); @@ -45,34 +43,3 @@ bool Is2DVRObject(float* projMatrix, bool ortho); void UpdateVRParams(float* projMatrix); void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye); void UpdateVRView(float* leftEye, float* rightEye); - -#else //dummy integration - -// VR app flow integration -inline bool IsVREnabled() { return false; } -inline void InitVROnAndroid(void* vm, void* activity, const char* system, int version, const char* name) {} -inline void EnterVR(bool firstTime, void* vulkanContext) {} -inline void GetVRResolutionPerEye(int* width, int* height) {} -inline void UpdateVRInput(bool(*NativeKey)(const KeyInput &key), bool(*NativeTouch)(const TouchInput &touch), bool haptics, float dp_xscale, float dp_yscale) {} -inline void UpdateVRSpecialKeys(const KeyInput &key) {} - -// VR games compatibility -inline void PreprocessStepVR(void* step) {} -inline void SetVRCompat(VRCompatFlag flag, long value) {} - -// VR rendering integration -inline void* BindVRFramebuffer() { return nullptr; } -inline bool StartVRRender() { return false; } -inline void FinishVRRender() {} -inline void PreVRFrameRender(int fboIndex) {} -inline void PostVRFrameRender() {} -inline int GetVRFBOIndex() { return 0; } -inline int GetVRPassesCount() { return 1; } -inline bool IsMultiviewSupported() { return false; } -inline bool IsFlatVRScene() { return true; } -inline bool Is2DVRObject(float* projMatrix, bool ortho) { return false; } -inline void UpdateVRParams(float* projMatrix) {} -inline void UpdateVRProjection(float* projMatrix, float* leftEye, float* rightEye) {} -inline void UpdateVRView(float* leftEye, float* rightEye) {} - -#endif diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index ec4a44c703..d6ff987fc4 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -41,12 +41,14 @@ static bool vr_platform[VR_PLATFORM_MAX]; static engine_t vr_engine; int vr_initialized = 0; -#if defined(OPENXR) - void VR_Init( void* system, const char* name, int version ) { if (vr_initialized) return; + if (!XRLoad()) { + return; + } + ovrApp_Clear(&vr_engine.appState); #ifdef ANDROID @@ -68,9 +70,12 @@ void VR_Init( void* system, const char* name, int version ) { if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { extensions.push_back(XR_KHR_VULKAN_ENABLE_EXTENSION_NAME); } else { +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES extensions.push_back(XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME); +#endif } extensions.push_back(XR_KHR_COMPOSITION_LAYER_CYLINDER_EXTENSION_NAME); +#ifdef ANDROID if (VR_GetPlatformFlag(VR_PLATFORM_PERFORMANCE_EXT)) { extensions.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME); extensions.push_back(XR_KHR_ANDROID_THREAD_SETTINGS_EXTENSION_NAME); @@ -83,6 +88,7 @@ void VR_Init( void* system, const char* name, int version ) { extensions.push_back("XR_PICO_configs_ext"); extensions.push_back("XR_PICO_reset_sensor"); } +#endif // Create the OpenXR instance. XrApplicationInfo appInfo; @@ -101,7 +107,7 @@ void VR_Init( void* system, const char* name, int version ) { instanceCreateInfo.applicationInfo = appInfo; instanceCreateInfo.enabledApiLayerCount = 0; instanceCreateInfo.enabledApiLayerNames = NULL; - instanceCreateInfo.enabledExtensionCount = extensions.size(); + instanceCreateInfo.enabledExtensionCount = (uint32_t)extensions.size(); instanceCreateInfo.enabledExtensionNames = extensions.data(); #ifdef ANDROID @@ -121,6 +127,8 @@ void VR_Init( void* system, const char* name, int version ) { exit(1); } + XRLoadInstanceFunctions(vr_engine.appState.Instance); + if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrSetEngineVersionPico", (PFN_xrVoidFunction*)(&pfnXrSetEngineVersionPico)); xrGetInstanceProcAddr(vr_engine.appState.Instance, "xrStartCVControllerThreadPico", (PFN_xrVoidFunction*)(&pfnXrStartCVControllerThreadPico)); @@ -166,6 +174,7 @@ void VR_Init( void* system, const char* name, int version ) { graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_VULKAN_KHR; OXR(pfnGetVulkanGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements)); } else { +#ifdef XR_USE_GRAPHICS_API_OPENGL_ES PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL; OXR(xrGetInstanceProcAddr( vr_engine.appState.Instance, @@ -175,15 +184,16 @@ void VR_Init( void* system, const char* name, int version ) { XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {}; graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR; OXR(pfnGetOpenGLESGraphicsRequirementsKHR(vr_engine.appState.Instance, systemId, &graphicsRequirements)); +#endif } +#ifdef ANDROID vr_engine.appState.MainThreadTid = gettid(); +#endif vr_engine.appState.SystemId = systemId; vr_initialized = 1; } -#endif - void VR_Destroy( engine_t* engine ) { if (engine == &vr_engine) { if (VR_GetPlatformFlag(VR_PLATFORM_PICO_INIT)) { diff --git a/Common/VR/VRBase.h b/Common/VR/VRBase.h index 0893ac7f84..34e52908d4 100644 --- a/Common/VR/VRBase.h +++ b/Common/VR/VRBase.h @@ -10,36 +10,10 @@ #define ALOGV(...) printf(__VA_ARGS__) #endif -//Vulkan -#ifdef VK_USE_NATIVE_LIB -#include -#else -#include "Common/GPU/Vulkan/VulkanLoader.h" -using namespace PPSSPP_VK; -#endif +#include "Common/VR/OpenXRLoader.h" -#ifdef ANDROID -//OpenXR -#define XR_USE_PLATFORM_ANDROID 1 -#define XR_USE_GRAPHICS_API_OPENGL_ES 1 -#define XR_USE_GRAPHICS_API_VULKAN 1 -#include -#include -#include -#elif defined(_WIN32) -#include "Common/CommonWindows.h" -#include "Common/GPU/OpenGL/GLCommon.h" -#include -#define XR_USE_PLATFORM_WIN32 1 -#define XR_USE_GRAPHICS_API_OPENGL 1 -#define XR_USE_GRAPHICS_API_VULKAN 1 -#else -#define XR_USE_GRAPHICS_API_VULKAN 1 -#endif - -#include -#include -#include +#define _USE_MATH_DEFINES +#include #ifdef ANDROID diff --git a/Common/VR/VRRenderer.cpp b/Common/VR/VRRenderer.cpp index 6895ad024f..e67d4ecd62 100644 --- a/Common/VR/VRRenderer.cpp +++ b/Common/VR/VRRenderer.cpp @@ -4,6 +4,7 @@ #include "VRBase.h" #include "VRInput.h" #include "VRRenderer.h" +#include "OpenXRLoader.h" #include #include diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 8913f641e5..2f3887c3e2 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -72,6 +72,7 @@ SPIRV_CROSS_FILES := \ $(SRC)/ext/SPIRV-Cross/spirv_cross_parsed_ir.cpp VR_FILES := \ + $(SRC)/Common/VR/OpenXRLoader.cpp \ $(SRC)/Common/VR/PPSSPPVR.cpp \ $(SRC)/Common/VR/VRBase.cpp \ $(SRC)/Common/VR/VRFramebuffer.cpp \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 7d858e0129..27540dc86f 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -314,6 +314,7 @@ SOURCES_CXX += \ $(COMMONDIR)/TimeUtil.cpp SOURCES_CXX += \ + $(COMMONDIR)/VR/OpenXRLoader.cpp \ $(COMMONDIR)/VR/PPSSPPVR.cpp \ $(COMMONDIR)/VR/VRBase.cpp \ $(COMMONDIR)/VR/VRMath.cpp \ From 162290147fcdac1b42504dc6fa320fe255626c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 15:50:47 +0100 Subject: [PATCH 353/374] UWP build fix. Had to reshuffle some stuff and compile some Vulkan files. --- Common/GPU/Vulkan/VulkanContext.cpp | 31 ---------------------- Common/GPU/Vulkan/VulkanContext.h | 1 - Common/GPU/Vulkan/VulkanLoader.cpp | 34 ++++++++++++++++++++++++- Common/GPU/Vulkan/VulkanLoader.h | 2 ++ Common/VR/OpenXRLoader.cpp | 8 +++--- Common/VR/OpenXRLoader.h | 10 +++++--- Common/VR/PPSSPPVR.cpp | 16 +++++++++--- Common/VR/VRBase.cpp | 6 ++--- Common/VR/VRFramebuffer.cpp | 4 +++ UWP/CommonUWP/CommonUWP.vcxproj | 4 +++ UWP/CommonUWP/CommonUWP.vcxproj.filters | 15 +++++++++++ UWP/PPSSPP_UWPMain.cpp | 4 --- 12 files changed, 85 insertions(+), 50 deletions(-) diff --git a/Common/GPU/Vulkan/VulkanContext.cpp b/Common/GPU/Vulkan/VulkanContext.cpp index 8a69c0f037..389eb6dbbe 100644 --- a/Common/GPU/Vulkan/VulkanContext.cpp +++ b/Common/GPU/Vulkan/VulkanContext.cpp @@ -1372,37 +1372,6 @@ void finalize_glslang() { glslang::FinalizeProcess(); } -const char *VulkanResultToString(VkResult res) { - switch (res) { - case VK_NOT_READY: return "VK_NOT_READY"; - case VK_TIMEOUT: return "VK_TIMEOUT"; - case VK_EVENT_SET: return "VK_EVENT_SET"; - case VK_EVENT_RESET: return "VK_EVENT_RESET"; - case VK_INCOMPLETE: return "VK_INCOMPLETE"; - case VK_ERROR_OUT_OF_HOST_MEMORY: return "VK_ERROR_OUT_OF_HOST_MEMORY"; - case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; - case VK_ERROR_INITIALIZATION_FAILED: return "VK_ERROR_INITIALIZATION_FAILED"; - case VK_ERROR_DEVICE_LOST: return "VK_ERROR_DEVICE_LOST"; - case VK_ERROR_MEMORY_MAP_FAILED: return "VK_ERROR_MEMORY_MAP_FAILED"; - case VK_ERROR_LAYER_NOT_PRESENT: return "VK_ERROR_LAYER_NOT_PRESENT"; - case VK_ERROR_EXTENSION_NOT_PRESENT: return "VK_ERROR_EXTENSION_NOT_PRESENT"; - case VK_ERROR_FEATURE_NOT_PRESENT: return "VK_ERROR_FEATURE_NOT_PRESENT"; - case VK_ERROR_INCOMPATIBLE_DRIVER: return "VK_ERROR_INCOMPATIBLE_DRIVER"; - case VK_ERROR_TOO_MANY_OBJECTS: return "VK_ERROR_TOO_MANY_OBJECTS"; - case VK_ERROR_FORMAT_NOT_SUPPORTED: return "VK_ERROR_FORMAT_NOT_SUPPORTED"; - case VK_ERROR_SURFACE_LOST_KHR: return "VK_ERROR_SURFACE_LOST_KHR"; - case VK_SUBOPTIMAL_KHR: return "VK_SUBOPTIMAL_KHR"; - case VK_ERROR_OUT_OF_DATE_KHR: return "VK_ERROR_OUT_OF_DATE_KHR"; - case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; - case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; - case VK_ERROR_OUT_OF_POOL_MEMORY_KHR: return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR"; - case VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR: return "VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR"; - - default: - return "VK_ERROR_...(unknown)"; - } -} - void VulkanDeleteList::Take(VulkanDeleteList &del) { _dbg_assert_(cmdPools_.empty()); _dbg_assert_(descPools_.empty()); diff --git a/Common/GPU/Vulkan/VulkanContext.h b/Common/GPU/Vulkan/VulkanContext.h index 7baf795717..a6f568aa5f 100644 --- a/Common/GPU/Vulkan/VulkanContext.h +++ b/Common/GPU/Vulkan/VulkanContext.h @@ -461,7 +461,6 @@ enum class GLSLVariant { bool GLSLtoSPV(const VkShaderStageFlagBits shader_type, const char *sourceCode, GLSLVariant variant, std::vector &spirv, std::string *errorMessage); -const char *VulkanResultToString(VkResult res); const char *VulkanColorSpaceToString(VkColorSpaceKHR colorSpace); const char *VulkanFormatToString(VkFormat format); diff --git a/Common/GPU/Vulkan/VulkanLoader.cpp b/Common/GPU/Vulkan/VulkanLoader.cpp index 32984494ce..c6012f001e 100644 --- a/Common/GPU/Vulkan/VulkanLoader.cpp +++ b/Common/GPU/Vulkan/VulkanLoader.cpp @@ -239,7 +239,6 @@ static VulkanLibraryHandle vulkanLibrary; typedef void *VulkanLibraryHandle; static VulkanLibraryHandle vulkanLibrary; #endif -const char *VulkanResultToString(VkResult res); bool g_vulkanAvailabilityChecked = false; bool g_vulkanMayBeAvailable = false; @@ -274,6 +273,8 @@ static VulkanLibraryHandle VulkanLoadLibrary(const char *logname) { #if PPSSPP_PLATFORM(SWITCH) // Always unavailable, for now. return nullptr; +#elif PPSSPP_PLATFORM(UWP) + return nullptr; #elif PPSSPP_PLATFORM(WINDOWS) return LoadLibrary(L"vulkan-1.dll"); #else @@ -724,3 +725,34 @@ void VulkanLoadDeviceFunctions(VkDevice device, const VulkanExtensions &enabledE void VulkanFree() { VulkanFreeLibrary(vulkanLibrary); } + +const char *VulkanResultToString(VkResult res) { + switch (res) { + case VK_NOT_READY: return "VK_NOT_READY"; + case VK_TIMEOUT: return "VK_TIMEOUT"; + case VK_EVENT_SET: return "VK_EVENT_SET"; + case VK_EVENT_RESET: return "VK_EVENT_RESET"; + case VK_INCOMPLETE: return "VK_INCOMPLETE"; + case VK_ERROR_OUT_OF_HOST_MEMORY: return "VK_ERROR_OUT_OF_HOST_MEMORY"; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; + case VK_ERROR_INITIALIZATION_FAILED: return "VK_ERROR_INITIALIZATION_FAILED"; + case VK_ERROR_DEVICE_LOST: return "VK_ERROR_DEVICE_LOST"; + case VK_ERROR_MEMORY_MAP_FAILED: return "VK_ERROR_MEMORY_MAP_FAILED"; + case VK_ERROR_LAYER_NOT_PRESENT: return "VK_ERROR_LAYER_NOT_PRESENT"; + case VK_ERROR_EXTENSION_NOT_PRESENT: return "VK_ERROR_EXTENSION_NOT_PRESENT"; + case VK_ERROR_FEATURE_NOT_PRESENT: return "VK_ERROR_FEATURE_NOT_PRESENT"; + case VK_ERROR_INCOMPATIBLE_DRIVER: return "VK_ERROR_INCOMPATIBLE_DRIVER"; + case VK_ERROR_TOO_MANY_OBJECTS: return "VK_ERROR_TOO_MANY_OBJECTS"; + case VK_ERROR_FORMAT_NOT_SUPPORTED: return "VK_ERROR_FORMAT_NOT_SUPPORTED"; + case VK_ERROR_SURFACE_LOST_KHR: return "VK_ERROR_SURFACE_LOST_KHR"; + case VK_SUBOPTIMAL_KHR: return "VK_SUBOPTIMAL_KHR"; + case VK_ERROR_OUT_OF_DATE_KHR: return "VK_ERROR_OUT_OF_DATE_KHR"; + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; + case VK_ERROR_OUT_OF_POOL_MEMORY_KHR: return "VK_ERROR_OUT_OF_POOL_MEMORY_KHR"; + case VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR: return "VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR"; + + default: + return "VK_ERROR_...(unknown)"; + } +} diff --git a/Common/GPU/Vulkan/VulkanLoader.h b/Common/GPU/Vulkan/VulkanLoader.h index b0c14570da..4f2d97d045 100644 --- a/Common/GPU/Vulkan/VulkanLoader.h +++ b/Common/GPU/Vulkan/VulkanLoader.h @@ -254,3 +254,5 @@ bool VulkanLoad(); void VulkanLoadInstanceFunctions(VkInstance instance, const VulkanExtensions &enabledExtensions); void VulkanLoadDeviceFunctions(VkDevice device, const VulkanExtensions &enabledExtensions); void VulkanFree(); + +const char *VulkanResultToString(VkResult res); diff --git a/Common/VR/OpenXRLoader.cpp b/Common/VR/OpenXRLoader.cpp index 57b39f85f1..4d5f8fb246 100644 --- a/Common/VR/OpenXRLoader.cpp +++ b/Common/VR/OpenXRLoader.cpp @@ -61,12 +61,12 @@ PFN_xrGetInputSourceLocalizedName xrGetInputSourceLocalizedName; PFN_xrApplyHapticFeedback xrApplyHapticFeedback; PFN_xrStopHapticFeedback xrStopHapticFeedback; -#ifdef _WIN32 +#ifdef XR_USE_PLATFORM_WIN32 #define dlsym(x, y) GetProcAddress(x, y) static HMODULE g_xrLibrary; #else #define dlsym(x, y) nullptr -void *xrLibrary; +void *g_xrLibrary; #endif #define LOAD_INSTANCE_FUNC(name) (PFN_ ## name)xrGetInstanceProcAddr(instance, #name, (PFN_xrVoidFunction *)(&name)) @@ -78,13 +78,13 @@ bool XRLoad() { return true; } -#ifdef _WIN32 +#ifdef XR_USE_PLATFORM_WIN32 g_xrLibrary = LoadLibrary(L"openxr_loader.dll"); if (!g_xrLibrary) { return false; } #else - void *library = nullptr; + return false; #endif // Load the three basic functions. diff --git a/Common/VR/OpenXRLoader.h b/Common/VR/OpenXRLoader.h index e8b4822d86..ab174ed50c 100644 --- a/Common/VR/OpenXRLoader.h +++ b/Common/VR/OpenXRLoader.h @@ -18,12 +18,16 @@ using namespace PPSSPP_VK; #include #elif defined(_WIN32) #include "Common/CommonWindows.h" +#if defined(WINAPI_FAMILY) && defined(WINAPI_FAMILY_PARTITION) +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP #include "Common/GPU/OpenGL/GLCommon.h" +#define XR_USE_GRAPHICS_API_OPENGL 1 +#define XR_USE_PLATFORM_WIN32 1 +#endif +#endif +#define XR_USE_GRAPHICS_API_VULKAN 1 #include "Common/VR/OpenXRLoader.h" #include -#define XR_USE_PLATFORM_WIN32 1 -#define XR_USE_GRAPHICS_API_OPENGL 1 -#define XR_USE_GRAPHICS_API_VULKAN 1 #define XR_NO_PROTOTYPES 1 #else #define XR_USE_GRAPHICS_API_VULKAN 1 diff --git a/Common/VR/PPSSPPVR.cpp b/Common/VR/PPSSPPVR.cpp index 4cec7c42c9..537844b073 100644 --- a/Common/VR/PPSSPPVR.cpp +++ b/Common/VR/PPSSPPVR.cpp @@ -1,12 +1,14 @@ -#include "Common/GPU/OpenGL/GLRenderManager.h" -#include "Common/GPU/Vulkan/VulkanContext.h" - #include "Common/VR/PPSSPPVR.h" #include "Common/VR/VRBase.h" #include "Common/VR/VRInput.h" #include "Common/VR/VRMath.h" #include "Common/VR/VRRenderer.h" +#if XR_USE_GRAPHICS_API_OPENGL +#include "Common/GPU/OpenGL/GLRenderManager.h" +#endif +#include "Common/GPU/Vulkan/VulkanContext.h" + #include "Core/HLE/sceDisplay.h" #include "Core/Config.h" #include "Core/KeyMap.h" @@ -337,6 +339,8 @@ void UpdateVRSpecialKeys(const KeyInput &key) { ================================================================================ */ +#if XR_USE_GRAPHICS_API_OPENGL + void PreprocessSkyplane(GLRStep* step) { // Do not do anything if the scene is not in VR. @@ -378,6 +382,12 @@ void PreprocessStepVR(void* step) { if (vrCompat[VR_COMPAT_SKYPLANE]) PreprocessSkyplane(glrStep); } +#else + +void PreprocessStepVR(void* step) {} + +#endif + void SetVRCompat(VRCompatFlag flag, long value) { vrCompat[flag] = value; } diff --git a/Common/VR/VRBase.cpp b/Common/VR/VRBase.cpp index d6ff987fc4..2855a75e1a 100644 --- a/Common/VR/VRBase.cpp +++ b/Common/VR/VRBase.cpp @@ -30,7 +30,7 @@ enum PxrTrackingDof { typedef XrResult (XRAPI_PTR *PFN_xrSetEngineVersionPico)(XrInstance instance,const char* version); typedef XrResult (XRAPI_PTR *PFN_xrStartCVControllerThreadPico)(XrInstance instance,int headSensorState, int handSensorState); typedef XrResult (XRAPI_PTR *PFN_xrStopCVControllerThreadPico)(XrInstance instance,int headSensorState, int handSensorState); -typedef XrResult (XRAPI_PTR *PFN_xrSetConfigPICO) (XrSession instance, enum ConfigsSetEXT configIndex, char* configData); +typedef XrResult (XRAPI_PTR *PFN_xrSetConfigPICO) (XrSession instance, enum ConfigsSetEXT configIndex, const char *configData); PFN_xrSetConfigPICO pfnXrSetConfigPICO = nullptr; PFN_xrSetEngineVersionPico pfnXrSetEngineVersionPico = nullptr; @@ -218,7 +218,7 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu XrSessionCreateInfo sessionCreateInfo = {}; #ifdef ANDROID XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingGL = {}; -#else +#elif XR_USE_GRAPHICS_API_OPENGL XrGraphicsBindingOpenGLWin32KHR graphicsBindingGL = {}; #endif memset(&sessionCreateInfo, 0, sizeof(sessionCreateInfo)); @@ -231,10 +231,10 @@ void VR_EnterVR( engine_t* engine, XrGraphicsBindingVulkanKHR* graphicsBindingVu graphicsBindingGL.display = eglGetCurrentDisplay(); graphicsBindingGL.config = eglGetCurrentSurface(EGL_DRAW); graphicsBindingGL.context = eglGetCurrentContext(); + sessionCreateInfo.next = &graphicsBindingGL; #else //TODO:PCVR definition #endif - sessionCreateInfo.next = &graphicsBindingGL; } sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO; sessionCreateInfo.createFlags = 0; diff --git a/Common/VR/VRFramebuffer.cpp b/Common/VR/VRFramebuffer.cpp index 1739e1a0de..a3986ee7d4 100644 --- a/Common/VR/VRFramebuffer.cpp +++ b/Common/VR/VRFramebuffer.cpp @@ -137,6 +137,8 @@ static bool ovrFramebuffer_CreateGLES(XrSession session, ovrFramebuffer* frameBu #endif +#if XR_USE_GRAPHICS_API_VULKAN + static bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuffer, int width, int height, bool multiview, void* context) { @@ -240,6 +242,8 @@ static bool ovrFramebuffer_CreateVK(XrSession session, ovrFramebuffer* frameBuff return true; } +#endif + void ovrFramebuffer_Destroy(ovrFramebuffer* frameBuffer) { if (VR_GetPlatformFlag(VR_PLATFORM_RENDERER_VULKAN)) { for (int i = 0; i < (int)frameBuffer->TextureSwapChainLength; i++) { diff --git a/UWP/CommonUWP/CommonUWP.vcxproj b/UWP/CommonUWP/CommonUWP.vcxproj index 90a1c1649c..0415092a9d 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj +++ b/UWP/CommonUWP/CommonUWP.vcxproj @@ -387,6 +387,7 @@ + @@ -502,6 +503,7 @@ + @@ -526,6 +528,7 @@ + @@ -618,6 +621,7 @@ + diff --git a/UWP/CommonUWP/CommonUWP.vcxproj.filters b/UWP/CommonUWP/CommonUWP.vcxproj.filters index dd2f6d6fda..15c00bcbfa 100644 --- a/UWP/CommonUWP/CommonUWP.vcxproj.filters +++ b/UWP/CommonUWP/CommonUWP.vcxproj.filters @@ -88,6 +88,9 @@ {a5bfc343-9c3a-43ff-a033-7b0406e13816} + + {096c3d00-fcfa-4877-8cf0-3b10d56b5d72} + @@ -396,6 +399,12 @@ VR + + VR + + + GPU\Vulkan + @@ -733,6 +742,12 @@ VR + + VR + + + GPU\Vulkan + diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index e4ed18b8f2..b734f6e3d2 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -406,10 +406,6 @@ float System_GetPropertyFloat(SystemProperty prop) { } } -bool VulkanMayBeAvailable() { - return false; -} - void System_Toast(const char *str) {} bool System_GetPropertyBool(SystemProperty prop) { From 44106ff2e793346557f22190bce2c86be288299d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 15:58:07 +0100 Subject: [PATCH 354/374] Linking fix for normal Android devices --- Common/VR/OpenXRLoader.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Common/VR/OpenXRLoader.h b/Common/VR/OpenXRLoader.h index ab174ed50c..fa783b7a58 100644 --- a/Common/VR/OpenXRLoader.h +++ b/Common/VR/OpenXRLoader.h @@ -9,13 +9,20 @@ using namespace PPSSPP_VK; #endif #ifdef ANDROID -//OpenXR +#include #define XR_USE_PLATFORM_ANDROID 1 #define XR_USE_GRAPHICS_API_OPENGL_ES 1 #define XR_USE_GRAPHICS_API_VULKAN 1 #include #include -#include + +#if OPENXR +// One of the Android-based headsets. We're linking with a static OpenXR loader. +#else +// Normal Android app, we don't have a loader so use our own dynamic loader, which won't load anything. +#define XR_NO_PROTOTYPES 1 +#endif + #elif defined(_WIN32) #include "Common/CommonWindows.h" #if defined(WINAPI_FAMILY) && defined(WINAPI_FAMILY_PARTITION) From a5d3af9cb0e2d3f254c1a686e524fb7fcbdd754c Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Nov 2022 07:59:01 -0800 Subject: [PATCH 355/374] GPU: Cleanup GetVertTypeID() usage. --- GPU/Common/DrawEngineCommon.cpp | 2 +- GPU/Common/SplineCommon.cpp | 2 +- GPU/Software/TransformUnit.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index 35cfb7dfa9..bf6d7a432d 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -184,7 +184,7 @@ void DrawEngineCommon::Resized() { } u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, int lowerBound, int upperBound, u32 vertType, int *vertexSize) { - const u32 vertTypeID = (vertType & 0xFFFFFF) | (gstate.getUVGenMode() << 24); + const u32 vertTypeID = GetVertTypeID(vertType, gstate.getUVGenMode()); VertexDecoder *dec = GetVertexDecoder(vertTypeID); if (vertexSize) *vertexSize = dec->VertexSize(); diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index b2358f401b..c5468e1203 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -507,7 +507,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic if (indices) GetIndexBounds(indices, num_points, vertType, &index_lower_bound, &index_upper_bound); - VertexDecoder *origVDecoder = GetVertexDecoder((vertType & 0xFFFFFF) | (gstate.getUVGenMode() << 24)); + VertexDecoder *origVDecoder = GetVertexDecoder(GetVertTypeID(vertType, gstate.getUVGenMode())); *bytesRead = num_points * origVDecoder->VertexSize(); // Simplify away bones and morph before proceeding diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 043683b88c..795d39635f 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -137,7 +137,7 @@ void SoftwareDrawEngine::DispatchSubmitImm(GEPrimitiveType prim, TransformedVert } VertexDecoder *SoftwareDrawEngine::FindVertexDecoder(u32 vtype) { - const u32 vertTypeID = (vtype & 0xFFFFFF) | (gstate.getUVGenMode() << 24); + const u32 vertTypeID = GetVertTypeID(vtype, gstate.getUVGenMode()); return DrawEngineCommon::GetVertexDecoder(vertTypeID); } From 66472c39ce1f20089c30022f0dfd5ecc476edcef Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Nov 2022 08:09:01 -0800 Subject: [PATCH 356/374] GPU: Use skinned position always in bounding check. Meanwhile, move to a flag on decoder options instead of global check. --- GPU/Common/DrawEngineCommon.cpp | 10 ++++++++-- GPU/Common/DrawEngineCommon.h | 4 ++-- GPU/Common/SplineCommon.cpp | 4 ++-- GPU/Common/VertexDecoderCommon.cpp | 2 +- GPU/Common/VertexDecoderCommon.h | 1 + GPU/GPUCommon.cpp | 4 ++-- GPU/Software/TransformUnit.cpp | 7 ++++--- Windows/GEDebugger/TabVertices.cpp | 2 ++ unittest/TestVertexJit.cpp | 12 +++++++++--- 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index bf6d7a432d..b1f4ca7049 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -54,6 +54,7 @@ DrawEngineCommon::~DrawEngineCommon() { void DrawEngineCommon::Init() { useHWTransform_ = g_Config.bHardwareTransform; useHWTessellation_ = UpdateUseHWTessellation(g_Config.bHardwareTessellation); + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } VertexDecoder *DrawEngineCommon::GetVertexDecoder(u32 vtype) { @@ -181,10 +182,11 @@ void DrawEngineCommon::Resized() { useHWTransform_ = g_Config.bHardwareTransform; useHWTessellation_ = UpdateUseHWTessellation(g_Config.bHardwareTessellation); + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, int lowerBound, int upperBound, u32 vertType, int *vertexSize) { - const u32 vertTypeID = GetVertTypeID(vertType, gstate.getUVGenMode()); + const u32 vertTypeID = GetVertTypeID(vertType, gstate.getUVGenMode(), decOptions_.applySkinInDecode); VertexDecoder *dec = GetVertexDecoder(vertTypeID); if (vertexSize) *vertexSize = dec->VertexSize(); @@ -232,7 +234,7 @@ void DrawEngineCommon::DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex } int bytesRead; - uint32_t vertTypeID = GetVertTypeID(vtype, 0); + uint32_t vertTypeID = GetVertTypeID(vtype, 0, decOptions_.applySkinInDecode); SubmitPrim(&temp[0], nullptr, prim, vertexCount, vertTypeID, cullMode, &bytesRead); DispatchFlush(); @@ -280,7 +282,11 @@ bool DrawEngineCommon::TestBoundingBox(const void *control_points, const void *i GetIndexBounds(inds, vertexCount, vertType, &indexLowerBound, &indexUpperBound); } + // Force software skinning. + bool wasApplyingSkinInDecode = decOptions_.applySkinInDecode; + decOptions_.applySkinInDecode = true; NormalizeVertices((u8 *)corners, temp_buffer, (const u8 *)control_points, indexLowerBound, indexUpperBound, vertType); + decOptions_.applySkinInDecode = wasApplyingSkinInDecode; IndexConverter conv(vertType, inds); for (int i = 0; i < vertexCount; i++) { diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index ea14a07884..c0125b28b2 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -52,10 +52,10 @@ enum FBOTexState { FBO_TEX_READ_FRAMEBUFFER, }; -inline uint32_t GetVertTypeID(uint32_t vertType, int uvGenMode) { +inline uint32_t GetVertTypeID(uint32_t vertType, int uvGenMode, bool skinInDecode) { // As the decoder depends on the UVGenMode when we use UV prescale, we simply mash it // into the top of the verttype where there are unused bits. - return (vertType & 0xFFFFFF) | (uvGenMode << 24); + return (vertType & 0xFFFFFF) | (uvGenMode << 24) | (skinInDecode << 26); } struct SimpleVertex; diff --git a/GPU/Common/SplineCommon.cpp b/GPU/Common/SplineCommon.cpp index c5468e1203..6fe6436291 100644 --- a/GPU/Common/SplineCommon.cpp +++ b/GPU/Common/SplineCommon.cpp @@ -507,7 +507,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic if (indices) GetIndexBounds(indices, num_points, vertType, &index_lower_bound, &index_upper_bound); - VertexDecoder *origVDecoder = GetVertexDecoder(GetVertTypeID(vertType, gstate.getUVGenMode())); + VertexDecoder *origVDecoder = GetVertexDecoder(GetVertTypeID(vertType, gstate.getUVGenMode(), decOptions_.applySkinInDecode)); *bytesRead = num_points * origVDecoder->VertexSize(); // Simplify away bones and morph before proceeding @@ -572,7 +572,7 @@ void DrawEngineCommon::SubmitCurve(const void *control_points, const void *indic gstate_c.uv.vOff = 0; } - uint32_t vertTypeID = GetVertTypeID(vertTypeWithIndex16, gstate.getUVGenMode()); + uint32_t vertTypeID = GetVertTypeID(vertTypeWithIndex16, gstate.getUVGenMode(), decOptions_.applySkinInDecode); int generatedBytesRead; if (output.count) DispatchSubmitPrim(output.vertices, output.indices, PatchPrimToPrim(surface.primType), output.count, vertTypeID, gstate.getCullMode(), &generatedBytesRead); diff --git a/GPU/Common/VertexDecoderCommon.cpp b/GPU/Common/VertexDecoderCommon.cpp index 62eb20ef84..3a77375cba 100644 --- a/GPU/Common/VertexDecoderCommon.cpp +++ b/GPU/Common/VertexDecoderCommon.cpp @@ -1089,7 +1089,7 @@ void VertexDecoder::SetVertexType(u32 fmt, const VertexDecoderOptions &options, DEBUG_LOG(G3D, "VTYPE: THRU=%i TC=%i COL=%i POS=%i NRM=%i WT=%i NW=%i IDX=%i MC=%i", (int)throughmode, tc, col, pos, nrm, weighttype, nweights, idx, morphcount); } - skinInDecode = weighttype != 0 && g_Config.bSoftwareSkinning; + skinInDecode = weighttype != 0 && options.applySkinInDecode; if (weighttype) { // && nweights? weightoff = size; diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index d3785e13c9..e4c886cbd4 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -335,6 +335,7 @@ typedef void(*JittedVertexDecoder)(const u8 *src, u8 *dst, int count); struct VertexDecoderOptions { bool expandAllWeightsToFloat; bool expand8BitNormalsToFloat; + bool applySkinInDecode; }; class VertexDecoder { diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index b8c80a76ed..ddaf02bab8 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -1834,7 +1834,7 @@ void GPUCommon::Execute_Prim(u32 op, u32 diff) { // cull mode int cullMode = gstate.getCullMode(); - uint32_t vertTypeID = GetVertTypeID(vertexType, gstate.getUVGenMode()); + uint32_t vertTypeID = GetVertTypeID(vertexType, gstate.getUVGenMode(), g_Config.bSoftwareSkinning); drawEngineCommon_->SubmitPrim(verts, inds, prim, count, vertTypeID, cullMode, &bytesRead); // After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed). // Some games rely on this, they don't bother reloading VADDR and IADDR. @@ -1892,7 +1892,7 @@ void GPUCommon::Execute_Prim(u32 op, u32 diff) { goto bail; } else { vertexType = data; - vertTypeID = GetVertTypeID(vertexType, gstate.getUVGenMode()); + vertTypeID = GetVertTypeID(vertexType, gstate.getUVGenMode(), g_Config.bSoftwareSkinning); } break; } diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 795d39635f..afd7d15920 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -72,7 +72,7 @@ void SoftwareDrawEngine::DispatchSubmitPrim(const void *verts, const void *inds, } void SoftwareDrawEngine::DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex *buffer, int vertexCount, int cullMode, bool continuation) { - uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode()); + uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode(), decOptions_.applySkinInDecode); int flipCull = cullMode != gstate.getCullMode() ? 1 : 0; // TODO: For now, just setting all dirty. @@ -137,7 +137,7 @@ void SoftwareDrawEngine::DispatchSubmitImm(GEPrimitiveType prim, TransformedVert } VertexDecoder *SoftwareDrawEngine::FindVertexDecoder(u32 vtype) { - const u32 vertTypeID = GetVertTypeID(vtype, gstate.getUVGenMode()); + const u32 vertTypeID = GetVertTypeID(vtype, gstate.getUVGenMode(), decOptions_.applySkinInDecode); return DrawEngineCommon::GetVertexDecoder(vertTypeID); } @@ -858,7 +858,7 @@ void TransformUnit::SubmitImmVertex(const ClipVertexData &vert, SoftwareDrawEngi break; } - uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode()); + uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode(), g_Config.bSoftwareSkinning); // This now processes the step with shared logic, given the existing data_. isImmDraw_ = true; SubmitPrimitive(nullptr, nullptr, GE_PRIM_KEEP_PREVIOUS, 0, vertTypeID, nullptr, drawEngine); @@ -958,6 +958,7 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vectorSetVertexType(state.vertType, options); return rowCount_; } diff --git a/unittest/TestVertexJit.cpp b/unittest/TestVertexJit.cpp index 573247ba38..12dad2f5aa 100644 --- a/unittest/TestVertexJit.cpp +++ b/unittest/TestVertexJit.cpp @@ -545,8 +545,10 @@ static bool TestVertexColor565() { static bool TestVertex8Skin() { VertexDecoderTestHarness dec; + VertexDecoderOptions opts{}; + opts.applySkinInDecode = true; + dec.SetOptions(opts); - g_Config.bSoftwareSkinning = true; for (int i = 0; i < 8 * 12; ++i) { gstate.boneMatrix[i] = 0.0f; } @@ -575,8 +577,10 @@ static bool TestVertex8Skin() { static bool TestVertex16Skin() { VertexDecoderTestHarness dec; + VertexDecoderOptions opts{}; + opts.applySkinInDecode = true; + dec.SetOptions(opts); - g_Config.bSoftwareSkinning = true; for (int i = 0; i < 8 * 12; ++i) { gstate.boneMatrix[i] = 0.0f; } @@ -605,8 +609,10 @@ static bool TestVertex16Skin() { static bool TestVertexFloatSkin() { VertexDecoderTestHarness dec; + VertexDecoderOptions opts{}; + opts.applySkinInDecode = true; + dec.SetOptions(opts); - g_Config.bSoftwareSkinning = true; for (int i = 0; i < 8 * 12; ++i) { gstate.boneMatrix[i] = 0.0f; } From 95cb358fbf6e6f7b781a1a5f0ceca98a814c017e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 17:28:50 +0100 Subject: [PATCH 357/374] Change the "Retain changed textures" option into a compat.ini option. This option benefits so few games and can hurt others, so that it's better that we specifically enable it for known cases like Popolocrois. --- Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + Core/Config.cpp | 1 - Core/Config.h | 1 - GPU/Common/TextureCacheCommon.cpp | 4 ++-- UI/GameSettingsScreen.cpp | 7 ------- assets/compat.ini | 12 ++++++++++++ libretro/libretro.cpp | 9 --------- 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index f59a0da45b..b70d7e788b 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -117,6 +117,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "ForceLowerResolutionForEffectsOn", &flags_.ForceLowerResolutionForEffectsOn); CheckSetting(iniFile, gameID, "AllowDownloadCLUT", &flags_.AllowDownloadCLUT); CheckSetting(iniFile, gameID, "NearestFilteringOnFramebufferCreate", &flags_.NearestFilteringOnFramebufferCreate); + CheckSetting(iniFile, gameID, "SecondaryTextureCache", &flags_.SecondaryTextureCache); } void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index 5946f1633b..c37541ce7a 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -89,6 +89,7 @@ struct CompatFlags { bool ForceLowerResolutionForEffectsOn; bool AllowDownloadCLUT; bool NearestFilteringOnFramebufferCreate; + bool SecondaryTextureCache; }; struct VRCompat { diff --git a/Core/Config.cpp b/Core/Config.cpp index b8d1408144..0986474080 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -904,7 +904,6 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("VertexDecCache", &g_Config.bVertexCache, false, true, true), ReportedConfigSetting("TextureBackoffCache", &g_Config.bTextureBackoffCache, false, true, true), - ReportedConfigSetting("TextureSecondaryCache", &g_Config.bTextureSecondaryCache, false, true, true), ReportedConfigSetting("VertexDecJit", &g_Config.bVertexDecoderJit, &DefaultCodeGen, false), #ifndef MOBILE_DEVICE diff --git a/Core/Config.h b/Core/Config.h index 1de62adf27..6dc1226858 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -199,7 +199,6 @@ public: bool bVertexCache; bool bTextureBackoffCache; - bool bTextureSecondaryCache; bool bVertexDecoderJit; bool bFullScreen; bool bFullScreenMulti; diff --git a/GPU/Common/TextureCacheCommon.cpp b/GPU/Common/TextureCacheCommon.cpp index e660bb20f8..53962e7644 100644 --- a/GPU/Common/TextureCacheCommon.cpp +++ b/GPU/Common/TextureCacheCommon.cpp @@ -767,7 +767,7 @@ void TextureCacheCommon::Decimate(bool forcePressure) { } // If enabled, we also need to clear the secondary cache. - if (g_Config.bTextureSecondaryCache && (forcePressure || secondCacheSizeEstimate_ >= TEXCACHE_SECOND_MIN_PRESSURE)) { + if (PSP_CoreParameter().compat.flags().SecondaryTextureCache && (forcePressure || secondCacheSizeEstimate_ >= TEXCACHE_SECOND_MIN_PRESSURE)) { const u32 had = secondCacheSizeEstimate_; for (TexCache::iterator iter = secondCache_.begin(); iter != secondCache_.end(); ) { @@ -2409,7 +2409,7 @@ bool TextureCacheCommon::CheckFullHash(TexCacheEntry *entry, bool &doDelete) { } // Don't give up just yet. Let's try the secondary cache if it's been invalidated before. - if (g_Config.bTextureSecondaryCache) { + if (PSP_CoreParameter().compat.flags().SecondaryTextureCache) { // Don't forget this one was unreliable (in case we match a secondary entry.) entry->status |= TexCacheEntry::STATUS_UNRELIABLE; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index e46311870b..cf87f56f47 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -545,13 +545,6 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_CONTINUE; }); - CheckBox *texSecondary_ = graphicsSettings->Add(new CheckBox(&g_Config.bTextureSecondaryCache, gr->T("Retain changed textures", "Retain changed textures (speedup, mem hog)"))); - texSecondary_->OnClick.Add([=](EventParams &e) { - settingInfo_->Show(gr->T("RetainChangedTextures Tip", "Makes many games slower, but some games a lot faster"), e.v); - return UI::EVENT_CONTINUE; - }); - texSecondary_->SetDisabledPtr(&g_Config.bSoftwareRendering); - // Seems solid, so we hide the setting. /*CheckBox *vtxJit = graphicsSettings->Add(new CheckBox(&g_Config.bVertexDecoderJit, gr->T("Vertex Decoder JIT"))); diff --git a/assets/compat.ini b/assets/compat.ini index 2fbe053168..bfa2165a19 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1240,3 +1240,15 @@ NPJH50366 = true [AllowDownloadCLUT] # Temporary compatibility option, while working on the GPU CLUT-from-framebuffer path. # Not required for any games now that it works, but might be useful for development. + +[SecondaryTextureCache] +# Was previously the "Retain changed textures" setting. +# See https://github.com/hrydgard/ppsspp/issues/16339#issuecomment-1304826656 + +# Popolocrois +UCJS10005 = true +UCAS40009 = true +ULUS10018 = true +UCJS18003 = true +ULES00291 = true +NPJG00033 = true diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 3716f1989e..ec07b1dc67 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -850,15 +850,6 @@ static void check_variables(CoreParameter &coreParam) g_Config.bTextureBackoffCache = true; } - var.key = "ppsspp_retain_changed_textures"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (!strcmp(var.value, "disabled")) - g_Config.bTextureSecondaryCache = false; - else - g_Config.bTextureSecondaryCache = true; - } - var.key = "ppsspp_spline_quality"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { From ff23d67bf4e346e30ff696e22989a6ba041b5fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 17:33:42 +0100 Subject: [PATCH 358/374] Remove now-unused lang keys --- assets/lang/ar_AE.ini | 2 -- assets/lang/az_AZ.ini | 2 -- assets/lang/bg_BG.ini | 2 -- assets/lang/ca_ES.ini | 2 -- assets/lang/cz_CZ.ini | 2 -- assets/lang/da_DK.ini | 2 -- assets/lang/de_DE.ini | 2 -- assets/lang/dr_ID.ini | 2 -- assets/lang/es_ES.ini | 2 -- assets/lang/es_LA.ini | 2 -- assets/lang/fa_IR.ini | 2 -- assets/lang/fi_FI.ini | 2 -- assets/lang/fr_FR.ini | 2 -- assets/lang/gl_ES.ini | 2 -- assets/lang/gr_EL.ini | 2 -- assets/lang/he_IL.ini | 2 -- assets/lang/he_IL_invert.ini | 2 -- assets/lang/hr_HR.ini | 2 -- assets/lang/hu_HU.ini | 2 -- assets/lang/id_ID.ini | 2 -- assets/lang/it_IT.ini | 2 -- assets/lang/ja_JP.ini | 2 -- assets/lang/jv_ID.ini | 2 -- assets/lang/ko_KR.ini | 2 -- assets/lang/lo_LA.ini | 2 -- assets/lang/lt-LT.ini | 2 -- assets/lang/ms_MY.ini | 2 -- assets/lang/nl_NL.ini | 2 -- assets/lang/no_NO.ini | 2 -- assets/lang/pl_PL.ini | 2 -- assets/lang/pt_BR.ini | 2 -- assets/lang/pt_PT.ini | 2 -- assets/lang/ro_RO.ini | 2 -- assets/lang/ru_RU.ini | 2 -- assets/lang/sv_SE.ini | 2 -- assets/lang/tg_PH.ini | 2 -- assets/lang/th_TH.ini | 2 -- assets/lang/tr_TR.ini | 2 -- assets/lang/uk_UA.ini | 2 -- assets/lang/vi_VN.ini | 2 -- assets/lang/zh_CN.ini | 2 -- assets/lang/zh_TW.ini | 2 -- 42 files changed, 84 deletions(-) diff --git a/assets/lang/ar_AE.ini b/assets/lang/ar_AE.ini index 20d525747b..6987e7b3c7 100644 --- a/assets/lang/ar_AE.ini +++ b/assets/lang/ar_AE.ini @@ -550,8 +550,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = ‎وضع التصيير Rendering Resolution = ‎حجم التصيير RenderingMode NonBuffered Tip = ‎أسرع, لكن يمكن أن لا يظهر أي شئ في بعض الألعاب -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = ‎يجعل ألعاب كثيرة بطيئة, لكن بعض الألعاب أسرع Rotation = ‎الدوران Safe = ‎أمن Screen layout = Screen layout diff --git a/assets/lang/az_AZ.ini b/assets/lang/az_AZ.ini index 26b022eb25..581e08ca3a 100644 --- a/assets/lang/az_AZ.ini +++ b/assets/lang/az_AZ.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering mode Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/bg_BG.ini b/assets/lang/bg_BG.ini index 1c2ba43a4e..e8b2d60613 100644 --- a/assets/lang/bg_BG.ini +++ b/assets/lang/bg_BG.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering mode Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/ca_ES.ini b/assets/lang/ca_ES.ini index 1f823575e8..dc018c04b4 100644 --- a/assets/lang/ca_ES.ini +++ b/assets/lang/ca_ES.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering mode Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/cz_CZ.ini b/assets/lang/cz_CZ.ini index 6682c46ee5..c190a4e884 100644 --- a/assets/lang/cz_CZ.ini +++ b/assets/lang/cz_CZ.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Režim vykreslování Rendering Resolution = Rozlišení vykreslování RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Zachovat změněné textury (někdy pomalejší) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Otočení Safe = Bezpečné Screen layout = Screen layout diff --git a/assets/lang/da_DK.ini b/assets/lang/da_DK.ini index 406dee1abd..de5366d8f5 100644 --- a/assets/lang/da_DK.ini +++ b/assets/lang/da_DK.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering tilstand Rendering Resolution = Render opløsning RenderingMode NonBuffered Tip = Hurtigere, men intet vises i nogle spil -Retain changed textures = Behold ændrede textures (nogle gange langsommere) -RetainChangedTextures Tip = Gør mange spil langsommere, men nogle spil er meget hurtigere Rotation = Rotation Safe = Sikker Screen layout = Screen layout diff --git a/assets/lang/de_DE.ini b/assets/lang/de_DE.ini index 0903a464a1..a5129d922e 100644 --- a/assets/lang/de_DE.ini +++ b/assets/lang/de_DE.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Kann Framerate smoother in Spielen machen, die eine Rendering Mode = Rendermodus Rendering Resolution = Renderauflösung RenderingMode NonBuffered Tip = Schneller, aber keine Anzeige in einigen Spielen -Retain changed textures = Veränderte Texturen behalten (manchmal langsamer) -RetainChangedTextures Tip = Macht viele Spiele langsamer, aber einige andere umso schneller Rotation = Drehung Safe = Sicher Screen layout = Screen layout diff --git a/assets/lang/dr_ID.ini b/assets/lang/dr_ID.ini index d0176fe3a9..23346118f2 100644 --- a/assets/lang/dr_ID.ini +++ b/assets/lang/dr_ID.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Pa marrender i Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/es_ES.ini b/assets/lang/es_ES.ini index a251e5cbb7..b61201985c 100644 --- a/assets/lang/es_ES.ini +++ b/assets/lang/es_ES.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Puede hacer la imagen más fluida in juegos con una Rendering Mode = Modo de renderizado Rendering Resolution = Resolución de renderizado RenderingMode NonBuffered Tip = Rápido, pero no se verá nada en algunos juegos. -Retain changed textures = Mantener texturas cambiadas -RetainChangedTextures Tip = Hace muchos juegos más lentos, pero unos pocos mucho más rápidos. Rotation = Rotación Safe = Seguro Screen layout = Diseño de pantalla diff --git a/assets/lang/es_LA.ini b/assets/lang/es_LA.ini index 46ad0c39e3..6c7d42d35f 100644 --- a/assets/lang/es_LA.ini +++ b/assets/lang/es_LA.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Puede hacer que la fluidez sea más suave en juegos Rendering Mode = Modo de renderizado Rendering Resolution = Resolución de renderizado RenderingMode NonBuffered Tip = Acelera, pero no podrá generar gráficos en algunos juegos. -Retain changed textures = Mantener texturas cambiadas -RetainChangedTextures Tip = Ralentiza muchos juegos, pero acelera algunos. Rotation = Rotación Safe = Seguro Screen layout = Disposición de pantalla diff --git a/assets/lang/fa_IR.ini b/assets/lang/fa_IR.ini index 4ea5d675dc..dba054242f 100644 --- a/assets/lang/fa_IR.ini +++ b/assets/lang/fa_IR.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = ‎حالت رندرینگ Rendering Resolution = ‎رزولوشن رندرینگ RenderingMode NonBuffered Tip = ‎سریع تر، اما در بعضی بازی ها ممکن است چیزی نشان ندهد -Retain changed textures = ‎کش کردن تکسچر های تغییر یافته (بعضی مواقع کندتر) -RetainChangedTextures Tip = ‎برای بسیاری از بازی ها کندتر و برای بعضی سریع تر Rotation = ‎چرخش Safe = ‎امن Screen layout = Screen layout diff --git a/assets/lang/fi_FI.ini b/assets/lang/fi_FI.ini index 94dd50c642..8d8aafccb5 100644 --- a/assets/lang/fi_FI.ini +++ b/assets/lang/fi_FI.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering mode Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/fr_FR.ini b/assets/lang/fr_FR.ini index 6c28c420e0..330ded83af 100644 --- a/assets/lang/fr_FR.ini +++ b/assets/lang/fr_FR.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Peut améliorer la fluidité dans les jeux qui fonct Rendering Mode = Mode de rendu Rendering Resolution = Définition du rendu RenderingMode NonBuffered Tip = Plus rapide, mais pour certains jeux rien ne s'affichera -Retain changed textures = Conserver les textures modifiées (seulement certains jeux) -RetainChangedTextures Tip = Ralentit de nombreux jeux, mais beaucoup plus rapide pour quelques autres Rotation = Rotation Safe = Prudent Screen layout = Disposition de l'écran diff --git a/assets/lang/gl_ES.ini b/assets/lang/gl_ES.ini index f644af1246..42c0a81859 100644 --- a/assets/lang/gl_ES.ini +++ b/assets/lang/gl_ES.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Modo de renderizado Rendering Resolution = Resolución de renderizado RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Seguro Screen layout = Screen layout diff --git a/assets/lang/gr_EL.ini b/assets/lang/gr_EL.ini index 51df0a1cd9..3f9555e900 100644 --- a/assets/lang/gr_EL.ini +++ b/assets/lang/gr_EL.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Τρόπος Απεικόνισης Rendering Resolution = Ανάλυση Απεικόνισης RenderingMode NonBuffered Tip = Γρηγορότερο, αλλά σε μερικά αιχνίδια μπορεί να μην εμφανίζει τίποτα -Retain changed textures = Διατηρήστε αλλαγμένων υφών (μερικές φορές αργότερο) -RetainChangedTextures Tip = Κάνει πολλά παιχνίδια πιο αργά, αλλά κάποια άλλα πιο γρήγορα Rotation = Περιστροφή Safe = Ασφαλής Screen layout = Screen layout diff --git a/assets/lang/he_IL.ini b/assets/lang/he_IL.ini index 95cda4cb26..eea8766876 100644 --- a/assets/lang/he_IL.ini +++ b/assets/lang/he_IL.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = מצב מעובד Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/he_IL_invert.ini b/assets/lang/he_IL_invert.ini index ee1ed7aced..81da08b1d1 100644 --- a/assets/lang/he_IL_invert.ini +++ b/assets/lang/he_IL_invert.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = דבועמ בצמ Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/hr_HR.ini b/assets/lang/hr_HR.ini index 8238d63b17..5b212cf395 100644 --- a/assets/lang/hr_HR.ini +++ b/assets/lang/hr_HR.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Izlgađiva frameove u igrama koje ih jako malo imaju Rendering Mode = Način prikaza Rendering Resolution = Rezolucija prikaza RenderingMode NonBuffered Tip = Brže, ali ništa može uvući neke igre -Retain changed textures = Ostavi promijenjene teksture (ponekad sporije) -RetainChangedTextures Tip = Usporava mnogo igara, ali neke igre dosta ubrzava Rotation = Rotacija Safe = Sigurno Screen layout = Screen layout diff --git a/assets/lang/hu_HU.ini b/assets/lang/hu_HU.ini index 13078c4f7f..a18b33795f 100644 --- a/assets/lang/hu_HU.ini +++ b/assets/lang/hu_HU.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Simábbá teheti az alacsonyabb képkocka számon fu Rendering Mode = Renderelés módja Rendering Resolution = Renderelés felbontása RenderingMode NonBuffered Tip = Gyorsabb, de egyes játékokban nem rajzol ki semmit. -Retain changed textures = Változtatott textúrák megtartása (olykor lassabb) -RetainChangedTextures Tip = Egyes játékokat gyorsít, de sok játékot lassít. Rotation = Forgatás Safe = Biztonságos Screen layout = Screen layout diff --git a/assets/lang/id_ID.ini b/assets/lang/id_ID.ini index 00af881bf1..bfc1724aa4 100644 --- a/assets/lang/id_ID.ini +++ b/assets/lang/id_ID.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Dapat membuat laju bingkai lebih lancar dalam permai Rendering Mode = Mode pelukisan Rendering Resolution = Resolusi pelukisan RenderingMode NonBuffered Tip = Lebih cepat, namun mungkin tidak ada gambar di beberapa permainan -Retain changed textures = Tahan tekstur yang berubah (adakalanya lambat) -RetainChangedTextures Tip = Membuat beberapa permainan lambat, namun beberapa lainnya sangat cepat Rotation = Rotasi Safe = Aman Screen layout = Tata letak layar diff --git a/assets/lang/it_IT.ini b/assets/lang/it_IT.ini index e52113462f..10453b2a13 100644 --- a/assets/lang/it_IT.ini +++ b/assets/lang/it_IT.ini @@ -543,8 +543,6 @@ RenderDuplicateFrames Tip = Può migliorare la fluidità nei giochi che funziona Rendering Mode = Modalità di Rendering Rendering Resolution = Rendering della Risoluzione RenderingMode NonBuffered Tip = Veloce, ma potrebbe generare dei glitch in alcuni giochi -Retain changed textures = Conserva le textures modificate (a volte è lento) -RetainChangedTextures Tip = Rallenta molti giochi, ma alcuni saranno velocizzati Rotation = Rotazione Safe = Sicuro Screen layout = Disposizione dello schermo diff --git a/assets/lang/ja_JP.ini b/assets/lang/ja_JP.ini index 10c66c47f1..dfe1a86e3a 100644 --- a/assets/lang/ja_JP.ini +++ b/assets/lang/ja_JP.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = フレームレートが低いゲームでフレー Rendering Mode = レンダリングモード Rendering Resolution = レンダリング解像度 RenderingMode NonBuffered Tip = 高速ですが何も表示されなくなるゲームがあるかもしれません -Retain changed textures = 変更したテクスチャを保持する (低速化する場合がある) -RetainChangedTextures Tip = 多くのゲームが低速化しますが、かなり速くなるゲームもあります Rotation = 向き Safe = セーフ Screen layout = 画面のレイアウト diff --git a/assets/lang/jv_ID.ini b/assets/lang/jv_ID.ini index 016ae0e857..da4130fb2b 100644 --- a/assets/lang/jv_ID.ini +++ b/assets/lang/jv_ID.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Mode Rendering Rendering Resolution = Rendering résolusi RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Makaryakke diganti tekstur (kadhangkala luwih alon) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotasi Safe = Aman Screen layout = Screen layout diff --git a/assets/lang/ko_KR.ini b/assets/lang/ko_KR.ini index d08d55dd14..0cdd1a11e3 100644 --- a/assets/lang/ko_KR.ini +++ b/assets/lang/ko_KR.ini @@ -541,8 +541,6 @@ RenderDuplicateFrames Tip = 낮은 프레임 속도에서 실행되는 게임에 Rendering Mode = 렌더링 모드 Rendering Resolution = 렌더링 해상도 RenderingMode NonBuffered Tip = 더 빠르지만 일부 게임에서는 아무 것도 표현되지 않을 수 있습니다. -Retain changed textures = 변경된 텍스처 유지 (때로는 느림) -RetainChangedTextures Tip = 많은 게임을 느리게 하지만 일부 게임은 훨씬 빠르게 만듭니다. Rotation = 회전 Safe = 안전 Screen layout = 화면 레이아웃 diff --git a/assets/lang/lo_LA.ini b/assets/lang/lo_LA.ini index dad15456b5..1409815abc 100644 --- a/assets/lang/lo_LA.ini +++ b/assets/lang/lo_LA.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = ໂໝດການສະແດງຜົນ Rendering Resolution = ຄວາມລະອຽດຂອງການສະແດງຜົນ RenderingMode NonBuffered Tip = ໄວຂຶ້ນແທ້, ແຕ່ອາດມີອາການຈໍດຳໃນບາງເກມ -Retain changed textures = ຮັກສາການປ່ຽນແປງຂອງພື້ນຜິວ (ຊ້າບາງເທື່ອ) -RetainChangedTextures Tip = ບາງເກມໃຊ້ແລ້ວຄວາມໄວຫຼຸດລົງ ແຕ່ບາງເກມຄວາມໄວກໍເພີ່ມຂຶ້ນ Rotation = ໝຸນຈໍ Safe = ປອດໄພ Screen layout = Screen layout diff --git a/assets/lang/lt-LT.ini b/assets/lang/lt-LT.ini index 917e171242..aff20af2e2 100644 --- a/assets/lang/lt-LT.ini +++ b/assets/lang/lt-LT.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rodymo režimas Rendering Resolution = Rodymo rezoliucija RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/ms_MY.ini b/assets/lang/ms_MY.ini index 5a6687e035..3cd85dd7c4 100644 --- a/assets/lang/ms_MY.ini +++ b/assets/lang/ms_MY.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Mod rendering Rendering Resolution = Resolusi rendering RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/nl_NL.ini b/assets/lang/nl_NL.ini index ad38f550cb..9b8c2cef4a 100644 --- a/assets/lang/nl_NL.ini +++ b/assets/lang/nl_NL.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Weergavemodus Rendering Resolution = Renderresolutie RenderingMode NonBuffered Tip = Sneller, maar mogelijk wordt in sommige games niets gerenderd -Retain changed textures = Gewijzigde textures behouden (soms trager) -RetainChangedTextures Tip = Maakt vele games trager, maar sommige games veel sneller Rotation = Rotatie Safe = Veilig Screen layout = Screen layout diff --git a/assets/lang/no_NO.ini b/assets/lang/no_NO.ini index 70163c25c0..132178a7e6 100644 --- a/assets/lang/no_NO.ini +++ b/assets/lang/no_NO.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering mode Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/pl_PL.ini b/assets/lang/pl_PL.ini index e963535aee..82a63c4757 100644 --- a/assets/lang/pl_PL.ini +++ b/assets/lang/pl_PL.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Tryb renderowania Rendering Resolution = Rozdzielczość renderowania RenderingMode NonBuffered Tip = Szybsze, ale niektóre gry mogą się nie wyświetlać -Retain changed textures = Zachowuj zmienione tekstury (czasem wolniejsze) -RetainChangedTextures Tip = Spowalnia wiele gier, ale mocno przyspiesza kilka innych Rotation = Obrót Safe = Bezpieczne Screen layout = Screen layout diff --git a/assets/lang/pt_BR.ini b/assets/lang/pt_BR.ini index 6d5b63cdcf..952c540f0b 100644 --- a/assets/lang/pt_BR.ini +++ b/assets/lang/pt_BR.ini @@ -565,8 +565,6 @@ RenderDuplicateFrames Tip = Pode tornar a taxa dos frames mais suave em jogos qu Rendering Mode = Modo de renderização Rendering Resolution = Resolução da renderização RenderingMode NonBuffered Tip = Mais rápido, mas nada pode ser desenhado em alguns jogos -Retain changed textures = Reter texturas mudadas (as vezes mais lento) -RetainChangedTextures Tip = Torna muitos jogos mais lentos mas alguns jogos muito mais rápidos Rotation = Rotação Safe = Seguro Screen layout = Esquema da tela diff --git a/assets/lang/pt_PT.ini b/assets/lang/pt_PT.ini index b50d6f0d95..3027a3c81e 100644 --- a/assets/lang/pt_PT.ini +++ b/assets/lang/pt_PT.ini @@ -565,8 +565,6 @@ RenderDuplicateFrames Tip = Pode tornar a taxa dos quadros mais suave em jogos q Rendering Mode = Modo de renderização Rendering Resolution = Resolução da renderização RenderingMode NonBuffered Tip = Mais rápido, mas poderá não ser desenhado nada em alguns jogos -Retain changed textures = Reter texturas mudadas (as vezes mais lento) -RetainChangedTextures Tip = Torna muitos jogos mais lentos mas alguns jogos muito mais rápidos Rotation = Rotação Safe = Seguro Screen layout = Esquema da tela diff --git a/assets/lang/ro_RO.ini b/assets/lang/ro_RO.ini index 0ec247f441..055ff8f9ff 100644 --- a/assets/lang/ro_RO.ini +++ b/assets/lang/ro_RO.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Mod Afișare Rendering Resolution = Rezoluție Afișare RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Sigur Screen layout = Screen layout diff --git a/assets/lang/ru_RU.ini b/assets/lang/ru_RU.ini index 35b73386d5..d3c867b2fe 100644 --- a/assets/lang/ru_RU.ini +++ b/assets/lang/ru_RU.ini @@ -543,8 +543,6 @@ RenderDuplicateFrames Tip = Может сгладить частоту кадр Rendering Mode = Режим рендеринга Rendering Resolution = Разрешение рендеринга RenderingMode NonBuffered Tip = Быстрее, но ничего не отображает в некоторых играх -Retain changed textures = Сохранять измененные текстуры (иногда медленнее) -RetainChangedTextures Tip = Делает много игр медленнее, но некоторые - намного быстрее Rotation = Ориентация Safe = Безопасно Screen layout = Расположение экрана diff --git a/assets/lang/sv_SE.ini b/assets/lang/sv_SE.ini index fbacbb1219..d4bedc6d5f 100644 --- a/assets/lang/sv_SE.ini +++ b/assets/lang/sv_SE.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Renderingsläge Rendering Resolution = Renderingsupplösning RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Behåll ändrade texturer i cachen (ibland långsammare) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/tg_PH.ini b/assets/lang/tg_PH.ini index 5afd25561b..1dca37dcc5 100644 --- a/assets/lang/tg_PH.ini +++ b/assets/lang/tg_PH.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Uri ng Rendering Rendering Resolution = Resolusyon ng rendering RenderingMode NonBuffered Tip = Mabilis, pero minsan wala kang makikita sa laro, blanko -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotasyon Safe = Safe Screen layout = Screen layout diff --git a/assets/lang/th_TH.ini b/assets/lang/th_TH.ini index c63fa3125b..6cdb15874c 100644 --- a/assets/lang/th_TH.ini +++ b/assets/lang/th_TH.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = ช่วยให้ภาพดูลื่นต Rendering Mode = โหมดที่ใช้ในการแสดงผล Rendering Resolution = ความละเอียดในการแสดงผลภาพ RenderingMode NonBuffered Tip = เร็วขึ้นก็จริง แต่มีผลข้างเคียงในบางเกมอาจเกิดอาการจอดำ -Retain changed textures = รักษาความเปลี่ยนแปลงของพื้นผิว (ช้าลงในบางครั้ง) -RetainChangedTextures Tip = มีหลายเกมที่ปรับใช้แล้วความเร็วตกลง แต่ในบางเกมความเร็วก็เพิ่มขึ้น Rotation = หมุนจอ Safe = ปลอดภัย Screen layout = เค้าโครงหน้าจอ diff --git a/assets/lang/tr_TR.ini b/assets/lang/tr_TR.ini index 4af52fed3c..4a98ecfeb9 100644 --- a/assets/lang/tr_TR.ini +++ b/assets/lang/tr_TR.ini @@ -545,8 +545,6 @@ RenderDuplicateFrames Tip = Daha düşük kare hızlarında çalışan oyunlarda Rendering Mode = İşleme modu Rendering Resolution = İşleme çözünürlüğü RenderingMode NonBuffered Tip = Daha hızlıdır, ancak bazı oyunlarda hiçbir şey çizilmeyebilir -Retain changed textures = Değişen dokuları koruyun (bazen daha yavaştır) -RetainChangedTextures Tip = Çoğu oyunu yavaşlatır ama bazı oyunları çok hızlandırır. Rotation = Rotasyon Safe = Güvenli Screen layout = Ekran düzeni diff --git a/assets/lang/uk_UA.ini b/assets/lang/uk_UA.ini index b6ec199493..b4581397ae 100644 --- a/assets/lang/uk_UA.ini +++ b/assets/lang/uk_UA.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Можна зробити більш плавний Rendering Mode = Режим рендерингу Rendering Resolution = Розширення рендерингу RenderingMode NonBuffered Tip = Швидше, але в деяких іграх нічого не може -Retain changed textures = Зберігати змінені текстури (іноді повільніше) -RetainChangedTextures Tip = Багато ігор робить повільніше, але деякі ігри набагато швидшими Rotation = Орієнтація: Safe = Безпечно Screen layout = Screen layout diff --git a/assets/lang/vi_VN.ini b/assets/lang/vi_VN.ini index 40e6bb7b30..c1593c6c33 100644 --- a/assets/lang/vi_VN.ini +++ b/assets/lang/vi_VN.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Chế độ kết xuất Rendering Resolution = Độ phân giải kết xuất RenderingMode NonBuffered Tip = Nhanh hơn, nhưng một số trò chơi thì bị lỗi -Retain changed textures = Giữ lại textures (thỉnh thoảng sẽ bị chậm) -RetainChangedTextures Tip = Làm cho một số trò chơi chậm hơn, nhưng cũng có một số trò chơi nhanh hơn. Rotation = Xoay màn hình Safe = An toàn Screen layout = Screen layout diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index 9ca27412e8..3d2682c3d6 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -542,8 +542,6 @@ RenderDuplicateFrames Tip = 在较低帧率的游戏中可以使帧速率更平 Rendering Mode = 渲染模式 Rendering Resolution = 渲染分辨率 RenderingMode NonBuffered Tip = 更快,但可能在某些游戏中丢失特效 -Retain changed textures = 保留已更改的纹理(有时更慢) -RetainChangedTextures Tip = 使较多游戏减速, 但有些游戏可能变快很多 Rotation = 旋转 Safe = 安全 Screen layout = 屏幕布局 diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index e94959fd9e..7b74b3e4a3 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -541,8 +541,6 @@ RenderDuplicateFrames Tip = 可以使以較低影格速率執行的遊戲更加 Rendering Mode = 轉譯模式 Rendering Resolution = 轉譯解析度 RenderingMode NonBuffered Tip = 更快,但在某些遊戲中可能無法繪圖 -Retain changed textures = 保留變更的紋理 (有時會更慢) -RetainChangedTextures Tip = 使很多遊戲變慢,但某些遊戲會變快許多 Rotation = 旋轉 Safe = 安全 Screen layout = 螢幕版面配置 From 09c0ebd3ca4ba3caba229b1e970174527c4243ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 17:40:33 +0100 Subject: [PATCH 359/374] Windows ARM/ARM64 buildfix --- Common/VR/OpenXRLoader.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Common/VR/OpenXRLoader.h b/Common/VR/OpenXRLoader.h index fa783b7a58..ce6613ec5e 100644 --- a/Common/VR/OpenXRLoader.h +++ b/Common/VR/OpenXRLoader.h @@ -27,8 +27,10 @@ using namespace PPSSPP_VK; #include "Common/CommonWindows.h" #if defined(WINAPI_FAMILY) && defined(WINAPI_FAMILY_PARTITION) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP +#if defined(_M_IX86) || defined(_M_X64) #include "Common/GPU/OpenGL/GLCommon.h" #define XR_USE_GRAPHICS_API_OPENGL 1 +#endif #define XR_USE_PLATFORM_WIN32 1 #endif #endif From 6c36f03a0dc35cccf366363ceaed52b470782835 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Nov 2022 08:40:54 -0800 Subject: [PATCH 360/374] GPU: Purify vertTypeIsSkinningEnabled(). --- GPU/Common/DrawEngineCommon.cpp | 8 +++----- GPU/Common/DrawEngineCommon.h | 2 +- GPU/Common/ShaderId.cpp | 4 ++-- GPU/Common/ShaderId.h | 2 +- GPU/Common/SoftwareTransformCommon.cpp | 2 +- GPU/D3D11/DrawEngineD3D11.cpp | 10 +++++----- GPU/D3D11/DrawEngineD3D11.h | 2 +- GPU/D3D11/GPU_D3D11.cpp | 2 +- GPU/D3D11/ShaderManagerD3D11.cpp | 4 ++-- GPU/D3D11/ShaderManagerD3D11.h | 2 +- GPU/Directx9/DrawEngineDX9.cpp | 6 +++--- GPU/Directx9/GPU_DX9.cpp | 4 ++-- GPU/Directx9/ShaderManagerDX9.cpp | 6 +++--- GPU/Directx9/ShaderManagerDX9.h | 2 +- GPU/GLES/DrawEngineGLES.cpp | 4 ++-- GPU/GLES/GPU_GLES.cpp | 4 ++-- GPU/GLES/ShaderManagerGLES.cpp | 6 +++--- GPU/GLES/ShaderManagerGLES.h | 2 +- GPU/GPUState.cpp | 5 +---- GPU/Software/TransformUnit.cpp | 2 +- GPU/Vulkan/DrawEngineVulkan.cpp | 8 ++++---- GPU/Vulkan/GPU_Vulkan.cpp | 2 +- GPU/Vulkan/ShaderManagerVulkan.cpp | 4 ++-- GPU/Vulkan/ShaderManagerVulkan.h | 2 +- 24 files changed, 45 insertions(+), 50 deletions(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index b1f4ca7049..e02da46179 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -52,9 +52,7 @@ DrawEngineCommon::~DrawEngineCommon() { } void DrawEngineCommon::Init() { - useHWTransform_ = g_Config.bHardwareTransform; - useHWTessellation_ = UpdateUseHWTessellation(g_Config.bHardwareTessellation); - decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; + NotifyConfigChanged(); } VertexDecoder *DrawEngineCommon::GetVertexDecoder(u32 vtype) { @@ -170,7 +168,7 @@ static Vec3f ScreenToDrawing(const Vec3f& coords) { return ret; } -void DrawEngineCommon::Resized() { +void DrawEngineCommon::NotifyConfigChanged() { decJitCache_->Clear(); lastVType_ = -1; dec_ = nullptr; @@ -838,7 +836,7 @@ void DrawEngineCommon::SubmitPrim(const void *verts, const void *inds, GEPrimiti numDrawCalls++; vertexCountInDrawCalls_ += vertexCount; - if (g_Config.bSoftwareSkinning && (vertTypeID & GE_VTYPE_WEIGHT_MASK)) { + if (decOptions_.applySkinInDecode && (vertTypeID & GE_VTYPE_WEIGHT_MASK)) { DecodeVertsStep(decoded, decodeCounter_, decodedVerts_); decodeCounter_++; } diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index c0125b28b2..4b62f48c14 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -105,7 +105,7 @@ public: std::vector DebugGetVertexLoaderIDs(); std::string DebugGetVertexLoaderString(std::string id, DebugShaderStringType stringType); - virtual void Resized(); + virtual void NotifyConfigChanged(); bool IsCodePtrVertexDecoder(const u8 *ptr) const { return decJitCache_->IsInSpace(ptr); diff --git a/GPU/Common/ShaderId.cpp b/GPU/Common/ShaderId.cpp index aee52476cf..0f034c7709 100644 --- a/GPU/Common/ShaderId.cpp +++ b/GPU/Common/ShaderId.cpp @@ -67,7 +67,7 @@ std::string VertexShaderDesc(const VShaderID &id) { return desc.str(); } -void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat) { +void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat, bool useSkinInDecode) { bool isModeThrough = (vertType & GE_VTYPE_THROUGH) != 0; bool doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear(); bool doShadeMapping = doTexture && (gstate.getUVGenMode() == GE_TEXMAP_ENVIRONMENT_MAP); @@ -118,7 +118,7 @@ void ComputeVertexShaderID(VShaderID *id_out, u32 vertType, bool useHWTransform, } // Bones. - bool enableBones = vertTypeIsSkinningEnabled(vertType); + bool enableBones = !useSkinInDecode && vertTypeIsSkinningEnabled(vertType); id.SetBit(VS_BIT_ENABLE_BONES, enableBones); if (enableBones) { id.SetBits(VS_BIT_BONES, 3, TranslateNumBones(vertTypeGetNumBoneWeights(vertType)) - 1); diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index effe330763..06b252d87d 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -275,7 +275,7 @@ namespace Draw { class Bugs; } -void ComputeVertexShaderID(VShaderID *id, uint32_t vertexType, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat); +void ComputeVertexShaderID(VShaderID *id, uint32_t vertexType, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat, bool useSkinInDecode); // Generates a compact string that describes the shader. Useful in a list to get an overview // of the current flora of shaders. std::string VertexShaderDesc(const VShaderID &id); diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 0f841d1709..dc86e9ec13 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -204,7 +204,7 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt vscale /= gstate_c.curTextureHeight; } - bool skinningEnabled = vertTypeIsSkinningEnabled(vertType); + bool skinningEnabled = vertTypeIsSkinningEnabled(vertType) && !g_Config.bSoftwareSkinning; const int w = gstate.getTextureWidth(0); const int h = gstate.getTextureHeight(0); diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index c5c4669ba9..2a537a83a3 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -130,8 +130,8 @@ void DrawEngineD3D11::ClearInputLayoutMap() { inputLayoutMap_.Clear(); } -void DrawEngineD3D11::Resized() { - DrawEngineCommon::Resized(); +void DrawEngineD3D11::NotifyConfigChanged() { + DrawEngineCommon::NotifyConfigChanged(); ClearInputLayoutMap(); } @@ -365,7 +365,7 @@ void DrawEngineD3D11::DoFlush() { // Cannot cache vertex data with morph enabled. bool useCache = g_Config.bVertexCache && !(lastVType_ & GE_VTYPE_MORPHCOUNT_MASK); // Also avoid caching when software skinning. - if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) + if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) useCache = false; if (useCache) { @@ -538,7 +538,7 @@ rotateVBO: D3D11VertexShader *vshader; D3D11FragmentShader *fshader; - shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, pipelineState_, useHWTransform, useHWTessellation_, decOptions_.expandAllWeightsToFloat); + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, pipelineState_, useHWTransform, useHWTessellation_, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode); ID3D11InputLayout *inputLayout = SetupDecFmtForDraw(vshader, dec_->GetDecVtxFmt(), dec_->VertexType()); context_->PSSetShader(fshader->GetShader(), nullptr, 0); context_->VSSetShader(vshader->GetShader(), nullptr, 0); @@ -648,7 +648,7 @@ rotateVBO: if (result.action == SW_DRAW_PRIMITIVES) { D3D11VertexShader *vshader; D3D11FragmentShader *fshader; - shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat); + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode); context_->PSSetShader(fshader->GetShader(), nullptr, 0); context_->VSSetShader(vshader->GetShader(), nullptr, 0); shaderManager_->UpdateUniforms(framebufferManager_->UseBufferedRendering()); diff --git a/GPU/D3D11/DrawEngineD3D11.h b/GPU/D3D11/DrawEngineD3D11.h index ca7fb04dbb..03f5f47ad7 100644 --- a/GPU/D3D11/DrawEngineD3D11.h +++ b/GPU/D3D11/DrawEngineD3D11.h @@ -150,7 +150,7 @@ public: void ClearTrackedVertexArrays() override; - void Resized() override; + void NotifyConfigChanged() override; void ClearInputLayoutMap(); diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index 19155b0df5..d1c5edcce3 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -176,7 +176,7 @@ void GPU_D3D11::BeginHostFrame() { if (resized_) { gstate_c.useFlags = CheckGPUFeatures(); framebufferManager_->Resized(); - drawEngine_.Resized(); + drawEngine_.NotifyConfigChanged(); textureCache_->NotifyConfigChanged(); shaderManagerD3D11_->DirtyLastShader(); resized_ = false; diff --git a/GPU/D3D11/ShaderManagerD3D11.cpp b/GPU/D3D11/ShaderManagerD3D11.cpp index 0c9fec1817..f8788f6df5 100644 --- a/GPU/D3D11/ShaderManagerD3D11.cpp +++ b/GPU/D3D11/ShaderManagerD3D11.cpp @@ -179,13 +179,13 @@ void ShaderManagerD3D11::BindUniforms() { context_->PSSetConstantBuffers(0, 1, ps_cbs); } -void ShaderManagerD3D11::GetShaders(int prim, u32 vertType, D3D11VertexShader **vshader, D3D11FragmentShader **fshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat) { +void ShaderManagerD3D11::GetShaders(int prim, u32 vertType, D3D11VertexShader **vshader, D3D11FragmentShader **fshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat, bool useSkinInDecode) { VShaderID VSID; FShaderID FSID; if (gstate_c.IsDirty(DIRTY_VERTEXSHADER_STATE)) { gstate_c.Clean(DIRTY_VERTEXSHADER_STATE); - ComputeVertexShaderID(&VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat); + ComputeVertexShaderID(&VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat, useSkinInDecode); } else { VSID = lastVSID_; } diff --git a/GPU/D3D11/ShaderManagerD3D11.h b/GPU/D3D11/ShaderManagerD3D11.h index 0f7a297965..d239daff8f 100644 --- a/GPU/D3D11/ShaderManagerD3D11.h +++ b/GPU/D3D11/ShaderManagerD3D11.h @@ -85,7 +85,7 @@ public: ShaderManagerD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context, D3D_FEATURE_LEVEL featureLevel); ~ShaderManagerD3D11(); - void GetShaders(int prim, u32 vertType, D3D11VertexShader **vshader, D3D11FragmentShader **fshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat); + void GetShaders(int prim, u32 vertType, D3D11VertexShader **vshader, D3D11FragmentShader **fshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat, bool useSkinInDecode); void ClearShaders(); void DirtyLastShader() override; diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 8d0bac74ea..40790c1648 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -349,7 +349,7 @@ void DrawEngineDX9::DoFlush() { // Cannot cache vertex data with morph enabled. bool useCache = g_Config.bVertexCache && !(lastVType_ & GE_VTYPE_MORPHCOUNT_MASK); // Also avoid caching when software skinning. - if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) + if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) useCache = false; if (useCache) { @@ -522,7 +522,7 @@ rotateVBO: ApplyDrawState(prim); ApplyDrawStateLate(); - VSShader *vshader = shaderManager_->ApplyShader(true, useHWTessellation_, lastVType_, decOptions_.expandAllWeightsToFloat, pipelineState_); + VSShader *vshader = shaderManager_->ApplyShader(true, useHWTessellation_, lastVType_, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode, pipelineState_); IDirect3DVertexDeclaration9 *pHardwareVertexDecl = SetupDecFmtForDraw(vshader, dec_->GetDecVtxFmt(), dec_->VertexType()); if (pHardwareVertexDecl) { @@ -613,7 +613,7 @@ rotateVBO: ApplyDrawStateLate(); - VSShader *vshader = shaderManager_->ApplyShader(false, false, lastVType_, decOptions_.expandAllWeightsToFloat, pipelineState_); + VSShader *vshader = shaderManager_->ApplyShader(false, false, lastVType_, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode, pipelineState_); if (result.action == SW_DRAW_PRIMITIVES) { if (result.setStencil) { diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 32d9d248c4..beb701796a 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -165,9 +165,9 @@ void GPU_DX9::BeginHostFrame() { if (resized_) { gstate_c.useFlags = CheckGPUFeatures(); framebufferManager_->Resized(); - drawEngine_.Resized(); - shaderManagerDX9_->DirtyShader(); + drawEngine_.NotifyConfigChanged(); textureCache_->NotifyConfigChanged(); + shaderManagerDX9_->DirtyShader(); resized_ = false; } } diff --git a/GPU/Directx9/ShaderManagerDX9.cpp b/GPU/Directx9/ShaderManagerDX9.cpp index 1e56e5ab37..0b419cfe76 100644 --- a/GPU/Directx9/ShaderManagerDX9.cpp +++ b/GPU/Directx9/ShaderManagerDX9.cpp @@ -544,11 +544,11 @@ void ShaderManagerDX9::DirtyLastShader() { // disables vertex arrays lastPShader_ = nullptr; } -VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, const ComputedPipelineState &pipelineState) { +VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, bool useSkinInDecode, const ComputedPipelineState &pipelineState) { VShaderID VSID; if (gstate_c.IsDirty(DIRTY_VERTEXSHADER_STATE)) { gstate_c.Clean(DIRTY_VERTEXSHADER_STATE); - ComputeVertexShaderID(&VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat); + ComputeVertexShaderID(&VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat, useSkinInDecode); } else { VSID = lastVSID_; } @@ -597,7 +597,7 @@ VSShader *ShaderManagerDX9::ApplyShader(bool useHWTransform, bool useHWTessellat } delete vs; - ComputeVertexShaderID(&VSID, vertType, false, false, weightsAsFloat); + ComputeVertexShaderID(&VSID, vertType, false, false, weightsAsFloat, useSkinInDecode); // TODO: Look for existing shader with the appropriate ID, use that instead of generating a new one - however, need to make sure // that that shader ID is not used when computing the linked shader ID below, because then IDs won't match diff --git a/GPU/Directx9/ShaderManagerDX9.h b/GPU/Directx9/ShaderManagerDX9.h index 9c7404d856..6ee812b2e6 100644 --- a/GPU/Directx9/ShaderManagerDX9.h +++ b/GPU/Directx9/ShaderManagerDX9.h @@ -78,7 +78,7 @@ public: ~ShaderManagerDX9(); void ClearCache(bool deleteThem); // TODO: deleteThem currently not respected - VSShader *ApplyShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, const ComputedPipelineState &pipelineState); + VSShader *ApplyShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, bool useSkinInDecode, const ComputedPipelineState &pipelineState); void DirtyShader(); void DirtyLastShader() override; diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index dd3395abd2..318cb19a02 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -267,7 +267,7 @@ void DrawEngineGLES::DoFlush() { GEPrimitiveType prim = prevPrim_; VShaderID vsid; - Shader *vshader = shaderManager_->ApplyVertexShader(CanUseHardwareTransform(prim), useHWTessellation_, lastVType_, decOptions_.expandAllWeightsToFloat, &vsid); + Shader *vshader = shaderManager_->ApplyVertexShader(CanUseHardwareTransform(prim), useHWTessellation_, lastVType_, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode, &vsid); GLRBuffer *vertexBuffer = nullptr; GLRBuffer *indexBuffer = nullptr; @@ -278,7 +278,7 @@ void DrawEngineGLES::DoFlush() { int vertexCount = 0; bool useElements = true; - if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { + if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { // If software skinning, we've already predecoded into "decoded". So push that content. size_t size = decodedVerts_ * dec_->GetDecVtxFmt().stride; u8 *dest = (u8 *)frameData.pushVertex->Push(size, &vertexBufferOffset, &vertexBuffer); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index b6b2b6a661..1798960b4d 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -291,9 +291,9 @@ void GPU_GLES::BeginHostFrame() { if (resized_) { gstate_c.useFlags = CheckGPUFeatures(); framebufferManager_->Resized(); - drawEngine_.Resized(); - shaderManagerGL_->DirtyShader(); + drawEngine_.NotifyConfigChanged(); textureCache_->NotifyConfigChanged(); + shaderManagerGL_->DirtyShader(); resized_ = false; } diff --git a/GPU/GLES/ShaderManagerGLES.cpp b/GPU/GLES/ShaderManagerGLES.cpp index e4a6350de1..c976e79b5c 100644 --- a/GPU/GLES/ShaderManagerGLES.cpp +++ b/GPU/GLES/ShaderManagerGLES.cpp @@ -754,10 +754,10 @@ Shader *ShaderManagerGLES::CompileVertexShader(VShaderID VSID) { return new Shader(render_, codeBuffer_, desc, params); } -Shader *ShaderManagerGLES::ApplyVertexShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, VShaderID *VSID) { +Shader *ShaderManagerGLES::ApplyVertexShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, bool useSkinInDecode, VShaderID *VSID) { if (gstate_c.IsDirty(DIRTY_VERTEXSHADER_STATE)) { gstate_c.Clean(DIRTY_VERTEXSHADER_STATE); - ComputeVertexShaderID(VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat); + ComputeVertexShaderID(VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat, useSkinInDecode); } else { *VSID = lastVSID_; } @@ -788,7 +788,7 @@ Shader *ShaderManagerGLES::ApplyVertexShader(bool useHWTransform, bool useHWTess // Can still work with software transform. VShaderID vsidTemp; - ComputeVertexShaderID(&vsidTemp, vertType, false, false, weightsAsFloat); + ComputeVertexShaderID(&vsidTemp, vertType, false, false, weightsAsFloat, useSkinInDecode); vs = CompileVertexShader(vsidTemp); } diff --git a/GPU/GLES/ShaderManagerGLES.h b/GPU/GLES/ShaderManagerGLES.h index a937318dd1..97ffe6c010 100644 --- a/GPU/GLES/ShaderManagerGLES.h +++ b/GPU/GLES/ShaderManagerGLES.h @@ -161,7 +161,7 @@ public: // This is the old ApplyShader split into two parts, because of annoying information dependencies. // If you call ApplyVertexShader, you MUST call ApplyFragmentShader soon afterwards. - Shader *ApplyVertexShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, VShaderID *VSID); + Shader *ApplyVertexShader(bool useHWTransform, bool useHWTessellation, u32 vertType, bool weightsAsFloat, bool useSkinInDecode, VShaderID *VSID); LinkedShader *ApplyFragmentShader(VShaderID VSID, Shader *vs, const ComputedPipelineState &pipelineState, u32 vertType, bool useBufferedRendering); void DeviceLost(); diff --git a/GPU/GPUState.cpp b/GPU/GPUState.cpp index 374816fa76..bae93b34b1 100644 --- a/GPU/GPUState.cpp +++ b/GPU/GPUState.cpp @@ -261,10 +261,7 @@ void GPUgstate::Restore(u32_le *ptr) { } bool vertTypeIsSkinningEnabled(u32 vertType) { - if (g_Config.bSoftwareSkinning) - return false; - else - return ((vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE); + return ((vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE); } struct GPUStateCache_v0 { diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index afd7d15920..731e4078f3 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -257,7 +257,7 @@ void ComputeTransformState(TransformState *state, const VertexReader &vreader) { state->enableLighting = gstate.isLightingEnabled(); state->enableFog = gstate.isFogEnabled(); state->readUV = !gstate.isModeClear() && gstate.isTextureMapEnabled() && vreader.hasUV(); - state->readWeights = vreader.skinningEnabled() && state->enableTransform; + state->readWeights = vreader.skinningEnabled() && state->enableTransform && !g_Config.bSoftwareSkinning; state->negateNormals = gstate.areNormalsReversed(); state->uvGenMode = gstate.getUVGenMode(); diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index f54afee3a9..01c356f34d 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -599,7 +599,7 @@ void DrawEngineVulkan::DoFlush() { // Also avoid caching when software skinning. VkBuffer vbuf = VK_NULL_HANDLE; VkBuffer ibuf = VK_NULL_HANDLE; - if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { + if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { useCache = false; } @@ -739,7 +739,7 @@ void DrawEngineVulkan::DoFlush() { break; } } else { - if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { + if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { // If software skinning, we've already predecoded into "decoded". So push that content. VkDeviceSize size = decodedVerts_ * dec_->GetDecVtxFmt().stride; u8 *dest = (u8 *)frameData.pushVertex->Push(size, &vbOffset, &vbuf); @@ -784,7 +784,7 @@ void DrawEngineVulkan::DoFlush() { VulkanFragmentShader *fshader = nullptr; VulkanGeometryShader *gshader = nullptr; - shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, true, useHWTessellation_, decOptions_.expandAllWeightsToFloat); // usehwtransform + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, true, useHWTessellation_, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode); if (!vshader) { // We're screwed. return; @@ -919,7 +919,7 @@ void DrawEngineVulkan::DoFlush() { VulkanFragmentShader *fshader = nullptr; VulkanGeometryShader *gshader = nullptr; - shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat); // usehwtransform + shaderManager_->GetShaders(prim, lastVType_, &vshader, &fshader, &gshader, pipelineState_, false, false, decOptions_.expandAllWeightsToFloat, decOptions_.applySkinInDecode); _dbg_assert_msg_(!vshader->UseHWTransform(), "Bad vshader"); VulkanPipeline *pipeline = pipelineManager_->GetOrCreatePipeline(renderManager, pipelineLayout_, pipelineKey_, &dec_->decFmt, vshader, fshader, gshader, false, 0); if (!pipeline || !pipeline->pipeline) { diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 12d0328f98..754ef6ffce 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -292,7 +292,7 @@ void GPU_Vulkan::BeginHostFrame() { // In case the GPU changed. BuildReportingInfo(); framebufferManager_->Resized(); - drawEngine_.Resized(); + drawEngine_.NotifyConfigChanged(); textureCache_->NotifyConfigChanged(); resized_ = false; } diff --git a/GPU/Vulkan/ShaderManagerVulkan.cpp b/GPU/Vulkan/ShaderManagerVulkan.cpp index 6356f43e0a..1d478325da 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.cpp +++ b/GPU/Vulkan/ShaderManagerVulkan.cpp @@ -280,11 +280,11 @@ uint64_t ShaderManagerVulkan::UpdateUniforms(bool useBufferedRendering) { return dirty; } -void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, VulkanGeometryShader **gshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat) { +void ShaderManagerVulkan::GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, VulkanGeometryShader **gshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat, bool useSkinInDecode) { VShaderID VSID; if (gstate_c.IsDirty(DIRTY_VERTEXSHADER_STATE)) { gstate_c.Clean(DIRTY_VERTEXSHADER_STATE); - ComputeVertexShaderID(&VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat); + ComputeVertexShaderID(&VSID, vertType, useHWTransform, useHWTessellation, weightsAsFloat, useSkinInDecode); } else { VSID = lastVSID_; } diff --git a/GPU/Vulkan/ShaderManagerVulkan.h b/GPU/Vulkan/ShaderManagerVulkan.h index 88f138d923..8e6ce2636a 100644 --- a/GPU/Vulkan/ShaderManagerVulkan.h +++ b/GPU/Vulkan/ShaderManagerVulkan.h @@ -115,7 +115,7 @@ public: void DeviceLost(); void DeviceRestore(Draw::DrawContext *draw); - void GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, VulkanGeometryShader **gshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat); + void GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, VulkanGeometryShader **gshader, const ComputedPipelineState &pipelineState, bool useHWTransform, bool useHWTessellation, bool weightsAsFloat, bool useSkinInDecode); void ClearShaders(); void DirtyShader(); void DirtyLastShader() override; From 7880eb15c103ec0e95344446f2d4d296f02384e8 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Nov 2022 08:44:22 -0800 Subject: [PATCH 361/374] softgpu: Always use software skinning. There's only software skinning, after all. --- GPU/Common/VertexDecoderCommon.h | 2 -- GPU/Software/TransformUnit.cpp | 34 ++++++++------------------------ GPU/Software/TransformUnit.h | 1 + 3 files changed, 9 insertions(+), 28 deletions(-) diff --git a/GPU/Common/VertexDecoderCommon.h b/GPU/Common/VertexDecoderCommon.h index e4c886cbd4..7c2dcb2cfc 100644 --- a/GPU/Common/VertexDecoderCommon.h +++ b/GPU/Common/VertexDecoderCommon.h @@ -300,8 +300,6 @@ public: bool hasNormal() const { return decFmt_.nrmfmt != 0; } bool hasUV() const { return decFmt_.uvfmt != 0; } bool isThrough() const { return (vtype_ & GE_VTYPE_THROUGH) != 0; } - bool skinningEnabled() const { return vertTypeIsSkinningEnabled(vtype_); } - int numBoneWeights() const { return vertTypeGetNumBoneWeights(vtype_); } void Goto(int index) { data_ = base_ + index * decFmt_.stride; } diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index 731e4078f3..bc1f8679eb 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -62,6 +62,11 @@ SoftwareDrawEngine::~SoftwareDrawEngine() { FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE); } +void SoftwareDrawEngine::NotifyConfigChanged() { + DrawEngineCommon::NotifyConfigChanged(); + decOptions_.applySkinInDecode = true; +} + void SoftwareDrawEngine::DispatchFlush() { transformUnit.Flush("debug"); } @@ -72,7 +77,7 @@ void SoftwareDrawEngine::DispatchSubmitPrim(const void *verts, const void *inds, } void SoftwareDrawEngine::DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex *buffer, int vertexCount, int cullMode, bool continuation) { - uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode(), decOptions_.applySkinInDecode); + uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode(), true); int flipCull = cullMode != gstate.getCullMode() ? 1 : 0; // TODO: For now, just setting all dirty. @@ -137,7 +142,7 @@ void SoftwareDrawEngine::DispatchSubmitImm(GEPrimitiveType prim, TransformedVert } VertexDecoder *SoftwareDrawEngine::FindVertexDecoder(u32 vtype) { - const u32 vertTypeID = GetVertTypeID(vtype, gstate.getUVGenMode(), decOptions_.applySkinInDecode); + const u32 vertTypeID = GetVertTypeID(vtype, gstate.getUVGenMode(), true); return DrawEngineCommon::GetVertexDecoder(vertTypeID); } @@ -245,7 +250,6 @@ struct TransformState { bool enableLighting : 1; bool enableFog : 1; bool readUV : 1; - bool readWeights : 1; bool negateNormals : 1; uint8_t uvGenMode : 2; uint8_t matrixMode : 2; @@ -257,7 +261,6 @@ void ComputeTransformState(TransformState *state, const VertexReader &vreader) { state->enableLighting = gstate.isLightingEnabled(); state->enableFog = gstate.isFogEnabled(); state->readUV = !gstate.isModeClear() && gstate.isTextureMapEnabled() && vreader.hasUV(); - state->readWeights = vreader.skinningEnabled() && state->enableTransform && !g_Config.bSoftwareSkinning; state->negateNormals = gstate.areNormalsReversed(); state->uvGenMode = gstate.getUVGenMode(); @@ -344,27 +347,6 @@ ClipVertexData TransformUnit::ReadVertex(VertexReader &vreader, const TransformS if (state.negateNormals) normal = -normal; - if (state.readWeights) { - float W[8] = { 1.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f }; - vreader.ReadWeights(W); - - Vec3 tmppos(0.f, 0.f, 0.f); - Vec3 tmpnrm(0.f, 0.f, 0.f); - - for (int i = 0; i < vreader.numBoneWeights(); ++i) { - Vec3 step = Vec3ByMatrix43(pos, gstate.boneMatrix + i * 12); - tmppos += step * W[i]; - if (vreader.hasNormal()) { - step = Norm3ByMatrix43(normal, gstate.boneMatrix + i * 12); - tmpnrm += step * W[i]; - } - } - - pos = tmppos; - if (vreader.hasNormal()) - normal = tmpnrm; - } - if (vreader.hasColor0()) { vreader.ReadColor0_8888((u8 *)&vertex.v.color0); } else { @@ -858,7 +840,7 @@ void TransformUnit::SubmitImmVertex(const ClipVertexData &vert, SoftwareDrawEngi break; } - uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode(), g_Config.bSoftwareSkinning); + uint32_t vertTypeID = GetVertTypeID(gstate.vertType | GE_VTYPE_POS_FLOAT, gstate.getUVGenMode(), true); // This now processes the step with shared logic, given the existing data_. isImmDraw_ = true; SubmitPrimitive(nullptr, nullptr, GE_PRIM_KEEP_PREVIOUS, 0, vertTypeID, nullptr, drawEngine); diff --git a/GPU/Software/TransformUnit.h b/GPU/Software/TransformUnit.h index 3c022523d2..a55c824a91 100644 --- a/GPU/Software/TransformUnit.h +++ b/GPU/Software/TransformUnit.h @@ -171,6 +171,7 @@ public: SoftwareDrawEngine(); ~SoftwareDrawEngine(); + void NotifyConfigChanged() override; void DispatchFlush() override; void DispatchSubmitPrim(const void *verts, const void *inds, GEPrimitiveType prim, int vertexCount, u32 vertType, int cullMode, int *bytesRead) override; void DispatchSubmitImm(GEPrimitiveType prim, TransformedVertex *buffer, int vertexCount, int cullMode, bool continuation) override; From 3de2557ecb50aba2ea59e61c4900918a5d99b725 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Nov 2022 08:55:07 -0800 Subject: [PATCH 362/374] GPU: Always skin in decode for software transform. --- GPU/Common/SoftwareTransformCommon.cpp | 81 +++++--------------------- GPU/D3D11/DrawEngineD3D11.cpp | 2 + GPU/Directx9/DrawEngineDX9.cpp | 2 + GPU/GLES/DrawEngineGLES.cpp | 3 + GPU/Vulkan/DrawEngineVulkan.cpp | 3 + 5 files changed, 24 insertions(+), 67 deletions(-) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index dc86e9ec13..67ba97af4c 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -168,29 +168,6 @@ void SoftwareTransform::SetProjMatrix(float mtx[14], bool invertedX, bool invert projMatrix_.translateAndScale(trans, scale); } -static void ReadWeightedNormal(Vec3f &source, VertexReader &reader, u32 vertType, bool skinningEnabled) { - if (reader.hasNormal()) - reader.ReadNrm(source.AsArray()); - if (skinningEnabled) { - float weights[8]; - reader.ReadWeights(weights); - - // Have to recalculate this, unfortunately. Please use software skinning... - Vec3f nsum(0, 0, 0); - for (int i = 0; i < vertTypeGetNumBoneWeights(vertType); i++) { - if (weights[i] != 0.0f) { - Vec3f norm; - Norm3ByMatrix43(norm.AsArray(), source.AsArray(), gstate.boneMatrix + i * 12); - nsum += norm * weights[i]; - } - } - - source = nsum; - } - if (gstate.areNormalsReversed()) - source = -source; -} - void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVtxFormat, int maxIndex, SoftwareTransformResult *result) { u8 *decoded = params_.decoded; TransformedVertex *transformed = params_.transformed; @@ -204,8 +181,6 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt vscale /= gstate_c.curTextureHeight; } - bool skinningEnabled = vertTypeIsSkinningEnabled(vertType) && !g_Config.bSoftwareSkinning; - const int w = gstate.getTextureWidth(0); const int h = gstate.getTextureHeight(0); float widthFactor = (float) w / (float) gstate_c.curTextureWidth; @@ -296,47 +271,13 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt if (reader.hasNormal()) reader.ReadNrm(normal.AsArray()); - if (!skinningEnabled) { - Vec3ByMatrix43(out, pos, gstate.worldMatrix); - if (reader.hasNormal()) { - if (gstate.areNormalsReversed()) { - normal = -normal; - } - Norm3ByMatrix43(worldnormal.AsArray(), normal.AsArray(), gstate.worldMatrix); - worldnormal = worldnormal.NormalizedOr001(cpu_info.bSSE4_1); - } - } else { - float weights[8]; - // For flat, we need the vertex weights. - reader.Goto(index); - reader.ReadWeights(weights); - - // Skinning - Vec3f psum(0, 0, 0); - Vec3f nsum(0, 0, 0); - for (int i = 0; i < vertTypeGetNumBoneWeights(vertType); i++) { - if (weights[i] != 0.0f) { - Vec3ByMatrix43(out, pos, gstate.boneMatrix+i*12); - Vec3f tpos(out); - psum += tpos * weights[i]; - if (reader.hasNormal()) { - Vec3f norm; - Norm3ByMatrix43(norm.AsArray(), normal.AsArray(), gstate.boneMatrix+i*12); - nsum += norm * weights[i]; - } - } - } - - // Yes, we really must multiply by the world matrix too. - Vec3ByMatrix43(out, psum.AsArray(), gstate.worldMatrix); - if (reader.hasNormal()) { - normal = nsum; - if (gstate.areNormalsReversed()) { - normal = -normal; - } - Norm3ByMatrix43(worldnormal.AsArray(), normal.AsArray(), gstate.worldMatrix); - worldnormal = worldnormal.NormalizedOr001(cpu_info.bSSE4_1); + Vec3ByMatrix43(out, pos, gstate.worldMatrix); + if (reader.hasNormal()) { + if (gstate.areNormalsReversed()) { + normal = -normal; } + Norm3ByMatrix43(worldnormal.AsArray(), normal.AsArray(), gstate.worldMatrix); + worldnormal = worldnormal.NormalizedOr001(cpu_info.bSSE4_1); } // Perform lighting here if enabled. @@ -398,7 +339,10 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt source = normal.Normalized(cpu_info.bSSE4_1); } else { reader.Goto(index); - ReadWeightedNormal(source, reader, vertType, skinningEnabled); + if (reader.hasNormal()) + reader.ReadNrm(source.AsArray()); + if (gstate.areNormalsReversed()) + source = -source; source.Normalize(); } if (!reader.hasNormal()) { @@ -413,7 +357,10 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt } else { // Need to read the normal for this vertex and weight it again.. reader.Goto(index); - ReadWeightedNormal(source, reader, vertType, skinningEnabled); + if (reader.hasNormal()) + reader.ReadNrm(source.AsArray()); + if (gstate.areNormalsReversed()) + source = -source; } if (!reader.hasNormal()) { ERROR_LOG_REPORT(G3D, "Normal projection mapping without normal?"); diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 2a537a83a3..e0c33e5d76 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -581,6 +581,7 @@ rotateVBO: } } else { PROFILE_THIS_SCOPE("soft"); + decOptions_.applySkinInDecode = true; DecodeVerts(decoded); bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE; if (gstate.isModeThrough()) { @@ -709,6 +710,7 @@ rotateVBO: framebufferManager_->ApplyClearToMemory(scissorX1, scissorY1, scissorX2, scissorY2, clearColor); } } + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } gpuStats.numDrawCalls += numDrawCalls; diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 40790c1648..33117be1c9 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -546,6 +546,7 @@ rotateVBO: } } } else { + decOptions_.applySkinInDecode = true; DecodeVerts(decoded); bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE; if (gstate.isModeThrough()) { @@ -653,6 +654,7 @@ rotateVBO: framebufferManager_->ApplyClearToMemory(scissorX1, scissorY1, scissorX2, scissorY2, clearColor); } } + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } gpuStats.numDrawCalls += numDrawCalls; diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 318cb19a02..e95afe57ed 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -331,7 +331,9 @@ void DrawEngineGLES::DoFlush() { } } else { PROFILE_THIS_SCOPE("soft"); + decOptions_.applySkinInDecode = true; DecodeVerts(decoded); + bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE; if (gstate.isModeThrough()) { gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && (hasColor || gstate.getMaterialAmbientA() == 255); @@ -446,6 +448,7 @@ void DrawEngineGLES::DoFlush() { } gstate_c.Dirty(DIRTY_BLEND_STATE); // Make sure the color mask gets re-applied. } + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } gpuStats.numDrawCalls += numDrawCalls; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index 01c356f34d..d8c8b740e5 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -841,6 +841,7 @@ void DrawEngineVulkan::DoFlush() { } } else { PROFILE_THIS_SCOPE("soft"); + decOptions_.applySkinInDecode = true; DecodeVerts(decoded); bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE; if (gstate.isModeThrough()) { @@ -927,6 +928,7 @@ void DrawEngineVulkan::DoFlush() { decodedVerts_ = 0; numDrawCalls = 0; decodeCounter_ = 0; + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; return; } BindShaderBlendTex(); // This might cause copies so super important to do before BindPipeline. @@ -994,6 +996,7 @@ void DrawEngineVulkan::DoFlush() { framebufferManager_->ApplyClearToMemory(scissorX1, scissorY1, scissorX2, scissorY2, result.color); } } + decOptions_.applySkinInDecode = g_Config.bSoftwareSkinning; } gpuStats.numDrawCalls += numDrawCalls; From 527947fd81c09804606b867677ab590d24d2f391 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 6 Nov 2022 09:06:07 -0800 Subject: [PATCH 363/374] GPU: Correct softgpu curve issue. --- GPU/Common/DrawEngineCommon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/DrawEngineCommon.cpp b/GPU/Common/DrawEngineCommon.cpp index e02da46179..664b90823e 100644 --- a/GPU/Common/DrawEngineCommon.cpp +++ b/GPU/Common/DrawEngineCommon.cpp @@ -514,7 +514,7 @@ u32 DrawEngineCommon::NormalizeVertices(u8 *outPtr, u8 *bufPtr, const u8 *inPtr, }; // Let's have two separate loops, one for non skinning and one for skinning. - if (!g_Config.bSoftwareSkinning && (vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE) { + if (!dec->skinInDecode && (vertType & GE_VTYPE_WEIGHT_MASK) != GE_VTYPE_WEIGHT_NONE) { int numBoneWeights = vertTypeGetNumBoneWeights(vertType); for (int i = lowerBound; i <= upperBound; i++) { reader.Goto(i - lowerBound); From 200c055823eb0b5be608fd28fbb1929d495dc24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 18:55:45 +0100 Subject: [PATCH 364/374] libretro fix, more games --- assets/compat.ini | 12 ++++++++++++ libretro/libretro_core_options.h | 10 ---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/assets/compat.ini b/assets/compat.ini index bfa2165a19..7a1ac5d79f 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1252,3 +1252,15 @@ ULUS10018 = true UCJS18003 = true ULES00291 = true NPJG00033 = true + +# Fushigi no Dungeon: Fuurai no Shiren 4 Plus - Kami no Hitomi to Akuma no Heso +ULJS00547 = true +NPJH50698 = true + +# Final Fantasy Tactics +UCAS40148 = true +ULJM05194 = true +ULES00850 = true +ULUS10297 = true +ULJM05516 = true +NPJH50408 = true diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h index 78cab61d7d..0ca87d8bce 100644 --- a/libretro/libretro_core_options.h +++ b/libretro/libretro_core_options.h @@ -427,16 +427,6 @@ struct retro_core_option_v2_definition option_defs_us[] = { BOOL_OPTIONS, "disabled" }, - { - "ppsspp_retain_changed_textures", - "Retain Changed Textures (Speedup, mem hog)", - NULL, - "Makes many games slower, but some games a lot faster.", - NULL, - "video", - BOOL_OPTIONS, - "disabled" - }, { "ppsspp_spline_quality", "Spline/Bezier Curves Quality", From 519db766b6a251d8d8032236c401babf29e82553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 19:20:10 +0100 Subject: [PATCH 365/374] Change "Rendering Mode" to just a "Skip buffer effects" checkbox. Reuse translations. --- Core/Config.cpp | 11 +++--- Core/Config.h | 6 ++-- Core/HLE/sceDisplay.cpp | 6 ++-- GPU/Common/FramebufferManagerCommon.cpp | 6 ++-- UI/DisplayLayoutScreen.cpp | 4 +-- UI/EmuScreen.cpp | 4 +-- UI/GameSettingsScreen.cpp | 46 ++++++++----------------- Windows/MainWindowMenu.cpp | 41 ++++++---------------- Windows/ppsspp.rc | 7 ++-- Windows/resource.h | 3 +- assets/lang/ar_AE.ini | 6 ++-- assets/lang/az_AZ.ini | 6 ++-- assets/lang/bg_BG.ini | 6 ++-- assets/lang/ca_ES.ini | 6 ++-- assets/lang/cz_CZ.ini | 6 ++-- assets/lang/da_DK.ini | 6 ++-- assets/lang/de_DE.ini | 6 ++-- assets/lang/dr_ID.ini | 6 ++-- assets/lang/en_US.ini | 6 ++-- assets/lang/es_ES.ini | 6 ++-- assets/lang/es_LA.ini | 6 ++-- assets/lang/fa_IR.ini | 6 ++-- assets/lang/fi_FI.ini | 6 ++-- assets/lang/fr_FR.ini | 6 ++-- assets/lang/gl_ES.ini | 6 ++-- assets/lang/gr_EL.ini | 6 ++-- assets/lang/he_IL.ini | 6 ++-- assets/lang/he_IL_invert.ini | 6 ++-- assets/lang/hr_HR.ini | 6 ++-- assets/lang/hu_HU.ini | 6 ++-- assets/lang/id_ID.ini | 6 ++-- assets/lang/it_IT.ini | 6 ++-- assets/lang/ja_JP.ini | 6 ++-- assets/lang/jv_ID.ini | 6 ++-- assets/lang/ko_KR.ini | 6 ++-- assets/lang/lo_LA.ini | 6 ++-- assets/lang/lt-LT.ini | 6 ++-- assets/lang/ms_MY.ini | 6 ++-- assets/lang/nl_NL.ini | 6 ++-- assets/lang/no_NO.ini | 6 ++-- assets/lang/pl_PL.ini | 6 ++-- assets/lang/pt_BR.ini | 6 ++-- assets/lang/pt_PT.ini | 6 ++-- assets/lang/ro_RO.ini | 6 ++-- assets/lang/ru_RU.ini | 6 ++-- assets/lang/sv_SE.ini | 6 ++-- assets/lang/tg_PH.ini | 6 ++-- assets/lang/th_TH.ini | 6 ++-- assets/lang/tr_TR.ini | 8 ++--- assets/lang/uk_UA.ini | 6 ++-- assets/lang/vi_VN.ini | 6 ++-- assets/lang/zh_CN.ini | 6 ++-- assets/lang/zh_TW.ini | 12 +++---- headless/Headless.cpp | 2 +- 54 files changed, 138 insertions(+), 264 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 3e095283cd..8e3c1d76d7 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -875,7 +875,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("CameraDevice", &g_Config.sCameraDevice, "", true, false), ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), ConfigSetting("UseGeometryShader", &g_Config.bUseGeometryShader, true, true, true), - ReportedConfigSetting("RenderingMode", &g_Config.iRenderingMode, 1, true, true), + ConfigSetting("SkipBufferEffects", &g_Config.bSkipBufferEffects, false, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ConfigSetting("SoftwareRendererJit", &g_Config.bSoftwareRenderingJit, true, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), @@ -1410,9 +1410,6 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { if (iAnisotropyLevel > 4) { iAnisotropyLevel = 4; } - if (iRenderingMode != FB_NON_BUFFERED_MODE && iRenderingMode != FB_BUFFERED_MODE) { - g_Config.iRenderingMode = FB_BUFFERED_MODE; - } // Check for an old dpad setting Section *control = iniFile.GetOrCreateSection("Control"); @@ -1463,8 +1460,8 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { if (sMACAddress.length() != 17) sMACAddress = CreateRandMAC(); - if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { - g_Config.iRenderingMode = FB_BUFFERED_MODE; + if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) { + g_Config.bSkipBufferEffects = false; } // Override ppsspp.ini JIT value to prevent crashing @@ -1985,5 +1982,5 @@ void Config::GetReportingInfo(UrlEncoder &data) { } bool Config::IsPortrait() const { - return (iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180) && iRenderingMode != FB_NON_BUFFERED_MODE; + return (iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180) && !bSkipBufferEffects; } diff --git a/Core/Config.h b/Core/Config.h index 6dc1226858..e4795bfd4b 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -162,11 +162,13 @@ public: bool bSoftwareRendering; bool bSoftwareRenderingJit; bool bHardwareTransform; // only used in the GLES backend - bool bSoftwareSkinning; // may speed up some games + bool bSoftwareSkinning; bool bVendorBugChecksEnabled; bool bUseGeometryShader; - int iRenderingMode; // 0 = non-buffered rendering 1 = buffered rendering + // Speedhacks (more will be moved here): + bool bSkipBufferEffects; + int iTexFiltering; // 1 = auto , 2 = nearest , 3 = linear , 4 = auto max quality int iBufFilter; // 1 = linear, 2 = nearest int iSmallDisplayZoomType; // Used to fit display into screen 0 = stretch, 1 = partial stretch, 2 = auto scaling, 3 = manual scaling. diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index d0577d46f2..342d522627 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -544,7 +544,7 @@ void __DisplayFlip(int cyclesLate) { // non-buffered rendering. The interaction with frame skipping seems to need // some work. // But, let's flip at least once every 10 vblanks, to update fps, etc. - const bool noRecentFlip = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && numVBlanksSinceFlip >= 10; + const bool noRecentFlip = !g_Config.bSkipBufferEffects && numVBlanksSinceFlip >= 10; // Also let's always flip for animated shaders. bool postEffectRequiresFlip = false; @@ -556,7 +556,7 @@ void __DisplayFlip(int cyclesLate) { fastForwardSkipFlip = true; } - if (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) { + if (!g_Config.bSkipBufferEffects) { postEffectRequiresFlip = duplicateFrames || g_Config.bShaderChainRequires60FPS; } @@ -777,7 +777,7 @@ void __DisplaySetFramebuf(u32 topaddr, int linesize, int pixelFormat, int sync) // IMMEDIATE means that the buffer is fine. We can just flip immediately. // Doing it in non-buffered though creates problems (black screen) on occasion though // so let's not. - if (!flippedThisFrame && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) { + if (!flippedThisFrame && !g_Config.bSkipBufferEffects) { double before_flip = time_now_d(); __DisplayFlip(0); double after_flip = time_now_d(); diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index f7a470bb7d..8a74467130 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -91,7 +91,9 @@ bool FramebufferManagerCommon::UpdateSize() { const int effectiveBloomHack = PSP_CoreParameter().compat.flags().ForceLowerResolutionForEffectsOn ? 3 : g_Config.iBloomHack; - const bool newSettings = bloomHack_ != effectiveBloomHack || useBufferedRendering_ != (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); + + bool newBuffered = !g_Config.bSkipBufferEffects; + const bool newSettings = bloomHack_ != effectiveBloomHack || useBufferedRendering_ != newBuffered; renderWidth_ = (float)PSP_CoreParameter().renderWidth; renderHeight_ = (float)PSP_CoreParameter().renderHeight; @@ -99,7 +101,7 @@ bool FramebufferManagerCommon::UpdateSize() { pixelWidth_ = PSP_CoreParameter().pixelWidth; pixelHeight_ = PSP_CoreParameter().pixelHeight; bloomHack_ = effectiveBloomHack; - useBufferedRendering_ = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + useBufferedRendering_ = newBuffered; presentation_->UpdateSize(pixelWidth_, pixelHeight_, renderWidth_, renderHeight_); diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 3e0dd6479a..e2ea500884 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -275,7 +275,7 @@ void DisplayLayoutScreen::CreateViews() { root_->Add(new Boundary(new AnchorLayoutParams(previewWidth, vertBoundariesHeight, horizPreviewPadding, vertPreviewPadding - vertBoundariesHeight, NONE, NONE))); root_->Add(new Boundary(new AnchorLayoutParams(previewWidth, vertBoundariesHeight, horizPreviewPadding, vertPreviewPadding + previewHeight, NONE, NONE))); - bool displayRotEnable = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) || g_Config.bSoftwareRendering; + bool displayRotEnable = !g_Config.bSkipBufferEffects || g_Config.bSoftwareRendering; bRotated_ = false; if (displayRotEnable && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) { bRotated_ = true; @@ -371,7 +371,7 @@ void DisplayLayoutScreen::CreateViews() { static const char *displayRotation[] = { "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed" }; auto rotation = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, previewWidth - 200.0f, 10, NONE, bounds.h - 64 - 10)); rotation->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE || g_Config.bSoftwareRendering; + return !g_Config.bSkipBufferEffects || g_Config.bSoftwareRendering; }); root_->Add(rotation); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bcf5a47a48..c046fb01d5 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -327,7 +327,7 @@ void EmuScreen::bootGame(const Path &filename) { System_SendMessage("event", "failstartgame"); } - if (PSP_CoreParameter().compat.flags().RequireBufferedRendering && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { + if (PSP_CoreParameter().compat.flags().RequireBufferedRendering && g_Config.bSkipBufferEffects) { auto gr = GetI18NCategory("Graphics"); host->NotifyUserMessage(gr->T("BufferedRenderingRequired", "Warning: This game requires Rendering Mode to be set to Buffered."), 15.0f); } @@ -1355,7 +1355,7 @@ void EmuScreen::preRender() { // We only bind it in FramebufferManager::CopyDisplayToOutput (unless non-buffered)... // We do, however, start the frame in other ways. - bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + bool useBufferedRendering = !g_Config.bSkipBufferEffects; if ((!useBufferedRendering && !g_Config.bSoftwareRendering) || Core_IsStepping()) { // We need to clear here already so that drawing during the frame is done on a clean slate. if (Core_IsStepping() && gpuStats.numFlips != 0) { diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index cf87f56f47..d92eed91a1 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -298,20 +298,16 @@ void GameSettingsScreen::CreateViews() { } } - static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering" }; - PopupMultiChoice *renderingModeChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gr->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gr->GetName(), screenManager())); - renderingModeChoice->OnChoice.Add([=](EventParams &e) { - switch (g_Config.iRenderingMode) { - case FB_NON_BUFFERED_MODE: + CheckBox *skipBufferEffects = graphicsSettings->Add(new CheckBox(&g_Config.bSkipBufferEffects, gr->T("Skip Buffer Effects"))); + skipBufferEffects->OnClick.Add([=](EventParams &e) { + if (g_Config.bSkipBufferEffects) { settingInfo_->Show(gr->T("RenderingMode NonBuffered Tip", "Faster, but graphics may be missing in some games"), e.v); - break; - case FB_BUFFERED_MODE: - break; + g_Config.bAutoFrameSkip = false; } - return UI::EVENT_CONTINUE; + return UI::EVENT_DONE; }); - renderingModeChoice->OnChoice.Handle(this, &GameSettingsScreen::OnRenderingMode); - renderingModeChoice->SetDisabledPtr(&g_Config.bSoftwareRendering); + skipBufferEffects->SetDisabledPtr(&g_Config.bSoftwareRendering); + CheckBox *blockTransfer = graphicsSettings->Add(new CheckBox(&g_Config.bBlockTransferGPU, gr->T("Simulate Block Transfer", "Simulate Block Transfer"))); blockTransfer->OnClick.Add([=](EventParams &e) { if (!g_Config.bBlockTransferGPU) @@ -378,7 +374,7 @@ void GameSettingsScreen::CreateViews() { auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)]; PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); settingValue->SetEnabledFunc([=] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && enableStereo(); + return !g_Config.bSkipBufferEffects && enableStereo(); }); } } @@ -400,7 +396,7 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_DONE; }); postProcChoice_->SetEnabledFunc([=] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo(); + return !g_Config.bSkipBufferEffects && !enableStereo(); }); // No need for settings on the last one. @@ -423,7 +419,7 @@ void GameSettingsScreen::CreateViews() { } else { PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager())); settingValue->SetEnabledFunc([=] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && !enableStereo(); + return !g_Config.bSkipBufferEffects && !enableStereo(); }); } } @@ -470,7 +466,7 @@ void GameSettingsScreen::CreateViews() { resolutionChoice_ = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gr->T("Rendering Resolution"), internalResolutions, 0, ARRAY_SIZE(internalResolutions), gr->GetName(), screenManager())); resolutionChoice_->OnChoice.Handle(this, &GameSettingsScreen::OnResolutionChange); resolutionChoice_->SetEnabledFunc([] { - return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; + return !g_Config.bSoftwareRendering && !g_Config.bSkipBufferEffects; }); #if PPSSPP_PLATFORM(ANDROID) @@ -499,7 +495,7 @@ void GameSettingsScreen::CreateViews() { return UI::EVENT_CONTINUE; }); frameDuplication->SetEnabledFunc([] { - return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && g_Config.iFrameSkip == 0; + return !g_Config.bSkipBufferEffects && g_Config.iFrameSkip == 0; }); if (GetGPUBackend() == GPUBackend::VULKAN || GetGPUBackend() == GPUBackend::OPENGL) { @@ -1198,8 +1194,8 @@ UI::EventReturn GameSettingsScreen::OnAutoFrameskip(UI::EventParams &e) { if (g_Config.bAutoFrameSkip && g_Config.iFrameSkip == 0) { g_Config.iFrameSkip = 1; } - if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { - g_Config.iRenderingMode = FB_BUFFERED_MODE; + if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) { + g_Config.bSkipBufferEffects = false; } return UI::EVENT_DONE; } @@ -1243,20 +1239,6 @@ UI::EventReturn GameSettingsScreen::OnSustainedPerformanceModeChange(UI::EventPa return UI::EVENT_DONE; } -UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) { - // We do not want to report when rendering mode is Framebuffer to memory - so many issues - // are caused by that (framebuffer copies overwriting display lists, etc). - Reporting::UpdateConfig(); - enableReportsCheckbox_->SetEnabled(Reporting::IsSupported()); - if (!Reporting::IsSupported()) - enableReports_ = Reporting::IsEnabled(); - - if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { - g_Config.bAutoFrameSkip = false; - } - return UI::EVENT_DONE; -} - UI::EventReturn GameSettingsScreen::OnJitAffectingSetting(UI::EventParams &e) { NativeMessageReceived("clear jit", ""); return UI::EVENT_DONE; diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index 384bb9a0f7..b8e8b10c94 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -315,8 +315,7 @@ namespace MainWindow { TranslateMenuItem(menu, ID_OPTIONS_VULKAN); TranslateMenuItem(menu, ID_OPTIONS_RENDERMODE_MENU); - TranslateMenuItem(menu, ID_OPTIONS_NONBUFFEREDRENDERING); - TranslateMenuItem(menu, ID_OPTIONS_BUFFEREDRENDERING); + TranslateMenuItem(menu, ID_OPTIONS_SKIP_BUFFER_EFFECTS); TranslateMenuItem(menu, ID_OPTIONS_FRAMESKIP_MENU, g_Config.bSystemControls ? L"\tF7" : L""); TranslateMenuItem(menu, ID_OPTIONS_FRAMESKIP_AUTO); TranslateMenuItem(menu, ID_OPTIONS_FRAMESKIP_0); @@ -489,21 +488,8 @@ namespace MainWindow { NativeMessageReceived("gpu_clearCache", ""); } - static void setRenderingMode(int mode) { - auto gr = GetI18NCategory("Graphics"); - - g_Config.iRenderingMode = mode; - switch (g_Config.iRenderingMode) { - case FB_NON_BUFFERED_MODE: - osm.Show(gr->T("Non-Buffered Rendering")); - g_Config.bAutoFrameSkip = false; - break; - - case FB_BUFFERED_MODE: - osm.Show(gr->T("Buffered Rendering")); - break; - } - + static void setSkipBufferEffects(bool skip) { + g_Config.bSkipBufferEffects = skip; NativeMessageReceived("gpu_resized", ""); } @@ -756,8 +742,8 @@ namespace MainWindow { case ID_OPTIONS_FRAMESKIP_AUTO: g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip; - if (g_Config.bAutoFrameSkip && g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { - g_Config.iRenderingMode = FB_BUFFERED_MODE; + if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) { + g_Config.bSkipBufferEffects = false; NativeMessageReceived("gpu_resized", ""); } break; @@ -802,8 +788,11 @@ namespace MainWindow { RestartApp(); break; - case ID_OPTIONS_NONBUFFEREDRENDERING: setRenderingMode(FB_NON_BUFFERED_MODE); break; - case ID_OPTIONS_BUFFEREDRENDERING: setRenderingMode(FB_BUFFERED_MODE); break; + case ID_OPTIONS_SKIP_BUFFER_EFFECTS: + g_Config.bSkipBufferEffects = !g_Config.bSkipBufferEffects; + NativeMessageReceived("gpu_resized", ""); + osm.ShowOnOff(gr->T("Skip Buffer Effects"), g_Config.bSkipBufferEffects); + break; case ID_DEBUG_SHOWDEBUGSTATISTICS: g_Config.bShowDebugStats = !g_Config.bShowDebugStats; @@ -1095,6 +1084,7 @@ namespace MainWindow { CHECKITEM(ID_FILE_USEFFV1, g_Config.bUseFFV1); CHECKITEM(ID_FILE_DUMP_VIDEO_OUTPUT, g_Config.bDumpVideoOutput); CHECKITEM(ID_FILE_DUMPAUDIO, g_Config.bDumpAudio); + CHECKITEM(ID_OPTIONS_SKIP_BUFFER_EFFECTS, g_Config.bSkipBufferEffects); static const int displayrotationitems[] = { ID_EMULATION_ROTATION_H, @@ -1238,15 +1228,6 @@ namespace MainWindow { CheckMenuItem(menu, bufferfilteritems[i], MF_BYCOMMAND | ((i + 1) == g_Config.iBufFilter ? MF_CHECKED : MF_UNCHECKED)); } - static const int renderingmode[] = { - ID_OPTIONS_NONBUFFEREDRENDERING, - ID_OPTIONS_BUFFEREDRENDERING, - }; - - for (int i = 0; i < ARRAY_SIZE(renderingmode); i++) { - CheckMenuItem(menu, renderingmode[i], MF_BYCOMMAND | ((i == g_Config.iRenderingMode) ? MF_CHECKED : MF_UNCHECKED)); - } - static const int frameskipping[] = { ID_OPTIONS_FRAMESKIP_0, ID_OPTIONS_FRAMESKIP_1, diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index c04801767e..27437ef9f1 100644 --- a/Windows/ppsspp.rc +++ b/Windows/ppsspp.rc @@ -552,6 +552,7 @@ BEGIN MENUITEM "", 0, MFT_SEPARATOR MENUITEM "Fullscreen", ID_OPTIONS_FULLSCREEN MENUITEM "VSync", ID_OPTIONS_VSYNC + MENUITEM "Skip Buffer Effects", ID_OPTIONS_SKIP_BUFFER_EFFECTS POPUP "Postprocessing Shader", ID_OPTIONS_SHADER_MENU BEGIN MENUITEM "", 0, MFT_SEPARATOR @@ -592,11 +593,7 @@ BEGIN MENUITEM "Vulkan", ID_OPTIONS_VULKAN END - POPUP "Rendering Mode", ID_OPTIONS_RENDERMODE_MENU - BEGIN - MENUITEM "Non-Buffered Rendering", ID_OPTIONS_NONBUFFEREDRENDERING - MENUITEM "Buffered Rendering", ID_OPTIONS_BUFFEREDRENDERING - END + POPUP "Frame Skipping", ID_OPTIONS_FRAMESKIP_MENU BEGIN MENUITEM "Auto", ID_OPTIONS_FRAMESKIP_AUTO diff --git a/Windows/resource.h b/Windows/resource.h index ab68ee494f..6bc03a9429 100644 --- a/Windows/resource.h +++ b/Windows/resource.h @@ -189,7 +189,7 @@ #define ID_DISASM_THREAD_KILL 40073 #define ID_FILE_SAVESTATE_NEXT_SLOT 40074 #define ID_FILE_SAVESTATE_NEXT_SLOT_HC 40075 -#define ID_OPTIONS_NONBUFFEREDRENDERING 40078 +#define ID_OPTIONS_SKIP_BUFFER_EFFECTS 40078 #define ID_OPTIONS_FRAMESKIP_0 40079 #define ID_OPTIONS_FRAMESKIP_1 40080 #define ID_OPTIONS_FRAMESKIP_2 40081 @@ -219,7 +219,6 @@ #define ID_OPTIONS_WINDOW3X 40106 #define ID_OPTIONS_WINDOW4X 40107 #define ID_OPTIONS_WINDOW5X 40108 -#define ID_OPTIONS_BUFFEREDRENDERING 40109 #define ID_DEBUG_SHOWDEBUGSTATISTICS 40110 #define ID_OPTIONS_SCREEN6X 40111 #define ID_OPTIONS_SCREEN7X 40112 diff --git a/assets/lang/ar_AE.ini b/assets/lang/ar_AE.ini index 6987e7b3c7..8cae321f81 100644 --- a/assets/lang/ar_AE.ini +++ b/assets/lang/ar_AE.ini @@ -137,7 +137,6 @@ Backend = ‎&خلفية التصيير(إعادة تشغيل PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = ‎&تصيير مخفف Buy Gold = ‎إشتري النسخة الإحترافية & Control Mapping... = ‎&تخطيط التحكم... Debugging = ‎&تصحيح @@ -181,7 +180,7 @@ Log Console = ‎&سجل الكونسول Memory View... = ‎عرض الرام... More Settings... = ‎&إعدادات إضافية... Nearest = ‎&الأقرب -Non-Buffered Rendering = ‎&تخطي تأثيرات الصقل (غير مصقول, أسرع) +Skip Buffer Effects = ‎&تخطي تأثيرات الصقل (غير مصقول, أسرع) Off = ‎&مغلق Open Chat = Open Chat Open Directory... = ‎إفتح مسار&... @@ -481,7 +480,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = ‎الأثنين Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = ‎التصيير المُخفف BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -533,7 +531,7 @@ Must Restart = ‎يجب عليك إعادة تشغيل البرنامج لكي Native device resolution = ‎حجم الجهاز الأساسي Nearest = Nearest No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = ‎لا شئ Number of Frames = Number of frames Off = ‎مغلق diff --git a/assets/lang/az_AZ.ini b/assets/lang/az_AZ.ini index 581e08ca3a..88dd568f32 100644 --- a/assets/lang/az_AZ.ini +++ b/assets/lang/az_AZ.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Buy &Gold Control Mapping... = C&ontrol Mapping... Debugging = &Debug @@ -173,7 +172,7 @@ Log Console = &Log Console Memory View... = Memory &View... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = Open &Directory... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Yükləyərək Aç BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Nearest No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = None Number of Frames = Number of frames Off = Off diff --git a/assets/lang/bg_BG.ini b/assets/lang/bg_BG.ini index e8b2d60613..f2a48cade1 100644 --- a/assets/lang/bg_BG.ini +++ b/assets/lang/bg_BG.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Купи &Gold Control Mapping... = Контроли... Debugging = &Debug @@ -173,7 +172,7 @@ Log Console = &Log Console Memory View... = Памет изглед... More Settings... = Още настройки... Nearest = &Най-близко -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Изключено Open Chat = Open Chat Open Directory... = Отвори директория... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = И двете Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffered rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Най-близко No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Нищо Number of Frames = Number of frames Off = Изключен diff --git a/assets/lang/ca_ES.ini b/assets/lang/ca_ES.ini index dc018c04b4..fab847026c 100644 --- a/assets/lang/ca_ES.ini +++ b/assets/lang/ca_ES.ini @@ -129,7 +129,6 @@ Backend = Motor &gràfic (requereix reiniciar) Bicubic = &Bicúbic Break = Break Break on Load = Break on load -Buffered Rendering = &Renderitzat en memòria intermèdia Buy Gold = Compreu la versió &Gold Control Mapping... = Assigneu els &botons... Debugging = &Depuració @@ -173,7 +172,7 @@ Log Console = Consola de re&gistres Memory View... = Visor de &memòria... More Settings... = Més &paràmetres... Nearest = &El més proper -Non-Buffered Rendering = &Renderitzat sense memòria intermèdia (més ràpid) +Skip Buffer Effects = &Renderitzat sense memòria intermèdia (més ràpid) Off = &No Open Chat = Open Chat Open Directory... = Obriu &directori... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Renderizat per buffer BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Nearest No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = None Number of Frames = Number of frames Off = Off diff --git a/assets/lang/cz_CZ.ini b/assets/lang/cz_CZ.ini index c190a4e884..08043400a9 100644 --- a/assets/lang/cz_CZ.ini +++ b/assets/lang/cz_CZ.ini @@ -129,7 +129,6 @@ Backend = V&ykreslovací Jádro (Restartuje PPSSPP) Bicubic = &Bikubická Break = Break Break on Load = Break on load -Buffered Rendering = Vykreslování &s vyrovnávací pamětí Buy Gold = &Koupit zlaté PPSSPP Control Mapping... = &Mapování ovládání... Debugging = &Ladění @@ -173,7 +172,7 @@ Log Console = &Konzole záznamu Memory View... = &Zobrazení paměti... More Settings... = D&alší nastavení... Nearest = &Nejbližší -Non-Buffered Rendering = &Přeskočit efekty vyrovnávací paměti (rychlejší, neukládá se do paměti) +Skip Buffer Effects = &Přeskočit efekty vyrovnávací paměti Off = &Vypnuto Open Chat = Open Chat Open Directory... = &Otevřít adresář... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Obojí Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Vykreslování s vyrovnávací pamětí BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Aby došlo k použití těchto změn, je nutné PPSSPP restartova Native device resolution = Původní rozlišení zařízení Nearest = Nejbližší No buffer = No buffer -Non-Buffered Rendering = Přeskočit efekty vyrovnávací paměti (rychlejší, neukládá se do paměti) +Skip Buffer Effects = Přeskočit efekty vyrovnávací paměti None = Nezobrazovat Number of Frames = Number of frames Off = Vypnuto diff --git a/assets/lang/da_DK.ini b/assets/lang/da_DK.ini index de5366d8f5..06dfd28cee 100644 --- a/assets/lang/da_DK.ini +++ b/assets/lang/da_DK.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Genstarter PPSSPP) Bicubic = &Bicubisk Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered rendering Buy Gold = Køb PPSSPP &guld Control Mapping... = &Ændre tasteplaceringen... Debugging = Fe&jlfind @@ -173,7 +172,7 @@ Log Console = &Log konsol Memory View... = Hukommelseso&versigt... More Settings... = &Flere indstillinger... Nearest = &Nærmest -Non-Buffered Rendering = &Skip buffer effekter (ikke-bufferet, hurtigere) +Skip Buffer Effects = &Skip buffer effekter Off = &Slukket Open Chat = Open Chat Open Directory... = &Åben katalog... @@ -473,7 +472,6 @@ BlockTransfer Tip = Nogle spil kræver at denne er tændt for korrekt grafik BlockTransferRequired = Advarsel: Dette spil kræver at simulerede blok overførsel tilstand er tændt. Both = Begge Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Bufferet rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Du må genstarte PPSSPP for at aktivere denne ændring. Native device resolution = Standard enheds opløsning Nearest = Nærmest No buffer = No buffer -Non-Buffered Rendering = Skip buffer effekter (ikke-buffered, hurtigere) +Skip Buffer Effects = Skip buffer effekter None = Ingen Number of Frames = Number of frames Off = Slukket diff --git a/assets/lang/de_DE.ini b/assets/lang/de_DE.ini index a5129d922e..4e194329bd 100644 --- a/assets/lang/de_DE.ini +++ b/assets/lang/de_DE.ini @@ -129,7 +129,6 @@ Backend = Grafik-Backend Bicubic = Bikubisch Break = Anhalten Break on Load = Anhalten beim Laden -Buffered Rendering = Gepuffertes Rendern Buy Gold = Goldversion kaufen Control Mapping... = Tastenbelegung ändern... Debugging = Debug @@ -173,7 +172,7 @@ Log Console = Logkonsole Memory View... = Speicheransicht... More Settings... = Mehr Einstellungen... Nearest = Nächster Nachbar -Non-Buffered Rendering = Überspringe Puffereffekte (ungepuffert, schneller) +Skip Buffer Effects = Überspringe Puffereffekte Off = Aus Open Chat = Öffne Chat Open Directory... = Öffne Verzeichnis... @@ -473,7 +472,6 @@ BlockTransfer Tip = Manche Spiele benötigen dies für eine korrekte Darstellung BlockTransferRequired = Warnung: Dieses Spiel benötigt "Blockübertragungseffekte simulieren". Both = Beide Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Gepuffertes Rendern BufferedRenderingRequired = Warnung: Bei diesem Spiel muss "Rendering Modus" auf "Gepuffert" gesetzt werden. Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Sie müssen PPSSPP neustarten, damit die Änderungen wirksam werd Native device resolution = Native Auflösung Nearest = Nächster Nachbar No buffer = No buffer -Non-Buffered Rendering = Über&springe Puffereffekte (ungepuffert, schneller) +Skip Buffer Effects = Über&springe Puffereffekte None = Keine Number of Frames = Anzahl an Frames Off = Aus diff --git a/assets/lang/dr_ID.ini b/assets/lang/dr_ID.ini index 23346118f2..ca081a1c09 100644 --- a/assets/lang/dr_ID.ini +++ b/assets/lang/dr_ID.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Alli &Gold Control Mapping... = C&ontrol Mapping... Debugging = Debu&g @@ -173,7 +172,7 @@ Log Console = &Konsol log Memory View... = Pempakitan &Memory... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Mate Open Chat = Open Chat Open Directory... = Bukka' &Ngenan... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Pa jio duai Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffered rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = To paling mandoppi' No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Danggo'mo Number of Frames = Number of frames Off = Mate diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index b3389a229b..b66ccc4ee1 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -153,7 +153,6 @@ Backend = Rendering &backend (restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered rendering Buy Gold = Buy &Gold Control Mapping... = C&ontrol mapping... Debugging = &Debug @@ -197,7 +196,7 @@ Log Console = &Log console Memory View... = Memory &view... More Settings... = &More settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = Open &directory... @@ -497,7 +496,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffered rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -548,7 +546,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Nearest No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = None Number of Frames = Number of frames Off = Off diff --git a/assets/lang/es_ES.ini b/assets/lang/es_ES.ini index b61201985c..30216ad2cd 100644 --- a/assets/lang/es_ES.ini +++ b/assets/lang/es_ES.ini @@ -129,7 +129,6 @@ Backend = Motor &gráfico (requiere reiniciar) Bicubic = &Bicúbico Break = Romper Break on Load = Romper en carga -Buffered Rendering = &Dibujado por búfer Buy Gold = Comprar versión &Gold Control Mapping... = Asignar &botones... Debugging = &Depuración @@ -173,7 +172,7 @@ Log Console = Consola de re&gistros... Memory View... = Visor de &memoria... More Settings... = Más &opciones... Nearest = &Cercano -Non-Buffered Rendering = &Saltar efectos del búfer (rápido) +Skip Buffer Effects = &Saltar efectos del búfer (rápido) Off = &No Open Chat = Abrir ventana de chat Open Directory... = &Abrir carpeta... @@ -473,7 +472,6 @@ BlockTransfer Tip = Algunos juegos necesitan esta opción para evitar errores gr BlockTransferRequired = AVISO: Este juego requiere activar los efectos de transferencia de bloque. Both = Ambos Buffer graphics commands (faster, input lag) = Comandos de búfer gráfico (puede generar input lag) -Buffered Rendering = Dibujado por búfer BufferedRenderingRequired = AVISO: este juego requiere modo de renderizado por búfer. Camera = Cámara Camera Device = Dispositivo de cámara @@ -525,7 +523,7 @@ Must Restart = Debes reiniciar PPSSPP para aplicar este cambio. Native device resolution = Resolución nativa del dispositivo Nearest = Pixelado No buffer = Sin búfer -Non-Buffered Rendering = Saltar efectos del búfer +Skip Buffer Effects = Saltar efectos del búfer None = No Number of Frames = Nº de cuadros Off = No diff --git a/assets/lang/es_LA.ini b/assets/lang/es_LA.ini index 6c7d42d35f..76da6dbded 100644 --- a/assets/lang/es_LA.ini +++ b/assets/lang/es_LA.ini @@ -129,7 +129,6 @@ Backend = Motor &gráfico (requiere reiniciar) Bicubic = &Bicúbico Break = Romper Break on Load = Romper en carga -Buffered Rendering = &Renderizado por búfer Buy Gold = Comprar versión &Gold Control Mapping... = Asignar &botones... Debugging = &Depuración @@ -173,7 +172,7 @@ Log Console = Consola de re&gistros... Memory View... = Visor de &memoria... More Settings... = Más &opciones... Nearest = &Cercano -Non-Buffered Rendering = &Saltar efectos por búfer (rápido) +Skip Buffer Effects = &Saltar efectos por búfer (rápido) Off = &No Open Chat = Abrir ventana de chat Open Directory... = &Abrir carpeta... @@ -473,7 +472,6 @@ BlockTransfer Tip = Algunos juegos requieren activarlo para corregir gráficos. BlockTransferRequired = Advertencia: Este juego requiere activar los efectos de transferencia de bloque. Both = Ambos Buffer graphics commands (faster, input lag) = Comandos gráficos de búfer (puede generar input lag) -Buffered Rendering = Renderizado con Buffer BufferedRenderingRequired = Advertencia: Este juego requiere modo de renderizado por búfer. Camera = Cámara Camera Device = Dispositivo de cámara @@ -525,7 +523,7 @@ Must Restart = Debes reiniciar PPSSPP para aplicar este cambio. Native device resolution = Resolución nativa del dispositivo Nearest = Pixelado No buffer = No hay búfer -Non-Buffered Rendering = Saltar efectos por búfer (Desactiva búfer, rápido) +Skip Buffer Effects = Saltar efectos por búfer (Desactiva búfer, rápido) None = No Number of Frames = Número de Frames Off = Apagado diff --git a/assets/lang/fa_IR.ini b/assets/lang/fa_IR.ini index dba054242f..c082a845b9 100644 --- a/assets/lang/fa_IR.ini +++ b/assets/lang/fa_IR.ini @@ -129,7 +129,6 @@ Backend = ‎Rendering &Backend (ریستارت میشود PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = ‎رندر کردن از بافر Buy Gold = ‎خرید نسخه طلایی Control Mapping... = ‎...تنظیمات کنترلر Debugging = ‎دیباگ @@ -173,7 +172,7 @@ Log Console = ‎کنسول لاگ Memory View... = ‎...نمایش مموری More Settings... = ‎...تنظیمات بیشتر Nearest = ‎نزدیک ترین -Non-Buffered Rendering = ‎رد کردن اثرات بافر (سریع تر) +Skip Buffer Effects = ‎رد کردن اثرات بافر (سریع تر) Off = ‎خاموش Open Chat = Open Chat Open Directory... = ‎... بازکردن مسیر @@ -473,7 +472,6 @@ BlockTransfer Tip = ‎در بعضی بازی ها برای نشان دادن د BlockTransferRequired = ‎دارد "simulate block transfer effects" هشدار:این گزینه نیاز به روشن بودن Both = ‎سرعت + فریم بر ثانیه Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = ‎رندر کردن از بافر BufferedRenderingRequired = ‎تنظیم باشد "buffered" هشدار: برای این بازی "حالت رندرینگ" باید روی Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = ‎برای اعمال این تنظیم باید برنامه ر Native device resolution = ‎رزولوشن دستگاه Nearest = ‎نزدیک ترین No buffer = No buffer -Non-Buffered Rendering = ‎رد کردن اثر بافر (سریع تر) +Skip Buffer Effects = ‎رد کردن اثر بافر (سریع تر) None = ‎هیچ Number of Frames = Number of frames Off = ‎خاموش diff --git a/assets/lang/fi_FI.ini b/assets/lang/fi_FI.ini index 8d8aafccb5..6e448250bc 100644 --- a/assets/lang/fi_FI.ini +++ b/assets/lang/fi_FI.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Buy &Gold Control Mapping... = C&ontrol Mapping... Debugging = &Debug @@ -173,7 +172,7 @@ Log Console = &Log Console Memory View... = Memory &View... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = Open &Directory... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Molemmat Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Puskuroitu renderointi BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Lähin No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Ei mitään Number of Frames = Number of frames Off = Off diff --git a/assets/lang/fr_FR.ini b/assets/lang/fr_FR.ini index 330ded83af..3e87cb10b8 100644 --- a/assets/lang/fr_FR.ini +++ b/assets/lang/fr_FR.ini @@ -129,7 +129,6 @@ Backend = Rendu &back-end (redémarre PPSSPP) Bicubic = &Bicubique Break = Arrêter Break on Load = Arrêter au lancement -Buffered Rendering = &Mise en mémoire tampon Buy Gold = Acheter la version &Gold Control Mapping... = R&éassignation des touches... Debugging = &Débogage @@ -173,7 +172,7 @@ Log Console = &Journal de débogage Memory View... = &Visionneur de mémoire More Settings... = &Plus de paramètres... Nearest = Le plus &proche -Non-Buffered Rendering = &Pas d'effets en mémoire tampon (hack de vitesse) +Skip Buffer Effects = &Pas d'effets en mémoire tampon (hack de vitesse) Off = &Désactivé Open Chat = Open Chat Open Directory... = Ouvrir &répertoire... @@ -473,7 +472,6 @@ BlockTransfer Tip = Certains jeux requièrent l'activation de ce paramètre pour BlockTransferRequired = Avertissement : Ce jeu requiert l'activation de "Simuler les effets de transfert de bloc". Both = Vitesse + FPS Buffer graphics commands (faster, input lag) = Commandes graphiques en mémoire tampon (+ rapide, + lag entrée) -Buffered Rendering = Mise en mémoire tampon BufferedRenderingRequired = Avertissement : Ce jeu requiert "mode de rendu" réglé sur "Mise en mémoire tampon". Camera = Caméra Camera Device = Caméra @@ -525,7 +523,7 @@ Must Restart = Vous devez redémarrer PPSSPP pour que cette modification prenne Native device resolution = Définition native de l'appareil Nearest = Le plus proche No buffer = 0 -Non-Buffered Rendering = Pas d'effets en mémoire tampon (hack vitesse) +Skip Buffer Effects = Pas d'effets en mémoire tampon (hack vitesse) None = Aucun Number of Frames = Nombre d'images Off = Désactivé diff --git a/assets/lang/gl_ES.ini b/assets/lang/gl_ES.ini index 42c0a81859..0144f5cb0d 100644 --- a/assets/lang/gl_ES.ini +++ b/assets/lang/gl_ES.ini @@ -129,7 +129,6 @@ Backend = Motor &gráfico (require reiniciar) Bicubic = &Bicúbico Break = Break Break on Load = Break on load -Buffered Rendering = &Renderizado por búfer Buy Gold = Comprar versión &Gold Control Mapping... = Asignar &botóns... Debugging = &Depuración @@ -173,7 +172,7 @@ Log Console = Consola de re&xistros... Memory View... = Visor de &memoria... More Settings... = Máis &opcións... Nearest = &Cercano -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Non Open Chat = Open Chat Open Directory... = &Abrir carpeta... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Renderizado por búfer BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Debes reiniciar PPSSPP para aplicar este cambio. Native device resolution = Resolución nativa do dispositivo Nearest = Pixelado No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Non Number of Frames = Number of frames Off = Non diff --git a/assets/lang/gr_EL.ini b/assets/lang/gr_EL.ini index 3f9555e900..53fc6fd553 100644 --- a/assets/lang/gr_EL.ini +++ b/assets/lang/gr_EL.ini @@ -129,7 +129,6 @@ Backend = Σύστημα Υποστήριξης (επανεκκινεί το PPS Bicubic = &Διακυβική Break = Break Break on Load = Break on load -Buffered Rendering = Απεικόνιση με Buffer Buy Gold = Αγορά &Gold Control Mapping... = Χαρτογράφηση Κουμπιών... Debugging = Αποσφαλμάτωση @@ -173,7 +172,7 @@ Log Console = Κονσόλα Καταγραφέα Memory View... = Προβολή Μνήμης... More Settings... = Περισσότερες Ρυθμίσεις... Nearest = Κοντινότερο -Non-Buffered Rendering = &Παράκαμψη εφέ buffer (γρηγορότερο) +Skip Buffer Effects = &Παράκαμψη εφέ buffer (γρηγορότερο) Off = &Off Open Chat = Open Chat Open Directory... = Άνοιγμα Φακέλου... @@ -473,7 +472,6 @@ BlockTransfer Tip = Ορισμένα παιχνίδια απαιτούν να ε BlockTransferRequired = Προειδοποίηση: Αυτό το παιχνίδι απαιτεί τη λειτουργία προσομοίωσης εφέ μεταφοράς block να είναι ενεργοποιημένη. Both = Όλα Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Απεικόνιση με Buffer BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Πρέπει να επανεκκινήσετε το PPSSPP για Native device resolution = Χρήση ανάλυσης συσκευής Nearest = Κοντινότερο No buffer = No buffer -Non-Buffered Rendering = Παράκαμψη εφέ buffer (γρηγορότερο) +Skip Buffer Effects = Παράκαμψη εφέ buffer (γρηγορότερο) None = Καμία Number of Frames = Number of frames Off = Ανενεργό diff --git a/assets/lang/he_IL.ini b/assets/lang/he_IL.ini index eea8766876..f7878259cd 100644 --- a/assets/lang/he_IL.ini +++ b/assets/lang/he_IL.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &מאגר מעובד Buy Gold = Buy &Gold Control Mapping... = C&ontrol Mapping... Debugging = ניפ&וי @@ -173,7 +172,7 @@ Log Console = &התחבר לקונסולה Memory View... = הצג &זיכרון... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = פתח &קובץ... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = שניהם Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = מאגר מעובד BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = הקרוב ביותר No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = אל תציג מונה Number of Frames = Number of frames Off = כבוי diff --git a/assets/lang/he_IL_invert.ini b/assets/lang/he_IL_invert.ini index 81da08b1d1..ca5a52c0e7 100644 --- a/assets/lang/he_IL_invert.ini +++ b/assets/lang/he_IL_invert.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Buy &Gold Control Mapping... = C&ontrol Mapping... Debugging = Debu&g @@ -173,7 +172,7 @@ Log Console = &Log Console Memory View... = Memory &View... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = Open &Directory... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = םהינש Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = דבועמ רגאמ BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = רתויב בורקה No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = הנומ גיצת לא Number of Frames = Number of frames Off = יובכ diff --git a/assets/lang/hr_HR.ini b/assets/lang/hr_HR.ini index 5b212cf395..50bf5487c3 100644 --- a/assets/lang/hr_HR.ini +++ b/assets/lang/hr_HR.ini @@ -129,7 +129,6 @@ Backend = Poslužitelj &renderanja (restarta PPSSPP) Bicubic = &Bikubično Break = Pokvari Break on Load = Pokvari na učitavanju -Buffered Rendering = &Buffano prikazivanje Buy Gold = Kupi &Gold Control Mapping... = P&ostavljanje kontroli... Debugging = &Debug @@ -173,7 +172,7 @@ Log Console = &Konzola log-a Memory View... = Pregled &memorije... More Settings... = &Više postavki... Nearest = &Najbliže -Non-Buffered Rendering = &Preskoči bufferane efekte (non-buffered, faster) +Skip Buffer Effects = &Preskoči bufferane efekte Off = &Off Open Chat = Open Chat Open Directory... = Otvori &direktorij... @@ -473,7 +472,6 @@ BlockTransfer Tip = Neke igre zahtijevaju ovo na Uključeno za točne grafike BlockTransferRequired = Upozorenje: Ova igra zahtijeva "simulirajte blok transfer efekte" da budu postavljeni na Uključeno. Both = Oboje Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Ublaživanje prikaza BufferedRenderingRequired = Upozorenje: Ova igra zahtijeva "prikazni način" da bude postavljen na "ublaženo". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Morate ponovno pokrenuti PPSSPP da bi se efekat primjenio. Native device resolution = Urođena rezolucija uređaja Nearest = Najbliže No buffer = No buffer -Non-Buffered Rendering = Preskoči efekte ublaživanja (nije ublaženo, faster) +Skip Buffer Effects = Preskoči efekte ublaživanja (nije ublaženo, faster) None = Nijedna Number of Frames = Broj frame-ova Off = Isključeno diff --git a/assets/lang/hu_HU.ini b/assets/lang/hu_HU.ini index a18b33795f..6be4c6ef72 100644 --- a/assets/lang/hu_HU.ini +++ b/assets/lang/hu_HU.ini @@ -129,7 +129,6 @@ Backend = Renderelési &backend (újraindítás szükséges) Bicubic = &Bicubic Break = Megállítás Break on Load = Megállítás betöltéskor -Buffered Rendering = &Bufferelt renderelés Buy Gold = &Gold vásárlása Control Mapping... = &Gombok beállítása… Debugging = &Hibakeresés @@ -173,7 +172,7 @@ Log Console = &Napló ablak Memory View... = Memória &nézet… More Settings... = &Egyéb beállítások… Nearest = Leg&közelebbi -Non-Buffered Rendering = Bufferelt effektek kihagyá&sa (nem bufferelt, gyorsabb) +Skip Buffer Effects = Bufferelt effektek kihagyá&sa (nem bufferelt, gyorsabb) Off = &Ki Open Chat = Open Chat Open Directory... = Ma&ppa megnyitása… @@ -473,7 +472,6 @@ BlockTransfer Tip = Néhány játék számára ezt be kell kapcsolni ahhoz, hogy BlockTransferRequired = Figyelem: Ehhez a játékhoz be kell kapcsolni a "Blokk transzfer effektek szimulálása" opciót! Both = Mindkettő Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Bufferelt renderelés BufferedRenderingRequired = Figyelem: Ehhez a játékhoz a "Renderelési mód" beállítást "Bufferelt"-re kell állítani! Camera = Kamera Camera Device = Kamera eszköz @@ -525,7 +523,7 @@ Must Restart = A beállítások érvénybeléptetéséhez újra kell indítani a Native device resolution = Natív készülék felbontás Nearest = Legközelebbi No buffer = No buffer -Non-Buffered Rendering = Buffer effektek kihagyása (nem bufferelt, gyorsabb) +Skip Buffer Effects = Buffer effektek kihagyása (nem bufferelt, gyorsabb) None = Nincs Number of Frames = Képkockák száma Off = Ki diff --git a/assets/lang/id_ID.ini b/assets/lang/id_ID.ini index bfc1724aa4..ce169cedad 100644 --- a/assets/lang/id_ID.ini +++ b/assets/lang/id_ID.ini @@ -129,7 +129,6 @@ Backend = Bangun pelukisan &penyangga grafis (mulai ulang PPSSPP) Bicubic = &Bikubik Break = Rusak Break on Load = Rusak pada pemuatan -Buffered Rendering = Pelukisan tersangga Buy Gold = Beli versi &Emas Control Mapping... = Pemetaan k&ontrol... Debugging = Awakutu @@ -173,7 +172,7 @@ Log Console = Konso&l pencatat Memory View... = Tampilan memori... More Settings... = Pengaturan lainnya... Nearest = Terdekat -Non-Buffered Rendering = Lewati efek penyangga (tak-tersangga, lebih cepat) +Skip Buffer Effects = Lewati efek penyangga (tak-tersangga, lebih cepat) Off = Mati Open Chat = Buka opsi obrolan Open Directory... = Buka &direktori... @@ -473,7 +472,6 @@ BlockTransfer Tip = Beberapa permainan memerlukan opsi ini untuk menghindari kes BlockTransferRequired = Peringatan: Permainan ini membutuhkan "Simulasikan efek transfer blok" dalam keadaan menyala. Both = Keduanya Buffer graphics commands (faster, input lag) = Perintah grafis penyangga (lebih cepat, masukan lag) -Buffered Rendering = Pelukisan tersangga BufferedRenderingRequired = Peringatan: Permainan ini membutuhkan "Mode pelukisan" yang ditetapkan "Penyangga". Camera = Kamera Camera Device = Kamera perangkat @@ -525,7 +523,7 @@ Must Restart = Anda harus memulai ulang PPSSPP agar perubahan ini berfungsi. Native device resolution = Resolusi asli Nearest = Terdekat No buffer = Tidak ada penyangga -Non-Buffered Rendering = Lewati efek penyangga (tak tersangga, lebih cepat) +Skip Buffer Effects = Lewati efek penyangga (tak tersangga, lebih cepat) None = Tidak ada Number of Frames = Nomor laju bingkai Off = Mati diff --git a/assets/lang/it_IT.ini b/assets/lang/it_IT.ini index 10453b2a13..e16911851f 100644 --- a/assets/lang/it_IT.ini +++ b/assets/lang/it_IT.ini @@ -129,7 +129,6 @@ Backend = Rendering di fondo (riavvia il PPSSPP) Bicubic = Bicubico Break = Interruzione Break on Load = Fermati al caricamento -Buffered Rendering = Rendering con buffer Buy Gold = Acquista la Versione Gold Control Mapping... = Impostazioni dei Controlli... Debugging = Debug @@ -173,7 +172,7 @@ Log Console = Log Console Memory View... = Visualizzazione Memoria... More Settings... = Altre Impostazioni... Nearest = Pixel perfect -Non-Buffered Rendering = Salta effetti di buffer (niente buffer, più velocità) +Skip Buffer Effects = Salta effetti di buffer (niente buffer, più velocità) Off = Disattiva Open Chat = Apri Chat Open Directory... = Apri Cartella... @@ -473,7 +472,6 @@ BlockTransfer Tip = Alcuni giochi richiedono che quest'opzione sia attiva per co BlockTransferRequired = Attenzione: Questo gioco richiede l'attivazione di 'Simula gli effetti del blocco trasferimento'. Both = Entrambi Buffer graphics commands (faster, input lag) = Comandi grafici bufferizzati (più rapido, più lag dei comandi) -Buffered Rendering = Rendering in buffer BufferedRenderingRequired = Attenzione: Questo gioco richiede di impostare "modalità di rendering" su "buffered". Camera = Telecamera Camera Device = Dispositivo di telecamera @@ -526,7 +524,7 @@ Must Restart = Sarà necessario riavviare PPSSPP per attivare le modifiche. Native device resolution = Risoluzione nativa della periferica Nearest = Pixel perfect No buffer = Niente buffer -Non-Buffered Rendering = Salta effetti di buffer (niente buffer, più velocità) +Skip Buffer Effects = Salta effetti di buffer (niente buffer, più velocità) None = Nessuno Number of Frames = Numero di Frames Off = Disattiva diff --git a/assets/lang/ja_JP.ini b/assets/lang/ja_JP.ini index dfe1a86e3a..9df017b836 100644 --- a/assets/lang/ja_JP.ini +++ b/assets/lang/ja_JP.ini @@ -129,7 +129,6 @@ Backend = バックエンド(&B) Bicubic = Bicubic(&B) Break = ブレーク Break on Load = ロード時にブレーク -Buffered Rendering = バッファレンダリング(&B) Buy Gold = Gold版を購入(&G) Control Mapping... = キーマッピング(入力ボタン設定)(&O)... Debugging = デバッグ(&D) @@ -173,7 +172,7 @@ Log Console = ログコンソール(&L) Memory View... = メモリビュー(&V)... More Settings... = 詳細設定(&M)... Nearest = &Nearest -Non-Buffered Rendering = ノンバッファレンダリング (高速化)(&S) +Skip Buffer Effects = ノンバッファレンダリング (高速化)(&S) Off = オフ(&O) Open Chat = Open Chat Open Directory... = ディレクトリを開く(&D)... @@ -473,7 +472,6 @@ BlockTransfer Tip = オンにしないと正しく表示できないゲームが BlockTransferRequired = 警告: このゲームは「ブロック転送の効果をシミュレートする」をオンにする必要があります。 Both = 両方 Buffer graphics commands (faster, input lag) = グラフィックスコマンドをバッファする (高速, 入力ラグあり) -Buffered Rendering = バッファレンダリング BufferedRenderingRequired = 警告: このゲームは「レンダリングモード」を「バッファ」にする必要があります。 Camera = カメラの設定 Camera Device = カメラデバイスの選択 @@ -525,7 +523,7 @@ Must Restart = この変更を適用するにはPPSSPPを再起動してくだ Native device resolution = 機器のネイティブ解像度 Nearest = Nearest No buffer = バッファなし -Non-Buffered Rendering = ノンバッファレンダリング (高速化) +Skip Buffer Effects = ノンバッファレンダリング (高速化) None = なし Number of Frames = フレーム数 Off = オフ diff --git a/assets/lang/jv_ID.ini b/assets/lang/jv_ID.ini index da4130fb2b..79220cf2ea 100644 --- a/assets/lang/jv_ID.ini +++ b/assets/lang/jv_ID.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Yakuwi Rendering Buy Gold = Tuku &Gold Control Mapping... = Pemetaan Kontrol ... Debugging = Debu&g @@ -173,7 +172,7 @@ Log Console = &Konsol Log Memory View... = Tampilan &Memory... More Settings... = Setelan sing luwih ... Nearest = &Nearest -Non-Buffered Rendering = Skip efek buffer (ora yakuwi,luwih cepet) +Skip Buffer Effects = Skip efek buffer (ora yakuwi,luwih cepet) Off = &Mati Open Chat = Open Chat Open Directory... = Mbukak &Direktori... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Kelorone Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Yakuwi Rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Wiwiti maneh PPSSPP kanggo aplikasi setelan. Native device resolution = Resolusi piranti asal Nearest = Cedhak No buffer = No buffer -Non-Buffered Rendering = Skip efek buffer (non-yakuwi,luwih cepet) +Skip Buffer Effects = Skip efek buffer (non-yakuwi,luwih cepet) None = Ora ana Number of Frames = Number of frames Off = Pateni diff --git a/assets/lang/ko_KR.ini b/assets/lang/ko_KR.ini index 0cdd1a11e3..4178d83ec4 100644 --- a/assets/lang/ko_KR.ini +++ b/assets/lang/ko_KR.ini @@ -129,7 +129,6 @@ Backend = 렌더링 백엔드(&B) (PPSSPP 재시작) Bicubic = 고등차수보간(&B) Break = 증딘 Break on Load = 불러오기 시 중단 -Buffered Rendering = 버퍼링된 렌더링(&B) Buy Gold = 골드 버전 구매(&G) Control Mapping... = 제어 맵핑(&O)... Debugging = 디버그(&D) @@ -173,7 +172,7 @@ Log Console = 콘솔 로그(&L) Memory View... = 메모리 보기(&V)... More Settings... = 기타 설정(&M)... Nearest = 근접 필터링(&N) -Non-Buffered Rendering = 버퍼 효과 건너뛰기(버퍼되지 않음, 더 빠름)(&S) +Skip Buffer Effects = 버퍼 효과 건너뛰기(버퍼되지 않음, 더 빠름)(&S) Off = 끔(&O) Open Chat = 채팅 열기 Open Directory... = 디렉터리 열기(&D)... @@ -473,7 +472,6 @@ BlockTransfer Tip = 일부 게임에서는 올바른 그래픽을 위해 이 기 BlockTransferRequired = 경고: 이 게임은 "블록 전송 효과 시뮬레이션"을 켬으로 설정해야 합니다. Both = 둘 다 Buffer graphics commands (faster, input lag) = 버퍼 그래픽 명령 (빠름, 입력 지연) -Buffered Rendering = 버퍼링된 렌더링 BufferedRenderingRequired = 경고: 이 게임은 "렌더링 모드"를 "버퍼링"으로 설정해야 합니다. Camera = 카메라 Camera Device = 카메라 장치 @@ -524,7 +522,7 @@ Must Restart = 이 변경 사항을 적용하려면 PPSSPP를 다시 시작해 Native device resolution = 기본 장치 해상도 Nearest = 근접 필터링 No buffer = 버퍼 없음 -Non-Buffered Rendering = 버퍼 효과 건너뛰기(버퍼되지 않음, 더 빠름) +Skip Buffer Effects = 버퍼 효과 건너뛰기(버퍼되지 않음, 더 빠름) None = 없음 Number of Frames = 프레임 수 Off = 끔 diff --git a/assets/lang/lo_LA.ini b/assets/lang/lo_LA.ini index 1409815abc..9dc2bb3fa8 100644 --- a/assets/lang/lo_LA.ini +++ b/assets/lang/lo_LA.ini @@ -129,7 +129,6 @@ Backend = &ການສະແດງຜົນທີ່ສະໜັບສະໜຸ Bicubic = &ປັບພາບແບບ Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = ການສະແດງຜົນແບບໃຊ້ ບັບເຟີ້ Buy Gold = & ຊື້ແບບ Gold Control Mapping... = &ແຜງຄວບຄຸມ... Debugging = &ແກ້ໄຂຈຸດບົກພ່ອງ @@ -173,7 +172,7 @@ Log Console = &ເກັບຄ່າຄອນໂຊລ Memory View... = &ມຸມມອງຄ່າຄວາມຈຳ... More Settings... = &ການຕັ້ງຄ່າອື່ນໆ... Nearest = &ພາບເປັນຮອຍຍັກໄດ້ -Non-Buffered Rendering = &ຂ້າມການໃຊ້ເອັບເຟັກບັບເຟີ້ (ບໍ່ມີບັບເຟີ້, ໄວຂຶ້ນ) +Skip Buffer Effects = &ຂ້າມການໃຊ້ເອັບເຟັກບັບເຟີ້ (ບໍ່ມີບັບເຟີ້, ໄວຂຶ້ນ) Off = &ປິດ Open Chat = Open Chat Open Directory... = &ເປີດໄດເຣກທໍຣີ... @@ -473,7 +472,6 @@ BlockTransfer Tip = ບາງເກມຕ້ອງເປີດໃຊ້ງານ BlockTransferRequired = ຄຳເຕືອນ: ເກມນີ້ຕ້ອງການໃຫ້ເປີດໂໝດ "ຈຳລອງຜົນປິດກັ້ນການສົ່ງຜ່ານຂໍ້ມູນເອັບເຟກ" ນຳ Both = ໃຊ້ທັງ FPS ແລະ Speed Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = ການສະແດງຜົນແບບໃຊ້ບັບເຟີ້ BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = ເຈົ້າຄວນເລີ່ມ PPSSPP ໃໝ່ເພື Native device resolution = ຄ່າຄວາມລະອຽດດັ້ງເດີມຂອງອຸປະກອນ Nearest = Nearest No buffer = No buffer -Non-Buffered Rendering = ຂ້າມການໃຊ້ບັບເຟີເອັບເຟກ (ບໍ່ໃຊ້ບັບເຟີ, ໄວຂຶ້ນ) +Skip Buffer Effects = ຂ້າມການໃຊ້ບັບເຟີເອັບເຟກ (ບໍ່ໃຊ້ບັບເຟີ, ໄວຂຶ້ນ) None = ບໍ່ມີ Number of Frames = Number of frames Off = ປິດ diff --git a/assets/lang/lt-LT.ini b/assets/lang/lt-LT.ini index aff20af2e2..6d54606a83 100644 --- a/assets/lang/lt-LT.ini +++ b/assets/lang/lt-LT.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Nusipirkti &Gold Control Mapping... = Va&ldymo mygtukų keitimas... Debugging = &Ekspermentas @@ -173,7 +172,7 @@ Log Console = "&Statuso" konsolė Memory View... = Atminties &rodymas... More Settings... = &Daugiau parametrų... Nearest = &Arčiausias -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Išjungti Open Chat = Open Chat Open Directory... = Atidaryti &vietą... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Abu Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buferinis rodymas BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Jūs turite perkrauti "PPSSPP" programą, kad pakeisti parametrai Native device resolution = Įrenginio rezoliucija Nearest = Arčiausias No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Nieko Number of Frames = Number of frames Off = Išjungti diff --git a/assets/lang/ms_MY.ini b/assets/lang/ms_MY.ini index 3cd85dd7c4..e785b696e3 100644 --- a/assets/lang/ms_MY.ini +++ b/assets/lang/ms_MY.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bikubik Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Beli ve&rsi Gold Control Mapping... = P&emetaan kawalan... Debugging = &Pepijat @@ -173,7 +172,7 @@ Log Console = &Log Konsol Memory View... = Lihat &Memori... More Settings... = &Tetapan lanjutan... Nearest = &Terdekat -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Tutup Open Chat = Open Chat Open Directory... = Buka &Penyimpanan... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Keduanya Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffered rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Terdekat No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Tiada Number of Frames = Number of frames Off = Tutup diff --git a/assets/lang/nl_NL.ini b/assets/lang/nl_NL.ini index 9b8c2cef4a..f9b4823c0d 100644 --- a/assets/lang/nl_NL.ini +++ b/assets/lang/nl_NL.ini @@ -129,7 +129,6 @@ Backend = &Renderbackend (herstart PPSSPP) Bicubic = &Bicubisch Break = Break Break on Load = Break on load -Buffered Rendering = &Gebufferde weergave Buy Gold = Gold &kopen Control Mapping... = Bestur&ing toewijzen... Debugging = &Fouten opsporen @@ -173,7 +172,7 @@ Log Console = Logboek&console Memory View... = &Geheugenweergave... More Settings... = &Meer instellingen... Nearest = &Naaste buur -Non-Buffered Rendering = &Buffereffecten nalaten (niet-gebufferd, sneller) +Skip Buffer Effects = &Buffereffecten nalaten (niet-gebufferd, sneller) Off = &Uit Open Chat = Open Chat Open Directory... = &Map openen... @@ -473,7 +472,6 @@ BlockTransfer Tip = Sommige games vereisen dat deze optie aan staat voor juiste BlockTransferRequired = Waarschuwing: Deze game vereist de optie Blokoverdrachteffecten simuleren. Both = Beide Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Gebufferde weergave BufferedRenderingRequired = Waarschuwing: Deze game vereist een "gebufferde renderingmodus". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = U moet PPSSPP herstarten om de wijzigingen door te voeren. Native device resolution = Apparaatresolutie Nearest = Naaste buur No buffer = No buffer -Non-Buffered Rendering = Buffereffecten nalaten (niet-gebufferd, sneller) +Skip Buffer Effects = Buffereffecten nalaten (niet-gebufferd, sneller) None = Geen Number of Frames = Number of frames Off = Uit diff --git a/assets/lang/no_NO.ini b/assets/lang/no_NO.ini index 132178a7e6..d18cfb601e 100644 --- a/assets/lang/no_NO.ini +++ b/assets/lang/no_NO.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Buy &Gold Control Mapping... = C&ontrol Mapping... Debugging = &Debug @@ -173,7 +172,7 @@ Log Console = &Log Console Memory View... = Memory &View... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = Open &Directory... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Begge Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffrad rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = You must restart PPSSPP for this change to take effect. Native device resolution = Native device resolution Nearest = Nermest No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Ingen Number of Frames = Number of frames Off = Off diff --git a/assets/lang/pl_PL.ini b/assets/lang/pl_PL.ini index 82a63c4757..3afd586155 100644 --- a/assets/lang/pl_PL.ini +++ b/assets/lang/pl_PL.ini @@ -129,7 +129,6 @@ Backend = &Sterownik obrazu (Restartuje PPSSPP) Bicubic = Bicubic (Dwusześcienne) Break = Zatrzymaj Break on Load = Zatrzymaj po załadowaniu -Buffered Rendering = Renderowanie buforowe Buy Gold = Kup wersję Gold Control Mapping... = Ustawienia przycisków... Debugging = &Debugowanie @@ -173,7 +172,7 @@ Log Console = Konsola dziennika zdarzeń Memory View... = Podgląd pamięci... More Settings... = Więcej ustawień... Nearest = Najbliższe -Non-Buffered Rendering = &Nie renderuj efektów z bufora (niebuforowane, szybsze) +Skip Buffer Effects = &Nie renderuj efektów z bufora (niebuforowane, szybsze) Off = Wyłącz Open Chat = Otwórz Chat Open Directory... = Otwórz katalog... @@ -473,7 +472,6 @@ BlockTransfer Tip = Niektóre gry wymagają włączenia tej opcji do poprawnego BlockTransferRequired = Uwaga: Ta gra wymaga włączonej opcji "Symuluj efekty transferu bloków". Both = Oba Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Renderowanie buforowe BufferedRenderingRequired = Uwaga: Ta gra wymaga włączonej opcji "Renderowanie buforowe". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Musisz zrestartować PPSSPP, aby zobaczyć zmiany. Native device resolution = Natywna rozdzielczość urządzenia Nearest = Najbliższe No buffer = No buffer -Non-Buffered Rendering = Nie renderuj efektów z bufora (niebuforowane, szybsze) +Skip Buffer Effects = Nie renderuj efektów z bufora (niebuforowane, szybsze) None = Wył. Number of Frames = Ilość klatek Off = Wył. diff --git a/assets/lang/pt_BR.ini b/assets/lang/pt_BR.ini index 952c540f0b..40d08c1294 100644 --- a/assets/lang/pt_BR.ini +++ b/assets/lang/pt_BR.ini @@ -153,7 +153,6 @@ Backend = Backend de &renderização (Reinicia o PPSSPP) Bicubic = &Bi-cúbico Break = Parar Break on Load = Parar ao carregar -Buffered Rendering = &Renderização com buffer Buy Gold = Comprar &Gold Control Mapping... = M&apeamento dos controles... Debugging = &Debug @@ -197,7 +196,7 @@ Log Console = &Console dos logs Memory View... = Visualização da &memória... More Settings... = &Mais configurações... Nearest = &Mais próximo -Non-Buffered Rendering = &Ignorar efeitos do buffer (sem buffer, mais rápido) +Skip Buffer Effects = &Ignorar efeitos do buffer (sem buffer, mais rápido) Off = &Desligado Open Chat = Abrir Bate-Papo Open Directory... = Abrir &diretório... @@ -497,7 +496,6 @@ BlockTransfer Tip = Alguns jogos requerem que isto esteja Ligado pros gráficos BlockTransferRequired = Aviso: Esse jogo requer que a "simulação dos efeitos de transferência dos blocos" esteja definida como Ligada. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer dos comandos dos gráficos (mais rápido, atraso na entrada dos dados) -Buffered Rendering = Renderização com buffer BufferedRenderingRequired = Aviso: Este jogo requer que o "modo de renderização" esteja definido "com buffer". Camera = Câmera Camera Device = Dispositivo de câmera @@ -548,7 +546,7 @@ Must Restart = Você deve reiniciar o PPSSPP pra esta mudança ter efeito. Native device resolution = Resolução nativa do dispositivo Nearest = Mais próximo No buffer = Sem buffer -Non-Buffered Rendering = Ignorar efeitos do buffer (sem buffer, mais rápido) +Skip Buffer Effects = Ignorar efeitos do buffer (sem buffer, mais rápido) None = Nenhum Number of Frames = Número de frames Off = Desligado diff --git a/assets/lang/pt_PT.ini b/assets/lang/pt_PT.ini index 3027a3c81e..298880849e 100644 --- a/assets/lang/pt_PT.ini +++ b/assets/lang/pt_PT.ini @@ -153,7 +153,6 @@ Backend = API de &renderização (Reinicia o PPSSPP) Bicubic = &Bi-cúbico Break = Parar Break on Load = Parar ao carregar -Buffered Rendering = &Renderização com buffer Buy Gold = Comprar &Gold Control Mapping... = M&apeamento dos controlos... Debugging = &Depurar @@ -197,7 +196,7 @@ Log Console = &Console dos Logs Memory View... = Visualização da &memória... More Settings... = &Mais Definições... Nearest = &Mais próximo -Non-Buffered Rendering = &Ignorar efeitos do buffer (sem buffer, mais rápido) +Skip Buffer Effects = &Ignorar efeitos do buffer (sem buffer, mais rápido) Off = &Desligado Open Chat = Abrir Bate-Papo Open Directory... = Abrir &Diretório... @@ -497,7 +496,6 @@ BlockTransfer Tip = Alguns jogos requerem que esta opção esteja habilitada par BlockTransferRequired = Aviso: Este jogo requer que a "Simulação dos Efeitos de Transferência dos Blocos" esteja habilitada. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer dos Comandos Gráficos (mais rápido, atraso na entrada dos dados) -Buffered Rendering = Renderização com Buffer BufferedRenderingRequired = Aviso: Este jogo requer que o "modo de renderização" esteja definido "com buffer". Camera = Câmera Camera Device = Dispositivo de câmera @@ -548,7 +546,7 @@ Must Restart = Deverás reiniciar o PPSSPP para esta mudança ter efeito. Native device resolution = Resolução Nativa do Dispositivo Nearest = Mais próximo No buffer = Sem buffer -Non-Buffered Rendering = Ignorar efeitos do buffer (sem buffer, mais rápido) +Skip Buffer Effects = Ignorar efeitos do buffer (sem buffer, mais rápido) None = Nenhum Number of Frames = Número de quadros Off = Desligado diff --git a/assets/lang/ro_RO.ini b/assets/lang/ro_RO.ini index 055ff8f9ff..e6491a68e2 100644 --- a/assets/lang/ro_RO.ini +++ b/assets/lang/ro_RO.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = &Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = &Buffered Rendering Buy Gold = Buy &Gold Control Mapping... = C&ontrol Mapping... Debugging = &Debug @@ -173,7 +172,7 @@ Log Console = &Log Console Memory View... = Memory &View... More Settings... = &More Settings... Nearest = &Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = &Off Open Chat = Open Chat Open Directory... = Open &Directory... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Ambele Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Afișare cu stocare BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Trebuie să resartezi PPSSPP pt. ca această schimbare să aibă Native device resolution = Rezoluție nativă dispozitiv Nearest = Apropiată No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects None = Fără Number of Frames = Number of frames Off = Oprit diff --git a/assets/lang/ru_RU.ini b/assets/lang/ru_RU.ini index d3c867b2fe..28548faa8a 100644 --- a/assets/lang/ru_RU.ini +++ b/assets/lang/ru_RU.ini @@ -129,7 +129,6 @@ Backend = Бэкенд &рендеринга (нужен перезапуск) Bicubic = &Бикубическое Break = Остановить Break on Load = Остановить после загрузки -Buffered Rendering = &Буферированный рендеринг Buy Gold = Купить &Gold Control Mapping... = Назначение &кнопок... Debugging = &Отладка @@ -173,7 +172,7 @@ Log Console = Консоль отладки Memory View... = Просмотрщик па&мяти... More Settings... = &Ещё настройки... Nearest = &Ближайший -Non-Buffered Rendering = &Пропускать эффекты (небуферированный, быстрее) +Skip Buffer Effects = &Пропускать эффекты (небуферированный, быстрее) Off = В&ыключено Open Chat = Открыть чат Open Directory... = Открыть &папку... @@ -473,7 +472,6 @@ BlockTransfer Tip = Требуется для корректной график BlockTransferRequired = Предупреждение: для этой игры требуется включить "Симуляцию эффектов от передачи блоков" Both = Оба Buffer graphics commands (faster, input lag) = Команды буферированной графики (быстрее, задержка ввода) -Buffered Rendering = Буферированный рендеринг BufferedRenderingRequired = Предупреждение: для этой игры требуется буферированный режим рендеринга. Camera = Камера Camera Device = Устройство камеры @@ -526,7 +524,7 @@ Must Restart = Вы должны перезапустить PPSSPP, чтобы Native device resolution = Разрешение устройства Nearest = Ближайший No buffer = Нет буфера -Non-Buffered Rendering = Пропускать эффекты (небуферированный) +Skip Buffer Effects = Пропускать эффекты (небуферированный) None = Выключено Number of Frames = Количество кадров Off = Выключено diff --git a/assets/lang/sv_SE.ini b/assets/lang/sv_SE.ini index d4bedc6d5f..2bf12a4af4 100644 --- a/assets/lang/sv_SE.ini +++ b/assets/lang/sv_SE.ini @@ -129,7 +129,6 @@ Backend = Backend Bicubic = Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = Buffrad rendering Buy Gold = Buy Gold Control Mapping... = Kontrollmappning... Debugging = Debuggning @@ -173,7 +172,7 @@ Log Console = Loggkonsol Memory View... = Minnesvy... More Settings... = Mer inställningar... Nearest = Nearest -Non-Buffered Rendering = &Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = &Skip buffer effects Off = Off Open Chat = Open Chat Open Directory... = Öppna mapp... @@ -473,7 +472,6 @@ BlockTransfer Tip = Vissa spel kräver att denna inställning är på. BlockTransferRequired = Varning: Detta spel kräver att "Simulera blocktransfer-effekter" är påslaget. Both = Båda Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffrad rendering BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". Camera = Kamera Camera Device = Kamera-enhet @@ -525,7 +523,7 @@ Must Restart = Starta om PPSSPP för att ändringen ska få effekt. Native device resolution = Native device resolution Nearest = Närmast No buffer = No buffer -Non-Buffered Rendering = Skippa buffereffekter (snabbare, risk för fel) +Skip Buffer Effects = Skippa buffereffekter (snabbare, risk för fel) None = Inget Number of Frames = Antal frames Off = Off diff --git a/assets/lang/tg_PH.ini b/assets/lang/tg_PH.ini index 1dca37dcc5..63c37442f1 100644 --- a/assets/lang/tg_PH.ini +++ b/assets/lang/tg_PH.ini @@ -129,7 +129,6 @@ Backend = Rendering &Backend (Restarts PPSSPP) Bicubic = Bicubic Break = Break Break on Load = Break on load -Buffered Rendering = Buffered Rendering Buy Gold = Bilhin ang Gold Control Mapping... = Control Mapping... Debugging = Debug @@ -173,7 +172,7 @@ Log Console = Log Console Memory View... = Memory View... More Settings... = Karagdagang settings... Nearest = Nearest -Non-Buffered Rendering = Skip buffer effects (non-buffered, faster) +Skip Buffer Effects = Skip buffer effects Off = Off Open Chat = Open Chat Open Directory... = Buksan ang Directory... @@ -473,7 +472,6 @@ BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = BABALA: This game requires "simulate block transfer effects" to be set to On. Both = Pareho Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Buffered Rendering BufferedRenderingRequired = BABALA: This game requires "rendering mode" to be set to "buffered". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Kailangan i-restart ang PPSSPP upang maging epiktibo ito Native device resolution = Native device resolution Nearest = Pinakamalapit No buffer = No buffer -Non-Buffered Rendering = Skip buffer effects (non-buffered, mabilis) +Skip Buffer Effects = Skip buffer effects (non-buffered, mabilis) None = Wala Number of Frames = Bilang ng frames Off = Patayin diff --git a/assets/lang/th_TH.ini b/assets/lang/th_TH.ini index 6cdb15874c..4b0d42f964 100644 --- a/assets/lang/th_TH.ini +++ b/assets/lang/th_TH.ini @@ -129,7 +129,6 @@ Backend = การแสดงผลที่สนับสนุน (ต้ Bicubic = ไบคิวบิค Break = หยุด Break on Load = หยุดเมื่อโหลด -Buffered Rendering = การแสดงผลแบบใช้บัฟเฟอร์ Buy Gold = ซื้อแบบตัวสีทอง Control Mapping... = แผงปรับการคุมควบ... Debugging = แก้ไขจุดบกพร่อง @@ -173,7 +172,7 @@ Log Console = เก็บค่าคอนโซล Memory View... = มุมมองค่าความจำ... More Settings... = การตั้งค่าอื่นๆ... Nearest = แบบใกล้เคียง -Non-Buffered Rendering = ข้ามการใช้บัฟเฟอร์เอฟเฟ็คท์ (ปิดบัฟเฟอร์) +Skip Buffer Effects = ข้ามการใช้บัฟเฟอร์เอฟเฟ็คท์ (ปิดบัฟเฟอร์) Off = ปิด Open Chat = เปิดหน้าต่างแชท Open Directory... = เปิดแหล่งที่เก็บ... @@ -473,7 +472,6 @@ BlockTransfer Tip = บางเกมจำเป็นต้องเปิด BlockTransferRequired = คำเตือน: เกมนี้ต้องปรับใช้งาน "จำลองผลปิดกั้นการส่งผ่านข้อมูลเอฟเฟ็คท์" ด้วย Both = ใช้ทั้งคู่ Buffer graphics commands (faster, input lag) = ควบคุมกราฟิกบัฟเฟอร์ (เร็วขึ้น, อาจทำให้เกิดอินพุตแล็ก) -Buffered Rendering = การแสดงผลแบบใช้บัฟเฟอร์ BufferedRenderingRequired = คำเตือน: เกมนี้ต้องปรับใช้งานในโหมด "การแสดงผลแบบใช้บัฟเฟอร์" Camera = กล้อง Camera Device = กล้องที่พร้อมใช้งาน @@ -525,7 +523,7 @@ Must Restart = คุณควรรีสตาร์ท PPSSPP อีกคร Native device resolution = ค่าความละเอียดดั้งเดิมของอุปกรณ์ Nearest = แบบใกล้เคียง No buffer = ไม่ใช้บัฟเฟอร์ -Non-Buffered Rendering = ข้ามการใช้บัฟเฟอร์เอฟเฟ็คท์ (ปิดบัฟเฟอร์) +Skip Buffer Effects = ข้ามการใช้บัฟเฟอร์เอฟเฟ็คท์ (ปิดบัฟเฟอร์) None = ไม่มี Number of Frames = อิงจากค่าจำนวนเฟรม Off = ปิด diff --git a/assets/lang/tr_TR.ini b/assets/lang/tr_TR.ini index 4a98ecfeb9..bcca5aeff4 100644 --- a/assets/lang/tr_TR.ini +++ b/assets/lang/tr_TR.ini @@ -131,7 +131,6 @@ Backend = Oluşturma &Arkaucu (PPSSPP'yi yeniden başlatır) Bicubic = &Bikübik Break = Break Break on Load = Break on load -Buffered Rendering = &Tampon bellek ile oluştur Buy Gold = Altın Sürümünü Satın Al Control Mapping... = Kontrol Ayarlama... Debugging = &Hata Ayıklama @@ -175,7 +174,7 @@ Log Console = &Günlük Konsolu Memory View... = Bellek &Görünümü... More Settings... = &Daha Fazla Ayar... Nearest = &En Yakın -Non-Buffered Rendering = &Arabellek efektlerini atla (arabelleğe alınmaz, daha hızlıdır) +Skip Buffer Effects = &Arabellek efektlerini atla (arabelleğe alınmaz, daha hızlıdır) Off = &Kapalı Open Chat = Open Chat Open Directory... = Dizin Aç... @@ -475,7 +474,6 @@ BlockTransfer Tip = Bazı oyunlarda doğru grafikler için bu ayarın açık olm BlockTransferRequired = Uyarı: Bu oyun Blok Aktarım Simülasyon Modunun Açık olmasını gerektirir. Both = İkisi de Buffer graphics commands (faster, input lag) = Grafik komutlarını arabellekle (daha hızlı, input lag'e sebep olabilir) -Buffered Rendering = Yükleyerek işleme BufferedRenderingRequired = Uyarı: Bu oyun "işleme modunun" "yükleyerek işleme"ye alınmasını gerektirir. Camera = Kamera Camera Device = Kamera cihazı @@ -528,7 +526,7 @@ Must Restart = Bu değişikliğin uygulanması için PPSSPP'yi yeniden başlatma Native device resolution = Yerel aygıt çözünürlüğü Nearest = En yakın No buffer = Arabellek/tampon bellek yok -Non-Buffered Rendering = Arabellek efektlerini atla (arabelleğe alınmaz, daha hızlıdır) +Skip Buffer Effects = Arabellek efektlerini atla (arabelleğe alınmaz, daha hızlıdır) None = Hiçbiri Number of Frames = Kare sayısı Off = Kapalı @@ -1196,7 +1194,7 @@ YYYYMMDD = YYYYAAGG [TextureShaders] Off = Off TexMMPX = TexMMPX -Tex2xBRZ = Tex2xBRZ +Tex2xBRZ = Tex2xBRZ Tex4xBRZ = Tex4xBRZ [Themes] diff --git a/assets/lang/uk_UA.ini b/assets/lang/uk_UA.ini index b4581397ae..cde502baac 100644 --- a/assets/lang/uk_UA.ini +++ b/assets/lang/uk_UA.ini @@ -129,7 +129,6 @@ Backend = Бекенд &рендерингу (потрібне перезава Bicubic = &Бікубічний Break = Перервати Break on Load = Перервати при завантаженні -Buffered Rendering = Буферинізований рендеринг Buy Gold = Купити &Gold Control Mapping... = Призначення &кнопок... Debugging = &Налагодження @@ -173,7 +172,7 @@ Log Console = Консоль журналу (log) Memory View... = Переглядач па&м'яті... More Settings... = &Ще налаштування... Nearest = &Найближчий -Non-Buffered Rendering = &Пропустити ефекти (небуферований, швидше) +Skip Buffer Effects = &Пропустити ефекти (небуферований, швидше) Off = В&имкнено Open Chat = Open Chat Open Directory... = Відкрити &папку... @@ -473,7 +472,6 @@ BlockTransfer Tip = Потрібно для правильної графіки BlockTransferRequired = Попередження: Ця гра вимагає, щоб "імітувати ефекти передачі блоку" було встановлено на Увімкнено. Both = Обидва Buffer graphics commands (faster, input lag) = Буферні графічні команди (швидше, можливі глюки) -Buffered Rendering = Буферинізований рендеринг BufferedRenderingRequired = Попередження: Ця гра вимагає, щоб "режим візуалізації" був встановлений на "буферний". Camera = Камера Camera Device = Пристрій камери @@ -525,7 +523,7 @@ Must Restart = Ви повинні перезавантажити PPSSPP, щоб Native device resolution = Роздільна здатність пристрою Nearest = Найближчий No buffer = Без буфера -Non-Buffered Rendering = Пропускати ефекти (небуференізованний, швидше) +Skip Buffer Effects = Пропускати ефекти (небуференізованний, швидше) None = Немає Number of Frames = Кількість кадрів Off = Вимкнено diff --git a/assets/lang/vi_VN.ini b/assets/lang/vi_VN.ini index c1593c6c33..918bfc6e91 100644 --- a/assets/lang/vi_VN.ini +++ b/assets/lang/vi_VN.ini @@ -129,7 +129,6 @@ Backend = Kết xuất từ thư viện đồ họa (Khởi động lại PPSSPP Bicubic = Bicubic (mịn) Break = Break Break on Load = Hủy bỏ trong mục load -Buffered Rendering = Dựng hình có bộ nhớ đệm Buy Gold = Mua PPSSPP Gold Control Mapping... = Chỉnh nút... Debugging = Debug @@ -173,7 +172,7 @@ Log Console = Log Console Memory View... = Xem bộ nhớ... More Settings... = Các thiết lập khác... Nearest = Gần nhất -Non-Buffered Rendering = Bỏ qua hiệu ứng đệm (Không bộ nhớ đệm, nhanh hơn) +Skip Buffer Effects = Bỏ qua hiệu ứng đệm (Không bộ nhớ đệm, nhanh hơn) Off = Tắt Open Chat = Open Chat Open Directory... = Mở thư mục... @@ -473,7 +472,6 @@ BlockTransfer Tip = Một số trò chơi yêu cầu đồ họa thích hợp. BlockTransferRequired = Cảnh báo: Trò chơi này yêu cầu mở "simulate block transfer effects" Both = Cả hai Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) -Buffered Rendering = Dựng hình có bộ nhớ đệm BufferedRenderingRequired = Cảnh báo: Trò chơi này yêu cầu "chế độ kết xuất" được đặt thành "được đệm". Camera = Camera Camera Device = Camera device @@ -525,7 +523,7 @@ Must Restart = Bạn cần khởi động lại PPSSPP để những thay đổi Native device resolution = Độ phân giải tự nhiên. Nearest = Gần nhất No buffer = No buffer -Non-Buffered Rendering = Bỏ qua hiệu ứng đệm (không bộ nhớ đệm, nhanh hơn) +Skip Buffer Effects = Bỏ qua hiệu ứng đệm (không bộ nhớ đệm, nhanh hơn) None = Không Number of Frames = Number of frames Off = Tắt diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index 3d2682c3d6..42e4d780da 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -129,7 +129,6 @@ Backend = 渲染引擎(需要PPSSPP重新启动) (&b) Bicubic = 双三次 (&B) Break = 停止 Break on Load = 载入后停止 -Buffered Rendering = 缓冲渲染 (&B) Buy Gold = 购买黄金版 (&G) Control Mapping... = 按键映射 (&o)... Debugging = 调试 (&D) @@ -173,7 +172,7 @@ Log Console = 控制台日志 (&L) Memory View... = 查看内存 (&V)... More Settings... = 更多设置 (&M)... Nearest = 邻近取样 (&N) -Non-Buffered Rendering = 跳过缓冲效果(非缓冲, 更快) (&S) +Skip Buffer Effects = 跳过缓冲效果(非缓冲, 更快) (&S) Off = 关闭 (&O) Open Chat = 打开聊天 Open Directory... = 打开路径(&D)... @@ -473,7 +472,6 @@ BlockTransfer Tip = 有些游戏需要将此选项设置为开以显示正确的 BlockTransferRequired = 警告:此游戏需要将"模拟块传输模式"设置为开。 Both = 全部显示 Buffer graphics commands (faster, input lag) = 缓冲图形命令(更快, 有输入延迟) -Buffered Rendering = 缓冲渲染 BufferedRenderingRequired = 警告:此游戏需要将"渲染模式"设置为"缓冲渲染"。 Camera = 摄像头 Camera Device = 摄像头设备 @@ -525,7 +523,7 @@ Must Restart = 重启PPSSPP才能使这项设置生效。 Native device resolution = 本机原生的分辨率 Nearest = 邻近取样 No buffer = 不缓冲 -Non-Buffered Rendering = 跳过缓冲(更快) +Skip Buffer Effects = 跳过缓冲(更快) None = 不显示 Number of Frames = 帧的数量 Off = 关闭 diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 7b74b3e4a3..24b8553d7d 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -129,7 +129,6 @@ Backend = 轉譯後端 (需要重新啟動) (&b) Bicubic = 雙立方 (&B) Break = 中斷 Break on Load = 載入時中斷 -Buffered Rendering = 緩衝轉譯 (&B) Buy Gold = 購買黃金版 (&G) Control Mapping... = 控制對應 (&O)… Debugging = 偵錯 (&D) @@ -173,7 +172,7 @@ Log Console = 記錄主控台 (&L) Memory View... = 記憶體檢視 (&V)… More Settings... = 更多設定 (&M)… Nearest = 鄰近取樣 (&N) -Non-Buffered Rendering = 跳過緩衝區效果 (非緩衝區,更快) (&S) +Skip Buffer Effects = 跳過緩衝區效果 (非緩衝區,更快) (&S) Off = 關閉 (&O) Open Chat = 開啟聊天 Open Directory... = 開啟目錄 (&D)… @@ -473,7 +472,6 @@ BlockTransfer Tip = 部分遊戲需要開啟此項以顯示正確的圖形 BlockTransferRequired = 警告:這個遊戲需要開啟「模擬區塊傳輸效果」 Both = 全部 Buffer graphics commands (faster, input lag) = 緩衝圖形命令 (更快,有輸入延遲) -Buffered Rendering = 緩衝轉譯 BufferedRenderingRequired = 警告:這個遊戲需要將「轉譯模式」設為「緩衝轉譯」 Camera = 相機 Camera Device = 相機裝置 @@ -524,7 +522,7 @@ Must Restart = 您必須重新啟動 PPSSPP 以使這項變更生效 Native device resolution = 原生裝置解析度 Nearest = 鄰近取樣 No buffer = 無緩衝 -Non-Buffered Rendering = 跳過緩衝效果 (無緩衝,更快) +Skip Buffer Effects = 跳過緩衝效果 (無緩衝,更快) None = 無 Number of Frames = 影格數 Off = 關閉 @@ -863,9 +861,9 @@ tools = 使用的自由工具: # Add translators1-6 for up to 6 lines of translator credits. # Leave extra lines blank. 4 contributors per line seems to look best. translators1 = sum2012, xujibbs, leoxxx, Adeptus2 -translators2 = -translators3 = -translators4 = +translators2 = +translators3 = +translators4 = translators5 = translators6 = Twitter @PPSSPP_emu = Twitter @PPSSPP_emu diff --git a/headless/Headless.cpp b/headless/Headless.cpp index ff5c3f94b4..60c3baaa0f 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -420,7 +420,7 @@ int main(int argc, const char* argv[]) // Never report from tests. g_Config.sReportHost.clear(); g_Config.bAutoSaveSymbolMap = false; - g_Config.iRenderingMode = FB_BUFFERED_MODE; + g_Config.bSkipBufferEffects = false; g_Config.bHardwareTransform = true; g_Config.iAnisotropyLevel = 0; // When testing mipmapping we really don't want this. g_Config.bVertexCache = false; From c91e7912bfc7cf9407d9d345f7143ec23497bceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 19:30:17 +0100 Subject: [PATCH 366/374] Change "Simulate block transfer" to "Skip GPU Readbacks". Group the speed hacks together --- Core/Config.cpp | 2 +- Core/Config.h | 2 +- GPU/Common/FramebufferManagerCommon.cpp | 6 +- UI/EmuScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 90 +++++++++++-------------- assets/lang/ar_AE.ini | 1 - assets/lang/az_AZ.ini | 1 - assets/lang/bg_BG.ini | 1 - assets/lang/ca_ES.ini | 1 - assets/lang/cz_CZ.ini | 1 - assets/lang/da_DK.ini | 1 - assets/lang/de_DE.ini | 1 - assets/lang/dr_ID.ini | 1 - assets/lang/es_ES.ini | 1 - assets/lang/es_LA.ini | 1 - assets/lang/fa_IR.ini | 1 - assets/lang/fi_FI.ini | 1 - assets/lang/fr_FR.ini | 1 - assets/lang/gl_ES.ini | 1 - assets/lang/gr_EL.ini | 1 - assets/lang/he_IL.ini | 1 - assets/lang/he_IL_invert.ini | 1 - assets/lang/hr_HR.ini | 1 - assets/lang/hu_HU.ini | 1 - assets/lang/id_ID.ini | 1 - assets/lang/it_IT.ini | 1 - assets/lang/ja_JP.ini | 1 - assets/lang/jv_ID.ini | 1 - assets/lang/ko_KR.ini | 1 - assets/lang/lo_LA.ini | 1 - assets/lang/lt-LT.ini | 1 - assets/lang/ms_MY.ini | 1 - assets/lang/nl_NL.ini | 1 - assets/lang/no_NO.ini | 1 - assets/lang/pl_PL.ini | 1 - assets/lang/pt_BR.ini | 1 - assets/lang/pt_PT.ini | 1 - assets/lang/ro_RO.ini | 1 - assets/lang/ru_RU.ini | 1 - assets/lang/sv_SE.ini | 1 - assets/lang/tg_PH.ini | 1 - assets/lang/th_TH.ini | 1 - assets/lang/tr_TR.ini | 1 - assets/lang/uk_UA.ini | 1 - assets/lang/vi_VN.ini | 1 - assets/lang/zh_CN.ini | 1 - assets/lang/zh_TW.ini | 1 - headless/Headless.cpp | 2 +- 48 files changed, 47 insertions(+), 99 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 8e3c1d76d7..41804f7875 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -937,7 +937,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("TextureShader", &g_Config.sTextureShaderName, "Off", true, true), ConfigSetting("ShaderChainRequires60FPS", &g_Config.bShaderChainRequires60FPS, false, true, true), - ReportedConfigSetting("MemBlockTransferGPU", &g_Config.bBlockTransferGPU, true, true, true), + ReportedConfigSetting("SkipGPUReadbacks", &g_Config.bSkipGPUReadbacks, false, true, true), ConfigSetting("GfxDebugOutput", &g_Config.bGfxDebugOutput, false, false, false), ConfigSetting("LogFrameDrops", &g_Config.bLogFrameDrops, false, true, false), diff --git a/Core/Config.h b/Core/Config.h index e4795bfd4b..af20f6289e 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -235,7 +235,7 @@ public: float fCwCheatScrollPosition; float fGameListScrollPosition; int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive - bool bBlockTransferGPU; + bool bSkipGPUReadbacks; int iSplineBezierQuality; // 0 = low , 1 = Intermediate , 2 = High bool bHardwareTessellation; bool bShaderCache; // Hidden ini-only setting, useful for debugging shader compile times. diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 8a74467130..a2e4ec05c6 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1346,7 +1346,7 @@ void FramebufferManagerCommon::DownloadFramebufferOnSwitch(VirtualFramebuffer *v // Some games will draw to some memory once, and use it as a render-to-texture later. // To support this, we save the first frame to memory when we have a safe w/h. // Saving each frame would be slow. - if (g_Config.bBlockTransferGPU && !PSP_CoreParameter().compat.flags().DisableFirstFrameReadback) { + if (!g_Config.bSkipGPUReadbacks && !PSP_CoreParameter().compat.flags().DisableFirstFrameReadback) { ReadFramebufferToMemory(vfb, 0, 0, vfb->safeWidth, vfb->safeHeight, RASTER_COLOR); vfb->usageFlags = (vfb->usageFlags | FB_USAGE_DOWNLOAD | FB_USAGE_FIRST_FRAME_SAVED) & ~FB_USAGE_DOWNLOAD_CLEAR; vfb->safeWidth = 0; @@ -1806,7 +1806,7 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size, FlushBeforeCopy(); if (srcH == 0 || srcY + srcH > srcBuffer->bufferHeight) { WARN_LOG_ONCE(btdcpyheight, G3D, "Memcpy fbo download %08x -> %08x skipped, %d+%d is taller than %d", src, dst, srcY, srcH, srcBuffer->bufferHeight); - } else if (g_Config.bBlockTransferGPU && (!srcBuffer->memoryUpdated || channel == RASTER_DEPTH)) { + } else if (!g_Config.bSkipGPUReadbacks && (!srcBuffer->memoryUpdated || channel == RASTER_DEPTH)) { ReadFramebufferToMemory(srcBuffer, 0, srcY, srcBuffer->width, srcH, channel); srcBuffer->usageFlags = (srcBuffer->usageFlags | FB_USAGE_DOWNLOAD) & ~FB_USAGE_DOWNLOAD_CLEAR; } @@ -2262,7 +2262,7 @@ bool FramebufferManagerCommon::NotifyBlockTransferBefore(u32 dstBasePtr, int dst srcBasePtr, srcRect.x_bytes / bpp, srcRect.y, srcStride, dstBasePtr, dstRect.x_bytes / bpp, dstRect.y, dstStride); FlushBeforeCopy(); - if (g_Config.bBlockTransferGPU && !srcRect.vfb->memoryUpdated) { + if (!g_Config.bSkipGPUReadbacks && !srcRect.vfb->memoryUpdated) { const int srcBpp = BufferFormatBytesPerPixel(srcRect.vfb->fb_format); const float srcXFactor = (float)bpp / srcBpp; const bool tooTall = srcY + srcRect.h > srcRect.vfb->bufferHeight; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index c046fb01d5..896c939d12 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -332,7 +332,7 @@ void EmuScreen::bootGame(const Path &filename) { host->NotifyUserMessage(gr->T("BufferedRenderingRequired", "Warning: This game requires Rendering Mode to be set to Buffered."), 15.0f); } - if (PSP_CoreParameter().compat.flags().RequireBlockTransfer && g_Config.bBlockTransferGPU == false) { + if (PSP_CoreParameter().compat.flags().RequireBlockTransfer && g_Config.bSkipGPUReadbacks) { auto gr = GetI18NCategory("Graphics"); host->NotifyUserMessage(gr->T("BlockTransferRequired", "Warning: This game requires Simulate Block Transfer Mode to be set to On."), 15.0f); } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index d92eed91a1..c551d87721 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -298,24 +298,6 @@ void GameSettingsScreen::CreateViews() { } } - CheckBox *skipBufferEffects = graphicsSettings->Add(new CheckBox(&g_Config.bSkipBufferEffects, gr->T("Skip Buffer Effects"))); - skipBufferEffects->OnClick.Add([=](EventParams &e) { - if (g_Config.bSkipBufferEffects) { - settingInfo_->Show(gr->T("RenderingMode NonBuffered Tip", "Faster, but graphics may be missing in some games"), e.v); - g_Config.bAutoFrameSkip = false; - } - return UI::EVENT_DONE; - }); - skipBufferEffects->SetDisabledPtr(&g_Config.bSoftwareRendering); - - CheckBox *blockTransfer = graphicsSettings->Add(new CheckBox(&g_Config.bBlockTransferGPU, gr->T("Simulate Block Transfer", "Simulate Block Transfer"))); - blockTransfer->OnClick.Add([=](EventParams &e) { - if (!g_Config.bBlockTransferGPU) - settingInfo_->Show(gr->T("BlockTransfer Tip", "Some games require this to be On for correct graphics"), e.v); - return UI::EVENT_CONTINUE; - }); - blockTransfer->SetDisabledPtr(&g_Config.bSoftwareRendering); - if (deviceType != DEVICE_TYPE_VR) { CheckBox *softwareGPU = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareRendering, gr->T("Software Rendering", "Software Rendering (slow)"))); softwareGPU->SetEnabled(!PSP_IsInited()); @@ -344,6 +326,46 @@ void GameSettingsScreen::CreateViews() { altSpeed2->SetFormat("%i%%"); } + graphicsSettings->Add(new ItemHeader(gr->T("Speed Hacks", "Speed Hacks (can cause rendering errors!)"))); + + CheckBox *skipBufferEffects = graphicsSettings->Add(new CheckBox(&g_Config.bSkipBufferEffects, gr->T("Skip Buffer Effects"))); + skipBufferEffects->OnClick.Add([=](EventParams &e) { + if (g_Config.bSkipBufferEffects) { + settingInfo_->Show(gr->T("RenderingMode NonBuffered Tip", "Faster, but graphics may be missing in some games"), e.v); + g_Config.bAutoFrameSkip = false; + } + return UI::EVENT_DONE; + }); + skipBufferEffects->SetDisabledPtr(&g_Config.bSoftwareRendering); + + CheckBox *skipGPUReadbacks = graphicsSettings->Add(new CheckBox(&g_Config.bSkipGPUReadbacks, gr->T("Skip GPU Readbacks"))); + skipGPUReadbacks->SetDisabledPtr(&g_Config.bSoftwareRendering); + + CheckBox *vtxCache = graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gr->T("Vertex Cache"))); + vtxCache->OnClick.Add([=](EventParams &e) { + settingInfo_->Show(gr->T("VertexCache Tip", "Faster, but may cause temporary flicker"), e.v); + return UI::EVENT_CONTINUE; + }); + vtxCache->SetEnabledFunc([] { + return !g_Config.bSoftwareRendering && g_Config.bHardwareTransform && g_Config.iGPUBackend != (int)GPUBackend::OPENGL; + }); + + CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gr->T("Lazy texture caching", "Lazy texture caching (speedup)"))); + texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering); + texBackoff->OnClick.Add([=](EventParams& e) { + settingInfo_->Show(gr->T("Lazy texture caching Tip", "Faster, but can cause text problems in a few games"), e.v); + return UI::EVENT_CONTINUE; + }); + + static const char *quality[] = { "Low", "Medium", "High" }; + PopupMultiChoice *beziersChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSplineBezierQuality, gr->T("LowCurves", "Spline/Bezier curves quality"), quality, 0, ARRAY_SIZE(quality), gr->GetName(), screenManager())); + beziersChoice->OnChoice.Add([=](EventParams &e) { + if (g_Config.iSplineBezierQuality != 0) { + settingInfo_->Show(gr->T("LowCurves Tip", "Only used by some games, controls smoothness of curves"), e.v); + } + return UI::EVENT_CONTINUE; + }); + graphicsSettings->Add(new ItemHeader(gr->T("Postprocessing effect"))); bool multiViewSupported = draw->GetDeviceCaps().multiViewSupported; @@ -525,38 +547,6 @@ void GameSettingsScreen::CreateViews() { }); swSkin->SetDisabledPtr(&g_Config.bSoftwareRendering); - CheckBox *vtxCache = graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gr->T("Vertex Cache"))); - vtxCache->OnClick.Add([=](EventParams &e) { - settingInfo_->Show(gr->T("VertexCache Tip", "Faster, but may cause temporary flicker"), e.v); - return UI::EVENT_CONTINUE; - }); - vtxCache->SetEnabledFunc([] { - return !g_Config.bSoftwareRendering && g_Config.bHardwareTransform && g_Config.iGPUBackend != (int)GPUBackend::OPENGL; - }); - - CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gr->T("Lazy texture caching", "Lazy texture caching (speedup)"))); - texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering); - texBackoff->OnClick.Add([=](EventParams& e) { - settingInfo_->Show(gr->T("Lazy texture caching Tip", "Faster, but can cause text problems in a few games"), e.v); - return UI::EVENT_CONTINUE; - }); - - // Seems solid, so we hide the setting. - /*CheckBox *vtxJit = graphicsSettings->Add(new CheckBox(&g_Config.bVertexDecoderJit, gr->T("Vertex Decoder JIT"))); - - if (PSP_IsInited()) { - vtxJit->SetEnabled(false); - }*/ - - static const char *quality[] = { "Low", "Medium", "High" }; - PopupMultiChoice *beziersChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSplineBezierQuality, gr->T("LowCurves", "Spline/Bezier curves quality"), quality, 0, ARRAY_SIZE(quality), gr->GetName(), screenManager())); - beziersChoice->OnChoice.Add([=](EventParams &e) { - if (g_Config.iSplineBezierQuality != 0) { - settingInfo_->Show(gr->T("LowCurves Tip", "Only used by some games, controls smoothness of curves"), e.v); - } - return UI::EVENT_CONTINUE; - }); - CheckBox *tessellationHW = graphicsSettings->Add(new CheckBox(&g_Config.bHardwareTessellation, gr->T("Hardware Tessellation"))); tessellationHW->OnClick.Add([=](EventParams &e) { settingInfo_->Show(gr->T("HardwareTessellation Tip", "Uses hardware to make curves"), e.v); diff --git a/assets/lang/ar_AE.ini b/assets/lang/ar_AE.ini index 8cae321f81..3307ba15a3 100644 --- a/assets/lang/ar_AE.ini +++ b/assets/lang/ar_AE.ini @@ -476,7 +476,6 @@ Auto Scaling = ‎تكبير تلقائي Backend = ‎الخلفي Balanced = ‎متناسق Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = ‎الأثنين Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/az_AZ.ini b/assets/lang/az_AZ.ini index 88dd568f32..64d1778f40 100644 --- a/assets/lang/az_AZ.ini +++ b/assets/lang/az_AZ.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/bg_BG.ini b/assets/lang/bg_BG.ini index f2a48cade1..9411fb92c5 100644 --- a/assets/lang/bg_BG.ini +++ b/assets/lang/bg_BG.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = И двете Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/ca_ES.ini b/assets/lang/ca_ES.ini index fab847026c..2a28a4307f 100644 --- a/assets/lang/ca_ES.ini +++ b/assets/lang/ca_ES.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicúbic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/cz_CZ.ini b/assets/lang/cz_CZ.ini index 08043400a9..8e6fa7105d 100644 --- a/assets/lang/cz_CZ.ini +++ b/assets/lang/cz_CZ.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatické zvětšení Backend = Jádro Balanced = Vyrovnané Bicubic = Bikubická -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Obojí Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/da_DK.ini b/assets/lang/da_DK.ini index 06dfd28cee..4f93a65b05 100644 --- a/assets/lang/da_DK.ini +++ b/assets/lang/da_DK.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanceret Bicubic = Bicubisk -BlockTransfer Tip = Nogle spil kræver at denne er tændt for korrekt grafik BlockTransferRequired = Advarsel: Dette spil kræver at simulerede blok overførsel tilstand er tændt. Both = Begge Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/de_DE.ini b/assets/lang/de_DE.ini index 4e194329bd..c51eea9b7f 100644 --- a/assets/lang/de_DE.ini +++ b/assets/lang/de_DE.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto Skalierung Backend = Grafik-Backend Balanced = Ausgeglichen Bicubic = Bikubisch -BlockTransfer Tip = Manche Spiele benötigen dies für eine korrekte Darstellung BlockTransferRequired = Warnung: Dieses Spiel benötigt "Blockübertragungseffekte simulieren". Both = Beide Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/dr_ID.ini b/assets/lang/dr_ID.ini index ca081a1c09..52e33266ce 100644 --- a/assets/lang/dr_ID.ini +++ b/assets/lang/dr_ID.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Pa jio duai Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/es_ES.ini b/assets/lang/es_ES.ini index 30216ad2cd..cee1d13717 100644 --- a/assets/lang/es_ES.ini +++ b/assets/lang/es_ES.ini @@ -468,7 +468,6 @@ Auto Scaling = Autoescalado Backend = Motor gráfico Balanced = Equilibrado Bicubic = Bicúbico -BlockTransfer Tip = Algunos juegos necesitan esta opción para evitar errores gráficos. BlockTransferRequired = AVISO: Este juego requiere activar los efectos de transferencia de bloque. Both = Ambos Buffer graphics commands (faster, input lag) = Comandos de búfer gráfico (puede generar input lag) diff --git a/assets/lang/es_LA.ini b/assets/lang/es_LA.ini index 76da6dbded..b6df17ab65 100644 --- a/assets/lang/es_LA.ini +++ b/assets/lang/es_LA.ini @@ -468,7 +468,6 @@ Auto Scaling = Escalado automático Backend = Motor gráfico Balanced = Balanceado Bicubic = Bicúbico -BlockTransfer Tip = Algunos juegos requieren activarlo para corregir gráficos. BlockTransferRequired = Advertencia: Este juego requiere activar los efectos de transferencia de bloque. Both = Ambos Buffer graphics commands (faster, input lag) = Comandos gráficos de búfer (puede generar input lag) diff --git a/assets/lang/fa_IR.ini b/assets/lang/fa_IR.ini index c082a845b9..f856c6e437 100644 --- a/assets/lang/fa_IR.ini +++ b/assets/lang/fa_IR.ini @@ -468,7 +468,6 @@ Auto Scaling = ‎تنظیم سایز خودکار Backend = ‎گرافیکی API Balanced = ‎متعادل Bicubic = Bicubic -BlockTransfer Tip = ‎در بعضی بازی ها برای نشان دادن درست گرافیک نیاز است BlockTransferRequired = ‎دارد "simulate block transfer effects" هشدار:این گزینه نیاز به روشن بودن Both = ‎سرعت + فریم بر ثانیه Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/fi_FI.ini b/assets/lang/fi_FI.ini index 6e448250bc..66d6596262 100644 --- a/assets/lang/fi_FI.ini +++ b/assets/lang/fi_FI.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Molemmat Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/fr_FR.ini b/assets/lang/fr_FR.ini index 3e87cb10b8..1d010efe05 100644 --- a/assets/lang/fr_FR.ini +++ b/assets/lang/fr_FR.ini @@ -468,7 +468,6 @@ Auto Scaling = Mise à l'échelle auto Backend = Rendu back-end Balanced = Équilibré Bicubic = Bicubique -BlockTransfer Tip = Certains jeux requièrent l'activation de ce paramètre pour obtenir des graphismes corrects BlockTransferRequired = Avertissement : Ce jeu requiert l'activation de "Simuler les effets de transfert de bloc". Both = Vitesse + FPS Buffer graphics commands (faster, input lag) = Commandes graphiques en mémoire tampon (+ rapide, + lag entrée) diff --git a/assets/lang/gl_ES.ini b/assets/lang/gl_ES.ini index 0144f5cb0d..0364e1feac 100644 --- a/assets/lang/gl_ES.ini +++ b/assets/lang/gl_ES.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Motor gráfico Balanced = Balanceado Bicubic = Bicúbico -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/gr_EL.ini b/assets/lang/gr_EL.ini index 53fc6fd553..0d876321b4 100644 --- a/assets/lang/gr_EL.ini +++ b/assets/lang/gr_EL.ini @@ -468,7 +468,6 @@ Auto Scaling = Αυτόματη Κλιμάκωση Backend = Σύστημα Υποστήριξης Balanced = Εξισορροπημένη Bicubic = Διακυβική -BlockTransfer Tip = Ορισμένα παιχνίδια απαιτούν να είναι ενεργοποιημένο για την σωστή επεικόνιση γραφικών. BlockTransferRequired = Προειδοποίηση: Αυτό το παιχνίδι απαιτεί τη λειτουργία προσομοίωσης εφέ μεταφοράς block να είναι ενεργοποιημένη. Both = Όλα Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/he_IL.ini b/assets/lang/he_IL.ini index f7878259cd..8d559c66d8 100644 --- a/assets/lang/he_IL.ini +++ b/assets/lang/he_IL.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = שניהם Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/he_IL_invert.ini b/assets/lang/he_IL_invert.ini index ca5a52c0e7..dea835df52 100644 --- a/assets/lang/he_IL_invert.ini +++ b/assets/lang/he_IL_invert.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = םהינש Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/hr_HR.ini b/assets/lang/hr_HR.ini index 50bf5487c3..6e65118dec 100644 --- a/assets/lang/hr_HR.ini +++ b/assets/lang/hr_HR.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto mjerenje Backend = Backend Balanced = Balansirano Bicubic = Bikubično -BlockTransfer Tip = Neke igre zahtijevaju ovo na Uključeno za točne grafike BlockTransferRequired = Upozorenje: Ova igra zahtijeva "simulirajte blok transfer efekte" da budu postavljeni na Uključeno. Both = Oboje Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/hu_HU.ini b/assets/lang/hu_HU.ini index 6be4c6ef72..8f2b003a41 100644 --- a/assets/lang/hu_HU.ini +++ b/assets/lang/hu_HU.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatikus skálázás Backend = Backend Balanced = Kiegyensúlyozott Bicubic = Bicubic -BlockTransfer Tip = Néhány játék számára ezt be kell kapcsolni ahhoz, hogy helyesen rajzolódjon ki. BlockTransferRequired = Figyelem: Ehhez a játékhoz be kell kapcsolni a "Blokk transzfer effektek szimulálása" opciót! Both = Mindkettő Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/id_ID.ini b/assets/lang/id_ID.ini index ce169cedad..f28ff33fac 100644 --- a/assets/lang/id_ID.ini +++ b/assets/lang/id_ID.ini @@ -468,7 +468,6 @@ Auto Scaling = Penskala otomatis Backend = Penyangga grafis Balanced = Seimbang Bicubic = Bikubik -BlockTransfer Tip = Beberapa permainan memerlukan opsi ini untuk menghindari kesalahan grafis. BlockTransferRequired = Peringatan: Permainan ini membutuhkan "Simulasikan efek transfer blok" dalam keadaan menyala. Both = Keduanya Buffer graphics commands (faster, input lag) = Perintah grafis penyangga (lebih cepat, masukan lag) diff --git a/assets/lang/it_IT.ini b/assets/lang/it_IT.ini index e16911851f..68d08f8a93 100644 --- a/assets/lang/it_IT.ini +++ b/assets/lang/it_IT.ini @@ -468,7 +468,6 @@ Auto Scaling = Scaling automatico Backend = Renderer Balanced = Bilanciato Bicubic = Bicubico -BlockTransfer Tip = Alcuni giochi richiedono che quest'opzione sia attiva per correggere la grafica BlockTransferRequired = Attenzione: Questo gioco richiede l'attivazione di 'Simula gli effetti del blocco trasferimento'. Both = Entrambi Buffer graphics commands (faster, input lag) = Comandi grafici bufferizzati (più rapido, più lag dei comandi) diff --git a/assets/lang/ja_JP.ini b/assets/lang/ja_JP.ini index 9df017b836..3d0f6eafc4 100644 --- a/assets/lang/ja_JP.ini +++ b/assets/lang/ja_JP.ini @@ -468,7 +468,6 @@ Auto Scaling = 自動的に拡大 Backend = バックエンド Balanced = バランス Bicubic = Bicubic -BlockTransfer Tip = オンにしないと正しく表示できないゲームがいくつかあります BlockTransferRequired = 警告: このゲームは「ブロック転送の効果をシミュレートする」をオンにする必要があります。 Both = 両方 Buffer graphics commands (faster, input lag) = グラフィックスコマンドをバッファする (高速, 入力ラグあり) diff --git a/assets/lang/jv_ID.ini b/assets/lang/jv_ID.ini index 79220cf2ea..b522a9a4c1 100644 --- a/assets/lang/jv_ID.ini +++ b/assets/lang/jv_ID.ini @@ -468,7 +468,6 @@ Auto Scaling = Njongko Otomatis Backend = Backend Balanced = Imbang Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Kelorone Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/ko_KR.ini b/assets/lang/ko_KR.ini index 4178d83ec4..337f624cf5 100644 --- a/assets/lang/ko_KR.ini +++ b/assets/lang/ko_KR.ini @@ -468,7 +468,6 @@ Auto Scaling = 자동 스케일링 Backend = 백엔드 Balanced = 평형 Bicubic = 고등차수보간 -BlockTransfer Tip = 일부 게임에서는 올바른 그래픽을 위해 이 기능을 켜야 합니다. BlockTransferRequired = 경고: 이 게임은 "블록 전송 효과 시뮬레이션"을 켬으로 설정해야 합니다. Both = 둘 다 Buffer graphics commands (faster, input lag) = 버퍼 그래픽 명령 (빠름, 입력 지연) diff --git a/assets/lang/lo_LA.ini b/assets/lang/lo_LA.ini index 9dc2bb3fa8..a5133a73ae 100644 --- a/assets/lang/lo_LA.ini +++ b/assets/lang/lo_LA.ini @@ -468,7 +468,6 @@ Auto Scaling = ປັບຂະໜາດສເກລອັດຕະໂນມັ Backend = ການສະໜັບສະໜູນ Balanced = ສົມດຸນ Bicubic = Bicubic -BlockTransfer Tip = ບາງເກມຕ້ອງເປີດໃຊ້ງານເພື່ອການສະແດງຜົນທີ່ຖືກຕ້ອງ BlockTransferRequired = ຄຳເຕືອນ: ເກມນີ້ຕ້ອງການໃຫ້ເປີດໂໝດ "ຈຳລອງຜົນປິດກັ້ນການສົ່ງຜ່ານຂໍ້ມູນເອັບເຟກ" ນຳ Both = ໃຊ້ທັງ FPS ແລະ Speed Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/lt-LT.ini b/assets/lang/lt-LT.ini index 6d54606a83..494653f8f5 100644 --- a/assets/lang/lt-LT.ini +++ b/assets/lang/lt-LT.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = "Bicubic" -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Abu Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/ms_MY.ini b/assets/lang/ms_MY.ini index e785b696e3..801a373dfe 100644 --- a/assets/lang/ms_MY.ini +++ b/assets/lang/ms_MY.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bikubik -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Keduanya Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/nl_NL.ini b/assets/lang/nl_NL.ini index f9b4823c0d..83a6aba047 100644 --- a/assets/lang/nl_NL.ini +++ b/assets/lang/nl_NL.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatisch schalen Backend = Backend Balanced = Gebalanceerd Bicubic = Bicubisch -BlockTransfer Tip = Sommige games vereisen dat deze optie aan staat voor juiste graphics BlockTransferRequired = Waarschuwing: Deze game vereist de optie Blokoverdrachteffecten simuleren. Both = Beide Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/no_NO.ini b/assets/lang/no_NO.ini index d18cfb601e..cceaa22382 100644 --- a/assets/lang/no_NO.ini +++ b/assets/lang/no_NO.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Begge Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/pl_PL.ini b/assets/lang/pl_PL.ini index 3afd586155..5b067680e3 100644 --- a/assets/lang/pl_PL.ini +++ b/assets/lang/pl_PL.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatyczne skalowanie Backend = Sterownik graficzny Balanced = Zbalansowane Bicubic = Bicubic (Dwusześcienne) -BlockTransfer Tip = Niektóre gry wymagają włączenia tej opcji do poprawnego działania. BlockTransferRequired = Uwaga: Ta gra wymaga włączonej opcji "Symuluj efekty transferu bloków". Both = Oba Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/pt_BR.ini b/assets/lang/pt_BR.ini index 40d08c1294..45d7e1b867 100644 --- a/assets/lang/pt_BR.ini +++ b/assets/lang/pt_BR.ini @@ -492,7 +492,6 @@ Auto Scaling = Auto-redimensionamento Backend = Backend Balanced = Balanceado Bicubic = Bi-cúbico -BlockTransfer Tip = Alguns jogos requerem que isto esteja Ligado pros gráficos estarem corretos BlockTransferRequired = Aviso: Esse jogo requer que a "simulação dos efeitos de transferência dos blocos" esteja definida como Ligada. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer dos comandos dos gráficos (mais rápido, atraso na entrada dos dados) diff --git a/assets/lang/pt_PT.ini b/assets/lang/pt_PT.ini index 298880849e..054d8f0dfd 100644 --- a/assets/lang/pt_PT.ini +++ b/assets/lang/pt_PT.ini @@ -492,7 +492,6 @@ Auto Scaling = Auto-redimensionamento Backend = Backend Balanced = Balanceado Bicubic = Bi-cúbico -BlockTransfer Tip = Alguns jogos requerem que esta opção esteja habilitada para os gráficos estarem corretos. BlockTransferRequired = Aviso: Este jogo requer que a "Simulação dos Efeitos de Transferência dos Blocos" esteja habilitada. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer dos Comandos Gráficos (mais rápido, atraso na entrada dos dados) diff --git a/assets/lang/ro_RO.ini b/assets/lang/ro_RO.ini index e6491a68e2..38d47a05b1 100644 --- a/assets/lang/ro_RO.ini +++ b/assets/lang/ro_RO.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Mod intern Balanced = Balansat Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Ambele Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/ru_RU.ini b/assets/lang/ru_RU.ini index 28548faa8a..082b087730 100644 --- a/assets/lang/ru_RU.ini +++ b/assets/lang/ru_RU.ini @@ -468,7 +468,6 @@ Auto Scaling = Автомасштаб Backend = Бэкенд Balanced = Сбалансированно Bicubic = Бикубический -BlockTransfer Tip = Требуется для корректной графики в некоторых играх BlockTransferRequired = Предупреждение: для этой игры требуется включить "Симуляцию эффектов от передачи блоков" Both = Оба Buffer graphics commands (faster, input lag) = Команды буферированной графики (быстрее, задержка ввода) diff --git a/assets/lang/sv_SE.ini b/assets/lang/sv_SE.ini index 2bf12a4af4..247e593a79 100644 --- a/assets/lang/sv_SE.ini +++ b/assets/lang/sv_SE.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balancerad Bicubic = Bicubisk -BlockTransfer Tip = Vissa spel kräver att denna inställning är på. BlockTransferRequired = Varning: Detta spel kräver att "Simulera blocktransfer-effekter" är påslaget. Both = Båda Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/tg_PH.ini b/assets/lang/tg_PH.ini index 63c37442f1..4815c0023c 100644 --- a/assets/lang/tg_PH.ini +++ b/assets/lang/tg_PH.ini @@ -468,7 +468,6 @@ Auto Scaling = Awto scaling Backend = Backend Balanced = Balanse Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics BlockTransferRequired = BABALA: This game requires "simulate block transfer effects" to be set to On. Both = Pareho Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/th_TH.ini b/assets/lang/th_TH.ini index 4b0d42f964..422f06b13f 100644 --- a/assets/lang/th_TH.ini +++ b/assets/lang/th_TH.ini @@ -468,7 +468,6 @@ Auto Scaling = สเกลอัตโนมัติ Backend = การสนับสนุนกราฟิก Balanced = สมดุล Bicubic = ไบคิวบิค -BlockTransfer Tip = บางเกมจำเป็นต้องเปิดใช้งานเพื่อการแสดงผลที่ถูกต้อง BlockTransferRequired = คำเตือน: เกมนี้ต้องปรับใช้งาน "จำลองผลปิดกั้นการส่งผ่านข้อมูลเอฟเฟ็คท์" ด้วย Both = ใช้ทั้งคู่ Buffer graphics commands (faster, input lag) = ควบคุมกราฟิกบัฟเฟอร์ (เร็วขึ้น, อาจทำให้เกิดอินพุตแล็ก) diff --git a/assets/lang/tr_TR.ini b/assets/lang/tr_TR.ini index bcca5aeff4..3bdaf3ef39 100644 --- a/assets/lang/tr_TR.ini +++ b/assets/lang/tr_TR.ini @@ -470,7 +470,6 @@ Auto Scaling = Otomatik ölçekleme Backend = Arkauç Balanced = Dengeli Bicubic = Çift Kübik -BlockTransfer Tip = Bazı oyunlarda doğru grafikler için bu ayarın açık olması gerekir BlockTransferRequired = Uyarı: Bu oyun Blok Aktarım Simülasyon Modunun Açık olmasını gerektirir. Both = İkisi de Buffer graphics commands (faster, input lag) = Grafik komutlarını arabellekle (daha hızlı, input lag'e sebep olabilir) diff --git a/assets/lang/uk_UA.ini b/assets/lang/uk_UA.ini index cde502baac..2105606270 100644 --- a/assets/lang/uk_UA.ini +++ b/assets/lang/uk_UA.ini @@ -468,7 +468,6 @@ Auto Scaling = Автоматичне масштабування Backend = Бекенд Balanced = Збалансовано Bicubic = Бікубічний -BlockTransfer Tip = Потрібно для правильної графіки в деяких іграх BlockTransferRequired = Попередження: Ця гра вимагає, щоб "імітувати ефекти передачі блоку" було встановлено на Увімкнено. Both = Обидва Buffer graphics commands (faster, input lag) = Буферні графічні команди (швидше, можливі глюки) diff --git a/assets/lang/vi_VN.ini b/assets/lang/vi_VN.ini index 918bfc6e91..2cf347c956 100644 --- a/assets/lang/vi_VN.ini +++ b/assets/lang/vi_VN.ini @@ -468,7 +468,6 @@ Auto Scaling = Tự động nhân rộng Backend = Thư viện đồ họa Balanced = Cân bằng Bicubic = Bicubic (mịn) -BlockTransfer Tip = Một số trò chơi yêu cầu đồ họa thích hợp. BlockTransferRequired = Cảnh báo: Trò chơi này yêu cầu mở "simulate block transfer effects" Both = Cả hai Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index 42e4d780da..42bdca4099 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -468,7 +468,6 @@ Auto Scaling = 自动缩放 Backend = 渲染引擎 Balanced = 均衡 Bicubic = 双三次 -BlockTransfer Tip = 有些游戏需要将此选项设置为开以显示正确的图形 BlockTransferRequired = 警告:此游戏需要将"模拟块传输模式"设置为开。 Both = 全部显示 Buffer graphics commands (faster, input lag) = 缓冲图形命令(更快, 有输入延迟) diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 24b8553d7d..a1cbd6c878 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -468,7 +468,6 @@ Auto Scaling = 自動縮放 Backend = 後端 Balanced = 平衡 Bicubic = 雙立方 -BlockTransfer Tip = 部分遊戲需要開啟此項以顯示正確的圖形 BlockTransferRequired = 警告:這個遊戲需要開啟「模擬區塊傳輸效果」 Both = 全部 Buffer graphics commands (faster, input lag) = 緩衝圖形命令 (更快,有輸入延遲) diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 60c3baaa0f..eb29a26500 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -421,6 +421,7 @@ int main(int argc, const char* argv[]) g_Config.sReportHost.clear(); g_Config.bAutoSaveSymbolMap = false; g_Config.bSkipBufferEffects = false; + g_Config.bSkipGPUReadbacks = false; g_Config.bHardwareTransform = true; g_Config.iAnisotropyLevel = 0; // When testing mipmapping we really don't want this. g_Config.bVertexCache = false; @@ -439,7 +440,6 @@ int main(int argc, const char* argv[]) g_Config.bVertexDecoderJit = true; g_Config.bSoftwareRendering = coreParameter.gpuCore == GPUCORE_SOFTWARE; g_Config.bSoftwareRenderingJit = true; - g_Config.bBlockTransferGPU = true; g_Config.iSplineBezierQuality = 2; g_Config.bHighQualityDepth = true; g_Config.bMemStickInserted = true; From f02c983a63168badf260000063815c2d4c916575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 19:40:02 +0100 Subject: [PATCH 367/374] lang: Remove obsolete keys, add new untranslated ones :( --- Tools/langtool/src/section.rs | 8 +++++--- assets/lang/ar_AE.ini | 5 +++-- assets/lang/az_AZ.ini | 5 +++-- assets/lang/bg_BG.ini | 5 +++-- assets/lang/ca_ES.ini | 5 +++-- assets/lang/cz_CZ.ini | 5 +++-- assets/lang/da_DK.ini | 5 +++-- assets/lang/de_DE.ini | 5 +++-- assets/lang/dr_ID.ini | 5 +++-- assets/lang/en_US.ini | 8 +++----- assets/lang/es_ES.ini | 5 +++-- assets/lang/es_LA.ini | 5 +++-- assets/lang/fa_IR.ini | 5 +++-- assets/lang/fi_FI.ini | 5 +++-- assets/lang/fr_FR.ini | 5 +++-- assets/lang/gl_ES.ini | 5 +++-- assets/lang/gr_EL.ini | 5 +++-- assets/lang/he_IL.ini | 5 +++-- assets/lang/he_IL_invert.ini | 5 +++-- assets/lang/hr_HR.ini | 5 +++-- assets/lang/hu_HU.ini | 5 +++-- assets/lang/id_ID.ini | 5 +++-- assets/lang/it_IT.ini | 9 ++++++--- assets/lang/ja_JP.ini | 5 +++-- assets/lang/jv_ID.ini | 5 +++-- assets/lang/ko_KR.ini | 5 +++-- assets/lang/lo_LA.ini | 5 +++-- assets/lang/lt-LT.ini | 5 +++-- assets/lang/ms_MY.ini | 5 +++-- assets/lang/nl_NL.ini | 5 +++-- assets/lang/no_NO.ini | 5 +++-- assets/lang/pl_PL.ini | 5 +++-- assets/lang/pt_BR.ini | 5 +++-- assets/lang/pt_PT.ini | 5 +++-- assets/lang/ro_RO.ini | 5 +++-- assets/lang/ru_RU.ini | 5 +++-- assets/lang/sv_SE.ini | 5 +++-- assets/lang/tg_PH.ini | 5 +++-- assets/lang/th_TH.ini | 5 +++-- assets/lang/tr_TR.ini | 8 +++++--- assets/lang/uk_UA.ini | 5 +++-- assets/lang/vi_VN.ini | 5 +++-- assets/lang/zh_CN.ini | 6 +++--- assets/lang/zh_TW.ini | 5 +++-- 44 files changed, 139 insertions(+), 95 deletions(-) diff --git a/Tools/langtool/src/section.rs b/Tools/langtool/src/section.rs index dbb097832a..f57c2e3563 100644 --- a/Tools/langtool/src/section.rs +++ b/Tools/langtool/src/section.rs @@ -96,9 +96,11 @@ impl Section { continue; } if !other.lines.iter().any(|line| line.starts_with(prefix)) { - println!("Commenting out: {}", line); - // Comment out the line. - *line = "#".to_owned() + line; + if !prefix.contains("URL") { + println!("Commenting out: {}", line); + // Comment out the line. + *line = "#".to_owned() + line; + } } } } diff --git a/assets/lang/ar_AE.ini b/assets/lang/ar_AE.ini index 3307ba15a3..2dc5aa69f1 100644 --- a/assets/lang/ar_AE.ini +++ b/assets/lang/ar_AE.ini @@ -476,7 +476,6 @@ Auto Scaling = ‎تكبير تلقائي Backend = ‎الخلفي Balanced = ‎متناسق Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = ‎الأثنين Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -506,6 +505,7 @@ Frame Skipping = ‎تخطي الإطارات Frame Skipping Type = Frame skipping type FullScreen = ‎الشاشة الكاملة GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Hardware transform @@ -553,11 +553,12 @@ Screen layout = Screen layout Screen Scaling Filter = ‎فلتر تكبير حجم الشاشة Show Debug Statistics = ‎أظهر معلومات التصحيح Show FPS Counter = ‎أظهر عداد الـFPS -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = ‎تصيير السوفت وير (slow) Software Skinning = ‎طلاء برمجي SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = ‎السرعة +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = ‎المط Texture Filter = ‎منقي الرسوم Texture Filtering = ‎مفلتر الرسوم diff --git a/assets/lang/az_AZ.ini b/assets/lang/az_AZ.ini index 64d1778f40..383ec9b5d4 100644 --- a/assets/lang/az_AZ.ini +++ b/assets/lang/az_AZ.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Kvadrat Keçid et (Sürət) Frame Skipping Type = Frame skipping type FullScreen = Fullscreen GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Təchizat Dönüşüm @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Show debug statistics Show FPS Counter = Show FPS counter -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software rendering (experimental) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Speed +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Texture filtering Texture Filtering = Texture filtering diff --git a/assets/lang/bg_BG.ini b/assets/lang/bg_BG.ini index 9411fb92c5..853d40a580 100644 --- a/assets/lang/bg_BG.ini +++ b/assets/lang/bg_BG.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = И двете Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Прескачане на кадри Frame Skipping Type = Frame skipping type FullScreen = Цял екран GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Hardware Transform @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Покажи debug инфо Show FPS Counter = Покажи брояча за кадри в сек. -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software rendering (експериментално) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Скорост +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Текстурно филтриране Texture Filtering = Текстурно филтриране diff --git a/assets/lang/ca_ES.ini b/assets/lang/ca_ES.ini index 2a28a4307f..393796df05 100644 --- a/assets/lang/ca_ES.ini +++ b/assets/lang/ca_ES.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicúbic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Saltar fotogrames (skip) Frame Skipping Type = Frame skipping type FullScreen = Fullscreen GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Transformació per maquinari @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Show debug statistics Show FPS Counter = Show FPS counter -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software rendering (experimental) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Speed +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Texture filtering Texture Filtering = Texture filtering diff --git a/assets/lang/cz_CZ.ini b/assets/lang/cz_CZ.ini index 8e6fa7105d..1f2dcbf436 100644 --- a/assets/lang/cz_CZ.ini +++ b/assets/lang/cz_CZ.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatické zvětšení Backend = Jádro Balanced = Vyrovnané Bicubic = Bikubická -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Obojí Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Přeskakování snímků Frame Skipping Type = Frame skipping type FullScreen = Režim celé obrazovky GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Nastavení hacků (Mohou způsobit problémy) Hardware Tessellation = Hardware tessellation Hardware Transform = Hardwarová transformace @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Filtr změny velikosti obrazovky Show Debug Statistics = Zobrazit statistiky ladění Show FPS Counter = Zobrazit počítadlo -Simulate Block Transfer = Simulovat efekty přesunu bloků +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Softwarové vykreslování (experimentální) Software Skinning = Textury aplikuje software SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Rychlost +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Roztažení Texture Filter = Filtr textur Texture Filtering = Filtrování textur diff --git a/assets/lang/da_DK.ini b/assets/lang/da_DK.ini index 4f93a65b05..72f0431317 100644 --- a/assets/lang/da_DK.ini +++ b/assets/lang/da_DK.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanceret Bicubic = Bicubisk -BlockTransferRequired = Advarsel: Dette spil kræver at simulerede blok overførsel tilstand er tændt. Both = Begge Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Frameskipping Frame Skipping Type = Frame skipping type FullScreen = Fuldskærm GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack indstillinger (kan give fejl) Hardware Tessellation = Hardware tessellation Hardware Transform = Hardware transformering @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Skærmskaleringsfilter Show Debug Statistics = Vis debugstatistik Show FPS Counter = Vis FPS -Simulate Block Transfer = Simuler blokoverførsel effekter +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software rendering (eksperiment) Software Skinning = Software skinning SoftwareSkinning Tip = Kombiner begrænset model tegning af CPU, hurtigere i fleste spil Speed = Hastighed +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Texturfilter Texture Filtering = Texturfiltrering diff --git a/assets/lang/de_DE.ini b/assets/lang/de_DE.ini index c51eea9b7f..fb0056e3dc 100644 --- a/assets/lang/de_DE.ini +++ b/assets/lang/de_DE.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto Skalierung Backend = Grafik-Backend Balanced = Ausgeglichen Bicubic = Bikubisch -BlockTransferRequired = Warnung: Dieses Spiel benötigt "Blockübertragungseffekte simulieren". Both = Beide Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warnung: Bei diesem Spiel muss "Rendering Modus" auf "Gepuffert" gesetzt werden. @@ -498,6 +497,7 @@ Frame Skipping = Bilder überspringen Frame Skipping Type = Typ für Bilder überspringen FullScreen = Vollbild GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hacks (kann zu Fehlern führen) Hardware Tessellation = Hardware Tessellation Hardware Transform = Hardware Transformierung @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Filter für Bildskalierung Show Debug Statistics = Debugstatistiken anzeigen Show FPS Counter = FPS anzeigen -Simulate Block Transfer = Blockübertragungseffekte simulieren +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software Renderer (experimentell) Software Skinning = Software Skinning SoftwareSkinning Tip = Reduziert Grafikbefehle und schneller in Spielen mit erweiterter Skinning-Technik, in anderen Spielen langsamer Speed = Geschwindigkeit +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Strecken Texture Filter = Texturfilter Texture Filtering = Texturfilterung diff --git a/assets/lang/dr_ID.ini b/assets/lang/dr_ID.ini index 52e33266ce..1988cada18 100644 --- a/assets/lang/dr_ID.ini +++ b/assets/lang/dr_ID.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Pa jio duai Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Frameskip Frame Skipping Type = Frame skipping type FullScreen = Layar pol GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Sullei Hardware @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Padenni Debugna Show FPS Counter = Padenni FPSna -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Pakeanni Software Tampilkan (dicoba-cobara) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Lassinna +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Panyaring Texture Texture Filtering = Saring i Texture diff --git a/assets/lang/en_US.ini b/assets/lang/en_US.ini index b66ccc4ee1..20450f8351 100644 --- a/assets/lang/en_US.ini +++ b/assets/lang/en_US.ini @@ -492,8 +492,7 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransfer Tip = Some games require this to be On for correct graphics -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Both = Both Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -563,19 +562,18 @@ RenderDuplicateFrames Tip = Can make framerate smoother in games that run at low Rendering Mode = Rendering mode Rendering Resolution = Rendering resolution RenderingMode NonBuffered Tip = Faster, but nothing may draw in some games -Retain changed textures = Retain changed textures (sometimes slower) -RetainChangedTextures Tip = Makes many games slower, but some games a lot faster Rotation = Rotation Safe = Safe Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Show debug statistics Show FPS Counter = Show FPS counter -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software rendering (slow) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Speed +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Texture filtering Texture Filtering = Texture filtering diff --git a/assets/lang/es_ES.ini b/assets/lang/es_ES.ini index cee1d13717..2f5dd72031 100644 --- a/assets/lang/es_ES.ini +++ b/assets/lang/es_ES.ini @@ -468,7 +468,6 @@ Auto Scaling = Autoescalado Backend = Motor gráfico Balanced = Equilibrado Bicubic = Bicúbico -BlockTransferRequired = AVISO: Este juego requiere activar los efectos de transferencia de bloque. Both = Ambos Buffer graphics commands (faster, input lag) = Comandos de búfer gráfico (puede generar input lag) BufferedRenderingRequired = AVISO: este juego requiere modo de renderizado por búfer. @@ -498,6 +497,7 @@ Frame Skipping = Saltar cuadros Frame Skipping Type = Tipo de salto de cuadros FullScreen = Pantalla completa GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Ajustes de hacks (causarán errores gráficos) Hardware Tessellation = Teselado por hardware Hardware Transform = Transformación por hardware @@ -545,11 +545,12 @@ Screen layout = Diseño de pantalla Screen Scaling Filter = Filtro de escalado de pantalla Show Debug Statistics = Mostrar estadísticas de depuración Show FPS Counter = Mostrar contador de FPS -Simulate Block Transfer = Simular efectos "block transfer" +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderizado por software Software Skinning = "Skinning" por software SoftwareSkinning Tip = Reduce la carga de dibujado, rápido en juegos con técnicas de skinning avanzadas, pero lento en otros. Speed = Velocidad +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Estirar Texture Filter = Filtro de texturas Texture Filtering = Filtrado de texturas diff --git a/assets/lang/es_LA.ini b/assets/lang/es_LA.ini index b6df17ab65..7c789a7f75 100644 --- a/assets/lang/es_LA.ini +++ b/assets/lang/es_LA.ini @@ -468,7 +468,6 @@ Auto Scaling = Escalado automático Backend = Motor gráfico Balanced = Balanceado Bicubic = Bicúbico -BlockTransferRequired = Advertencia: Este juego requiere activar los efectos de transferencia de bloque. Both = Ambos Buffer graphics commands (faster, input lag) = Comandos gráficos de búfer (puede generar input lag) BufferedRenderingRequired = Advertencia: Este juego requiere modo de renderizado por búfer. @@ -498,6 +497,7 @@ Frame Skipping = Salto de cuadros Frame Skipping Type = Tipo de salto de cuadros FullScreen = Pantalla completa GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Ajustes de hacks (puede causar glitches) Hardware Tessellation = Teselado por Hardware Hardware Transform = Transformación por Hardware @@ -545,11 +545,12 @@ Screen layout = Disposición de pantalla Screen Scaling Filter = Filtro de escalado de pantalla Show Debug Statistics = Mostrar estadísticas de depuración Show FPS Counter = Mostrar contador de FPS -Simulate Block Transfer = Simular efectos de transferencia de bloque +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderizado por software (experimental) Software Skinning = Skineado por software SoftwareSkinning Tip = Combina dibujados de modelo de skineado en la CPU. Acelera muchos juegos pero ralentiza otros. Speed = Velocidad +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Estirar Texture Filter = Filtro de texturas Texture Filtering = Filtrado de texturas diff --git a/assets/lang/fa_IR.ini b/assets/lang/fa_IR.ini index f856c6e437..7b7b8ca47b 100644 --- a/assets/lang/fa_IR.ini +++ b/assets/lang/fa_IR.ini @@ -468,7 +468,6 @@ Auto Scaling = ‎تنظیم سایز خودکار Backend = ‎گرافیکی API Balanced = ‎متعادل Bicubic = Bicubic -BlockTransferRequired = ‎دارد "simulate block transfer effects" هشدار:این گزینه نیاز به روشن بودن Both = ‎سرعت + فریم بر ثانیه Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = ‎تنظیم باشد "buffered" هشدار: برای این بازی "حالت رندرینگ" باید روی @@ -498,6 +497,7 @@ Frame Skipping = ‎ردکردن فریم Frame Skipping Type = Frame skipping type FullScreen = ‎تمام صفحه GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = ‎تنظیمات هک ها (میتواند باعث باگ شود) Hardware Tessellation = Hardware tessellation Hardware Transform = ‎استفاده از سخت افزار در پردازش @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = ‎فیلتر تغییر ساز صفحه Show Debug Statistics = ‎نمایش اطلاعات دیباگ Show FPS Counter = ‎نمایش شمارنده فریم بر ثانیه -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = ‎(رندر نرم افزاری (آزمایشی Software Skinning = Software skinning SoftwareSkinning Tip = ‎در اکثر بازی ها سریع تر ،CPU دار در skin ترکیب رسم مدل های Speed = ‎سرعت +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = ‎کشیدن Texture Filter = ‎فیلتر تکسچر Texture Filtering = ‎فیلتر کردن تکسچر diff --git a/assets/lang/fi_FI.ini b/assets/lang/fi_FI.ini index 66d6596262..6d3d8eb412 100644 --- a/assets/lang/fi_FI.ini +++ b/assets/lang/fi_FI.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Molemmat Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Ruudun ohitus Frame Skipping Type = Frame skipping type FullScreen = Koko näyttö GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Laitteistomuunnos @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Näytä virheenkorjaustilastot Show FPS Counter = Näytä FPS-laskuri -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Ohjelmistopohjainen renderointi (kokeellinen) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Nopeus +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Tekstuurisuodatin Texture Filtering = Tekstuurin suodatus diff --git a/assets/lang/fr_FR.ini b/assets/lang/fr_FR.ini index 1d010efe05..23b23fccd6 100644 --- a/assets/lang/fr_FR.ini +++ b/assets/lang/fr_FR.ini @@ -468,7 +468,6 @@ Auto Scaling = Mise à l'échelle auto Backend = Rendu back-end Balanced = Équilibré Bicubic = Bicubique -BlockTransferRequired = Avertissement : Ce jeu requiert l'activation de "Simuler les effets de transfert de bloc". Both = Vitesse + FPS Buffer graphics commands (faster, input lag) = Commandes graphiques en mémoire tampon (+ rapide, + lag entrée) BufferedRenderingRequired = Avertissement : Ce jeu requiert "mode de rendu" réglé sur "Mise en mémoire tampon". @@ -498,6 +497,7 @@ Frame Skipping = Saut d'images Frame Skipping Type = Type de saut d'images FullScreen = Plein écran GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Paramètres "hack" (crée des bugs graphiques) Hardware Tessellation = Tessellation matérielle Hardware Transform = Transformation matérielle @@ -545,11 +545,12 @@ Screen layout = Disposition de l'écran Screen Scaling Filter = Filtre de mise à l'échelle de l'écran Show Debug Statistics = Montrer les statistiques de débogage Show FPS Counter = Montrer les compteurs -Simulate Block Transfer = Simuler les effets de transfert de bloc +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Rendu logiciel (expérimental) Software Skinning = Enveloppe logicielle SoftwareSkinning Tip = Combine l'affichage des modèles enveloppés sur le CPU, plus rapide dans la plupart des jeux Speed = Vitesse +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Étirement Texture Filter = Filtre de textures Texture Filtering = Filtrage des textures diff --git a/assets/lang/gl_ES.ini b/assets/lang/gl_ES.ini index 0364e1feac..5e8fe159d4 100644 --- a/assets/lang/gl_ES.ini +++ b/assets/lang/gl_ES.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Motor gráfico Balanced = Balanceado Bicubic = Bicúbico -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Saltar cadros Frame Skipping Type = Frame skipping type FullScreen = Pantalla completa GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Axustes de hacks (causarán erros gráficos) Hardware Tessellation = Hardware tessellation Hardware Transform = Transformación por hardware @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Filtro de escalado de pantalla Show Debug Statistics = Mostrar estadísticas de depuración Show FPS Counter = Mostrar contador de FPS -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderizado por software (beta) Software Skinning = «Skinning» por software SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Velocidade +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Filtro de texturas Texture Filtering = Filtrado de texturas diff --git a/assets/lang/gr_EL.ini b/assets/lang/gr_EL.ini index 0d876321b4..38f61cd2a0 100644 --- a/assets/lang/gr_EL.ini +++ b/assets/lang/gr_EL.ini @@ -468,7 +468,6 @@ Auto Scaling = Αυτόματη Κλιμάκωση Backend = Σύστημα Υποστήριξης Balanced = Εξισορροπημένη Bicubic = Διακυβική -BlockTransferRequired = Προειδοποίηση: Αυτό το παιχνίδι απαιτεί τη λειτουργία προσομοίωσης εφέ μεταφοράς block να είναι ενεργοποιημένη. Both = Όλα Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Παράκαμψη Καρέ Frame Skipping Type = Frame skipping type FullScreen = Πλήρης Οθόνη GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Ρυθμίσεις Hack Hardware Tessellation = Tessellation Υλικού Hardware Transform = Μετασχηματισμός Υλικού @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Φίλτο κλιμάκωσης οθόνης Show Debug Statistics = Εμφάνιση στατιστικών αποσφαλμάτωσης Show FPS Counter = Εμφάνιση μετρητή FPS -Simulate Block Transfer = Προσομοίωση εφέ μεταφοράς block +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Απεικόνιση Λογισμικού (πειραματικό) Software Skinning = Εκδορά Λογισμικού SoftwareSkinning Tip = Συνδυασμός μοντέλου στην CPU, γρηγορότερο στα περισσότερα παιχνίδια Speed = Ταχύτητα +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Επέκταση Texture Filter = Φίλτρο Υφών Texture Filtering = Φιλτράρισμα Υφών diff --git a/assets/lang/he_IL.ini b/assets/lang/he_IL.ini index 8d559c66d8..ecad06a830 100644 --- a/assets/lang/he_IL.ini +++ b/assets/lang/he_IL.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = שניהם Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = דלג על פריימים Frame Skipping Type = Frame skipping type FullScreen = מסך מלא GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = התאמת חומרה @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = הצג סטטיסטיקת באגים Show FPS Counter = הצג מונה -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = עיבוד תוכנה (ניסיוני) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = מהירות +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = קידוד טקסטורה Texture Filtering = קידוד טקסטורה diff --git a/assets/lang/he_IL_invert.ini b/assets/lang/he_IL_invert.ini index dea835df52..97fb5347a6 100644 --- a/assets/lang/he_IL_invert.ini +++ b/assets/lang/he_IL_invert.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = םהינש Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = םימיירפ לע גלד Frame Skipping Type = Frame skipping type FullScreen = אלמ ךסמ GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = הרמוח תמאתה @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = םיגאב תקיטסיטטס גצה Show FPS Counter = הנומ גצה -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = )ינויסינ( הנכות דוביע Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = תוריהמ +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = הרוטסקט דודיק Texture Filtering = הרוטסקט דודיק diff --git a/assets/lang/hr_HR.ini b/assets/lang/hr_HR.ini index 6e65118dec..a6465719e8 100644 --- a/assets/lang/hr_HR.ini +++ b/assets/lang/hr_HR.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto mjerenje Backend = Backend Balanced = Balansirano Bicubic = Bikubično -BlockTransferRequired = Upozorenje: Ova igra zahtijeva "simulirajte blok transfer efekte" da budu postavljeni na Uključeno. Both = Oboje Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Upozorenje: Ova igra zahtijeva "prikazni način" da bude postavljen na "ublaženo". @@ -498,6 +497,7 @@ Frame Skipping = Preskakanje sličica Frame Skipping Type = Vrsta preskakanja sličica FullScreen = Puni zaslon GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Opcije hakiranja (može uzrokovati glitcheve) Hardware Tessellation = Hardware tesselacija Hardware Transform = Hardver mozaik @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Mjerenje filtriranje zaslona Show Debug Statistics = Pokaži statistike otklanjanja grešaka Show FPS Counter = Pokaži FPS counter -Simulate Block Transfer = Simuliraj blok transfer efekte +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Žbukanje softvera (sporo) Software Skinning = Skiniranje softvera SoftwareSkinning Tip = Kombiniraj skinirane modele crteža na CPU, brže u većini igara Speed = Brzina +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Rastezanje Texture Filter = Filtar tekstura Texture Filtering = Filtriranje tekstura diff --git a/assets/lang/hu_HU.ini b/assets/lang/hu_HU.ini index 8f2b003a41..945b81fab2 100644 --- a/assets/lang/hu_HU.ini +++ b/assets/lang/hu_HU.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatikus skálázás Backend = Backend Balanced = Kiegyensúlyozott Bicubic = Bicubic -BlockTransferRequired = Figyelem: Ehhez a játékhoz be kell kapcsolni a "Blokk transzfer effektek szimulálása" opciót! Both = Mindkettő Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Figyelem: Ehhez a játékhoz a "Renderelési mód" beállítást "Bufferelt"-re kell állítani! @@ -498,6 +497,7 @@ Frame Skipping = Képkocka kihagyás Frame Skipping Type = Képkocka kihagyás típusa FullScreen = Teljes képernyő GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack beállítások (ezek HIBÁKAT OKOZHATNAK) Hardware Tessellation = Hardveres tesszeláció Hardware Transform = Hardveres transzform @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Képernyő skálázási szűrő Show Debug Statistics = Hibakeresési statisztikák mutatása Show FPS Counter = FPS számláló mutatása -Simulate Block Transfer = Blokk transzfer effektek szimulálása +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Szoftveres renderelés (lassú) Software Skinning = Szoftveres "skinning" SoftwareSkinning Tip = "Skinning" művelet elvégzése a processzoron. Sok játék esetében gyorsabb. Speed = Sebesség +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Nyújtás Texture Filter = Textúra szűrés Texture Filtering = Textúra szűrés diff --git a/assets/lang/id_ID.ini b/assets/lang/id_ID.ini index f28ff33fac..c1fe30cf77 100644 --- a/assets/lang/id_ID.ini +++ b/assets/lang/id_ID.ini @@ -468,7 +468,6 @@ Auto Scaling = Penskala otomatis Backend = Penyangga grafis Balanced = Seimbang Bicubic = Bikubik -BlockTransferRequired = Peringatan: Permainan ini membutuhkan "Simulasikan efek transfer blok" dalam keadaan menyala. Both = Keduanya Buffer graphics commands (faster, input lag) = Perintah grafis penyangga (lebih cepat, masukan lag) BufferedRenderingRequired = Peringatan: Permainan ini membutuhkan "Mode pelukisan" yang ditetapkan "Penyangga". @@ -498,6 +497,7 @@ Frame Skipping = Lewati laju bingkai Frame Skipping Type = Jenis lewati laju bingkai FullScreen = Layar penuh GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Retas pengaturan (menyebabkan kecacatan) Hardware Tessellation = Pengujian perangkat keras Hardware Transform = Transformasi perangkat keras @@ -545,11 +545,12 @@ Screen layout = Tata letak layar Screen Scaling Filter = Pemfilteran penskala layar Show Debug Statistics = Tampilkan statistik awakutu Show FPS Counter = Tampilkan penghitung FPS -Simulate Block Transfer = Simulasikan efek transfer blok +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Pelukisan perangkat lunak (eksperimental) Software Skinning = Pengkulitan perangkat lunak SoftwareSkinning Tip = Menggabungkan model berkulit pada CPU, lebih cepat di kebanyakan permainan Speed = Kecepatan +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Peregangan Texture Filter = Filter tekstur Texture Filtering = Pemfilteran tekstur diff --git a/assets/lang/it_IT.ini b/assets/lang/it_IT.ini index 68d08f8a93..5ca9f3470e 100644 --- a/assets/lang/it_IT.ini +++ b/assets/lang/it_IT.ini @@ -468,7 +468,6 @@ Auto Scaling = Scaling automatico Backend = Renderer Balanced = Bilanciato Bicubic = Bicubico -BlockTransferRequired = Attenzione: Questo gioco richiede l'attivazione di 'Simula gli effetti del blocco trasferimento'. Both = Entrambi Buffer graphics commands (faster, input lag) = Comandi grafici bufferizzati (più rapido, più lag dei comandi) BufferedRenderingRequired = Attenzione: Questo gioco richiede di impostare "modalità di rendering" su "buffered". @@ -487,7 +486,7 @@ Deposterize Tip = Sistema i possibili problemi visivi nelle texture upscalate Device = Dispositivo Direct3D 9 = Direct3D 9 Direct3D 11 = Direct3D 11 -Disable slower effects (speedup) = Disattiva gli effetti più lenti (veloce) +#Disable slower effects (speedup) = Disattiva gli effetti più lenti (veloce) Disabled = Disabilitato Display layout editor = Editor Display Display Resolution (HW scaler) = Risoluzione Display (scaler HW) @@ -499,6 +498,7 @@ Frame Skipping = Salto frame Frame Skipping Type = Tipo di Salto frame FullScreen = Schermo Intero GPU log profiler = Log profilo GPU +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Impostazioni Hack (causerà dei problemi, sicuramente) Hardware Tessellation = Tassellazione Hardware Hardware Transform = Trasformazione Hardware @@ -546,11 +546,12 @@ Screen layout = Disposizione dello schermo Screen Scaling Filter = Filtro Scalatura Schermo Show Debug Statistics = Mostra Statistiche Debug Show FPS Counter = Mostra FPS -Simulate Block Transfer = Simula gli effetti del blocco trasferimento +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Rendering tramite Software (sperimentale) Software Skinning = Software Skinning SoftwareSkinning Tip = Combina la visualizzazione di modelli disegnati dalla CPU, più veloce nella maggior parte dei giochi Speed = Velocità +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Adatta al Display Texture Filter = Filtro delle texture Texture Filtering = Filtraggio delle texture @@ -723,6 +724,8 @@ Center Left = Al centro a sinistra Center Right = Al centro a destra Change Mac Address = Cambia indirizzo MAC Change proAdhocServer Address = Cambia indirizzo server IP PRO ad hoc (localhost = istanze multiple) +ChangeMacSaveConfirm = Generate a new MAC address? +ChangeMacSaveWarning = Some games verify the MAC address when loading savedata, so this may break old saves. Chat = Chat Chat Button Position = Posizione del pulsante chat Chat Here = Scrivi qui diff --git a/assets/lang/ja_JP.ini b/assets/lang/ja_JP.ini index 3d0f6eafc4..d49482846e 100644 --- a/assets/lang/ja_JP.ini +++ b/assets/lang/ja_JP.ini @@ -468,7 +468,6 @@ Auto Scaling = 自動的に拡大 Backend = バックエンド Balanced = バランス Bicubic = Bicubic -BlockTransferRequired = 警告: このゲームは「ブロック転送の効果をシミュレートする」をオンにする必要があります。 Both = 両方 Buffer graphics commands (faster, input lag) = グラフィックスコマンドをバッファする (高速, 入力ラグあり) BufferedRenderingRequired = 警告: このゲームは「レンダリングモード」を「バッファ」にする必要があります。 @@ -498,6 +497,7 @@ Frame Skipping = フレームスキップ Frame Skipping Type = フレームスキップのタイプ FullScreen = フルスクリーン GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = ハックの設定 (不具合あり) Hardware Tessellation = ハードウェアテッセレーション Hardware Transform = ハードウェアトランスフォーム @@ -545,11 +545,12 @@ Screen layout = 画面のレイアウト Screen Scaling Filter = 画像スケーリングのフィルタ Show Debug Statistics = デバッグ情報を表示する Show FPS Counter = FPSを表示する -Simulate Block Transfer = ブロック転送の効果をシミュレートする +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = ソフトウェアレンダリング (実験的) Software Skinning = ソフトウェアスキニング SoftwareSkinning Tip = スキンモデルの描画をCPUでまとめて行う。ほとんどのゲームが高速化します Speed = 速度 +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = 拡大 Texture Filter = テクスチャフィルタ Texture Filtering = テクスチャフィルタリング diff --git a/assets/lang/jv_ID.ini b/assets/lang/jv_ID.ini index b522a9a4c1..328bb6a46f 100644 --- a/assets/lang/jv_ID.ini +++ b/assets/lang/jv_ID.ini @@ -468,7 +468,6 @@ Auto Scaling = Njongko Otomatis Backend = Backend Balanced = Imbang Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Kelorone Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Frame-skip Frame Skipping Type = Frame skipping type FullScreen = Layar Penuh GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Retas setelsn (nyebabake glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Ndandani Hardware @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Layar njongko Filter Show Debug Statistics = Tampilno statistik debug Show FPS Counter = Tampilno penghitung FPS -Simulate Block Transfer = Simulasi efek transfer pemblokiran +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software rendering (jajalan) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Kacepetan +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Penyaring Tekstur Texture Filtering = Penyaring Tekstur diff --git a/assets/lang/ko_KR.ini b/assets/lang/ko_KR.ini index 337f624cf5..ea067713be 100644 --- a/assets/lang/ko_KR.ini +++ b/assets/lang/ko_KR.ini @@ -468,7 +468,6 @@ Auto Scaling = 자동 스케일링 Backend = 백엔드 Balanced = 평형 Bicubic = 고등차수보간 -BlockTransferRequired = 경고: 이 게임은 "블록 전송 효과 시뮬레이션"을 켬으로 설정해야 합니다. Both = 둘 다 Buffer graphics commands (faster, input lag) = 버퍼 그래픽 명령 (빠름, 입력 지연) BufferedRenderingRequired = 경고: 이 게임은 "렌더링 모드"를 "버퍼링"으로 설정해야 합니다. @@ -497,6 +496,7 @@ Frame Rate Control = 프레임속도 제어 Frame Skipping = 프레임 생략 Frame Skipping Type = 프레임 생략 유형 FullScreen = 전체화면 +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = 핵 설정 (결함을 일으킬 수 있음) Hardware Tessellation = 하드웨어 조각화 Hardware Transform = 하드웨어 변환 @@ -544,11 +544,12 @@ Screen layout = 화면 레이아웃 Screen Scaling Filter = 화면 크기 조정 필터 Show Debug Statistics = 디버그 통계 표시 Show FPS Counter = FPS 카운터 표시 -Simulate Block Transfer = 블록 전송 효과 시뮬레이션 +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = 소프트웨어 렌더링 (느림) Software Skinning = 소프트웨어 스키닝 SoftwareSkinning Tip = 대부분의 게임에서 더 빠르게 CPU에서 스킨 모델 드로우를 결합합니다. Speed = 속도 +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = 늘이기 Texture Filter = 텍스처 필터링 Texture Filtering = 텍스처 필터링 diff --git a/assets/lang/lo_LA.ini b/assets/lang/lo_LA.ini index a5133a73ae..64f175d367 100644 --- a/assets/lang/lo_LA.ini +++ b/assets/lang/lo_LA.ini @@ -468,7 +468,6 @@ Auto Scaling = ປັບຂະໜາດສເກລອັດຕະໂນມັ Backend = ການສະໜັບສະໜູນ Balanced = ສົມດຸນ Bicubic = Bicubic -BlockTransferRequired = ຄຳເຕືອນ: ເກມນີ້ຕ້ອງການໃຫ້ເປີດໂໝດ "ຈຳລອງຜົນປິດກັ້ນການສົ່ງຜ່ານຂໍ້ມູນເອັບເຟກ" ນຳ Both = ໃຊ້ທັງ FPS ແລະ Speed Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = ຂ້າມເຟຣມ Frame Skipping Type = Frame skipping type FullScreen = ເຕັມໜ້າຈໍ GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = ການຕັ້ງຄ່າແຮັກ Hardware Tessellation = Hardware tessellation Hardware Transform = ໃຊ້ຮາດແວຣ໌ປະມວນຜົນ @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = ໂຕຕອງປັບສເກລໜ້າຈໍ Show Debug Statistics = ສະແດງຄ່າທາງສະຖິຕິການແກ້ໄຂຈຸດບົກພ່ອງ Show FPS Counter = ສະແດງຄ່າເຟຣມເຣດ ແລະ ຄວາມໄວ/ວິນາທີ -Simulate Block Transfer = ຈຳລອງຜົນປິດກັ້ນການສົ່ງຜ່ານຂໍ້ມູນເອັບເຟກ +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = ໃຊ້ຊອບແວຣ໌ສະແດງຜົນ (ລຸ້ນທົດລອງ) Software Skinning = ຊ໋ອບແວຣ໌ສກິນນິງ SoftwareSkinning Tip = ປະສານໂມເດລພື້ນຜິວໃຫ້ຂຽນຜ່ານ CPU, ເກມສ່ວນໃຫຍ່ໃຊ້ແລ້ວໄວຂຶ້ນ Speed = ຄວາມໄວ +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = ດຶງເຕັມຈໍ Texture Filter = ໂຕຕອງພື້ນຜິວ Texture Filtering = ຕອງພື້ນຜິວ diff --git a/assets/lang/lt-LT.ini b/assets/lang/lt-LT.ini index 494653f8f5..d01df7a0ad 100644 --- a/assets/lang/lt-LT.ini +++ b/assets/lang/lt-LT.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = "Bicubic" -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Abu Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Kadrų praleidimas Frame Skipping Type = Frame skipping type FullScreen = Pilnas ekranas GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Modifikavimo parametrai (gali sukelti problemų) Hardware Tessellation = Hardware tessellation Hardware Transform = Aparatūros transformacija @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Rodyti testinio režimo statistikas Show FPS Counter = Rodyti kadrų per sekundę rodmenis -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Programinės įrangos rodymas(ekspermentalus) Software Skinning = Programinės įrangos "nulupimas" SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Greitis +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Tekstūrų filtravimas Texture Filtering = Tekstūrų filtravimas diff --git a/assets/lang/ms_MY.ini b/assets/lang/ms_MY.ini index 801a373dfe..cb7a06426d 100644 --- a/assets/lang/ms_MY.ini +++ b/assets/lang/ms_MY.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bikubik -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Keduanya Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Pelompatan Frame Frame Skipping Type = Frame skipping type FullScreen = Skrin penuh GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Godam tetapan (mungkin menyebabkan gangguan) Hardware Tessellation = Hardware tessellation Hardware Transform = Penukaran Alatan @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Papar statistik pepijat Show FPS Counter = Papar penghitung FPS -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Render perisian (eksperimen) Software Skinning = Pembalutan Perisian SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Laju +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Penapis Tekstur Texture Filtering = Penapisan Tekstur diff --git a/assets/lang/nl_NL.ini b/assets/lang/nl_NL.ini index 83a6aba047..8a4a3c3339 100644 --- a/assets/lang/nl_NL.ini +++ b/assets/lang/nl_NL.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatisch schalen Backend = Backend Balanced = Gebalanceerd Bicubic = Bicubisch -BlockTransferRequired = Waarschuwing: Deze game vereist de optie Blokoverdrachteffecten simuleren. Both = Beide Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Waarschuwing: Deze game vereist een "gebufferde renderingmodus". @@ -498,6 +497,7 @@ Frame Skipping = Frames overslaan Frame Skipping Type = Frame skipping type FullScreen = Volledig scherm GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hackinstellingen (kan glitches veroorzaken) Hardware Tessellation = Hardwarebetegeling Hardware Transform = Hardwaretransformatie @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Beeldschalingsfilter Show Debug Statistics = Foutopsporingsstatistieken weergeven Show FPS Counter = FPS-teller weergeven -Simulate Block Transfer = Blokoverdrachteffecten simuleren +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderen via software (experimenteel) Software Skinning = Skinning via software SoftwareSkinning Tip = Vermindert aantal renders en is sneller in games die de geavanceerde skinningtechniek gebruiken, maar voor sommige games trager Speed = Snelheid +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Uitrekken Texture Filter = Texturefilter Texture Filtering = Texturefilter diff --git a/assets/lang/no_NO.ini b/assets/lang/no_NO.ini index cceaa22382..5baf3a6c55 100644 --- a/assets/lang/no_NO.ini +++ b/assets/lang/no_NO.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balanced Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Begge Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Ramme Hoppe over Frame Skipping Type = Frame skipping type FullScreen = Fullskjerm GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack settings (may cause glitches) Hardware Tessellation = Hardware tessellation Hardware Transform = Maskinvare omdanning @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen scaling filter Show Debug Statistics = Vis debugstatistik Show FPS Counter = Vis FPS-teller -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Programvare gjengivelse (eksperiment) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Hastighet +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Tekstur filtrering Texture Filtering = Tekstur filtrering diff --git a/assets/lang/pl_PL.ini b/assets/lang/pl_PL.ini index 5b067680e3..25c17fef2f 100644 --- a/assets/lang/pl_PL.ini +++ b/assets/lang/pl_PL.ini @@ -468,7 +468,6 @@ Auto Scaling = Automatyczne skalowanie Backend = Sterownik graficzny Balanced = Zbalansowane Bicubic = Bicubic (Dwusześcienne) -BlockTransferRequired = Uwaga: Ta gra wymaga włączonej opcji "Symuluj efekty transferu bloków". Both = Oba Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Uwaga: Ta gra wymaga włączonej opcji "Renderowanie buforowe". @@ -498,6 +497,7 @@ Frame Skipping = Pomijanie klatek Frame Skipping Type = Tryb pomijania klatek FullScreen = Pełny ekran GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Ustawienia specjalne (powodują problemy) Hardware Tessellation = Sprzętowa teselacja Hardware Transform = Transformacja sprzętowa @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Filtrowanie skalowania ekranu Show Debug Statistics = Pokaż statystyki debugowania Show FPS Counter = Pokaż licznik FPS -Simulate Block Transfer = Symuluj efekty transferu bloków +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderowanie programowe (wolne) Software Skinning = Programowy skinning SoftwareSkinning Tip = Łączy na CPU wywołania rysujące modele z animacjami, przyspieszenie w większości gier Speed = Prędkość (procentowo) +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Rozciąganie Texture Filter = Filtrowanie tekstur Texture Filtering = Filtrowanie tekstur diff --git a/assets/lang/pt_BR.ini b/assets/lang/pt_BR.ini index 45d7e1b867..970025ecb0 100644 --- a/assets/lang/pt_BR.ini +++ b/assets/lang/pt_BR.ini @@ -492,7 +492,6 @@ Auto Scaling = Auto-redimensionamento Backend = Backend Balanced = Balanceado Bicubic = Bi-cúbico -BlockTransferRequired = Aviso: Esse jogo requer que a "simulação dos efeitos de transferência dos blocos" esteja definida como Ligada. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer dos comandos dos gráficos (mais rápido, atraso na entrada dos dados) BufferedRenderingRequired = Aviso: Este jogo requer que o "modo de renderização" esteja definido "com buffer". @@ -521,6 +520,7 @@ Frame Rate Control = Controle da taxa dos frames Frame Skipping = Pulo dos frames Frame Skipping Type = Tipo de pulo dos frames FullScreen = Tela cheia +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Configurações dos hacks (pode causar erros gráficos) Hardware Tessellation = Tesselação por hardware Hardware Transform = Transformação por hardware @@ -568,11 +568,12 @@ Screen layout = Esquema da tela Screen Scaling Filter = Filtro do dimensionamento da tela Show Debug Statistics = Mostrar estatísticas do debug Show FPS Counter = Mostrar contador de FPS -Simulate Block Transfer = Simular efeitos de transferência dos blocos +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderização por software (lento) Software Skinning = Skinning via software SoftwareSkinning Tip = Combina os desenhos dos modelos de skinning na CPU, mais rápido na maioria dos jogos Speed = Velocidade +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Esticamento Texture Filter = Filtragem das texturas Texture Filtering = Filtragem das texturas diff --git a/assets/lang/pt_PT.ini b/assets/lang/pt_PT.ini index 054d8f0dfd..244bc14492 100644 --- a/assets/lang/pt_PT.ini +++ b/assets/lang/pt_PT.ini @@ -492,7 +492,6 @@ Auto Scaling = Auto-redimensionamento Backend = Backend Balanced = Balanceado Bicubic = Bi-cúbico -BlockTransferRequired = Aviso: Este jogo requer que a "Simulação dos Efeitos de Transferência dos Blocos" esteja habilitada. Both = Ambos Buffer graphics commands (faster, input lag) = Buffer dos Comandos Gráficos (mais rápido, atraso na entrada dos dados) BufferedRenderingRequired = Aviso: Este jogo requer que o "modo de renderização" esteja definido "com buffer". @@ -521,6 +520,7 @@ Frame Rate Control = Controle da taxa dos quadros Frame Skipping = Pulo dos quadros Frame Skipping Type = Tipo de pulo dos quadros FullScreen = Tela Cheia +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Definições dos Hacks (pode causar erros gráficos) Hardware Tessellation = Tesselação por Hardware Hardware Transform = Transformação por Hardware @@ -568,11 +568,12 @@ Screen layout = Esquema da tela Screen Scaling Filter = Filtro do dimensionamento da tela Show Debug Statistics = Mostrar estatísticas de depuração Show FPS Counter = Mostrar contador de FPS -Simulate Block Transfer = Simular efeitos de transferência dos blocos +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Renderização por software (lento) Software Skinning = Skinning via software SoftwareSkinning Tip = Combina os desenhos dos modelos de skinning na CPU, mais rápido na maioria dos jogos Speed = Velocidade +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Esticamento Texture Filter = Filtração das texturas Texture Filtering = Filtração das texturas diff --git a/assets/lang/ro_RO.ini b/assets/lang/ro_RO.ini index 38d47a05b1..c639b659ae 100644 --- a/assets/lang/ro_RO.ini +++ b/assets/lang/ro_RO.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Mod intern Balanced = Balansat Bicubic = Bicubic -BlockTransferRequired = Warning: This game requires "simulate block transfer effects" to be set to On. Both = Ambele Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Cadre Omise Frame Skipping Type = Frame skipping type FullScreen = Ecran intreg GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Setări trișare (pot cauza stricăciuni) Hardware Tessellation = Hardware tessellation Hardware Transform = Transformare pe Hardware @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Filtrul de scalare al ecranului Show Debug Statistics = Arată statistici de depanare Show FPS Counter = Arată FPS -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Afișare cu sofware (experimental) Software Skinning = Skinning cu software SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Viteză +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Filtru texturi Texture Filtering = Filtrare texturi diff --git a/assets/lang/ru_RU.ini b/assets/lang/ru_RU.ini index 082b087730..5b02a758d1 100644 --- a/assets/lang/ru_RU.ini +++ b/assets/lang/ru_RU.ini @@ -468,7 +468,6 @@ Auto Scaling = Автомасштаб Backend = Бэкенд Balanced = Сбалансированно Bicubic = Бикубический -BlockTransferRequired = Предупреждение: для этой игры требуется включить "Симуляцию эффектов от передачи блоков" Both = Оба Buffer graphics commands (faster, input lag) = Команды буферированной графики (быстрее, задержка ввода) BufferedRenderingRequired = Предупреждение: для этой игры требуется буферированный режим рендеринга. @@ -499,6 +498,7 @@ Frame Skipping = Пропуск кадров Frame Skipping Type = Тип пропуска кадров FullScreen = Полноэкранный режим GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Параметры хаков (могут вызывать глюки) Hardware Tessellation = Аппаратная тесселяция Hardware Transform = Аппаратное преобразование @@ -546,11 +546,12 @@ Screen layout = Расположение экрана Screen Scaling Filter = Фильтр масштабирования экрана Show Debug Statistics = Отображать отладочную информацию Show FPS Counter = Показывать счетчик FPS -Simulate Block Transfer = Симулировать эффекты от передачи блоков +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Программный рендеринг (медленно) Software Skinning = Программная заливка SoftwareSkinning Tip = Объединяет вызовы отрисовки моделей с заливкой на ЦП, быстрее во многих играх Speed = Скорость +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Растягивание Texture Filter = Текстурный фильтр Texture Filtering = Фильтрация текстур diff --git a/assets/lang/sv_SE.ini b/assets/lang/sv_SE.ini index 247e593a79..03a8b4d574 100644 --- a/assets/lang/sv_SE.ini +++ b/assets/lang/sv_SE.ini @@ -468,7 +468,6 @@ Auto Scaling = Auto scaling Backend = Backend Balanced = Balancerad Bicubic = Bicubisk -BlockTransferRequired = Varning: Detta spel kräver att "Simulera blocktransfer-effekter" är påslaget. Both = Båda Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Warning: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Frameskipping Frame Skipping Type = Frame skipping type FullScreen = Fullskärm GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack-inställningar (kan orsaka problem) Hardware Tessellation = Hårdvarutessellering Hardware Transform = Hårdvarutransform @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Skärmskalningsfilter Show Debug Statistics = Visa debugstatistik Show FPS Counter = Visa FPS-räknare -Simulate Block Transfer = Simulera blocktransfer-effekter +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Mjukvarurendering (experiment) Software Skinning = Software Skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Hastighet +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Texturfilter Texture Filtering = Texturfiltrering diff --git a/assets/lang/tg_PH.ini b/assets/lang/tg_PH.ini index 4815c0023c..7f90a8349d 100644 --- a/assets/lang/tg_PH.ini +++ b/assets/lang/tg_PH.ini @@ -468,7 +468,6 @@ Auto Scaling = Awto scaling Backend = Backend Balanced = Balanse Bicubic = Bicubic -BlockTransferRequired = BABALA: This game requires "simulate block transfer effects" to be set to On. Both = Pareho Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = BABALA: This game requires "rendering mode" to be set to "buffered". @@ -498,6 +497,7 @@ Frame Skipping = Frame Skipping Frame Skipping Type = Frame skipping type FullScreen = Isakto sa Sukat ng iyong Iskrin GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack Settings (maaring magdulot ng pagloloko sa laro) Hardware Tessellation = Hardware tessellation Hardware Transform = Hardware Transform @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Screen Scaling Filter Show Debug Statistics = Ipakita ang debug statistics Show FPS Counter = Ipakita ang FPS -Simulate Block Transfer = Simulate block transfer effects +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Software Rendering (Expiremental) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Bilis +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Iunat Texture Filter = Panala ng Texture Texture Filtering = Pagsala sa Texture diff --git a/assets/lang/th_TH.ini b/assets/lang/th_TH.ini index 422f06b13f..d9a6d1eff6 100644 --- a/assets/lang/th_TH.ini +++ b/assets/lang/th_TH.ini @@ -468,7 +468,6 @@ Auto Scaling = สเกลอัตโนมัติ Backend = การสนับสนุนกราฟิก Balanced = สมดุล Bicubic = ไบคิวบิค -BlockTransferRequired = คำเตือน: เกมนี้ต้องปรับใช้งาน "จำลองผลปิดกั้นการส่งผ่านข้อมูลเอฟเฟ็คท์" ด้วย Both = ใช้ทั้งคู่ Buffer graphics commands (faster, input lag) = ควบคุมกราฟิกบัฟเฟอร์ (เร็วขึ้น, อาจทำให้เกิดอินพุตแล็ก) BufferedRenderingRequired = คำเตือน: เกมนี้ต้องปรับใช้งานในโหมด "การแสดงผลแบบใช้บัฟเฟอร์" @@ -498,6 +497,7 @@ Frame Skipping = ข้ามเฟรม Frame Skipping Type = รูปแบบการข้ามเฟรม FullScreen = เต็มหน้าจอ GPU log profiler = ตัวแสดงค่าโปรไฟล์ GPU +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = ตั้งค่าการปรับแฮ็ค (อาจแสดงผลผิดพลาด) Hardware Tessellation = ฮาร์ดแวร์ เทสเซลเลชั่น Hardware Transform = ใช้ฮาร์ดแวร์ในการแปลงค่าประมวลผล @@ -545,11 +545,12 @@ Screen layout = เค้าโครงหน้าจอ Screen Scaling Filter = ตัวกรองปรับสเกลหน้าจอ Show Debug Statistics = แสดงค่าทางสถิติการแก้ไขจุดบกพร่อง Show FPS Counter = แสดงค่าเฟรมเรท และความเร็ว/วินาที -Simulate Block Transfer = จำลองผลปิดกั้นการส่งผ่านข้อมูลเอฟเฟ็คท์ +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = ใช้ซอฟต์แวร์ในการแสดงผล (ช้า) Software Skinning = ซอฟต์แวร์ สกินนิ่ง SoftwareSkinning Tip = ผสานโมเดลพื้นผิวให้เขียนผ่านซีพียู ซึ่งเกมส่วนใหญ่ปรับใช้แล้วไวขึ้น Speed = ความเร็ว +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = ดึงเต็มจอ Texture Filter = ตัวกรองพื้นผิว Texture Filtering = การกรองพื้นผิว diff --git a/assets/lang/tr_TR.ini b/assets/lang/tr_TR.ini index 3bdaf3ef39..96a1ccb313 100644 --- a/assets/lang/tr_TR.ini +++ b/assets/lang/tr_TR.ini @@ -470,7 +470,6 @@ Auto Scaling = Otomatik ölçekleme Backend = Arkauç Balanced = Dengeli Bicubic = Çift Kübik -BlockTransferRequired = Uyarı: Bu oyun Blok Aktarım Simülasyon Modunun Açık olmasını gerektirir. Both = İkisi de Buffer graphics commands (faster, input lag) = Grafik komutlarını arabellekle (daha hızlı, input lag'e sebep olabilir) BufferedRenderingRequired = Uyarı: Bu oyun "işleme modunun" "yükleyerek işleme"ye alınmasını gerektirir. @@ -489,7 +488,6 @@ Deposterize Tip = Yeniden ölçeklenen dokulardaki görsel şerit hatalarını d Device = Cihaz Direct3D 9 = Direct3D 9 Direct3D 11 = Direct3D 11 -Disable slower effects (speedup) = Daha yavaş efektleri kapatın (daha hızlı) Disabled = Devre dışı Display layout editor = Görüntü Düzeni Düzenleyicisi Display Resolution (HW scaler) = Görüntü Çözünürlüğü (HW scaler) @@ -501,6 +499,7 @@ Frame Skipping = Kare atla Frame Skipping Type = Kare atlama türü FullScreen = Tam ekran GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Hack ayarları (Küçük teknik problemlere neden olabilir.) Hardware Tessellation = Donanım Mozaikleme Hardware Transform = Donanım dönüştürme @@ -548,11 +547,12 @@ Screen layout = Ekran düzeni Screen Scaling Filter = Ekran ölçekleme filtresi Show Debug Statistics = Hata ayıklama istatistiklerini göster Show FPS Counter = FPS sayacını göster -Simulate Block Transfer = Blok aktarım efektlerini simüle edin +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Yazılımsal işleme (Deneysel) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Hız +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Serbest tam ekran (sünme) Texture Filter = Doku filtreleme Texture Filtering = Doku filtreleme @@ -754,6 +754,8 @@ Center Left = Sol orta Center Right = Sağ orta Change Mac Address = MAC adresini değiştir Change proAdhocServer Address = PRO Ad Hoc Server IP adresini değiştir (localhost = çoklu örnek) +ChangeMacSaveConfirm = Generate a new MAC address? +ChangeMacSaveWarning = Some games verify the MAC address when loading savedata, so this may break old saves. Chat = Chat Chat Button Position = Chat düğmesinin konumu Chat Here = Buraya yazın diff --git a/assets/lang/uk_UA.ini b/assets/lang/uk_UA.ini index 2105606270..5c57d9af18 100644 --- a/assets/lang/uk_UA.ini +++ b/assets/lang/uk_UA.ini @@ -468,7 +468,6 @@ Auto Scaling = Автоматичне масштабування Backend = Бекенд Balanced = Збалансовано Bicubic = Бікубічний -BlockTransferRequired = Попередження: Ця гра вимагає, щоб "імітувати ефекти передачі блоку" було встановлено на Увімкнено. Both = Обидва Buffer graphics commands (faster, input lag) = Буферні графічні команди (швидше, можливі глюки) BufferedRenderingRequired = Попередження: Ця гра вимагає, щоб "режим візуалізації" був встановлений на "буферний". @@ -498,6 +497,7 @@ Frame Skipping = Пропуск кадрів Frame Skipping Type = Тип пропуску кадрів FullScreen = Повноекранний режим GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Параметри хаків (можуть викликати глюки) Hardware Tessellation = Апаратна тесселляція Hardware Transform = Апаратне перетворення @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Фільтр обчислення екрану Show Debug Statistics = Відоброжати зневадження Show FPS Counter = Показати FPS -Simulate Block Transfer = Симулювати ефекти від передачі блоків +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Програмний рендеринг (експериментально) Software Skinning = Програмна заливка SoftwareSkinning Tip = Комбінована модель розібраної моделі яка притягується до процесора, швидше в більшості ігор Speed = Швидкість +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Розтягнення Texture Filter = Фільтр текстур Texture Filtering = Фільтрація текстур diff --git a/assets/lang/vi_VN.ini b/assets/lang/vi_VN.ini index 2cf347c956..6aed763937 100644 --- a/assets/lang/vi_VN.ini +++ b/assets/lang/vi_VN.ini @@ -468,7 +468,6 @@ Auto Scaling = Tự động nhân rộng Backend = Thư viện đồ họa Balanced = Cân bằng Bicubic = Bicubic (mịn) -BlockTransferRequired = Cảnh báo: Trò chơi này yêu cầu mở "simulate block transfer effects" Both = Cả hai Buffer graphics commands (faster, input lag) = Buffer graphics commands (faster, input lag) BufferedRenderingRequired = Cảnh báo: Trò chơi này yêu cầu "chế độ kết xuất" được đặt thành "được đệm". @@ -498,6 +497,7 @@ Frame Skipping = Nhảy khuôn hình Frame Skipping Type = Frame skipping type FullScreen = Toàn màn hình GPU log profiler = GPU log profiler +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = Thiết lập hack (sẽ bị lỗi) Hardware Tessellation = Lót phần cứng Hardware Transform = Chuyển đổi phần cứng @@ -545,11 +545,12 @@ Screen layout = Screen layout Screen Scaling Filter = Bộ lọc họa tiết rộng Show Debug Statistics = Hiện thông số debug Show FPS Counter = Hiện thông số FPS -Simulate Block Transfer = Mô phỏng truyền tải khối vật thể , hiệu ứng +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = Dựng hình bằng phần mềm Software Skinning = phủ lớp bằng phần mềm SoftwareSkinning Tip = Mô hình kết hợp vẽ trên CPU, nhanh hơn trong hầu hết các trò chơi Speed = Tốc độ +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = Stretching Texture Filter = Bộ lọc họa tiết Texture Filtering = Lọc texture diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index 42bdca4099..d5bd28529b 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -468,7 +468,6 @@ Auto Scaling = 自动缩放 Backend = 渲染引擎 Balanced = 均衡 Bicubic = 双三次 -BlockTransferRequired = 警告:此游戏需要将"模拟块传输模式"设置为开。 Both = 全部显示 Buffer graphics commands (faster, input lag) = 缓冲图形命令(更快, 有输入延迟) BufferedRenderingRequired = 警告:此游戏需要将"渲染模式"设置为"缓冲渲染"。 @@ -498,6 +497,7 @@ Frame Skipping = 跳帧 Frame Skipping Type = 跳帧方式 FullScreen = 全屏幕 GPU log profiler = GPU日志分析器 +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = 渲染修正(可能引发故障) Hardware Tessellation = 硬件曲面细分 Hardware Transform = 硬件几何变换 @@ -545,11 +545,12 @@ Screen layout = 屏幕布局 Screen Scaling Filter = 屏幕缩放滤镜 Show Debug Statistics = 显示调试信息 Show FPS Counter = 显示FPS计数器 -Simulate Block Transfer = 模拟数据块传输效果 +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = 软件渲染(慢) Software Skinning = 软件蒙皮 SoftwareSkinning Tip = 合并CPU中已经蒙皮的模型绘制,在部分游戏中更快 Speed = 运行速度 +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = 拉伸 Texture Filter = 纹理过滤方式 Texture Filtering = 纹理过滤 @@ -709,7 +710,6 @@ Up = 方向键:上 Vol + = 音量+ Vol - = 音量- Wlan = 无线网络 -Analog speed = 模拟速度 [MemStick] Already contains PSP data = 已含有PSP数据 diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index a1cbd6c878..0b2ec4b154 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -468,7 +468,6 @@ Auto Scaling = 自動縮放 Backend = 後端 Balanced = 平衡 Bicubic = 雙立方 -BlockTransferRequired = 警告:這個遊戲需要開啟「模擬區塊傳輸效果」 Both = 全部 Buffer graphics commands (faster, input lag) = 緩衝圖形命令 (更快,有輸入延遲) BufferedRenderingRequired = 警告:這個遊戲需要將「轉譯模式」設為「緩衝轉譯」 @@ -497,6 +496,7 @@ Frame Rate Control = 影格速率控制 Frame Skipping = 影格跳過 Frame Skipping Type = 影格跳過類型 FullScreen = 全螢幕 +GPUReadbackRequired = Warning: This game requires "Skip GPU Readbacks" to be set to Off. Hack Settings = 駭客設定 (可能會造成故障) Hardware Tessellation = 硬體鑲嵌式 Hardware Transform = 硬體轉換 @@ -544,11 +544,12 @@ Screen layout = 螢幕版面配置 Screen Scaling Filter = 螢幕縮放濾鏡 Show Debug Statistics = 顯示偵錯統計資料 Show FPS Counter = 顯示 FPS 計數器 -Simulate Block Transfer = 模擬區塊傳輸效果 +Skip GPU Readbacks = Skip GPU Readbacks Software Rendering = 軟體轉譯 (慢) Software Skinning = 軟體除皮 SoftwareSkinning Tip = 結合除皮模組在 CPU 上繪製,在多數遊戲上更快 Speed = 速度 +Speed Hacks = Speed Hacks (can cause rendering errors!) Stretching = 延伸 Texture Filter = 紋理濾鏡 Texture Filtering = 紋理濾鏡 From 9518aa09004b7730dbd326a6397dc742d1ffcf64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 20:01:03 +0100 Subject: [PATCH 368/374] Blind Qt fix --- Qt/mainwindow.cpp | 8 +++----- Qt/mainwindow.h | 12 +++--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp index 2560711684..fbe4a35c84 100644 --- a/Qt/mainwindow.cpp +++ b/Qt/mainwindow.cpp @@ -89,7 +89,6 @@ void MainWindow::updateMenus() updateMenuGroupInt(saveStateGroup, g_Config.iCurrentStateSlot); updateMenuGroupInt(displayRotationGroup, g_Config.iInternalScreenRotation); updateMenuGroupInt(renderingResolutionGroup, g_Config.iInternalResolution); - updateMenuGroupInt(renderingModeGroup, g_Config.iRenderingMode); updateMenuGroupInt(frameSkippingGroup, g_Config.iFrameSkip); updateMenuGroupInt(frameSkippingTypeGroup, g_Config.iFrameSkipType); updateMenuGroupInt(textureFilteringGroup, g_Config.iTexFiltering); @@ -599,6 +598,9 @@ void MainWindow::createMenus() gameSettingsMenu->add(new MenuAction(this, SLOT(fullscrAct()), QT_TR_NOOP("Fu&llscreen"), QKeySequence::FullScreen)) #endif ->addEventChecked(&g_Config.bFullScreen); + gameSettingsMenu->add(new MenuAction(this, SLOT(bufferRenderAct()), QT_TR_NOOP("&Skip buffer effects"))) + ->addEventChecked(&g_Config.bSkipBufferEffects); + MenuTree* renderingResolutionMenu = new MenuTree(this, gameSettingsMenu, QT_TR_NOOP("&Rendering resolution")); renderingResolutionGroup = new MenuActionGroup(this, renderingResolutionMenu, SLOT(renderingResolutionGroup_triggered(QAction *)), QStringList() << "&Auto" << "&1x" << "&2x" << "&3x" << "&4x" << "&5x" << "&6x" << "&7x" << "&8x" << "&9x" << "1&0x", @@ -609,10 +611,6 @@ void MainWindow::createMenus() QStringList() << "&1x" << "&2x" << "&3x" << "&4x" << "&5x" << "&6x" << "&7x" << "&8x" << "&9x" << "1&0x", QList() << 1 << 2 << 3 << 4 << 5 << 6 << 7 << 8 << 9 << 10); - MenuTree* renderingModeMenu = new MenuTree(this, gameSettingsMenu, QT_TR_NOOP("Rendering m&ode")); - renderingModeGroup = new MenuActionGroup(this, renderingModeMenu, SLOT(renderingModeGroup_triggered(QAction *)), - QStringList() << "&Skip buffered effects (non-buffered, faster)" << "&Buffered rendering", - QList() << 0 << 1); MenuTree* frameSkippingMenu = new MenuTree(this, gameSettingsMenu, QT_TR_NOOP("&Frame skipping")); frameSkippingMenu->add(new MenuAction(this, SLOT(autoframeskipAct()), QT_TR_NOOP("&Auto"))) ->addEventChecked(&g_Config.bAutoFrameSkip); diff --git a/Qt/mainwindow.h b/Qt/mainwindow.h index 87718b51cf..864a658b58 100644 --- a/Qt/mainwindow.h +++ b/Qt/mainwindow.h @@ -119,7 +119,6 @@ private slots: void moreSettingsAct() { NativeMessageReceived("settings", ""); } void bufferRenderAct() { - g_Config.iRenderingMode = !g_Config.iRenderingMode; NativeMessageReceived("gpu_resized", ""); } void linearAct() { g_Config.iTexFiltering = (g_Config.iTexFiltering != 0) ? 0 : 3; } @@ -134,15 +133,10 @@ private slots: g_Config.iSmallDisplayZoomType = action->data().toInt(); NativeMessageReceived("gpu_resized", ""); } - void renderingModeGroup_triggered(QAction *action) { - g_Config.iRenderingMode = action->data().toInt(); - g_Config.bAutoFrameSkip = false; - NativeMessageReceived("gpu_resized", ""); - } void autoframeskipAct() { g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip; - if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { - g_Config.iRenderingMode = FB_BUFFERED_MODE; + if (g_Config.bSkipBufferEffects) { + g_Config.bSkipBufferEffects = false; NativeMessageReceived("gpu_resized", ""); } } @@ -224,7 +218,7 @@ private: *textureScalingLevelGroup, *textureScalingTypeGroup, *screenScalingFilterGroup, *textureFilteringGroup, *frameSkippingTypeGroup, *frameSkippingGroup, - *renderingModeGroup, *renderingResolutionGroup, + *renderingResolutionGroup, *displayRotationGroup, *saveStateGroup; std::queue msgQueue_; From 69941c0d72ff18e1c2d9e18769fdb8a06c1de7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 20:01:22 +0100 Subject: [PATCH 369/374] Android fix --- GPU/Common/GPUStateUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index 47d11afb4a..c6fcfd7007 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -1265,7 +1265,7 @@ static void ConvertBlendState(GenericBlendState &blendState, bool forceReplaceBl // Some Android devices (especially old Mali, it seems) composite badly if there's alpha in the backbuffer. // So in non-buffered rendering, we will simply consider the dest alpha to be zero in blending equations. #ifdef __ANDROID__ - if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { + if (g_Config.bSkipBufferEffects) { if (glBlendFuncA == BlendFactor::DST_ALPHA) glBlendFuncA = BlendFactor::ZERO; if (glBlendFuncB == BlendFactor::DST_ALPHA) glBlendFuncB = BlendFactor::ZERO; if (glBlendFuncA == BlendFactor::ONE_MINUS_DST_ALPHA) glBlendFuncA = BlendFactor::ONE; From f597b4ca51c462a9bc6b0bf1e8cbc636a323121c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 20:01:29 +0100 Subject: [PATCH 370/374] Blind libretro fix --- libretro/libretro.cpp | 24 ++++++++++++------------ libretro/libretro_core_options.h | 32 ++++++++++++++------------------ 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index ec07b1dc67..4213a72758 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -745,22 +745,22 @@ static void check_variables(CoreParameter &coreParam) g_Config.iInternalResolution = 10; } - var.key = "ppsspp_rendering_mode"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (!strcmp(var.value, "Buffered")) - g_Config.iRenderingMode = FB_BUFFERED_MODE; - else if (!strcmp(var.value, "Skip Buffer Effects")) - g_Config.iRenderingMode = FB_NON_BUFFERED_MODE; - } - - var.key = "ppsspp_block_transfer_gpu"; + var.key = "ppsspp_skip_buffer_effects"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (!strcmp(var.value, "disabled")) - g_Config.bBlockTransferGPU = false; + g_Config.bSkipBufferEffects = false; else - g_Config.bBlockTransferGPU = true; + g_Config.bSkipBufferEffects = true; + } + + var.key = "ppsspp_skip_gpu_readbacks"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (!strcmp(var.value, "disabled")) + g_Config.bSkipGPUReadbacks = false; + else + g_Config.bSkipGPUReadbacks = true; } var.key = "ppsspp_frameskip"; diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h index 0ca87d8bce..cc5f428268 100644 --- a/libretro/libretro_core_options.h +++ b/libretro/libretro_core_options.h @@ -284,28 +284,24 @@ struct retro_core_option_v2_definition option_defs_us[] = { "480x272" }, { - "ppsspp_rendering_mode", - "Rendering Mode", + "ppsspp_skip_buffer_effects", + "Skip Buffer Effects", NULL, - "'Skip Buffer Effects' is faster, but nothing may draw in some games.", - NULL, - "video", - { - { "Buffered", NULL }, - { "Skip Buffer Effects", NULL }, - { NULL, NULL }, - }, - "Buffered" - }, - { - "ppsspp_block_transfer_gpu", - "Block Transfer GPU", - NULL, - "Some games require this to be enabled for correct graphics.", + "Faster, but may cause major rendering issues.", NULL, "video", BOOL_OPTIONS, - "enabled" + "disabled" + }, + { + "ppsspp_skip_gpu_readbacks", + "Skip GPU Readbacks", + NULL, + "Some games require GPU readbacks, so be careful.", + NULL, + "video", + BOOL_OPTIONS, + "disabled" }, { "ppsspp_frameskip", From c918ab5044f4d7d8f4b31f7724534728d52d697e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 20:02:34 +0100 Subject: [PATCH 371/374] Setting should be reported --- Core/Config.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index 41804f7875..4b75a46c54 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -875,7 +875,7 @@ static ConfigSetting graphicsSettings[] = { ConfigSetting("CameraDevice", &g_Config.sCameraDevice, "", true, false), ConfigSetting("VendorBugChecksEnabled", &g_Config.bVendorBugChecksEnabled, true, false, false), ConfigSetting("UseGeometryShader", &g_Config.bUseGeometryShader, true, true, true), - ConfigSetting("SkipBufferEffects", &g_Config.bSkipBufferEffects, false, true, true), + ReportedConfigSetting("SkipBufferEffects", &g_Config.bSkipBufferEffects, false, true, true), ConfigSetting("SoftwareRenderer", &g_Config.bSoftwareRendering, false, true, true), ConfigSetting("SoftwareRendererJit", &g_Config.bSoftwareRenderingJit, true, true, true), ReportedConfigSetting("HardwareTransform", &g_Config.bHardwareTransform, true, true, true), From 5eccf03cb9528092eaa1aee11486f5762f913cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 6 Nov 2022 20:18:32 +0100 Subject: [PATCH 372/374] Partially rescue translation by copying from Hack Settings --- assets/lang/cz_CZ.ini | 2 +- assets/lang/da_DK.ini | 2 +- assets/lang/de_DE.ini | 2 +- assets/lang/es_ES.ini | 2 +- assets/lang/es_LA.ini | 2 +- assets/lang/fa_IR.ini | 2 +- assets/lang/fr_FR.ini | 2 +- assets/lang/gl_ES.ini | 2 +- assets/lang/hr_HR.ini | 2 +- assets/lang/hu_HU.ini | 2 +- assets/lang/id_ID.ini | 2 +- assets/lang/it_IT.ini | 2 +- assets/lang/ja_JP.ini | 2 +- assets/lang/jv_ID.ini | 2 +- assets/lang/ko_KR.ini | 2 +- assets/lang/lt-LT.ini | 2 +- assets/lang/ms_MY.ini | 2 +- assets/lang/nl_NL.ini | 2 +- assets/lang/pl_PL.ini | 2 +- assets/lang/pt_BR.ini | 2 +- assets/lang/pt_PT.ini | 2 +- assets/lang/ro_RO.ini | 2 +- assets/lang/ru_RU.ini | 2 +- assets/lang/sv_SE.ini | 2 +- assets/lang/tg_PH.ini | 2 +- assets/lang/th_TH.ini | 2 +- assets/lang/tr_TR.ini | 2 +- assets/lang/uk_UA.ini | 2 +- assets/lang/vi_VN.ini | 2 +- assets/lang/zh_CN.ini | 2 +- assets/lang/zh_TW.ini | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/assets/lang/cz_CZ.ini b/assets/lang/cz_CZ.ini index 1f2dcbf436..78ce12bd2e 100644 --- a/assets/lang/cz_CZ.ini +++ b/assets/lang/cz_CZ.ini @@ -550,7 +550,7 @@ Software Rendering = Softwarové vykreslování (experimentální) Software Skinning = Textury aplikuje software SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Rychlost -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (Mohou způsobit problémy) Stretching = Roztažení Texture Filter = Filtr textur Texture Filtering = Filtrování textur diff --git a/assets/lang/da_DK.ini b/assets/lang/da_DK.ini index 72f0431317..02e61c6366 100644 --- a/assets/lang/da_DK.ini +++ b/assets/lang/da_DK.ini @@ -550,7 +550,7 @@ Software Rendering = Software rendering (eksperiment) Software Skinning = Software skinning SoftwareSkinning Tip = Kombiner begrænset model tegning af CPU, hurtigere i fleste spil Speed = Hastighed -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (kan give fejl) Stretching = Stretching Texture Filter = Texturfilter Texture Filtering = Texturfiltrering diff --git a/assets/lang/de_DE.ini b/assets/lang/de_DE.ini index fb0056e3dc..bb01cfeacd 100644 --- a/assets/lang/de_DE.ini +++ b/assets/lang/de_DE.ini @@ -550,7 +550,7 @@ Software Rendering = Software Renderer (experimentell) Software Skinning = Software Skinning SoftwareSkinning Tip = Reduziert Grafikbefehle und schneller in Spielen mit erweiterter Skinning-Technik, in anderen Spielen langsamer Speed = Geschwindigkeit -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (kann zu Fehlern führen) Stretching = Strecken Texture Filter = Texturfilter Texture Filtering = Texturfilterung diff --git a/assets/lang/es_ES.ini b/assets/lang/es_ES.ini index 2f5dd72031..7d587aa8e3 100644 --- a/assets/lang/es_ES.ini +++ b/assets/lang/es_ES.ini @@ -550,7 +550,7 @@ Software Rendering = Renderizado por software Software Skinning = "Skinning" por software SoftwareSkinning Tip = Reduce la carga de dibujado, rápido en juegos con técnicas de skinning avanzadas, pero lento en otros. Speed = Velocidad -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (causarán errores gráficos) Stretching = Estirar Texture Filter = Filtro de texturas Texture Filtering = Filtrado de texturas diff --git a/assets/lang/es_LA.ini b/assets/lang/es_LA.ini index 7c789a7f75..59019321b3 100644 --- a/assets/lang/es_LA.ini +++ b/assets/lang/es_LA.ini @@ -550,7 +550,7 @@ Software Rendering = Renderizado por software (experimental) Software Skinning = Skineado por software SoftwareSkinning Tip = Combina dibujados de modelo de skineado en la CPU. Acelera muchos juegos pero ralentiza otros. Speed = Velocidad -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (puede causar glitches) Stretching = Estirar Texture Filter = Filtro de texturas Texture Filtering = Filtrado de texturas diff --git a/assets/lang/fa_IR.ini b/assets/lang/fa_IR.ini index 7b7b8ca47b..925f48c1a7 100644 --- a/assets/lang/fa_IR.ini +++ b/assets/lang/fa_IR.ini @@ -550,7 +550,7 @@ Software Rendering = ‎(رندر نرم افزاری (آزمایشی Software Skinning = Software skinning SoftwareSkinning Tip = ‎در اکثر بازی ها سریع تر ،CPU دار در skin ترکیب رسم مدل های Speed = ‎سرعت -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks ‎(میتواند باعث باگ شود) Stretching = ‎کشیدن Texture Filter = ‎فیلتر تکسچر Texture Filtering = ‎فیلتر کردن تکسچر diff --git a/assets/lang/fr_FR.ini b/assets/lang/fr_FR.ini index 23b23fccd6..8f4dd25f7e 100644 --- a/assets/lang/fr_FR.ini +++ b/assets/lang/fr_FR.ini @@ -550,7 +550,7 @@ Software Rendering = Rendu logiciel (expérimental) Software Skinning = Enveloppe logicielle SoftwareSkinning Tip = Combine l'affichage des modèles enveloppés sur le CPU, plus rapide dans la plupart des jeux Speed = Vitesse -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (crée des bugs graphiques) Stretching = Étirement Texture Filter = Filtre de textures Texture Filtering = Filtrage des textures diff --git a/assets/lang/gl_ES.ini b/assets/lang/gl_ES.ini index 5e8fe159d4..1ec4ad468d 100644 --- a/assets/lang/gl_ES.ini +++ b/assets/lang/gl_ES.ini @@ -550,7 +550,7 @@ Software Rendering = Renderizado por software (beta) Software Skinning = «Skinning» por software SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Velocidade -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (causarán erros gráficos) Stretching = Stretching Texture Filter = Filtro de texturas Texture Filtering = Filtrado de texturas diff --git a/assets/lang/hr_HR.ini b/assets/lang/hr_HR.ini index a6465719e8..5fc79d26e0 100644 --- a/assets/lang/hr_HR.ini +++ b/assets/lang/hr_HR.ini @@ -550,7 +550,7 @@ Software Rendering = Žbukanje softvera (sporo) Software Skinning = Skiniranje softvera SoftwareSkinning Tip = Kombiniraj skinirane modele crteža na CPU, brže u većini igara Speed = Brzina -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (može uzrokovati glitcheve) Stretching = Rastezanje Texture Filter = Filtar tekstura Texture Filtering = Filtriranje tekstura diff --git a/assets/lang/hu_HU.ini b/assets/lang/hu_HU.ini index 945b81fab2..c5f9433ce2 100644 --- a/assets/lang/hu_HU.ini +++ b/assets/lang/hu_HU.ini @@ -550,7 +550,7 @@ Software Rendering = Szoftveres renderelés (lassú) Software Skinning = Szoftveres "skinning" SoftwareSkinning Tip = "Skinning" művelet elvégzése a processzoron. Sok játék esetében gyorsabb. Speed = Sebesség -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (ezek HIBÁKAT OKOZHATNAK) Stretching = Nyújtás Texture Filter = Textúra szűrés Texture Filtering = Textúra szűrés diff --git a/assets/lang/id_ID.ini b/assets/lang/id_ID.ini index c1fe30cf77..3e75cd0a93 100644 --- a/assets/lang/id_ID.ini +++ b/assets/lang/id_ID.ini @@ -550,7 +550,7 @@ Software Rendering = Pelukisan perangkat lunak (eksperimental) Software Skinning = Pengkulitan perangkat lunak SoftwareSkinning Tip = Menggabungkan model berkulit pada CPU, lebih cepat di kebanyakan permainan Speed = Kecepatan -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (menyebabkan kecacatan) Stretching = Peregangan Texture Filter = Filter tekstur Texture Filtering = Pemfilteran tekstur diff --git a/assets/lang/it_IT.ini b/assets/lang/it_IT.ini index 5ca9f3470e..ed9fda0f09 100644 --- a/assets/lang/it_IT.ini +++ b/assets/lang/it_IT.ini @@ -551,7 +551,7 @@ Software Rendering = Rendering tramite Software (sperimentale) Software Skinning = Software Skinning SoftwareSkinning Tip = Combina la visualizzazione di modelli disegnati dalla CPU, più veloce nella maggior parte dei giochi Speed = Velocità -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (causerà dei problemi) Stretching = Adatta al Display Texture Filter = Filtro delle texture Texture Filtering = Filtraggio delle texture diff --git a/assets/lang/ja_JP.ini b/assets/lang/ja_JP.ini index d49482846e..cc152ab6f3 100644 --- a/assets/lang/ja_JP.ini +++ b/assets/lang/ja_JP.ini @@ -550,7 +550,7 @@ Software Rendering = ソフトウェアレンダリング (実験的) Software Skinning = ソフトウェアスキニング SoftwareSkinning Tip = スキンモデルの描画をCPUでまとめて行う。ほとんどのゲームが高速化します Speed = 速度 -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (不具合あり) Stretching = 拡大 Texture Filter = テクスチャフィルタ Texture Filtering = テクスチャフィルタリング diff --git a/assets/lang/jv_ID.ini b/assets/lang/jv_ID.ini index 328bb6a46f..43b9d219cb 100644 --- a/assets/lang/jv_ID.ini +++ b/assets/lang/jv_ID.ini @@ -550,7 +550,7 @@ Software Rendering = Software rendering (jajalan) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Kacepetan -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (nyebabake glitches) Stretching = Stretching Texture Filter = Penyaring Tekstur Texture Filtering = Penyaring Tekstur diff --git a/assets/lang/ko_KR.ini b/assets/lang/ko_KR.ini index ea067713be..c9074383ce 100644 --- a/assets/lang/ko_KR.ini +++ b/assets/lang/ko_KR.ini @@ -549,7 +549,7 @@ Software Rendering = 소프트웨어 렌더링 (느림) Software Skinning = 소프트웨어 스키닝 SoftwareSkinning Tip = 대부분의 게임에서 더 빠르게 CPU에서 스킨 모델 드로우를 결합합니다. Speed = 속도 -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (결함을 일으킬 수 있음) Stretching = 늘이기 Texture Filter = 텍스처 필터링 Texture Filtering = 텍스처 필터링 diff --git a/assets/lang/lt-LT.ini b/assets/lang/lt-LT.ini index d01df7a0ad..b2d3a3c81f 100644 --- a/assets/lang/lt-LT.ini +++ b/assets/lang/lt-LT.ini @@ -550,7 +550,7 @@ Software Rendering = Programinės įrangos rodymas(ekspermentalus) Software Skinning = Programinės įrangos "nulupimas" SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Greitis -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (gali sukelti problemų) Stretching = Stretching Texture Filter = Tekstūrų filtravimas Texture Filtering = Tekstūrų filtravimas diff --git a/assets/lang/ms_MY.ini b/assets/lang/ms_MY.ini index cb7a06426d..32dc995720 100644 --- a/assets/lang/ms_MY.ini +++ b/assets/lang/ms_MY.ini @@ -550,7 +550,7 @@ Software Rendering = Render perisian (eksperimen) Software Skinning = Pembalutan Perisian SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Laju -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (mungkin menyebabkan gangguan) Stretching = Stretching Texture Filter = Penapis Tekstur Texture Filtering = Penapisan Tekstur diff --git a/assets/lang/nl_NL.ini b/assets/lang/nl_NL.ini index 8a4a3c3339..9ec6b9a017 100644 --- a/assets/lang/nl_NL.ini +++ b/assets/lang/nl_NL.ini @@ -550,7 +550,7 @@ Software Rendering = Renderen via software (experimenteel) Software Skinning = Skinning via software SoftwareSkinning Tip = Vermindert aantal renders en is sneller in games die de geavanceerde skinningtechniek gebruiken, maar voor sommige games trager Speed = Snelheid -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (kan glitches veroorzaken) Stretching = Uitrekken Texture Filter = Texturefilter Texture Filtering = Texturefilter diff --git a/assets/lang/pl_PL.ini b/assets/lang/pl_PL.ini index 25c17fef2f..98ffd7fd04 100644 --- a/assets/lang/pl_PL.ini +++ b/assets/lang/pl_PL.ini @@ -550,7 +550,7 @@ Software Rendering = Renderowanie programowe (wolne) Software Skinning = Programowy skinning SoftwareSkinning Tip = Łączy na CPU wywołania rysujące modele z animacjami, przyspieszenie w większości gier Speed = Prędkość (procentowo) -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (powodują problemy) Stretching = Rozciąganie Texture Filter = Filtrowanie tekstur Texture Filtering = Filtrowanie tekstur diff --git a/assets/lang/pt_BR.ini b/assets/lang/pt_BR.ini index 970025ecb0..7827800c21 100644 --- a/assets/lang/pt_BR.ini +++ b/assets/lang/pt_BR.ini @@ -573,7 +573,7 @@ Software Rendering = Renderização por software (lento) Software Skinning = Skinning via software SoftwareSkinning Tip = Combina os desenhos dos modelos de skinning na CPU, mais rápido na maioria dos jogos Speed = Velocidade -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (pode causar erros gráficos) Stretching = Esticamento Texture Filter = Filtragem das texturas Texture Filtering = Filtragem das texturas diff --git a/assets/lang/pt_PT.ini b/assets/lang/pt_PT.ini index 244bc14492..21262dea6e 100644 --- a/assets/lang/pt_PT.ini +++ b/assets/lang/pt_PT.ini @@ -573,7 +573,7 @@ Software Rendering = Renderização por software (lento) Software Skinning = Skinning via software SoftwareSkinning Tip = Combina os desenhos dos modelos de skinning na CPU, mais rápido na maioria dos jogos Speed = Velocidade -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (pode causar erros gráficos) Stretching = Esticamento Texture Filter = Filtração das texturas Texture Filtering = Filtração das texturas diff --git a/assets/lang/ro_RO.ini b/assets/lang/ro_RO.ini index c639b659ae..22bc711b1d 100644 --- a/assets/lang/ro_RO.ini +++ b/assets/lang/ro_RO.ini @@ -550,7 +550,7 @@ Software Rendering = Afișare cu sofware (experimental) Software Skinning = Skinning cu software SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Viteză -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (pot cauza stricăciuni) Stretching = Stretching Texture Filter = Filtru texturi Texture Filtering = Filtrare texturi diff --git a/assets/lang/ru_RU.ini b/assets/lang/ru_RU.ini index 5b02a758d1..a3a421559c 100644 --- a/assets/lang/ru_RU.ini +++ b/assets/lang/ru_RU.ini @@ -551,7 +551,7 @@ Software Rendering = Программный рендеринг (медленно Software Skinning = Программная заливка SoftwareSkinning Tip = Объединяет вызовы отрисовки моделей с заливкой на ЦП, быстрее во многих играх Speed = Скорость -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (могут вызывать глюки) Stretching = Растягивание Texture Filter = Текстурный фильтр Texture Filtering = Фильтрация текстур diff --git a/assets/lang/sv_SE.ini b/assets/lang/sv_SE.ini index 03a8b4d574..c55bd25529 100644 --- a/assets/lang/sv_SE.ini +++ b/assets/lang/sv_SE.ini @@ -550,7 +550,7 @@ Software Rendering = Mjukvarurendering (experiment) Software Skinning = Software Skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Hastighet -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed-hacks (kan orsaka renderingsproblem) Stretching = Stretching Texture Filter = Texturfilter Texture Filtering = Texturfiltrering diff --git a/assets/lang/tg_PH.ini b/assets/lang/tg_PH.ini index 7f90a8349d..624644a464 100644 --- a/assets/lang/tg_PH.ini +++ b/assets/lang/tg_PH.ini @@ -550,7 +550,7 @@ Software Rendering = Software Rendering (Expiremental) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Bilis -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (maaring magdulot ng pagloloko sa laro) Stretching = Iunat Texture Filter = Panala ng Texture Texture Filtering = Pagsala sa Texture diff --git a/assets/lang/th_TH.ini b/assets/lang/th_TH.ini index d9a6d1eff6..2f48108dd7 100644 --- a/assets/lang/th_TH.ini +++ b/assets/lang/th_TH.ini @@ -550,7 +550,7 @@ Software Rendering = ใช้ซอฟต์แวร์ในการแส Software Skinning = ซอฟต์แวร์ สกินนิ่ง SoftwareSkinning Tip = ผสานโมเดลพื้นผิวให้เขียนผ่านซีพียู ซึ่งเกมส่วนใหญ่ปรับใช้แล้วไวขึ้น Speed = ความเร็ว -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (อาจแสดงผลผิดพลาด) Stretching = ดึงเต็มจอ Texture Filter = ตัวกรองพื้นผิว Texture Filtering = การกรองพื้นผิว diff --git a/assets/lang/tr_TR.ini b/assets/lang/tr_TR.ini index 96a1ccb313..6183381f8b 100644 --- a/assets/lang/tr_TR.ini +++ b/assets/lang/tr_TR.ini @@ -552,7 +552,7 @@ Software Rendering = Yazılımsal işleme (Deneysel) Software Skinning = Software skinning SoftwareSkinning Tip = Combine skinned model draws on the CPU, faster in most games Speed = Hız -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Hız Hacks (Küçük teknik problemlere neden olabilir.) Stretching = Serbest tam ekran (sünme) Texture Filter = Doku filtreleme Texture Filtering = Doku filtreleme diff --git a/assets/lang/uk_UA.ini b/assets/lang/uk_UA.ini index 5c57d9af18..d27fc056b1 100644 --- a/assets/lang/uk_UA.ini +++ b/assets/lang/uk_UA.ini @@ -550,7 +550,7 @@ Software Rendering = Програмний рендеринг (експериме Software Skinning = Програмна заливка SoftwareSkinning Tip = Комбінована модель розібраної моделі яка притягується до процесора, швидше в більшості ігор Speed = Швидкість -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (можуть викликати глюки) Stretching = Розтягнення Texture Filter = Фільтр текстур Texture Filtering = Фільтрація текстур diff --git a/assets/lang/vi_VN.ini b/assets/lang/vi_VN.ini index 6aed763937..0aeebfb027 100644 --- a/assets/lang/vi_VN.ini +++ b/assets/lang/vi_VN.ini @@ -550,7 +550,7 @@ Software Rendering = Dựng hình bằng phần mềm Software Skinning = phủ lớp bằng phần mềm SoftwareSkinning Tip = Mô hình kết hợp vẽ trên CPU, nhanh hơn trong hầu hết các trò chơi Speed = Tốc độ -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Tốc độ Hacks (sẽ bị lỗi) Stretching = Stretching Texture Filter = Bộ lọc họa tiết Texture Filtering = Lọc texture diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index d5bd28529b..7b1f77592f 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -550,7 +550,7 @@ Software Rendering = 软件渲染(慢) Software Skinning = 软件蒙皮 SoftwareSkinning Tip = 合并CPU中已经蒙皮的模型绘制,在部分游戏中更快 Speed = 运行速度 -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (可能引发故障) Stretching = 拉伸 Texture Filter = 纹理过滤方式 Texture Filtering = 纹理过滤 diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 0b2ec4b154..4ae22d488f 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -549,7 +549,7 @@ Software Rendering = 軟體轉譯 (慢) Software Skinning = 軟體除皮 SoftwareSkinning Tip = 結合除皮模組在 CPU 上繪製,在多數遊戲上更快 Speed = 速度 -Speed Hacks = Speed Hacks (can cause rendering errors!) +Speed Hacks = Speed Hacks (可能會造成故障) Stretching = 延伸 Texture Filter = 紋理濾鏡 Texture Filtering = 紋理濾鏡 From 24451bb45d0be1eba25bd616612194d60f03a3a4 Mon Sep 17 00:00:00 2001 From: xujibbs <79200793+xujibbs@users.noreply.github.com> Date: Mon, 7 Nov 2022 12:34:27 +0800 Subject: [PATCH 373/374] Update zh_CN.ini --- assets/lang/zh_CN.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/lang/zh_CN.ini b/assets/lang/zh_CN.ini index 7b1f77592f..f51aa2c856 100644 --- a/assets/lang/zh_CN.ini +++ b/assets/lang/zh_CN.ini @@ -550,7 +550,7 @@ Software Rendering = 软件渲染(慢) Software Skinning = 软件蒙皮 SoftwareSkinning Tip = 合并CPU中已经蒙皮的模型绘制,在部分游戏中更快 Speed = 运行速度 -Speed Hacks = Speed Hacks (可能引发故障) +Speed Hacks = 速度修正 (可能引发故障) Stretching = 拉伸 Texture Filter = 纹理过滤方式 Texture Filtering = 纹理过滤 From 1c356c5ae461a014ab4305181da0ef44b712d036 Mon Sep 17 00:00:00 2001 From: xujibbs <79200793+xujibbs@users.noreply.github.com> Date: Mon, 7 Nov 2022 12:35:57 +0800 Subject: [PATCH 374/374] Update zh_TW.ini --- assets/lang/zh_TW.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/lang/zh_TW.ini b/assets/lang/zh_TW.ini index 4ae22d488f..444d6be346 100644 --- a/assets/lang/zh_TW.ini +++ b/assets/lang/zh_TW.ini @@ -549,7 +549,7 @@ Software Rendering = 軟體轉譯 (慢) Software Skinning = 軟體除皮 SoftwareSkinning Tip = 結合除皮模組在 CPU 上繪製,在多數遊戲上更快 Speed = 速度 -Speed Hacks = Speed Hacks (可能會造成故障) +Speed Hacks = 速度修正 (可能會造成故障) Stretching = 延伸 Texture Filter = 紋理濾鏡 Texture Filtering = 紋理濾鏡