diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt index ef1234dd47..e6606715ed 100644 --- a/qrenderdoc/CMakeLists.txt +++ b/qrenderdoc/CMakeLists.txt @@ -159,6 +159,10 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.24") cmake_policy(SET CMP0135 NEW) endif() +if(FREEBSD) + set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};/usr/local/include") +endif() + CHECK_INCLUDE_FILE(pcre.h PCRE_HEADER) set(PCRE_PREFIX_PATH "") diff --git a/renderdoc/CMakeLists.txt b/renderdoc/CMakeLists.txt index 3735c5d66d..1cbd5a0221 100644 --- a/renderdoc/CMakeLists.txt +++ b/renderdoc/CMakeLists.txt @@ -632,7 +632,11 @@ target_link_libraries(renderdoc ${RDOC_LIBRARIES}) add_dependencies(renderdoc renderdoc_libentry) if(UNIX AND NOT ANDROID AND NOT APPLE) - set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/${RDOC_BASE_NAME}.version") + if(FREEBSD) + set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry") + else() + set(RDOC_LINK_FLAGS "-Wl,--undefined,force_include_libentry -Wl,--version-script,${CMAKE_CURRENT_SOURCE_DIR}/${RDOC_BASE_NAME}.version") + endif() if(NOT ENABLE_ASAN AND NOT ENABLE_TSAN) set(RDOC_LINK_FLAGS "${RDOC_LINK_FLAGS} -Wl,--no-undefined") diff --git a/renderdoc/os/posix/bsd/bsd_hook.cpp b/renderdoc/os/posix/bsd/bsd_hook.cpp index bce1a599f6..a5e02ab8e2 100644 --- a/renderdoc/os/posix/bsd/bsd_hook.cpp +++ b/renderdoc/os/posix/bsd/bsd_hook.cpp @@ -428,7 +428,7 @@ static void CheckLoadedLibraries() for(FunctionLoadCallback cb : callbacks) if(cb) - cb(handle); + cb(handle, libName.c_str()); } } @@ -470,7 +470,7 @@ void *intercept_dlopen(const char *filename, int flag, void *ret) for(FunctionLoadCallback cb : callbacks) if(cb) - cb(ret); + cb(ret, libName.c_str()); ret = realdlopen("lib" STRINGIZE(RDOC_BASE_NAME) ".so", flag); break; diff --git a/renderdoc/os/posix/bsd/bsd_threading.cpp b/renderdoc/os/posix/bsd/bsd_threading.cpp index 8b81105ad0..0dd8904201 100644 --- a/renderdoc/os/posix/bsd/bsd_threading.cpp +++ b/renderdoc/os/posix/bsd/bsd_threading.cpp @@ -24,6 +24,11 @@ #include "os/os_specific.h" +#include "common/common.h" + +#include +#include +#include #include #include @@ -41,4 +46,78 @@ uint64_t Timing::GetTick() void Threading::SetCurrentThreadName(const rdcstr &name) { + // only substantial difference from linux_threading.cpp + pthread_setname_np(pthread_self(), name.c_str()); +} + +uint32_t Threading::NumberOfCores() +{ + long ret = sysconf(_SC_NPROCESSORS_ONLN); + if(ret <= 0) + return 1; + return uint32_t(ret); +} + +namespace Threading +{ + +// works for all posix except apple, hence being here +struct PosixSemaphore : public Semaphore +{ + ~PosixSemaphore() {} + + sem_t h; +}; + +Semaphore *Semaphore::Create() +{ + PosixSemaphore *sem = new PosixSemaphore(); + int err = sem_init(&sem->h, 0, 0); + // only documented errors are too large initial value (impossible for 0) or for shared semaphores + // going wrong (we're not shared) + RDCASSERT(err == 0, (int)errno); + return sem; } + +void Semaphore::Destroy() +{ + PosixSemaphore *sem = (PosixSemaphore *)this; + sem_destroy(&sem->h); + delete sem; +} + +void Semaphore::Wake(uint32_t numToWake) +{ + PosixSemaphore *sem = (PosixSemaphore *)this; + for(uint32_t i = 0; i < numToWake; i++) + sem_post(&sem->h); +} + +void Semaphore::WaitForWake() +{ + PosixSemaphore *sem = (PosixSemaphore *)this; + + // handle extremely moronic stupid signal interruptions + do + { + int ret = sem_wait(&sem->h); + + if(ret == -1) + { + if(errno == EINTR) + continue; + + RDCWARN("Semaphore wait failed: %d", errno); + } + } while(false); +} + +Semaphore::Semaphore() +{ +} + +Semaphore::~Semaphore() +{ +} + +};