Skip to content

Commit

Permalink
integrate VKPT
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Schied committed Jan 17, 2019
1 parent 924ff39 commit 75edde7
Show file tree
Hide file tree
Showing 2,059 changed files with 110,091 additions and 89 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
q2pro
q2proded
game*.so
*.swp
build/
/baseq2
shader_vkpt
./vkpt
./vkptded
64 changes: 64 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cmake_minimum_required (VERSION 3.8)

include("cmake/HunterGate.cmake")
# ---------- Startup hunter -------------------------
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.20.7.tar.gz"
SHA1 "a376088a679fbfbe3a2c330746801f1d47e51a37"
)

PROJECT(quake2-pt)

OPTION(CONFIG_GL_RENDERER "Enable GL renderer")
OPTION(CONFIG_VKPT_RENDERER "Enable VKPT renderer" ON)
OPTION(CONFIG_USE_OPTIX "Use optix for tracing rays")
SET(CONFIG_OPTIX_DIR "" CACHE PATH "Optix SDK directory")

# ---------- Setup output Directories -------------------------
SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Libraries"
)

# --------- Setup the Executable output Directory -------------
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Executables."
)

# --------- Dependencies -------------------------------------
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set( IS_64_BIT 1 )
else ()
endif ()

# --------- Dependencies -------------------------------------
hunter_add_package(zlib)
hunter_add_package(png)
hunter_add_package(jpeg)
hunter_add_package(sdl2)
#hunter_add_package(curl)

find_package(ZLIB CONFIG REQUIRED)
find_package(PNG CONFIG REQUIRED)
find_package(JPEG CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
#find_package(Vulkan)
#find_library(Vulkan_LIBRARY NAMES vulkan-1 vulkan PATHS "C:/VulkanSDK/1.1.85.0")

link_directories(.)

# Compatibility mode
find_package(ZLIB REQUIRED)
string(COMPARE EQUAL "${ZLIB_INCLUDE_DIRS}" "" is_empty)
if(is_empty)
message(FATAL_ERROR "Expected non-empty")
endif()


SET(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install)


ADD_SUBDIRECTORY(src)
93 changes: 86 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

-include .config


ifdef CONFIG_WINDOWS
CPU ?= x86
SYS ?= Win32
Expand Down Expand Up @@ -45,6 +46,17 @@ LDFLAGS_s :=
LDFLAGS_c :=
LDFLAGS_g := -shared

ifdef CONFIG_SANITIZE
CFLAGS_c += -O0 -fsanitize=address -fno-omit-frame-pointer
LDFLAGS_c += -fsanitize=address
endif

ifdef CONFIG_VKPT_ENABLE_VALIDATION
ifneq ($(CONFIG_VKPT_ENABLE_VALIDATION),0)
CFLAGS_c += -DVKPT_ENABLE_VALIDATION
endif
endif

ifdef CONFIG_WINDOWS
# Force i?86-netware calling convention on x86 Windows
ifeq ($(CPU),x86)
Expand Down Expand Up @@ -117,7 +129,7 @@ ifndef CONFIG_WINDOWS
PATH_DEFS += -DHOMEDIR='"$(CONFIG_PATH_HOME)"'
endif

CFLAGS_s += $(BUILD_DEFS) $(VER_DEFS) $(PATH_DEFS) -DUSE_SERVER=1
CFLAGS_s += $(BUILD_DEFS) $(VER_DEFS) $(PATH_DEFS) -DUSE_SERVER=1 -DUSE_CLIENT=0
CFLAGS_c += $(BUILD_DEFS) $(VER_DEFS) $(PATH_DEFS) -DUSE_SERVER=1 -DUSE_CLIENT=1

# windres needs special quoting...
Expand Down Expand Up @@ -252,6 +264,13 @@ OBJS_g := \

### Configuration Options ###

# cd tracks via ogg
ifdef CONFIG_OGG
OBJS_c += src/client/sound/ogg.o
CFLAGS_c += -DOGG
LIBS_c += -lvorbisfile -lvorbis -logg
endif

ifdef CONFIG_HTTP
CURL_CFLAGS ?= $(shell pkg-config libcurl --cflags)
CURL_LIBS ?= $(shell pkg-config libcurl --libs)
Expand Down Expand Up @@ -331,7 +350,8 @@ ifdef CONFIG_SOFTWARE_RENDERER
OBJS_c += src/refresh/sw/surf.o
OBJS_c += src/refresh/sw/sird.o
OBJS_c += src/refresh/sw/sky.o
else
endif
ifdef CONFIG_GL_RENDERER
CFLAGS_c += -DREF_GL=1 -DUSE_REF=1 -DVID_REF='"gl"'
OBJS_c += src/refresh/gl/draw.o
OBJS_c += src/refresh/gl/hq2x.o
Expand All @@ -354,6 +374,30 @@ else
OBJS_c += src/refresh/gl/qgl/dynamic.o
endif
endif
ifdef CONFIG_VKPT_RENDERER
VKPT_SHADER_DIR=shader_vkpt
CFLAGS_c += -DREF_VKPT=1 -DUSE_REF=1 -DVID_REF='"vkpt"' -Isrc/refresh/vkpt/ -DVKPT_SHADER_DIR='"$(VKPT_SHADER_DIR)"'
LDFLAGS +=-lvulkan
OBJS_c += src/refresh/vkpt/main.o
OBJS_c += src/refresh/vkpt/textures.o
OBJS_c += src/refresh/vkpt/draw.o
OBJS_c += src/refresh/vkpt/matrix.o
OBJS_c += src/refresh/vkpt/models.o
OBJS_c += src/refresh/vkpt/path_tracer.o
OBJS_c += src/refresh/vkpt/vk_util.o
OBJS_c += src/refresh/vkpt/bsp_mesh.o
OBJS_c += src/refresh/vkpt/uniform_buffer.o
OBJS_c += src/refresh/vkpt/vertex_buffer.o
OBJS_c += src/refresh/vkpt/light_hierarchy.o
OBJS_c += src/refresh/vkpt/asvgf.o
OBJS_c += src/refresh/vkpt/stb.o
OBJS_c += src/refresh/vkpt/profiler.o

VKPT_SHADER_SRC = $(shell find src/refresh/vkpt/shader -type f | egrep '\.(vert|frag|geom|rchit|rgen|rmiss|rcall|comp)$$' | sed s!.*/!!)
VKPT_SHADER_HDR = $(shell find src/refresh/vkpt/shader -type f | egrep '\.(h|glsl)$$')
VKPT_SHADER_SPV = $(VKPT_SHADER_SRC:%=$(VKPT_SHADER_DIR)/%.spv)

endif

CONFIG_DEFAULT_MODELIST ?= 640x480 800x600 1024x768
CONFIG_DEFAULT_GEOMETRY ?= 640x480
Expand All @@ -366,6 +410,14 @@ ifndef CONFIG_SOFTWARE_RENDERER
endif
endif

ifdef CONFIG_NO_BINDLESS_TEXTURES
CFLAGS_c += -DNO_BINDLESS_TEXTURES=1
endif

ifdef CONFIG_SMALL_GPU
CFLAGS_c += -DUSE_SMALL_GPU=1
endif

ifndef CONFIG_NO_TGA
CFLAGS_c += -DUSE_TGA=1
endif
Expand Down Expand Up @@ -454,7 +506,8 @@ ifdef CONFIG_WINDOWS

ifdef CONFIG_SOFTWARE_RENDERER
OBJS_c += src/windows/swimp.o
else
endif
ifdef CONFIG_GL_RENDERER
OBJS_c += src/windows/glimp.o
OBJS_c += src/windows/wgl.o
endif
Expand Down Expand Up @@ -498,7 +551,8 @@ else

ifdef CONFIG_SOFTWARE_RENDERER
OBJS_c += src/unix/sdl/swimp.o
else
endif
ifdef CONFIG_GL_RENDERER
OBJS_c += src/unix/sdl/glimp.o
endif

Expand All @@ -507,7 +561,7 @@ else
X11_LIBS ?= -lX11
CFLAGS_c += -DUSE_X11=1 $(X11_CFLAGS)
LIBS_c += $(X11_LIBS)
ifndef CONFIG_SOFTWARE_RENDERER
ifdef CONFIG_GL_RENDERER
OBJS_c += src/unix/sdl/glx.o
endif
endif
Expand Down Expand Up @@ -575,6 +629,10 @@ ifdef CONFIG_DEBUG
CFLAGS_s += -D_DEBUG
endif

ifdef CONFIG_GL_DEBUG
CFLAGS_c += -D_GL_DEBUG
endif

ifeq ($(CPU),x86)
OBJS_c += src/common/x86/fpu.o
OBJS_s += src/common/x86/fpu.o
Expand All @@ -591,10 +649,12 @@ ifdef CONFIG_WINDOWS
TARG_s := q2proded.exe
TARG_c := q2pro.exe
TARG_g := game$(CPU).dll
TARG_t :=
else
TARG_s := q2proded
TARG_c := q2pro
TARG_s := vkptded
TARG_c := q2vkpt
TARG_g := game$(CPU).so
TARG_t :=
endif

all: $(TARG_s) $(TARG_c) $(TARG_g)
Expand Down Expand Up @@ -626,13 +686,32 @@ DEPS_s := $(OBJS_s:.o=.d)
DEPS_c := $(OBJS_c:.o=.d)
DEPS_g := $(OBJS_g:.o=.d)


ifdef CONFIG_VKPT_RENDERER
$(TARG_c): $(VKPT_SHADER_SPV)
compile_shaders: $(VKPT_SHADER_SPV)

CONFIG_GLSLANGVALIDATOR ?= glslangValidator

$(VKPT_SHADER_DIR)/%.spv: src/refresh/vkpt/shader/% $(VKPT_SHADER_HDR)
$(E) [GLSL] $@
$(Q)$(MKDIR) $(@D)
$(Q)$(CONFIG_GLSLANGVALIDATOR) \
--target-env vulkan1.1 \
-DVKPT_SHADER \
-DSHADER_STAGE_$$(echo $< | sed 's/.*\.//' | tr 'a-z' 'A-Z') \
-V $< -o $@ | sed 1d

endif

-include $(DEPS_s)
-include $(DEPS_c)
-include $(DEPS_g)

clean:
$(E) [CLEAN]
$(Q)$(RM) $(TARG_s) $(TARG_c) $(TARG_g)
$(Q)$(RM) $(VKPT_SHADER_SPV)
$(Q)$(RMDIR) $(BUILD_s) $(BUILD_c) $(BUILD_g)

strip: $(TARG_s) $(TARG_c) $(TARG_g)
Expand Down
15 changes: 10 additions & 5 deletions README
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
Welcome to Q2PRO, an enhanced, multiplayer oriented Quake 2 client and server.
Welcome to Q2VKPT, a Quake II engine with real-time path tracing. This client
implements fully dynamic illumination without precomputation supporting area
light sources, reflections, soft shadows, and indirect illumination. This
client is a port of our real-time path tracer vkpt and is based on the Quake II
engine Q2PRO.

For building Q2PRO, please consult the INSTALL file.
This client requires a high-end GPU supporting the Vulkan extension
VK_NV_ray_tracing.

For information on using and configuring Q2PRO, please refer to client and
server manuals available in doc/ subdirectory.
Please refer to our project page for more details.

Project homepage: http://brechpunkt.de/q2vkpt

Project homepage: http://skuller.net/q2pro/
Loading

0 comments on commit 75edde7

Please sign in to comment.