diff --git a/Common/GPU/Vulkan/VulkanDebug.cpp b/Common/GPU/Vulkan/VulkanDebug.cpp index c0bf23567771..0bda4815cace 100644 --- a/Common/GPU/Vulkan/VulkanDebug.cpp +++ b/Common/GPU/Vulkan/VulkanDebug.cpp @@ -21,6 +21,7 @@ #include #include "Common/Log.h" +#include "Common/System/System.h" #include "Common/GPU/Vulkan/VulkanContext.h" #include "Common/GPU/Vulkan/VulkanDebug.h" @@ -139,7 +140,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback( #ifdef _WIN32 OutputDebugStringA(msg.c_str()); if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { - if (options->breakOnError && IsDebuggerPresent()) { + if (options->breakOnError && System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) { DebugBreak(); } if (options->msgBoxOnError) { @@ -147,7 +148,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback( } } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { // Don't break on perf warnings for now, even with a debugger. We log them at least. - if (options->breakOnWarning && IsDebuggerPresent() && 0 == (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)) { + if (options->breakOnWarning && System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT) && 0 == (messageType & VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT)) { DebugBreak(); } } diff --git a/Common/System/System.h b/Common/System/System.h index 2b59d52ce236..5b009c571870 100644 --- a/Common/System/System.h +++ b/Common/System/System.h @@ -139,6 +139,8 @@ enum SystemProperty { SYSPROP_SUPPORTS_HTTPS, + SYSPROP_DEBUGGER_PRESENT, + // Available as Int: SYSPROP_SYSTEMVERSION, SYSPROP_DISPLAY_XRES, diff --git a/GPU/D3D11/DrawEngineD3D11.cpp b/GPU/D3D11/DrawEngineD3D11.cpp index 778569ed3faa..08c0ae6b6388 100644 --- a/GPU/D3D11/DrawEngineD3D11.cpp +++ b/GPU/D3D11/DrawEngineD3D11.cpp @@ -288,9 +288,10 @@ void DrawEngineD3D11::DoFlush() { DecodeVerts(decoded_); DecodeInds(); - gpuStats.numUncachedVertsDrawn += indexGen.VertexCount(); + bool useElements = !indexGen.SeenOnlyPurePrims() || prim == GE_PRIM_TRIANGLE_FAN; int vertexCount = indexGen.VertexCount(); + gpuStats.numUncachedVertsDrawn += vertexCount; int maxIndex = MaxIndex(); if (!useElements && indexGen.PureCount()) { vertexCount = indexGen.PureCount(); diff --git a/GPU/Directx9/DrawEngineDX9.cpp b/GPU/Directx9/DrawEngineDX9.cpp index 3575a6dbb189..506856556f6f 100644 --- a/GPU/Directx9/DrawEngineDX9.cpp +++ b/GPU/Directx9/DrawEngineDX9.cpp @@ -255,24 +255,20 @@ void DrawEngineDX9::DoFlush() { bool useHWTransform = CanUseHardwareTransform(prim) && (tess || gstate.getShadeMode() != GE_SHADE_FLAT); if (useHWTransform) { - LPDIRECT3DVERTEXBUFFER9 vb_ = NULL; - LPDIRECT3DINDEXBUFFER9 ib_ = NULL; - - int vertexCount = 0; - int maxIndex = 0; - bool useElements = true; - { - DecodeVerts(decoded_); - DecodeInds(); - gpuStats.numUncachedVertsDrawn += indexGen.VertexCount(); - useElements = !indexGen.SeenOnlyPurePrims(); - vertexCount = indexGen.VertexCount(); - maxIndex = MaxIndex(); - if (!useElements && indexGen.PureCount()) { - vertexCount = indexGen.PureCount(); - } - prim = indexGen.Prim(); + LPDIRECT3DVERTEXBUFFER9 vb_ = nullptr; + LPDIRECT3DINDEXBUFFER9 ib_ = nullptr; + + DecodeVerts(decoded_); + DecodeInds(); + + bool useElements = !indexGen.SeenOnlyPurePrims(); + int vertexCount = indexGen.VertexCount(); + gpuStats.numUncachedVertsDrawn += vertexCount; + int maxIndex = MaxIndex(); + if (!useElements && indexGen.PureCount()) { + vertexCount = indexGen.PureCount(); } + prim = indexGen.Prim(); _dbg_assert_((int)prim > 0); diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index 598a41546a36..240bc73a59e3 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -271,9 +271,6 @@ void DrawEngineGLES::DoFlush() { uint32_t indexBufferOffset = 0; if (vshader->UseHWTransform()) { - int vertexCount = 0; - bool useElements = true; - if (decOptions_.applySkinInDecode && (lastVType_ & GE_VTYPE_WEIGHT_MASK)) { // If software skinning, we're predecoding into "decoded". So make sure we're done, then push that content. DecodeVerts(decoded_); @@ -288,24 +285,16 @@ void DrawEngineGLES::DoFlush() { } DecodeInds(); - gpuStats.numUncachedVertsDrawn += indexGen.VertexCount(); - // If there's only been one primitive type, and it's either TRIANGLES, LINES or POINTS, // there is no need for the index buffer we built. We can then use glDrawArrays instead // for a very minor speed boost. TODO: We can probably detect this case earlier, like before // actually doing any vertex decoding (unless we're doing soft skinning and pre-decode on submit). - useElements = !indexGen.SeenOnlyPurePrims(); - vertexCount = indexGen.VertexCount(); + bool useElements = !indexGen.SeenOnlyPurePrims(); + int vertexCount = indexGen.VertexCount(); + gpuStats.numUncachedVertsDrawn += vertexCount; if (!useElements && indexGen.PureCount()) { vertexCount = indexGen.PureCount(); } - if (useElements) { - uint32_t esz = sizeof(uint16_t) * indexGen.VertexCount(); - void *dest = frameData.pushIndex->Allocate(esz, 2, &indexBuffer, &indexBufferOffset); - // TODO: When we need to apply an index offset, we can apply it directly when copying the indices here. - // Of course, minding the maximum value of 65535... - memcpy(dest, decIndex_, esz); - } prim = indexGen.Prim(); bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE; @@ -326,6 +315,11 @@ void DrawEngineGLES::DoFlush() { LinkedShader *program = shaderManager_->ApplyFragmentShader(vsid, vshader, pipelineState_, framebufferManager_->UseBufferedRendering()); GLRInputLayout *inputLayout = SetupDecFmtForDraw(dec_->GetDecVtxFmt()); if (useElements) { + uint32_t esz = sizeof(uint16_t) * indexGen.VertexCount(); + void *dest = frameData.pushIndex->Allocate(esz, 2, &indexBuffer, &indexBufferOffset); + // TODO: When we need to apply an index offset, we can apply it directly when copying the indices here. + // Of course, minding the maximum value of 65535... + memcpy(dest, decIndex_, esz); render_->DrawIndexed(inputLayout, vertexBuffer, vertexBufferOffset, indexBuffer, indexBufferOffset, diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index a31d26340460..cd81b7caf32d 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -185,17 +185,6 @@ void DrawEngineVulkan::EndFrame() { stats_.pushIndexSpaceUsed = (int)pushIndex_->GetUsedThisFrame(); } -void DrawEngineVulkan::DecodeVertsToPushPool(VulkanPushPool *push, uint32_t *bindOffset, VkBuffer *vkbuf) { - u8 *dest = decoded_; - - // Figure out how much pushbuffer space we need to allocate. - if (push) { - int vertsToDecode = ComputeNumVertsToDecode(); - dest = push->Allocate(vertsToDecode * dec_->GetDecVtxFmt().stride, 4, vkbuf, bindOffset); - } - DecodeVerts(dest); -} - void DrawEngineVulkan::DirtyAllUBOs() { baseUBOOffset = 0; lightUBOOffset = 0; @@ -263,14 +252,17 @@ void DrawEngineVulkan::DoFlush() { u8 *dest = (u8 *)pushVertex_->Allocate(size, 4, &vbuf, &vbOffset); memcpy(dest, decoded_, size); } else { + // Figure out how much pushbuffer space we need to allocate. + int vertsToDecode = ComputeNumVertsToDecode(); // Decode directly into the pushbuffer - DecodeVertsToPushPool(pushVertex_, &vbOffset, &vbuf); + u8 *dest = pushVertex_->Allocate(vertsToDecode * dec_->GetDecVtxFmt().stride, 4, &vbuf, &vbOffset); + DecodeVerts(dest); } DecodeInds(); - gpuStats.numUncachedVertsDrawn += indexGen.VertexCount(); bool useElements; int vertexCount = indexGen.VertexCount(); + gpuStats.numUncachedVertsDrawn += vertexCount; if (forceIndexed) { useElements = true; prim = indexGen.GeneralPrim(); diff --git a/GPU/Vulkan/DrawEngineVulkan.h b/GPU/Vulkan/DrawEngineVulkan.h index 00e61a09e370..d7f108b74daa 100644 --- a/GPU/Vulkan/DrawEngineVulkan.h +++ b/GPU/Vulkan/DrawEngineVulkan.h @@ -184,8 +184,6 @@ class DrawEngineVulkan : public DrawEngineCommon { void DestroyDeviceObjects(); - void DecodeVertsToPushPool(VulkanPushPool *push, uint32_t *bindOffset, VkBuffer *vkbuf); - void DoFlush(); void UpdateUBOs(); diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 46e396bfd512..a4c4fb98a97f 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -510,11 +510,9 @@ void SystemInfoScreen::CreateTabs() { if (!board.empty()) systemInfo->Add(new InfoItem(si->T("Board"), board)); systemInfo->Add(new InfoItem(si->T("ABI"), GetCompilerABI())); -#ifdef _WIN32 - if (IsDebuggerPresent()) { + if (System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) { systemInfo->Add(new InfoItem(si->T("Debugger Present"), di->T("Yes"))); } -#endif CollapsibleSection *cpuInfo = deviceSpecs->Add(new CollapsibleSection(si->T("CPU Information"))); diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index f9a0798d7897..4293ac2a0b05 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -431,6 +431,8 @@ bool System_GetPropertyBool(SystemProperty prop) { // I don't know any possible way to display input dialog in non-xaml apps return isKeyboardAvailable() || isTouchAvailable(); } + case SYSPROP_DEBUGGER_PRESENT: + return IsDebuggerPresent(); default: return false; } diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index cc5ea9a40759..9f5b89253fcf 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -418,7 +418,7 @@ namespace MainWindow { } static void RestartApp() { - if (IsDebuggerPresent()) { + if (System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) { PostMessage(MainWindow::GetHWND(), WM_USER_RESTART_EMUTHREAD, 0, 0); } else { g_Config.bRestartRequired = true; diff --git a/Windows/main.cpp b/Windows/main.cpp index 5e651e019a10..762d5a747ed9 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -381,6 +381,8 @@ bool System_GetPropertyBool(SystemProperty prop) { return true; // FileUtil.cpp: OpenFileInEditor case SYSPROP_SUPPORTS_HTTPS: return !g_Config.bDisableHTTPS; + case SYSPROP_DEBUGGER_PRESENT: + return IsDebuggerPresent(); default: return false; } @@ -494,7 +496,7 @@ bool System_MakeRequest(SystemRequestType type, int requestId, const std::string restartArgs = param1; if (!restartArgs.empty()) AddDebugRestartArgs(); - if (IsDebuggerPresent()) { + if (System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) { PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_RESTART_EMUTHREAD, 0, 0); } else { g_Config.bRestartRequired = true;