Convert some glslang files to C (#14248)

* Convert some glslang files to C (OSIndependent files)

* Fix some strings that were preventing Unix from being compilable

* Remove leftover for Apple in griffin_glslang.cpp - fixes compilation
This commit is contained in:
LibretroAdmin 2022-07-29 17:42:10 +02:00 committed by GitHub
parent 3d69321c70
commit 454e6f9b07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 310 additions and 409 deletions

View File

@ -1868,8 +1868,9 @@ ifeq ($(HAVE_BUILTINGLSLANG), 1)
$(DEPS_DIR)/glslang/glslang/SPIRV/SpvBuilder.cpp \
$(wildcard $(DEPS_DIR)/glslang/glslang/OGLCompilersDLL/*.cpp) \
$(wildcard $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/*.cpp) \
$(wildcard $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/*.cpp) \
$(DEPS_DIR)/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM)/ossource.cpp
$(wildcard $(DEPS_DIR)/glslang/glslang/glslang/MachineIndependent/preprocessor/*.cpp)
GLSLANG_SOURCES_C += \
$(DEPS_DIR)/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM)/ossource.c
ifneq ($(findstring Win32,$(OS)),)
DEFINES += -DENABLE_HLSL
@ -1891,6 +1892,7 @@ endif
ifeq ($(HAVE_GLSLANG_COMMON), 1)
DEFINES += -DHAVE_GLSLANG
OBJ += $(GLSLANG_SOURCES_C:.c=.o)
OBJ += $(GLSLANG_SOURCES:.cpp=.o)
endif

View File

@ -1,14 +0,0 @@
set(SOURCES InitializeDll.cpp InitializeDll.h)
add_library(OGLCompiler STATIC ${SOURCES})
set_property(TARGET OGLCompiler PROPERTY FOLDER glslang)
set_property(TARGET OGLCompiler PROPERTY POSITION_INDEPENDENT_CODE ON)
if(WIN32)
source_group("Source" FILES ${SOURCES})
endif(WIN32)
if(ENABLE_GLSLANG_INSTALL)
install(TARGETS OGLCompiler
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(ENABLE_GLSLANG_INSTALL)

View File

@ -39,113 +39,97 @@
#include "../glslang/Public/ShaderLang.h"
#include "../glslang/Include/PoolAlloc.h"
namespace glslang {
static OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
// Per-process initialization.
// Needs to be called at least once before parsing, etc. is done.
// Will also do thread initialization for the calling thread; other
// threads will need to do that explicitly.
bool InitProcess()
/* Per-process initialization.
* Needs to be called at least once before parsing, etc. is done.
* Will also do thread initialization for the calling thread; other
* threads will need to do that explicitly.
*/
extern "C" bool InitProcess(void)
{
glslang::GetGlobalLock();
GetGlobalLock();
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX) {
//
// Function is re-entrant.
//
glslang::ReleaseGlobalLock();
if (ThreadInitializeIndex != OS_INVALID_TLS_INDEX)
{
/* Function is re-entrant. */
ReleaseGlobalLock();
return true;
}
ThreadInitializeIndex = OS_AllocTLSIndex();
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "InitProcess(): Failed to allocate TLS area for init flag");
glslang::ReleaseGlobalLock();
if ((ThreadInitializeIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
{
ReleaseGlobalLock();
return false;
}
if (! InitializePoolIndex()) {
assert(0 && "InitProcess(): Failed to initialize global pool");
glslang::ReleaseGlobalLock();
if (! InitializePoolIndex())
{
ReleaseGlobalLock();
return false;
}
if (! InitThread()) {
assert(0 && "InitProcess(): Failed to initialize thread");
glslang::ReleaseGlobalLock();
if (!InitThread())
{
ReleaseGlobalLock();
return false;
}
glslang::ReleaseGlobalLock();
ReleaseGlobalLock();
return true;
}
// Per-thread scoped initialization.
// Must be called at least once by each new thread sharing the
// symbol tables, etc., needed to parse.
bool InitThread()
/* Per-thread scoped initialization.
* Must be called at least once by each new thread sharing the
* symbol tables, etc., needed to parse.
*/
extern "C" bool InitThread(void)
{
//
// This function is re-entrant
//
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX) {
assert(0 && "InitThread(): Process hasn't been initalised.");
/* This function is re-entrant */
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return false;
}
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
return true;
if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1)) {
assert(0 && "InitThread(): Unable to set init flag.");
if (! OS_SetTLSValue(ThreadInitializeIndex, (void *)1))
return false;
}
glslang::SetThreadPoolAllocator(nullptr);
return true;
}
// Not necessary to call this: InitThread() is reentrant, and the need
// to do per thread tear down has been removed.
//
// This is kept, with memory management removed, to satisfy any exiting
// calls to it that rely on it.
bool DetachThread()
/* Not necessary to call this: InitThread() is reentrant, and the need
* to do per thread tear down has been removed.
*
* This is kept, with memory management removed, to satisfy any exiting
* calls to it that rely on it.
*/
extern "C" bool DetachThread(void)
{
bool success = true;
if (ThreadInitializeIndex == OS_INVALID_TLS_INDEX)
return true;
//
// Function is re-entrant and this thread may not have been initialized.
//
if (OS_GetTLSValue(ThreadInitializeIndex) != 0) {
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0)) {
assert(0 && "DetachThread(): Unable to clear init flag.");
success = false;
}
/* Function is re-entrant and this thread may not have been initialized. */
if (OS_GetTLSValue(ThreadInitializeIndex) != 0)
{
if (!OS_SetTLSValue(ThreadInitializeIndex, (void *)0))
return false;
}
return success;
return true;
}
// Not necessary to call this: InitProcess() is reentrant.
//
// This is kept, with memory management removed, to satisfy any exiting
// calls to it that rely on it.
//
// Users of glslang should call shFinalize() or glslang::FinalizeProcess() for
// process-scoped memory tear down.
bool DetachProcess()
/* Not necessary to call this: InitProcess() is reentrant.
*
* This is kept, with memory management removed, to satisfy any exiting
* calls to it that rely on it.
*
* Users of glslang should call shFinalize() or glslang::FinalizeProcess() for
* process-scoped memory tear down.
*/
extern "C" bool DetachProcess(void)
{
bool success = true;
@ -160,5 +144,3 @@ bool DetachProcess()
return success;
}
} // end namespace glslang

View File

@ -1,49 +1,53 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
/*
* Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of 3Dlabs Inc. Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __INITIALIZEDLL_H
#define __INITIALIZEDLL_H
#include "../glslang/OSDependent/osinclude.h"
namespace glslang {
#ifdef __cplusplus
extern "C" {
#endif
bool InitProcess();
bool InitThread();
bool DetachThread(); // not called from standalone, perhaps other tools rely on parts of it
bool DetachProcess(); // not called from standalone, perhaps other tools rely on parts of it
bool InitProcess(void);
bool InitThread(void);
bool DetachThread(void); /* not called from standalone, perhaps other tools rely on parts of it */
bool DetachProcess(void); /* not called from standalone, perhaps other tools rely on parts of it */
} // end namespace glslang
#endif // __INITIALIZEDLL_H
#ifdef __cplusplus
}
#endif
#endif /* __INITIALIZEDLL_H */

View File

@ -35,11 +35,15 @@
#ifndef __INITIALIZE_GLOBALS_INCLUDED_
#define __INITIALIZE_GLOBALS_INCLUDED_
namespace glslang {
#ifdef __cplusplus
extern "C" {
#endif
bool InitializePoolIndex();
bool DeinitializePoolIndex();
bool InitializePoolIndex(void);
bool DeinitializePoolIndex(void);
} // end namespace glslang
#ifdef __cplusplus
}
#endif
#endif // __INITIALIZE_GLOBALS_INCLUDED_

View File

@ -56,7 +56,7 @@ void SetThreadPoolAllocator(TPoolAllocator* poolAllocator)
}
// Process-wide set up of the TLS pool storage.
bool InitializePoolIndex()
extern "C" bool InitializePoolIndex(void)
{
// Allocate a TLS index.
if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
@ -65,7 +65,7 @@ bool InitializePoolIndex()
return true;
}
bool DeinitializePoolIndex()
extern "C" bool DeinitializePoolIndex(void)
{
if (PoolIndex == OS_INVALID_TLS_INDEX)
return false;

View File

@ -374,7 +374,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
TInfoSink infoSink;
// Make sure only one thread tries to do this at a time
glslang::GetGlobalLock();
GetGlobalLock();
// See if it's already been done for this version/profile combination
int versionIndex = MapVersionToIndex(version);
@ -382,8 +382,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
int profileIndex = MapProfileToIndex(profile);
int sourceIndex = MapSourceToIndex(source);
if (CommonSymbolTable[versionIndex][spvVersionIndex][profileIndex][sourceIndex][EPcGeneral]) {
glslang::ReleaseGlobalLock();
ReleaseGlobalLock();
return;
}
@ -433,7 +432,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
delete builtInPoolAllocator;
SetThreadPoolAllocator(&previousAllocator);
glslang::ReleaseGlobalLock();
ReleaseGlobalLock();
}
// Return true if the shader was correctly specified for version/profile/stage.
@ -1188,16 +1187,16 @@ static bool CompileDeferred(
//
// ShInitialize() should be called exactly once per process, not per thread.
//
int ShInitialize()
int ShInitialize(void)
{
glslang::InitGlobalLock();
InitGlobalLock();
if (! InitProcess())
return 0;
glslang::GetGlobalLock();
GetGlobalLock();
++NumberOfClients;
glslang::ReleaseGlobalLock();
ReleaseGlobalLock();
if (PerProcessGPA == nullptr)
PerProcessGPA = new TPoolAllocator();
@ -1213,13 +1212,13 @@ int ShInitialize()
//
// Cleanup symbol tables
//
int __fastcall ShFinalize()
int __fastcall ShFinalize(void)
{
glslang::GetGlobalLock();
GetGlobalLock();
--NumberOfClients;
assert(NumberOfClients >= 0);
bool finalize = NumberOfClients == 0;
glslang::ReleaseGlobalLock();
ReleaseGlobalLock();
if (! finalize)
return 1;

View File

@ -1,8 +0,0 @@
add_library(OSDependent STATIC ossource.cpp ../osinclude.h)
set_property(TARGET OSDependent PROPERTY FOLDER glslang)
set_property(TARGET OSDependent PROPERTY POSITION_INDEPENDENT_CODE ON)
if(ENABLE_GLSLANG_INSTALL)
install(TARGETS OSDependent
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(ENABLE_GLSLANG_INSTALL)

View File

@ -0,0 +1,108 @@
/*
* Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of 3Dlabs Inc. Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* This file contains the Linux-specific functions */
#include "../osinclude.h"
#include "../../../OGLCompilersDLL/InitializeDll.h"
#include <pthread.h>
#include <semaphore.h>
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>
static pthread_mutex_t glslang_global_lock;
/* Thread cleanup */
/* Thread Local Storage Operations */
#define TLS_INDEX_TO_PTHREAD_KEY(nIndex) ((pthread_key_t)((uintptr_t)(nIndex) - 1))
OS_TLSIndex OS_AllocTLSIndex(void)
{
pthread_key_t pPoolIndex;
/* Create global pool key. */
if ((pthread_key_create(&pPoolIndex, NULL)) != 0)
return OS_INVALID_TLS_INDEX;
return (OS_TLSIndex)((uintptr_t)pPoolIndex + 1);
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX)
return false;
if (pthread_setspecific(TLS_INDEX_TO_PTHREAD_KEY(nIndex), lpvValue) != 0)
return false;
return true;
}
void *OS_GetTLSValue(OS_TLSIndex nIndex)
{
/* This function should return 0 if nIndex is invalid. */
assert(nIndex != OS_INVALID_TLS_INDEX);
return pthread_getspecific(TLS_INDEX_TO_PTHREAD_KEY(nIndex));
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX)
return false;
/* Delete the global pool key. */
if (pthread_key_delete(TLS_INDEX_TO_PTHREAD_KEY(nIndex)) != 0)
return false;
return true;
}
void InitGlobalLock(void)
{
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&glslang_global_lock, &mutexattr);
}
void GetGlobalLock(void)
{
pthread_mutex_lock(&glslang_global_lock);
}
void ReleaseGlobalLock(void)
{
pthread_mutex_unlock(&glslang_global_lock);
}

View File

@ -1,139 +0,0 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
//
// This file contains the Linux-specific functions
//
#include "../osinclude.h"
#include "../../../OGLCompilersDLL/InitializeDll.h"
#include <pthread.h>
#include <semaphore.h>
#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <cstdio>
#include <sys/time.h>
#include <sys/resource.h>
namespace glslang {
//
// Thread cleanup
//
//
// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
// the cleanup routine to return void.
//
static void DetachThreadLinux(void *)
{
DetachThread();
}
//
// Thread Local Storage Operations
//
inline OS_TLSIndex PthreadKeyToTLSIndex(pthread_key_t key)
{
return (OS_TLSIndex)((uintptr_t)key + 1);
}
inline pthread_key_t TLSIndexToPthreadKey(OS_TLSIndex nIndex)
{
return (pthread_key_t)((uintptr_t)nIndex - 1);
}
OS_TLSIndex OS_AllocTLSIndex()
{
pthread_key_t pPoolIndex;
//
// Create global pool key.
//
if ((pthread_key_create(&pPoolIndex, NULL)) != 0)
return OS_INVALID_TLS_INDEX;
return PthreadKeyToTLSIndex(pPoolIndex);
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX)
return false;
if (pthread_setspecific(TLSIndexToPthreadKey(nIndex), lpvValue) != 0)
return false;
return true;
}
void* OS_GetTLSValue(OS_TLSIndex nIndex)
{
// This function should return 0 if nIndex is invalid.
assert(nIndex != OS_INVALID_TLS_INDEX);
return pthread_getspecific(TLSIndexToPthreadKey(nIndex));
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX)
return false;
// Delete the global pool key.
if (pthread_key_delete(TLSIndexToPthreadKey(nIndex)) != 0)
return false;
return true;
}
namespace {
pthread_mutex_t gMutex;
}
void InitGlobalLock()
{
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&gMutex, &mutexattr);
}
void GetGlobalLock()
{
pthread_mutex_lock(&gMutex);
}
void ReleaseGlobalLock()
{
pthread_mutex_unlock(&gMutex);
}
} // end namespace glslang

View File

@ -1,20 +0,0 @@
set(SOURCES ossource.cpp ../osinclude.h)
add_library(OSDependent STATIC ${SOURCES})
set_property(TARGET OSDependent PROPERTY FOLDER glslang)
set_property(TARGET OSDependent PROPERTY POSITION_INDEPENDENT_CODE ON)
# MinGW GCC complains about function pointer casts to void*.
# Turn that off with -fpermissive.
if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
target_compile_options(OSDependent PRIVATE -fpermissive)
endif()
if(WIN32)
source_group("Source" FILES ${SOURCES})
endif(WIN32)
if(ENABLE_GLSLANG_INSTALL)
install(TARGETS OSDependent
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(ENABLE_GLSLANG_INSTALL)

View File

@ -38,82 +38,60 @@
#define STRICT
#define VC_EXTRALEAN 1
#include <windows.h>
#include <cassert>
#include <process.h>
#include <psapi.h>
#include <cstdio>
#include <cstdint>
#include <stdio.h>
#include <stdint.h>
//
// This file contains the Window-OS-specific functions
//
static HANDLE glslang_global_lock;
#if !(defined(_WIN32) || defined(_WIN64))
#error Trying to build a windows specific file in a non windows build.
#endif
/* This file contains the Window-OS-specific functions */
namespace glslang {
#define TO_NATIVE_TLS_INDEX(nIndex) ((DWORD)((uintptr_t)(nIndex) - 1))
inline OS_TLSIndex ToGenericTLSIndex (DWORD handle)
{
return (OS_TLSIndex)((uintptr_t)handle + 1);
}
inline DWORD ToNativeTLSIndex (OS_TLSIndex nIndex)
{
return (DWORD)((uintptr_t)nIndex - 1);
}
//
// Thread Local Storage Operations
//
OS_TLSIndex OS_AllocTLSIndex()
/* Thread Local Storage Operations */
OS_TLSIndex OS_AllocTLSIndex(void)
{
DWORD dwIndex = TlsAlloc();
if (dwIndex == TLS_OUT_OF_INDEXES)
return OS_INVALID_TLS_INDEX;
return ToGenericTLSIndex(dwIndex);
return (OS_TLSIndex)((uintptr_t)dwIndex + 1);
}
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
{
if (nIndex == OS_INVALID_TLS_INDEX)
return false;
if (!TlsSetValue(ToNativeTLSIndex(nIndex), lpvValue))
if (!TlsSetValue(TO_NATIVE_TLS_INDEX(nIndex), lpvValue))
return false;
return true;
}
void* OS_GetTLSValue(OS_TLSIndex nIndex)
void *OS_GetTLSValue(OS_TLSIndex nIndex)
{
assert(nIndex != OS_INVALID_TLS_INDEX);
return TlsGetValue(ToNativeTLSIndex(nIndex));
return TlsGetValue(TO_NATIVE_TLS_INDEX(nIndex));
}
bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
{
if (nIndex == OS_INVALID_TLS_INDEX)
return false;
if (!TlsFree(ToNativeTLSIndex(nIndex)))
if (!TlsFree(TO_NATIVE_TLS_INDEX(nIndex)))
return false;
return true;
}
HANDLE GlobalLock;
void InitGlobalLock()
void InitGlobalLock(void)
{
GlobalLock = CreateMutex(0, false, 0);
glslang_global_lock = CreateMutex(0, false, 0);
}
void GetGlobalLock()
void GetGlobalLock(void)
{
WaitForSingleObject(GlobalLock, INFINITE);
WaitForSingleObject(glslang_global_lock, INFINITE);
}
void ReleaseGlobalLock()
void ReleaseGlobalLock(void)
{
ReleaseMutex(GlobalLock);
ReleaseMutex(glslang_global_lock);
}
} // namespace glslang

View File

@ -1,57 +1,61 @@
//
// Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
/*
* Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* Neither the name of 3Dlabs Inc. Ltd. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __OSINCLUDE_H
#define __OSINCLUDE_H
namespace glslang {
#include <boolean.h>
//
// Thread Local Storage Operations
//
typedef void* OS_TLSIndex;
#ifdef __cplusplus
extern "C" {
#endif
/* Thread Local Storage Operations */
typedef void *OS_TLSIndex;
#define OS_INVALID_TLS_INDEX ((void*)0)
OS_TLSIndex OS_AllocTLSIndex();
OS_TLSIndex OS_AllocTLSIndex(void);
bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
void* OS_GetTLSValue(OS_TLSIndex nIndex);
void InitGlobalLock();
void GetGlobalLock();
void ReleaseGlobalLock();
void InitGlobalLock(void);
void GetGlobalLock(void);
void ReleaseGlobalLock(void);
} // end namespace glslang
#ifdef __cplusplus
}
#endif
#endif // __OSINCLUDE_H
#endif /* __OSINCLUDE_H */

View File

@ -1711,3 +1711,18 @@ ANDROID PLAY FEATURE DELIVERY
#if defined(ANDROID)
#include "../play_feature_delivery/play_feature_delivery.c"
#endif
/*============================================================
GLSLANG
============================================================ */
#ifdef WANT_GLSLANG
#if defined(__linux__) || defined(__APPLE__)
#include "../deps/glslang/glslang/glslang/OSDependent/Unix/ossource.c"
#endif
#ifdef _WIN32
#include "../deps/glslang/glslang/glslang/OSDependent/Windows/ossource.c"
#endif
#endif

View File

@ -105,16 +105,6 @@ VIDEO DRIVER
/*============================================================
FONTS
============================================================ */
#ifdef WANT_GLSLANG
#ifdef _WIN32
#include "../deps/glslang/glslang/glslang/OSDependent/Windows/ossource.cpp"
#endif
#if defined(__linux__)
#include "../deps/glslang/glslang/glslang/OSDependent/Unix/ossource.cpp"
#endif
#endif
#if defined(HAVE_DISCORD)
#include "../deps/discord-rpc/src/discord_rpc.cpp"
#include "../deps/discord-rpc/src/rpc_connection.cpp"

View File

@ -42,10 +42,6 @@
#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpScanner.cpp"
#include "../deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.cpp"
#ifdef __APPLE__
#include "../deps/glslang/glslang/glslang/OSDependent/Unix/ossource.cpp"
#endif
#if defined(ENABLE_HLSL)
#include "../deps/glslang/glslang/hlsl/hlslAttributes.cpp"
#include "../deps/glslang/glslang/hlsl/hlslGrammar.cpp"