Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swiftshader
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
swiftshader
Commits
e2540106
Commit
e2540106
authored
Nov 05, 2014
by
Nicolas Capens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Load libraries from a list of possible names.
BUG=18208440 Change-Id: Ie57bf7c6fa40ec1f9d0c3780c360d281d84a8c56
parent
f6b6d273
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
85 additions
and
22 deletions
+85
-22
SharedLibrary.hpp
src/Common/SharedLibrary.hpp
+45
-0
libEGL.vcxproj
src/OpenGL/libEGL/libEGL.vcxproj
+9
-3
main.cpp
src/OpenGL/libEGL/main.cpp
+6
-6
libGLES_CM.vcxproj
src/OpenGL/libGLES_CM/libGLES_CM.vcxproj
+9
-3
main.cpp
src/OpenGL/libGLES_CM/main.cpp
+2
-2
libGLESv2.vcxproj
src/OpenGL/libGLESv2/libGLESv2.vcxproj
+9
-3
main.cpp
src/OpenGL/libGLESv2/main.cpp
+5
-5
No files found.
src/Common/SharedLibrary.hpp
View file @
e2540106
...
@@ -15,12 +15,45 @@
...
@@ -15,12 +15,45 @@
#include <dlfcn.h>
#include <dlfcn.h>
#endif
#endif
template
<
int
n
>
void
*
loadLibrary
(
const
char
*
(
&
names
)[
n
])
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
void
*
library
=
getLibraryHandle
(
names
[
i
]);
if
(
library
)
{
return
library
;
}
}
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
void
*
library
=
loadLibrary
(
names
[
i
]);
if
(
library
)
{
return
library
;
}
}
return
0
;
}
#if defined(_WIN32)
#if defined(_WIN32)
inline
void
*
loadLibrary
(
const
char
*
path
)
inline
void
*
loadLibrary
(
const
char
*
path
)
{
{
return
(
void
*
)
LoadLibrary
(
path
);
return
(
void
*
)
LoadLibrary
(
path
);
}
}
inline
void
*
getLibraryHandle
(
const
char
*
path
)
{
HMODULE
module
=
0
;
GetModuleHandleEx
(
0
,
path
,
&
module
);
return
(
void
*
)
module
;
}
inline
void
freeLibrary
(
void
*
library
)
inline
void
freeLibrary
(
void
*
library
)
{
{
FreeLibrary
((
HMODULE
)
library
);
FreeLibrary
((
HMODULE
)
library
);
...
@@ -36,6 +69,18 @@
...
@@ -36,6 +69,18 @@
return
dlopen
(
path
,
RTLD_LAZY
);
return
dlopen
(
path
,
RTLD_LAZY
);
}
}
inline
void
*
getLibraryHandle
(
const
char
*
path
)
{
bool
resident
=
(
dlopen
(
names
[
i
],
RTLD_NOLOAD
)
!=
0
);
if
(
resident
)
{
return
dlopen
(
path
,
RTLD_LAZY
);
// Increment reference count
}
return
0
;
}
inline
void
freeLibrary
(
void
*
library
)
inline
void
freeLibrary
(
void
*
library
)
{
{
dlclose
(
library
);
dlclose
(
library
);
...
...
src/OpenGL/libEGL/libEGL.vcxproj
View file @
e2540106
...
@@ -89,7 +89,9 @@
...
@@ -89,7 +89,9 @@
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\"
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libEGL_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
...
@@ -116,7 +118,9 @@ copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
...
@@ -116,7 +118,9 @@ copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\"
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libEGL_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Profile|Win32'"
>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Profile|Win32'"
>
...
@@ -144,7 +148,9 @@ copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
...
@@ -144,7 +148,9 @@ copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\"
copy "$(OutDir)libEGL.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libEGL_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ItemGroup>
...
...
src/OpenGL/libEGL/main.cpp
View file @
e2540106
...
@@ -84,21 +84,21 @@ CONSTRUCTOR static bool eglAttachProcess()
...
@@ -84,21 +84,21 @@ CONSTRUCTOR static bool eglAttachProcess()
eglAttachThread
();
eglAttachThread
();
#if defined(_WIN32)
#if defined(_WIN32)
const
char
*
libGLES_CM_lib
=
"libGLES_CM.dll"
;
const
char
*
libGLES_CM_lib
[]
=
{
"libGLES_CM.dll"
,
"libGLES_CM_translator.dll"
}
;
#else
#else
const
char
*
libGLES_CM_lib
=
"libGLES_CM.so.1"
;
const
char
*
libGLES_CM_lib
[]
=
{
"libGLES_CM.so.1"
,
"libGLES_CM.so"
}
;
#endif
#endif
libGLES_CM
=
loadLibrary
(
libGLES_CM_lib
);
libGLES_CM
=
loadLibrary
(
libGLES_CM_lib
);
es1
::
createContext
=
(
egl
::
Context
*
(
*
)(
const
egl
::
Config
*
,
const
egl
::
Context
*
))
getProcAddress
(
libGLES_CM
,
"glCreateContext"
);
es1
::
createContext
=
(
egl
::
Context
*
(
*
)(
const
egl
::
Config
*
,
const
egl
::
Context
*
))
getProcAddress
(
libGLES_CM
,
"glCreateContext"
);
es1
::
getProcAddress
=
(
__eglMustCastToProperFunctionPointerType
(
*
)(
const
char
*
))
getProcAddress
(
libGLES_CM
,
"glGetProcAddress"
);
es1
::
getProcAddress
=
(
__eglMustCastToProperFunctionPointerType
(
*
)(
const
char
*
))
getProcAddress
(
libGLES_CM
,
"glGetProcAddress"
);
#if defined(_WIN32)
#if defined(_WIN32)
const
char
*
libGLESv2_lib
=
"libGLESv2.dll"
;
const
char
*
libGLESv2_lib
[]
=
{
"libGLESv2.dll"
,
"libGLES_V2_translator.dll"
}
;
#else
#else
const
char
*
libGLESv2_lib
=
"libGLESv2.so.2"
;
const
char
*
libGLESv2_lib
[]
=
{
"libGLESv2.so.2"
,
"libGLESv2.so"
}
;
#endif
#endif
libGLESv2
=
loadLibrary
(
libGLESv2_lib
);
libGLESv2
=
loadLibrary
(
libGLESv2_lib
);
es2
::
createContext
=
(
egl
::
Context
*
(
*
)(
const
egl
::
Config
*
,
const
egl
::
Context
*
))
getProcAddress
(
libGLESv2
,
"glCreateContext"
);
es2
::
createContext
=
(
egl
::
Context
*
(
*
)(
const
egl
::
Config
*
,
const
egl
::
Context
*
))
getProcAddress
(
libGLESv2
,
"glCreateContext"
);
es2
::
getProcAddress
=
(
__eglMustCastToProperFunctionPointerType
(
*
)(
const
char
*
))
getProcAddress
(
libGLESv2
,
"glGetProcAddress"
);
es2
::
getProcAddress
=
(
__eglMustCastToProperFunctionPointerType
(
*
)(
const
char
*
))
getProcAddress
(
libGLESv2
,
"glGetProcAddress"
);
...
...
src/OpenGL/libGLES_CM/libGLES_CM.vcxproj
View file @
e2540106
...
@@ -91,7 +91,9 @@
...
@@ -91,7 +91,9 @@
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\"
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libGLES_CM_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
...
@@ -124,7 +126,9 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
...
@@ -124,7 +126,9 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\"
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libGLES_CM_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Profile|Win32'"
>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Profile|Win32'"
>
...
@@ -156,7 +160,9 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
...
@@ -156,7 +160,9 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\"
copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libGLES_CM_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ItemGroup>
...
...
src/OpenGL/libGLES_CM/main.cpp
View file @
e2540106
...
@@ -44,9 +44,9 @@ CONSTRUCTOR static bool glAttachProcess()
...
@@ -44,9 +44,9 @@ CONSTRUCTOR static bool glAttachProcess()
glAttachThread
();
glAttachThread
();
#if defined(_WIN32)
#if defined(_WIN32)
const
char
*
libEGL_lib
=
"libEGL.dll"
;
const
char
*
libEGL_lib
[]
=
{
"libEGL.dll"
,
"libEGL_translator.dll"
}
;
#else
#else
const
char
*
libEGL_lib
=
"libEGL.so.1"
;
const
char
*
libEGL_lib
[]
=
{
"libEGL.so.1"
,
"libEGL.so"
}
;
#endif
#endif
libEGL
=
loadLibrary
(
libEGL_lib
);
libEGL
=
loadLibrary
(
libEGL_lib
);
...
...
src/OpenGL/libGLESv2/libGLESv2.vcxproj
View file @
e2540106
...
@@ -91,7 +91,9 @@
...
@@ -91,7 +91,9 @@
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator"
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libGLES_V2_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
...
@@ -124,7 +126,9 @@ copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Com
...
@@ -124,7 +126,9 @@ copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Com
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator"
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libGLES_V2_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Profile|Win32'"
>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Profile|Win32'"
>
...
@@ -156,7 +160,9 @@ copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Com
...
@@ -156,7 +160,9 @@ copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Com
</Link>
</Link>
<PostBuildEvent>
<PostBuildEvent>
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
<Command>
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\"
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
</Command>
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"
mkdir "$(ProjectDir)..\..\..\lib\$(Configuration)\translator"
copy "$(OutDir)libGLESv2.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\translator\libGLES_V2_translator.dll"
</Command>
</PostBuildEvent>
</PostBuildEvent>
</ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<ItemGroup>
...
...
src/OpenGL/libGLESv2/main.cpp
View file @
e2540106
...
@@ -43,10 +43,10 @@ CONSTRUCTOR static bool glAttachProcess()
...
@@ -43,10 +43,10 @@ CONSTRUCTOR static bool glAttachProcess()
glAttachThread
();
glAttachThread
();
#if defined(_WIN32)
#if defined(_WIN32)
const
char
*
libEGL_lib
=
"libEGL.dll"
;
const
char
*
libEGL_lib
[]
=
{
"libEGL.dll"
,
"libEGL_translator.dll"
}
;
#else
#else
const
char
*
libEGL_lib
=
"libEGL.so.1"
;
const
char
*
libEGL_lib
[]
=
{
"libEGL.so.1"
,
"libEGL.so"
}
;
#endif
#endif
libEGL
=
loadLibrary
(
libEGL_lib
);
libEGL
=
loadLibrary
(
libEGL_lib
);
...
@@ -54,9 +54,9 @@ CONSTRUCTOR static bool glAttachProcess()
...
@@ -54,9 +54,9 @@ CONSTRUCTOR static bool glAttachProcess()
egl
::
getCurrentDisplay
=
(
egl
::
Display
*
(
*
)())
getProcAddress
(
libEGL
,
"eglGetCurrentDisplay"
);
egl
::
getCurrentDisplay
=
(
egl
::
Display
*
(
*
)())
getProcAddress
(
libEGL
,
"eglGetCurrentDisplay"
);
#if defined(_WIN32)
#if defined(_WIN32)
const
char
*
libGLES_CM_lib
=
"libGLES_CM.dll"
;
const
char
*
libGLES_CM_lib
[]
=
{
"libGLES_CM.dll"
,
"libGLES_CM_translator.dll"
}
;
#else
#else
const
char
*
libGLES_CM_lib
=
"libGLES_CM.so.1"
;
const
char
*
libGLES_CM_lib
[]
=
{
"libGLES_CM.so.1"
,
"libGLES_CM.so"
}
;
#endif
#endif
libGLES_CM
=
loadLibrary
(
libGLES_CM_lib
);
libGLES_CM
=
loadLibrary
(
libGLES_CM_lib
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment