mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 10:40:01 +01:00
Merge branch 'master' into TemporaryHackishBranch
This commit is contained in:
commit
398c58c489
39 files changed
+588
-205
No files matched your search
+4
-1
@@ -1769,9 +1769,12 @@ set(NativeAssets
|
||||
if(HEADLESS)
|
||||
add_executable(PPSSPPHeadless
|
||||
headless/Headless.cpp
|
||||
headless/StubHost.cpp
|
||||
headless/StubHost.h
|
||||
headless/Compare.cpp
|
||||
headless/Compare.h)
|
||||
headless/Compare.h
|
||||
headless/SDLHeadlessHost.cpp
|
||||
headless/SDLHeadlessHost.h)
|
||||
target_link_libraries(PPSSPPHeadless
|
||||
${COCOA_LIBRARY} ${LinkCommon})
|
||||
setup_target_project(PPSSPPHeadless headless)
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ enum {
|
||||
VIRTKEY_REWIND = 0x4000000d,
|
||||
VIRTKEY_SAVE_STATE = 0x4000000e,
|
||||
VIRTKEY_LOAD_STATE = 0x4000000f,
|
||||
VIRTKEY_NEXT_SLOT = 0x40000010,
|
||||
VIRTKEY_NEXT_SLOT = 0x40000010,
|
||||
VIRTKEY_TOGGLE_FULLSCREEN = 0x40000011,
|
||||
VIRTKEY_ANALOG_LIGHTLY = 0x40000012,
|
||||
VIRTKEY_AXIS_SWAP = 0x40000013,
|
||||
|
||||
@@ -123,11 +123,20 @@ VkResult VulkanContext::CreateInstance(const char *app_name, int app_ver, uint32
|
||||
|
||||
uint32_t gpu_count = 1;
|
||||
res = vkEnumeratePhysicalDevices(instance_, &gpu_count, nullptr);
|
||||
if (gpu_count <= 0) {
|
||||
ELOG("Vulkan driver found but no supported GPU is available");
|
||||
init_error_ = "No Vulkan physical devices found";
|
||||
vkDestroyInstance(instance_, nullptr);
|
||||
instance_ = nullptr;
|
||||
return VK_ERROR_INITIALIZATION_FAILED;
|
||||
}
|
||||
|
||||
assert(gpu_count > 0);
|
||||
physical_devices_.resize(gpu_count);
|
||||
res = vkEnumeratePhysicalDevices(instance_, &gpu_count, physical_devices_.data());
|
||||
if (res != VK_SUCCESS) {
|
||||
init_error_ = "Failed to enumerate physical devices";
|
||||
vkDestroyInstance(instance_, nullptr);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ void VulkanDeviceAllocator::Destroy() {
|
||||
}
|
||||
}
|
||||
|
||||
assert(slab.deviceMemory);
|
||||
vulkan_->Delete().QueueDeleteDeviceMemory(slab.deviceMemory);
|
||||
}
|
||||
slabs_.clear();
|
||||
|
||||
+2
-1
@@ -739,7 +739,7 @@ static ConfigSetting systemParamSettings[] = {
|
||||
ReportedConfigSetting("PSPModel", &g_Config.iPSPModel, &DefaultPSPModel, true, true),
|
||||
ReportedConfigSetting("PSPFirmwareVersion", &g_Config.iFirmwareVersion, PSP_DEFAULT_FIRMWARE, true, true),
|
||||
ConfigSetting("NickName", &g_Config.sNickName, "PPSSPP", true, true),
|
||||
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "coldbird.net", true, true),
|
||||
ConfigSetting("proAdhocServer", &g_Config.proAdhocServer, "", true, true),
|
||||
ConfigSetting("MacAddress", &g_Config.sMACAddress, "", true, true),
|
||||
ConfigSetting("PortOffset", &g_Config.iPortOffset, 0, true, true),
|
||||
ReportedConfigSetting("Language", &g_Config.iLanguage, &DefaultSystemParamLanguage, true, true),
|
||||
@@ -755,6 +755,7 @@ static ConfigSetting systemParamSettings[] = {
|
||||
#endif
|
||||
ConfigSetting("WlanPowerSave", &g_Config.bWlanPowerSave, (bool) PSP_SYSTEMPARAM_WLAN_POWERSAVE_OFF, true, true),
|
||||
ReportedConfigSetting("EncryptSave", &g_Config.bEncryptSave, true, true, true),
|
||||
ConfigSetting("SavedataUpgrade", &g_Config.bSavedataUpgrade, false, true, false),
|
||||
|
||||
ConfigSetting(false),
|
||||
};
|
||||
|
||||
@@ -419,6 +419,7 @@ public:
|
||||
int iButtonPreference;
|
||||
int iLockParentalLevel;
|
||||
bool bEncryptSave;
|
||||
bool bSavedataUpgrade;
|
||||
|
||||
// Networking
|
||||
bool bEnableWlan;
|
||||
|
||||
@@ -647,6 +647,12 @@ void SavedataParam::LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, u8
|
||||
} else {
|
||||
WARN_LOG_REPORT(SCEUTILITY, "Savedata loading with detected hashmode %d instead of file's %d", decryptMode, prevCryptMode);
|
||||
}
|
||||
if (g_Config.bSavedataUpgrade) {
|
||||
decryptMode = prevCryptMode;
|
||||
I18NCategory *di = GetI18NCategory("Dialog");
|
||||
host->NotifyUserMessage(di->T("When you save, it will not work on outdated PSP Firmware anymore"), 6.0f);
|
||||
host->NotifyUserMessage(di->T("Old savedata detected"), 6.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -263,7 +263,6 @@ void __KernelDoState(PointerWrap &p)
|
||||
__UmdDoState(p);
|
||||
__UtilityDoState(p);
|
||||
__UsbDoState(p);
|
||||
__UsbGpsDoState(p);
|
||||
__VaudioDoState(p);
|
||||
__HeapDoState(p);
|
||||
|
||||
@@ -272,6 +271,9 @@ void __KernelDoState(PointerWrap &p)
|
||||
__sceAudiocodecDoState(p);
|
||||
__VideoPmpDoState(p);
|
||||
__AACDoState(p);
|
||||
__UsbGpsDoState(p);
|
||||
|
||||
// IMPORTANT! Add new sections last!
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ void __UsbGpsInit() {
|
||||
}
|
||||
|
||||
void __UsbGpsDoState(PointerWrap &p) {
|
||||
auto s = p.Section("sceUsbGps", 1, 4);
|
||||
auto s = p.Section("sceUsbGps", 0, 1);
|
||||
if (!s)
|
||||
return;
|
||||
|
||||
|
||||
@@ -124,8 +124,9 @@ void ShaderManagerD3D11::Clear() {
|
||||
}
|
||||
fsCache_.clear();
|
||||
vsCache_.clear();
|
||||
lastFSID_.clear();
|
||||
lastVSID_.clear();
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
||||
void ShaderManagerD3D11::ClearShaders() {
|
||||
@@ -135,11 +136,11 @@ void ShaderManagerD3D11::ClearShaders() {
|
||||
}
|
||||
|
||||
void ShaderManagerD3D11::DirtyLastShader() {
|
||||
lastFSID_.clear();
|
||||
lastVSID_.clear();
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
lastVShader_ = nullptr;
|
||||
lastFShader_ = nullptr;
|
||||
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE|DIRTY_FRAGMENTSHADER_STATE);
|
||||
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
||||
uint64_t ShaderManagerD3D11::UpdateUniforms() {
|
||||
|
||||
@@ -516,9 +516,6 @@ void ShaderManagerDX9::Clear() {
|
||||
}
|
||||
fsCache_.clear();
|
||||
vsCache_.clear();
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
||||
lastFSID_.clear();
|
||||
lastVSID_.clear();
|
||||
DirtyShader();
|
||||
}
|
||||
|
||||
@@ -529,11 +526,11 @@ void ShaderManagerDX9::ClearCache(bool deleteThem) {
|
||||
|
||||
void ShaderManagerDX9::DirtyShader() {
|
||||
// Forget the last shader ID
|
||||
lastFSID_.clear();
|
||||
lastVSID_.clear();
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
lastVShader_ = nullptr;
|
||||
lastPShader_ = nullptr;
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
||||
void ShaderManagerDX9::DirtyLastShader() { // disables vertex arrays
|
||||
|
||||
@@ -49,6 +49,12 @@
|
||||
// #define DEBUG_READ_PIXELS 1
|
||||
|
||||
static const char tex_fs[] =
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define varying in\n"
|
||||
"#define texture2D texture\n"
|
||||
"#define gl_FragColor fragColor0\n"
|
||||
"out vec4 fragColor0;\n"
|
||||
"#endif\n"
|
||||
#ifdef USING_GLES2
|
||||
"precision mediump float;\n"
|
||||
#endif
|
||||
@@ -59,6 +65,10 @@ static const char tex_fs[] =
|
||||
"}\n";
|
||||
|
||||
static const char basic_vs[] =
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define attribute in\n"
|
||||
"#define varying out\n"
|
||||
"#endif\n"
|
||||
"attribute vec4 a_position;\n"
|
||||
"attribute vec2 a_texcoord0;\n"
|
||||
"varying vec2 v_texcoord0;\n"
|
||||
@@ -87,7 +97,10 @@ void FramebufferManagerGLES::DisableState() {
|
||||
void FramebufferManagerGLES::CompileDraw2DProgram() {
|
||||
if (!draw2dprogram_) {
|
||||
std::string errorString;
|
||||
draw2dprogram_ = glsl_create_source(basic_vs, tex_fs, &errorString);
|
||||
static std::string vs_code, fs_code;
|
||||
vs_code = ApplyGLSLPrelude(basic_vs, GL_VERTEX_SHADER);
|
||||
fs_code = ApplyGLSLPrelude(tex_fs, GL_FRAGMENT_SHADER);
|
||||
draw2dprogram_ = glsl_create_source(vs_code.c_str(), fs_code.c_str(), &errorString);
|
||||
if (!draw2dprogram_) {
|
||||
ERROR_LOG_REPORT(G3D, "Failed to compile draw2dprogram! This shouldn't happen.\n%s", errorString.c_str());
|
||||
} else {
|
||||
|
||||
@@ -299,7 +299,7 @@ void GPU_GLES::CheckGPUFeatures() {
|
||||
features |= GPU_SUPPORTS_ANISOTROPY;
|
||||
|
||||
bool canUseInstanceID = gl_extensions.EXT_draw_instanced || gl_extensions.ARB_draw_instanced;
|
||||
bool canDefInstanceID = gl_extensions.IsGLES || gl_extensions.EXT_gpu_shader4;
|
||||
bool canDefInstanceID = gl_extensions.IsGLES || gl_extensions.EXT_gpu_shader4 || gl_extensions.VersionGEThan(3, 1);
|
||||
bool instanceRendering = gl_extensions.GLES3 || (canUseInstanceID && canDefInstanceID);
|
||||
features |= GPU_SUPPORTS_INSTANCE_RENDERING;
|
||||
|
||||
|
||||
@@ -774,9 +774,6 @@ void ShaderManagerGLES::Clear() {
|
||||
linkedShaderCache_.clear();
|
||||
fsCache_.Clear();
|
||||
vsCache_.Clear();
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
DirtyShader();
|
||||
}
|
||||
|
||||
@@ -790,7 +787,7 @@ void ShaderManagerGLES::DirtyShader() {
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
DirtyLastShader();
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
shaderSwitchDirtyUniforms_ = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,11 +22,16 @@
|
||||
#include "GPU/GLES/ShaderManagerGLES.h"
|
||||
#include "GPU/GLES/TextureCacheGLES.h"
|
||||
|
||||
static const char *gles_prefix =
|
||||
"#version 100\n"
|
||||
"precision highp float;\n";
|
||||
|
||||
static const char *stencil_fs =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision highp float;\n"
|
||||
"#endif\n"
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define varying in\n"
|
||||
"#define texture2D texture\n"
|
||||
"#define gl_FragColor fragColor0\n"
|
||||
"out vec4 fragColor0;\n"
|
||||
"#endif\n"
|
||||
"varying vec2 v_texcoord0;\n"
|
||||
"uniform float u_stencilValue;\n"
|
||||
"uniform sampler2D tex;\n"
|
||||
@@ -39,6 +44,13 @@ static const char *stencil_fs =
|
||||
"}\n";
|
||||
|
||||
static const char *stencil_vs =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision highp float;\n"
|
||||
"#endif\n"
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define attribute in\n"
|
||||
"#define varying out\n"
|
||||
"#endif\n"
|
||||
"attribute vec4 a_position;\n"
|
||||
"attribute vec2 a_texcoord0;\n"
|
||||
"varying vec2 v_texcoord0;\n"
|
||||
@@ -47,14 +59,6 @@ static const char *stencil_vs =
|
||||
" gl_Position = a_position;\n"
|
||||
"}\n";
|
||||
|
||||
std::string GLSLES100PrefixProgram(std::string code) {
|
||||
if (gl_extensions.IsGLES) {
|
||||
return std::string(gles_prefix) + code;
|
||||
} else {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
static u8 StencilBits5551(const u8 *ptr8, u32 numPixels) {
|
||||
const u32 *ptr = (const u32 *)ptr8;
|
||||
|
||||
@@ -152,7 +156,10 @@ bool FramebufferManagerGLES::NotifyStencilUpload(u32 addr, int size, bool skipZe
|
||||
|
||||
if (!stencilUploadProgram_) {
|
||||
std::string errorString;
|
||||
stencilUploadProgram_ = glsl_create_source(GLSLES100PrefixProgram(stencil_vs).c_str(), GLSLES100PrefixProgram(stencil_fs).c_str(), &errorString);
|
||||
static std::string vs_code, fs_code;
|
||||
vs_code = ApplyGLSLPrelude(stencil_vs, GL_VERTEX_SHADER);
|
||||
fs_code = ApplyGLSLPrelude(stencil_fs, GL_FRAGMENT_SHADER);
|
||||
stencilUploadProgram_ = glsl_create_source(vs_code.c_str(), fs_code.c_str(), &errorString);
|
||||
if (!stencilUploadProgram_) {
|
||||
ERROR_LOG_REPORT(G3D, "Failed to compile stencilUploadProgram! This shouldn't happen.\n%s", errorString.c_str());
|
||||
} else {
|
||||
|
||||
+3
-3
@@ -49,7 +49,7 @@ const CommonCommandTableEntry commonCommandTable[] = {
|
||||
// Changes that dirty the framebuffer
|
||||
{ GE_CMD_FRAMEBUFPTR, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAMEBUF | DIRTY_TEXTURE_PARAMS },
|
||||
{ GE_CMD_FRAMEBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAMEBUF | DIRTY_TEXTURE_PARAMS | DIRTY_VIEWPORTSCISSOR_STATE },
|
||||
{ GE_CMD_FRAMEBUFPIXFORMAT, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAMEBUF | DIRTY_TEXTURE_PARAMS | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_FRAGMENTSHADER_STATE},
|
||||
{ GE_CMD_FRAMEBUFPIXFORMAT, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAMEBUF | DIRTY_TEXTURE_PARAMS | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_FRAGMENTSHADER_STATE },
|
||||
{ GE_CMD_ZBUFPTR, FLAG_FLUSHBEFOREONCHANGE },
|
||||
{ GE_CMD_ZBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE },
|
||||
|
||||
@@ -1795,7 +1795,7 @@ void GPUCommon::Execute_BoneMtxNum(u32 op, u32 diff) {
|
||||
}
|
||||
}
|
||||
|
||||
const int numPlusCount = (op & 0x7F) + i;
|
||||
const unsigned int numPlusCount = (op & 0x7F) + i;
|
||||
for (unsigned int num = op & 0x7F; num < numPlusCount; num += 12) {
|
||||
gstate_c.Dirty(DIRTY_BONEMATRIX0 << (num / 12));
|
||||
}
|
||||
@@ -1807,7 +1807,7 @@ void GPUCommon::Execute_BoneMtxNum(u32 op, u32 diff) {
|
||||
}
|
||||
}
|
||||
|
||||
const int numPlusCount = (op & 0x7F) + i;
|
||||
const unsigned int numPlusCount = (op & 0x7F) + i;
|
||||
for (unsigned int num = op & 0x7F; num < numPlusCount; num += 12) {
|
||||
gstate_c.deferredVertTypeDirty |= DIRTY_BONEMATRIX0 << (num / 12);
|
||||
}
|
||||
|
||||
@@ -186,22 +186,22 @@ void ShaderManagerVulkan::Clear() {
|
||||
});
|
||||
fsCache_.Clear();
|
||||
vsCache_.Clear();
|
||||
lastFSID_.clear();
|
||||
lastVSID_.clear();
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
||||
void ShaderManagerVulkan::ClearShaders() {
|
||||
Clear();
|
||||
DirtyShader();
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
||||
gstate_c.Dirty(DIRTY_ALL_UNIFORMS | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
|
||||
void ShaderManagerVulkan::DirtyShader() {
|
||||
// Forget the last shader ID
|
||||
lastFSID_.clear();
|
||||
lastVSID_.clear();
|
||||
lastVShader_ = nullptr;
|
||||
lastFShader_ = nullptr;
|
||||
lastFSID_.set_invalid();
|
||||
lastVSID_.set_invalid();
|
||||
DirtyLastShader();
|
||||
}
|
||||
|
||||
void ShaderManagerVulkan::DirtyLastShader() { // disables vertex arrays
|
||||
|
||||
@@ -135,13 +135,16 @@ TextureCacheVulkan::TextureCacheVulkan(Draw::DrawContext *draw, VulkanContext *v
|
||||
|
||||
TextureCacheVulkan::~TextureCacheVulkan() {
|
||||
Clear(true);
|
||||
allocator_->Destroy();
|
||||
|
||||
// We have to delete on queue, so this can free its queued deletions.
|
||||
vulkan_->Delete().QueueCallback([](void *ptr) {
|
||||
auto allocator = static_cast<VulkanDeviceAllocator *>(ptr);
|
||||
delete allocator;
|
||||
}, allocator_);
|
||||
if (allocator_) {
|
||||
allocator_->Destroy();
|
||||
|
||||
// We have to delete on queue, so this can free its queued deletions.
|
||||
vulkan_->Delete().QueueCallback([](void *ptr) {
|
||||
auto allocator = static_cast<VulkanDeviceAllocator *>(ptr);
|
||||
delete allocator;
|
||||
}, allocator_);
|
||||
}
|
||||
}
|
||||
|
||||
void TextureCacheVulkan::SetFramebufferManager(FramebufferManagerVulkan *fbManager) {
|
||||
@@ -171,6 +174,8 @@ void TextureCacheVulkan::DeviceLost() {
|
||||
void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan) {
|
||||
vulkan_ = vulkan;
|
||||
|
||||
assert(!allocator_);
|
||||
|
||||
allocator_ = new VulkanDeviceAllocator(vulkan_, TEXCACHE_MIN_SLAB_SIZE, TEXCACHE_MAX_SLAB_SIZE);
|
||||
samplerCache_.DeviceRestore(vulkan);
|
||||
}
|
||||
|
||||
+28
-14
@@ -50,22 +50,36 @@ void SDLJoystick::setUpControllers() {
|
||||
}
|
||||
|
||||
void SDLJoystick::setUpController(int deviceIndex) {
|
||||
if (SDL_IsGameController(deviceIndex)) {
|
||||
SDL_GameController *controller = SDL_GameControllerOpen(deviceIndex);
|
||||
if (controller) {
|
||||
if (SDL_GameControllerGetAttached(controller)) {
|
||||
controllers.push_back(controller);
|
||||
controllerDeviceMap[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))] = deviceIndex;
|
||||
cout << "found control pad: " << SDL_GameControllerName(controller) << ", loading mapping: ";
|
||||
auto mapping = SDL_GameControllerMapping(controller);
|
||||
if (mapping == NULL) {
|
||||
cout << "FAILED" << endl;
|
||||
} else {
|
||||
cout << "SUCCESS, mapping is:" << endl << mapping << endl;
|
||||
}
|
||||
if (!SDL_IsGameController(deviceIndex)) {
|
||||
cout << "Control pad device " << deviceIndex << " not supported by SDL game controller database, attempting to create default mapping..." << endl;
|
||||
int cbGUID = 33;
|
||||
char pszGUID[cbGUID];
|
||||
SDL_Joystick* joystick = SDL_JoystickOpen(deviceIndex);
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(joystick), pszGUID, cbGUID);
|
||||
// create default mapping - this is the PS3 dual shock mapping
|
||||
std::string mapping = string(pszGUID) + "," + string(SDL_JoystickName(joystick)) + ",x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4";
|
||||
if (SDL_GameControllerAddMapping(mapping.c_str()) == 1){
|
||||
cout << "Added default mapping ok" << endl;
|
||||
} else {
|
||||
cout << "Failed to add default mapping" << endl;
|
||||
}
|
||||
SDL_JoystickClose(joystick);
|
||||
}
|
||||
SDL_GameController *controller = SDL_GameControllerOpen(deviceIndex);
|
||||
if (controller) {
|
||||
if (SDL_GameControllerGetAttached(controller)) {
|
||||
controllers.push_back(controller);
|
||||
controllerDeviceMap[SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(controller))] = deviceIndex;
|
||||
cout << "found control pad: " << SDL_GameControllerName(controller) << ", loading mapping: ";
|
||||
auto mapping = SDL_GameControllerMapping(controller);
|
||||
if (mapping == NULL) {
|
||||
//cout << "FAILED" << endl;
|
||||
cout << "Could not find mapping in SDL2 controller database" << endl;
|
||||
} else {
|
||||
SDL_GameControllerClose(controller);
|
||||
cout << "SUCCESS, mapping is:" << endl << mapping << endl;
|
||||
}
|
||||
} else {
|
||||
SDL_GameControllerClose(controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ public:
|
||||
JoystickHistoryView(int xAxis, int xDevice, int xDir, int yAxis, int yDevice, int yDir, UI::LayoutParams *layoutParams = nullptr)
|
||||
: UI::InertView(layoutParams),
|
||||
xAxis_(xAxis), xDevice_(xDevice), xDir_(xDir),
|
||||
yAxis_(yAxis), yDevice_(yDevice), yDir_(xDir),
|
||||
yAxis_(yAxis), yDevice_(yDevice), yDir_(yDir),
|
||||
curX_(0.0f), curY_(0.0f),
|
||||
maxCount_(500) {}
|
||||
void Draw(UIContext &dc) override;
|
||||
|
||||
@@ -94,7 +94,7 @@ bool CheckSupportInstancedTessellationGLES() {
|
||||
bool vertexTexture = maxVertexTextureImageUnits >= 3; // At least 3 for hardware tessellation
|
||||
|
||||
bool canUseInstanceID = gl_extensions.EXT_draw_instanced || gl_extensions.ARB_draw_instanced;
|
||||
bool canDefInstanceID = gl_extensions.IsGLES || gl_extensions.EXT_gpu_shader4;
|
||||
bool canDefInstanceID = gl_extensions.IsGLES || gl_extensions.EXT_gpu_shader4 || gl_extensions.VersionGEThan(3, 1);
|
||||
bool instanceRendering = gl_extensions.GLES3 || (canUseInstanceID && canDefInstanceID);
|
||||
|
||||
bool textureFloat = gl_extensions.ARB_texture_float || gl_extensions.OES_texture_float;
|
||||
@@ -1105,6 +1105,9 @@ void GameSettingsScreen::CallbackRenderingBackend(bool yes) {
|
||||
// If the user ends up deciding not to restart, set the config back to the current backend
|
||||
// so it doesn't get switched by accident.
|
||||
if (yes) {
|
||||
// Extra save here to make sure the choice really gets saved even if there are shutdown bugs in
|
||||
// the GPU backend code.
|
||||
g_Config.Save();
|
||||
System_SendMessage("graphics_restart", "");
|
||||
} else {
|
||||
g_Config.iGPUBackend = (int)GetGPUBackend();
|
||||
|
||||
@@ -444,6 +444,7 @@ ifeq ($(HEADLESS),1)
|
||||
LOCAL_MODULE := ppsspp_headless
|
||||
LOCAL_SRC_FILES := \
|
||||
$(SRC)/headless/Headless.cpp \
|
||||
$(SRC)/headless/StubHost.cpp \
|
||||
$(SRC)/headless/Compare.cpp
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
@@ -1200,26 +1200,20 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
||||
NativeApp.sendMessage("permission_granted", "storage");
|
||||
}
|
||||
} else if (command.equals("gps_command")) {
|
||||
switch (params) {
|
||||
case "open":
|
||||
if(!askForPermissions(permissionsForLocation, REQUEST_CODE_LOCATION_PERMISSION)) {
|
||||
mLocationHelper.startLocationUpdates();
|
||||
}
|
||||
break;
|
||||
case "close":
|
||||
mLocationHelper.stopLocationUpdates();
|
||||
break;
|
||||
if (params.equals("open")) {
|
||||
if (!askForPermissions(permissionsForLocation, REQUEST_CODE_LOCATION_PERMISSION)) {
|
||||
mLocationHelper.startLocationUpdates();
|
||||
}
|
||||
} else if (params.equals("close")) {
|
||||
mLocationHelper.stopLocationUpdates();
|
||||
}
|
||||
} else if (command.equals("camera_command")) {
|
||||
switch (params) {
|
||||
case "startVideo":
|
||||
if(!askForPermissions(permissionsForCamera, REQUEST_CODE_CAMERA_PERMISSION)) {
|
||||
mCameraHelper.startCamera();
|
||||
}
|
||||
break;
|
||||
case "stopVideo":
|
||||
mCameraHelper.stopCamera();
|
||||
break;
|
||||
if (params.equals("startVideo")) {
|
||||
if (!askForPermissions(permissionsForCamera, REQUEST_CODE_CAMERA_PERMISSION)) {
|
||||
mCameraHelper.startCamera();
|
||||
}
|
||||
} else if (params.equals("stopVideo")) {
|
||||
mCameraHelper.stopCamera();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -155,6 +155,7 @@ bd1200000000000015d0000000000000,Tomee SNES USB Controller,x:b3,a:b2,b:b1,y:b0,b
|
||||
05000000102800000900000000010000,8Bitdo SFC30 GamePad,platform:Linux,x:b4,a:b1,b:b0,y:b3,back:b10,start:b11,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,
|
||||
03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,platform:Linux,a:b1,b:b2,y:b3,x:b0,start:b12,guide:b9,back:b8,leftshoulder:b4,rightshoulder:b5,lefttrigger:b6,righttrigger:b7,leftx:a0,lefty:a1,
|
||||
030000000d0f00000d00000000010000,hori,platform:Linux,a:b0,b:b6,y:b2,x:b1,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,start:b9,guide:b10,back:b8,leftshoulder:b3,rightshoulder:b7,leftx:b4,lefty:b5,
|
||||
030000000d0f00006700000001010000,HORIPAD ONE,platform:Linux,a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,guide:b8,leftshoulder:b4,rightshoulder:b5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,
|
||||
03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,platform:Linux,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,
|
||||
03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,platform:Linux,a:b0,b:b1,y:b2,x:b3,start:b9,back:b8,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,lefttrigger:b6,righttrigger:b7,
|
||||
03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),platform:Linux,a:b3,b:b4,y:b1,x:b0,start:b7,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,
|
||||
@@ -181,3 +182,5 @@ bd1200000000000015d0000000000000,Tomee SNES USB Controller,x:b3,a:b2,b:b1,y:b0,b
|
||||
050000004c050000cc09000000810000,Wireless Controller,platform:Linux,x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
||||
030000004c0500006802000011810000,Sony PLAYSTATION(R)3 Controller,platform:Linux,x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
||||
050000004c0500006802000000810000,PLAYSTATION(R)3 Controller,platform:Linux,x:b3,a:b0,b:b1,y:b2,back:b8,guide:b10,start:b9,dpleft:b15,dpdown:b14,dpright:b16,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b6,rightshoulder:b5,righttrigger:a5,leftstick:b7,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,
|
||||
03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,platform:Linux,a:b1,b:b0,x:b4,y:b3,back:b10,start:b11,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,
|
||||
05000000c82d00002038000000010000,8Bitdo NES30 Pro,platform:Linux,a:b1,b:b0,x:b4,y:b3,back:b10,guide:b2,start:b11,leftstick:b13,rightstick:b14,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,
|
||||
+1
-1
Submodule assets/lang updated: 7b31a30fd0...c31a1d3096.
+32
-27
@@ -558,10 +558,40 @@ int main(int argc, char *argv[]) {
|
||||
dp_xres = (float)pixel_xres * dpi_scale;
|
||||
dp_yres = (float)pixel_yres * dpi_scale;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// VFSRegister("temp/", new DirectoryAssetReader("E:\\Temp\\"));
|
||||
TCHAR path[MAX_PATH];
|
||||
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path);
|
||||
PathAppend(path, (app_name + "\\").c_str());
|
||||
#else
|
||||
// Mac / Linux
|
||||
char path[2048];
|
||||
const char *the_path = getenv("HOME");
|
||||
if (!the_path) {
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
if (pwd)
|
||||
the_path = pwd->pw_dir;
|
||||
}
|
||||
strcpy(path, the_path);
|
||||
if (path[strlen(path)-1] != '/')
|
||||
strcat(path, "/");
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
NativeInit(remain_argc, (const char **)remain_argv, path, "D:\\", nullptr);
|
||||
#else
|
||||
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
|
||||
#endif
|
||||
|
||||
// Use the setting from the config when initing the window.
|
||||
if (g_Config.bFullScreen)
|
||||
mode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
|
||||
g_Screen = SDL_CreateWindow(app_name_nice.c_str(), SDL_WINDOWPOS_UNDEFINED_DISPLAY(getDisplayNumber()),\
|
||||
SDL_WINDOWPOS_UNDEFINED, pixel_xres, pixel_yres, mode);
|
||||
|
||||
if (g_Screen == NULL) {
|
||||
NativeShutdown();
|
||||
fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
return 2;
|
||||
@@ -569,6 +599,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
SDL_GLContext glContext = SDL_GL_CreateContext(g_Screen);
|
||||
if (glContext == NULL) {
|
||||
NativeShutdown();
|
||||
fprintf(stderr, "SDL_GL_CreateContext failed: %s\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
return 2;
|
||||
@@ -606,30 +637,6 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// VFSRegister("temp/", new DirectoryAssetReader("E:\\Temp\\"));
|
||||
TCHAR path[MAX_PATH];
|
||||
SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path);
|
||||
PathAppend(path, (app_name + "\\").c_str());
|
||||
#else
|
||||
// Mac / Linux
|
||||
char path[2048];
|
||||
const char *the_path = getenv("HOME");
|
||||
if (!the_path) {
|
||||
struct passwd* pwd = getpwuid(getuid());
|
||||
if (pwd)
|
||||
the_path = pwd->pw_dir;
|
||||
}
|
||||
strcpy(path, the_path);
|
||||
if (path[strlen(path)-1] != '/')
|
||||
strcat(path, "/");
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
NativeInit(remain_argc, (const char **)remain_argv, path, "D:\\", nullptr);
|
||||
#else
|
||||
NativeInit(remain_argc, (const char **)remain_argv, path, "/tmp", nullptr);
|
||||
#endif
|
||||
|
||||
pixel_in_dps_x = (float)pixel_xres / dp_xres;
|
||||
pixel_in_dps_y = (float)pixel_yres / dp_yres;
|
||||
@@ -711,7 +718,6 @@ int main(int argc, char *argv[]) {
|
||||
dp_yres = (float)pixel_yres * dpi_scale;
|
||||
NativeResized();
|
||||
|
||||
#if defined(PPSSPP)
|
||||
// Set variable here in case fullscreen was toggled by hotkey
|
||||
g_Config.bFullScreen = fullscreen;
|
||||
|
||||
@@ -721,7 +727,6 @@ int main(int argc, char *argv[]) {
|
||||
} else if (lastUIState != UISTATE_INGAME || !fullscreen) {
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -860,7 +865,7 @@ int main(int argc, char *argv[]) {
|
||||
UpdateRunLoop();
|
||||
if (g_QuitRequested)
|
||||
break;
|
||||
#if defined(PPSSPP) && !defined(MOBILE_DEVICE)
|
||||
#if !defined(MOBILE_DEVICE)
|
||||
if (lastUIState != GetUIState()) {
|
||||
lastUIState = GetUIState();
|
||||
if (lastUIState == UISTATE_INGAME && g_Config.bFullScreen && !g_Config.bShowTouchControls)
|
||||
|
||||
@@ -394,7 +394,7 @@ void CheckGLExtensions() {
|
||||
#endif
|
||||
|
||||
// This is probably a waste of time, implementations lie.
|
||||
if (gl_extensions.IsGLES || strstr(extString, "GL_ARB_ES2_compatibility")) {
|
||||
if (gl_extensions.IsGLES || strstr(extString, "GL_ARB_ES2_compatibility") || gl_extensions.VersionGEThan(4, 1)) {
|
||||
const GLint precisions[6] = {
|
||||
GL_LOW_FLOAT, GL_MEDIUM_FLOAT, GL_HIGH_FLOAT,
|
||||
GL_LOW_INT, GL_MEDIUM_INT, GL_HIGH_INT
|
||||
@@ -419,6 +419,47 @@ void CheckGLExtensions() {
|
||||
gl_extensions.ARB_vertex_array_object = true;
|
||||
gl_extensions.ARB_framebuffer_object = true;
|
||||
}
|
||||
|
||||
// Add any extensions that are included in core. May be elided.
|
||||
if (!gl_extensions.IsGLES) {
|
||||
if (gl_extensions.VersionGEThan(3, 0)) {
|
||||
gl_extensions.ARB_texture_float = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(3, 1)) {
|
||||
gl_extensions.ARB_draw_instanced = true;
|
||||
// ARB_uniform_buffer_object = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(3, 2)) {
|
||||
// ARB_depth_clamp = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(3, 3)) {
|
||||
gl_extensions.ARB_blend_func_extended = true;
|
||||
// ARB_explicit_attrib_location = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(4, 0)) {
|
||||
// ARB_gpu_shader5 = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(4, 1)) {
|
||||
// ARB_get_program_binary = true;
|
||||
// ARB_separate_shader_objects = true;
|
||||
// ARB_shader_precision = true;
|
||||
// ARB_viewport_array = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(4, 2)) {
|
||||
// ARB_texture_storage = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(4, 3)) {
|
||||
gl_extensions.ARB_copy_image = true;
|
||||
// ARB_explicit_uniform_location = true;
|
||||
// ARB_stencil_texturing = true;
|
||||
// ARB_texture_view = true;
|
||||
// ARB_vertex_attrib_binding = true;
|
||||
}
|
||||
if (gl_extensions.VersionGEThan(4, 4)) {
|
||||
// ARB_buffer_storage = true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
if (!gl_extensions.IsGLES && !gl_extensions.IsCoreContext) {
|
||||
// Apple doesn't allow OpenGL 3.x+ in compatibility contexts.
|
||||
@@ -444,3 +485,31 @@ void SetGLCoreContext(bool flag) {
|
||||
// For convenience, it'll get reset later.
|
||||
gl_extensions.IsCoreContext = useCoreContext;
|
||||
}
|
||||
|
||||
static const char *glsl_fragment_prelude =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision mediump float;\n"
|
||||
"#endif\n";
|
||||
|
||||
std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage) {
|
||||
std::string temp;
|
||||
std::string version = "";
|
||||
if (!gl_extensions.IsGLES && gl_extensions.IsCoreContext) {
|
||||
// We need to add a corresponding #version. Apple drives fail without an exact match.
|
||||
if (gl_extensions.VersionGEThan(3, 3)) {
|
||||
version = StringFromFormat("#version %d%d0\n", gl_extensions.ver[0], gl_extensions.ver[1]);
|
||||
} else if (gl_extensions.VersionGEThan(3, 2)) {
|
||||
version = "#version 150\n";
|
||||
} else if (gl_extensions.VersionGEThan(3, 1)) {
|
||||
version = "#version 140\n";
|
||||
} else {
|
||||
version = "#version 130\n";
|
||||
}
|
||||
}
|
||||
if (stage == GL_FRAGMENT_SHADER) {
|
||||
temp = version + glsl_fragment_prelude + source;
|
||||
} else if (stage == GL_VERTEX_SHADER) {
|
||||
temp = version + source;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "base/NativeApp.h"
|
||||
|
||||
enum {
|
||||
@@ -110,3 +111,5 @@ extern std::string g_all_egl_extensions;
|
||||
|
||||
void CheckGLExtensions();
|
||||
void SetGLCoreContext(bool flag);
|
||||
|
||||
std::string ApplyGLSLPrelude(const std::string &source, uint32_t stage);
|
||||
@@ -69,6 +69,12 @@ static const std::vector<ShaderSource> fsTexCol = {
|
||||
"#ifdef GL_ES\n"
|
||||
"precision lowp float;\n"
|
||||
"#endif\n"
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define varying in\n"
|
||||
"#define texture2D texture\n"
|
||||
"#define gl_FragColor fragColor0\n"
|
||||
"out vec4 fragColor0;\n"
|
||||
"#endif\n"
|
||||
"varying vec4 oColor0;\n"
|
||||
"varying vec2 oTexCoord0;\n"
|
||||
"uniform sampler2D Sampler0;\n"
|
||||
@@ -107,6 +113,11 @@ static const std::vector<ShaderSource> fsCol = {
|
||||
"#ifdef GL_ES\n"
|
||||
"precision lowp float;\n"
|
||||
"#endif\n"
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define varying in\n"
|
||||
"#define gl_FragColor fragColor0\n"
|
||||
"out vec4 fragColor0;\n"
|
||||
"#endif\n"
|
||||
"varying vec4 oColor0;\n"
|
||||
"void main() { gl_FragColor = oColor0; }\n"
|
||||
},
|
||||
@@ -136,6 +147,10 @@ static const std::vector<ShaderSource> fsCol = {
|
||||
|
||||
static const std::vector<ShaderSource> vsCol = {
|
||||
{ ShaderLanguage::GLSL_ES_200,
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define attribute in\n"
|
||||
"#define varying out\n"
|
||||
"#endif\n"
|
||||
"attribute vec3 Position;\n"
|
||||
"attribute vec4 Color0;\n"
|
||||
"varying vec4 oColor0;\n"
|
||||
@@ -193,6 +208,10 @@ const UniformBufferDesc vsColBufDesc { sizeof(VsColUB), {
|
||||
|
||||
static const std::vector<ShaderSource> vsTexCol = {
|
||||
{ ShaderLanguage::GLSL_ES_200,
|
||||
"#if __VERSION__ >= 130\n"
|
||||
"#define attribute in\n"
|
||||
"#define varying out\n"
|
||||
"#endif\n"
|
||||
"attribute vec3 Position;\n"
|
||||
"attribute vec4 Color0;\n"
|
||||
"attribute vec2 TexCoord0;\n"
|
||||
@@ -285,4 +304,4 @@ DrawContext::~DrawContext() {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Draw
|
||||
} // namespace Draw
|
||||
@@ -163,11 +163,6 @@ static const unsigned short primToGL[] = {
|
||||
|
||||
class OpenGLBuffer;
|
||||
|
||||
static const char *glsl_fragment_prelude =
|
||||
"#ifdef GL_ES\n"
|
||||
"precision mediump float;\n"
|
||||
"#endif\n";
|
||||
|
||||
class OpenGLBlendState : public BlendState {
|
||||
public:
|
||||
bool enabled;
|
||||
@@ -332,9 +327,9 @@ bool OpenGLShaderModule::Compile(ShaderLanguage language, const uint8_t *data, s
|
||||
language_ = language;
|
||||
|
||||
std::string temp;
|
||||
// Add the prelude on automatically for fragment shaders.
|
||||
if (glstage_ == GL_FRAGMENT_SHADER) {
|
||||
temp = std::string(glsl_fragment_prelude) + source_;
|
||||
// Add the prelude on automatically.
|
||||
if (glstage_ == GL_FRAGMENT_SHADER || glstage_ == GL_VERTEX_SHADER) {
|
||||
temp = ApplyGLSLPrelude(source_, glstage_);
|
||||
source_ = temp.c_str();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,10 @@
|
||||
|
||||
#include "Compare.h"
|
||||
#include "StubHost.h"
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
#include "WindowsHeadlessHost.h"
|
||||
#elif defined(SDL)
|
||||
#include "SDLHeadlessHost.h"
|
||||
#endif
|
||||
|
||||
// https://github.com/richq/android-ndk-profiler
|
||||
@@ -199,7 +201,7 @@ int main(int argc, const char* argv[])
|
||||
{
|
||||
PROFILE_INIT();
|
||||
|
||||
#ifdef _DEBUG
|
||||
#if defined(_DEBUG) && defined(_MSC_VER)
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -237,6 +237,13 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SDLHeadlessHost.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StubHost.cpp" />
|
||||
<ClCompile Include="WindowsHeadlessHost.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -268,6 +275,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Compare.h" />
|
||||
<ClInclude Include="SDLHeadlessHost.h" />
|
||||
<ClInclude Include="StubHost.h" />
|
||||
<ClInclude Include="WindowsHeadlessHost.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
<ClCompile Include="..\Windows\GPU\D3D11Context.cpp">
|
||||
<Filter>Windows</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StubHost.cpp" />
|
||||
<ClCompile Include="SDLHeadlessHost.cpp">
|
||||
<Filter>Other Platforms</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="headless.txt" />
|
||||
@@ -33,10 +37,16 @@
|
||||
<ClInclude Include="WindowsHeadlessHost.h">
|
||||
<Filter>Windows</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SDLHeadlessHost.h">
|
||||
<Filter>Other Platforms</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Windows">
|
||||
<UniqueIdentifier>{28215e85-3e11-4a8a-8b4d-3e355b85a542}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Other Platforms">
|
||||
<UniqueIdentifier>{d34ba935-dcca-4f21-a869-5d0b3bba7478}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -0,0 +1,143 @@
|
||||
// Copyright (c) 2017- 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/.
|
||||
|
||||
#ifdef SDL
|
||||
|
||||
#include <stdio.h>
|
||||
#include <SDL.h>
|
||||
#include "gfx/gl_lost_manager.h"
|
||||
|
||||
#include "headless/SDLHeadlessHost.h"
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/GraphicsContext.h"
|
||||
|
||||
#include "Core/CoreParameter.h"
|
||||
#include "Core/System.h"
|
||||
#include "GPU/Common/GPUDebugInterface.h"
|
||||
#include "GPU/GPUState.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "gfx/gl_common.h"
|
||||
#include "gfx_es2/gpu_features.h"
|
||||
#include "file/vfs.h"
|
||||
#include "file/zip_read.h"
|
||||
|
||||
const bool WINDOW_VISIBLE = false;
|
||||
const int WINDOW_WIDTH = 480;
|
||||
const int WINDOW_HEIGHT = 272;
|
||||
|
||||
SDL_Window *CreateHiddenWindow() {
|
||||
Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS;
|
||||
if (!WINDOW_VISIBLE) {
|
||||
flags |= SDL_WINDOW_HIDDEN;
|
||||
}
|
||||
return SDL_CreateWindow("PPSSPPHeadless", 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, flags);
|
||||
}
|
||||
|
||||
class GLDummyGraphicsContext : public DummyGraphicsContext {
|
||||
public:
|
||||
GLDummyGraphicsContext() {
|
||||
CheckGLExtensions();
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
}
|
||||
~GLDummyGraphicsContext() { delete draw_; }
|
||||
|
||||
Draw::DrawContext *GetDrawContext() override {
|
||||
return draw_;
|
||||
}
|
||||
|
||||
private:
|
||||
Draw::DrawContext *draw_;
|
||||
};
|
||||
|
||||
void SDLHeadlessHost::LoadNativeAssets() {
|
||||
VFSRegister("", new DirectoryAssetReader("assets/"));
|
||||
VFSRegister("", new DirectoryAssetReader(""));
|
||||
VFSRegister("", new DirectoryAssetReader("../"));
|
||||
}
|
||||
|
||||
bool SDLHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
// TODO
|
||||
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
//SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
|
||||
screen_ = CreateHiddenWindow();
|
||||
glContext_ = SDL_GL_CreateContext(screen_);
|
||||
|
||||
#ifndef USING_GLES2
|
||||
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
|
||||
// glewExperimental allows us to force GLEW to search for the pointers anyway.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glewExperimental = true;
|
||||
if (GLEW_OK != glewInit()) {
|
||||
printf("Failed to initialize glew!\n");
|
||||
return false;
|
||||
}
|
||||
// Unfortunately, glew will generate an invalid enum error, ignore.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glGetError();
|
||||
|
||||
if (GLEW_VERSION_2_0) {
|
||||
printf("OpenGL 2.0 or higher.\n");
|
||||
} else {
|
||||
printf("Sorry, this program requires OpenGL 2.0.\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
gl_lost_manager_init();
|
||||
|
||||
GraphicsContext *graphicsContext = new GLDummyGraphicsContext();
|
||||
*ctx = graphicsContext;
|
||||
gfx_ = graphicsContext;
|
||||
|
||||
LoadNativeAssets();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDLHeadlessHost::ShutdownGraphics() {
|
||||
gfx_->Shutdown();
|
||||
delete gfx_;
|
||||
gfx_ = nullptr;
|
||||
|
||||
SDL_GL_DeleteContext(glContext_);
|
||||
glContext_ = nullptr;
|
||||
SDL_DestroyWindow(screen_);
|
||||
screen_ = nullptr;
|
||||
|
||||
gl_lost_manager_shutdown();
|
||||
}
|
||||
|
||||
void SDLHeadlessHost::SwapBuffers() {
|
||||
gfx_->SwapBuffers();
|
||||
SDL_GL_SwapWindow(screen_);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2017- 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
|
||||
|
||||
#ifdef SDL
|
||||
|
||||
#include "headless/StubHost.h"
|
||||
|
||||
#undef HEADLESSHOST_CLASS
|
||||
#define HEADLESSHOST_CLASS SDLHeadlessHost
|
||||
|
||||
struct SDL_Window;
|
||||
typedef void *SDL_GLContext;
|
||||
|
||||
class SDLHeadlessHost : public HeadlessHost
|
||||
{
|
||||
public:
|
||||
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
|
||||
void ShutdownGraphics() override;
|
||||
|
||||
void SwapBuffers() override;
|
||||
|
||||
protected:
|
||||
void LoadNativeAssets();
|
||||
|
||||
SDL_Window *screen_;
|
||||
SDL_GLContext glContext_;
|
||||
GraphicsContext *gfx_;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
// Copyright (c) 2017- 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 "Common/FileUtil.h"
|
||||
#include "Core/CoreParameter.h"
|
||||
#include "Core/System.h"
|
||||
#include "GPU/Common/GPUDebugInterface.h"
|
||||
#include "headless/Compare.h"
|
||||
#include "headless/StubHost.h"
|
||||
|
||||
void HeadlessHost::SendOrCollectDebugOutput(const std::string &data)
|
||||
{
|
||||
if (PSP_CoreParameter().printfEmuLog)
|
||||
SendDebugOutput(data);
|
||||
else if (PSP_CoreParameter().collectEmuLog)
|
||||
*PSP_CoreParameter().collectEmuLog += data;
|
||||
else
|
||||
DEBUG_LOG(COMMON, "%s", data.c_str());
|
||||
}
|
||||
|
||||
void HeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h)
|
||||
{
|
||||
if (!gfx_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only if we're actually comparing.
|
||||
if (comparisonScreenshot_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We ignore the current framebuffer parameters and just grab the full screen.
|
||||
const static u32 FRAME_STRIDE = 512;
|
||||
const static u32 FRAME_WIDTH = 480;
|
||||
const static u32 FRAME_HEIGHT = 272;
|
||||
|
||||
GPUDebugBuffer buffer;
|
||||
gpuDebug->GetCurrentFramebuffer(buffer, GPU_DBG_FRAMEBUF_RENDER);
|
||||
const std::vector<u32> pixels = TranslateDebugBufferToCompare(&buffer, 512, 272);
|
||||
|
||||
std::string error;
|
||||
double errors = CompareScreenshot(pixels, FRAME_STRIDE, FRAME_WIDTH, FRAME_HEIGHT, comparisonScreenshot_, error);
|
||||
if (errors < 0)
|
||||
SendOrCollectDebugOutput(error);
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
char temp[256];
|
||||
snprintf(temp, sizeof(temp), "Screenshot error: %f%%\n", errors * 100.0f);
|
||||
SendOrCollectDebugOutput(temp);
|
||||
}
|
||||
|
||||
if (errors > 0 && !teamCityMode)
|
||||
{
|
||||
// Lazy, just read in the original header to output the failed screenshot.
|
||||
u8 header[14 + 40] = {0};
|
||||
FILE *bmp = File::OpenCFile(comparisonScreenshot_, "rb");
|
||||
if (bmp)
|
||||
{
|
||||
fread(&header, sizeof(header), 1, bmp);
|
||||
fclose(bmp);
|
||||
}
|
||||
|
||||
FILE *saved = File::OpenCFile("__testfailure.bmp", "wb");
|
||||
if (saved)
|
||||
{
|
||||
fwrite(&header, sizeof(header), 1, saved);
|
||||
fwrite(pixels.data(), sizeof(u32), FRAME_STRIDE * FRAME_HEIGHT, saved);
|
||||
fclose(saved);
|
||||
|
||||
SendOrCollectDebugOutput("Actual output written to: __testfailure.bmp\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -64,13 +64,21 @@ public:
|
||||
debugOutputBuffer_.clear();
|
||||
}
|
||||
}
|
||||
virtual void SetComparisonScreenshot(const std::string &filename) {}
|
||||
|
||||
virtual void SetComparisonScreenshot(const std::string &filename) {
|
||||
comparisonScreenshot_ = filename;
|
||||
}
|
||||
|
||||
void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) override;
|
||||
|
||||
// Unique for HeadlessHost
|
||||
virtual void SwapBuffers() {}
|
||||
|
||||
protected:
|
||||
void SendOrCollectDebugOutput(const std::string &output);
|
||||
|
||||
std::string comparisonScreenshot_;
|
||||
std::string debugOutputBuffer_;
|
||||
GPUCore gpuCore_;
|
||||
GraphicsContext *gfx_ = nullptr;
|
||||
};
|
||||
@@ -17,8 +17,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "WindowsHeadlessHost.h"
|
||||
#include "Compare.h"
|
||||
#include "headless/WindowsHeadlessHost.h"
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/CommonWindows.h"
|
||||
@@ -78,72 +77,6 @@ void WindowsHeadlessHost::SendDebugOutput(const std::string &output)
|
||||
OutputDebugStringUTF8(output.c_str());
|
||||
}
|
||||
|
||||
void WindowsHeadlessHost::SendOrCollectDebugOutput(const std::string &data)
|
||||
{
|
||||
if (PSP_CoreParameter().printfEmuLog)
|
||||
SendDebugOutput(data);
|
||||
else if (PSP_CoreParameter().collectEmuLog)
|
||||
*PSP_CoreParameter().collectEmuLog += data;
|
||||
else
|
||||
DEBUG_LOG(COMMON, "%s", data.c_str());
|
||||
}
|
||||
|
||||
void WindowsHeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h)
|
||||
{
|
||||
// Only if we're actually comparing.
|
||||
if (comparisonScreenshot.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We ignore the current framebuffer parameters and just grab the full screen.
|
||||
const static u32 FRAME_STRIDE = 512;
|
||||
const static u32 FRAME_WIDTH = 480;
|
||||
const static u32 FRAME_HEIGHT = 272;
|
||||
|
||||
GPUDebugBuffer buffer;
|
||||
gpuDebug->GetCurrentFramebuffer(buffer, GPU_DBG_FRAMEBUF_RENDER);
|
||||
const std::vector<u32> pixels = TranslateDebugBufferToCompare(&buffer, 512, 272);
|
||||
|
||||
std::string error;
|
||||
double errors = CompareScreenshot(pixels, FRAME_STRIDE, FRAME_WIDTH, FRAME_HEIGHT, comparisonScreenshot, error);
|
||||
if (errors < 0)
|
||||
SendOrCollectDebugOutput(error);
|
||||
|
||||
if (errors > 0)
|
||||
{
|
||||
char temp[256];
|
||||
sprintf_s(temp, "Screenshot error: %f%%\n", errors * 100.0f);
|
||||
SendOrCollectDebugOutput(temp);
|
||||
}
|
||||
|
||||
if (errors > 0 && !teamCityMode)
|
||||
{
|
||||
// Lazy, just read in the original header to output the failed screenshot.
|
||||
u8 header[14 + 40] = {0};
|
||||
FILE *bmp = File::OpenCFile(comparisonScreenshot, "rb");
|
||||
if (bmp)
|
||||
{
|
||||
fread(&header, sizeof(header), 1, bmp);
|
||||
fclose(bmp);
|
||||
}
|
||||
|
||||
FILE *saved = File::OpenCFile("__testfailure.bmp", "wb");
|
||||
if (saved)
|
||||
{
|
||||
fwrite(&header, sizeof(header), 1, saved);
|
||||
fwrite(pixels.data(), sizeof(u32), FRAME_STRIDE * FRAME_HEIGHT, saved);
|
||||
fclose(saved);
|
||||
|
||||
SendOrCollectDebugOutput("Actual output written to: __testfailure.bmp\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WindowsHeadlessHost::SetComparisonScreenshot(const std::string &filename)
|
||||
{
|
||||
comparisonScreenshot = filename;
|
||||
}
|
||||
|
||||
bool WindowsHeadlessHost::InitGraphics(std::string *error_message, GraphicsContext **ctx) {
|
||||
hWnd = CreateHiddenWindow();
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "StubHost.h"
|
||||
#include "headless/StubHost.h"
|
||||
|
||||
#undef HEADLESSHOST_CLASS
|
||||
#define HEADLESSHOST_CLASS WindowsHeadlessHost
|
||||
@@ -28,22 +28,18 @@
|
||||
class WindowsHeadlessHost : public HeadlessHost
|
||||
{
|
||||
public:
|
||||
virtual bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
|
||||
virtual void ShutdownGraphics() override;
|
||||
bool InitGraphics(std::string *error_message, GraphicsContext **ctx) override;
|
||||
void ShutdownGraphics() override;
|
||||
|
||||
virtual void SwapBuffers() override;
|
||||
void SwapBuffers() override;
|
||||
|
||||
virtual void SendDebugOutput(const std::string &output) override;
|
||||
virtual void SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) override;
|
||||
virtual void SetComparisonScreenshot(const std::string &filename) override;
|
||||
void SendDebugOutput(const std::string &output) override;
|
||||
|
||||
protected:
|
||||
void LoadNativeAssets();
|
||||
void SendOrCollectDebugOutput(const std::string &output);
|
||||
|
||||
HWND hWnd;
|
||||
HDC hDC;
|
||||
HGLRC hRC;
|
||||
GraphicsContext *gfx_;
|
||||
std::string comparisonScreenshot;
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user