test: Add simple_vertex.spvasm

Update test-all.sh to grep for and test spvasm files.

Bug: tint:740
Change-Id: Ic43faeda35b0b1fd98e42dac2f8a515f118c5ce7
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48690
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton 2021-04-26 10:46:55 +00:00 committed by Commit Bot service account
parent 8f9de8a509
commit 6e2ed30be3
2 changed files with 61 additions and 9 deletions

52
test/simple_vertex.spvasm Normal file
View File

@ -0,0 +1,52 @@
; #version 450
;
; void main() {
; gl_Position = vec4(0.0);
; }
; SPIR-V
; Version: 1.0
; Generator: Google Shaderc over Glslang; 10
; Bound: 20
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %_
OpSource GLSL 450
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
OpSourceExtension "GL_GOOGLE_include_directive"
OpName %main "main"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %_ ""
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%float_0 = OpConstant %float 0
%17 = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
%_ptr_Output_v4float = OpTypePointer Output %v4float
%main = OpFunction %void None %3
%5 = OpLabel
%19 = OpAccessChain %_ptr_Output_v4float %_ %int_0
OpStore %19 %17
OpReturn
OpFunctionEnd

View File

@ -35,13 +35,13 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
NUM_PASS=0 NUM_PASS=0
NUM_FAIL=0 NUM_FAIL=0
# check(WGSL_FILE, FORMAT) # check(TEST_FILE, FORMAT)
function check() { function check() {
WGSL_FILE=$1 TEST_FILE=$1
FORMAT=$2 FORMAT=$2
printf "%7s: " "${FORMAT}" printf "%7s: " "${FORMAT}"
set +e set +e
${TINT} ${WGSL_FILE} --format ${FORMAT} -o /dev/null ${TINT} ${TEST_FILE} --format ${FORMAT} -o /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "${TEXT_GREEN}PASS${TEXT_DEFAULT}" echo -e "${TEXT_GREEN}PASS${TEXT_DEFAULT}"
NUM_PASS=$((${NUM_PASS}+1)) NUM_PASS=$((${NUM_PASS}+1))
@ -52,14 +52,14 @@ function check() {
set -e set -e
} }
for WGSL_FILE in ${SCRIPT_DIR}/*.wgsl for TEST_FILE in ${SCRIPT_DIR}/*.spvasm ${SCRIPT_DIR}/*.wgsl
do do
echo echo
echo "Testing $WGSL_FILE..." echo "Testing $TEST_FILE..."
check "${WGSL_FILE}" wgsl check "${TEST_FILE}" wgsl
check "${WGSL_FILE}" spirv check "${TEST_FILE}" spirv
check "${WGSL_FILE}" msl check "${TEST_FILE}" msl
check "${WGSL_FILE}" hlsl check "${TEST_FILE}" hlsl
done done
if [ ${NUM_FAIL} -ne 0 ]; then if [ ${NUM_FAIL} -ne 0 ]; then