Revision 4323a15708cafa6411ec10ef8fefb736f8bda82c authored by Theresa Foley on 11 August 2021, 18:00:16 UTC, committed by GitHub on 11 August 2021, 18:00:16 UTC
* Fix a few issues around opaque types as outputs

Slang and HLSL support opaque types (textures, buffers, samplers, etc.) as members of `struct`s, mutable local variables, function results, and `out`/`inout` parameters. GLSL and SPIR-V do not.

In order to translate Slang code over to GLSL/SPIR-V we use a variety of passes that seek to eliminate all of the above use cases and produce code that only uses opaque types in the limited ways that GLSL/SPIR-V allow. This change relates to the passes that deal with function results and `out`/`inout` parameters.

There are two basic changes here:

1. The `specializeResourceOutputs` pass was only dealing with resource (texture/buffer) types. This change updates it to process sampler types as well.

2. The sequencing of the passes made it possible that an opaque-typed local variable might be left around after `specializeResourceOutputs`, which would mean the code is still invalid for GLSL/SPIR-V. This change adds an additional SSA-formation pass which would eliminate any opaque-type local variables whose lifetimes were made simple enough by the optimizations.

Together these changes fix a problem-case user shader that was failing to compile for Vulkan.

* Update slang-emit.cpp

Fix typo 'reuslt'

* Update slang-emit.cpp

Comment change to re-trigger CI build.

Co-authored-by: jsmall-nvidia <jsmall@nvidia.com>
1 parent 08e36dd
Raw File
github_test.sh
#!/usr/bin/env bash

# CONFIGURATION=release or debug
if [ "${CC}" == "gcc" ] && [ "${CONFIGURATION}" == "release" ]
then
    SLANG_TEST_CATEGORY=full
else
    SLANG_TEST_CATEGORY=smoke
fi

PLATFORM=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCHITECTURE=$(uname -p)

if [ "${ARCHITECTURE}" == "x86_64" ]; then
    ARCHITECTURE="x64"
fi

TARGET=${PLATFORM}-${ARCHITECTURE}

OUTPUTDIR=bin/${TARGET}/${CONFIGURATION}/

if [ "${ARCHITECTURE}" == "x64" ]; then
    LOCATION=$(curl -s https://api.github.com/repos/shader-slang/swiftshader/releases/latest \
    | grep "tag_name" \
    | awk '{print "https://github.com/shader-slang/swiftshader/releases/download/" substr($2, 2, length($2)-3) "/vk_swiftshader_linux_x64.zip"}')
    curl -L -o libswiftshader.zip $LOCATION
    unzip libswiftshader.zip -d $OUTPUTDIR
fi

SLANG_TEST=${OUTPUTDIR}slang-test

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OUTPUTDIR
${SLANG_TEST} -bindir ${OUTPUTDIR} -travis -category ${SLANG_TEST_CATEGORY} ${SLANG_TEST_FLAGS}
back to top