microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] [SPIR-V] `vk::ext_extension(string name,bool enable)` to conditionally enable extensions

devshgraphicsprogramming opened this issue · comments

Is your feature request related to a problem? Please describe.

I'm autogenerating large amounts of templates SPIR-V intrinsics, and as you know depending on their argument types extensions or capabilities might be required (i.e. atomicIAdd on a 64bit value needs 64-bit atomic capability).

Describe the solution you'd like

Since I would have used a template metaprogramming conditional to choose between the extension string and some other ubiquitous string, it would save everyone legwork, if the ext_extension attribute just took a literal boolean whether to enable it or not.

Describe alternatives you've considered

For capabilities its easy to do:

[[vk::ext_capability(conditional_capability_v<SomeCondition,CapabilityEnum>)]]

where upon false I just default to the Shader capability which everyone needs to have.

but because vk::ext_extension takes a string, it makes any of these impossible

// complains not literal
static const string str = "SPV_EXT_shader_stencil_export";
// non-type template argument does not refer to any declaration
using cstr = integral_type<string,"SPV_EXT_shader_stencil_export">;
using cstr2 = integral_type<__decltype("SPV_EXT_shader_stencil_export"),"SPV_EXT_shader_stencil_export">;
// SIGSEGV
static __decltype("SPV_EXT_shader_stencil_export") str = "SPV_EXT_shader_stencil_export";