diff options
Diffstat (limited to '3rdparty/bgfx/scripts')
-rw-r--r-- | 3rdparty/bgfx/scripts/bgfx.lua | 79 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/genie.lua | 87 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/shader.mk | 41 | ||||
-rw-r--r-- | 3rdparty/bgfx/scripts/shaderc.lua | 22 |
4 files changed, 157 insertions, 72 deletions
diff --git a/3rdparty/bgfx/scripts/bgfx.lua b/3rdparty/bgfx/scripts/bgfx.lua index 76d6b70258a..a3716b976f3 100644 --- a/3rdparty/bgfx/scripts/bgfx.lua +++ b/3rdparty/bgfx/scripts/bgfx.lua @@ -3,6 +3,38 @@ -- License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause -- +function filesexist(_srcPath, _dstPath, _files) + for _, file in ipairs(_files) do + file = path.getrelative(_srcPath, file) + local filePath = path.join(_dstPath, file) + if not os.isfile(filePath) then return false end + end + + return true +end + +function overridefiles(_srcPath, _dstPath, _files) + + local remove = {} + local add = {} + for _, file in ipairs(_files) do + file = path.getrelative(_srcPath, file) + local filePath = path.join(_dstPath, file) + if not os.isfile(filePath) then return end + + table.insert(remove, path.join(_srcPath, file)) + table.insert(add, filePath) + end + + removefiles { + remove, + } + + files { + add, + } +end + function bgfxProject(_name, _kind, _defines) project ("bgfx" .. _name) @@ -98,6 +130,7 @@ function bgfxProject(_name, _kind, _defines) "-framework QuartzCore", "-framework OpenGL", "-weak_framework Metal", + "-weak_framework MetalKit", } configuration { "not nacl", "not linux-steamlink" } @@ -128,25 +161,26 @@ function bgfxProject(_name, _kind, _defines) path.join(BGFX_DIR, "src/**.bin.h"), } + overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "src/renderer_vk.cpp"), + path.join(BGFX_DIR, "src/renderer_vk.h"), + }) + + overridefiles(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "src/renderer_gnm.cpp"), + path.join(BGFX_DIR, "src/renderer_gnm.h"), + }) + if _OPTIONS["with-amalgamated"] then excludes { path.join(BGFX_DIR, "src/bgfx.cpp"), - path.join(BGFX_DIR, "src/glcontext_egl.cpp"), - path.join(BGFX_DIR, "src/glcontext_glx.cpp"), - path.join(BGFX_DIR, "src/glcontext_ppapi.cpp"), - path.join(BGFX_DIR, "src/glcontext_wgl.cpp"), + path.join(BGFX_DIR, "src/debug_**.cpp"), + path.join(BGFX_DIR, "src/glcontext_**.cpp"), path.join(BGFX_DIR, "src/image.cpp"), - path.join(BGFX_DIR, "src/ovr.cpp"), - path.join(BGFX_DIR, "src/renderdoc.cpp"), - path.join(BGFX_DIR, "src/renderer_d3d9.cpp"), - path.join(BGFX_DIR, "src/renderer_d3d11.cpp"), - path.join(BGFX_DIR, "src/renderer_d3d12.cpp"), - path.join(BGFX_DIR, "src/renderer_null.cpp"), - path.join(BGFX_DIR, "src/renderer_gl.cpp"), - path.join(BGFX_DIR, "src/renderer_vk.cpp"), - path.join(BGFX_DIR, "src/shader_dx9bc.cpp"), - path.join(BGFX_DIR, "src/shader_dxbc.cpp"), - path.join(BGFX_DIR, "src/shader_spirv.cpp"), + path.join(BGFX_DIR, "src/hmd**.cpp"), + path.join(BGFX_DIR, "src/renderer_**.cpp"), + path.join(BGFX_DIR, "src/shader**.cpp"), + path.join(BGFX_DIR, "src/topology.cpp"), path.join(BGFX_DIR, "src/vertexdecl.cpp"), } @@ -156,20 +190,23 @@ function bgfxProject(_name, _kind, _defines) } excludes { - path.join(BGFX_DIR, "src/glcontext_eagl.mm"), - path.join(BGFX_DIR, "src/glcontext_nsgl.mm"), - path.join(BGFX_DIR, "src/renderer_mtl.mm"), + path.join(BGFX_DIR, "src/glcontext_**.mm"), + path.join(BGFX_DIR, "src/renderer_**.mm"), path.join(BGFX_DIR, "src/amalgamated.cpp"), } + configuration { "not (xcode* or osx or ios*)" } + excludes { + path.join(BGFX_DIR, "src/**.mm"), + } + configuration {} else configuration { "xcode* or osx or ios*" } files { - path.join(BGFX_DIR, "src/glcontext_eagl.mm"), - path.join(BGFX_DIR, "src/glcontext_nsgl.mm"), - path.join(BGFX_DIR, "src/renderer_mtl.mm"), + path.join(BGFX_DIR, "src/glcontext_**.mm"), + path.join(BGFX_DIR, "src/renderer_**.mm"), } configuration {} diff --git a/3rdparty/bgfx/scripts/genie.lua b/3rdparty/bgfx/scripts/genie.lua index fe21f0eaa14..2e915603fef 100644 --- a/3rdparty/bgfx/scripts/genie.lua +++ b/3rdparty/bgfx/scripts/genie.lua @@ -43,6 +43,11 @@ newoption { description = "Enable building tools.", } +newoption { + trigger = "with-examples", + description = "Enable building examples.", +} + solution "bgfx" configurations { "Debug", @@ -355,48 +360,52 @@ end dofile "bgfx.lua" -group "examples" -dofile "example-common.lua" - group "libs" bgfxProject("", "StaticLib", {}) -group "examples" -exampleProject("00-helloworld") -exampleProject("01-cubes") -exampleProject("02-metaballs") -exampleProject("03-raymarch") -exampleProject("04-mesh") -exampleProject("05-instancing") -exampleProject("06-bump") -exampleProject("07-callback") -exampleProject("08-update") -exampleProject("09-hdr") -exampleProject("10-font") -exampleProject("11-fontsdf") -exampleProject("12-lod") -exampleProject("13-stencil") -exampleProject("14-shadowvolumes") -exampleProject("15-shadowmaps-simple") -exampleProject("16-shadowmaps") -exampleProject("17-drawstress") -exampleProject("18-ibl") -exampleProject("19-oit") -exampleProject("20-nanovg") -exampleProject("21-deferred") -exampleProject("22-windows") -exampleProject("23-vectordisplay") -exampleProject("24-nbody") -exampleProject("26-occlusion") -exampleProject("27-terrain") -exampleProject("28-wireframe") -exampleProject("29-debugdraw") -exampleProject("30-picking") -exampleProject("31-rsm") - --- C99 source doesn't compile under WinRT settings -if not premake.vstudio.iswinrt() then - exampleProject("25-c99") +if _OPTIONS["with-examples"] or _OPTIONS["with-tools"] then + group "examples" + dofile "example-common.lua" +end + +if _OPTIONS["with-examples"] then + group "examples" + exampleProject("00-helloworld") + exampleProject("01-cubes") + exampleProject("02-metaballs") + exampleProject("03-raymarch") + exampleProject("04-mesh") + exampleProject("05-instancing") + exampleProject("06-bump") + exampleProject("07-callback") + exampleProject("08-update") + exampleProject("09-hdr") + exampleProject("10-font") + exampleProject("11-fontsdf") + exampleProject("12-lod") + exampleProject("13-stencil") + exampleProject("14-shadowvolumes") + exampleProject("15-shadowmaps-simple") + exampleProject("16-shadowmaps") + exampleProject("17-drawstress") + exampleProject("18-ibl") + exampleProject("19-oit") + exampleProject("20-nanovg") + exampleProject("21-deferred") + exampleProject("22-windows") + exampleProject("23-vectordisplay") + exampleProject("24-nbody") + exampleProject("26-occlusion") + exampleProject("27-terrain") + exampleProject("28-wireframe") + exampleProject("29-debugdraw") + exampleProject("30-picking") + exampleProject("31-rsm") + + -- C99 source doesn't compile under WinRT settings + if not premake.vstudio.iswinrt() then + exampleProject("25-c99") + end end if _OPTIONS["with-shared-lib"] then diff --git a/3rdparty/bgfx/scripts/shader.mk b/3rdparty/bgfx/scripts/shader.mk index 7a479ea8896..56937fb1026 100644 --- a/3rdparty/bgfx/scripts/shader.mk +++ b/3rdparty/bgfx/scripts/shader.mk @@ -15,15 +15,18 @@ ifndef TARGET .PHONY: all all: @echo Usage: make TARGET=# [clean, all, rebuild] - @echo " TARGET=0 (hlsl - dx9)" - @echo " TARGET=1 (hlsl - dx11)" - @echo " TARGET=2 (glsl - nacl)" - @echo " TARGET=3 (glsl - android)" - @echo " TARGET=4 (glsl - linux)" - @echo " TARGET=5 (metal - OSX/iOS)" - @echo " VERBOSE=1 show build commands." + @echo " TARGET=0 (hlsl - d3d9)" + @echo " TARGET=1 (hlsl - d3d11)" + @echo " TARGET=2 (essl - nacl)" + @echo " TARGET=3 (essl - android)" + @echo " TARGET=4 (glsl)" + @echo " TARGET=5 (metal)" + @echo " TARGET=6 (pssl)" + @echo " TARGET=7 (spriv)" else +ADDITIONAL_INCLUDES?= + ifeq ($(TARGET), 0) VS_FLAGS=--platform windows -p vs_3_0 -O 3 FS_FLAGS=--platform windows -p ps_3_0 -O 3 @@ -38,13 +41,13 @@ else ifeq ($(TARGET), 2) VS_FLAGS=--platform nacl FS_FLAGS=--platform nacl -SHADER_PATH=shaders/gles +SHADER_PATH=shaders/essl else ifeq ($(TARGET), 3) VS_FLAGS=--platform android FS_FLAGS=--platform android CS_FLAGS=--platform android -SHADER_PATH=shaders/gles +SHADER_PATH=shaders/essl else ifeq ($(TARGET), 4) VS_FLAGS=--platform linux -p 120 @@ -57,6 +60,20 @@ VS_FLAGS=--platform osx -p metal FS_FLAGS=--platform osx -p metal CS_FLAGS=--platform osx -p metal SHADER_PATH=shaders/metal +else +ifeq ($(TARGET), 6) +VS_FLAGS=--platform orbis -p pssl +FS_FLAGS=--platform orbis -p pssl +CS_FLAGS=--platform orbis -p pssl +SHADER_PATH=shaders/pssl +else +ifeq ($(TARGET), 7) +VS_FLAGS=--platform linux -p spirv +FS_FLAGS=--platform linux -p spirv +CS_FLAGS=--platform linux -p spirv +SHADER_PATH=shaders/spirv +endif +endif endif endif endif @@ -65,9 +82,9 @@ endif endif THISDIR := $(dir $(lastword $(MAKEFILE_LIST))) -VS_FLAGS+=-i $(THISDIR)../src/ -FS_FLAGS+=-i $(THISDIR)../src/ -CS_FLAGS+=-i $(THISDIR)../src/ +VS_FLAGS+=-i $(THISDIR)../src/ $(ADDITIONAL_INCLUDES) +FS_FLAGS+=-i $(THISDIR)../src/ $(ADDITIONAL_INCLUDES) +CS_FLAGS+=-i $(THISDIR)../src/ $(ADDITIONAL_INCLUDES) BUILD_OUTPUT_DIR=$(addprefix ./, $(RUNTIME_DIR)/$(SHADER_PATH)) BUILD_INTERMEDIATE_DIR=$(addprefix $(BUILD_DIR)/, $(SHADER_PATH)) diff --git a/3rdparty/bgfx/scripts/shaderc.lua b/3rdparty/bgfx/scripts/shaderc.lua index f45310417e4..3942b6917de 100644 --- a/3rdparty/bgfx/scripts/shaderc.lua +++ b/3rdparty/bgfx/scripts/shaderc.lua @@ -114,4 +114,26 @@ project "shaderc" path.join(GLSL_OPTIMIZER, "src/glsl/builtin_stubs.cpp"), } + if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "scripts/shaderc.lua"), }) then + + if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), }) then + + removefiles { + path.join(BGFX_DIR, "tools/shaderc/shaderc_pssl.cpp"), + } + end + + if filesexist(BGFX_DIR, path.join(BGFX_DIR, "../bgfx-ext"), { + path.join(BGFX_DIR, "tools/shaderc/shaderc_spirv.cpp"), }) then + + removefiles { + path.join(BGFX_DIR, "tools/shaderc/shaderc_spirv.cpp"), + } + end + + dofile(path.join(BGFX_DIR, "../bgfx-ext/scripts/shaderc.lua") ) + end + strip() |