Skip to content

Commit 74e6309

Browse files
authored
Merge pull request #22 from Unity-Technologies/embeddedlinux_vulkan_support
Add Vulkan support for EmbeddedLinux x64/arm64 (and GLES support for x64)
2 parents 28122b5 + 37cece4 commit 74e6309

File tree

5 files changed

+22
-7
lines changed

5 files changed

+22
-7
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
REM UNITY_ROOT should be set to folder with Unity repository
2-
"%UNITY_ROOT%/build/EmbeddedLinux/llvm/bin/clang++" --sysroot="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-arm64/aarch64-embedded-linux-gnu/sysroot" -DUNITY_EMBEDDED_LINUX=1 -O2 -fPIC -shared -rdynamic -o libRenderingPlugin.so -fuse-ld=lld.exe -Wl,-soname,RenderingPlugin -Wl,-lGLESv2 --gcc-toolchain="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-arm64" -target aarch64-embedded-linux-gnu ../../source/RenderingPlugin.cpp ../../source/RenderAPI_OpenGLCoreES.cpp ../../source/RenderAPI.cpp
2+
"%UNITY_ROOT%/build/EmbeddedLinux/llvm/bin/clang++" --sysroot="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-arm64/aarch64-embedded-linux-gnu/sysroot" -DUNITY_EMBEDDED_LINUX=1 -DSUPPORT_VULKAN=1 -I"%UNITY_ROOT%/External/Vulkan/include" -O2 -fPIC -shared -rdynamic -o libRenderingPlugin.so -fuse-ld=lld.exe -Wl,-soname,RenderingPlugin -Wl,-lGLESv2 --gcc-toolchain="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-arm64" -target aarch64-embedded-linux-gnu ../../source/RenderingPlugin.cpp ../../source/RenderAPI_OpenGLCoreES.cpp ../../source/RenderAPI_Vulkan.cpp ../../source/RenderAPI.cpp
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
REM UNITY_ROOT should be set to folder with Unity repository
2-
"%UNITY_ROOT%/build/EmbeddedLinux/llvm/bin/clang++" --sysroot="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x64/x86_64-embedded-linux-gnu/sysroot" -DUNITY_EMBEDDED_LINUX_GL=1 -O2 -fPIC -shared -rdynamic -o libRenderingPlugin.so -fuse-ld=lld.exe -Wl,-soname,RenderingPlugin -Wl,-lGL --gcc-toolchain="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x64" -target x86_64-embedded-linux-gnu ../../source/RenderingPlugin.cpp ../../source/RenderAPI_OpenGLCoreES.cpp ../../source/RenderAPI.cpp
2+
"%UNITY_ROOT%/build/EmbeddedLinux/llvm/bin/clang++" --sysroot="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x64/x86_64-embedded-linux-gnu/sysroot" -DUNITY_EMBEDDED_LINUX=1 -DSUPPORT_OPENGL_CORE=1 -DSUPPORT_VULKAN=1 -I"%UNITY_ROOT%/External/Vulkan/include" -O2 -fPIC -shared -rdynamic -o libRenderingPlugin.so -fuse-ld=lld.exe -Wl,-soname,RenderingPlugin -Wl,-lGL --gcc-toolchain="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x64" -target x86_64-embedded-linux-gnu ../../source/RenderingPlugin.cpp ../../source/RenderAPI_OpenGLCoreES.cpp ../../source/RenderAPI_Vulkan.cpp ../../source/RenderAPI.cpp
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
REM UNITY_ROOT should be set to folder with Unity repository
2-
"%UNITY_ROOT%/build/EmbeddedLinux/llvm/bin/clang++" --sysroot="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x86/i686-embedded-linux-gnu/sysroot" -DUNITY_EMBEDDED_LINUX_GL=1 -O2 -fPIC -shared -rdynamic -o libRenderingPlugin.so -fuse-ld=lld.exe -Wl,-soname,RenderingPlugin -Wl,-lGL --gcc-toolchain="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x86" -target i686-embedded-linux-gnu ../../source/RenderingPlugin.cpp ../../source/RenderAPI_OpenGLCoreES.cpp ../../source/RenderAPI.cpp
2+
"%UNITY_ROOT%/build/EmbeddedLinux/llvm/bin/clang++" --sysroot="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x86/i686-embedded-linux-gnu/sysroot" -DUNITY_EMBEDDED_LINUX=1 -DSUPPORT_OPENGL_CORE=1 -O2 -fPIC -shared -rdynamic -o libRenderingPlugin.so -fuse-ld=lld.exe -Wl,-soname,RenderingPlugin -Wl,-lGL --gcc-toolchain="%UNITY_ROOT%/build/EmbeddedLinux/sdk-linux-x86" -target i686-embedded-linux-gnu ../../source/RenderingPlugin.cpp ../../source/RenderAPI_OpenGLCoreES.cpp ../../source/RenderAPI.cpp

PluginSource/source/PlatformBase.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,23 @@
5151
#define SUPPORT_OPENGL_UNIFIED 1
5252
#define SUPPORT_OPENGL_CORE 1
5353
#define SUPPORT_VULKAN 0 // Requires Vulkan SDK to be installed
54-
#elif UNITY_IOS || UNITY_TVOS || UNITY_ANDROID || UNITY_WEBGL || UNITY_EMBEDDED_LINUX
54+
#elif UNITY_IOS || UNITY_TVOS || UNITY_ANDROID || UNITY_WEBGL
5555
#ifndef SUPPORT_OPENGL_ES
5656
#define SUPPORT_OPENGL_ES 1
5757
#endif
5858
#define SUPPORT_OPENGL_UNIFIED SUPPORT_OPENGL_ES
5959
#ifndef SUPPORT_VULKAN
6060
#define SUPPORT_VULKAN 0
6161
#endif
62-
#elif UNITY_OSX || UNITY_LINUX || UNITY_EMBEDDED_LINUX_GL
62+
#elif UNITY_OSX || UNITY_LINUX
6363
#define SUPPORT_OPENGL_UNIFIED 1
6464
#define SUPPORT_OPENGL_CORE 1
65+
#elif UNITY_EMBEDDED_LINUX
66+
#define SUPPORT_OPENGL_UNIFIED 1
67+
#define SUPPORT_OPENGL_ES 1
68+
#ifndef SUPPORT_VULKAN
69+
#define SUPPORT_VULKAN 0
70+
#endif
6571
#endif
6672

6773
#if UNITY_IOS || UNITY_TVOS || UNITY_OSX

PluginSource/source/RenderAPI_OpenGLCoreES.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <assert.h>
1212
#if UNITY_IOS || UNITY_TVOS
1313
# include <OpenGLES/ES2/gl.h>
14-
#elif UNITY_ANDROID || UNITY_WEBGL || UNITY_EMBEDDED_LINUX
14+
#elif UNITY_ANDROID || UNITY_WEBGL
1515
# include <GLES2/gl2.h>
1616
#elif UNITY_OSX
1717
# include <OpenGL/gl3.h>
@@ -20,9 +20,15 @@
2020
// library (like GLEW, GLFW etc.) can be used; here we use gl3w since it's simple and
2121
// straightforward.
2222
# include "gl3w/gl3w.h"
23-
#elif UNITY_LINUX || UNITY_EMBEDDED_LINUX_GL
23+
#elif UNITY_LINUX
2424
# define GL_GLEXT_PROTOTYPES
2525
# include <GL/gl.h>
26+
#elif UNITY_EMBEDDED_LINUX
27+
# include <GLES2/gl2.h>
28+
#if SUPPORT_OPENGL_CORE
29+
# define GL_GLEXT_PROTOTYPES
30+
# include <GL/gl.h>
31+
#endif
2632
#else
2733
# error Unknown platform
2834
#endif
@@ -131,6 +137,9 @@ static GLuint CreateShader(GLenum type, const char* sourceText)
131137

132138
void RenderAPI_OpenGLCoreES::CreateResources()
133139
{
140+
// Make sure that there are no GL error flags set before creating resources
141+
while (glGetError() != GL_NO_ERROR) {}
142+
134143
// Create shaders
135144
if (m_APIType == kUnityGfxRendererOpenGLES20)
136145
{

0 commit comments

Comments
 (0)