Updated glslang.

This commit is contained in:
Branimir Karadžić
2017-11-11 22:19:19 -08:00
parent 013a96ad7d
commit b8c9d718f4
9 changed files with 377 additions and 20 deletions

View File

@@ -7,7 +7,7 @@ version: "{build}"
os: Visual Studio 2013
platform:
- Any CPU
- x64
configuration:
- Debug
@@ -39,3 +39,45 @@ build_script:
test_script:
- ctest -C %CONFIGURATION% --output-on-failure
- cd ../Test && bash runtests
- cd ../build
after_test:
# For debug build, the generated dll has a postfix "d" in its name.
- ps: >-
If ($env:configuration -Match "Debug") {
$env:SUFFIX="d"
} Else {
$env:SUFFIX=""
}
- cd install
# Zip all glslang artifacts for uploading and deploying
- 7z a glslang-master-windows-"%PLATFORM%"-"%CONFIGURATION%".zip
bin\glslangValidator.exe
include\glslang\*
include\SPIRV\*
lib\glslang%SUFFIX%.lib
lib\HLSL%SUFFIX%.lib
lib\OGLCompiler%SUFFIX%.lib
lib\OSDependent%SUFFIX%.lib
lib\SPIRV%SUFFIX%.lib
lib\SPVRemapper%SUFFIX%.lib
lib\SPIRV-Tools%SUFFIX%.lib
lib\SPIRV-Tools-opt%SUFFIX%.lib
artifacts:
- path: build\install\*.zip
name: artifacts-zip
deploy:
- provider: GitHub
auth_token:
secure: YglcSYdl0TylEa59H4K6lylBEDr586NAt2EMgZquSo+iuPrwgZQuJLPCoihSm9y6
release: master-tot
description: "Continuous build of the latest master branch by Appveyor and Travis CI"
artifact: artifacts-zip
draft: false
prerelease: false
force_update: true
on:
branch: master
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013

View File

@@ -11,8 +11,11 @@ sudo: false
dist: trusty
env:
- GLSLANG_BUILD_TYPE=Release
- GLSLANG_BUILD_TYPE=Debug
global:
- secure: aGFrgzyKp+84hKrGkxVWg8cHV61uqrKEHT38gfSQK6+WS4GfLOyH83p7WnsEBb7AMhzU7LMNFdvOFr6+NaMpVnqRvc40CEG1Q+lNg9Pq9mhIZLowvDrfqTL9kQ+8Nbw5Q6/dg6CTvY7fvRfpfCEmKIUZBRkoKUuHeuM1uy3IupFcdNuL5bSYn3Beo+apSJginh9DI4BLDXFUgBzTRSLLyCX5g3cpaeGGOCr8quJlYx75W6HRck5g9SZuLtUoH9GFEV3l+ZEWB8noErW+J56L03bwNwFuuAh321evw++oQk5KFa8rlDvar3SJ3b1RHB8u/eq5DBYMyaK/fS8+Q7QbGr8diF/wDe68bKO7U9IhpNfExXmczCpExjHomW5TQv4rYdGhygPMfW97aIsPRYyNKcl4fkmb7NDrM8w0Jscdq2g5c2Kz0ItyZoBri/NXLwFQQjaVCs7Pf97TjuMA7mK0GJmDTRzi6SrDYlWMt5BQL3y0CCojyfLIRcTh0CQjQI29s97bLfQrYAxt9GNNFR+HTXRLLrkaAlJkPGEPwUywlSfEThnvHLesNxYqemolAYpQT4ithoL4GehGIHmaxsW295aKVhuRf8K9eBODNqrfblvM42UHhjntT+92ZnQ/Gkq80GqaMxnxi4PO5FyPIxt0r981b54YBkWi8YA4P7w5pNI=
matrix:
- GLSLANG_BUILD_TYPE=Release
- GLSLANG_BUILD_TYPE=Debug
compiler:
- clang
@@ -75,3 +78,46 @@ script:
ctest --output-on-failure &&
cd ../Test && ./runtests;
fi
after_success:
# For debug build, the generated dll has a postfix "d" in its name.
- if [[ "${GLSLANG_BUILD_TYPE}" == "Debug" ]]; then
export SUFFIX="d";
else
export SUFFIX="";
fi
# Create tarball for deployment
- if [[ ${CC} == clang* && "${BUILD_NDK}" != "ON" ]]; then
cd ../build/install;
export TARBALL=glslang-master-${TRAVIS_OS_NAME}-${GLSLANG_BUILD_TYPE}.zip;
zip ${TARBALL}
bin/glslangValidator
include/glslang/*
include/SPIRV/*
lib/libglslang${SUFFIX}.a
lib/libHLSL${SUFFIX}.a
lib/libOGLCompiler${SUFFIX}.a
lib/libOSDependent${SUFFIX}.a
lib/libSPIRV${SUFFIX}.a
lib/libSPVRemapper${SUFFIX}.a
lib/libSPIRV-Tools${SUFFIX}.a
lib/libSPIRV-Tools-opt${SUFFIX}.a;
fi
before_deploy:
# Tag the current top of the tree as "master-tot".
# Travis CI replies on the tag name to properly push to GitHub Releases.
- git config --global user.name "Travis CI"
- git config --global user.email "builds@travis-ci.org"
- git tag -f master-tot
- git push -q -f https://${glslangtoken}@github.com/KhronosGroup/glslang --tags
deploy:
provider: releases
api_key: ${glslangtoken}
on:
branch: master
condition: ${CC} == clang* && ${BUILD_NDK} != ON
file: ${TARBALL}
skip_cleanup: true
overwrite: true

View File

@@ -268,7 +268,7 @@ void Error(const char* message)
//
// Process an optional binding base of one the forms:
// --argname [stage] base // base for stage (if given) or all stages (if not)
// --argname [stage] [set base]... // set/base pairs: set the base for given binding set.
// --argname [stage] [base set]... // set/base pairs: set the base for given binding set.
// Where stage is one of the forms accepted by FindLanguage, and base is an integer
//
@@ -293,8 +293,8 @@ void ProcessBindingBase(int& argc, char**& argv, glslang::TResourceType res)
if ((argc - arg) > 2 && isdigit(argv[arg+0][0]) && isdigit(argv[arg+1][0])) {
// Parse a per-set binding base
while ((argc - arg) > 2 && isdigit(argv[arg+0][0]) && isdigit(argv[arg+1][0])) {
const int setNum = atoi(argv[arg++]);
const int baseNum = atoi(argv[arg++]);
const int setNum = atoi(argv[arg++]);
perSetBase[setNum] = baseNum;
}
} else {
@@ -821,7 +821,7 @@ void CompileAndLinkShaderUnits(std::vector<ShaderCompUnit> compUnits)
// TODO: use a range based for loop here, when available in all environments.
for (auto i = baseBindingForSet[res][compUnit.stage].begin();
i != baseBindingForSet[res][compUnit.stage].end(); ++i)
shader->setShiftBindingForSet(res, i->first, i->second);
shader->setShiftBindingForSet(res, i->second, i->first);
}
shader->setFlattenUniformArrays((Options & EOptionFlattenUniformArrays) != 0);
@@ -1302,24 +1302,24 @@ void usage()
" Set descriptor set for all resources\n"
" --rsb [stage] type set binding synonym for --resource-set-binding\n"
" --shift-image-binding [stage] num base binding number for images (uav)\n"
" --shift-image-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-image-binding [stage] [num set]... per-descriptor-set shift values\n"
" --sib [stage] num synonym for --shift-image-binding\n"
" --shift-sampler-binding [stage] num base binding number for samplers\n"
" --shift-sampler-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-sampler-binding [stage] [num set]... per-descriptor-set shift values\n"
" --ssb [stage] num synonym for --shift-sampler-binding\n"
" --shift-ssbo-binding [stage] num base binding number for SSBOs\n"
" --shift-ssbo-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-ssbo-binding [stage] [num set]... per-descriptor-set shift values\n"
" --sbb [stage] num synonym for --shift-ssbo-binding\n"
" --shift-texture-binding [stage] num base binding number for textures\n"
" --shift-texture-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-texture-binding [stage] [num set]... per-descriptor-set shift values\n"
" --stb [stage] num synonym for --shift-texture-binding\n"
" --shift-uav-binding [stage] num base binding number for UAVs\n"
" --shift-uav-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-uav-binding [stage] [num set]... per-descriptor-set shift values\n"
" --suavb [stage] num synonym for --shift-uav-binding\n"
" --shift-UBO-binding [stage] num base binding number for UBOs\n"
" --shift-UBO-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-UBO-binding [stage] [num set]... per-descriptor-set shift values\n"
" --shift-cbuffer-binding [stage] num synonym for --shift-UBO-binding\n"
" --shift-cbuffer-binding [stage] [set num]... per-descriptor-set shift values\n"
" --shift-cbuffer-binding [stage] [num set]... per-descriptor-set shift values\n"
" --sub [stage] num synonym for --shift-UBO-binding\n"
" --source-entrypoint <name> the given shader source function is\n"
" renamed to be the <name> given in -e\n"

View File

@@ -108,7 +108,7 @@ diff -b $BASEDIR/hlsl.explicitDescriptorSet-2.frag.out $TARGETDIR/hlsl.explicitD
# Testing per-descriptor-set IO map shift
#
echo 'Testing per-descriptor-set IO map shift'
$EXE -e main --hlsl-iomap --ssb 1 10 2 15 --stb 20 --stb 2 25 --suavb 30 --suavb 2 40 --sub 6 50 -i -q -D -V hlsl.shift.per-set.frag > $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1
$EXE -e main --hlsl-iomap --ssb 10 1 15 2 --stb 20 --stb 25 2 --suavb 30 --suavb 40 2 --sub 50 6 -i -q -D -V hlsl.shift.per-set.frag > $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1
diff -b $BASEDIR/hlsl.shift.per-set.frag.out $TARGETDIR/hlsl.shift.per-set.frag.out || HASERROR=1
#

269
3rdparty/glslang/Test/validate-shaders.sh vendored Executable file
View File

@@ -0,0 +1,269 @@
#!/bin/bash
# This script validates shaders (if successfully compiled) using spirv-val.
# It is not meant to preclude the possible addition of the validator to
# glslang.
declare -r EXE='../build/install/bin/glslangValidator'
# search common locations for spirv-tools: keep first one
for toolsdir in '../External/spirv-tools/build/tools' '../../SPIRV-Tools/build/tools' '/usr/local/bin'; do
[[ -z "$VAL" && -x "${toolsdir}/spirv-val" ]] && declare -r VAL="${toolsdir}/spirv-val"
[[ -z "$DIS" && -x "${toolsdir}/spirv-dis" ]] && declare -r DIS="${toolsdir}/spirv-dis"
done
declare -r gtests='../gtests/Hlsl.FromFile.cpp ../gtests/Spv.FromFile.cpp'
declare -r targetenv='vulkan1.0'
function fatal() { echo "ERROR: $@"; exit 5; }
function usage
{
echo
echo "Usage: $(basename $0) [options...] shaders..."
echo
echo " Validates shaders (if successfully compiled) through spirv-val."
echo
echo "General options:"
echo " --help prints this text"
echo " --no-color disables output colorization"
echo " --dump-asm dumps all successfully compiled shader assemblies"
echo " --dump-val dumps all validation results"
echo " --dump-comp dumps all compilation logs"
echo "Spam reduction options:"
echo " --no-summary disables result summaries"
echo " --skip-ok do not print successful validations"
echo " --skip-comperr do not print compilation errors"
echo " --skip-valerr do not print validation errors"
echo " --quiet synonym for --skip-ok --skip-comperr --skip-valerr --no-summary"
echo " --terse print terse single line progress summary"
echo "Disassembly options:"
echo " --raw-id uses raw ids for disassembly"
echo
echo "Usage examples. Note most non-hlsl tests fail to compile for expected reasons."
echo " Exercise all hlsl.* files:"
echo " $(basename $0) hlsl.*"
echo " Exercise all hlsl.* files, tersely:"
echo " $(basename $0) --terse hlsl.*"
echo " Print validator output for myfile.frag:"
echo " $(basename $0) --quiet --dump-val myfile.frag"
echo " Exercise hlsl.* files, only printing validation errors:"
echo " $(basename $0) --skip-ok --skip-comperr hlsl.*"
exit 5
}
function status()
{
printf "%-40s: %b\n" "$1" "$2"
}
# make sure we can find glslang
[[ -x "$EXE" ]] || fatal "Unable to locate $(basename "$EXE") executable"
[[ -x "$VAL" ]] || fatal "Unable to locate spirv-val executable"
[[ -x "$DIS" ]] || fatal "Unable to locate spirv-dis executable"
for gtest in $gtests; do
[[ -r "$gtest" ]] || fatal "Unable to locate source file: $(basename $gtest)"
done
# temp files
declare -r spvfile='out.spv' \
complog='comp.out' \
vallog='val.out' \
dislog='dis.out' \
# options
declare opt_vallog=false \
opt_complog=false \
opt_dislog=false \
opt_summary=true \
opt_stat_comperr=true \
opt_stat_ok=true \
opt_stat_valerr=true \
opt_color=true \
opt_raw_id=false \
opt_quiet=false \
opt_terse=false
# clean up on exit
trap "rm -f ${spvfile} ${complog} ${vallog} ${dislog}" EXIT
# Language guesser: there is no fixed mapping from filenames to language,
# so this examines the file and return one of:
# hlsl
# glsl
# bin
# unknown
# This is easier WRT future expansion than a big explicit list.
function FindLanguage()
{
local test="$1"
# If it starts with hlsl, assume it's hlsl.
if [[ "$test" == *hlsl.* ]]; then
echo hlsl
return
fi
if [[ "$test" == *.spv ]]; then
echo bin
return;
fi
# If it doesn't start with spv., assume it's GLSL.
if [[ ! "$test" == spv.* && ! "$test" == remap.* ]]; then
echo glsl
return
fi
# Otherwise, attempt to guess from shader contents, since there's no
# fixed mapping of filenames to languages.
local contents="$(cat "$test")"
if [[ "$contents" == *#version* ]]; then
echo glsl
return
fi
if [[ "$contents" == *SamplerState* ||
"$contents" == *cbuffer* ||
"$contents" == *SV_* ]]; then
echo hlsl
return
fi
echo unknown
}
# Attempt to discover entry point
function FindEntryPoint()
{
local test="$1"
# if it's not hlsl, always use main
if [[ "$language" != 'hlsl' ]]; then
echo 'main'
return
fi
# Try to find it in test sources
awk -F '[ (){",]+' -e "\$2 == \"${test}\" { print \$3; found=1; } END { if (found==0) print \"main\"; } " $gtests
}
# command line options
while [ $# -gt 0 ]
do
case "$1" in
# -c) glslang="$2"; shift 2;;
--help|-?) usage;;
--no-color) opt_color=false; shift;;
--no-summary) opt_summary=false; shift;;
--skip-ok) opt_stat_ok=false; shift;;
--skip-comperr) opt_stat_comperr=false; shift;;
--skip-valerr) opt_stat_valerr=false; shift;;
--dump-asm) opt_dislog=true; shift;;
--dump-val) opt_vallog=true; shift;;
--dump-comp) opt_complog=true; shift;;
--raw-id) opt_raw_id=true; shift;;
--quiet) opt_quiet=true; shift;;
--terse) opt_quiet=true
opt_terse=true
shift;;
--*) fatal "Unknown command line option: $1";;
*) break;;
esac
done
# this is what quiet means
if $opt_quiet; then
opt_stat_ok=false
opt_stat_comperr=false
opt_stat_valerr=false
$opt_terse || opt_summary=false
fi
if $opt_color; then
declare -r white="\e[1;37m" cyan="\e[1;36m" red="\e[0;31m" no_color="\e[0m"
else
declare -r white="" cyan="" red="" no_color=""
fi
# stats
declare -i count_ok=0 count_err=0 count_nocomp=0 count_total=0
declare -r dashsep='------------------------------------------------------------------------'
testfiles=(${@})
# if no shaders given, look for everything in current directory
[[ ${#testfiles[*]} == 0 ]] && testfiles=(*.frag *.vert *.tesc *.tese *.geom *.comp)
$opt_summary && printf "\nValidating: ${#testfiles[*]} shaders\n\n"
# Loop through the shaders we were given, compiling them if we can.
for test in ${testfiles[*]}
do
if [[ ! -r "$test" ]]; then
$opt_quiet || status "$test" "${red}FILE NOT FOUND${no_color}"
continue
fi
((++count_total))
$opt_terse && printf "\r[%-3d/%-3d : ${white}comperr=%-3d ${red}valerr=%-3d ${cyan}ok=%-3d${no_color}]" \
${count_total} ${#testfiles[*]} ${count_nocomp} ${count_err} ${count_ok}
language="$(FindLanguage $test)"
entry="$(FindEntryPoint $test)"
langops=''
case "$language" in
hlsl) langops='-D --hlsl-iomap --hlsl-offsets';;
glsl) ;;
bin) continue;; # skip binaries
*) $opt_quiet || status "$test" "${red}UNKNOWN LANGUAGE${no_color}"; continue;;
esac
# compile the test file
if compout=$("$EXE" -e "$entry" $langops -V -o "$spvfile" "$test" 2>&1)
then
# successful compilation: validate
if valout=$("$VAL" --target-env ${targetenv} "$spvfile" 2>&1)
then
# validated OK
$opt_stat_ok && status "$test" "${cyan}OK${no_color}"
((++count_ok))
else
# validation failure
$opt_stat_valerr && status "$test" "${red}VAL ERROR${no_color}"
printf "%s\n%s:\n%s\n" "$dashsep" "$test" "$valout" >> "$vallog"
((++count_err))
fi
if $opt_dislog; then
printf "%s\n%s:\n" "$dashsep" "$test" >> "$dislog"
$opt_raw_id && id_opt=--raw-id
"$DIS" ${id_opt} "$spvfile" >> "$dislog"
fi
else
# compile failure
$opt_stat_comperr && status "$test" "${white}COMP ERROR${no_color}"
printf "%s\n%s\n" "$dashsep" "$compout" >> "$complog"
((++count_nocomp))
fi
done
$opt_terse && echo
# summarize
$opt_summary && printf "\nSummary: ${white}${count_nocomp} compile errors${no_color}, ${red}${count_err} validation errors${no_color}, ${cyan}${count_ok} successes${no_color}\n"
# dump logs
$opt_vallog && [[ -r $vallog ]] && cat "$vallog"
$opt_complog && [[ -r $complog ]] && cat "$complog"
$opt_dislog && [[ -r $dislog ]] && cat "$dislog"
# exit code
[[ ${count_err} -gt 0 ]] && exit 1
exit 0

View File

@@ -1667,8 +1667,8 @@ void TShader::setShiftBinding(TResourceType res, unsigned int base) {
}
// Set binding base for given resource type for a given binding set.
void TShader::setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int base) {
intermediate->setShiftBindingForSet(res, set, base);
void TShader::setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set) {
intermediate->setShiftBindingForSet(res, base, set);
}
// Set binding base for sampler types

View File

@@ -271,7 +271,7 @@ public:
unsigned int getShiftBinding(TResourceType res) const { return shiftBinding[res]; }
void setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int shift)
void setShiftBindingForSet(TResourceType res, unsigned int shift, unsigned int set)
{
if (shift == 0) // ignore if there's no shift: it's a no-op.
return;
@@ -281,8 +281,8 @@ public:
const char* name = getResourceName(res);
if (name != nullptr) {
processes.addProcess(name);
processes.addArgument(set);
processes.addArgument(shift);
processes.addArgument(set);
}
}

View File

@@ -368,7 +368,7 @@ public:
void setShiftUavBinding(unsigned int base); // DEPRECATED: use setShiftBinding
void setShiftCbufferBinding(unsigned int base); // synonym for setShiftUboBinding
void setShiftSsboBinding(unsigned int base); // DEPRECATED: use setShiftBinding
void setShiftBindingForSet(TResourceType res, unsigned int set, unsigned int base);
void setShiftBindingForSet(TResourceType res, unsigned int base, unsigned int set);
void setResourceSetBinding(const std::vector<std::string>& base);
void setAutoMapBindings(bool map);
void setAutoMapLocations(bool map);

View File

@@ -5,7 +5,7 @@
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Tools",
"subdir" : "External/spirv-tools",
"commit" : "5834719fc17d4735fce0102738b87b70255cfd5f"
"commit" : "ac04b2faeabc15811e8c542a5d7a36dbdba243b8"
},
{
"name" : "spirv-tools/external/spirv-headers",