From 00bd481e001e8c0b8008eaff5a38fa37963e6f99 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Tue, 15 Aug 2023 20:28:42 +0800 Subject: SPIR-V WIP (#3064) * Add type layout for structured buffer * Default to generating spirv directly * vk test for compute simple * Add spirv-dis as a downstream compiler * Emit Array types in SPIR-V * makevector for spirv * Dump whole spirv module on validation failure * register array types todo, use emitTypeInst * Neater formatting for unhandled inst printing * break out emitCompositeConstruct * Correct array type generation * neaten * Allow getElement for vector * Remove unused * Allow predicating target intrinsics on types * Consider functions with intrinsics to have definitions We need to specialize these if they are predicated on types * Correct array type generation * makeArray for spir-v * replace getElement with getElementPtr for spirv * Correct translation of field access for spirv * Push layouts to types for spirv * Spirv intrinsics * operator now makes a pointer * Add structured buffer of struct test * Preserve type layout in spirv structured buffer legalization * neaten * makeVectorFromScalar for SPIRV * placeholder for layouts on param groups * More type safe spirv op construction * Know that constants and types only go in one section * Remove emitTypeInst * Add todo for spirv sampling * Add links to spirv documentation on emit functions * OpTypeImage support for SPIR-V * Add simpler texture test for spirv * s/spirv_direct/spirv/g * Allow several string literals in target_intrinsic * Handle global params without a var layour for SPIR-V For example groupshared vars * uint spirv asm type * Add todo for isDefinition It is currently too broad * Some atomic op spirv intrinsics * Strip ConstantBuffer wrappers for spirv * Add todo for matrix annotations * Do not associate decorations insts with spirv counterparts * Correct entry point parameter generation * Spelling * Assert that fieldAddress is returning a pointer * Add error for existential type layout getting to spir-v emit * Add IRTupleTypeLayout Unused so far * Allow getElementPtr to work with vectors * Correct target name in test * Hide default spirv direct behind a premake option --default-spirv-direct=true * Do not insert space at start of intrinsic def * Correct asm rendering in tests * remove redundant option * Emit directly from direct test * Add source language options for spirv-dis * Add comments to spirv dis * Add dead debug print for before spirv module * Correct asm rendering in tests * s/spirv_direct/spirv/g * Only specialize intrinsic functions with predicates * regenerate vs projects * squash warnings * squash warnings * remove duplication * Silence warnings from msvc * squash warnings * Overload for zero sized array * More msvc warnings * warnings * Add spirv-tools to path for tests * Do not be specific about dxc version for diag test * Normalize line endings from spirv-dis * Correct filecheck matches * Temporarily disable two spirv tests Failing on CI, undebuggable hang :/ * Do not emit storage class more than once for spirv snippet * Do not pass spir-v to spirv-dis by stdin * Do not get spirv-dis output via stream, use file * normalize file endings in spirv-dis output --- tests/spirv/direct-spirv-compute-simple.slang | 4 +-- tests/spirv/direct-spirv-control-flow-2.slang | 4 +-- tests/spirv/direct-spirv-control-flow.slang | 2 +- tests/spirv/direct-spirv-emit.slang.expected | 35 ++++++++++++++++----------- 4 files changed, 26 insertions(+), 19 deletions(-) (limited to 'tests/spirv') diff --git a/tests/spirv/direct-spirv-compute-simple.slang b/tests/spirv/direct-spirv-compute-simple.slang index 2fa2798e5..4c33d8a72 100644 --- a/tests/spirv/direct-spirv-compute-simple.slang +++ b/tests/spirv/direct-spirv-compute-simple.slang @@ -1,6 +1,6 @@ // direct-spirv-compute-simple.slang -//TESTD:SIMPLE:-target spirv -entry computeMain -stage compute -emit-spirv-directly -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -emit-spirv-directly +//TESTD:SIMPLE:-target spirv -entry computeMain -stage compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute // Test runinng a shader generated from direct SPIR-V emit. diff --git a/tests/spirv/direct-spirv-control-flow-2.slang b/tests/spirv/direct-spirv-control-flow-2.slang index 7dd829bda..697125500 100644 --- a/tests/spirv/direct-spirv-control-flow-2.slang +++ b/tests/spirv/direct-spirv-control-flow-2.slang @@ -1,7 +1,7 @@ // direct-spirv-control-flow-2.slang -//TESTD:SIMPLE:-target spirv -entry computeMain -stage compute -emit-spirv-directly -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type -emit-spirv-directly +//TESTD:SIMPLE:-target spirv -entry computeMain -stage compute +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -output-using-type // Test direct SPIR-V emit on control flows. diff --git a/tests/spirv/direct-spirv-control-flow.slang b/tests/spirv/direct-spirv-control-flow.slang index 10bee2522..744519438 100644 --- a/tests/spirv/direct-spirv-control-flow.slang +++ b/tests/spirv/direct-spirv-control-flow.slang @@ -1,6 +1,6 @@ // direct-spirv-control-flow.slang -//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -emit-spirv-directly +//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute // Test direct SPIRV emit on control fl. diff --git a/tests/spirv/direct-spirv-emit.slang.expected b/tests/spirv/direct-spirv-emit.slang.expected index aff2198be..55cc718a8 100644 --- a/tests/spirv/direct-spirv-emit.slang.expected +++ b/tests/spirv/direct-spirv-emit.slang.expected @@ -2,19 +2,26 @@ result code = 0 standard error = { } standard output = { -// Module Version 10500 -// Generated by (magic number): 0 -// Id's are bound by 5 +; SPIR-V +; Version: 1.5 +; Generator: Khronos; 0 +; Bound: 5 +; Schema: 0 + OpCapability Shader + OpMemoryModel Logical GLSL450 + OpEntryPoint GLCompute %computeMain "computeMain" + OpExecutionMode %computeMain LocalSize 4 1 1 - Capability Shader - MemoryModel Logical GLSL450 - EntryPoint GLCompute 2 "computeMain" - ExecutionMode 2 LocalSize 4 1 1 - Name 2 "computeMain" - 1: TypeVoid - 3: TypeFunction 1 - 2(computeMain): 1 Function None 3 - 4: Label - Return - FunctionEnd + ; Debug Information + OpName %computeMain "computeMain" ; id %2 + + ; Types, variables and constants + %void = OpTypeVoid + %3 = OpTypeFunction %void + + ; Function computeMain +%computeMain = OpFunction %void None %3 + %4 = OpLabel + OpReturn + OpFunctionEnd } -- cgit v1.2.3