mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-17 11:24:27 +01:00
Merge branch 'master' into TemporaryHackishBranch
# Conflicts: # Common/GPU/Vulkan/VulkanRenderManager.cpp # Core/Config.cpp # Core/HW/MediaEngine.cpp # UI/CwCheatScreen.cpp # UI/MainScreen.cpp # UI/MiscScreens.cpp # Windows/resource.h
This commit is contained in:
commit
a5ed04b1b6
513 files changed
+13159
-8708
No files matched your search
@@ -4,6 +4,8 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
# For testing.
|
||||
- actions
|
||||
paths-ignore:
|
||||
- '*.{txt,md}'
|
||||
- 'Tools/**'
|
||||
@@ -176,9 +178,19 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- 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
|
||||
if: matrix.extra == 'qt'
|
||||
with:
|
||||
cached: ${{ steps.cache-qt.outputs.cache-hit }}
|
||||
|
||||
- uses: nttld/setup-ndk@v1
|
||||
if: matrix.extra == 'android'
|
||||
|
||||
@@ -116,6 +116,3 @@ debian/ppsspp/
|
||||
|
||||
# RenderDoc
|
||||
*.rdc
|
||||
|
||||
# bad output from libretro. don't want to accidentally add it
|
||||
nul
|
||||
+28
-5
@@ -11,26 +11,49 @@ variables:
|
||||
variables:
|
||||
EXTRA_PATH: lib
|
||||
|
||||
.windows-defs:
|
||||
variables:
|
||||
MAKEFILE_PATH: libretro
|
||||
|
||||
include:
|
||||
- template: Jobs/Code-Quality.gitlab-ci.yml
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/android-cmake.yml'
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/linux-cmake.yml'
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/windows-x64-msvc19-msys2.yml'
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/windows-i686-msvc19-msys2.yml'
|
||||
|
||||
stages:
|
||||
- build-prepare
|
||||
- build-shared
|
||||
- build-static
|
||||
- test
|
||||
|
||||
#Desktop
|
||||
libretro-build-linux-x86_64:
|
||||
# Desktop
|
||||
libretro-build-linux-x64:
|
||||
extends:
|
||||
- .libretro-linux-cmake-x86_64
|
||||
- .core-defs
|
||||
- .linux-defs
|
||||
|
||||
libretro-build-linux-i686:
|
||||
extends:
|
||||
- .libretro-linux-cmake-x86
|
||||
- .core-defs
|
||||
- .linux-defs
|
||||
|
||||
libretro-build-windows-x64:
|
||||
extends:
|
||||
- .libretro-windows-x64-msvc19-msys2-make-default
|
||||
- .core-defs
|
||||
- .windows-defs
|
||||
|
||||
libretro-build-windows-i686:
|
||||
extends:
|
||||
- .libretro-windows-i686-msvc19-msys2-make-default
|
||||
- .core-defs
|
||||
- .windows-defs
|
||||
|
||||
# Android
|
||||
libretro-build-android-armeabi-v7a:
|
||||
extends:
|
||||
|
||||
+62
-19
@@ -1,6 +1,7 @@
|
||||
# vim:noexpandtab:
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
project(PPSSPP)
|
||||
enable_testing()
|
||||
|
||||
#This is supposed to work but doesn't!
|
||||
if(NOT ANDROID)
|
||||
@@ -134,7 +135,8 @@ option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
|
||||
option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY})
|
||||
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
|
||||
option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP})
|
||||
option(USE_ADDRESS_SANITIZER "Use Clang memory sanitizer" ${USE_ADDRESS_SANITIZER})
|
||||
option(USE_ASAN "Use address sanitizer" OFF)
|
||||
option(USE_UBSAN "Use undefined behaviour sanitizer" OFF)
|
||||
|
||||
if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
|
||||
if(USING_X11_VULKAN)
|
||||
@@ -188,6 +190,9 @@ if(NOT OPENGL_LIBRARIES AND USING_GLES2)
|
||||
endif()
|
||||
|
||||
if(NOT OPENGL_LIBRARIES)
|
||||
if(POLICY CMP0072)
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
|
||||
@@ -272,11 +277,24 @@ if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-uninitialized")
|
||||
endif()
|
||||
|
||||
if(USE_ADDRESS_SANITIZER)
|
||||
if(USE_ASAN)
|
||||
message("Address sanitizer enabled (DEBUG only)")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
|
||||
add_definitions(-DUSE_ADDRESS_SANITIZER)
|
||||
add_definitions(-DUSE_ASAN)
|
||||
endif()
|
||||
if(USE_UBSAN)
|
||||
message("Undefined behaviour sanitizer enabled (DEBUG only)")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=undefined")
|
||||
|
||||
# UBSAN is a collection of sanitizers, including vtpr, which reqiuires RTTI.
|
||||
# ext/glslang disables RTTI by default using the `ENABLE_RTTI` option.
|
||||
# If RTTI is disabled, we must also disable the vtpr sanitizer.
|
||||
if(NOT ENABLE_RTTI)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=vptr")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-sanitize=vptr")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
|
||||
@@ -287,12 +305,6 @@ if(NOT MSVC)
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2 -D_NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O2 -g -D_NDEBUG")
|
||||
#TODO: Remove this and include the file properly everywhere it makes sense
|
||||
# First step is too use the macros everywhere
|
||||
# Second step is to remove the compatibility defines
|
||||
# Third step is to include the file
|
||||
# Fourth step is to remove that line!
|
||||
add_compile_options(-include ${CMAKE_CURRENT_SOURCE_DIR}/ppsspp_config.h)
|
||||
|
||||
# Disable some warnings
|
||||
add_definitions(-Wno-multichar)
|
||||
@@ -1318,8 +1330,6 @@ set(GPU_D3D9
|
||||
GPU/Directx9/TextureCacheDX9.h
|
||||
GPU/Directx9/TextureScalerDX9.cpp
|
||||
GPU/Directx9/TextureScalerDX9.h
|
||||
GPU/Directx9/VertexShaderGeneratorHLSL.cpp
|
||||
GPU/GLES/VertexShaderGeneratorGLES.h
|
||||
)
|
||||
|
||||
set(GPU_D3D11
|
||||
@@ -1470,6 +1480,8 @@ add_library(${CoreLibName} ${CoreLinkType}
|
||||
Core/Debugger/Breakpoints.cpp
|
||||
Core/Debugger/Breakpoints.h
|
||||
Core/Debugger/DebugInterface.h
|
||||
Core/Debugger/MemBlockInfo.cpp
|
||||
Core/Debugger/MemBlockInfo.h
|
||||
Core/Debugger/SymbolMap.cpp
|
||||
Core/Debugger/SymbolMap.h
|
||||
Core/Debugger/DisassemblyManager.cpp
|
||||
@@ -1898,9 +1910,7 @@ if(USE_MINIUPNPC)
|
||||
endif()
|
||||
if (WIN32)
|
||||
set_source_files_properties(${MINIUPNPC_SOURCES} PROPERTIES COMPILE_DEFINITIONS "MINIUPNP_STATICLIB;MINIUPNP_EXPORTS")
|
||||
find_library(WINSOCK2_LIBRARY NAMES ws2_32 WS2_32 Ws2_32)
|
||||
find_library(IPHLPAPI_LIBRARY NAMES iphlpapi)
|
||||
set(LDLIBS ${WINSOCK2_LIBRARY} ${IPHLPAPI_LIBRARY} ${LDLIBS})
|
||||
set(LDLIBS ws2_32 iphlpapi ${LDLIBS})
|
||||
#elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
|
||||
# find_library (SOCKET_LIBRARY NAMES socket)
|
||||
# find_library (NSL_LIBRARY NAMES nsl)
|
||||
@@ -1956,7 +1966,6 @@ set(WindowsFiles
|
||||
Windows/Debugger/CtrlMemView.h
|
||||
Windows/Debugger/CtrlRegisterList.cpp
|
||||
Windows/Debugger/CtrlRegisterList.h
|
||||
Windows/Debugger/Debugger.h
|
||||
Windows/Debugger/DebuggerShared.cpp
|
||||
Windows/Debugger/DebuggerShared.h
|
||||
Windows/Debugger/Debugger_Disasm.cpp
|
||||
@@ -1965,8 +1974,6 @@ set(WindowsFiles
|
||||
Windows/Debugger/Debugger_MemoryDlg.h
|
||||
Windows/Debugger/Debugger_Lists.cpp
|
||||
Windows/Debugger/Debugger_Lists.h
|
||||
Windows/Debugger/Debugger_Misc.cpp
|
||||
Windows/Debugger/Debugger_Misc.h
|
||||
Windows/Debugger/Debugger_SymbolMap.h
|
||||
Windows/Debugger/Debugger_VFPUDlg.cpp
|
||||
Windows/Debugger/Debugger_VFPUDlg.h
|
||||
@@ -2071,7 +2078,7 @@ set(NativeAssets
|
||||
|
||||
|
||||
if(HEADLESS)
|
||||
add_executable(PPSSPPHeadless
|
||||
set(HeadlessSource
|
||||
headless/Headless.cpp
|
||||
headless/StubHost.cpp
|
||||
headless/StubHost.h
|
||||
@@ -2080,6 +2087,25 @@ if(HEADLESS)
|
||||
headless/SDLHeadlessHost.cpp
|
||||
headless/SDLHeadlessHost.h
|
||||
)
|
||||
if(WIN32)
|
||||
list(APPEND HeadlessSource
|
||||
headless/WindowsHeadlessHost.cpp
|
||||
headless/WindowsHeadlessHost.h
|
||||
Windows/GPU/D3D9Context.cpp
|
||||
Windows/GPU/D3D9Context.h
|
||||
Windows/GPU/D3D11Context.cpp
|
||||
Windows/GPU/D3D11Context.h
|
||||
Windows/GPU/WindowsGLContext.cpp
|
||||
Windows/GPU/WindowsVulkanContext.cpp
|
||||
Windows/W32Util/ShellUtil.cpp
|
||||
Windows/W32Util/ShellUtil.h
|
||||
Windows/CaptureDevice.cpp
|
||||
Windows/CaptureDevice.h
|
||||
Windows/W32Util/Misc.cpp
|
||||
Windows/W32Util/Misc.h
|
||||
)
|
||||
endif()
|
||||
add_executable(PPSSPPHeadless ${HeadlessSource})
|
||||
target_link_libraries(PPSSPPHeadless ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${LinkCommon})
|
||||
setup_target_project(PPSSPPHeadless headless)
|
||||
endif()
|
||||
@@ -2087,6 +2113,7 @@ endif()
|
||||
if(UNITTEST)
|
||||
add_executable(unitTest
|
||||
unittest/UnitTest.cpp
|
||||
unittest/TestShaderGenerators.cpp
|
||||
unittest/TestArmEmitter.cpp
|
||||
unittest/TestArm64Emitter.cpp
|
||||
unittest/TestX64Emitter.cpp
|
||||
@@ -2097,6 +2124,21 @@ if(UNITTEST)
|
||||
)
|
||||
target_link_libraries(unitTest ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${LinkCommon} Common)
|
||||
setup_target_project(unitTest unittest)
|
||||
add_test(arm64_emitter unitTest Arm64Emitter)
|
||||
add_test(arm_emitter unitTest ArmEmitter)
|
||||
add_test(x64_emitter unitTest X64Emitter)
|
||||
add_test(vertex_jit unitTest VertexJit)
|
||||
add_test(asin unitTest Asin)
|
||||
add_test(sincos unitTest SinCos)
|
||||
add_test(vfpu_sincos unitTest VFPUSinCos)
|
||||
add_test(math_util unitTest MathUtil)
|
||||
add_test(parsers unitTest Parsers)
|
||||
add_test(jit unitTest Jit)
|
||||
add_test(matrix_transpose unitTest MatrixTranspose)
|
||||
add_test(parse_lbn unitTest ParseLBN)
|
||||
add_test(quick_texhash unitTest QuickTexHash)
|
||||
add_test(clz unitTest CLZ)
|
||||
add_test(shadergen unitTest ShaderGenerators)
|
||||
endif()
|
||||
|
||||
if(LIBRETRO)
|
||||
@@ -2190,6 +2232,7 @@ if(IOS)
|
||||
RESOURCE "ios/Settings.bundle"
|
||||
RESOURCE "MoltenVK/iOS/Frameworks"
|
||||
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET}
|
||||
XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "iPhone/iPad"
|
||||
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
|
||||
XCODE_ATTRIBUTE_ENABLE_BITCODE NO
|
||||
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "-"
|
||||
|
||||
+8
-7
@@ -15,7 +15,8 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_X64)
|
||||
#include "ppsspp_config.h"
|
||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
|
||||
#include "x64Emitter.h"
|
||||
#include "ABI.h"
|
||||
@@ -27,9 +28,9 @@ using namespace Gen;
|
||||
// Sets up a __cdecl function.
|
||||
void XEmitter::ABI_EmitPrologue(int maxCallParams)
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
#if PPSSPP_ARCH(X86)
|
||||
// Don't really need to do anything
|
||||
#elif defined(_M_X64)
|
||||
#elif PPSSPP_ARCH(AMD64)
|
||||
#if _WIN32
|
||||
int stacksize = ((maxCallParams + 1) & ~1) * 8 + 8;
|
||||
// Set up a stack frame so that we can call functions
|
||||
@@ -43,9 +44,9 @@ void XEmitter::ABI_EmitPrologue(int maxCallParams)
|
||||
|
||||
void XEmitter::ABI_EmitEpilogue(int maxCallParams)
|
||||
{
|
||||
#ifdef _M_IX86
|
||||
#if PPSSPP_ARCH(X86)
|
||||
RET();
|
||||
#elif defined(_M_X64)
|
||||
#elif PPSSPP_ARCH(AMD64)
|
||||
#ifdef _WIN32
|
||||
int stacksize = ((maxCallParams+1)&~1)*8 + 8;
|
||||
ADD(64, R(RSP), Imm8(stacksize));
|
||||
@@ -58,7 +59,7 @@ void XEmitter::ABI_EmitEpilogue(int maxCallParams)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _M_IX86 // All32
|
||||
#if PPSSPP_ARCH(X86) // All32
|
||||
|
||||
// Shared code between Win32 and Unix32
|
||||
void XEmitter::ABI_CallFunction(const void *func) {
|
||||
@@ -681,4 +682,4 @@ void XEmitter::ABI_RestoreStack(unsigned int /*frameSize*/) {
|
||||
|
||||
#endif // 32bit
|
||||
|
||||
#endif // defined(_M_IX86) || defined(_M_X64)
|
||||
#endif // PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
+3
-2
@@ -17,6 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common.h"
|
||||
|
||||
// x86/x64 ABI:s, and helpers to help follow them when JIT-ing code.
|
||||
@@ -44,7 +45,7 @@
|
||||
// Callee-save: RBX RBP R12 R13 R14 R15
|
||||
// Parameters: RDI RSI RDX RCX R8 R9
|
||||
|
||||
#ifdef _M_IX86 // 32 bit calling convention, shared by all
|
||||
#if PPSSPP_ARCH(X86) // 32 bit calling convention, shared by all
|
||||
|
||||
// 32-bit don't pass parameters in regs, but these are convenient to have anyway when we have to
|
||||
// choose regs to put stuff in.
|
||||
@@ -55,7 +56,7 @@
|
||||
// 32-bit bog standard cdecl, shared between linux and windows
|
||||
// MacOSX 32-bit is same as System V with a few exceptions that we probably don't care much about.
|
||||
|
||||
#elif _M_X64 // 64 bit calling convention
|
||||
#elif PPSSPP_ARCH(AMD64) // 64 bit calling convention
|
||||
|
||||
#ifdef _WIN32 // 64-bit Windows - the really exotic calling convention
|
||||
|
||||
|
||||
@@ -3833,8 +3833,6 @@ bool ARM64XEmitter::TryEORI2R(ARM64Reg Rd, ARM64Reg Rn, u64 imm) {
|
||||
}
|
||||
|
||||
float FPImm8ToFloat(uint8_t bits) {
|
||||
int E = 8;
|
||||
int F = 32 - 8 - 1;
|
||||
int sign = bits >> 7;
|
||||
uint32_t f = 0;
|
||||
f |= (sign << 31);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef IOS
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
#include <libkern/OSCacheControl.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
@@ -627,7 +627,7 @@ void ARMXEmitter::FlushIcache()
|
||||
|
||||
void ARMXEmitter::FlushIcacheSection(u8 *start, u8 *end)
|
||||
{
|
||||
#if defined(IOS)
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
// Header file says this is equivalent to: sys_icache_invalidate(start, end - start);
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||
#elif PPSSPP_PLATFORM(WINDOWS)
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <cstdint>
|
||||
#include <cstdlib> // for byte swapping
|
||||
#include <cstddef>
|
||||
@@ -27,7 +28,7 @@ inline int LeastSignificantSetBit(u32 val)
|
||||
_BitScanForward(&index, val);
|
||||
return (int)index;
|
||||
}
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
inline int LeastSignificantSetBit(u64 val)
|
||||
{
|
||||
unsigned long index;
|
||||
|
||||
+31
-22
@@ -16,9 +16,9 @@
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
// Reference : https://stackoverflow.com/questions/6121792/how-to-check-if-a-cpu-supports-the-sse3-instruction-set
|
||||
#if defined(_M_IX86) || defined(_M_X64)
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory.h>
|
||||
#include <set>
|
||||
|
||||
@@ -34,10 +35,9 @@
|
||||
#include "Common/File/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
|
||||
#if defined(_WIN32) && !defined(__MINGW32__)
|
||||
#if defined(_WIN32)
|
||||
#include "Common/CommonWindows.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#define _interlockedbittestandset workaround_ms_header_bug_platform_sdk6_set
|
||||
#define _interlockedbittestandreset workaround_ms_header_bug_platform_sdk6_reset
|
||||
#define _interlockedbittestandset64 workaround_ms_header_bug_platform_sdk6_set64
|
||||
@@ -55,24 +55,30 @@ void do_cpuid(u32 regs[4], u32 cpuid_leaf) {
|
||||
__cpuid((int *)regs, cpuid_leaf);
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
static uint64_t do_xgetbv(unsigned int index) {
|
||||
unsigned int eax, edx;
|
||||
// This is xgetbv directly, so we can avoid compilers warning we need runtime checks.
|
||||
asm(".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(index));
|
||||
return ((uint64_t)edx << 32) | eax;
|
||||
}
|
||||
#else
|
||||
#define do_xgetbv _xgetbv
|
||||
#endif
|
||||
|
||||
#else // _WIN32
|
||||
|
||||
#ifdef _M_SSE
|
||||
#include <emmintrin.h>
|
||||
|
||||
#define _XCR_XFEATURE_ENABLED_MASK 0
|
||||
static unsigned long long _xgetbv(unsigned int index)
|
||||
{
|
||||
static uint64_t do_xgetbv(unsigned int index) {
|
||||
unsigned int eax, edx;
|
||||
__asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index));
|
||||
return ((unsigned long long)edx << 32) | eax;
|
||||
return ((uint64_t)edx << 32) | eax;
|
||||
}
|
||||
|
||||
#else
|
||||
#define _XCR_XFEATURE_ENABLED_MASK 0
|
||||
#endif // _M_SSE
|
||||
|
||||
#if !defined(MIPS)
|
||||
#if !PPSSPP_ARCH(MIPS)
|
||||
|
||||
void do_cpuidex(u32 regs[4], u32 cpuid_leaf, u32 ecxval) {
|
||||
#if defined(__i386__) && defined(__PIC__)
|
||||
@@ -94,10 +100,13 @@ void do_cpuid(u32 regs[4], u32 cpuid_leaf)
|
||||
do_cpuidex(regs, cpuid_leaf, 0);
|
||||
}
|
||||
|
||||
#endif // !defined(MIPS)
|
||||
#endif // !PPSSPP_ARCH(MIPS)
|
||||
|
||||
#endif // !win32
|
||||
|
||||
#ifndef _XCR_XFEATURE_ENABLED_MASK
|
||||
#define _XCR_XFEATURE_ENABLED_MASK 0
|
||||
#endif
|
||||
|
||||
CPUInfo cpu_info;
|
||||
|
||||
@@ -105,6 +114,7 @@ CPUInfo::CPUInfo() {
|
||||
Detect();
|
||||
}
|
||||
|
||||
#if PPSSPP_PLATFORM(LINUX)
|
||||
static std::vector<int> ParseCPUList(const std::string &filename) {
|
||||
std::string data;
|
||||
std::vector<int> results;
|
||||
@@ -126,13 +136,14 @@ static std::vector<int> ParseCPUList(const std::string &filename) {
|
||||
|
||||
return results;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Detects the various cpu features
|
||||
void CPUInfo::Detect() {
|
||||
memset(this, 0, sizeof(*this));
|
||||
#ifdef _M_IX86
|
||||
#if PPSSPP_ARCH(X86)
|
||||
Mode64bit = false;
|
||||
#elif defined (_M_X64)
|
||||
#elif PPSSPP_ARCH(AMD64)
|
||||
Mode64bit = true;
|
||||
OS64bit = true;
|
||||
#endif
|
||||
@@ -140,7 +151,7 @@ void CPUInfo::Detect() {
|
||||
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
OS64bit = Mode64bit; // TODO: Not always accurate!
|
||||
#elif defined(_WIN32) && defined(_M_IX86)
|
||||
#elif defined(_WIN32) && PPSSPP_ARCH(X86)
|
||||
BOOL f64 = false;
|
||||
IsWow64Process(GetCurrentProcess(), &f64);
|
||||
OS64bit = (f64 == TRUE) ? true : false;
|
||||
@@ -215,10 +226,8 @@ void CPUInfo::Detect() {
|
||||
// - Is the XSAVE bit set in CPUID? ( >>26)
|
||||
// - Is the OSXSAVE bit set in CPUID? ( >>27)
|
||||
// - XGETBV result has the XCR bit set.
|
||||
if (((cpu_id[2] >> 28) & 1) && ((cpu_id[2] >> 27) & 1) && ((cpu_id[2] >> 26) & 1))
|
||||
{
|
||||
if ((_xgetbv(_XCR_XFEATURE_ENABLED_MASK) & 0x6) == 0x6)
|
||||
{
|
||||
if (((cpu_id[2] >> 28) & 1) && ((cpu_id[2] >> 27) & 1) && ((cpu_id[2] >> 26) & 1)) {
|
||||
if ((do_xgetbv(_XCR_XFEATURE_ENABLED_MASK) & 0x6) == 0x6) {
|
||||
bAVX = true;
|
||||
if ((cpu_id[2] >> 12) & 1)
|
||||
bFMA3 = true;
|
||||
@@ -432,4 +441,4 @@ std::string CPUInfo::Summarize()
|
||||
return sum;
|
||||
}
|
||||
|
||||
#endif // defined(_M_IX86) || defined(_M_X64)
|
||||
#endif // PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)
|
||||
@@ -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 "ppsspp_config.h"
|
||||
#include "Common/Data/Convert/SmallDataConvert.h"
|
||||
#include "ColorConv.h"
|
||||
// NEON is in a separate file so that it can be compiled with a runtime check.
|
||||
#include "ColorConvNEON.h"
|
||||
@@ -487,8 +489,8 @@ void ConvertRGBA5551ToBGRA8888(u32 *dst, const u16 *src, u32 numPixels) {
|
||||
u32 r = Convert5To8(c & 0x001f);
|
||||
u32 g = Convert5To8((c >> 5) & 0x001f);
|
||||
u32 b = Convert5To8((c >> 10) & 0x001f);
|
||||
// We force an arithmetic shift to get the sign bits/
|
||||
u32 a = ((s32)(s16)c) & 0xff000000;
|
||||
// We force an arithmetic shift to get the sign bits.
|
||||
u32 a = SignExtend16ToU32(c) & 0xff000000;
|
||||
|
||||
dst[x] = a | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4100)
|
||||
#pragma warning(disable:4244)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#include "CommonTypes.h"
|
||||
|
||||
@@ -133,7 +133,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
@@ -160,7 +160,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_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)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
@@ -186,7 +186,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<ForcedIncludeFiles>Common/DbgNew.h</ForcedIncludeFiles>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
@@ -213,7 +213,7 @@
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
@@ -240,7 +240,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;_M_IX86=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
@@ -272,7 +272,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;_M_X64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
@@ -306,7 +306,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_64=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
@@ -340,7 +340,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_ARCH_32=1;NDEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ForcedIncludeFiles>
|
||||
</ForcedIncludeFiles>
|
||||
<AdditionalIncludeDirectories>../ext/glew;../ext/snappy;../ext/glslang;../ext/libpng17;../ext;../ext/zlib;..</AdditionalIncludeDirectories>
|
||||
|
||||
@@ -517,8 +517,6 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
|
||||
// Check size
|
||||
if (Width < 8 || Height < 12) return;
|
||||
|
||||
bool DBef = true;
|
||||
bool DAft = true;
|
||||
std::string SLog = "";
|
||||
|
||||
// Get console info
|
||||
|
||||
@@ -180,3 +180,22 @@ inline void ExpandFloat24x3ToFloat4(float dest[4], const uint32_t src[3]) {
|
||||
inline uint32_t BytesToUint32(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
|
||||
return (a) | (b << 8) | (c << 16) | (d << 24);
|
||||
}
|
||||
|
||||
constexpr int32_t SignExtend8ToS32(uint32_t value) {
|
||||
// This extends this sign at the 8th bit to the other 24 bits.
|
||||
return (int8_t)(value & 0xFF);
|
||||
}
|
||||
|
||||
constexpr uint32_t SignExtend8ToU32(uint32_t value) {
|
||||
// Just treat the bits as unsigned.
|
||||
return (uint32_t)SignExtend8ToS32(value);
|
||||
}
|
||||
|
||||
constexpr int32_t SignExtend16ToS32(uint32_t value) {
|
||||
// Same as SignExtend8toS32, but from the 16th bit.
|
||||
return (int16_t)(value & 0xFFFF);
|
||||
}
|
||||
|
||||
constexpr uint32_t SignExtend16ToU32(uint32_t value) {
|
||||
return (uint32_t)SignExtend16ToS32(value);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include "Common/Swap.h"
|
||||
|
||||
// George Marsaglia-style random number generator.
|
||||
class GMRng {
|
||||
@@ -57,8 +58,8 @@ private:
|
||||
MT_SIZE = 624,
|
||||
};
|
||||
|
||||
uint32_t index_;
|
||||
uint32_t mt_[MT_SIZE];
|
||||
u32_le index_;
|
||||
u32_le mt_[MT_SIZE];
|
||||
|
||||
void gen() {
|
||||
for(uint32_t i = 0; i < MT_SIZE; i++){
|
||||
|
||||
+25
-64
@@ -24,6 +24,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Common/CodeBlock.h"
|
||||
|
||||
// VCVT flags
|
||||
#define TO_FLOAT 0
|
||||
@@ -167,7 +168,7 @@ public:
|
||||
Operand2(FakeReg base, ShiftType type, FakeReg shift) // RSR
|
||||
{
|
||||
Type = TYPE_RSR;
|
||||
_assert_msg_(JIT, type != ST_RRX, "Invalid Operand2: RRX does not take a register shift amount");
|
||||
_assert_msg_(type != ST_RRX, "Invalid Operand2: RRX does not take a register shift amount");
|
||||
IndexOrShift = shift;
|
||||
Shift = type;
|
||||
Value = base;
|
||||
@@ -179,29 +180,29 @@ public:
|
||||
switch (type)
|
||||
{
|
||||
case ST_LSL:
|
||||
_assert_msg_(JIT, shift < 32, "Invalid Operand2: LSL %u", shift);
|
||||
_assert_msg_(shift < 32, "Invalid Operand2: LSL %u", shift);
|
||||
break;
|
||||
case ST_LSR:
|
||||
_assert_msg_(JIT, shift <= 32, "Invalid Operand2: LSR %u", shift);
|
||||
_assert_msg_(shift <= 32, "Invalid Operand2: LSR %u", shift);
|
||||
if (!shift)
|
||||
type = ST_LSL;
|
||||
if (shift == 32)
|
||||
shift = 0;
|
||||
break;
|
||||
case ST_ASR:
|
||||
_assert_msg_(JIT, shift < 32, "Invalid Operand2: ASR %u", shift);
|
||||
_assert_msg_(shift < 32, "Invalid Operand2: ASR %u", shift);
|
||||
if (!shift)
|
||||
type = ST_LSL;
|
||||
if (shift == 32)
|
||||
shift = 0;
|
||||
break;
|
||||
case ST_ROR:
|
||||
_assert_msg_(JIT, shift < 32, "Invalid Operand2: ROR %u", shift);
|
||||
_assert_msg_(shift < 32, "Invalid Operand2: ROR %u", shift);
|
||||
if (!shift)
|
||||
type = ST_LSL;
|
||||
break;
|
||||
case ST_RRX:
|
||||
_assert_msg_(JIT, shift == 0, "Invalid Operand2: RRX does not take an immediate shift amount");
|
||||
_assert_msg_(shift == 0, "Invalid Operand2: RRX does not take an immediate shift amount");
|
||||
type = ST_ROR;
|
||||
break;
|
||||
}
|
||||
@@ -223,45 +224,45 @@ public:
|
||||
case TYPE_RSR:
|
||||
return RSR();
|
||||
default:
|
||||
_assert_msg_(JIT, false, "GetData with Invalid Type");
|
||||
_assert_msg_(false, "GetData with Invalid Type");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
u32 IMMSR() // IMM shifted register
|
||||
{
|
||||
_assert_msg_(JIT, Type == TYPE_IMMSREG, "IMMSR must be imm shifted register");
|
||||
_assert_msg_(Type == TYPE_IMMSREG, "IMMSR must be imm shifted register");
|
||||
return ((IndexOrShift & 0x1f) << 7 | (Shift << 5) | Value);
|
||||
}
|
||||
u32 RSR() // Register shifted register
|
||||
{
|
||||
_assert_msg_(JIT, Type == TYPE_RSR, "RSR must be RSR Of Course");
|
||||
_assert_msg_(Type == TYPE_RSR, "RSR must be RSR Of Course");
|
||||
return (IndexOrShift << 8) | (Shift << 5) | 0x10 | Value;
|
||||
}
|
||||
u32 Rm()
|
||||
{
|
||||
_assert_msg_(JIT, Type == TYPE_REG, "Rm must be with Reg");
|
||||
_assert_msg_(Type == TYPE_REG, "Rm must be with Reg");
|
||||
return Value;
|
||||
}
|
||||
|
||||
u32 Imm5()
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm5 not IMM value");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm5 not IMM value");
|
||||
return ((Value & 0x0000001F) << 7);
|
||||
}
|
||||
u32 Imm8()
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm8Rot not IMM value");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm8Rot not IMM value");
|
||||
return Value & 0xFF;
|
||||
}
|
||||
u32 Imm8Rot() // IMM8 with Rotation
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm8Rot not IMM value");
|
||||
_assert_msg_(JIT, (Rotation & 0xE1) != 0, "Invalid Operand2: immediate rotation %u", Rotation);
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm8Rot not IMM value");
|
||||
_assert_msg_((Rotation & 0xE1) != 0, "Invalid Operand2: immediate rotation %u", Rotation);
|
||||
return (1 << 25) | (Rotation << 7) | (Value & 0x000000FF);
|
||||
}
|
||||
u32 Imm12()
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm12 not IMM");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm12 not IMM");
|
||||
return (Value & 0x00000FFF);
|
||||
}
|
||||
|
||||
@@ -272,12 +273,12 @@ public:
|
||||
// expand a 8bit IMM to a 32bit value and gives you some rotation as
|
||||
// well.
|
||||
// Each rotation rotates to the right by 2 bits
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm12Mod not IMM");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm12Mod not IMM");
|
||||
return ((Rotation & 0xF) << 8) | (Value & 0xFF);
|
||||
}
|
||||
u32 Imm16()
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm16 not IMM");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm16 not IMM");
|
||||
return ( (Value & 0xF000) << 4) | (Value & 0x0FFF);
|
||||
}
|
||||
u32 Imm16Low()
|
||||
@@ -286,12 +287,12 @@ public:
|
||||
}
|
||||
u32 Imm16High() // Returns high 16bits
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm16 not IMM");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm16 not IMM");
|
||||
return ( ((Value >> 16) & 0xF000) << 4) | ((Value >> 16) & 0x0FFF);
|
||||
}
|
||||
u32 Imm24()
|
||||
{
|
||||
_assert_msg_(JIT, (Type == TYPE_IMM), "Imm16 not IMM");
|
||||
_assert_msg_(Type == TYPE_IMM, "Imm16 not IMM");
|
||||
return (Value & 0x0FFFFFFF);
|
||||
}
|
||||
};
|
||||
@@ -380,6 +381,9 @@ public:
|
||||
}
|
||||
virtual ~FakeXEmitter() {}
|
||||
|
||||
void SetCodePointer(u8 *ptr, u8 *writePtr) {}
|
||||
const u8 *GetCodePointer() const { return nullptr; }
|
||||
|
||||
void SetCodePtr(u8 *ptr) {}
|
||||
void ReserveCodeSpace(u32 bytes) {}
|
||||
const u8 *AlignCode16() { return nullptr; }
|
||||
@@ -411,52 +415,9 @@ public:
|
||||
// Everything that needs to generate machine code should inherit from this.
|
||||
// You get memory management for free, plus, you can use all the MOV etc functions without
|
||||
// having to prefix them with gen-> or something similar.
|
||||
class FakeXCodeBlock : public FakeXEmitter
|
||||
{
|
||||
protected:
|
||||
u8 *region;
|
||||
size_t region_size;
|
||||
|
||||
class FakeXCodeBlock : public CodeBlock<FakeXEmitter> {
|
||||
public:
|
||||
FakeXCodeBlock() : region(NULL), region_size(0) {}
|
||||
virtual ~FakeXCodeBlock() { if (region) FreeCodeSpace(); }
|
||||
|
||||
// Call this before you generate any code.
|
||||
void AllocCodeSpace(int size) { }
|
||||
|
||||
// Always clear code space with breakpoints, so that if someone accidentally executes
|
||||
// uninitialized, it just breaks into the debugger.
|
||||
void ClearCodeSpace() { }
|
||||
|
||||
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
||||
void FreeCodeSpace() { }
|
||||
|
||||
bool IsInSpace(const u8 *ptr) const
|
||||
{
|
||||
return ptr >= region && ptr < region + region_size;
|
||||
}
|
||||
|
||||
// Cannot currently be undone. Will write protect the entire code region.
|
||||
// Start over if you need to change the code (call FreeCodeSpace(), AllocCodeSpace()).
|
||||
void WriteProtect() { }
|
||||
void UnWriteProtect() { }
|
||||
|
||||
void ResetCodePtr()
|
||||
{
|
||||
SetCodePtr(region);
|
||||
}
|
||||
|
||||
size_t GetSpaceLeft() const
|
||||
{
|
||||
return region_size - (GetCodePtr() - region);
|
||||
}
|
||||
|
||||
u8 *GetBasePtr() {
|
||||
return region;
|
||||
}
|
||||
|
||||
size_t GetOffset(const u8 *ptr) const {
|
||||
return ptr - region;
|
||||
void PoisonMemory(int offset) override {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,14 @@
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#include <unistd.h>
|
||||
#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
|
||||
#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
|
||||
#endif
|
||||
#endif
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
#include "Common/Log.h"
|
||||
@@ -56,9 +63,9 @@
|
||||
#include <CoreFoundation/CFString.h>
|
||||
#include <CoreFoundation/CFURL.h>
|
||||
#include <CoreFoundation/CFBundle.h>
|
||||
#if !defined(IOS)
|
||||
#if !PPSSPP_PLATFORM(IOS)
|
||||
#include <mach-o/dyld.h>
|
||||
#endif // !defined(IOS)
|
||||
#endif // !PPSSPP_PLATFORM(IOS)
|
||||
#endif // __APPLE__
|
||||
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
@@ -238,7 +245,7 @@ bool IsDirectory(const std::string &filename)
|
||||
std::wstring copy = ConvertUTF8ToWString(fn);
|
||||
WIN32_FILE_ATTRIBUTE_DATA data{};
|
||||
if (!GetFileAttributesEx(copy.c_str(), GetFileExInfoStandard, &data) || data.dwFileAttributes == INVALID_FILE_ATTRIBUTES) {
|
||||
WARN_LOG(COMMON, "GetFileAttributes failed on %s: %08x", fn.c_str(), GetLastError());
|
||||
WARN_LOG(COMMON, "GetFileAttributes failed on %s: %08x", fn.c_str(), (uint32_t)GetLastError());
|
||||
return false;
|
||||
}
|
||||
DWORD result = data.dwFileAttributes;
|
||||
@@ -304,7 +311,7 @@ bool CreateDir(const std::string &path)
|
||||
WARN_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: already exists", path.c_str());
|
||||
return true;
|
||||
}
|
||||
ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %i", path.c_str(), error);
|
||||
ERROR_LOG(COMMON, "CreateDir: CreateDirectory failed on %s: %08x", path.c_str(), (uint32_t)error);
|
||||
return false;
|
||||
#else
|
||||
if (mkdir(fn.c_str(), 0755) == 0)
|
||||
@@ -837,13 +844,13 @@ const std::string &GetExeDirectory()
|
||||
ExePath = program_path;
|
||||
#endif
|
||||
|
||||
#elif (defined(__APPLE__) && !defined(IOS)) || defined(__linux__) || defined(KERN_PROC_PATHNAME)
|
||||
#elif (defined(__APPLE__) && !PPSSPP_PLATFORM(IOS)) || defined(__linux__) || defined(KERN_PROC_PATHNAME)
|
||||
char program_path[4096];
|
||||
uint32_t program_path_size = sizeof(program_path) - 1;
|
||||
|
||||
#if defined(__linux__)
|
||||
if (readlink("/proc/self/exe", program_path, program_path_size) > 0)
|
||||
#elif defined(__APPLE__) && !defined(IOS)
|
||||
#elif defined(__APPLE__) && !PPSSPP_PLATFORM(IOS)
|
||||
if (_NSGetExecutablePath(program_path, &program_path_size) == 0)
|
||||
#elif defined(KERN_PROC_PATHNAME)
|
||||
int mib[4] = {
|
||||
|
||||
@@ -146,22 +146,22 @@ void PathBrowser::SetPath(const std::string &path) {
|
||||
}
|
||||
|
||||
void PathBrowser::HandlePath() {
|
||||
std::lock_guard<std::mutex> guard(pendingLock_);
|
||||
|
||||
if (!path_.empty() && path_[0] == '!') {
|
||||
if (pendingActive_)
|
||||
ResetPending();
|
||||
ready_ = true;
|
||||
pendingCancel_ = true;
|
||||
pendingPath_.clear();
|
||||
return;
|
||||
}
|
||||
if (!startsWith(path_, "http://") && !startsWith(path_, "https://")) {
|
||||
if (pendingActive_)
|
||||
ResetPending();
|
||||
ready_ = true;
|
||||
pendingCancel_ = true;
|
||||
pendingPath_.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(pendingLock_);
|
||||
ready_ = false;
|
||||
pendingActive_ = true;
|
||||
pendingCancel_ = false;
|
||||
pendingFiles_.clear();
|
||||
pendingPath_ = path_;
|
||||
@@ -201,6 +201,12 @@ void PathBrowser::HandlePath() {
|
||||
});
|
||||
}
|
||||
|
||||
void PathBrowser::ResetPending() {
|
||||
std::lock_guard<std::mutex> guard(pendingLock_);
|
||||
pendingCancel_ = true;
|
||||
pendingPath_.clear();
|
||||
}
|
||||
|
||||
bool PathBrowser::IsListingReady() {
|
||||
return ready_;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
|
||||
private:
|
||||
void HandlePath();
|
||||
void ResetPending();
|
||||
|
||||
std::string path_;
|
||||
std::string pendingPath_;
|
||||
@@ -44,6 +45,7 @@ private:
|
||||
std::condition_variable pendingCond_;
|
||||
std::mutex pendingLock_;
|
||||
std::thread pendingThread_;
|
||||
bool pendingActive_ = false;
|
||||
bool pendingCancel_ = false;
|
||||
bool pendingStop_ = false;
|
||||
bool ready_ = false;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/GPU/D3D11/D3D11Loader.h"
|
||||
|
||||
#if PPSSPP_PLATFORM(UWP)
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
#include "Common/Log.h"
|
||||
|
||||
#include <cfloat>
|
||||
#include <D3DCommon.h>
|
||||
#include <D3Dcommon.h>
|
||||
#include <d3d11.h>
|
||||
#include <d3d11_1.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <D3Dcompiler.h>
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#undef __uuidof
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
void CopyFramebufferImage(Framebuffer *src, int level, int x, int y, int z, Framebuffer *dst, int dstLevel, int dstX, int dstY, int dstZ, int width, int height, int depth, int channelBits, const char *tag) override;
|
||||
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);
|
||||
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;
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal);
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
// void BeginFrame() override; //Libretro bs
|
||||
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
ID3D11Texture2D *bbDepthStencilTex_ = nullptr;
|
||||
ID3D11DepthStencilView *bbDepthStencilView_ = nullptr;
|
||||
|
||||
Framebuffer *curRenderTarget_ = nullptr;
|
||||
AutoRef<Framebuffer> curRenderTarget_;
|
||||
ID3D11RenderTargetView *curRenderTargetView_ = nullptr;
|
||||
ID3D11DepthStencilView *curDepthStencilView_ = nullptr;
|
||||
// Needed to rotate stencil/viewport rectangles properly
|
||||
@@ -194,12 +194,12 @@ private:
|
||||
int curRTWidth_ = 0;
|
||||
int curRTHeight_ = 0;
|
||||
|
||||
D3D11Pipeline *curPipeline_ = nullptr;
|
||||
AutoRef<D3D11Pipeline> curPipeline_;
|
||||
DeviceCaps caps_{};
|
||||
|
||||
D3D11BlendState *curBlend_ = nullptr;
|
||||
D3D11DepthStencilState *curDepth_ = nullptr;
|
||||
D3D11RasterState *curRaster_ = nullptr;
|
||||
AutoRef<D3D11BlendState> curBlend_;
|
||||
AutoRef<D3D11DepthStencilState> curDepth_;
|
||||
AutoRef<D3D11RasterState> curRaster_;
|
||||
ID3D11InputLayout *curInputLayout_ = nullptr;
|
||||
ID3D11VertexShader *curVS_ = nullptr;
|
||||
ID3D11PixelShader *curPS_ = nullptr;
|
||||
@@ -229,12 +229,12 @@ private:
|
||||
};
|
||||
|
||||
D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, D3D_FEATURE_LEVEL featureLevel, HWND hWnd, std::vector<std::string> deviceList)
|
||||
: device_(device),
|
||||
: hWnd_(hWnd),
|
||||
device_(device),
|
||||
context_(deviceContext1),
|
||||
device1_(device1),
|
||||
context1_(deviceContext1),
|
||||
featureLevel_(featureLevel),
|
||||
hWnd_(hWnd),
|
||||
deviceList_(deviceList) {
|
||||
|
||||
// We no longer support Windows Phone.
|
||||
@@ -696,14 +696,6 @@ public:
|
||||
class D3D11Pipeline : public Pipeline {
|
||||
public:
|
||||
~D3D11Pipeline() {
|
||||
if (input)
|
||||
input->Release();
|
||||
if (blend)
|
||||
blend->Release();
|
||||
if (depth)
|
||||
depth->Release();
|
||||
if (raster)
|
||||
raster->Release();
|
||||
if (il)
|
||||
il->Release();
|
||||
if (dynamicUniforms)
|
||||
@@ -716,11 +708,11 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
D3D11InputLayout *input = nullptr;
|
||||
AutoRef<D3D11InputLayout> input;
|
||||
ID3D11InputLayout *il = nullptr;
|
||||
D3D11BlendState *blend = nullptr;
|
||||
D3D11DepthStencilState *depth = nullptr;
|
||||
D3D11RasterState *raster = nullptr;
|
||||
AutoRef<D3D11BlendState> blend;
|
||||
AutoRef<D3D11DepthStencilState> depth;
|
||||
AutoRef<D3D11RasterState> raster;
|
||||
ID3D11VertexShader *vs = nullptr;
|
||||
ID3D11PixelShader *ps = nullptr;
|
||||
ID3D11GeometryShader *gs = nullptr;
|
||||
@@ -975,12 +967,6 @@ Pipeline *D3D11DrawContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
dPipeline->depth = (D3D11DepthStencilState *)desc.depthStencil;
|
||||
dPipeline->input = (D3D11InputLayout *)desc.inputLayout;
|
||||
dPipeline->raster = (D3D11RasterState *)desc.raster;
|
||||
dPipeline->blend->AddRef();
|
||||
dPipeline->depth->AddRef();
|
||||
if (dPipeline->input) {
|
||||
dPipeline->input->AddRef();
|
||||
}
|
||||
dPipeline->raster->AddRef();
|
||||
dPipeline->topology = primToD3D11[(int)desc.prim];
|
||||
if (desc.uniformDesc) {
|
||||
dPipeline->dynamicUniformsSize = desc.uniformDesc->uniformBufferSize;
|
||||
@@ -991,6 +977,10 @@ Pipeline *D3D11DrawContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
bufdesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
bufdesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
HRESULT hr = device_->CreateBuffer(&bufdesc, nullptr, &dPipeline->dynamicUniforms);
|
||||
if (FAILED(hr)) {
|
||||
dPipeline->Release();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<D3D11ShaderModule *> shaders;
|
||||
@@ -1022,8 +1012,7 @@ Pipeline *D3D11DrawContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
}
|
||||
|
||||
// Can finally create the input layout
|
||||
if (dPipeline->input) {
|
||||
auto &inputDesc = dPipeline->input->desc;
|
||||
if (dPipeline->input != nullptr) {
|
||||
const std::vector<D3D11_INPUT_ELEMENT_DESC> &elements = dPipeline->input->elements;
|
||||
HRESULT hr = device_->CreateInputLayout(elements.data(), (UINT)elements.size(), vshader->byteCode_.data(), vshader->byteCode_.size(), &dPipeline->il);
|
||||
if (!SUCCEEDED(hr)) {
|
||||
@@ -1101,7 +1090,7 @@ void D3D11DrawContext::ApplyCurrentState() {
|
||||
curTopology_ = curPipeline_->topology;
|
||||
}
|
||||
|
||||
if (curPipeline_->input) {
|
||||
if (curPipeline_->input != nullptr) {
|
||||
int numVBs = (int)curPipeline_->input->strides.size();
|
||||
context_->IASetVertexBuffers(0, numVBs, nextVertexBuffers_, (UINT *)curPipeline_->input->strides.data(), (UINT *)nextVertexBufferOffsets_);
|
||||
}
|
||||
@@ -1375,13 +1364,13 @@ void D3D11DrawContext::Clear(int mask, uint32_t colorval, float depthVal, int st
|
||||
/*void D3D11DrawContext::BeginFrame() { //Libretro bs
|
||||
context_->OMSetRenderTargets(1, &curRenderTargetView_, curDepthStencilView_);
|
||||
|
||||
if (curBlend_) {
|
||||
if (curBlend_ != nullptr) {
|
||||
context_->OMSetBlendState(curBlend_->bs, blendFactor_, 0xFFFFFFFF);
|
||||
}
|
||||
if (curDepth_) {
|
||||
if (curDepth_ != nullptr) {
|
||||
context_->OMSetDepthStencilState(curDepth_->dss, stencilRef_);
|
||||
}
|
||||
if (curRaster_) {
|
||||
if (curRaster_ != nullptr) {
|
||||
context_->RSSetState(curRaster_->rs);
|
||||
}
|
||||
context_->IASetInputLayout(curInputLayout_);
|
||||
@@ -1391,7 +1380,7 @@ void D3D11DrawContext::Clear(int mask, uint32_t colorval, float depthVal, int st
|
||||
if (curTopology_ != D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED) {
|
||||
context_->IASetPrimitiveTopology(curTopology_);
|
||||
}
|
||||
if (curPipeline_) {
|
||||
if (curPipeline_ != nullptr) {
|
||||
context_->IASetVertexBuffers(0, 1, nextVertexBuffers_, (UINT *)curPipeline_->input->strides.data(), (UINT *)nextVertexBufferOffsets_);
|
||||
context_->IASetIndexBuffer(nextIndexBuffer_, DXGI_FORMAT_R16_UINT, nextIndexBufferOffset_);
|
||||
if (curPipeline_->dynamicUniforms) {
|
||||
@@ -1488,7 +1477,6 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel
|
||||
packDesc.MipLevels = 1;
|
||||
packDesc.Usage = D3D11_USAGE_STAGING;
|
||||
packDesc.SampleDesc.Count = 1;
|
||||
D3D11_BOX srcBox{ (UINT)bx, (UINT)by, 0, (UINT)(bx + bw), (UINT)(by + bh), 1 };
|
||||
switch (channelBits) {
|
||||
case FB_COLOR_BIT:
|
||||
packDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // TODO: fb->colorFormat;
|
||||
|
||||
@@ -271,12 +271,8 @@ private:
|
||||
|
||||
class D3D9Pipeline : public Pipeline {
|
||||
public:
|
||||
D3D9Pipeline(LPDIRECT3DDEVICE9 device) : device_(device) {}
|
||||
D3D9Pipeline() {}
|
||||
~D3D9Pipeline() {
|
||||
if (depthStencil) depthStencil->Release();
|
||||
if (blend) blend->Release();
|
||||
if (raster) raster->Release();
|
||||
if (inputLayout) inputLayout->Release();
|
||||
}
|
||||
bool RequiresBuffer() override {
|
||||
return false;
|
||||
@@ -287,15 +283,13 @@ public:
|
||||
|
||||
D3DPRIMITIVETYPE prim;
|
||||
int primDivisor;
|
||||
D3D9InputLayout *inputLayout = nullptr;
|
||||
D3D9DepthStencilState *depthStencil = nullptr;
|
||||
D3D9BlendState *blend = nullptr;
|
||||
D3D9RasterState *raster = nullptr;
|
||||
AutoRef<D3D9InputLayout> inputLayout;
|
||||
AutoRef<D3D9DepthStencilState> depthStencil;
|
||||
AutoRef<D3D9BlendState> blend;
|
||||
AutoRef<D3D9RasterState> raster;
|
||||
UniformBufferDesc dynamicUniforms;
|
||||
|
||||
void Apply(LPDIRECT3DDEVICE9 device);
|
||||
private:
|
||||
LPDIRECT3DDEVICE9 device_;
|
||||
};
|
||||
|
||||
class D3D9Texture : public Texture {
|
||||
@@ -564,7 +558,7 @@ public:
|
||||
void Draw(int vertexCount, int offset) override;
|
||||
void DrawIndexed(int vertexCount, int offset) override;
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal);
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) override;
|
||||
|
||||
uint64_t GetNativeObject(NativeObject obj) override {
|
||||
switch (obj) {
|
||||
@@ -612,12 +606,12 @@ private:
|
||||
DeviceCaps caps_{};
|
||||
|
||||
// Bound state
|
||||
D3D9Pipeline *curPipeline_ = nullptr;
|
||||
D3D9Buffer *curVBuffers_[4]{};
|
||||
AutoRef<D3D9Pipeline> curPipeline_;
|
||||
AutoRef<D3D9Buffer> curVBuffers_[4];
|
||||
int curVBufferOffsets_[4]{};
|
||||
D3D9Buffer *curIBuffer_ = nullptr;
|
||||
AutoRef<D3D9Buffer> curIBuffer_;
|
||||
int curIBufferOffset_ = 0;
|
||||
Framebuffer *curRenderTarget_ = nullptr;
|
||||
AutoRef<Framebuffer> curRenderTarget_;
|
||||
|
||||
// Framebuffer state
|
||||
LPDIRECT3DSURFACE9 deviceRTsurf = 0;
|
||||
@@ -633,7 +627,7 @@ void D3D9Context::InvalidateCachedState() {
|
||||
#define FOURCC_INTZ ((D3DFORMAT)(MAKEFOURCC('I', 'N', 'T', 'Z')))
|
||||
|
||||
D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx)
|
||||
: d3d_(d3d), d3dEx_(d3dEx), adapterId_(adapterId), device_(device), deviceEx_(deviceEx), caps_{} {
|
||||
: d3d_(d3d), d3dEx_(d3dEx), device_(device), deviceEx_(deviceEx), adapterId_(adapterId), caps_{} {
|
||||
if (FAILED(d3d->GetAdapterIdentifier(adapterId, 0, &identifier_))) {
|
||||
ERROR_LOG(G3D, "Failed to get adapter identifier: %d", adapterId);
|
||||
}
|
||||
@@ -695,7 +689,7 @@ Pipeline *D3D9Context::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
ERROR_LOG(G3D, "Pipeline requires at least one shader");
|
||||
return NULL;
|
||||
}
|
||||
D3D9Pipeline *pipeline = new D3D9Pipeline(device_);
|
||||
D3D9Pipeline *pipeline = new D3D9Pipeline();
|
||||
for (auto iter : desc.shaders) {
|
||||
if (!iter) {
|
||||
ERROR_LOG(G3D, "NULL shader passed to CreateGraphicsPipeline");
|
||||
@@ -715,10 +709,6 @@ Pipeline *D3D9Context::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
pipeline->blend = (D3D9BlendState *)desc.blend;
|
||||
pipeline->raster = (D3D9RasterState *)desc.raster;
|
||||
pipeline->inputLayout = (D3D9InputLayout *)desc.inputLayout;
|
||||
pipeline->depthStencil->AddRef();
|
||||
pipeline->blend->AddRef();
|
||||
pipeline->raster->AddRef();
|
||||
pipeline->inputLayout->AddRef();
|
||||
if (desc.uniformDesc)
|
||||
pipeline->dynamicUniforms = *desc.uniformDesc;
|
||||
return pipeline;
|
||||
@@ -971,9 +961,6 @@ void D3D9Context::Draw(int vertexCount, int offset) {
|
||||
}
|
||||
|
||||
void D3D9Context::DrawIndexed(int vertexCount, int offset) {
|
||||
D3D9Buffer *vbuf = static_cast<D3D9Buffer *>(curVBuffers_[0]);
|
||||
D3D9Buffer *ibuf = static_cast<D3D9Buffer *>(curIBuffer_);
|
||||
|
||||
curPipeline_->Apply(device_);
|
||||
curPipeline_->inputLayout->Apply(device_);
|
||||
device_->SetStreamSource(0, curVBuffers_[0]->vbuffer_, curVBufferOffsets_[0], curPipeline_->inputLayout->GetStride(0));
|
||||
@@ -1032,7 +1019,6 @@ void D3D9Context::SetStencilRef(uint8_t ref) {
|
||||
bool D3D9ShaderModule::Compile(LPDIRECT3DDEVICE9 device, const uint8_t *data, size_t size) {
|
||||
LPD3D_SHADER_MACRO defines = nullptr;
|
||||
LPD3DINCLUDE includes = nullptr;
|
||||
DWORD flags = 0;
|
||||
LPD3DBLOB codeBuffer = nullptr;
|
||||
LPD3DBLOB errorBuffer = nullptr;
|
||||
const char *source = (const char *)data;
|
||||
|
||||
@@ -2,15 +2,12 @@
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#ifdef IOS
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
#include <OpenGLES/ES3/gl.h>
|
||||
#include <OpenGLES/ES3/glext.h>
|
||||
#elif defined(USING_GLES2)
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
// At least Nokia platforms need the three below
|
||||
#include <KHR/khrplatform.h>
|
||||
typedef char GLchar;
|
||||
#define GL_BGRA_EXT 0x80E1
|
||||
#else // OpenGL
|
||||
#include "GL/glew.h"
|
||||
@@ -61,7 +58,7 @@ typedef void (EGLAPIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (
|
||||
#endif
|
||||
extern PFNGLBLITFRAMEBUFFERNVPROC glBlitFramebufferNV;
|
||||
|
||||
#ifdef IOS
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
extern PFNGLDISCARDFRAMEBUFFEREXTPROC glDiscardFramebufferEXT;
|
||||
extern PFNGLGENVERTEXARRAYSOESPROC glGenVertexArraysOES;
|
||||
extern PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES;
|
||||
|
||||
@@ -31,7 +31,7 @@ PFNGLBINDVERTEXARRAYOESPROC glBindVertexArrayOES;
|
||||
PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOES;
|
||||
PFNGLISVERTEXARRAYOESPROC glIsVertexArrayOES;
|
||||
#endif
|
||||
#ifndef IOS
|
||||
#if !PPSSPP_PLATFORM(IOS)
|
||||
#include "EGL/egl.h"
|
||||
#endif
|
||||
#endif
|
||||
@@ -181,7 +181,7 @@ void CheckGLExtensions() {
|
||||
// Just for reference: Galaxy Y has renderer == "VideoCore IV HW"
|
||||
} else if (vendor == "Vivante Corporation") {
|
||||
gl_extensions.gpuVendor = GPU_VENDOR_VIVANTE;
|
||||
} else if (vendor == "Apple Inc.") {
|
||||
} else if (vendor == "Apple Inc." || vendor == "Apple") {
|
||||
gl_extensions.gpuVendor = GPU_VENDOR_APPLE;
|
||||
} else {
|
||||
WARN_LOG(G3D, "Unknown GL vendor: '%s'", vendor.c_str());
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/GPU/OpenGL/GLCommon.h"
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
#define TEXCACHE_NAME_CACHE_SIZE 16
|
||||
|
||||
#ifdef IOS
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
extern void bindDefaultFBO();
|
||||
#endif
|
||||
|
||||
@@ -201,7 +202,7 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &steps, bool ski
|
||||
} else if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
||||
glBindFragDataLocation(program->program, 0, "fragColor0");
|
||||
}
|
||||
#elif !defined(IOS)
|
||||
#elif !PPSSPP_PLATFORM(IOS)
|
||||
if (gl_extensions.GLES3 && step.create_program.support_dual_source) {
|
||||
glBindFragDataLocationIndexedEXT(program->program, 0, 0, "fragColor0");
|
||||
glBindFragDataLocationIndexedEXT(program->program, 0, 1, "fragColor1");
|
||||
@@ -1368,13 +1369,15 @@ void GLQueueRunner::PerformCopy(const GLRStep &step) {
|
||||
_dbg_assert_(dstTex);
|
||||
|
||||
#if defined(USING_GLES2)
|
||||
#ifndef IOS
|
||||
#if !PPSSPP_PLATFORM(IOS)
|
||||
_assert_msg_(gl_extensions.OES_copy_image || gl_extensions.NV_copy_image || gl_extensions.EXT_copy_image, "Image copy extension expected");
|
||||
glCopyImageSubDataOES(
|
||||
srcTex, target, srcLevel, srcRect.x, srcRect.y, srcZ,
|
||||
dstTex, target, dstLevel, dstPos.x, dstPos.y, dstZ,
|
||||
srcRect.w, srcRect.h, depth);
|
||||
#endif
|
||||
#else
|
||||
_assert_msg_(gl_extensions.ARB_copy_image || gl_extensions.NV_copy_image, "Image copy extension expected");
|
||||
if (gl_extensions.ARB_copy_image) {
|
||||
glCopyImageSubData(
|
||||
srcTex, target, srcLevel, srcRect.x, srcRect.y, srcZ,
|
||||
@@ -1680,7 +1683,7 @@ void GLQueueRunner::fbo_unbind() {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, g_defaultFBO);
|
||||
#endif
|
||||
|
||||
#ifdef IOS
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
bindDefaultFBO();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "GLRenderManager.h"
|
||||
#include "Common/GPU/OpenGL/GLFeatures.h"
|
||||
#include "Common/GPU/thin3d.h"
|
||||
@@ -672,7 +673,7 @@ void GLRenderManager::WaitUntilQueueIdle() {
|
||||
}
|
||||
}
|
||||
|
||||
GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size) : render_(render), target_(target), size_(size) {
|
||||
GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size) : render_(render), size_(size), target_(target) {
|
||||
bool res = AddBuffer();
|
||||
_assert_(res);
|
||||
}
|
||||
@@ -889,7 +890,7 @@ void *GLRBuffer::Map(GLBufferStrategy strategy) {
|
||||
glBindBuffer(target_, buffer_);
|
||||
|
||||
if (gl_extensions.ARB_buffer_storage || gl_extensions.EXT_buffer_storage) {
|
||||
#ifndef IOS
|
||||
#if !PPSSPP_PLATFORM(IOS)
|
||||
if (!hasStorage_) {
|
||||
GLbitfield storageFlags = access & ~(GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_FLUSH_EXPLICIT_BIT);
|
||||
#ifdef USING_GLES2
|
||||
|
||||
@@ -47,8 +47,8 @@ public:
|
||||
class GLRFramebuffer {
|
||||
public:
|
||||
GLRFramebuffer(int _width, int _height, bool z_stencil)
|
||||
: width(_width), height(_height), z_stencil_(z_stencil),
|
||||
color_texture(_width, _height, 1), z_stencil_texture(_width, _height, 1) {
|
||||
: color_texture(_width, _height, 1), z_stencil_texture(_width, _height, 1),
|
||||
width(_width), height(_height), z_stencil_(z_stencil) {
|
||||
}
|
||||
|
||||
~GLRFramebuffer();
|
||||
|
||||
@@ -382,7 +382,7 @@ GLboolean gl3stubInit() {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
#endif // IOS
|
||||
#endif // PPSPP_PLATFORM(IOS)
|
||||
|
||||
#endif // GLES2
|
||||
|
||||
@@ -514,7 +514,7 @@ extern GL_APICALL void (* GL_APIENTRY glBufferStorageEXT) (GLenum targ
|
||||
/* OES_copy_image, etc. */
|
||||
extern GL_APICALL void (* GL_APIENTRY glCopyImageSubDataOES) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth);
|
||||
|
||||
#endif // IOS
|
||||
#endif // PPSSPP_PLATFORM(IOS)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ static const unsigned short blendFactorToGL[] = {
|
||||
GL_ONE_MINUS_SRC1_COLOR,
|
||||
GL_SRC1_ALPHA,
|
||||
GL_ONE_MINUS_SRC1_ALPHA,
|
||||
#elif !defined(IOS)
|
||||
#elif !PPSSPP_PLATFORM(IOS)
|
||||
GL_SRC1_COLOR_EXT,
|
||||
GL_ONE_MINUS_SRC1_COLOR_EXT,
|
||||
GL_SRC1_ALPHA_EXT,
|
||||
@@ -281,10 +281,6 @@ public:
|
||||
iter->Release();
|
||||
}
|
||||
if (program_) render_->DeleteProgram(program_);
|
||||
if (depthStencil) depthStencil->Release();
|
||||
if (blend) blend->Release();
|
||||
if (raster) raster->Release();
|
||||
if (inputLayout) inputLayout->Release();
|
||||
}
|
||||
|
||||
bool LinkShaders();
|
||||
@@ -295,14 +291,14 @@ public:
|
||||
|
||||
GLuint prim = 0;
|
||||
std::vector<OpenGLShaderModule *> shaders;
|
||||
OpenGLInputLayout *inputLayout = nullptr;
|
||||
OpenGLDepthStencilState *depthStencil = nullptr;
|
||||
OpenGLBlendState *blend = nullptr;
|
||||
OpenGLRasterState *raster = nullptr;
|
||||
AutoRef<OpenGLInputLayout> inputLayout;
|
||||
AutoRef<OpenGLDepthStencilState> depthStencil;
|
||||
AutoRef<OpenGLBlendState> blend;
|
||||
AutoRef<OpenGLRasterState> raster;
|
||||
|
||||
// TODO: Optimize by getting the locations first and putting in a custom struct
|
||||
UniformBufferDesc dynamicUniforms;
|
||||
GLint samplerLocs_[8];
|
||||
GLint samplerLocs_[8]{};
|
||||
std::vector<GLint> dynamicUniformLocs_;
|
||||
GLRProgram *program_ = nullptr;
|
||||
|
||||
@@ -406,7 +402,7 @@ public:
|
||||
void BindPipeline(Pipeline *pipeline) override;
|
||||
void BindVertexBuffers(int start, int count, Buffer **buffers, int *offsets) override {
|
||||
for (int i = 0; i < count; i++) {
|
||||
curVBuffers_[i + start] = (OpenGLBuffer *)buffers[i];
|
||||
curVBuffers_[i + start] = (OpenGLBuffer *)buffers[i];
|
||||
curVBufferOffsets_[i + start] = offsets ? offsets[i] : 0;
|
||||
}
|
||||
}
|
||||
@@ -482,17 +478,17 @@ private:
|
||||
DeviceCaps caps_{};
|
||||
|
||||
// Bound state
|
||||
OpenGLSamplerState *boundSamplers_[MAX_TEXTURE_SLOTS]{};
|
||||
AutoRef<OpenGLSamplerState> boundSamplers_[MAX_TEXTURE_SLOTS];
|
||||
// Point to GLRTexture directly because they can point to the textures
|
||||
// in framebuffers too (which also can be bound).
|
||||
const GLRTexture *boundTextures_[MAX_TEXTURE_SLOTS]{};
|
||||
|
||||
OpenGLPipeline *curPipeline_ = nullptr;
|
||||
OpenGLBuffer *curVBuffers_[4]{};
|
||||
AutoRef<OpenGLPipeline> curPipeline_;
|
||||
AutoRef<OpenGLBuffer> curVBuffers_[4]{};
|
||||
int curVBufferOffsets_[4]{};
|
||||
OpenGLBuffer *curIBuffer_ = nullptr;
|
||||
AutoRef<OpenGLBuffer> curIBuffer_;
|
||||
int curIBufferOffset_ = 0;
|
||||
Framebuffer *curRenderTarget_ = nullptr;
|
||||
AutoRef<Framebuffer> curRenderTarget_;
|
||||
|
||||
uint8_t stencilRef_ = 0;
|
||||
|
||||
@@ -1038,8 +1034,8 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
ERROR_LOG(G3D, "Pipeline requires at least one shader");
|
||||
return nullptr;
|
||||
}
|
||||
if ((int)desc.prim >= (int)Primitive::PRIMITIVE_TYPE_COUNT) {
|
||||
ERROR_LOG(G3D, "Invalid primitive type");
|
||||
if ((uint32_t)desc.prim >= (uint32_t)Primitive::PRIMITIVE_TYPE_COUNT) {
|
||||
ERROR_LOG(G3D, "Invalid primitive type");
|
||||
return nullptr;
|
||||
}
|
||||
if (!desc.depthStencil || !desc.blend || !desc.raster) {
|
||||
@@ -1069,12 +1065,6 @@ Pipeline *OpenGLContext::CreateGraphicsPipeline(const PipelineDesc &desc) {
|
||||
pipeline->blend = (OpenGLBlendState *)desc.blend;
|
||||
pipeline->raster = (OpenGLRasterState *)desc.raster;
|
||||
pipeline->inputLayout = (OpenGLInputLayout *)desc.inputLayout;
|
||||
pipeline->depthStencil->AddRef();
|
||||
pipeline->blend->AddRef();
|
||||
pipeline->raster->AddRef();
|
||||
if (pipeline->inputLayout) {
|
||||
pipeline->inputLayout->AddRef();
|
||||
}
|
||||
return pipeline;
|
||||
} else {
|
||||
ERROR_LOG(G3D, "Failed to create pipeline - shaders failed to link");
|
||||
@@ -1210,7 +1200,7 @@ void OpenGLContext::UpdateDynamicUniformBuffer(const void *ub, size_t size) {
|
||||
}
|
||||
|
||||
void OpenGLContext::Draw(int vertexCount, int offset) {
|
||||
_dbg_assert_msg_(curVBuffers_[0], "Can't call Draw without a vertex buffer");
|
||||
_dbg_assert_msg_(curVBuffers_[0] != nullptr, "Can't call Draw without a vertex buffer");
|
||||
ApplySamplers();
|
||||
if (curPipeline_->inputLayout) {
|
||||
renderManager_.BindVertexBuffer(curPipeline_->inputLayout->inputLayout_, curVBuffers_[0]->buffer_, curVBufferOffsets_[0]);
|
||||
@@ -1219,8 +1209,8 @@ void OpenGLContext::Draw(int vertexCount, int offset) {
|
||||
}
|
||||
|
||||
void OpenGLContext::DrawIndexed(int vertexCount, int offset) {
|
||||
_dbg_assert_msg_(curVBuffers_[0], "Can't call DrawIndexed without a vertex buffer");
|
||||
_dbg_assert_msg_(curIBuffer_, "Can't call DrawIndexed without an index buffer");
|
||||
_dbg_assert_msg_(curVBuffers_[0] != nullptr, "Can't call DrawIndexed without a vertex buffer");
|
||||
_dbg_assert_msg_(curIBuffer_ != nullptr, "Can't call DrawIndexed without an index buffer");
|
||||
ApplySamplers();
|
||||
if (curPipeline_->inputLayout) {
|
||||
renderManager_.BindVertexBuffer(curPipeline_->inputLayout->inputLayout_, curVBuffers_[0]->buffer_, curVBufferOffsets_[0]);
|
||||
@@ -1230,7 +1220,7 @@ void OpenGLContext::DrawIndexed(int vertexCount, int offset) {
|
||||
}
|
||||
|
||||
void OpenGLContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
_assert_(curPipeline_->inputLayout);
|
||||
_assert_(curPipeline_->inputLayout != nullptr);
|
||||
int stride = curPipeline_->inputLayout->stride;
|
||||
size_t dataSize = stride * vertexCount;
|
||||
|
||||
|
||||
@@ -21,17 +21,8 @@
|
||||
#undef new
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
#include "ext/glslang/SPIRV/GlslangToSpv.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#ifdef USE_CRT_DBG
|
||||
#define new DBG_NEW
|
||||
#endif
|
||||
@@ -1001,7 +992,6 @@ bool VulkanContext::InitSwapchain() {
|
||||
std::string currentTransform = surface_transforms_to_string(surfCapabilities_.currentTransform);
|
||||
g_display_rotation = DisplayRotation::ROTATE_0;
|
||||
g_display_rot_matrix.setIdentity();
|
||||
bool swapChainExtentSwap = false;
|
||||
if (surfCapabilities_.currentTransform & (VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR | VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR)) {
|
||||
preTransform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR;
|
||||
} else if (surfCapabilities_.currentTransform & (VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR | VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR | VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR)) {
|
||||
@@ -1429,7 +1419,6 @@ bool IsHashMaliDriverVersion(const VkPhysicalDeviceProperties &props) {
|
||||
// ARM used to put a hash in place of the driver version.
|
||||
// Now they only use major versions. We'll just make a bad heuristic.
|
||||
uint32_t major = VK_VERSION_MAJOR(props.driverVersion);
|
||||
uint32_t minor = VK_VERSION_MINOR(props.driverVersion);
|
||||
uint32_t branch = VK_VERSION_PATCH(props.driverVersion);
|
||||
if (branch > 0)
|
||||
return true;
|
||||
|
||||
@@ -37,8 +37,12 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
|
||||
// UNASSIGNED-CoreValidation-Shader-OutputNotConsumed - benign perf warning
|
||||
return false;
|
||||
}
|
||||
if (messageCode == 1303270965) {
|
||||
// Benign perf warning, image blit using GENERAL layout.
|
||||
// UNASSIGNED
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *pLayerPrefix = "";
|
||||
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
||||
message << "ERROR(";
|
||||
} else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
|
||||
|
||||
@@ -31,6 +31,11 @@ static bool IsDepthStencilFormat(VkFormat format) {
|
||||
}
|
||||
|
||||
bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *allocator, int w, int h, int numMips, VkFormat format, VkImageLayout initialLayout, VkImageUsageFlags usage, const VkComponentMapping *mapping) {
|
||||
if (w == 0 || h == 0 || numMips == 0) {
|
||||
ERROR_LOG(G3D, "Can't create a zero-size VulkanTexture");
|
||||
return false;
|
||||
}
|
||||
|
||||
Wipe();
|
||||
|
||||
width_ = w;
|
||||
@@ -196,7 +201,8 @@ void VulkanTexture::ClearMip(VkCommandBuffer cmd, int mip, uint32_t value) {
|
||||
vkCmdClearColorImage(cmd, image_, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clearVal, 1, &range);
|
||||
}
|
||||
|
||||
void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip) {
|
||||
// Low-quality mipmap generation by bilinear blit, but works okay.
|
||||
void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip, VkImageLayout imageLayout) {
|
||||
_assert_msg_(mip != 0, "Cannot generate the first level");
|
||||
_assert_msg_(mip < numMips_, "Cannot generate mipmaps past the maximum created (%d vs %d)", mip, numMips_);
|
||||
VkImageBlit blit{};
|
||||
@@ -214,16 +220,20 @@ void VulkanTexture::GenerateMip(VkCommandBuffer cmd, int mip) {
|
||||
blit.dstOffsets[1].y = height_ >> mip;
|
||||
blit.dstOffsets[1].z = 1;
|
||||
|
||||
// TODO: We could do better with the image transitions - would be enough with one per level
|
||||
// for the memory barrier, then one final one for the whole stack when done. This function
|
||||
// currently doesn't have a global enough view, though.
|
||||
// We should also coalesce barriers across multiple texture uploads in a frame and all kinds of other stuff, but...
|
||||
|
||||
TransitionImageLayout2(cmd, image_, mip - 1, 1, VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
imageLayout, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||
|
||||
// Low-quality mipmap generation, but works okay.
|
||||
vkCmdBlitImage(cmd, image_, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, VK_FILTER_LINEAR);
|
||||
vkCmdBlitImage(cmd, image_, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, image_, imageLayout, 1, &blit, VK_FILTER_LINEAR);
|
||||
|
||||
TransitionImageLayout2(cmd, image_, mip - 1, 1, VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, imageLayout,
|
||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_ACCESS_TRANSFER_READ_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
bool CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *allocator, int w, int h, int numMips, VkFormat format, VkImageLayout initialLayout, VkImageUsageFlags usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, const VkComponentMapping *mapping = nullptr);
|
||||
void ClearMip(VkCommandBuffer cmd, int mip, uint32_t value);
|
||||
void UploadMip(VkCommandBuffer cmd, int mip, int mipWidth, int mipHeight, VkBuffer buffer, uint32_t offset, size_t rowLength); // rowLength is in pixels
|
||||
void GenerateMip(VkCommandBuffer cmd, int mip);
|
||||
void GenerateMip(VkCommandBuffer cmd, int mip, VkImageLayout imageLayout);
|
||||
void EndCreate(VkCommandBuffer cmd, bool vertexTexture = false, VkImageLayout layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
|
||||
// When loading mips from compute shaders, you need to pass VK_IMAGE_LAYOUT_GENERAL to the above function.
|
||||
|
||||
@@ -15,11 +15,12 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "Common/GPU/Vulkan/VulkanLoader.h"
|
||||
#include "ppsspp_config.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/GPU/Vulkan/VulkanLoader.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/System/System.h"
|
||||
|
||||
@@ -235,10 +236,11 @@ static const char *device_name_blacklist[] = {
|
||||
"SDL:Horizon",
|
||||
};
|
||||
|
||||
#ifndef _WIN32
|
||||
static const char *so_names[] = {
|
||||
#ifdef IOS
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
"@executable_path/Frameworks/libMoltenVK.dylib",
|
||||
#elif defined(PPSSPP_PLATFORM_MAC)
|
||||
#elif PPSSPP_PLATFORM(MAC)
|
||||
"@executable_path/../Frameworks/libMoltenVK.dylib",
|
||||
#else
|
||||
"libvulkan.so",
|
||||
@@ -247,6 +249,7 @@ static const char *so_names[] = {
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
void VulkanSetAvailable(bool available) {
|
||||
g_vulkanAvailabilityChecked = true;
|
||||
|
||||
@@ -246,7 +246,6 @@ size_t VulkanDeviceAllocator::Allocate(const VkMemoryRequirements &reqs, VkDevic
|
||||
|
||||
bool VulkanDeviceAllocator::AllocateFromSlab(Slab &slab, size_t &start, size_t blocks, const char *tag) {
|
||||
_assert_(!destroyed_);
|
||||
bool matched = true;
|
||||
|
||||
if (start + blocks > slab.usage.size()) {
|
||||
start = slab.usage.size();
|
||||
|
||||
@@ -207,9 +207,10 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan
|
||||
|
||||
queueRunner_.CreateDeviceObjects();
|
||||
|
||||
// Temporary AMD hack for issue #10097
|
||||
if (vulkan_->GetPhysicalDeviceProperties().properties.vendorID == VULKAN_VENDOR_AMD) {
|
||||
useThread_ = false;
|
||||
// AMD hack for issue #10097 (older drivers only.)
|
||||
const auto &props = vulkan_->GetPhysicalDeviceProperties().properties;
|
||||
if (props.vendorID == VULKAN_VENDOR_AMD && props.apiVersion < VK_API_VERSION_1_1) {
|
||||
useThread_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, con
|
||||
std::vector<uint32_t> spirv;
|
||||
std::string errorMessage;
|
||||
if (!GLSLtoSPV(vkstage_, source_.c_str(), GLSLVariant::VULKAN, spirv, &errorMessage)) {
|
||||
INFO_LOG(G3D, "Shader compile to module failed: %s", errorMessage.c_str());
|
||||
WARN_LOG(G3D, "Shader compile to module failed: %s", errorMessage.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,6 +231,7 @@ bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, con
|
||||
if (vulkan->CreateShaderModule(spirv, &module_)) {
|
||||
ok_ = true;
|
||||
} else {
|
||||
WARN_LOG(G3D, "vkCreateShaderModule failed");
|
||||
ok_ = false;
|
||||
}
|
||||
return ok_;
|
||||
@@ -245,7 +246,7 @@ public:
|
||||
|
||||
class VKPipeline : public Pipeline {
|
||||
public:
|
||||
VKPipeline(VulkanContext *vulkan, size_t size, PipelineFlags _flags) : vulkan_(vulkan), flags(_flags) {
|
||||
VKPipeline(VulkanContext *vulkan, size_t size, PipelineFlags _flags) : flags(_flags), vulkan_(vulkan) {
|
||||
uboSize_ = (int)size;
|
||||
ubo_ = new uint8_t[uboSize_];
|
||||
}
|
||||
@@ -510,16 +511,16 @@ private:
|
||||
|
||||
VulkanTexture *nullTexture_ = nullptr;
|
||||
|
||||
VKPipeline *curPipeline_ = nullptr;
|
||||
VKBuffer *curVBuffers_[4]{};
|
||||
AutoRef<VKPipeline> curPipeline_;
|
||||
AutoRef<VKBuffer> curVBuffers_[4];
|
||||
int curVBufferOffsets_[4]{};
|
||||
VKBuffer *curIBuffer_ = nullptr;
|
||||
AutoRef<VKBuffer> curIBuffer_;
|
||||
int curIBufferOffset_ = 0;
|
||||
|
||||
VkDescriptorSetLayout descriptorSetLayout_ = VK_NULL_HANDLE;
|
||||
VkPipelineLayout pipelineLayout_ = VK_NULL_HANDLE;
|
||||
VkPipelineCache pipelineCache_ = VK_NULL_HANDLE;
|
||||
Framebuffer *curFramebuffer_ = nullptr;
|
||||
AutoRef<Framebuffer> curFramebuffer_;
|
||||
|
||||
VkDevice device_;
|
||||
VkQueue queue_;
|
||||
@@ -528,8 +529,8 @@ private:
|
||||
enum {
|
||||
MAX_FRAME_COMMAND_BUFFERS = 256,
|
||||
};
|
||||
VKTexture *boundTextures_[MAX_BOUND_TEXTURES]{};
|
||||
VKSamplerState *boundSamplers_[MAX_BOUND_TEXTURES]{};
|
||||
AutoRef<VKTexture> boundTextures_[MAX_BOUND_TEXTURES];
|
||||
AutoRef<VKSamplerState> boundSamplers_[MAX_BOUND_TEXTURES];
|
||||
VkImageView boundImageView_[MAX_BOUND_TEXTURES]{};
|
||||
|
||||
struct FrameData {
|
||||
@@ -754,7 +755,7 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushBuffer *push, const Textur
|
||||
}
|
||||
// Generate the rest of the mips automatically.
|
||||
for (; i < mipLevels_; i++) {
|
||||
vkTex_->GenerateMip(cmd, i);
|
||||
vkTex_->GenerateMip(cmd, i, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
}
|
||||
vkTex_->EndCreate(cmd, false);
|
||||
@@ -762,7 +763,7 @@ bool VKTexture::Create(VkCommandBuffer cmd, VulkanPushBuffer *push, const Textur
|
||||
}
|
||||
|
||||
VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit)
|
||||
: vulkan_(vulkan), caps_{}, renderManager_(vulkan) {
|
||||
: vulkan_(vulkan), renderManager_(vulkan) {
|
||||
shaderLanguageDesc_.Init(GLSL_VULKAN);
|
||||
|
||||
caps_.anisoSupported = vulkan->GetDeviceFeatures().enabled.samplerAnisotropy != 0;
|
||||
@@ -1281,7 +1282,7 @@ ShaderModule *VKContext::CreateShaderModule(ShaderStage stage, ShaderLanguage la
|
||||
if (shader->Compile(vulkan_, language, data, size)) {
|
||||
return shader;
|
||||
} else {
|
||||
ERROR_LOG(G3D, "Failed to compile shader: %s", (const char *)data);
|
||||
ERROR_LOG(G3D, "Failed to compile shader:\n%s", (const char *)data);
|
||||
shader->Release();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -335,6 +335,46 @@ private:
|
||||
int refcount_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct AutoRef {
|
||||
AutoRef() {
|
||||
}
|
||||
explicit AutoRef(T *p) {
|
||||
ptr = p;
|
||||
if (ptr)
|
||||
ptr->AddRef();
|
||||
}
|
||||
AutoRef(const AutoRef<T> &p) {
|
||||
*this = p.ptr;
|
||||
}
|
||||
~AutoRef() {
|
||||
if (ptr)
|
||||
ptr->Release();
|
||||
}
|
||||
|
||||
T *operator =(T *p) {
|
||||
if (ptr)
|
||||
ptr->Release();
|
||||
ptr = p;
|
||||
if (ptr)
|
||||
ptr->AddRef();
|
||||
return ptr;
|
||||
}
|
||||
AutoRef<T> &operator =(const AutoRef<T> &p) {
|
||||
*this = p.ptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
T *operator->() const {
|
||||
return ptr;
|
||||
}
|
||||
operator T *() {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
T *ptr = nullptr;
|
||||
};
|
||||
|
||||
class BlendState : public RefCountedObject {
|
||||
public:
|
||||
};
|
||||
|
||||
@@ -7,12 +7,8 @@
|
||||
// Separated this stuff into its own file so we don't get Windows.h included if all we want is the thin3d declarations.
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <d3dcommon.h>
|
||||
#include "Common/CommonWindows.h"
|
||||
#include <D3Dcommon.h>
|
||||
struct IDirect3DDevice9;
|
||||
struct IDirect3D9;
|
||||
struct IDirect3DDevice9Ex;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "fast_math.h"
|
||||
#include "fast_matrix.h"
|
||||
|
||||
|
||||
@@ -66,6 +66,9 @@ struct Bounds {
|
||||
Bounds Expand(float amount) const {
|
||||
return Bounds(x - amount, y - amount, w + amount * 2, h + amount * 2);
|
||||
}
|
||||
Bounds Expand(float xAmount, float yAmount) const {
|
||||
return Bounds(x - xAmount, y - yAmount, w + xAmount * 2, h + yAmount * 2);
|
||||
}
|
||||
Bounds Offset(float xAmount, float yAmount) const {
|
||||
return Bounds(x + xAmount, y + yAmount, w, h);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ void MemArena::ReleaseView(void* view, size_t size) {
|
||||
}
|
||||
|
||||
bool MemArena::NeedsProbing() {
|
||||
#if defined(IOS) && PPSSPP_ARCH(64BIT)
|
||||
#if PPSSPP_PLATFORM(IOS) && PPSSPP_ARCH(64BIT)
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
@@ -92,7 +92,7 @@ bool MemArena::NeedsProbing() {
|
||||
}
|
||||
|
||||
u8* MemArena::Find4GBBase() {
|
||||
#if defined(IOS) && PPSSPP_ARCH(64BIT)
|
||||
#if PPSSPP_PLATFORM(IOS) && PPSSPP_ARCH(64BIT)
|
||||
// The caller will need to do probing, like on 32-bit Windows.
|
||||
return nullptr;
|
||||
#else
|
||||
|
||||
@@ -107,7 +107,7 @@ void MemArena::ReleaseView(void* view, size_t size) {
|
||||
|
||||
u8* MemArena::Find4GBBase() {
|
||||
// Now, create views in high memory where there's plenty of space.
|
||||
#if PPSSPP_ARCH(64BIT) && !defined(USE_ADDRESS_SANITIZER)
|
||||
#if PPSSPP_ARCH(64BIT) && !defined(USE_ASAN)
|
||||
// We should probably just go look in /proc/self/maps for some free space.
|
||||
// But let's try the anonymous mmap trick, just like on 32-bit, but bigger and
|
||||
// aligned to 4GB for the movk trick. We can ensure that we get an aligned 4GB
|
||||
|
||||
@@ -87,7 +87,7 @@ static uint32_t ConvertProtFlagsUnix(uint32_t flags) {
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && defined(_M_X64)
|
||||
#if defined(_WIN32) && PPSSPP_ARCH(AMD64)
|
||||
static uintptr_t last_executable_addr;
|
||||
static void *SearchForFreeMem(size_t size) {
|
||||
if (!last_executable_addr)
|
||||
@@ -128,7 +128,7 @@ void *AllocateExecutableMemory(size_t size) {
|
||||
prot = PAGE_READWRITE;
|
||||
if (sys_info.dwPageSize == 0)
|
||||
GetSystemInfo(&sys_info);
|
||||
#if defined(_M_X64)
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
if ((uintptr_t)&hint_location > 0xFFFFFFFFULL) {
|
||||
size_t aligned_size = ppsspp_round_page(size);
|
||||
#if 1 // Turn off to hunt for RIP bugs on x86-64.
|
||||
@@ -159,7 +159,7 @@ void *AllocateExecutableMemory(size_t size) {
|
||||
}
|
||||
#else
|
||||
static char *map_hint = 0;
|
||||
#if defined(_M_X64)
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
// Try to request one that is close to our memory location if we're in high memory.
|
||||
// We use a dummy global variable to give us a good location to start from.
|
||||
if (!map_hint) {
|
||||
@@ -190,7 +190,7 @@ void *AllocateExecutableMemory(size_t size) {
|
||||
ERROR_LOG(MEMMAP, "Failed to allocate executable memory (%d) errno=%d", (int)size, errno);
|
||||
}
|
||||
|
||||
#if defined(_M_X64) && !defined(_WIN32)
|
||||
#if PPSSPP_ARCH(AMD64) && !defined(_WIN32)
|
||||
else if ((uintptr_t)map_hint <= 0xFFFFFFFF) {
|
||||
// Round up if we're below 32-bit mark, probably allocating sequentially.
|
||||
map_hint += ppsspp_round_page(size);
|
||||
@@ -279,7 +279,7 @@ void FreeAlignedMemory(void* ptr) {
|
||||
bool PlatformIsWXExclusive() {
|
||||
// Needed on platforms that disable W^X pages for security. Even without block linking, still should be much faster than IR JIT.
|
||||
// This might also come in useful for UWP (Universal Windows Platform) if I'm understanding things correctly.
|
||||
#if defined(IOS) || PPSSPP_PLATFORM(UWP) || defined(__OpenBSD__)
|
||||
#if PPSSPP_PLATFORM(IOS) || PPSSPP_PLATFORM(UWP) || defined(__OpenBSD__)
|
||||
return true;
|
||||
#elif PPSSPP_PLATFORM(MAC) && PPSSPP_ARCH(ARM64)
|
||||
return true;
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#ifdef __mips__
|
||||
#include "ppsspp_config.h"
|
||||
#if PPSSPP_ARCH(MIPS) || PPSSPP_ARCH(MIPS64)
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CPUDetect.h"
|
||||
@@ -202,4 +203,4 @@ std::string CPUInfo::Summarize()
|
||||
return sum;
|
||||
}
|
||||
|
||||
#endif // __mips__
|
||||
#endif // PPSSPP_ARCH(MIPS) || PPSSPP_ARCH(MIPS64)
|
||||
+17
-25
@@ -15,6 +15,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
@@ -27,9 +28,13 @@
|
||||
#include "Common/CPUDetect.h"
|
||||
|
||||
namespace MIPSGen {
|
||||
void MIPSEmitter::SetCodePtr(u8 *ptr) {
|
||||
code_ = ptr;
|
||||
lastCacheFlushEnd_ = ptr;
|
||||
void MIPSEmitter::SetCodePointer(const u8 *ptr, u8 *writePtr) {
|
||||
code_ = writePtr;
|
||||
lastCacheFlushEnd_ = writePtr;
|
||||
}
|
||||
|
||||
const u8 *MIPSEmitter::GetCodePointer() const {
|
||||
return code_;
|
||||
}
|
||||
|
||||
void MIPSEmitter::ReserveCodeSpace(u32 bytes) {
|
||||
@@ -63,7 +68,7 @@ void MIPSEmitter::FlushIcache() {
|
||||
}
|
||||
|
||||
void MIPSEmitter::FlushIcacheSection(u8 *start, u8 *end) {
|
||||
#if defined(MIPS)
|
||||
#if PPSSPP_ARCH(MIPS)
|
||||
#ifdef __clang__
|
||||
__clear_cache(start, end);
|
||||
#else
|
||||
@@ -466,27 +471,14 @@ void MIPSEmitter::MOVI2R(MIPSReg reg, u32 imm) {
|
||||
}
|
||||
}
|
||||
|
||||
void MIPSCodeBlock::AllocCodeSpace(int size) {
|
||||
region_size = size;
|
||||
region = (u8 *)AllocateExecutableMemory(region_size);
|
||||
SetCodePtr(region);
|
||||
}
|
||||
|
||||
// Always clear code space with breakpoints, so that if someone accidentally executes
|
||||
// uninitialized, it just breaks into the debugger.
|
||||
void MIPSCodeBlock::ClearCodeSpace() {
|
||||
// Set BREAK instructions on all of it.
|
||||
u32 *region32 = (u32 *)region;
|
||||
for (u32 i = 0; i < region_size / 4; ++i) {
|
||||
*region32++ = 0x0000000d;
|
||||
}
|
||||
ResetCodePtr();
|
||||
}
|
||||
|
||||
void MIPSCodeBlock::FreeCodeSpace() {
|
||||
FreeMemoryPages(region, region_size);
|
||||
region = NULL;
|
||||
region_size = 0;
|
||||
void MIPSCodeBlock::PoisonMemory(int offset) {
|
||||
u32 *ptr = (u32 *)(region + offset);
|
||||
u32 *maxptr = (u32 *)(region + region_size - offset);
|
||||
// If our memory isn't a multiple of u32 then this won't write the last remaining bytes with anything
|
||||
// Less than optimal, but there would be nothing we could do but throw a runtime warning anyway.
|
||||
// AArch64: 0x0000000d = break 0
|
||||
while (ptr < maxptr)
|
||||
*ptr++ = 0x0000000d;
|
||||
}
|
||||
|
||||
}
|
||||
+8
-41
@@ -21,7 +21,8 @@
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "Common/CodeBlock.h"
|
||||
#include "Common/Common.h"
|
||||
|
||||
namespace MIPSGen {
|
||||
|
||||
@@ -72,12 +73,14 @@ public:
|
||||
MIPSEmitter() : code_(0), lastCacheFlushEnd_(0) {
|
||||
}
|
||||
MIPSEmitter(u8 *code_ptr) : code_(code_ptr), lastCacheFlushEnd_(code_ptr) {
|
||||
SetCodePtr(code_ptr);
|
||||
SetCodePointer(code_ptr, code_ptr);
|
||||
}
|
||||
virtual ~MIPSEmitter() {
|
||||
}
|
||||
|
||||
void SetCodePtr(u8 *ptr);
|
||||
void SetCodePointer(const u8 *ptr, u8 *writePtr);
|
||||
const u8* GetCodePointer() const;
|
||||
|
||||
void ReserveCodeSpace(u32 bytes);
|
||||
const u8 *AlignCode16();
|
||||
const u8 *AlignCodePage();
|
||||
@@ -270,45 +273,9 @@ private:
|
||||
// Everything that needs to generate machine code should inherit from this.
|
||||
// You get memory management for free, plus, you can use all the LUI etc functions without
|
||||
// having to prefix them with gen-> or something similar.
|
||||
class MIPSCodeBlock : public MIPSEmitter {
|
||||
class MIPSCodeBlock : public CodeBlock<MIPSEmitter> {
|
||||
public:
|
||||
MIPSCodeBlock() : region(nullptr), region_size(0) {
|
||||
}
|
||||
virtual ~MIPSCodeBlock() {
|
||||
if (region) {
|
||||
FreeCodeSpace();
|
||||
}
|
||||
}
|
||||
|
||||
// Call this before you generate any code.
|
||||
void AllocCodeSpace(int size);
|
||||
|
||||
// Always clear code space with breakpoints, so that if someone accidentally executes
|
||||
// uninitialized, it just breaks into the debugger.
|
||||
void ClearCodeSpace();
|
||||
|
||||
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
||||
void FreeCodeSpace();
|
||||
|
||||
bool IsInSpace(const u8 *ptr) const {
|
||||
return ptr >= region && ptr < region + region_size;
|
||||
}
|
||||
|
||||
void ResetCodePtr() {
|
||||
SetCodePtr(region);
|
||||
}
|
||||
|
||||
size_t GetSpaceLeft() const {
|
||||
return region_size - (GetCodePtr() - region);
|
||||
}
|
||||
|
||||
u8 *GetBasePtr() {
|
||||
return region;
|
||||
}
|
||||
|
||||
size_t GetOffset(const u8 *ptr) const {
|
||||
return ptr - region;
|
||||
}
|
||||
void PoisonMemory(int offset) override;
|
||||
|
||||
protected:
|
||||
u8 *region;
|
||||
|
||||
@@ -224,6 +224,20 @@ void DrawBuffer::DrawImage(ImageID atlas_image, float x, float y, float scale, C
|
||||
DrawImageStretch(atlas_image, x, y, x + w, y + h, color);
|
||||
}
|
||||
|
||||
void DrawBuffer::DrawImageCenterTexel(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color) {
|
||||
const AtlasImage *image = atlas->getImage(atlas_image);
|
||||
if (!image)
|
||||
return;
|
||||
float centerU = (image->u1 + image->u2) * 0.5f;
|
||||
float centerV = (image->v1 + image->v2) * 0.5f;
|
||||
V(x1, y1, color, centerU, centerV);
|
||||
V(x2, y1, color, centerU, centerV);
|
||||
V(x2, y2, color, centerU, centerV);
|
||||
V(x1, y1, color, centerU, centerV);
|
||||
V(x2, y2, color, centerU, centerV);
|
||||
V(x1, y2, color, centerU, centerV);
|
||||
}
|
||||
|
||||
void DrawBuffer::DrawImageStretch(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color) {
|
||||
const AtlasImage *image = atlas->getImage(atlas_image);
|
||||
if (!image)
|
||||
|
||||
@@ -107,6 +107,9 @@ public:
|
||||
const Atlas *GetAtlas() const { return atlas; }
|
||||
bool MeasureImage(ImageID atlas_image, float *w, float *h);
|
||||
void DrawImage(ImageID atlas_image, float x, float y, float scale, Color color = COLOR(0xFFFFFF), int align = ALIGN_TOPLEFT);
|
||||
|
||||
// Good for stretching out a white image without edge artifacts that I'm getting on iOS.
|
||||
void DrawImageCenterTexel(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color = COLOR(0xFFFFFF));
|
||||
void DrawImageStretch(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color = COLOR(0xFFFFFF));
|
||||
void DrawImageStretchVGradient(ImageID atlas_image, float x1, float y1, float x2, float y2, Color color1, Color color2);
|
||||
void DrawImageStretch(ImageID atlas_image, const Bounds &bounds, Color color = COLOR(0xFFFFFF)) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Common/System/Display.h"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Common/Data/Hash/Hash.h"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include "ppsspp_config.h"
|
||||
#include "Common/System/Display.h"
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Common/Data/Hash/Hash.h"
|
||||
|
||||
@@ -111,14 +111,22 @@ void Do(PointerWrap &p, std::string &x) {
|
||||
}
|
||||
|
||||
void Do(PointerWrap &p, std::wstring &x) {
|
||||
int stringLen = sizeof(wchar_t)*((int)x.length() + 1);
|
||||
int stringLen = sizeof(wchar_t) * ((int)x.length() + 1);
|
||||
Do(p, stringLen);
|
||||
|
||||
auto read = [&]() {
|
||||
std::wstring r;
|
||||
// In case unaligned, use memcpy.
|
||||
r.resize((stringLen / sizeof(wchar_t)) - 1);
|
||||
memcpy(&r[0], *p.ptr, stringLen - sizeof(wchar_t));
|
||||
return r;
|
||||
};
|
||||
|
||||
switch (p.mode) {
|
||||
case PointerWrap::MODE_READ: x = (wchar_t*)*p.ptr; break;
|
||||
case PointerWrap::MODE_READ: x = read(); break;
|
||||
case PointerWrap::MODE_WRITE: memcpy(*p.ptr, x.c_str(), stringLen); break;
|
||||
case PointerWrap::MODE_MEASURE: break;
|
||||
case PointerWrap::MODE_VERIFY: _dbg_assert_msg_(x == (wchar_t*)*p.ptr, "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), (wchar_t*)*p.ptr, p.ptr); break;
|
||||
case PointerWrap::MODE_VERIFY: _dbg_assert_msg_(x == read(), "Savestate verification failure: \"%ls\" != \"%ls\" (at %p).\n", x.c_str(), read().c_str(), p.ptr); break;
|
||||
}
|
||||
(*p.ptr) += stringLen;
|
||||
}
|
||||
@@ -127,11 +135,19 @@ void Do(PointerWrap &p, std::u16string &x) {
|
||||
int stringLen = sizeof(char16_t) * ((int)x.length() + 1);
|
||||
Do(p, stringLen);
|
||||
|
||||
auto read = [&]() {
|
||||
std::u16string r;
|
||||
// In case unaligned, use memcpy.
|
||||
r.resize((stringLen / sizeof(char16_t)) - 1);
|
||||
memcpy(&r[0], *p.ptr, stringLen - sizeof(char16_t));
|
||||
return r;
|
||||
};
|
||||
|
||||
switch (p.mode) {
|
||||
case PointerWrap::MODE_READ: x = (char16_t*)*p.ptr; break;
|
||||
case PointerWrap::MODE_READ: x = read(); break;
|
||||
case PointerWrap::MODE_WRITE: memcpy(*p.ptr, x.c_str(), stringLen); break;
|
||||
case PointerWrap::MODE_MEASURE: break;
|
||||
case PointerWrap::MODE_VERIFY: _dbg_assert_msg_(x == (char16_t*)*p.ptr, "Savestate verification failure: (at %p).\n", x.c_str()); break;
|
||||
case PointerWrap::MODE_VERIFY: _dbg_assert_msg_(x == read(), "Savestate verification failure: (at %p).\n", p.ptr); break;
|
||||
}
|
||||
(*p.ptr) += stringLen;
|
||||
}
|
||||
@@ -174,7 +190,7 @@ void PointerWrap::DoMarker(const char *prevName, u32 arbitraryNumber) {
|
||||
u32 cookie = arbitraryNumber;
|
||||
Do(*this, cookie);
|
||||
if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) {
|
||||
_assert_msg_(false, "Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
|
||||
ERROR_LOG(SAVESTATE, "Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
|
||||
SetError(ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,23 @@ std::string LineNumberString(const std::string &str) {
|
||||
return output.str();
|
||||
}
|
||||
|
||||
std::string IndentString(const std::string &str, const std::string &sep, bool skipFirst) {
|
||||
std::stringstream input(str);
|
||||
std::stringstream output;
|
||||
std::string line;
|
||||
|
||||
bool doIndent = !skipFirst;
|
||||
while (std::getline(input, line)) {
|
||||
if (doIndent) {
|
||||
output << sep;
|
||||
}
|
||||
doIndent = true;
|
||||
output << line << "\n";
|
||||
}
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
void SkipSpace(const char **ptr) {
|
||||
while (**ptr && isspace(**ptr)) {
|
||||
(*ptr)++;
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include <vector>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable:4996)
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#else
|
||||
@@ -32,6 +31,7 @@
|
||||
|
||||
// Useful for shaders with error messages..
|
||||
std::string LineNumberString(const std::string &str);
|
||||
std::string IndentString(const std::string &str, const std::string &sep, bool skipFirst = false);
|
||||
|
||||
// Other simple string utilities.
|
||||
|
||||
|
||||
@@ -98,6 +98,11 @@ enum SystemProperty {
|
||||
|
||||
SYSPROP_SUPPORTS_PERMISSIONS,
|
||||
SYSPROP_SUPPORTS_SUSTAINED_PERF_MODE,
|
||||
|
||||
// Android-specific.
|
||||
SYSPROP_ANDROID_SCOPED_STORAGE,
|
||||
|
||||
SYSPROP_CAN_JIT,
|
||||
};
|
||||
|
||||
std::string System_GetProperty(SystemProperty prop);
|
||||
|
||||
+10
-9
@@ -15,6 +15,7 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include "MemoryUtil.h"
|
||||
#include "ABI.h"
|
||||
#include "Thunk.h"
|
||||
@@ -23,7 +24,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
#ifndef _M_X64
|
||||
#if !PPSSPP_ARCH(AMD64)
|
||||
alignas(32) static u8 saved_fp_state[16 * 4 * 4];
|
||||
alignas(32) static u8 saved_gpr_state[16 * 8];
|
||||
static u16 saved_mxcsr;
|
||||
@@ -35,7 +36,7 @@ using namespace Gen;
|
||||
|
||||
void ThunkManager::Init()
|
||||
{
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
// Account for the return address and "home space" on Windows (which needs to be at the bottom.)
|
||||
const int stackOffset = ThunkStackOffset();
|
||||
int stackPosition;
|
||||
@@ -44,7 +45,7 @@ void ThunkManager::Init()
|
||||
AllocCodeSpace(THUNK_ARENA_SIZE);
|
||||
BeginWrite();
|
||||
save_regs = GetCodePtr();
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
for (int i = 2; i < ABI_GetNumXMMRegs(); i++)
|
||||
MOVAPS(MDisp(RSP, stackOffset + (i - 2) * 16), (X64Reg)(XMM0 + i));
|
||||
stackPosition = (ABI_GetNumXMMRegs() - 2) * 2;
|
||||
@@ -70,7 +71,7 @@ void ThunkManager::Init()
|
||||
RET();
|
||||
|
||||
load_regs = GetCodePtr();
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
for (int i = 2; i < ABI_GetNumXMMRegs(); i++)
|
||||
MOVAPS((X64Reg)(XMM0 + i), MDisp(RSP, stackOffset + (i - 2) * 16));
|
||||
stackPosition = (ABI_GetNumXMMRegs() - 2) * 2;
|
||||
@@ -112,7 +113,7 @@ void ThunkManager::Shutdown()
|
||||
int ThunkManager::ThunkBytesNeeded()
|
||||
{
|
||||
int space = (ABI_GetNumXMMRegs() - 2) * 16;
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
// MXCSR
|
||||
space += 8;
|
||||
space += 7 * 8;
|
||||
@@ -131,7 +132,7 @@ int ThunkManager::ThunkBytesNeeded()
|
||||
|
||||
int ThunkManager::ThunkStackOffset()
|
||||
{
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
#ifdef _WIN32
|
||||
return 0x28;
|
||||
#else
|
||||
@@ -154,7 +155,7 @@ const void *ThunkManager::ProtectFunction(const void *function, int num_params)
|
||||
const u8 *call_point = GetCodePtr();
|
||||
Enter(this, true);
|
||||
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
ABI_CallFunction(function);
|
||||
#else
|
||||
// Since parameters are in the previous stack frame, not in registers, this takes some
|
||||
@@ -180,7 +181,7 @@ const void *ThunkManager::ProtectFunction(const void *function, int num_params)
|
||||
|
||||
void ThunkManager::Enter(ThunkEmitter *emit, bool withinCall)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
// Make sure to align stack.
|
||||
emit->SUB(64, R(ESP), Imm32(ThunkStackOffset() + ThunkBytesNeeded() + (withinCall ? 0 : 8)));
|
||||
emit->ABI_CallFunction(save_regs);
|
||||
@@ -191,7 +192,7 @@ void ThunkManager::Enter(ThunkEmitter *emit, bool withinCall)
|
||||
|
||||
void ThunkManager::Leave(ThunkEmitter *emit, bool withinCall)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
emit->ABI_CallFunction(load_regs);
|
||||
emit->ADD(64, R(ESP), Imm32(ThunkStackOffset() + ThunkBytesNeeded() + (withinCall ? 0 : 8)));
|
||||
#else
|
||||
|
||||
+1
-1
@@ -1,6 +1,5 @@
|
||||
#include <cstdio>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
@@ -18,6 +17,7 @@
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <ctime>
|
||||
|
||||
static double curtime = 0;
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ void UIContext::FillRect(const UI::Drawable &drawable, const Bounds &bounds) {
|
||||
|
||||
switch (drawable.type) {
|
||||
case UI::DRAW_SOLID_COLOR:
|
||||
uidrawbuffer_->DrawImageStretch(theme->whiteImage, bounds.x, bounds.y, bounds.x2(), bounds.y2(), drawable.color);
|
||||
uidrawbuffer_->DrawImageCenterTexel(theme->whiteImage, bounds.x, bounds.y, bounds.x2(), bounds.y2(), drawable.color);
|
||||
break;
|
||||
case UI::DRAW_4GRID:
|
||||
uidrawbuffer_->DrawImage4Grid(drawable.image, bounds.x, bounds.y, bounds.x2(), bounds.y2(), drawable.color);
|
||||
|
||||
+2
-2
@@ -99,7 +99,7 @@ public:
|
||||
Bounds TransformBounds(const Bounds &bounds);
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_;
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
Bounds bounds_;
|
||||
|
||||
float fontScaleX_ = 1.0f;
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
UI::FontStyle *fontStyle_ = nullptr;
|
||||
TextDrawer *textDrawer_ = nullptr;
|
||||
|
||||
Draw::SamplerState *sampler_;
|
||||
Draw::SamplerState *sampler_ = nullptr;
|
||||
Draw::Pipeline *ui_pipeline_ = nullptr;
|
||||
Draw::Pipeline *ui_pipeline_notex_ = nullptr;
|
||||
std::unique_ptr<ManagedTexture> uitexture_;
|
||||
|
||||
+10
-1
@@ -1,3 +1,4 @@
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
#include <deque>
|
||||
|
||||
@@ -29,6 +30,7 @@ struct DispatchQueueItem {
|
||||
EventParams params;
|
||||
};
|
||||
|
||||
std::atomic<bool> hasDispatchQueue;
|
||||
std::deque<DispatchQueueItem> g_dispatchQueue;
|
||||
|
||||
void EventTriggered(Event *e, EventParams params) {
|
||||
@@ -37,11 +39,13 @@ void EventTriggered(Event *e, EventParams params) {
|
||||
item.params = params;
|
||||
|
||||
std::unique_lock<std::mutex> guard(eventMutex_);
|
||||
// Set before adding so we lock and check the added value.
|
||||
hasDispatchQueue = true;
|
||||
g_dispatchQueue.push_front(item);
|
||||
}
|
||||
|
||||
void DispatchEvents() {
|
||||
while (true) {
|
||||
while (hasDispatchQueue) {
|
||||
DispatchQueueItem item;
|
||||
{
|
||||
std::unique_lock<std::mutex> guard(eventMutex_);
|
||||
@@ -49,6 +53,7 @@ void DispatchEvents() {
|
||||
break;
|
||||
item = g_dispatchQueue.back();
|
||||
g_dispatchQueue.pop_back();
|
||||
hasDispatchQueue = !g_dispatchQueue.empty();
|
||||
}
|
||||
if (item.e) {
|
||||
item.e->Dispatch(item.params);
|
||||
@@ -57,6 +62,8 @@ void DispatchEvents() {
|
||||
}
|
||||
|
||||
void RemoveQueuedEventsByView(View *view) {
|
||||
if (!hasDispatchQueue)
|
||||
return;
|
||||
std::unique_lock<std::mutex> guard(eventMutex_);
|
||||
for (auto it = g_dispatchQueue.begin(); it != g_dispatchQueue.end(); ) {
|
||||
if (it->params.v == view) {
|
||||
@@ -68,6 +75,8 @@ void RemoveQueuedEventsByView(View *view) {
|
||||
}
|
||||
|
||||
void RemoveQueuedEventsByEvent(Event *event) {
|
||||
if (!hasDispatchQueue)
|
||||
return;
|
||||
std::unique_lock<std::mutex> guard(eventMutex_);
|
||||
for (auto it = g_dispatchQueue.begin(); it != g_dispatchQueue.end(); ) {
|
||||
if (it->e == event) {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
namespace UI {
|
||||
|
||||
void Tween::Apply(View *view) {
|
||||
if (!valid_)
|
||||
if (!valid_ || finishApplied_)
|
||||
return;
|
||||
|
||||
if (DurationOffset() >= duration_)
|
||||
|
||||
@@ -27,9 +27,9 @@ UIScreen::~UIScreen() {
|
||||
}
|
||||
|
||||
void UIScreen::DoRecreateViews() {
|
||||
std::lock_guard<std::recursive_mutex> guard(screenManager()->inputLock_);
|
||||
|
||||
if (recreateViews_) {
|
||||
std::lock_guard<std::recursive_mutex> guard(screenManager()->inputLock_);
|
||||
|
||||
UI::PersistMap persisted;
|
||||
bool persisting = root_ != nullptr;
|
||||
if (persisting) {
|
||||
@@ -144,7 +144,7 @@ bool UIScreen::touch(const TouchInput &touch) {
|
||||
std::vector<UI::View *> views;
|
||||
root_->Query(touch.x, touch.y, views);
|
||||
for (auto view : views) {
|
||||
INFO_LOG(SYSTEM, "%s", view->Describe().c_str());
|
||||
INFO_LOG(SYSTEM, "%s", view->DescribeLog().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ void SliderPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
char temp[64];
|
||||
sprintf(temp, "%d", sliderValue_);
|
||||
edit_ = new TextEdit(temp, "", new LinearLayoutParams(10.0f));
|
||||
edit_ = new TextEdit(temp, Title(), "", new LinearLayoutParams(10.0f));
|
||||
edit_->SetMaxLen(16);
|
||||
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
|
||||
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
|
||||
@@ -689,7 +689,7 @@ void SliderFloatPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
char temp[64];
|
||||
sprintf(temp, "%0.3f", sliderValue_);
|
||||
edit_ = new TextEdit(temp, "", new LinearLayoutParams(10.0f));
|
||||
edit_ = new TextEdit(temp, Title(), "", new LinearLayoutParams(10.0f));
|
||||
edit_->SetMaxLen(16);
|
||||
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
|
||||
edit_->SetTextAlign(FLAG_DYNAMIC_ASCII);
|
||||
@@ -818,7 +818,7 @@ void TextEditPopupScreen::CreatePopupContents(UI::ViewGroup *parent) {
|
||||
|
||||
textEditValue_ = *value_;
|
||||
LinearLayout *lin = parent->Add(new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams((UI::Size)300, WRAP_CONTENT)));
|
||||
edit_ = new TextEdit(textEditValue_, placeholder_, new LinearLayoutParams(1.0f));
|
||||
edit_ = new TextEdit(textEditValue_, Title(), placeholder_, new LinearLayoutParams(1.0f));
|
||||
edit_->SetMaxLen(maxLen_);
|
||||
edit_->SetTextColor(dc.theme->popupStyle.fgColor);
|
||||
lin->Add(edit_);
|
||||
|
||||
@@ -88,6 +88,7 @@ protected:
|
||||
virtual bool ShowButtons() const { return true; }
|
||||
virtual bool CanComplete(DialogResult result) { return true; }
|
||||
virtual void OnCompleted(DialogResult result) {}
|
||||
const std::string &Title() { return title_; }
|
||||
|
||||
virtual void update() override;
|
||||
|
||||
|
||||
+72
-11
@@ -6,6 +6,7 @@
|
||||
#include "Common/Render/DrawBuffer.h"
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/UI/UI.h"
|
||||
#include "Common/UI/View.h"
|
||||
#include "Common/UI/Context.h"
|
||||
@@ -135,7 +136,7 @@ void View::Query(float x, float y, std::vector<View *> &list) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string View::Describe() const {
|
||||
std::string View::DescribeLog() const {
|
||||
return StringFromFormat("%0.1f,%0.1f %0.1fx%0.1f", bounds_.x, bounds_.y, bounds_.w, bounds_.h);
|
||||
}
|
||||
|
||||
@@ -201,7 +202,7 @@ void Clickable::DrawBG(UIContext &dc, const Style &style) {
|
||||
if (style.background.type == DRAW_SOLID_COLOR) {
|
||||
if (time_now_d() - bgColorLast_ >= 0.25f) {
|
||||
bgColor_->Reset(style.background.color);
|
||||
} else {
|
||||
} else if (bgColor_->CurrentValue() != style.background.color) {
|
||||
bgColor_->Divert(style.background.color, down_ ? 0.05f : 0.1f);
|
||||
}
|
||||
bgColorLast_ = time_now_d();
|
||||
@@ -513,6 +514,11 @@ void Choice::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Choice::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 choice"), "%1", text_);
|
||||
}
|
||||
|
||||
InfoItem::InfoItem(const std::string &text, const std::string &rightText, LayoutParams *layoutParams)
|
||||
: Item(layoutParams), text_(text), rightText_(rightText) {
|
||||
// We set the colors later once we have a UIContext.
|
||||
@@ -540,11 +546,21 @@ void InfoItem::Draw(UIContext &dc) {
|
||||
dc.FillRect(style.background, bounds_);
|
||||
|
||||
int paddingX = 12;
|
||||
Bounds padBounds = bounds_.Expand(-paddingX, 0);
|
||||
|
||||
float leftWidth, leftHeight;
|
||||
dc.MeasureTextRect(dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.size(), padBounds, &leftWidth, &leftHeight, ALIGN_VCENTER);
|
||||
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
||||
dc.DrawText(rightText_.c_str(), bounds_.x2() - paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT);
|
||||
// dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x2(), bounds_.y + 2, dc.theme->itemDownStyle.bgColor);
|
||||
dc.DrawTextRect(text_.c_str(), padBounds, style.fgColor, ALIGN_VCENTER);
|
||||
|
||||
Bounds rightBounds(padBounds.x + leftWidth, padBounds.y, padBounds.w - leftWidth, padBounds.h);
|
||||
dc.DrawTextRect(rightText_.c_str(), rightBounds, style.fgColor, ALIGN_VCENTER | ALIGN_RIGHT | FLAG_WRAP_TEXT);
|
||||
}
|
||||
|
||||
std::string InfoItem::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(ReplaceAll(u->T("%1: %2"), "%1", text_), "%2", rightText_);
|
||||
}
|
||||
|
||||
ItemHeader::ItemHeader(const std::string &text, LayoutParams *layoutParams)
|
||||
@@ -556,7 +572,7 @@ ItemHeader::ItemHeader(const std::string &text, LayoutParams *layoutParams)
|
||||
void ItemHeader::Draw(UIContext &dc) {
|
||||
dc.SetFontStyle(dc.theme->uiFontSmall);
|
||||
dc.DrawText(text_.c_str(), bounds_.x + 4, bounds_.centerY(), dc.theme->headerStyle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->headerStyle.fgColor);
|
||||
}
|
||||
|
||||
void ItemHeader::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const {
|
||||
@@ -572,6 +588,11 @@ void ItemHeader::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec hor
|
||||
dc.MeasureTextRect(dc.theme->uiFontSmall, 1.0f, 1.0f, text_.c_str(), (int)text_.length(), bounds, &w, &h, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
}
|
||||
|
||||
std::string ItemHeader::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 heading"), "%1", text_);
|
||||
}
|
||||
|
||||
void PopupHeader::Draw(UIContext &dc) {
|
||||
const float paddingHorizontal = 12;
|
||||
const float availableWidth = bounds_.w - paddingHorizontal * 2;
|
||||
@@ -593,13 +614,18 @@ void PopupHeader::Draw(UIContext &dc) {
|
||||
}
|
||||
|
||||
dc.DrawText(text_.c_str(), bounds_.x + tx, bounds_.centerY(), dc.theme->popupTitle.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupTitle.fgColor);
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2()-2, bounds_.x2(), bounds_.y2(), dc.theme->popupTitle.fgColor);
|
||||
|
||||
if (availableWidth < tw) {
|
||||
dc.PopScissor();
|
||||
}
|
||||
}
|
||||
|
||||
std::string PopupHeader::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 heading"), "%1", text_);
|
||||
}
|
||||
|
||||
void CheckBox::Toggle() {
|
||||
if (toggle_) {
|
||||
*toggle_ = !(*toggle_);
|
||||
@@ -642,6 +668,15 @@ void CheckBox::Draw(UIContext &dc) {
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
|
||||
std::string CheckBox::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
std::string text = ReplaceAll(u->T("%1 checkbox"), "%1", text_);
|
||||
if (!smallText_.empty()) {
|
||||
text += "\n" + smallText_;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
float CheckBox::CalculateTextScale(const UIContext &dc, float availWidth) const {
|
||||
float actualWidth, actualHeight;
|
||||
Bounds availBounds(0, 0, availWidth, bounds_.h);
|
||||
@@ -705,6 +740,11 @@ void Button::GetContentDimensions(const UIContext &dc, float &w, float &h) const
|
||||
h *= scale_;
|
||||
}
|
||||
|
||||
std::string Button::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 button"), "%1", GetText());
|
||||
}
|
||||
|
||||
void Button::Click() {
|
||||
Clickable::Click();
|
||||
UI::PlayUISound(UI::UISound::CONFIRM);
|
||||
@@ -729,7 +769,7 @@ void Button::Draw(UIContext &dc) {
|
||||
}
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.SetFontScale(scale_, scale_);
|
||||
if (imageID_.isValid() && text_.empty()) {
|
||||
if (imageID_.isValid() && (ignoreText_ || text_.empty())) {
|
||||
dc.Draw()->DrawImage(imageID_, bounds_.centerX(), bounds_.centerY(), scale_, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
} else if (!text_.empty()) {
|
||||
dc.DrawText(text_.c_str(), bounds_.centerX(), bounds_.centerY(), style.fgColor, ALIGN_CENTER);
|
||||
@@ -812,8 +852,8 @@ void TextView::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
TextEdit::TextEdit(const std::string &text, const std::string &placeholderText, LayoutParams *layoutParams)
|
||||
: View(layoutParams), text_(text), undo_(text), placeholderText_(placeholderText),
|
||||
TextEdit::TextEdit(const std::string &text, const std::string &title, const std::string &placeholderText, LayoutParams *layoutParams)
|
||||
: View(layoutParams), text_(text), title_(title), undo_(text), placeholderText_(placeholderText),
|
||||
textColor_(0xFFFFFFFF), maxLen_(255) {
|
||||
caret_ = (int)text_.size();
|
||||
}
|
||||
@@ -861,6 +901,11 @@ void TextEdit::GetContentDimensions(const UIContext &dc, float &w, float &h) con
|
||||
h += 2;
|
||||
}
|
||||
|
||||
std::string TextEdit::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return ReplaceAll(u->T("%1 text field"), "%1", GetText());
|
||||
}
|
||||
|
||||
// Handles both windows and unix line endings.
|
||||
static std::string FirstLine(const std::string &text) {
|
||||
size_t pos = text.find("\r\n");
|
||||
@@ -1032,11 +1077,17 @@ void ProgressBar::GetContentDimensions(const UIContext &dc, float &w, float &h)
|
||||
void ProgressBar::Draw(UIContext &dc) {
|
||||
char temp[32];
|
||||
sprintf(temp, "%i%%", (int)(progress_ * 100.0f));
|
||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x + bounds_.w * progress_, bounds_.y2(), 0xc0c0c0c0);
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y, bounds_.x + bounds_.w * progress_, bounds_.y2(), 0xc0c0c0c0);
|
||||
dc.SetFontStyle(dc.theme->uiFont);
|
||||
dc.DrawTextRect(temp, bounds_, 0xFFFFFFFF, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
std::string ProgressBar::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
float percent = progress_ * 100.0f;
|
||||
return ReplaceAll(u->T("Progress: %1%"), "%1", StringFromInt((int)percent));
|
||||
}
|
||||
|
||||
void Spinner::GetContentDimensions(const UIContext &dc, float &w, float &h) const {
|
||||
w = 48;
|
||||
h = 48;
|
||||
@@ -1181,6 +1232,12 @@ void Slider::Draw(UIContext &dc) {
|
||||
dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER | FLAG_DYNAMIC_ASCII);
|
||||
}
|
||||
|
||||
std::string Slider::DescribeText() const {
|
||||
if (showPercent_)
|
||||
return StringFromFormat("%i%% / %i%%", *value_, maxValue_);
|
||||
return StringFromFormat("%i / %i", *value_, maxValue_);
|
||||
}
|
||||
|
||||
void Slider::Update() {
|
||||
View::Update();
|
||||
if (repeat_ >= 0) {
|
||||
@@ -1291,6 +1348,10 @@ void SliderFloat::Draw(UIContext &dc) {
|
||||
dc.DrawText(temp, bounds_.x2() - 22, bounds_.centerY(), dc.theme->popupStyle.fgColor, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
std::string SliderFloat::DescribeText() const {
|
||||
return StringFromFormat("%0.2f / %0.2f", *value_, maxValue_);
|
||||
}
|
||||
|
||||
void SliderFloat::Update() {
|
||||
View::Update();
|
||||
if (repeat_ >= 0) {
|
||||
|
||||
+28
-6
@@ -365,7 +365,9 @@ public:
|
||||
|
||||
// If this view covers these coordinates, it should add itself and its children to the list.
|
||||
virtual void Query(float x, float y, std::vector<View *> &list);
|
||||
virtual std::string Describe() const;
|
||||
virtual std::string DescribeLog() const;
|
||||
// Accessible/searchable description.
|
||||
virtual std::string DescribeText() const { return ""; }
|
||||
|
||||
virtual void FocusChanged(int focusFlags) {}
|
||||
virtual void PersistData(PersistStatus status, std::string anonId, PersistMap &storage);
|
||||
@@ -514,8 +516,6 @@ class Button : public Clickable {
|
||||
public:
|
||||
Button(const std::string &text, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), text_(text), imageID_(ImageID::invalid()) {}
|
||||
Button(ImageID imageID, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), imageID_(imageID) {}
|
||||
Button(const std::string &text, ImageID imageID, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), text_(text), imageID_(imageID) {}
|
||||
|
||||
@@ -523,6 +523,7 @@ public:
|
||||
void Draw(UIContext &dc) override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
const std::string &GetText() const { return text_; }
|
||||
std::string DescribeText() const override;
|
||||
void SetPadding(int w, int h) {
|
||||
paddingW_ = w;
|
||||
paddingH_ = h;
|
||||
@@ -530,6 +531,9 @@ public:
|
||||
void SetImageID(ImageID imageID) {
|
||||
imageID_ = imageID;
|
||||
}
|
||||
void SetIgnoreText(bool ignore) {
|
||||
ignoreText_ = ignore;
|
||||
}
|
||||
|
||||
// Needed an extra small button...
|
||||
void SetScale(float f) {
|
||||
@@ -543,6 +547,7 @@ private:
|
||||
int paddingW_ = 16;
|
||||
int paddingH_ = 8;
|
||||
float scale_ = 1.0f;
|
||||
bool ignoreText_ = false;
|
||||
};
|
||||
|
||||
class Slider : public Clickable {
|
||||
@@ -555,6 +560,7 @@ public:
|
||||
step_ = step <= 0 ? 1 : step;
|
||||
}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
bool Key(const KeyInput &input) override;
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Update() override;
|
||||
@@ -585,6 +591,7 @@ public:
|
||||
SliderFloat(float *value, float minValue, float maxValue, LayoutParams *layoutParams = 0)
|
||||
: Clickable(layoutParams), value_(value), minValue_(minValue), maxValue_(maxValue), paddingLeft_(5), paddingRight_(70), repeat_(-1) {}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
bool Key(const KeyInput &input) override;
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Update() override;
|
||||
@@ -661,6 +668,7 @@ public:
|
||||
virtual void HighlightChanged(bool highlighted);
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
virtual void SetCentered(bool c) {
|
||||
centered_ = c;
|
||||
}
|
||||
@@ -711,6 +719,7 @@ public:
|
||||
InfoItem(const std::string &text, const std::string &rightText, LayoutParams *layoutParams = nullptr);
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
// These are focusable so that long lists of them can be keyboard scrolled.
|
||||
bool CanBeFocused() const override { return true; }
|
||||
@@ -737,6 +746,7 @@ class ItemHeader : public Item {
|
||||
public:
|
||||
ItemHeader(const std::string &text, LayoutParams *layoutParams = 0);
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const override;
|
||||
|
||||
private:
|
||||
@@ -751,6 +761,8 @@ public:
|
||||
layoutParams_->height = 64;
|
||||
}
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
};
|
||||
@@ -763,6 +775,7 @@ public:
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
|
||||
EventReturn OnClicked(EventParams &e);
|
||||
@@ -803,6 +816,8 @@ public:
|
||||
w = size_; h = size_;
|
||||
}
|
||||
void Draw(UIContext &dc) override {}
|
||||
std::string DescribeText() const override { return ""; }
|
||||
|
||||
private:
|
||||
float size_;
|
||||
};
|
||||
@@ -820,6 +835,7 @@ public:
|
||||
|
||||
void SetText(const std::string &text) { text_ = text; }
|
||||
const std::string &GetText() const { return text_; }
|
||||
std::string DescribeText() const override { return GetText(); }
|
||||
void SetSmall(bool small) { small_ = small; }
|
||||
void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; }
|
||||
void SetShadow(bool shadow) { shadow_ = shadow; }
|
||||
@@ -841,7 +857,7 @@ private:
|
||||
|
||||
class TextEdit : public View {
|
||||
public:
|
||||
TextEdit(const std::string &text, const std::string &placeholderText, LayoutParams *layoutParams = 0);
|
||||
TextEdit(const std::string &text, const std::string &title, const std::string &placeholderText, LayoutParams *layoutParams = nullptr);
|
||||
void SetText(const std::string &text) { text_ = text; scrollPos_ = 0; caret_ = (int)text_.size(); }
|
||||
void SetTextColor(uint32_t color) { textColor_ = color; hasTextColor_ = true; }
|
||||
const std::string &GetText() const { return text_; }
|
||||
@@ -850,6 +866,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
bool Key(const KeyInput &key) override;
|
||||
void Touch(const TouchInput &touch) override;
|
||||
|
||||
@@ -860,6 +877,7 @@ private:
|
||||
void InsertAtCaret(const char *text);
|
||||
|
||||
std::string text_;
|
||||
std::string title_;
|
||||
std::string undo_;
|
||||
std::string placeholderText_;
|
||||
uint32_t textColor_;
|
||||
@@ -880,13 +898,15 @@ enum ImageSizeMode {
|
||||
|
||||
class ImageView : public InertView {
|
||||
public:
|
||||
ImageView(ImageID atlasImage, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), atlasImage_(atlasImage), sizeMode_(sizeMode) {}
|
||||
ImageView(ImageID atlasImage, const std::string &text, ImageSizeMode sizeMode, LayoutParams *layoutParams = 0)
|
||||
: InertView(layoutParams), text_(text), atlasImage_(atlasImage), sizeMode_(sizeMode) {}
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return text_; }
|
||||
|
||||
private:
|
||||
std::string text_;
|
||||
ImageID atlasImage_;
|
||||
ImageSizeMode sizeMode_;
|
||||
};
|
||||
@@ -898,6 +918,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override;
|
||||
|
||||
void SetProgress(float progress) {
|
||||
if (progress > 1.0f) {
|
||||
@@ -922,6 +943,7 @@ public:
|
||||
|
||||
void GetContentDimensions(const UIContext &dc, float &w, float &h) const override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string DescribeText() const override { return ""; }
|
||||
void SetColor(uint32_t color) { color_ = color; }
|
||||
|
||||
private:
|
||||
|
||||
+91
-9
@@ -1,8 +1,12 @@
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <set>
|
||||
#include <iomanip>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <sstream>
|
||||
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
#include "Common/Input/KeyCodes.h"
|
||||
#include "Common/Math/curves.h"
|
||||
#include "Common/UI/Context.h"
|
||||
@@ -154,6 +158,64 @@ void ViewGroup::Draw(UIContext &dc) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string ViewGroup::DescribeText() const {
|
||||
std::stringstream ss;
|
||||
bool needNewline = false;
|
||||
for (View *view : views_) {
|
||||
if (view->GetVisibility() != V_VISIBLE)
|
||||
continue;
|
||||
std::string s = view->DescribeText();
|
||||
if (s.empty())
|
||||
continue;
|
||||
|
||||
if (needNewline) {
|
||||
ss << "\n";
|
||||
}
|
||||
ss << s;
|
||||
needNewline = s[s.length() - 1] != '\n';
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string ViewGroup::DescribeListUnordered(const char *heading) const {
|
||||
std::stringstream ss;
|
||||
ss << heading << "\n";
|
||||
|
||||
bool needNewline = false;
|
||||
for (View *view : views_) {
|
||||
if (view->GetVisibility() != V_VISIBLE)
|
||||
continue;
|
||||
std::string s = view->DescribeText();
|
||||
if (s.empty())
|
||||
continue;
|
||||
|
||||
ss << " - " << IndentString(s, " ", true);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::string ViewGroup::DescribeListOrdered(const char *heading) const {
|
||||
std::stringstream ss;
|
||||
ss << heading << "\n";
|
||||
|
||||
// This is how much space we need for the highest number.
|
||||
int sz = (int)floorf(log10f((float)views_.size())) + 1;
|
||||
std::string indent = " " + std::string(sz, ' ');
|
||||
|
||||
bool needNewline = false;
|
||||
int n = 1;
|
||||
for (View *view : views_) {
|
||||
if (view->GetVisibility() != V_VISIBLE)
|
||||
continue;
|
||||
std::string s = view->DescribeText();
|
||||
if (s.empty())
|
||||
continue;
|
||||
|
||||
ss << std::setw(sz) << n++ << ". " << IndentString(s, indent, true);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void ViewGroup::Update() {
|
||||
View::Update();
|
||||
for (View *view : views_) {
|
||||
@@ -582,6 +644,11 @@ void LinearLayout::Layout() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string LinearLayoutList::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return DescribeListOrdered(u->T("List:"));
|
||||
}
|
||||
|
||||
void FrameLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) {
|
||||
if (views_.empty()) {
|
||||
MeasureBySpec(layoutParams_->width, 0.0f, horiz, &measuredWidth_);
|
||||
@@ -1134,6 +1201,11 @@ void GridLayout::Layout() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string GridLayoutList::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return DescribeListOrdered(u->T("List:"));
|
||||
}
|
||||
|
||||
TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *layoutParams)
|
||||
: LinearLayout(Opposite(orientation), layoutParams), stripSize_(stripSize) {
|
||||
SetSpacing(0.0f);
|
||||
@@ -1216,7 +1288,7 @@ void TabHolder::SetCurrentTab(int tab, bool skipTween) {
|
||||
|
||||
currentTab_ = tab;
|
||||
}
|
||||
tabStrip_->SetSelection(tab);
|
||||
tabStrip_->SetSelection(tab, false);
|
||||
}
|
||||
|
||||
EventReturn TabHolder::OnTabClick(EventParams &e) {
|
||||
@@ -1297,7 +1369,7 @@ EventReturn ChoiceStrip::OnChoiceClick(EventParams &e) {
|
||||
return OnChoice.Dispatch(e2);
|
||||
}
|
||||
|
||||
void ChoiceStrip::SetSelection(int sel) {
|
||||
void ChoiceStrip::SetSelection(int sel, bool triggerClick) {
|
||||
int prevSelected = selected_;
|
||||
StickyChoice *prevChoice = Choice(selected_);
|
||||
if (prevChoice)
|
||||
@@ -1312,7 +1384,7 @@ void ChoiceStrip::SetSelection(int sel) {
|
||||
e.v = views_[selected_];
|
||||
e.a = selected_;
|
||||
// Set to 0 to indicate a selection change (not a click.)
|
||||
e.b = 0;
|
||||
e.b = triggerClick ? 1 : 0;
|
||||
OnChoice.Trigger(e);
|
||||
}
|
||||
}
|
||||
@@ -1326,16 +1398,16 @@ void ChoiceStrip::HighlightChoice(unsigned int choice){
|
||||
|
||||
bool ChoiceStrip::Key(const KeyInput &input) {
|
||||
bool ret = false;
|
||||
if (input.flags & KEY_DOWN) {
|
||||
if (topTabs_ && (input.flags & KEY_DOWN)) {
|
||||
if (IsTabLeftKey(input)) {
|
||||
if (selected_ > 0) {
|
||||
SetSelection(selected_ - 1);
|
||||
SetSelection(selected_ - 1, true);
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_OFF); // Maybe make specific sounds for this at some point?
|
||||
}
|
||||
ret = true;
|
||||
} else if (IsTabRightKey(input)) {
|
||||
if (selected_ < (int)views_.size() - 1) {
|
||||
SetSelection(selected_ + 1);
|
||||
SetSelection(selected_ + 1, true);
|
||||
UI::PlayUISound(UI::UISound::TOGGLE_ON);
|
||||
}
|
||||
ret = true;
|
||||
@@ -1348,12 +1420,17 @@ void ChoiceStrip::Draw(UIContext &dc) {
|
||||
ViewGroup::Draw(dc);
|
||||
if (topTabs_) {
|
||||
if (orientation_ == ORIENT_HORIZONTAL)
|
||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x, bounds_.y2() - 4, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color );
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x, bounds_.y2() - 4, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color );
|
||||
else if (orientation_ == ORIENT_VERTICAL)
|
||||
dc.Draw()->DrawImageStretch(dc.theme->whiteImage, bounds_.x2() - 4, bounds_.y, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color );
|
||||
dc.Draw()->DrawImageCenterTexel(dc.theme->whiteImage, bounds_.x2() - 4, bounds_.y, bounds_.x2(), bounds_.y2(), dc.theme->itemDownStyle.background.color );
|
||||
}
|
||||
}
|
||||
|
||||
std::string ChoiceStrip::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return DescribeListUnordered(u->T("Choices:"));
|
||||
}
|
||||
|
||||
StickyChoice *ChoiceStrip::Choice(int index) {
|
||||
if ((size_t)index < views_.size())
|
||||
return static_cast<StickyChoice *>(views_[index]);
|
||||
@@ -1386,6 +1463,11 @@ void ListView::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert)
|
||||
}
|
||||
}
|
||||
|
||||
std::string ListView::DescribeText() const {
|
||||
auto u = GetI18NCategory("UI Elements");
|
||||
return DescribeListOrdered(u->T("List:"));
|
||||
}
|
||||
|
||||
EventReturn ListView::OnItemCallback(int num, EventParams &e) {
|
||||
EventParams ev{};
|
||||
ev.v = nullptr;
|
||||
|
||||
+33
-9
@@ -80,9 +80,13 @@ public:
|
||||
void Unlock() { modifyLock_.unlock(); }
|
||||
|
||||
void SetClip(bool clip) { clip_ = clip; }
|
||||
std::string Describe() const override { return "ViewGroup: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "ViewGroup: " + View::DescribeLog(); }
|
||||
std::string DescribeText() const override;
|
||||
|
||||
protected:
|
||||
std::string DescribeListUnordered(const char *heading) const;
|
||||
std::string DescribeListOrdered(const char *heading) const;
|
||||
|
||||
std::mutex modifyLock_; // Hold this when changing the subviews.
|
||||
std::vector<View *> views_;
|
||||
View *defaultFocusView_ = nullptr;
|
||||
@@ -132,7 +136,7 @@ public:
|
||||
void Overflow(bool allow) {
|
||||
overflow_ = allow;
|
||||
}
|
||||
std::string Describe() const override { return "AnchorLayout: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "AnchorLayout: " + View::DescribeLog(); }
|
||||
|
||||
private:
|
||||
void MeasureViews(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert);
|
||||
@@ -182,7 +186,7 @@ public:
|
||||
void SetSpacing(float spacing) {
|
||||
spacing_ = spacing;
|
||||
}
|
||||
std::string Describe() const override { return (orientation_ == ORIENT_HORIZONTAL ? "LinearLayoutHoriz: " : "LinearLayoutVert: ") + View::Describe(); }
|
||||
std::string DescribeLog() const override { return (orientation_ == ORIENT_HORIZONTAL ? "LinearLayoutHoriz: " : "LinearLayoutVert: ") + View::DescribeLog(); }
|
||||
|
||||
protected:
|
||||
Orientation orientation_;
|
||||
@@ -191,6 +195,15 @@ private:
|
||||
float spacing_;
|
||||
};
|
||||
|
||||
class LinearLayoutList : public LinearLayout {
|
||||
public:
|
||||
LinearLayoutList(Orientation orientation, LayoutParams *layoutParams = nullptr)
|
||||
: LinearLayout(orientation, layoutParams) {
|
||||
}
|
||||
|
||||
std::string DescribeText() const override;
|
||||
};
|
||||
|
||||
// GridLayout is a little different from the Android layout. This one has fixed size
|
||||
// rows and columns. Items are not allowed to deviate from the set sizes.
|
||||
// Initially, only horizontal layout is supported.
|
||||
@@ -212,13 +225,22 @@ public:
|
||||
|
||||
void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override;
|
||||
void Layout() override;
|
||||
std::string Describe() const override { return "GridLayout: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "GridLayout: " + View::DescribeLog(); }
|
||||
|
||||
private:
|
||||
GridLayoutSettings settings_;
|
||||
int numColumns_;
|
||||
};
|
||||
|
||||
class GridLayoutList : public GridLayout {
|
||||
public:
|
||||
GridLayoutList(GridLayoutSettings settings, LayoutParams *layoutParams = nullptr)
|
||||
: GridLayout(settings, layoutParams) {
|
||||
}
|
||||
|
||||
std::string DescribeText() const override;
|
||||
};
|
||||
|
||||
// A scrollview usually contains just a single child - a linear layout or similar.
|
||||
class ScrollView : public ViewGroup {
|
||||
public:
|
||||
@@ -231,7 +253,7 @@ public:
|
||||
bool Key(const KeyInput &input) override;
|
||||
void Touch(const TouchInput &input) override;
|
||||
void Draw(UIContext &dc) override;
|
||||
std::string Describe() const override { return "ScrollView: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "ScrollView: " + View::DescribeLog(); }
|
||||
|
||||
void ScrollTo(float newScrollPos);
|
||||
void ScrollToBottom();
|
||||
@@ -278,7 +300,7 @@ public:
|
||||
void AddChoice(ImageID buttonImage);
|
||||
|
||||
int GetSelection() const { return selected_; }
|
||||
void SetSelection(int sel);
|
||||
void SetSelection(int sel, bool triggerClick);
|
||||
|
||||
void HighlightChoice(unsigned int choice);
|
||||
|
||||
@@ -287,7 +309,8 @@ public:
|
||||
void SetTopTabs(bool tabs) { topTabs_ = tabs; }
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
std::string Describe() const override { return "ChoiceStrip: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "ChoiceStrip: " + View::DescribeLog(); }
|
||||
std::string DescribeText() const override;
|
||||
|
||||
Event OnChoice;
|
||||
|
||||
@@ -313,7 +336,7 @@ public:
|
||||
void SetCurrentTab(int tab, bool skipTween = false);
|
||||
|
||||
int GetCurrentTab() const { return currentTab_; }
|
||||
std::string Describe() const override { return "TabHolder: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "TabHolder: " + View::DescribeLog(); }
|
||||
|
||||
void PersistData(PersistStatus status, std::string anonId, PersistMap &storage) override;
|
||||
|
||||
@@ -383,7 +406,8 @@ public:
|
||||
virtual void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override;
|
||||
virtual void SetMaxHeight(float mh) { maxHeight_ = mh; }
|
||||
Event OnChoice;
|
||||
std::string Describe() const override { return "ListView: " + View::Describe(); }
|
||||
std::string DescribeLog() const override { return "ListView: " + View::DescribeLog(); }
|
||||
std::string DescribeText() const override;
|
||||
|
||||
private:
|
||||
void CreateAllItems();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "x64Emitter.h"
|
||||
@@ -160,7 +161,7 @@ void XEmitter::WriteSIB(int scale, int index, int base)
|
||||
void OpArg::WriteRex(XEmitter *emit, int opBits, int bits, int customOp) const
|
||||
{
|
||||
if (customOp == -1) customOp = operandReg;
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
u8 op = 0x40;
|
||||
// REX.W (whether operation is a 64-bit operation)
|
||||
if (opBits == 64) op |= 8;
|
||||
@@ -232,7 +233,7 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg,
|
||||
_offsetOrBaseReg = 5;
|
||||
emit->WriteModRM(0, _operandReg, _offsetOrBaseReg);
|
||||
//TODO : add some checks
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
u64 ripAddr = (u64)emit->GetCodePointer() + 4 + extraBytes;
|
||||
s64 distance = (s64)offset - (s64)ripAddr;
|
||||
_assert_msg_(
|
||||
@@ -501,7 +502,8 @@ void XEmitter::SetJumpTarget(const FixupBranch &branch)
|
||||
{
|
||||
s64 distance = (s64)(code - branch.ptr);
|
||||
_assert_msg_(distance >= -0x80000000LL && distance < 0x80000000LL, "Jump target too far away, needs indirect register");
|
||||
((s32*)branch.ptr)[-1] = (s32)distance;
|
||||
const s32 distance32 = static_cast<s32>(distance);
|
||||
std::memcpy(branch.ptr - sizeof(s32), &distance32, sizeof(s32));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1450,7 +1452,7 @@ void XEmitter::MOVD_xmm(const OpArg &arg, X64Reg src) {WriteSSEOp(0x66, 0x7E, sr
|
||||
|
||||
void XEmitter::MOVQ_xmm(X64Reg dest, OpArg arg)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
// Alternate encoding
|
||||
// This does not display correctly in MSVC's debugger, it thinks it's a MOVD
|
||||
arg.operandReg = dest;
|
||||
|
||||
+6
-5
@@ -20,6 +20,7 @@
|
||||
#include "ppsspp_config.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/Log.h"
|
||||
@@ -361,9 +362,9 @@ private:
|
||||
|
||||
protected:
|
||||
inline void Write8(u8 value) {*code++ = value;}
|
||||
inline void Write16(u16 value) {*(u16*)code = (value); code += 2;}
|
||||
inline void Write32(u32 value) {*(u32*)code = (value); code += 4;}
|
||||
inline void Write64(u64 value) {*(u64*)code = (value); code += 8;}
|
||||
inline void Write16(u16 value) {std::memcpy(code, &value, sizeof(u16)); code += 2;}
|
||||
inline void Write32(u32 value) {std::memcpy(code, &value, sizeof(u32)); code += 4;}
|
||||
inline void Write64(u64 value) {std::memcpy(code, &value, sizeof(u64)); code += 8;}
|
||||
|
||||
public:
|
||||
XEmitter() { code = nullptr; flags_locked = false; }
|
||||
@@ -1056,7 +1057,7 @@ public:
|
||||
void ABI_EmitPrologue(int maxCallParams);
|
||||
void ABI_EmitEpilogue(int maxCallParams);
|
||||
|
||||
#ifdef _M_IX86
|
||||
#if PPSSPP_ARCH(X86)
|
||||
inline int ABI_GetNumXMMRegs() { return 8; }
|
||||
#else
|
||||
inline int ABI_GetNumXMMRegs() { return 16; }
|
||||
@@ -1074,7 +1075,7 @@ public:
|
||||
bool RipAccessible(const void *ptr) const {
|
||||
// For debugging
|
||||
// return false;
|
||||
#ifdef _M_IX86
|
||||
#if PPSSPP_ARCH(X86)
|
||||
return true;
|
||||
#else
|
||||
ptrdiff_t diff = GetCodePtr() - (const uint8_t *)ptr;
|
||||
|
||||
+96
-60
@@ -44,11 +44,12 @@ extern "C" {
|
||||
#define av_frame_free avcodec_free_frame
|
||||
#endif
|
||||
|
||||
static AVFormatContext* s_format_context = nullptr;
|
||||
static AVStream* s_stream = nullptr;
|
||||
static AVFrame* s_src_frame = nullptr;
|
||||
static AVFrame* s_scaled_frame = nullptr;
|
||||
static SwsContext* s_sws_context = nullptr;
|
||||
static AVFormatContext *s_format_context = nullptr;
|
||||
static AVCodecContext *s_codec_context = nullptr;
|
||||
static AVStream *s_stream = nullptr;
|
||||
static AVFrame *s_src_frame = nullptr;
|
||||
static AVFrame *s_scaled_frame = nullptr;
|
||||
static SwsContext *s_sws_context = nullptr;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -65,7 +66,9 @@ static void InitAVCodec() {
|
||||
static bool first_run = true;
|
||||
if (first_run) {
|
||||
#ifdef USE_FFMPEG
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 12, 100)
|
||||
av_register_all();
|
||||
#endif
|
||||
#endif
|
||||
first_run = false;
|
||||
}
|
||||
@@ -87,51 +90,70 @@ bool AVIDump::Start(int w, int h)
|
||||
|
||||
bool AVIDump::CreateAVI() {
|
||||
#ifdef USE_FFMPEG
|
||||
AVCodec* codec = nullptr;
|
||||
AVCodec *codec = nullptr;
|
||||
|
||||
// Use gameID_EmulatedTimestamp for filename
|
||||
std::string discID = g_paramSFO.GetDiscID();
|
||||
std::string video_file_name = StringFromFormat("%s%s_%s.avi", GetSysDirectory(DIRECTORY_VIDEO).c_str(), discID.c_str(), KernelTimeNowFormatted().c_str()).c_str();
|
||||
|
||||
s_format_context = avformat_alloc_context();
|
||||
std::stringstream s_file_index_str;
|
||||
s_file_index_str << video_file_name;
|
||||
|
||||
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s", s_file_index_str.str().c_str());
|
||||
INFO_LOG(COMMON, "Recording Video to: %s", s_format_context->filename);
|
||||
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(58, 7, 0)
|
||||
char *filename = av_strdup(video_file_name.c_str());
|
||||
// Freed when the context is freed.
|
||||
s_format_context->url = filename;
|
||||
#else
|
||||
const char *filename = s_format_context->filename;
|
||||
snprintf(s_format_context->filename, sizeof(s_format_context->filename), "%s", video_file_name.c_str());
|
||||
#endif
|
||||
INFO_LOG(COMMON, "Recording Video to: %s", filename);
|
||||
|
||||
// Make sure that the path exists
|
||||
if (!File::Exists(GetSysDirectory(DIRECTORY_VIDEO)))
|
||||
File::CreateDir(GetSysDirectory(DIRECTORY_VIDEO));
|
||||
|
||||
if (File::Exists(s_format_context->filename))
|
||||
File::Delete(s_format_context->filename);
|
||||
if (File::Exists(filename))
|
||||
File::Delete(filename);
|
||||
|
||||
if (!(s_format_context->oformat = av_guess_format("avi", nullptr, nullptr)) || !(s_stream = avformat_new_stream(s_format_context, codec)))
|
||||
{
|
||||
s_format_context->oformat = av_guess_format("avi", nullptr, nullptr);
|
||||
if (!s_format_context->oformat)
|
||||
return false;
|
||||
s_stream = avformat_new_stream(s_format_context, codec);
|
||||
if (!s_stream)
|
||||
return false;
|
||||
}
|
||||
|
||||
s_stream->codec->codec_id = g_Config.bUseFFV1 ? AV_CODEC_ID_FFV1 : s_format_context->oformat->video_codec;
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 48, 101)
|
||||
s_codec_context = s_stream->codec;
|
||||
#else
|
||||
s_codec_context = avcodec_alloc_context3(codec);
|
||||
#endif
|
||||
s_codec_context->codec_id = g_Config.bUseFFV1 ? AV_CODEC_ID_FFV1 : s_format_context->oformat->video_codec;
|
||||
if (!g_Config.bUseFFV1)
|
||||
s_stream->codec->codec_tag = MKTAG('X', 'V', 'I', 'D'); // Force XVID FourCC for better compatibility
|
||||
s_stream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
s_stream->codec->bit_rate = 400000;
|
||||
s_stream->codec->width = s_width;
|
||||
s_stream->codec->height = s_height;
|
||||
s_stream->codec->time_base.num = 1001;
|
||||
s_stream->codec->time_base.den = 60000;
|
||||
s_stream->codec->gop_size = 12;
|
||||
s_stream->codec->pix_fmt = g_Config.bUseFFV1 ? AV_PIX_FMT_BGRA : AV_PIX_FMT_YUV420P;
|
||||
s_codec_context->codec_tag = MKTAG('X', 'V', 'I', 'D'); // Force XVID FourCC for better compatibility
|
||||
s_codec_context->codec_type = AVMEDIA_TYPE_VIDEO;
|
||||
s_codec_context->bit_rate = 400000;
|
||||
s_codec_context->width = s_width;
|
||||
s_codec_context->height = s_height;
|
||||
s_codec_context->time_base.num = 1001;
|
||||
s_codec_context->time_base.den = 60000;
|
||||
s_codec_context->gop_size = 12;
|
||||
s_codec_context->pix_fmt = g_Config.bUseFFV1 ? AV_PIX_FMT_BGRA : AV_PIX_FMT_YUV420P;
|
||||
|
||||
if (!(codec = avcodec_find_encoder(s_stream->codec->codec_id)) || (avcodec_open2(s_stream->codec, codec, nullptr) < 0))
|
||||
{
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
|
||||
if (avcodec_parameters_from_context(s_stream->codecpar, s_codec_context) < 0)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
codec = avcodec_find_encoder(s_codec_context->codec_id);
|
||||
if (!codec)
|
||||
return false;
|
||||
if (avcodec_open2(s_codec_context, codec, nullptr) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
s_src_frame = av_frame_alloc();
|
||||
s_scaled_frame = av_frame_alloc();
|
||||
|
||||
s_scaled_frame->format = s_stream->codec->pix_fmt;
|
||||
s_scaled_frame->format = s_codec_context->pix_fmt;
|
||||
s_scaled_frame->width = s_width;
|
||||
s_scaled_frame->height = s_height;
|
||||
|
||||
@@ -139,14 +161,13 @@ bool AVIDump::CreateAVI() {
|
||||
if (av_frame_get_buffer(s_scaled_frame, 1))
|
||||
return false;
|
||||
#else
|
||||
if (avcodec_default_get_buffer(s_stream->codec, s_scaled_frame))
|
||||
if (avcodec_default_get_buffer(s_codec_context, s_scaled_frame))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
NOTICE_LOG(G3D, "Opening file %s for dumping", s_format_context->filename);
|
||||
if (avio_open(&s_format_context->pb, s_format_context->filename, AVIO_FLAG_WRITE) < 0 || avformat_write_header(s_format_context, nullptr))
|
||||
{
|
||||
WARN_LOG(G3D, "Could not open %s", s_format_context->filename);
|
||||
NOTICE_LOG(G3D, "Opening file %s for dumping", filename);
|
||||
if (avio_open(&s_format_context->pb, filename, AVIO_FLAG_WRITE) < 0 || avformat_write_header(s_format_context, nullptr)) {
|
||||
WARN_LOG(G3D, "Could not open %s", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,8 +187,7 @@ static void PreparePacket(AVPacket* pkt) {
|
||||
|
||||
#endif
|
||||
|
||||
void AVIDump::AddFrame()
|
||||
{
|
||||
void AVIDump::AddFrame() {
|
||||
u32 w = 0;
|
||||
u32 h = 0;
|
||||
if (g_Config.bDumpVideoOutput) {
|
||||
@@ -192,44 +212,60 @@ void AVIDump::AddFrame()
|
||||
s_src_frame->height = s_height;
|
||||
|
||||
// Convert image from BGR24 to desired pixel format, and scale to initial width and height
|
||||
if ((s_sws_context = sws_getCachedContext(s_sws_context, w, h, AV_PIX_FMT_RGB24, s_width, s_height, s_stream->codec->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr)))
|
||||
{
|
||||
if ((s_sws_context = sws_getCachedContext(s_sws_context, w, h, AV_PIX_FMT_RGB24, s_width, s_height, s_codec_context->pix_fmt, SWS_BICUBIC, nullptr, nullptr, nullptr))) {
|
||||
sws_scale(s_sws_context, s_src_frame->data, s_src_frame->linesize, 0, h, s_scaled_frame->data, s_scaled_frame->linesize);
|
||||
}
|
||||
|
||||
s_scaled_frame->format = s_stream->codec->pix_fmt;
|
||||
s_scaled_frame->format = s_codec_context->pix_fmt;
|
||||
s_scaled_frame->width = s_width;
|
||||
s_scaled_frame->height = s_height;
|
||||
|
||||
// Encode and write the image.
|
||||
AVPacket pkt;
|
||||
PreparePacket(&pkt);
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
|
||||
int error = avcodec_send_frame(s_codec_context, s_scaled_frame);
|
||||
int got_packet = 0;
|
||||
if (avcodec_receive_packet(s_codec_context, &pkt) >= 0) {
|
||||
got_packet = 1;
|
||||
}
|
||||
#else
|
||||
int got_packet;
|
||||
int error = avcodec_encode_video2(s_stream->codec, &pkt, s_scaled_frame, &got_packet);
|
||||
while (!error && got_packet)
|
||||
{
|
||||
int error = avcodec_encode_video2(s_codec_context, &pkt, s_scaled_frame, &got_packet);
|
||||
#endif
|
||||
while (error >= 0 && got_packet) {
|
||||
// Write the compressed frame in the media file.
|
||||
if (pkt.pts != (s64)AV_NOPTS_VALUE)
|
||||
{
|
||||
pkt.pts = av_rescale_q(pkt.pts, s_stream->codec->time_base, s_stream->time_base);
|
||||
if (pkt.pts != (s64)AV_NOPTS_VALUE) {
|
||||
pkt.pts = av_rescale_q(pkt.pts, s_codec_context->time_base, s_stream->time_base);
|
||||
}
|
||||
if (pkt.dts != (s64)AV_NOPTS_VALUE)
|
||||
{
|
||||
pkt.dts = av_rescale_q(pkt.dts, s_stream->codec->time_base, s_stream->time_base);
|
||||
if (pkt.dts != (s64)AV_NOPTS_VALUE) {
|
||||
pkt.dts = av_rescale_q(pkt.dts, s_codec_context->time_base, s_stream->time_base);
|
||||
}
|
||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(56, 60, 100)
|
||||
if (s_stream->codec->coded_frame->key_frame)
|
||||
if (s_codec_context->coded_frame->key_frame)
|
||||
pkt.flags |= AV_PKT_FLAG_KEY;
|
||||
#endif
|
||||
pkt.stream_index = s_stream->index;
|
||||
av_interleaved_write_frame(s_format_context, &pkt);
|
||||
|
||||
// Handle delayed frames.
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
|
||||
av_packet_unref(&pkt);
|
||||
error = avcodec_receive_packet(s_codec_context, &pkt);
|
||||
got_packet = error >= 0 ? 1 : 0;
|
||||
#else
|
||||
PreparePacket(&pkt);
|
||||
error = avcodec_encode_video2(s_stream->codec, &pkt, nullptr, &got_packet);
|
||||
error = avcodec_encode_video2(s_codec_context, &pkt, nullptr, &got_packet);
|
||||
#endif
|
||||
}
|
||||
if (error)
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
|
||||
av_packet_unref(&pkt);
|
||||
if (error < 0 && error != AVERROR(EAGAIN) && error != AVERROR_EOF)
|
||||
ERROR_LOG(G3D, "Error while encoding video: %d", error);
|
||||
#else
|
||||
if (error < 0)
|
||||
ERROR_LOG(G3D, "Error while encoding video: %d", error);
|
||||
#endif
|
||||
#endif
|
||||
delete[] flipbuffer;
|
||||
}
|
||||
@@ -246,18 +282,18 @@ void AVIDump::Stop() {
|
||||
|
||||
void AVIDump::CloseFile() {
|
||||
#ifdef USE_FFMPEG
|
||||
|
||||
if (s_stream)
|
||||
{
|
||||
if (s_stream->codec)
|
||||
{
|
||||
if (s_codec_context) {
|
||||
#if LIBAVCODEC_VERSION_MAJOR < 55
|
||||
avcodec_default_release_buffer(s_stream->codec, s_src_frame);
|
||||
avcodec_default_release_buffer(s_codec_context, s_src_frame);
|
||||
#endif
|
||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101)
|
||||
avcodec_free_context(&s_codec_context);
|
||||
#else
|
||||
avcodec_close(s_codec_context);
|
||||
s_codec_context = nullptr;
|
||||
#endif
|
||||
avcodec_close(s_stream->codec);
|
||||
}
|
||||
av_freep(&s_stream);
|
||||
}
|
||||
av_freep(&s_stream);
|
||||
|
||||
av_frame_free(&s_src_frame);
|
||||
av_frame_free(&s_scaled_frame);
|
||||
|
||||
@@ -91,6 +91,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
|
||||
CheckSetting(iniFile, gameID, "ShaderColorBitmask", &flags_.ShaderColorBitmask);
|
||||
CheckSetting(iniFile, gameID, "DisableFirstFrameReadback", &flags_.DisableFirstFrameReadback);
|
||||
CheckSetting(iniFile, gameID, "DisableRangeCulling", &flags_.DisableRangeCulling);
|
||||
CheckSetting(iniFile, gameID, "MpegAvcWarmUp", &flags_.MpegAvcWarmUp);
|
||||
}
|
||||
|
||||
void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) {
|
||||
|
||||
@@ -89,6 +89,7 @@ struct CompatFlags {
|
||||
bool ShaderColorBitmask;
|
||||
bool DisableFirstFrameReadback;
|
||||
bool DisableRangeCulling;
|
||||
bool MpegAvcWarmUp;
|
||||
};
|
||||
|
||||
class IniFile;
|
||||
|
||||
+9
-9
@@ -513,7 +513,7 @@ static ConfigSetting generalSettings[] = {
|
||||
ConfigSetting("FullscreenOnDoubleclick", &g_Config.bFullscreenOnDoubleclick, true, false, false),
|
||||
|
||||
ReportedConfigSetting("MemStickInserted", &g_Config.bMemStickInserted, true, true, true),
|
||||
ConfigSetting("LoadPlugins", &g_Config.bLoadPlugins, false, true, true),
|
||||
ConfigSetting("EnablePlugins", &g_Config.bLoadPlugins, true, true, true),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
@@ -524,12 +524,11 @@ static bool DefaultSasThread() {
|
||||
|
||||
static ConfigSetting cpuSettings[] = {
|
||||
ReportedConfigSetting("CPUCore", &g_Config.iCpuCore, &DefaultCpuCore, true, true),
|
||||
ConfigSetting("VulkanMultithreading", &g_Config.bVulkanMultithreading, false, true, true),
|
||||
ReportedConfigSetting("SeparateSASThread", &g_Config.bSeparateSASThread, &DefaultSasThread, true, true),
|
||||
ReportedConfigSetting("SeparateIOThread", &g_Config.bSeparateIOThread, true, true, true),
|
||||
ReportedConfigSetting("IOTimingMethod", &g_Config.iIOTimingMethod, IOTIMING_REALISTIC, true, true),
|
||||
ConfigSetting("FastMemoryAccess", &g_Config.bFastMemory, true, true, true),
|
||||
ReportedConfigSetting("FuncReplacements", &g_Config.bFuncReplacements, true, true, true),
|
||||
ReportedConfigSetting("FunctionReplacements", &g_Config.bFuncReplacements, true, true, true),
|
||||
ConfigSetting("HideSlowWarnings", &g_Config.bHideSlowWarnings, true, true, false),
|
||||
ConfigSetting("HideStateWarnings", &g_Config.bHideStateWarnings, false, true, false),
|
||||
ConfigSetting("PreloadFunctions", &g_Config.bPreloadFunctions, false, true, true),
|
||||
@@ -553,7 +552,7 @@ static int DefaultInternalResolution() {
|
||||
|
||||
static int DefaultUnthrottleMode() {
|
||||
#if PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS)
|
||||
return (int)UnthrottleMode::SKIP_DRAW;
|
||||
return (int)UnthrottleMode::SKIP_FLIP;
|
||||
#else
|
||||
return (int)UnthrottleMode::CONTINUOUS;
|
||||
#endif
|
||||
@@ -773,7 +772,7 @@ static ConfigSetting graphicsSettings[] = {
|
||||
ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false, true, true),
|
||||
ConfigSetting("FrameRate", &g_Config.iFpsLimit1, 0, true, true),
|
||||
ConfigSetting("FrameRate2", &g_Config.iFpsLimit2, -1, true, true),
|
||||
ConfigSetting("UnthrottleMode", &g_Config.iUnthrottleMode, &DefaultUnthrottleMode, &UnthrottleModeToString, &UnthrottleModeFromString, true, true),
|
||||
ConfigSetting("UnthrottlingMode", &g_Config.iUnthrottleMode, &DefaultUnthrottleMode, &UnthrottleModeToString, &UnthrottleModeFromString, true, true),
|
||||
#if defined(USING_WIN_UI)
|
||||
ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, false),
|
||||
#endif
|
||||
@@ -830,8 +829,6 @@ static ConfigSetting graphicsSettings[] = {
|
||||
ConfigSetting("InflightFrames", &g_Config.iInflightFrames, 3, true, false),
|
||||
ConfigSetting("RenderDuplicateFrames", &g_Config.bRenderDuplicateFrames, false, true, true),
|
||||
|
||||
ConfigSetting("ClearFramebuffersOnFirstUseHack", &g_Config.bClearFramebuffersOnFirstUseHack, false, true, true),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
||||
@@ -975,6 +972,8 @@ static ConfigSetting controlSettings[] = {
|
||||
ConfigSetting("MouseSensitivity", &g_Config.fMouseSensitivity, 0.1f, true, true),
|
||||
ConfigSetting("MouseSmoothing", &g_Config.fMouseSmoothing, 0.9f, true, true),
|
||||
|
||||
ConfigSetting("SystemControls", &g_Config.bSystemControls, true, true, false),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
||||
@@ -984,7 +983,7 @@ static ConfigSetting networkSettings[] = {
|
||||
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "localhost", true, true),
|
||||
ConfigSetting("PortOffset", &g_Config.iPortOffset, 0, true, true),
|
||||
ConfigSetting("MinTimeout", &g_Config.iMinTimeout, 0, true, true),
|
||||
ConfigSetting("TCPNoDelay", &g_Config.bTCPNoDelay, false, true, true),
|
||||
ConfigSetting("TCPNoDelay", &g_Config.bTCPNoDelay, true, true, true),
|
||||
ConfigSetting("ForcedFirstConnect", &g_Config.bForcedFirstConnect, false, true, true),
|
||||
ConfigSetting("EnableUPnP", &g_Config.bEnableUPnP, false, true, true),
|
||||
ConfigSetting("UPnPUseOriginalPort", &g_Config.bUPnPUseOriginalPort, false, true, true),
|
||||
@@ -1004,7 +1003,7 @@ static ConfigSetting networkSettings[] = {
|
||||
|
||||
static int DefaultPSPModel() {
|
||||
// TODO: Can probably default this on, but not sure about its memory differences.
|
||||
#if !defined(_M_X64) && !defined(_WIN32)
|
||||
#if !PPSSPP_ARCH(AMD64) && !defined(_WIN32)
|
||||
return PSP_MODEL_FAT;
|
||||
#else
|
||||
return PSP_MODEL_SLIM;
|
||||
@@ -1523,6 +1522,7 @@ void Config::AddRecent(const std::string &file) {
|
||||
|
||||
// We'll add it back below. This makes sure it's at the front, and only once.
|
||||
RemoveRecent(file);
|
||||
|
||||
const std::string filename = File::ResolvePath(file);
|
||||
recentIsos.insert(recentIsos.begin(), filename);
|
||||
if ((int)recentIsos.size() > iMaxRecent)
|
||||
|
||||
+3
-1
@@ -174,7 +174,6 @@ public:
|
||||
int iFrameSkipType;
|
||||
int iUnthrottleMode; // See UnthrottleMode in ConfigValues.h.
|
||||
bool bAutoFrameSkip;
|
||||
bool bClearFramebuffersOnFirstUseHack;
|
||||
|
||||
bool bEnableCardboardVR; // Cardboard Master Switch
|
||||
int iCardboardScreenSize; // Screen Size (in %)
|
||||
@@ -410,6 +409,8 @@ public:
|
||||
float fMouseSensitivity;
|
||||
float fMouseSmoothing;
|
||||
|
||||
bool bSystemControls;
|
||||
|
||||
// Use the hardware scaler to scale up the image to save fillrate. Similar to Windows' window size, really.
|
||||
int iAndroidHwScale; // 0 = device resolution. 1 = 480x272 (extended to correct aspect), 2 = 960x544 etc.
|
||||
|
||||
@@ -487,6 +488,7 @@ public:
|
||||
bool bShowFrameProfiler;
|
||||
bool bSimpleFrameStats;
|
||||
|
||||
// Various directories. Autoconfigured, not read from ini.
|
||||
std::string currentDirectory;
|
||||
std::string externalDirectory;
|
||||
std::string memStickDirectory;
|
||||
|
||||
+9
-11
@@ -460,17 +460,15 @@ void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) {
|
||||
const char *desc = ExecExceptionTypeAsString(type);
|
||||
WARN_LOG(MEMMAP, "%s: Invalid destination %08x PC %08x LR %08x", desc, address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
|
||||
|
||||
if (!g_Config.bIgnoreBadMemAccess) {
|
||||
ExceptionInfo &e = g_exceptionInfo;
|
||||
e = {};
|
||||
e.type = ExceptionType::BAD_EXEC_ADDR;
|
||||
e.info = "";
|
||||
e.exec_type = type;
|
||||
e.address = address;
|
||||
e.pc = pc;
|
||||
Core_EnableStepping(true);
|
||||
host->SetDebugMode(true);
|
||||
}
|
||||
ExceptionInfo &e = g_exceptionInfo;
|
||||
e = {};
|
||||
e.type = ExceptionType::BAD_EXEC_ADDR;
|
||||
e.info = "";
|
||||
e.exec_type = type;
|
||||
e.address = address;
|
||||
e.pc = pc;
|
||||
Core_EnableStepping(true);
|
||||
host->SetDebugMode(true);
|
||||
}
|
||||
|
||||
void Core_Break() {
|
||||
|
||||
+12
-8
@@ -139,7 +139,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86\include;../common;..;../ext/glew;../ext/snappy;../ext/libpng17;../ext/zlib;../ext</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_M_IX86=1;_DEBUG;_LIB;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
@@ -162,7 +162,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\x86_64\include;../common;..;../ext/glew;../ext/snappy;../ext/libpng17;../ext/zlib;../ext</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_M_X64=1;_DEBUG;_LIB;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
@@ -186,7 +186,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\aarch64\include;../common;..;../ext/glew;../ext/snappy;../ext/libpng17;../ext/zlib;../ext</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
@@ -210,7 +210,7 @@
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<AdditionalIncludeDirectories>..\ffmpeg\WindowsInclude;..\ffmpeg\Windows\arm\include;../common;..;../ext/glew;../ext/snappy;../ext/libpng17;../ext/zlib;../ext</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRTDBG_MAP_ALLOC;USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_DEBUG;_LIB;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<OmitFramePointers>false</OmitFramePointers>
|
||||
@@ -241,7 +241,7 @@
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_M_IX86=1;_LIB;NDEBUG;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_M_IX86=1;_LIB;NDEBUG;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
@@ -276,7 +276,7 @@
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_M_X64=1;_LIB;NDEBUG;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_M_X64=1;_LIB;NDEBUG;_UNICODE;UNICODE;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StringPooling>true</StringPooling>
|
||||
@@ -307,7 +307,7 @@
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_64=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StringPooling>true</StringPooling>
|
||||
@@ -338,7 +338,7 @@
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>false</WholeProgramOptimization>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>USING_WIN_UI;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;USE_FFMPEG;WIN32;_ARCH_32=1;_LIB;NDEBUG;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<StringPooling>true</StringPooling>
|
||||
@@ -429,6 +429,7 @@
|
||||
<ClCompile Include="..\ext\udis86\syn.c" />
|
||||
<ClCompile Include="..\ext\udis86\udis86.c" />
|
||||
<ClCompile Include="AVIDump.cpp" />
|
||||
<ClCompile Include="Debugger\MemBlockInfo.cpp" />
|
||||
<ClCompile Include="Debugger\WebSocket.cpp" />
|
||||
<ClCompile Include="Debugger\WebSocket\BreakpointSubscriber.cpp" />
|
||||
<ClCompile Include="Debugger\WebSocket\CPUCoreSubscriber.cpp" />
|
||||
@@ -457,6 +458,7 @@
|
||||
<ClCompile Include="Instance.cpp" />
|
||||
<ClCompile Include="KeyMap.cpp" />
|
||||
<ClCompile Include="MemFault.cpp" />
|
||||
<ClCompile Include="MIPS\fake\FakeJit.cpp" />
|
||||
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
|
||||
<ClCompile Include="MIPS\IR\IRCompALU.cpp" />
|
||||
<ClCompile Include="MIPS\IR\IRCompBranch.cpp" />
|
||||
@@ -976,6 +978,7 @@
|
||||
<ClInclude Include="..\ext\udis86\udis86.h" />
|
||||
<ClInclude Include="AVIDump.h" />
|
||||
<ClInclude Include="ConfigValues.h" />
|
||||
<ClInclude Include="Debugger\MemBlockInfo.h" />
|
||||
<ClInclude Include="Debugger\WebSocket.h" />
|
||||
<ClInclude Include="Debugger\WebSocket\BreakpointSubscriber.h" />
|
||||
<ClInclude Include="Debugger\WebSocket\GameSubscriber.h" />
|
||||
@@ -1004,6 +1007,7 @@
|
||||
<ClInclude Include="Instance.h" />
|
||||
<ClInclude Include="KeyMap.h" />
|
||||
<ClInclude Include="MemFault.h" />
|
||||
<ClInclude Include="MIPS\fake\FakeJit.h" />
|
||||
<ClInclude Include="MIPS\IR\IRFrontend.h" />
|
||||
<ClInclude Include="MIPS\IR\IRInst.h" />
|
||||
<ClInclude Include="MIPS\IR\IRInterpreter.h" />
|
||||
|
||||
@@ -88,6 +88,9 @@
|
||||
<Filter Include="Ext\libzip">
|
||||
<UniqueIdentifier>{0201ff27-4fa8-4cf3-bbb9-accfdc0c7046}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="MIPS\fake">
|
||||
<UniqueIdentifier>{678fa299-0ff7-4983-982d-2da47b52e238}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ELF\ElfReader.cpp">
|
||||
@@ -971,6 +974,12 @@
|
||||
<ClCompile Include="Debugger\WebSocket\InputBroadcaster.cpp">
|
||||
<Filter>Debugger\WebSocket</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MIPS\fake\FakeJit.cpp">
|
||||
<Filter>MIPS\fake</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Debugger\MemBlockInfo.cpp">
|
||||
<Filter>Debugger</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ELF\ElfReader.h">
|
||||
@@ -1661,6 +1670,12 @@
|
||||
<ClInclude Include="Debugger\WebSocket\InputBroadcaster.h">
|
||||
<Filter>Debugger\WebSocket</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MIPS\fake\FakeJit.h">
|
||||
<Filter>MIPS\fake</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Debugger\MemBlockInfo.h">
|
||||
<Filter>Debugger</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
||||
+72
-40
@@ -16,9 +16,10 @@
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/Profiler/Profiler.h"
|
||||
|
||||
@@ -47,7 +48,11 @@ struct EventType {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
std::vector<EventType> event_types;
|
||||
static std::vector<EventType> event_types;
|
||||
// Only used during restore.
|
||||
static std::set<int> usedEventTypes;
|
||||
static std::set<int> restoredEventTypes;
|
||||
static int nextEventTypeRestoreId = -1;
|
||||
|
||||
struct BaseEvent {
|
||||
s64 time;
|
||||
@@ -160,31 +165,53 @@ void FreeTsEvent(Event* ev)
|
||||
allocatedTsEvents--;
|
||||
}
|
||||
|
||||
int RegisterEvent(const char *name, TimedCallback callback)
|
||||
{
|
||||
int RegisterEvent(const char *name, TimedCallback callback) {
|
||||
for (const auto &ty : event_types) {
|
||||
if (!strcmp(ty.name, name)) {
|
||||
_assert_msg_(false, "Event type %s already registered", name);
|
||||
// Try to make sure it doesn't work so we notice for sure.
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int id = (int)event_types.size();
|
||||
event_types.push_back(EventType{ callback, name });
|
||||
return (int)event_types.size() - 1;
|
||||
usedEventTypes.insert(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
void AntiCrashCallback(u64 userdata, int cyclesLate)
|
||||
{
|
||||
void AntiCrashCallback(u64 userdata, int cyclesLate) {
|
||||
ERROR_LOG(SAVESTATE, "Savestate broken: an unregistered event was called.");
|
||||
Core_EnableStepping(true);
|
||||
}
|
||||
|
||||
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback)
|
||||
{
|
||||
_assert_msg_(event_type >= 0, "Invalid event type %d", event_type)
|
||||
if (event_type >= (int) event_types.size())
|
||||
event_types.resize(event_type + 1, EventType{ AntiCrashCallback, "INVALID EVENT" });
|
||||
|
||||
void RestoreRegisterEvent(int &event_type, const char *name, TimedCallback callback) {
|
||||
// Some old states have a duplicate restore, do our best to fix...
|
||||
if (restoredEventTypes.count(event_type) != 0)
|
||||
event_type = -1;
|
||||
if (event_type == -1)
|
||||
event_type = nextEventTypeRestoreId++;
|
||||
if (event_type >= event_types.size()) {
|
||||
// Give it any unused event id starting from the end.
|
||||
// Older save states with messed up ids have gaps near the end.
|
||||
for (int i = (int)event_types.size() - 1; i >= 0; --i) {
|
||||
if (usedEventTypes.count(i) == 0) {
|
||||
event_type = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_assert_msg_(event_type >= 0 && event_type < event_types.size(), "Invalid event type %d", event_type);
|
||||
event_types[event_type] = EventType{ callback, name };
|
||||
usedEventTypes.insert(event_type);
|
||||
restoredEventTypes.insert(event_type);
|
||||
}
|
||||
|
||||
void UnregisterAllEvents()
|
||||
{
|
||||
void UnregisterAllEvents() {
|
||||
_dbg_assert_msg_(first == nullptr, "Unregistering events with events pending - this isn't good.");
|
||||
event_types.clear();
|
||||
usedEventTypes.clear();
|
||||
restoredEventTypes.clear();
|
||||
}
|
||||
|
||||
void Init()
|
||||
@@ -566,8 +593,7 @@ void ForceCheck()
|
||||
#endif
|
||||
}
|
||||
|
||||
void Advance()
|
||||
{
|
||||
void Advance() {
|
||||
PROFILE_THIS_SCOPE("advance");
|
||||
int cyclesExecuted = slicelength - currentMIPS->downcount;
|
||||
globalTimer += cyclesExecuted;
|
||||
@@ -577,17 +603,14 @@ void Advance()
|
||||
MoveEvents();
|
||||
ProcessFifoWaitEvents();
|
||||
|
||||
if (!first)
|
||||
{
|
||||
if (!first) {
|
||||
// This should never happen in PPSSPP.
|
||||
// WARN_LOG_REPORT(TIME, "WARNING - no events in queue. Setting currentMIPS->downcount to 10000");
|
||||
if (slicelength < 10000) {
|
||||
slicelength += 10000;
|
||||
currentMIPS->downcount += slicelength;
|
||||
currentMIPS->downcount += 10000;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Note that events can eat cycles as well.
|
||||
int target = (int)(first->time - globalTimer);
|
||||
if (target > MAX_SLICE_LENGTH)
|
||||
@@ -599,36 +622,31 @@ void Advance()
|
||||
}
|
||||
}
|
||||
|
||||
void LogPendingEvents()
|
||||
{
|
||||
void LogPendingEvents() {
|
||||
Event *ptr = first;
|
||||
while (ptr)
|
||||
{
|
||||
while (ptr) {
|
||||
//INFO_LOG(CPU, "PENDING: Now: %lld Pending: %lld Type: %d", globalTimer, ptr->time, ptr->type);
|
||||
ptr = ptr->next;
|
||||
}
|
||||
}
|
||||
|
||||
void Idle(int maxIdle)
|
||||
{
|
||||
void Idle(int maxIdle) {
|
||||
int cyclesDown = currentMIPS->downcount;
|
||||
if (maxIdle != 0 && cyclesDown > maxIdle)
|
||||
cyclesDown = maxIdle;
|
||||
|
||||
if (first && cyclesDown > 0)
|
||||
{
|
||||
if (first && cyclesDown > 0) {
|
||||
int cyclesExecuted = slicelength - currentMIPS->downcount;
|
||||
int cyclesNextEvent = (int) (first->time - globalTimer);
|
||||
|
||||
if (cyclesNextEvent < cyclesExecuted + cyclesDown)
|
||||
{
|
||||
cyclesDown = cyclesNextEvent - cyclesExecuted;
|
||||
// Now, now... no time machines, please.
|
||||
if (cyclesDown < 0)
|
||||
cyclesDown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Now, now... no time machines, please.
|
||||
if (cyclesDown < 0)
|
||||
cyclesDown = 0;
|
||||
|
||||
// VERBOSE_LOG(CPU, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(CPU_HZ * 0.001f));
|
||||
|
||||
idledCycles += cyclesDown;
|
||||
@@ -665,25 +683,39 @@ void Event_DoState(PointerWrap &p, BaseEvent *ev)
|
||||
Do(p, ev->time);
|
||||
Do(p, ev->userdata);
|
||||
Do(p, ev->type);
|
||||
usedEventTypes.insert(ev->type);
|
||||
}
|
||||
|
||||
void Event_DoStateOld(PointerWrap &p, BaseEvent *ev)
|
||||
{
|
||||
Do(p, *ev);
|
||||
usedEventTypes.insert(ev->type);
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p)
|
||||
{
|
||||
void DoState(PointerWrap &p) {
|
||||
std::lock_guard<std::mutex> lk(externalEventLock);
|
||||
|
||||
auto s = p.Section("CoreTiming", 1, 3);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
int n = (int) event_types.size();
|
||||
int n = (int)event_types.size();
|
||||
int current = n;
|
||||
Do(p, n);
|
||||
if (n > current) {
|
||||
WARN_LOG(SAVESTATE, "Savestate failure: more events than current (can't ever remove an event)");
|
||||
p.SetError(p.ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
// These (should) be filled in later by the modules.
|
||||
event_types.resize(n, EventType{ AntiCrashCallback, "INVALID EVENT" });
|
||||
for (int i = 0; i < current; ++i) {
|
||||
event_types[i].callback = AntiCrashCallback;
|
||||
event_types[i].name = "INVALID EVENT";
|
||||
}
|
||||
nextEventTypeRestoreId = n - 1;
|
||||
usedEventTypes.clear();
|
||||
restoredEventTypes.clear();
|
||||
|
||||
if (s >= 3) {
|
||||
DoLinkedList<BaseEvent, GetNewEvent, FreeEvent, Event_DoState>(p, first, (Event **) NULL);
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ namespace CoreTiming
|
||||
// Returns the event_type identifier.
|
||||
int RegisterEvent(const char *name, TimedCallback callback);
|
||||
// For save states.
|
||||
void RestoreRegisterEvent(int event_type, const char *name, TimedCallback callback);
|
||||
void RestoreRegisterEvent(int &event_type, const char *name, TimedCallback callback);
|
||||
void UnregisterAllEvents();
|
||||
|
||||
// userdata MAY NOT CONTAIN POINTERS. userdata might get written and reloaded from disk,
|
||||
|
||||
+14
-14
@@ -11,6 +11,7 @@
|
||||
#include "Core/CwCheat.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/Host.h"
|
||||
#include "Core/MemMapHelpers.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
#include "Core/ELF/ParamSFO.h"
|
||||
#include "Core/System.h"
|
||||
@@ -248,16 +249,9 @@ static void __CheatStop() {
|
||||
static void __CheatStart() {
|
||||
__CheatStop();
|
||||
|
||||
std::string realGameID = g_paramSFO.GetValueString("DISC_ID");
|
||||
std::string gameID = realGameID;
|
||||
const std::string gamePath = PSP_CoreParameter().fileToStart;
|
||||
const bool badGameSFO = realGameID.empty() || !g_paramSFO.GetValueInt("DISC_TOTAL");
|
||||
if (badGameSFO && gamePath.find("/PSP/GAME/") != std::string::npos) {
|
||||
gameID = g_paramSFO.GenerateFakeID(gamePath);
|
||||
}
|
||||
|
||||
cheatEngine = new CWCheatEngine(gameID);
|
||||
cheatEngine = new CWCheatEngine(g_paramSFO.GetDiscID());
|
||||
// This only generates ini files on boot, let's leave homebrew ini file for UI.
|
||||
std::string realGameID = g_paramSFO.GetValueString("DISC_ID");
|
||||
if (!realGameID.empty()) {
|
||||
cheatEngine->CreateCheatFile();
|
||||
}
|
||||
@@ -301,6 +295,8 @@ void __CheatShutdown() {
|
||||
void __CheatDoState(PointerWrap &p) {
|
||||
auto s = p.Section("CwCheat", 0, 2);
|
||||
if (!s) {
|
||||
CheatEvent = -1;
|
||||
CoreTiming::RestoreRegisterEvent(CheatEvent, "CheatEvent", &hleCheat);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -785,9 +781,13 @@ CheatOperation CWCheatEngine::InterpretNextOp(const CheatCode &cheat, size_t &i)
|
||||
return InterpretNextCwCheat(cheat, i);
|
||||
else if (cheat.fmt == CheatCodeFormat::TEMPAR)
|
||||
return InterpretNextTempAR(cheat, i);
|
||||
else
|
||||
_assert_(false);
|
||||
return { CheatOp::Invalid };
|
||||
else {
|
||||
// This shouldn't happen, but apparently does: #14082
|
||||
// Either I'm missing a path or we have memory corruption.
|
||||
// Not sure whether to log here though, feels like we could end up with a
|
||||
// ton of logspam...
|
||||
return { CheatOp::Invalid };
|
||||
}
|
||||
}
|
||||
|
||||
void CWCheatEngine::ApplyMemoryOperator(const CheatOperation &op, uint32_t(*oper)(uint32_t, uint32_t)) {
|
||||
@@ -918,7 +918,7 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
|
||||
InvalidateICache(op.addr, op.val);
|
||||
InvalidateICache(op.copyBytesFrom.destAddr, op.val);
|
||||
|
||||
Memory::MemcpyUnchecked(op.copyBytesFrom.destAddr, op.addr, op.val);
|
||||
Memory::Memcpy(op.copyBytesFrom.destAddr, op.addr, op.val, "CwCheat");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1100,7 +1100,7 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat,
|
||||
if (Memory::IsValidRange(dstAddr, val) && Memory::IsValidRange(srcAddr, val)) {
|
||||
InvalidateICache(dstAddr, val);
|
||||
InvalidateICache(srcAddr, val);
|
||||
Memory::MemcpyUnchecked(dstAddr, srcAddr, val);
|
||||
Memory::Memcpy(dstAddr, srcAddr, val, "CwCheat");
|
||||
}
|
||||
// Don't perform any further action.
|
||||
type = -1;
|
||||
|
||||
@@ -40,14 +40,15 @@ static std::mutex memCheckMutex_;
|
||||
std::vector<MemCheck> CBreakPoints::memChecks_;
|
||||
std::vector<MemCheck *> CBreakPoints::cleanupMemChecks_;
|
||||
|
||||
void MemCheck::Log(u32 addr, bool write, int size, u32 pc) {
|
||||
void MemCheck::Log(u32 addr, bool write, int size, u32 pc, const char *reason) {
|
||||
if (result & BREAK_ACTION_LOG) {
|
||||
const char *type = write ? "Write" : "Read";
|
||||
if (logFormat.empty()) {
|
||||
NOTICE_LOG(MEMMAP, "CHK %s%i at %08x (%s), PC=%08x (%s)", write ? "Write" : "Read", size * 8, addr, g_symbolMap->GetDescription(addr).c_str(), pc, g_symbolMap->GetDescription(pc).c_str());
|
||||
NOTICE_LOG(MEMMAP, "CHK %s%i(%s) at %08x (%s), PC=%08x (%s)", type, size * 8, reason, addr, g_symbolMap->GetDescription(addr).c_str(), pc, g_symbolMap->GetDescription(pc).c_str());
|
||||
} else {
|
||||
std::string formatted;
|
||||
CBreakPoints::EvaluateLogFormat(currentDebugMIPS, logFormat, formatted);
|
||||
NOTICE_LOG(MEMMAP, "CHK %s%i at %08x: %s", write ? "Write" : "Read", size * 8, addr, formatted.c_str());
|
||||
NOTICE_LOG(MEMMAP, "CHK %s%i(%s) at %08x: %s", type, size * 8, reason, addr, formatted.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,10 +63,10 @@ BreakAction MemCheck::Apply(u32 addr, bool write, int size, u32 pc) {
|
||||
return BREAK_ACTION_IGNORE;
|
||||
}
|
||||
|
||||
BreakAction MemCheck::Action(u32 addr, bool write, int size, u32 pc) {
|
||||
BreakAction MemCheck::Action(u32 addr, bool write, int size, u32 pc, const char *reason) {
|
||||
int mask = write ? MEMCHECK_WRITE : MEMCHECK_READ;
|
||||
if (cond & mask) {
|
||||
Log(addr, write, size, pc);
|
||||
Log(addr, write, size, pc, reason);
|
||||
if ((result & BREAK_ACTION_PAUSE) && coreState != CORE_POWERUP) {
|
||||
Core_EnableStepping(true);
|
||||
host->SetDebugMode(true);
|
||||
@@ -94,7 +95,7 @@ void MemCheck::JitBeforeAction(u32 addr, bool write, int size, u32 pc) {
|
||||
// We have to break to find out if it changed.
|
||||
Core_EnableStepping(true);
|
||||
} else {
|
||||
Action(addr, write, size, pc);
|
||||
Action(addr, write, size, pc, "CPU");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ void MemCheck::JitCleanup(bool changed)
|
||||
return;
|
||||
|
||||
if (changed)
|
||||
Log(lastAddr, true, lastSize, lastPC);
|
||||
Log(lastAddr, true, lastSize, lastPC, "CPU");
|
||||
|
||||
// Resume if it should not have gone to stepping, or if it did not change.
|
||||
if ((!(result & BREAK_ACTION_PAUSE) || !changed) && coreState == CORE_STEPPING)
|
||||
@@ -504,7 +505,7 @@ MemCheck *CBreakPoints::GetMemCheckLocked(u32 address, int size) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BreakAction CBreakPoints::ExecMemCheck(u32 address, bool write, int size, u32 pc)
|
||||
BreakAction CBreakPoints::ExecMemCheck(u32 address, bool write, int size, u32 pc, const char *reason)
|
||||
{
|
||||
if (!anyMemChecks_)
|
||||
return BREAK_ACTION_IGNORE;
|
||||
@@ -514,7 +515,7 @@ BreakAction CBreakPoints::ExecMemCheck(u32 address, bool write, int size, u32 pc
|
||||
check->Apply(address, write, size, pc);
|
||||
auto copy = *check;
|
||||
guard.unlock();
|
||||
return copy.Action(address, write, size, pc);
|
||||
return copy.Action(address, write, size, pc, reason);
|
||||
}
|
||||
return BREAK_ACTION_IGNORE;
|
||||
}
|
||||
@@ -547,7 +548,7 @@ BreakAction CBreakPoints::ExecOpMemCheck(u32 address, u32 pc)
|
||||
check->Apply(address, write, size, pc);
|
||||
auto copy = *check;
|
||||
guard.unlock();
|
||||
return copy.Action(address, write, size, pc);
|
||||
return copy.Action(address, write, size, pc, "CPU");
|
||||
}
|
||||
}
|
||||
return BREAK_ACTION_IGNORE;
|
||||
|
||||
@@ -96,13 +96,13 @@ struct MemCheck {
|
||||
// Called on the stored memcheck (affects numHits, etc.)
|
||||
BreakAction Apply(u32 addr, bool write, int size, u32 pc);
|
||||
// Called on a copy.
|
||||
BreakAction Action(u32 addr, bool write, int size, u32 pc);
|
||||
BreakAction Action(u32 addr, bool write, int size, u32 pc, const char *reason);
|
||||
void JitBeforeApply(u32 addr, bool write, int size, u32 pc);
|
||||
void JitBeforeAction(u32 addr, bool write, int size, u32 pc);
|
||||
bool JitApplyChanged();
|
||||
void JitCleanup(bool changed);
|
||||
|
||||
void Log(u32 addr, bool write, int size, u32 pc);
|
||||
void Log(u32 addr, bool write, int size, u32 pc, const char *reason);
|
||||
|
||||
bool IsEnabled() const {
|
||||
return (result & BREAK_ACTION_PAUSE) != 0;
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
static bool GetMemCheck(u32 start, u32 end, MemCheck *check);
|
||||
static bool GetMemCheckInRange(u32 address, int size, MemCheck *check);
|
||||
static BreakAction ExecMemCheck(u32 address, bool write, int size, u32 pc);
|
||||
static BreakAction ExecMemCheck(u32 address, bool write, int size, u32 pc, const char *reason);
|
||||
static BreakAction ExecOpMemCheck(u32 address, u32 pc);
|
||||
|
||||
// Executes memchecks but used by the jit. Cleanup finalizes after jit is done.
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
@@ -43,7 +44,7 @@ bool isInInterval(u32 start, u32 size, u32 value)
|
||||
|
||||
static HashType computeHash(u32 address, u32 size)
|
||||
{
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
return XXH3_64bits(Memory::GetPointer(address), size);
|
||||
#else
|
||||
return XXH3_64bits(Memory::GetPointer(address), size) & 0xFFFFFFFF;
|
||||
@@ -302,7 +303,6 @@ u32 DisassemblyManager::getNthPreviousAddress(u32 address, int n)
|
||||
{
|
||||
DisassemblyEntry* entry = it->second;
|
||||
int oldLineNum = entry->getLineNum(address,true);
|
||||
int oldNumLines = entry->getNumLines();
|
||||
if (n <= oldLineNum)
|
||||
{
|
||||
return entry->getLineAddress(oldLineNum-n);
|
||||
@@ -420,7 +420,6 @@ int DisassemblyFunction::getLineNum(u32 address, bool findStart)
|
||||
int last = (int)lineAddresses.size() - 1;
|
||||
for (int i = 0; i < last; i++)
|
||||
{
|
||||
u32 next = lineAddresses[i + 1];
|
||||
if (lineAddresses[i] == address)
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <mutex>
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Core/Debugger/SymbolMap.h"
|
||||
#include "Core/MIPS/MIPSAnalyst.h"
|
||||
|
||||
#ifdef _M_X64
|
||||
#if PPSSPP_ARCH(AMD64)
|
||||
typedef u64 HashType;
|
||||
#else
|
||||
typedef u32 HashType;
|
||||
|
||||
@@ -0,0 +1,438 @@
|
||||
// Copyright (c) 2021- 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 <mutex>
|
||||
#include "Common/Log.h"
|
||||
#include "Common/Serialize/Serializer.h"
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/Debugger/Breakpoints.h"
|
||||
#include "Core/Debugger/MemBlockInfo.h"
|
||||
#include "Core/MIPS/MIPS.h"
|
||||
|
||||
class MemSlabMap {
|
||||
public:
|
||||
MemSlabMap();
|
||||
~MemSlabMap();
|
||||
|
||||
bool Mark(uint32_t addr, uint32_t size, uint64_t ticks, uint32_t pc, bool allocated, const std::string &tag);
|
||||
bool Find(MemBlockFlags flags, uint32_t addr, uint32_t size, std::vector<MemBlockInfo> &results);
|
||||
void Reset();
|
||||
void DoState(PointerWrap &p);
|
||||
|
||||
private:
|
||||
struct Slab {
|
||||
uint32_t start = 0;
|
||||
uint32_t end = 0;
|
||||
uint64_t ticks = 0;
|
||||
uint32_t pc = 0;
|
||||
bool allocated = false;
|
||||
std::string tag;
|
||||
Slab *prev = nullptr;
|
||||
Slab *next = nullptr;
|
||||
|
||||
void DoState(PointerWrap &p);
|
||||
};
|
||||
|
||||
static constexpr uint32_t MAX_SIZE = 0x40000000;
|
||||
static constexpr uint32_t SLICES = 16384;
|
||||
static constexpr uint32_t SLICE_SIZE = MAX_SIZE / SLICES;
|
||||
|
||||
Slab *FindSlab(uint32_t addr);
|
||||
void Clear();
|
||||
// Returns the new slab after size.
|
||||
Slab *Split(Slab *slab, uint32_t size);
|
||||
void MergeAdjacent(Slab *slab);
|
||||
bool Same(const Slab *a, const Slab *b) const;
|
||||
void Merge(Slab *a, Slab *b);
|
||||
void FillHeads(Slab *slab);
|
||||
|
||||
Slab *first_ = nullptr;
|
||||
Slab *lastFind_ = nullptr;
|
||||
std::vector<Slab *> heads_;
|
||||
};
|
||||
|
||||
struct PendingNotifyMem {
|
||||
MemBlockFlags flags;
|
||||
uint32_t start;
|
||||
uint32_t size;
|
||||
uint64_t ticks;
|
||||
uint32_t pc;
|
||||
std::string tag;
|
||||
};
|
||||
|
||||
static constexpr size_t MAX_PENDING_NOTIFIES = 512;
|
||||
static MemSlabMap allocMap;
|
||||
static MemSlabMap suballocMap;
|
||||
static MemSlabMap writeMap;
|
||||
static MemSlabMap textureMap;
|
||||
static std::vector<PendingNotifyMem> pendingNotifies;
|
||||
static std::mutex pendingMutex;
|
||||
|
||||
MemSlabMap::MemSlabMap() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
MemSlabMap::~MemSlabMap() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool MemSlabMap::Mark(uint32_t addr, uint32_t size, uint64_t ticks, uint32_t pc, bool allocated, const std::string &tag) {
|
||||
uint32_t end = addr + size;
|
||||
Slab *slab = FindSlab(addr);
|
||||
Slab *firstMatch = nullptr;
|
||||
while (slab != nullptr && slab->start < end) {
|
||||
if (slab->start < addr)
|
||||
slab = Split(slab, addr - slab->start);
|
||||
// Don't replace slab, the return is the after part.
|
||||
if (slab->end > end) {
|
||||
Split(slab, end - slab->start);
|
||||
}
|
||||
|
||||
slab->allocated = allocated;
|
||||
if (pc != 0) {
|
||||
slab->ticks = ticks;
|
||||
slab->pc = pc;
|
||||
}
|
||||
if (!tag.empty())
|
||||
slab->tag = tag;
|
||||
|
||||
// Move on to the next one.
|
||||
if (firstMatch == nullptr)
|
||||
firstMatch = slab;
|
||||
slab = slab->next;
|
||||
}
|
||||
|
||||
if (firstMatch != nullptr) {
|
||||
// This will merge all those blocks to one.
|
||||
MergeAdjacent(firstMatch);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MemSlabMap::Find(MemBlockFlags flags, uint32_t addr, uint32_t size, std::vector<MemBlockInfo> &results) {
|
||||
uint32_t end = addr + size;
|
||||
Slab *slab = FindSlab(addr);
|
||||
bool found = false;
|
||||
while (slab != nullptr && slab->start < end) {
|
||||
if (slab->pc != 0 || !slab->tag.empty()) {
|
||||
results.push_back({ flags, slab->start, slab->end - slab->start, slab->ticks, slab->pc, slab->tag, slab->allocated });
|
||||
found = true;
|
||||
}
|
||||
slab = slab->next;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
void MemSlabMap::Reset() {
|
||||
Clear();
|
||||
|
||||
first_ = new Slab();
|
||||
first_->end = MAX_SIZE;
|
||||
lastFind_ = first_;
|
||||
|
||||
heads_.resize(SLICES, first_);
|
||||
}
|
||||
|
||||
void MemSlabMap::DoState(PointerWrap &p) {
|
||||
auto s = p.Section("MemSlabMap", 1);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
int count = 0;
|
||||
if (p.mode == p.MODE_READ) {
|
||||
Clear();
|
||||
Do(p, count);
|
||||
|
||||
first_ = new Slab();
|
||||
first_->DoState(p);
|
||||
lastFind_ = first_;
|
||||
--count;
|
||||
|
||||
heads_.resize(SLICES, nullptr);
|
||||
FillHeads(first_);
|
||||
|
||||
Slab *slab = first_;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
slab->next = new Slab();
|
||||
slab->next->DoState(p);
|
||||
|
||||
slab->next->prev = slab;
|
||||
slab = slab->next;
|
||||
|
||||
FillHeads(slab);
|
||||
}
|
||||
} else {
|
||||
for (Slab *slab = first_; slab != nullptr; slab = slab->next)
|
||||
++count;
|
||||
Do(p, count);
|
||||
|
||||
first_->DoState(p);
|
||||
--count;
|
||||
|
||||
Slab *slab = first_;
|
||||
for (int i = 0; i < count; ++i) {
|
||||
slab->next->DoState(p);
|
||||
slab = slab->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MemSlabMap::Slab::DoState(PointerWrap &p) {
|
||||
auto s = p.Section("MemSlabMapSlab", 1);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
Do(p, start);
|
||||
Do(p, end);
|
||||
Do(p, ticks);
|
||||
Do(p, pc);
|
||||
Do(p, allocated);
|
||||
Do(p, tag);
|
||||
}
|
||||
|
||||
void MemSlabMap::Clear() {
|
||||
Slab *s = first_;
|
||||
while (s != nullptr) {
|
||||
Slab *next = s->next;
|
||||
delete s;
|
||||
s = next;
|
||||
}
|
||||
first_ = nullptr;
|
||||
lastFind_ = nullptr;
|
||||
heads_.clear();
|
||||
}
|
||||
|
||||
MemSlabMap::Slab *MemSlabMap::FindSlab(uint32_t addr) {
|
||||
// Jump ahead using our index.
|
||||
Slab *slab = heads_[addr / SLICE_SIZE];
|
||||
// We often move forward, so check the last find.
|
||||
if (lastFind_->start > slab->start && lastFind_->start <= addr)
|
||||
slab = lastFind_;
|
||||
|
||||
while (slab != nullptr && slab->start <= addr) {
|
||||
if (slab->end > addr) {
|
||||
lastFind_ = slab;
|
||||
return slab;
|
||||
}
|
||||
slab = slab->next;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemSlabMap::Slab *MemSlabMap::Split(Slab *slab, uint32_t size) {
|
||||
Slab *next = new Slab();
|
||||
next->start = slab->start + size;
|
||||
next->end = slab->end;
|
||||
next->ticks = slab->ticks;
|
||||
next->pc = slab->pc;
|
||||
next->allocated = slab->allocated;
|
||||
next->tag = slab->tag;
|
||||
next->prev = slab;
|
||||
next->next = slab->next;
|
||||
|
||||
slab->next = next;
|
||||
if (next->next)
|
||||
next->next->prev = next;
|
||||
|
||||
// If the split is big, we might have to update our index.
|
||||
FillHeads(next);
|
||||
|
||||
slab->end = slab->start + size;
|
||||
return next;
|
||||
}
|
||||
|
||||
void MemSlabMap::MergeAdjacent(Slab *slab) {
|
||||
while (slab->next != nullptr && Same(slab, slab->next)) {
|
||||
Merge(slab, slab->next);
|
||||
}
|
||||
while (slab->prev != nullptr && Same(slab, slab->prev)) {
|
||||
Merge(slab, slab->prev);
|
||||
}
|
||||
}
|
||||
|
||||
bool MemSlabMap::Same(const Slab *a, const Slab *b) const {
|
||||
if (a->allocated != b->allocated)
|
||||
return false;
|
||||
if (a->pc != b->pc)
|
||||
return false;
|
||||
if (a->tag != b->tag)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemSlabMap::Merge(Slab *a, Slab *b) {
|
||||
if (a->next == b) {
|
||||
_assert_(a->end == b->start);
|
||||
a->end = b->end;
|
||||
a->next = b->next;
|
||||
|
||||
if (a->next)
|
||||
a->next->prev = a;
|
||||
} else if (a->prev == b) {
|
||||
_assert_(b->end == a->start);
|
||||
a->start = b->start;
|
||||
a->prev = b->prev;
|
||||
|
||||
if (a->prev)
|
||||
a->prev->next = a;
|
||||
else if (first_ == b)
|
||||
first_ = a;
|
||||
} else {
|
||||
_assert_(false);
|
||||
}
|
||||
// Take over index entries b had.
|
||||
FillHeads(a);
|
||||
if (b->ticks > a->ticks) {
|
||||
a->ticks = b->ticks;
|
||||
// In case we ignore PC for same.
|
||||
a->pc = b->pc;
|
||||
}
|
||||
if (lastFind_ == b)
|
||||
lastFind_ = a;
|
||||
delete b;
|
||||
}
|
||||
|
||||
void MemSlabMap::FillHeads(Slab *slab) {
|
||||
uint32_t slice = slab->start / SLICE_SIZE;
|
||||
uint32_t endSlice = (slab->end - 1) / SLICE_SIZE;
|
||||
|
||||
// For the first slice, only replace if it's the one we're removing.
|
||||
if (slab->start == slice * SLICE_SIZE) {
|
||||
heads_[slice] = slab;
|
||||
}
|
||||
|
||||
// Now replace all the rest - we definitely cover the start of them.
|
||||
for (uint32_t i = slice + 1; i <= endSlice; ++i) {
|
||||
heads_[i] = slab;
|
||||
}
|
||||
}
|
||||
|
||||
void FlushPendingMemInfo() {
|
||||
std::lock_guard<std::mutex> guard(pendingMutex);
|
||||
for (auto info : pendingNotifies) {
|
||||
if (info.flags & MemBlockFlags::ALLOC) {
|
||||
allocMap.Mark(info.start, info.size, info.ticks, info.pc, true, info.tag);
|
||||
} else if (info.flags & MemBlockFlags::FREE) {
|
||||
// Maintain the previous allocation tag for debugging.
|
||||
allocMap.Mark(info.start, info.size, info.ticks, 0, false, "");
|
||||
suballocMap.Mark(info.start, info.size, info.ticks, 0, false, "");
|
||||
}
|
||||
if (info.flags & MemBlockFlags::SUB_ALLOC) {
|
||||
suballocMap.Mark(info.start, info.size, info.ticks, info.pc, true, info.tag);
|
||||
} else if (info.flags & MemBlockFlags::SUB_FREE) {
|
||||
// Maintain the previous allocation tag for debugging.
|
||||
suballocMap.Mark(info.start, info.size, info.ticks, 0, false, "");
|
||||
}
|
||||
if (info.flags & MemBlockFlags::TEXTURE) {
|
||||
textureMap.Mark(info.start, info.size, info.ticks, info.pc, true, info.tag);
|
||||
}
|
||||
if (info.flags & MemBlockFlags::WRITE) {
|
||||
writeMap.Mark(info.start, info.size, info.ticks, info.pc, true, info.tag);
|
||||
}
|
||||
}
|
||||
pendingNotifies.clear();
|
||||
}
|
||||
|
||||
void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const std::string &tag) {
|
||||
NotifyMemInfoPC(flags, start, size, currentMIPS->pc, tag);
|
||||
}
|
||||
|
||||
void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const std::string &tag) {
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
// Clear the uncached and kernel bits.
|
||||
start &= ~0xC0000000;
|
||||
|
||||
PendingNotifyMem info{ flags, start, size };
|
||||
info.ticks = CoreTiming::GetTicks();
|
||||
info.pc = pc;
|
||||
info.tag = tag;
|
||||
|
||||
bool needFlush = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(pendingMutex);
|
||||
pendingNotifies.push_back(info);
|
||||
needFlush = pendingNotifies.size() > MAX_PENDING_NOTIFIES;
|
||||
}
|
||||
|
||||
if (needFlush) {
|
||||
FlushPendingMemInfo();
|
||||
}
|
||||
|
||||
if (flags & MemBlockFlags::WRITE) {
|
||||
CBreakPoints::ExecMemCheck(start, true, size, pc, tag.c_str());
|
||||
} else if (flags & MemBlockFlags::READ) {
|
||||
CBreakPoints::ExecMemCheck(start, false, size, pc, tag.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<MemBlockInfo> FindMemInfo(uint32_t start, uint32_t size) {
|
||||
FlushPendingMemInfo();
|
||||
start &= ~0xC0000000;
|
||||
|
||||
std::vector<MemBlockInfo> results;
|
||||
allocMap.Find(MemBlockFlags::ALLOC, start, size, results);
|
||||
suballocMap.Find(MemBlockFlags::SUB_ALLOC, start, size, results);
|
||||
writeMap.Find(MemBlockFlags::WRITE, start, size, results);
|
||||
textureMap.Find(MemBlockFlags::TEXTURE, start, size, results);
|
||||
return results;
|
||||
}
|
||||
|
||||
std::vector<MemBlockInfo> FindMemInfoByFlag(MemBlockFlags flags, uint32_t start, uint32_t size) {
|
||||
FlushPendingMemInfo();
|
||||
start &= ~0xC0000000;
|
||||
|
||||
std::vector<MemBlockInfo> results;
|
||||
if (flags & MemBlockFlags::ALLOC)
|
||||
allocMap.Find(MemBlockFlags::ALLOC, start, size, results);
|
||||
if (flags & MemBlockFlags::SUB_ALLOC)
|
||||
suballocMap.Find(MemBlockFlags::SUB_ALLOC, start, size, results);
|
||||
if (flags & MemBlockFlags::WRITE)
|
||||
writeMap.Find(MemBlockFlags::WRITE, start, size, results);
|
||||
if (flags & MemBlockFlags::TEXTURE)
|
||||
textureMap.Find(MemBlockFlags::TEXTURE, start, size, results);
|
||||
return results;
|
||||
}
|
||||
|
||||
void MemBlockInfoInit() {
|
||||
std::lock_guard<std::mutex> guard(pendingMutex);
|
||||
pendingNotifies.reserve(MAX_PENDING_NOTIFIES);
|
||||
}
|
||||
|
||||
void MemBlockInfoShutdown() {
|
||||
std::lock_guard<std::mutex> guard(pendingMutex);
|
||||
allocMap.Reset();
|
||||
suballocMap.Reset();
|
||||
writeMap.Reset();
|
||||
textureMap.Reset();
|
||||
pendingNotifies.clear();
|
||||
}
|
||||
|
||||
void MemBlockInfoDoState(PointerWrap &p) {
|
||||
auto s = p.Section("MemBlockInfo", 0, 1);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
FlushPendingMemInfo();
|
||||
allocMap.DoState(p);
|
||||
suballocMap.DoState(p);
|
||||
writeMap.DoState(p);
|
||||
textureMap.DoState(p);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2021- 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Common/Common.h"
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
enum class MemBlockFlags {
|
||||
ALLOC = 0x0001,
|
||||
SUB_ALLOC = 0x0002,
|
||||
WRITE = 0x0004,
|
||||
TEXTURE = 0x0008,
|
||||
// Not actually logged.
|
||||
READ = 0x0800,
|
||||
FREE = 0x1000,
|
||||
SUB_FREE = 0x2000,
|
||||
};
|
||||
ENUM_CLASS_BITOPS(MemBlockFlags);
|
||||
|
||||
struct MemBlockInfo {
|
||||
MemBlockFlags flags;
|
||||
uint32_t start;
|
||||
uint32_t size;
|
||||
uint64_t ticks;
|
||||
uint32_t pc;
|
||||
std::string tag;
|
||||
bool allocated;
|
||||
};
|
||||
|
||||
void NotifyMemInfo(MemBlockFlags flags, uint32_t start, uint32_t size, const std::string &tag);
|
||||
void NotifyMemInfoPC(MemBlockFlags flags, uint32_t start, uint32_t size, uint32_t pc, const std::string &tag);
|
||||
|
||||
std::vector<MemBlockInfo> FindMemInfo(uint32_t start, uint32_t size);
|
||||
std::vector<MemBlockInfo> FindMemInfoByFlag(MemBlockFlags flags, uint32_t start, uint32_t size);
|
||||
|
||||
void MemBlockInfoInit();
|
||||
void MemBlockInfoShutdown();
|
||||
void MemBlockInfoDoState(PointerWrap &p);
|
||||
@@ -21,6 +21,7 @@
|
||||
#pragma optimize("gty", on)
|
||||
#endif
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#ifdef _WIN32
|
||||
#include "Common/CommonWindows.h"
|
||||
#include <WindowsX.h>
|
||||
@@ -1045,7 +1046,6 @@ void SymbolMap::FillSymbolListBox(HWND listbox,SymbolType symType) {
|
||||
SendMessage(listbox, LB_INITSTORAGE, (WPARAM)activeFunctions.size(), (LPARAM)activeFunctions.size() * 30);
|
||||
|
||||
for (auto it = activeFunctions.begin(), end = activeFunctions.end(); it != end; ++it) {
|
||||
const FunctionEntry& entry = it->second;
|
||||
const char* name = GetLabelName(it->first);
|
||||
if (name != NULL)
|
||||
wsprintf(temp, L"%S", name);
|
||||
@@ -1069,7 +1069,6 @@ void SymbolMap::FillSymbolListBox(HWND listbox,SymbolType symType) {
|
||||
}
|
||||
|
||||
for (auto it = activeData.begin(), end = activeData.end(); it != end; ++it) {
|
||||
const DataEntry& entry = it->second;
|
||||
const char* name = GetLabelName(it->first);
|
||||
|
||||
if (name != NULL)
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <cstring>
|
||||
#include "Common/Data/Encoding/Base64.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HLE/ReplaceTables.h"
|
||||
#include "Core/MemMap.h"
|
||||
#include "Core/MIPS/MIPSDebugInterface.h"
|
||||
#include "Core/System.h"
|
||||
@@ -40,6 +42,48 @@ DebuggerSubscriber *WebSocketMemoryInit(DebuggerEventHandlerMap &map) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
struct AutoDisabledReplacements {
|
||||
~AutoDisabledReplacements();
|
||||
|
||||
Memory::MemoryInitedLock *lock = nullptr;
|
||||
std::map<u32, u32> replacements;
|
||||
std::vector<u32> emuhacks;
|
||||
bool saved = false;
|
||||
bool wasStepping = false;
|
||||
};
|
||||
|
||||
// Important: Only use keepReplacements when reading, not writing.
|
||||
static AutoDisabledReplacements LockMemoryAndCPU(bool keepReplacements) {
|
||||
AutoDisabledReplacements result;
|
||||
if (Core_IsStepping()) {
|
||||
result.wasStepping = true;
|
||||
} else {
|
||||
Core_EnableStepping(true);
|
||||
Core_WaitInactive();
|
||||
}
|
||||
|
||||
result.lock = new Memory::MemoryInitedLock();
|
||||
if (!keepReplacements) {
|
||||
result.saved = true;
|
||||
// Okay, save so we can restore later.
|
||||
result.replacements = SaveAndClearReplacements();
|
||||
if (MIPSComp::jit)
|
||||
result.emuhacks = MIPSComp::jit->SaveAndClearEmuHackOps();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
AutoDisabledReplacements::~AutoDisabledReplacements() {
|
||||
if (saved) {
|
||||
if (MIPSComp::jit)
|
||||
MIPSComp::jit->RestoreSavedEmuHackOps(emuhacks);
|
||||
RestoreSavedReplacements(replacements);
|
||||
}
|
||||
if (!wasStepping)
|
||||
Core_EnableStepping(false);
|
||||
delete lock;
|
||||
}
|
||||
|
||||
// Read a byte from memory (memory.read_u8)
|
||||
//
|
||||
// Parameters:
|
||||
@@ -48,7 +92,7 @@ DebuggerSubscriber *WebSocketMemoryInit(DebuggerEventHandlerMap &map) {
|
||||
// Response (same event name):
|
||||
// - value: unsigned integer
|
||||
void WebSocketMemoryReadU8(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -74,7 +118,7 @@ void WebSocketMemoryReadU8(DebuggerRequest &req) {
|
||||
// Response (same event name):
|
||||
// - value: unsigned integer
|
||||
void WebSocketMemoryReadU16(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -100,7 +144,7 @@ void WebSocketMemoryReadU16(DebuggerRequest &req) {
|
||||
// Response (same event name):
|
||||
// - value: unsigned integer
|
||||
void WebSocketMemoryReadU32(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -123,20 +167,24 @@ void WebSocketMemoryReadU32(DebuggerRequest &req) {
|
||||
// Parameters:
|
||||
// - address: unsigned integer address for the start of the memory range.
|
||||
// - size: unsigned integer specifying size of memory range.
|
||||
// - replacements: optional, false to ignore PPSSPP replacements in MIPS code.
|
||||
//
|
||||
// Response (same event name):
|
||||
// - base64: base64 encode of binary data.
|
||||
void WebSocketMemoryRead(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
uint32_t addr;
|
||||
if (!req.ParamU32("address", &addr))
|
||||
return;
|
||||
uint32_t size;
|
||||
if (!req.ParamU32("size", &size))
|
||||
return;
|
||||
bool replacements = true;
|
||||
if (!req.ParamBool("replacements", &replacements, DebuggerParamType::OPTIONAL))
|
||||
return;
|
||||
|
||||
auto memLock = LockMemoryAndCPU(replacements);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
if (!Memory::IsValidAddress(addr))
|
||||
return req.Fail("Invalid address");
|
||||
@@ -171,7 +219,7 @@ void WebSocketMemoryRead(DebuggerRequest &req) {
|
||||
// Response (same event name) for 'base64':
|
||||
// - base64: base64 encode of binary data, not including NUL.
|
||||
void WebSocketMemoryReadString(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -209,7 +257,7 @@ void WebSocketMemoryReadString(DebuggerRequest &req) {
|
||||
// Response (same event name):
|
||||
// - value: new value, unsigned integer
|
||||
void WebSocketMemoryWriteU8(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -225,6 +273,7 @@ void WebSocketMemoryWriteU8(DebuggerRequest &req) {
|
||||
req.Fail("Invalid address");
|
||||
return;
|
||||
}
|
||||
currentMIPS->InvalidateICache(addr, 1);
|
||||
Memory::Write_U8(val, addr);
|
||||
|
||||
JsonWriter &json = req.Respond();
|
||||
@@ -240,7 +289,7 @@ void WebSocketMemoryWriteU8(DebuggerRequest &req) {
|
||||
// Response (same event name):
|
||||
// - value: new value, unsigned integer
|
||||
void WebSocketMemoryWriteU16(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -256,6 +305,7 @@ void WebSocketMemoryWriteU16(DebuggerRequest &req) {
|
||||
req.Fail("Invalid address");
|
||||
return;
|
||||
}
|
||||
currentMIPS->InvalidateICache(addr, 2);
|
||||
Memory::Write_U16(val, addr);
|
||||
|
||||
JsonWriter &json = req.Respond();
|
||||
@@ -271,7 +321,7 @@ void WebSocketMemoryWriteU16(DebuggerRequest &req) {
|
||||
// Response (same event name):
|
||||
// - value: new value, unsigned integer
|
||||
void WebSocketMemoryWriteU32(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -287,6 +337,7 @@ void WebSocketMemoryWriteU32(DebuggerRequest &req) {
|
||||
req.Fail("Invalid address");
|
||||
return;
|
||||
}
|
||||
currentMIPS->InvalidateICache(addr, 4);
|
||||
Memory::Write_U32(val, addr);
|
||||
|
||||
JsonWriter &json = req.Respond();
|
||||
@@ -301,7 +352,7 @@ void WebSocketMemoryWriteU32(DebuggerRequest &req) {
|
||||
//
|
||||
// Response (same event name) with no extra data.
|
||||
void WebSocketMemoryWrite(DebuggerRequest &req) {
|
||||
auto memLock = Memory::Lock();
|
||||
auto memLock = LockMemoryAndCPU(true);
|
||||
if (!currentDebugMIPS->isAlive() || !Memory::IsActive())
|
||||
return req.Fail("CPU not started");
|
||||
|
||||
@@ -320,6 +371,7 @@ void WebSocketMemoryWrite(DebuggerRequest &req) {
|
||||
else if (value.size() != (size_t)size || !Memory::IsValidRange(addr, size))
|
||||
return req.Fail("Invalid size");
|
||||
|
||||
currentMIPS->InvalidateICache(addr, size);
|
||||
Memory::MemcpyUnchecked(addr, &value[0], size);
|
||||
req.Respond();
|
||||
}
|
||||
+59
-15
@@ -21,28 +21,37 @@
|
||||
#include "Common/Serialize/SerializeFuncs.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#include "Core/CoreTiming.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
#include "Core/Dialog/PSPDialog.h"
|
||||
#include "Core/HLE/sceCtrl.h"
|
||||
#include "Core/HLE/scePower.h"
|
||||
#include "Core/HLE/sceUtility.h"
|
||||
#include "Core/MemMapHelpers.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
|
||||
#define FADE_TIME 1.0
|
||||
const float FONT_SCALE = 0.55f;
|
||||
|
||||
PSPDialog::PSPDialog()
|
||||
: status(SCE_UTILITY_STATUS_NONE), pendingStatus(SCE_UTILITY_STATUS_NONE),
|
||||
pendingStatusTicks(0), lastButtons(0), buttons(0)
|
||||
{
|
||||
|
||||
PSPDialog::PSPDialog(UtilityDialogType type) : dialogType_(type) {
|
||||
}
|
||||
|
||||
PSPDialog::~PSPDialog() {
|
||||
}
|
||||
|
||||
PSPDialog::DialogStatus PSPDialog::GetStatus()
|
||||
{
|
||||
PSPDialog::DialogStatus PSPDialog::GetStatus() {
|
||||
if (pendingStatusTicks != 0 && CoreTiming::GetTicks() >= pendingStatusTicks) {
|
||||
status = pendingStatus;
|
||||
pendingStatusTicks = 0;
|
||||
bool changeAllowed = true;
|
||||
if (pendingStatus == SCE_UTILITY_STATUS_NONE && status == SCE_UTILITY_STATUS_SHUTDOWN) {
|
||||
FinishVolatile();
|
||||
} else if (pendingStatus == SCE_UTILITY_STATUS_RUNNING && status == SCE_UTILITY_STATUS_INITIALIZE) {
|
||||
if (!volatileLocked_) {
|
||||
volatileLocked_ = KernelVolatileMemLock(0, 0, 0) == 0;
|
||||
changeAllowed = volatileLocked_;
|
||||
}
|
||||
}
|
||||
if (changeAllowed) {
|
||||
status = pendingStatus;
|
||||
pendingStatusTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
PSPDialog::DialogStatus retval = status;
|
||||
@@ -57,6 +66,14 @@ PSPDialog::DialogStatus PSPDialog::GetStatus()
|
||||
|
||||
void PSPDialog::ChangeStatus(DialogStatus newStatus, int delayUs) {
|
||||
if (delayUs <= 0) {
|
||||
if (newStatus == SCE_UTILITY_STATUS_NONE && status == SCE_UTILITY_STATUS_SHUTDOWN) {
|
||||
FinishVolatile();
|
||||
} else if (newStatus == SCE_UTILITY_STATUS_RUNNING && status == SCE_UTILITY_STATUS_INITIALIZE) {
|
||||
if (!volatileLocked_) {
|
||||
// TODO: Should probably make the status pending instead?
|
||||
volatileLocked_ = KernelVolatileMemLock(0, 0, 0) == 0;
|
||||
}
|
||||
}
|
||||
status = newStatus;
|
||||
pendingStatusTicks = 0;
|
||||
} else {
|
||||
@@ -65,6 +82,24 @@ void PSPDialog::ChangeStatus(DialogStatus newStatus, int delayUs) {
|
||||
}
|
||||
}
|
||||
|
||||
void PSPDialog::FinishVolatile() {
|
||||
if (!volatileLocked_)
|
||||
return;
|
||||
|
||||
if (KernelVolatileMemUnlock(0) == 0) {
|
||||
volatileLocked_ = false;
|
||||
// Simulate modifications to volatile memory.
|
||||
Memory::Memset(PSP_GetVolatileMemoryStart(), 0, PSP_GetVolatileMemoryEnd() - PSP_GetVolatileMemoryStart());
|
||||
}
|
||||
}
|
||||
|
||||
int PSPDialog::FinishShutdown() {
|
||||
if (ReadStatus() != SCE_UTILITY_STATUS_SHUTDOWN)
|
||||
return -1;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_NONE, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PSPDialog::ChangeStatusInit(int delayUs) {
|
||||
status = SCE_UTILITY_STATUS_INITIALIZE;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_RUNNING, delayUs);
|
||||
@@ -72,7 +107,11 @@ void PSPDialog::ChangeStatusInit(int delayUs) {
|
||||
|
||||
void PSPDialog::ChangeStatusShutdown(int delayUs) {
|
||||
status = SCE_UTILITY_STATUS_SHUTDOWN;
|
||||
ChangeStatus(SCE_UTILITY_STATUS_NONE, delayUs);
|
||||
auto params = GetCommonParam();
|
||||
if (params)
|
||||
UtilityDialogShutdown(DialogType(), delayUs, params->accessThread);
|
||||
else
|
||||
ChangeStatus(SCE_UTILITY_STATUS_NONE, delayUs);
|
||||
}
|
||||
|
||||
void PSPDialog::StartDraw()
|
||||
@@ -132,9 +171,8 @@ u32 PSPDialog::CalcFadedColor(u32 inColor)
|
||||
return (inColor & 0x00FFFFFF) | (alpha << 24);
|
||||
}
|
||||
|
||||
void PSPDialog::DoState(PointerWrap &p)
|
||||
{
|
||||
auto s = p.Section("PSPDialog", 1, 2);
|
||||
void PSPDialog::DoState(PointerWrap &p) {
|
||||
auto s = p.Section("PSPDialog", 1, 3);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
@@ -161,6 +199,12 @@ void PSPDialog::DoState(PointerWrap &p)
|
||||
} else {
|
||||
pendingStatusTicks = 0;
|
||||
}
|
||||
|
||||
if (s >= 3) {
|
||||
Do(p, volatileLocked_);
|
||||
} else {
|
||||
volatileLocked_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
pspUtilityDialogCommon *PSPDialog::GetCommonParam()
|
||||
|
||||
+21
-11
@@ -17,11 +17,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Render/TextureAtlas.h"
|
||||
#include "Common/Swap.h"
|
||||
#include "Core/HLE/sceUtility.h"
|
||||
#include "Core/Util/PPGeDraw.h"
|
||||
|
||||
class PointerWrap;
|
||||
@@ -53,7 +53,7 @@ struct pspUtilityDialogCommon
|
||||
class PSPDialog
|
||||
{
|
||||
public:
|
||||
PSPDialog();
|
||||
PSPDialog(UtilityDialogType type);
|
||||
virtual ~PSPDialog();
|
||||
|
||||
virtual int Update(int animSpeed) = 0;
|
||||
@@ -80,9 +80,14 @@ public:
|
||||
};
|
||||
|
||||
DialogStatus GetStatus();
|
||||
UtilityDialogType DialogType() { return dialogType_; }
|
||||
|
||||
void StartDraw();
|
||||
void EndDraw();
|
||||
|
||||
void FinishVolatile();
|
||||
int FinishShutdown();
|
||||
|
||||
protected:
|
||||
PPGeStyle FadedStyle(PPGeAlign align, float scale);
|
||||
PPGeImageStyle FadedImageStyle();
|
||||
@@ -94,23 +99,23 @@ protected:
|
||||
void ChangeStatus(DialogStatus newStatus, int delayUs);
|
||||
void ChangeStatusInit(int delayUs);
|
||||
void ChangeStatusShutdown(int delayUs);
|
||||
DialogStatus ReadStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
// TODO: Remove this once all dialogs are updated.
|
||||
virtual bool UseAutoStatus() {
|
||||
return true;
|
||||
}
|
||||
virtual bool UseAutoStatus() = 0;
|
||||
|
||||
void StartFade(bool fadeIn_);
|
||||
void UpdateFade(int animSpeed);
|
||||
virtual void FinishFadeOut();
|
||||
u32 CalcFadedColor(u32 inColor);
|
||||
|
||||
DialogStatus status;
|
||||
DialogStatus pendingStatus;
|
||||
u64 pendingStatusTicks;
|
||||
DialogStatus pendingStatus = SCE_UTILITY_STATUS_NONE;
|
||||
u64 pendingStatusTicks = 0;
|
||||
|
||||
unsigned int lastButtons;
|
||||
unsigned int buttons;
|
||||
unsigned int lastButtons = 0;
|
||||
unsigned int buttons = 0;
|
||||
|
||||
float fadeTimer;
|
||||
bool isFading;
|
||||
@@ -121,4 +126,9 @@ protected:
|
||||
ImageID cancelButtonImg;
|
||||
int okButtonFlag;
|
||||
int cancelButtonFlag;
|
||||
|
||||
private:
|
||||
DialogStatus status = SCE_UTILITY_STATUS_NONE;
|
||||
UtilityDialogType dialogType_;
|
||||
bool volatileLocked_ = false;
|
||||
};
|
||||
@@ -55,7 +55,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
PSPGamedataInstallDialog::PSPGamedataInstallDialog() {
|
||||
PSPGamedataInstallDialog::PSPGamedataInstallDialog(UtilityDialogType type) : PSPDialog(type) {
|
||||
}
|
||||
|
||||
PSPGamedataInstallDialog::~PSPGamedataInstallDialog() {
|
||||
|
||||
@@ -35,7 +35,7 @@ struct SceUtilityGamedataInstallParam {
|
||||
|
||||
class PSPGamedataInstallDialog: public PSPDialog {
|
||||
public:
|
||||
PSPGamedataInstallDialog();
|
||||
PSPGamedataInstallDialog(UtilityDialogType type);
|
||||
virtual ~PSPGamedataInstallDialog();
|
||||
|
||||
virtual int Init(u32 paramAddr);
|
||||
@@ -46,6 +46,12 @@ public:
|
||||
int Abort();
|
||||
std::string GetGameDataInstallFileName(SceUtilityGamedataInstallParam *param, std::string filename);
|
||||
|
||||
protected:
|
||||
// TODO: Manage status correctly.
|
||||
bool UseAutoStatus() override {
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
void UpdateProgress();
|
||||
void OpenNextFile();
|
||||
|
||||
@@ -35,10 +35,7 @@ static const float FONT_SCALE = 0.65f;
|
||||
const static int MSG_INIT_DELAY_US = 300000;
|
||||
const static int MSG_SHUTDOWN_DELAY_US = 26000;
|
||||
|
||||
PSPMsgDialog::PSPMsgDialog()
|
||||
: PSPDialog()
|
||||
, flag(0)
|
||||
{
|
||||
PSPMsgDialog::PSPMsgDialog(UtilityDialogType type) : PSPDialog(type) {
|
||||
}
|
||||
|
||||
PSPMsgDialog::~PSPMsgDialog() {
|
||||
@@ -344,7 +341,7 @@ int PSPMsgDialog::Update(int animSpeed) {
|
||||
messageDialog.result = 0;
|
||||
}
|
||||
|
||||
Memory::Memcpy(messageDialogAddr, &messageDialog ,messageDialog.common.size);
|
||||
Memory::Memcpy(messageDialogAddr, &messageDialog, messageDialog.common.size, "MsgDialogParam");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ struct pspMessageDialog
|
||||
|
||||
class PSPMsgDialog: public PSPDialog {
|
||||
public:
|
||||
PSPMsgDialog();
|
||||
PSPMsgDialog(UtilityDialogType type);
|
||||
virtual ~PSPMsgDialog();
|
||||
|
||||
virtual int Init(unsigned int paramAddr);
|
||||
@@ -92,7 +92,7 @@ private:
|
||||
DS_ABORT = 0x200,
|
||||
};
|
||||
|
||||
u32 flag;
|
||||
u32 flag = 0;
|
||||
|
||||
pspMessageDialog messageDialog;
|
||||
int messageDialogAddr;
|
||||
|
||||
@@ -54,7 +54,7 @@ struct ScanInfos {
|
||||
} PACK;
|
||||
|
||||
|
||||
PSPNetconfDialog::PSPNetconfDialog() {
|
||||
PSPNetconfDialog::PSPNetconfDialog(UtilityDialogType type) : PSPDialog(type) {
|
||||
}
|
||||
|
||||
PSPNetconfDialog::~PSPNetconfDialog() {
|
||||
@@ -62,7 +62,7 @@ PSPNetconfDialog::~PSPNetconfDialog() {
|
||||
|
||||
int PSPNetconfDialog::Init(u32 paramAddr) {
|
||||
// Already running
|
||||
if (status != SCE_UTILITY_STATUS_NONE)
|
||||
if (ReadStatus() != SCE_UTILITY_STATUS_NONE)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
requestAddr = paramAddr;
|
||||
@@ -465,13 +465,13 @@ int PSPNetconfDialog::Update(int animSpeed) {
|
||||
}
|
||||
|
||||
if (GetStatus() == SCE_UTILITY_STATUS_FINISHED || pendingStatus == SCE_UTILITY_STATUS_FINISHED)
|
||||
Memory::Memcpy(requestAddr, &request, request.common.size);
|
||||
Memory::Memcpy(requestAddr, &request, request.common.size, "NetConfDialogParam");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PSPNetconfDialog::Shutdown(bool force) {
|
||||
if (status != SCE_UTILITY_STATUS_FINISHED && !force)
|
||||
if (ReadStatus() != SCE_UTILITY_STATUS_FINISHED && !force)
|
||||
return SCE_ERROR_UTILITY_INVALID_STATUS;
|
||||
|
||||
PSPDialog::Shutdown(force);
|
||||
|
||||
@@ -37,7 +37,7 @@ struct SceUtilityNetconfParam {
|
||||
|
||||
class PSPNetconfDialog: public PSPDialog {
|
||||
public:
|
||||
PSPNetconfDialog();
|
||||
PSPNetconfDialog(UtilityDialogType type);
|
||||
virtual ~PSPNetconfDialog();
|
||||
|
||||
virtual int Init(u32 paramAddr);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include "ppsspp_config.h"
|
||||
#include <algorithm>
|
||||
|
||||
#include "Common/Data/Text/I18n.h"
|
||||
@@ -156,7 +157,7 @@ int allowedInputFlagsMap[OSK_KEYBOARD_COUNT] = {
|
||||
PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_UPPERCASE | PSP_UTILITY_OSK_INPUTTYPE_JAPANESE_SYMBOL,
|
||||
};
|
||||
|
||||
PSPOskDialog::PSPOskDialog() : PSPDialog() {
|
||||
PSPOskDialog::PSPOskDialog(UtilityDialogType type) : PSPDialog(type) {
|
||||
// This can break all kinds of stuff, changing the decimal point in sprintf for example.
|
||||
// Not sure what the intended effect is so commented out for now.
|
||||
// setlocale(LC_ALL, "");
|
||||
|
||||
Loaded 100 of 513 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user