Skip to content

Commit c83756e

Browse files
committed
Start of daemon-vulkan infrastructure
1 parent 4ff4427 commit c83756e

File tree

16 files changed

+523
-480
lines changed

16 files changed

+523
-480
lines changed

CMakeLists.txt

Lines changed: 72 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ if(NOT DAEMON_EXTERNAL_APP)
117117
option(USE_MUMBLE "Build Daemon with mumblelink sumpport" ON)
118118
endif()
119119

120+
if (BUILD_CLIENT)
121+
# option(USE_VULKAN "Use Vulkan rendering API instead of OpenGL." OFF)
122+
endif()
123+
120124
option(USE_SMP "Compile with support for running the renderer in a separate thread" ON)
121125
option(USE_BREAKPAD "Generate Daemon crash dumps (which require Breakpad tools to read)" OFF)
122126
endif()
@@ -634,65 +638,72 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP)
634638
endif()
635639
endif()
636640

637-
# Look for OpenGL here before we potentially switch to looking for static libs.
638-
if (BUILD_CLIENT)
639-
if (LINUX OR FREEBSD)
640-
# Set LEGACY OpenGL ABI if the variable is not explictly set.
641-
# The backward-incompatible GLVND OpenGL ABI should only be used
642-
# by developers who have a good reason to require it.
643-
# See: https://github.com/DaemonEngine/Daemon/issues/945#issuecomment-1835091256
644-
set(OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Linux OpenGL ABI (LEGACY or GLVND).")
645-
endif()
646-
647-
find_package(OpenGL REQUIRED)
648-
include_directories(${OPENGL_INCLUDE_DIR})
649-
set(LIBS_CLIENT ${LIBS_CLIENT} OpenGL::GL)
650-
651-
# When OpenGL_GL_PREFERENCE is set but neither GLVND nor LEGACY are available,
652-
# This code is unreachable since it already errored out at find_package time.
653-
# This code only executes if OpenGL is supported, either because the GLVND ABI
654-
# is available, either because the LEGACY ABI is available.
655-
if (LINUX OR FREEBSD)
656-
if (NOT OPENGL_gl_LIBRARY)
657-
# When OpenGL_GL_PREFERENCE is supported and GLVND is available
658-
# OPENGL_gl_LIBRARY is expected to be empty. So we can use the
659-
# emptyness of OPENGL_gl_LIBRARY to detect that CMake supports
660-
# OpenGL_GL_PREFERENCE and GLVND is used:
661-
# > If the GLVND OpenGL and GLX libraries are available, prefer them.
662-
# > This forces OPENGL_gl_LIBRARY to be empty.
663-
# -- https://cmake.org/cmake/help/latest/module/FindOpenGL.html
664-
set(OpenGL_selected_ABI "GLVND")
665-
set(OpenGL_selected_LIBRARY "${OPENGL_opengl_LIBRARY}")
666-
else()
667-
# When OpenGL_GL_PREFERENCE is not supported or GLVND is not available
668-
# the OPENGL_gl_LIBRARY is always set, so if it is set, it means the ABI
669-
# is the LEGACY one.
670-
set(OpenGL_selected_ABI "LEGACY")
671-
set(OpenGL_selected_LIBRARY "${OPENGL_gl_LIBRARY}")
641+
if (USE_VULKAN)
642+
add_definitions("-DDAEMON_RENDERER_VULKAN=1")
643+
add_definitions("-DVK_NO_PROTOTYPES=1")
644+
else()
645+
add_definitions("-DDAEMON_RENDERER_OPENGL=1")
646+
647+
# Look for OpenGL here before we potentially switch to looking for static libs.
648+
if (BUILD_CLIENT)
649+
if (LINUX OR FREEBSD)
650+
# Set LEGACY OpenGL ABI if the variable is not explictly set.
651+
# The backward-incompatible GLVND OpenGL ABI should only be used
652+
# by developers who have a good reason to require it.
653+
# See: https://github.com/DaemonEngine/Daemon/issues/945#issuecomment-1835091256
654+
set(OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Linux OpenGL ABI (LEGACY or GLVND).")
672655
endif()
673656

674-
if (OpenGL_selected_ABI STREQUAL "GLVND")
675-
message(WARNING "The GLVND OpenGL ABI is backward incompatible with legacy drivers.\nSee https://github.com/DaemonEngine/Daemon/issues/945")
676-
endif()
657+
find_package(OpenGL REQUIRED)
658+
include_directories(${OPENGL_INCLUDE_DIR})
659+
set(LIBS_CLIENT ${LIBS_CLIENT} OpenGL::GL)
677660

678-
if (OpenGL_GL_PREFERENCE STREQUAL "GLVND")
679-
if (NOT OPENGL_opengl_LIBRARY)
680-
message(WARNING "GLVND OpenGL ABI not available but LEGACY is.\nTry OpenGL_GL_PREFERENCE=LEGACY")
681-
message(FATAL_ERROR "Could NOT find GLVND libOpenGL.so")
682-
endif()
683-
else()
661+
# When OpenGL_GL_PREFERENCE is set but neither GLVND nor LEGACY are available,
662+
# This code is unreachable since it already errored out at find_package time.
663+
# This code only executes if OpenGL is supported, either because the GLVND ABI
664+
# is available, either because the LEGACY ABI is available.
665+
if (LINUX OR FREEBSD)
684666
if (NOT OPENGL_gl_LIBRARY)
685-
message(WARNING "LEGACY OpenGL ABI not available but GLVND is.\nTry OpenGL_GL_PREFERENCE=GLVND")
686-
message(FATAL_ERROR "Could NOT find LEGACY libGL.so")
667+
# When OpenGL_GL_PREFERENCE is supported and GLVND is available
668+
# OPENGL_gl_LIBRARY is expected to be empty. So we can use the
669+
# emptyness of OPENGL_gl_LIBRARY to detect that CMake supports
670+
# OpenGL_GL_PREFERENCE and GLVND is used:
671+
# > If the GLVND OpenGL and GLX libraries are available, prefer them.
672+
# > This forces OPENGL_gl_LIBRARY to be empty.
673+
# -- https://cmake.org/cmake/help/latest/module/FindOpenGL.html
674+
set(OpenGL_selected_ABI "GLVND")
675+
set(OpenGL_selected_LIBRARY "${OPENGL_opengl_LIBRARY}")
676+
else()
677+
# When OpenGL_GL_PREFERENCE is not supported or GLVND is not available
678+
# the OPENGL_gl_LIBRARY is always set, so if it is set, it means the ABI
679+
# is the LEGACY one.
680+
set(OpenGL_selected_ABI "LEGACY")
681+
set(OpenGL_selected_LIBRARY "${OPENGL_gl_LIBRARY}")
682+
endif()
683+
684+
if (OpenGL_selected_ABI STREQUAL "GLVND")
685+
message(WARNING "The GLVND OpenGL ABI is backward incompatible with legacy drivers.\nSee https://github.com/DaemonEngine/Daemon/issues/945")
686+
endif()
687+
688+
if (OpenGL_GL_PREFERENCE STREQUAL "GLVND")
689+
if (NOT OPENGL_opengl_LIBRARY)
690+
message(WARNING "GLVND OpenGL ABI not available but LEGACY is.\nTry OpenGL_GL_PREFERENCE=LEGACY")
691+
message(FATAL_ERROR "Could NOT find GLVND libOpenGL.so")
692+
endif()
693+
else()
694+
if (NOT OPENGL_gl_LIBRARY)
695+
message(WARNING "LEGACY OpenGL ABI not available but GLVND is.\nTry OpenGL_GL_PREFERENCE=GLVND")
696+
message(FATAL_ERROR "Could NOT find LEGACY libGL.so")
697+
endif()
687698
endif()
688-
endif()
689699

690-
message(STATUS "Found OpenGL ABI: ${OpenGL_selected_ABI}")
691-
message(STATUS "Found OpenGL library: ${OpenGL_selected_LIBRARY}")
700+
message(STATUS "Found OpenGL ABI: ${OpenGL_selected_ABI}")
701+
message(STATUS "Found OpenGL library: ${OpenGL_selected_LIBRARY}")
692702

693-
daemon_add_buildinfo("char*" "DAEMON_OPENGL_ABI_STRING" "\"${OpenGL_selected_ABI}\"")
694-
add_definitions("-DDAEMON_OPENGL_ABI_${OpenGL_selected_ABI}")
695-
add_definitions("-DDAEMON_OPENGL_ABI")
703+
daemon_add_buildinfo("char*" "DAEMON_OPENGL_ABI_STRING" "\"${OpenGL_selected_ABI}\"")
704+
add_definitions("-DDAEMON_OPENGL_ABI_${OpenGL_selected_ABI}")
705+
add_definitions("-DDAEMON_OPENGL_ABI")
706+
endif()
696707
endif()
697708
endif()
698709

@@ -985,6 +996,7 @@ if (NOT NACL)
985996
set_property(TARGET engine-lib APPEND PROPERTY INCLUDE_DIRECTORIES ${ENGINE_DIR} ${MOUNT_DIR} ${LIB_DIR})
986997
set_property(TARGET engine-lib APPEND PROPERTY COMPILE_OPTIONS ${WARNINGS})
987998
set_target_properties(engine-lib PROPERTIES FOLDER "engine/objects")
999+
9881000
ADD_PRECOMPILED_HEADER(engine-lib)
9891001

9901002
if (BUILD_DUMMY_APP)
@@ -1007,9 +1019,16 @@ if (BUILD_CLIENT)
10071019
if (USE_SMP)
10081020
list(APPEND Definitions USE_SMP)
10091021
endif()
1022+
1023+
if (USE_VULKAN)
1024+
set(CLIENT_EXECUTABLE_NAME daemon-vulkan)
1025+
else()
1026+
set(CLIENT_EXECUTABLE_NAME daemon)
1027+
endif()
1028+
10101029
AddApplication(
10111030
Target client
1012-
ExecutableName daemon
1031+
ExecutableName ${CLIENT_EXECUTABLE_NAME}
10131032
ApplicationMain ${ENGINE_DIR}/client/ClientApplication.cpp
10141033
Definitions ${Definitions}
10151034
Flags ${WARNINGS}

src.cmake

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ set(COMMONLIST
2727
${COMMON_DIR}/IPC/Primitives.h
2828
${COMMON_DIR}/KeyIdentification.cpp
2929
${COMMON_DIR}/KeyIdentification.h
30+
${COMMON_DIR}/CPPStandard.h
3031
${COMMON_DIR}/LineEditData.cpp
3132
${COMMON_DIR}/LineEditData.h
3233
${COMMON_DIR}/Log.cpp
@@ -79,74 +80,11 @@ set(COMMONTESTLIST
7980
${ENGINE_DIR}/qcommon/q_math_test.cpp
8081
)
8182

82-
set(RENDERERLIST
83-
${DAEMON_GENERATED_DIR}/shaders.cpp
84-
${ENGINE_DIR}/renderer/BufferBind.h
85-
${ENGINE_DIR}/renderer/DetectGLVendors.cpp
86-
${ENGINE_DIR}/renderer/DetectGLVendors.h
87-
${ENGINE_DIR}/renderer/gl_shader.cpp
88-
${ENGINE_DIR}/renderer/gl_shader.h
89-
${ENGINE_DIR}/renderer/iqm.h
90-
${ENGINE_DIR}/renderer/ShadeCommon.h
91-
${ENGINE_DIR}/renderer/tr_animation.cpp
92-
${ENGINE_DIR}/renderer/tr_backend.cpp
93-
${ENGINE_DIR}/renderer/tr_bsp.cpp
94-
${ENGINE_DIR}/renderer/tr_cmds.cpp
95-
${ENGINE_DIR}/renderer/tr_curve.cpp
96-
${ENGINE_DIR}/renderer/tr_fbo.cpp
97-
${ENGINE_DIR}/renderer/tr_font.cpp
98-
${ENGINE_DIR}/renderer/GeometryCache.cpp
99-
${ENGINE_DIR}/renderer/GeometryCache.h
100-
${ENGINE_DIR}/renderer/GeometryOptimiser.cpp
101-
${ENGINE_DIR}/renderer/GeometryOptimiser.h
102-
${ENGINE_DIR}/renderer/GLMemory.cpp
103-
${ENGINE_DIR}/renderer/GLMemory.h
104-
${ENGINE_DIR}/renderer/GLUtils.h
105-
${ENGINE_DIR}/renderer/InternalImage.cpp
106-
${ENGINE_DIR}/renderer/InternalImage.h
107-
${ENGINE_DIR}/renderer/Material.cpp
108-
${ENGINE_DIR}/renderer/Material.h
109-
${ENGINE_DIR}/renderer/TextureManager.cpp
110-
${ENGINE_DIR}/renderer/TextureManager.h
111-
${ENGINE_DIR}/renderer/tr_image.cpp
112-
${ENGINE_DIR}/renderer/tr_image.h
113-
${ENGINE_DIR}/renderer/tr_image_crn.cpp
114-
${ENGINE_DIR}/renderer/tr_image_dds.cpp
115-
${ENGINE_DIR}/renderer/tr_image_jpg.cpp
116-
${ENGINE_DIR}/renderer/tr_image_ktx.cpp
117-
${ENGINE_DIR}/renderer/tr_image_png.cpp
118-
${ENGINE_DIR}/renderer/tr_image_tga.cpp
119-
${ENGINE_DIR}/renderer/tr_image_webp.cpp
120-
${ENGINE_DIR}/renderer/tr_init.cpp
121-
${ENGINE_DIR}/renderer/tr_light.cpp
122-
${ENGINE_DIR}/renderer/tr_local.h
123-
${ENGINE_DIR}/renderer/tr_main.cpp
124-
${ENGINE_DIR}/renderer/tr_marks.cpp
125-
${ENGINE_DIR}/renderer/tr_mesh.cpp
126-
${ENGINE_DIR}/renderer/tr_model.cpp
127-
${ENGINE_DIR}/renderer/tr_model_iqm.cpp
128-
${ENGINE_DIR}/renderer/tr_model_md3.cpp
129-
${ENGINE_DIR}/renderer/tr_model_md5.cpp
130-
${ENGINE_DIR}/renderer/tr_model_skel.cpp
131-
${ENGINE_DIR}/renderer/tr_model_skel.h
132-
${ENGINE_DIR}/renderer/tr_noise.cpp
133-
${ENGINE_DIR}/renderer/tr_public.h
134-
${ENGINE_DIR}/renderer/tr_scene.cpp
135-
${ENGINE_DIR}/renderer/tr_shade.cpp
136-
${ENGINE_DIR}/renderer/tr_shader.cpp
137-
${ENGINE_DIR}/renderer/tr_shade_calc.cpp
138-
${ENGINE_DIR}/renderer/tr_skin.cpp
139-
${ENGINE_DIR}/renderer/tr_sky.cpp
140-
${ENGINE_DIR}/renderer/tr_surface.cpp
141-
${ENGINE_DIR}/renderer/tr_types.h
142-
${ENGINE_DIR}/renderer/tr_vbo.cpp
143-
${ENGINE_DIR}/renderer/VBO.h
144-
${ENGINE_DIR}/renderer/VertexSpecification.h
145-
${ENGINE_DIR}/renderer/tr_video.cpp
146-
${ENGINE_DIR}/renderer/tr_world.cpp
147-
${ENGINE_DIR}/sys/sdl_glimp.cpp
148-
${ENGINE_DIR}/sys/sdl_icon.h
149-
)
83+
if (USE_VULKAN)
84+
include (${ENGINE_DIR}/renderer-vulkan/src.cmake)
85+
else()
86+
include (${ENGINE_DIR}/renderer/src.cmake)
87+
endif()
15088

15189
set(GLSLSOURCELIST
15290
# Common shader libraries
@@ -266,6 +204,7 @@ set(ENGINELIST
266204
${ENGINE_DIR}/sys/con_common.h
267205
${ENGINE_DIR}/sys/con_common.cpp
268206
${ENGINE_DIR}/sys/sys_events.h
207+
${ENGINE_DIR}/RefAPI.h
269208
)
270209

271210
if (WIN32)

src/common/StackTrace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ inline std::string FormatStackTrace( const std::stacktrace& stackTrace,
5858
}
5959

6060
if( compact ) {
61-
out += Str::Format( addLineEnd ? "\n%s:%u" : "%s:%u", entry.source_file(), entry.source_line());
61+
out += Str::Format( addLineEnd ? "\n%s:%u" : "%s:%u", entry.source_file(), entry.source_line() );
6262
} else {
63-
out += Str::Format( addLineEnd ? "\n%s:%u: %s" : "%s:%u: %s", entry.source_file(), entry.source_line(), entry.description());
63+
out += Str::Format( addLineEnd ? "\n%s:%u: %s" : "%s:%u: %s", entry.source_file(), entry.source_line(), entry.description() );
6464
}
6565
addLineEnd = true;
6666
}

src/common/System.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ constexpr bool defaultPedanticShutdown = true;
6464
#else
6565
constexpr bool defaultPedanticShutdown = false;
6666
#endif
67+
#if defined( DAEMON_RENDERER_VULKAN )
68+
static Cvar::Cvar<bool> pedanticShutdown( "common.pedanticShutdown", "Daemon-vulkan always does proper shutdown", Cvar::ROM, true );
69+
#else
6770
static Cvar::Cvar<bool> pedanticShutdown("common.pedanticShutdown", "run useless shutdown procedures before exit", Cvar::NONE, defaultPedanticShutdown);
71+
#endif
6872
#endif // BUILD_ENGINE
6973

7074
#if defined(BUILD_ENGINE) && defined(_WIN32)

0 commit comments

Comments
 (0)