Merge remote-tracking branch 'upstream/vulkan' into vulkan-glslc

This commit is contained in:
Ivan Avdeev 2021-03-01 23:22:40 -08:00
commit dc71afd08a
2 changed files with 58 additions and 0 deletions

View File

@ -15,6 +15,7 @@ def configure(conf):
if conf.options.DEDICATED:
return
conf.load('glslc')
conf.define('REF_DLL', 1)
if conf.env.DEST_OS == 'win32':
@ -29,6 +30,7 @@ def build(bld):
libs = [ 'public', 'M' ]
source = bld.path.ant_glob(['*.c'])
glsl_source = bld.path.ant_glob(['shaders/*.vert', 'shaders/*.frag'])
includes = ['.',
'../engine',
@ -53,3 +55,11 @@ def build(bld):
subsystem = bld.env.MSVC_SUBSYSTEM
)
bld(
source = glsl_source,
features = 'glsl',
# includes = 'shaders/', # write your includes here
# defines = 'TEST', # write your C preprocessor defines here
install_path = '${LIBDIR}/valve' # TEMPORARY!!!!
)

48
scripts/waifulib/glslc.py Normal file
View File

@ -0,0 +1,48 @@
# encoding: utf-8
# a1batross, 2020
import os
from waflib import *
from waflib.Tools import c_preproc, ccroot
def configure(conf):
conf.find_program('glslc')
conf.add_os_flags('GLSLCPPFLAGS', dup=False)
conf.add_os_flags('GLSLCFLAGS', dup=False)
v = conf.env
v.GLSLCINCLUDES = []
v.GLSLCDEFINES = []
v.GLSLCPPPATH_ST = '-I%s'
v.GLSLDEFINES_ST = '-D%s'
v.GLSLC_SRC_F = []
v.GLSLC_TGT_F = ['-c', '-o']
class glsl(Task.Task):
color = 'PINK'
run_str = '${GLSLC} ${GLSLCFLAGS} ${GLSLCPPPATH_ST:INCPATHS} ${GLSLDEFINES_ST:GLSLCDEFINES} ${GLSLC_SRC_F}${SRC} ${GLSLC_TGT_F}${TGT[0].abspath()} ${GLSLCPPFLAGS}'
vars = ['GLSLCDEPS'] # unused variable to depend on, just in case
ext_in = ['.h'] # set the build order easily by using ext_out=['.h']
scan = c_preproc.scan
def keyword(self):
return 'Compiling shader'
@TaskGen.extension('.vert', '.frag')
def process_glsl_source(self, src):
# see ccroot.apply_incpaths
lst = self.to_incnodes(self.to_list(getattr(self, 'includes', [])) + self.env.GLSLCINCLUDES)
self.includes_nodes = lst
cwd = self.get_cwd()
self.env.INCPATHS = [x.path_from(cwd) for x in lst]
self.env.append_unique('GLSLCDEFINES', self.to_list(getattr(self, 'defines', [])))
tsk = self.create_task('glsl', src, src.parent.find_or_declare('%s.spv' % src.name))
inst_to = getattr(self, 'install_path', None)
if inst_to:
self.add_install_files(install_to=inst_to,
install_from=tsk.outputs[:], chmod=Utils.O755, task=tsk)