From 7652659dcce563a2700cac553782b55e435cc9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 16 Nov 2015 08:47:40 -0800 Subject: [PATCH] Updated Remotery. --- 3rdparty/remotery/lib/Remotery.c | 128 ++++++++++++++++--------------- 3rdparty/remotery/lib/Remotery.h | 9 +++ 2 files changed, 75 insertions(+), 62 deletions(-) diff --git a/3rdparty/remotery/lib/Remotery.c b/3rdparty/remotery/lib/Remotery.c index f739df200..0653029f4 100644 --- a/3rdparty/remotery/lib/Remotery.c +++ b/3rdparty/remotery/lib/Remotery.c @@ -47,74 +47,15 @@ #define RMT_IMPL #include "Remotery.h" + #ifdef RMT_PLATFORM_WINDOWS #pragma comment(lib, "ws2_32.lib") #endif -#ifdef __ANDROID__ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#define ASHMEM_DEVICE "/dev/ashmem" - -/* - * ashmem_create_region - creates a new ashmem region and returns the file - * descriptor, or <0 on error - * - * `name' is an optional label to give the region (visible in /proc/pid/maps) - * `size' is the size of the region, in page-aligned bytes - */ -int ashmem_create_region(const char *name, size_t size) -{ - int fd, ret; - - fd = open(ASHMEM_DEVICE, O_RDWR); - if (fd < 0) - return fd; - - if (name) { - char buf[ASHMEM_NAME_LEN] = {0}; - - strncpy(buf, name, sizeof(buf)); - buf[sizeof(buf)-1] = 0; - ret = ioctl(fd, ASHMEM_SET_NAME, buf); - if (ret < 0) - goto error; - } - - ret = ioctl(fd, ASHMEM_SET_SIZE, size); - if (ret < 0) - goto error; - - return fd; - -error: - close(fd); - return ret; -} -#endif // __ANDROID__ #if RMT_ENABLED + // Global settings static rmtSettings g_Settings; static rmtBool g_SettingsInitialized = RMT_FALSE; @@ -582,6 +523,69 @@ typedef struct VirtualMirrorBuffer } VirtualMirrorBuffer; +#ifdef __ANDROID__ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#define ASHMEM_DEVICE "/dev/ashmem" + +/* + * ashmem_create_region - creates a new ashmem region and returns the file + * descriptor, or <0 on error + * + * `name' is an optional label to give the region (visible in /proc/pid/maps) + * `size' is the size of the region, in page-aligned bytes + */ +int ashmem_create_region(const char *name, size_t size) +{ + int fd, ret; + + fd = open(ASHMEM_DEVICE, O_RDWR); + if (fd < 0) + return fd; + + if (name) { + char buf[ASHMEM_NAME_LEN] = {0}; + + strncpy(buf, name, sizeof(buf)); + buf[sizeof(buf)-1] = 0; + ret = ioctl(fd, ASHMEM_SET_NAME, buf); + if (ret < 0) + goto error; + } + + ret = ioctl(fd, ASHMEM_SET_SIZE, size); + if (ret < 0) + goto error; + + return fd; + +error: + close(fd); + return ret; +} +#endif // __ANDROID__ + + static rmtError VirtualMirrorBuffer_Constructor(VirtualMirrorBuffer* buffer, rmtU32 size, int nb_attempts) { static const rmtU32 k_64 = 64 * 1024; @@ -1266,7 +1270,7 @@ static const char* hex_encoding_table = "0123456789ABCDEF"; static void itoahex_s( char *dest, rsize_t dmax, rmtS32 value ) { rsize_t len; - rmtS32 halfbytepos; + rmtS32 halfbytepos; halfbytepos = 8; diff --git a/3rdparty/remotery/lib/Remotery.h b/3rdparty/remotery/lib/Remotery.h index d6c692b76..803a596d2 100644 --- a/3rdparty/remotery/lib/Remotery.h +++ b/3rdparty/remotery/lib/Remotery.h @@ -290,6 +290,9 @@ typedef enum rmtError _rmt_BeginCPUSample(#name, &rmt_sample_hash_##name); \ }) +#define rmt_BeginCPUSampleDynamic(namestr) \ + RMT_OPTIONAL(RMT_ENABLED, _rmt_BeginCPUSample(namestr, NULL)) + #define rmt_EndCPUSample() \ RMT_OPTIONAL(RMT_ENABLED, _rmt_EndCPUSample()) @@ -385,6 +388,9 @@ typedef struct rmtCUDABind _rmt_BeginD3D11Sample(#name, &rmt_sample_hash_##name); \ }) +#define rmt_BeginD3D11SampleDynamic(namestr) \ + RMT_OPTIONAL(RMT_USE_D3D11, _rmt_BeginD3D11Sample(namestr, NULL)) + #define rmt_EndD3D11Sample() \ RMT_OPTIONAL(RMT_USE_D3D11, _rmt_EndD3D11Sample()) @@ -401,6 +407,9 @@ typedef struct rmtCUDABind _rmt_BeginOpenGLSample(#name, &rmt_sample_hash_##name); \ }) +#define rmt_BeginOpenGLSampleDynamic(namestr) \ + RMT_OPTIONAL(RMT_USE_OPENGL, _rmt_BeginOpenGLSample(namestr, NULL)) + #define rmt_EndOpenGLSample() \ RMT_OPTIONAL(RMT_USE_OPENGL, _rmt_EndOpenGLSample())