From c9ef8d58a135061262fd321a82061d27dc733cf5 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 3 May 2023 20:16:58 -0400 Subject: HLSL->Vulkan binding support (#2865) * WIP around VK shift binding. * Refactor around options parsing. * Remove needless passing around of sink. * Some more tidying around OptionsParser. * Handle vulkan shift parsing. * Fix small issue around vk binding and "all". * Fixing some small issues. Missing break. * Split out VulkanLayoutOptions * WIP binding taking into account HLSL->Vulkan options. * First attempt at making binding work with HLSLVulkanOptions. * VulkanLayoutOptions -> HLSLToVulkanLayoutOptions * WIP with HLSL-Vulkan binding. * Some more testing around vk-shift. * Improvements around global binding. More tests. * Improve test coverage. Improve checking for requirements around default space. * Update command line options. * Small fixes. * Small fix in options reporting. * Fix warning issue. * Some fixes for isDefault for HLSLToVulkanLayoutOptions. * Update hlsl-to-vulkan-shift output. The difference was due to default handling if shift isn't specified, and not being specified was not correctly tracked. --- source/slang/slang-options.cpp | 3556 +++++++++++++++++++++------------------- 1 file changed, 1893 insertions(+), 1663 deletions(-) (limited to 'source/slang/slang-options.cpp') diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 353c6e57f..0c788a404 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -19,6 +19,7 @@ #include "slang-repro.h" #include "slang-serialize-ir.h" +#include "slang-hlsl-to-vulkan-layout-options.h" #include "../core/slang-castable.h" #include "../core/slang-file-system.h" @@ -81,6 +82,10 @@ enum class OptionKind LineDirectiveMode, Optimization, Obfuscate, + + VulkanBindShift, + VulkanBindGlobals, + GLSLForceScalarLayout, EnableEffectAnnotations, @@ -160,10 +165,25 @@ enum class ValueCategory OptimizationLevel, DebugLevel, FileSystemType, + VulkanShift, CountOf, }; +template +struct GetValueCategory; + +#define SLANG_GET_VALUE_CATEGORY(cat, type) template <> struct GetValueCategory { enum { Value = Index(ValueCategory::cat) }; }; + +SLANG_GET_VALUE_CATEGORY(Compiler, SlangPassThrough) +SLANG_GET_VALUE_CATEGORY(ArchiveType, SlangArchiveType) +SLANG_GET_VALUE_CATEGORY(LineDirectiveMode, SlangLineDirectiveMode) +SLANG_GET_VALUE_CATEGORY(FloatingPointMode, FloatingPointMode) +SLANG_GET_VALUE_CATEGORY(FileSystemType, TypeTextUtil::FileSystemType) +SLANG_GET_VALUE_CATEGORY(HelpStyle, CommandOptionsWriter::Style) +SLANG_GET_VALUE_CATEGORY(OptimizationLevel, SlangOptimizationLevel) +SLANG_GET_VALUE_CATEGORY(VulkanShift, HLSLToVulkanLayoutOptions::Kind) + } // anonymous static void _addOptions(const ConstArrayView