summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-hlsl-to-vulkan-layout-options.cpp18
-rw-r--r--source/slang/slang-hlsl-to-vulkan-layout-options.h29
-rw-r--r--source/slang/slang-options.cpp9
-rw-r--r--source/slang/slang-parameter-binding.cpp6
4 files changed, 44 insertions, 18 deletions
diff --git a/source/slang/slang-hlsl-to-vulkan-layout-options.cpp b/source/slang/slang-hlsl-to-vulkan-layout-options.cpp
index bb02a079c..1033c0f56 100644
--- a/source/slang/slang-hlsl-to-vulkan-layout-options.cpp
+++ b/source/slang/slang-hlsl-to-vulkan-layout-options.cpp
@@ -8,14 +8,16 @@ namespace { // anonymous
typedef HLSLToVulkanLayoutOptions::Kind ShiftKind;
-/* {b|s|t|u} */
+/* {b|s|t|u}
+https://github.com/KhronosGroup/glslang/wiki/HLSL-FAQ
+*/
static NamesDescriptionValue s_vulkanShiftKinds[] =
{
- { ValueInt(ShiftKind::Buffer), "b", "Vulkan Buffer resource" },
- { ValueInt(ShiftKind::Sampler), "s", "Vulkan Sampler resource" },
- { ValueInt(ShiftKind::Texture), "t", "Vulkan Texture resource" },
- { ValueInt(ShiftKind::Uniform), "u", "Vulkan Uniform resource" },
+ { ValueInt(ShiftKind::ConstantBuffer), "b", "Constant buffer view" },
+ { ValueInt(ShiftKind::Sampler), "s", "Sampler" },
+ { ValueInt(ShiftKind::ShaderResource), "t", "Shader resource view" },
+ { ValueInt(ShiftKind::UnorderedAccess), "u", "Unorderd access view" },
};
} // anonymous
@@ -136,10 +138,10 @@ HLSLToVulkanLayoutOptions::Binding HLSLToVulkanLayoutOptions::inferBinding(Kind
case ParameterCategory::Uniform:
case ParameterCategory::ConstantBuffer:
{
- return Kind::Uniform;
+ return Kind::ConstantBuffer;
}
- case ParameterCategory::ShaderResource: return Kind::Texture;
- case ParameterCategory::UnorderedAccess: return Kind::Buffer;
+ case ParameterCategory::ShaderResource: return Kind::ShaderResource;
+ case ParameterCategory::UnorderedAccess: return Kind::UnorderedAccess;
case ParameterCategory::SamplerState: return Kind::Sampler;
default:
diff --git a/source/slang/slang-hlsl-to-vulkan-layout-options.h b/source/slang/slang-hlsl-to-vulkan-layout-options.h
index 642f6b5f4..b9eb3046d 100644
--- a/source/slang/slang-hlsl-to-vulkan-layout-options.h
+++ b/source/slang/slang-hlsl-to-vulkan-layout-options.h
@@ -32,15 +32,36 @@ public:
Index index = -1;
};
+ // https://github.com/KhronosGroup/glslang/wiki/HLSL-FAQ
// {b|s|t|u}
enum class Kind
{
Invalid = -1,
- Buffer, ///< Buffer
- Sampler, ///< Sampler
- Texture, ///< Texture
- Uniform, ///< Uniform
+ /// Unordered access view (u)
+ ///
+ /// RWByteAddressBuffer/RWStructuredBuffer
+ /// Append/ConsumeStructuredBuffer
+ /// RWBuffer
+ /// RWTextureXD/Array
+ UnorderedAccess,
+
+ /// Sampler (s)
+ ///
+ /// SamplerXD
+ /// SamplerState/SamplerComparisonState
+ Sampler,
+
+ /// Shader Resource (t)
+ ///
+ /// TextureXD/Array
+ /// ByteAddressBuffer/StructuredBuffer/Buffer/TBuffer
+ ShaderResource,
+
+ /// Constant buffer (b)
+ ///
+ /// ConstantBufferViews, CBuffer
+ ConstantBuffer,
CountOf,
};
diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp
index 552d5bc47..dd4473497 100644
--- a/source/slang/slang-options.cpp
+++ b/source/slang/slang-options.cpp
@@ -484,13 +484,16 @@ void initCommandOptions(CommandOptions& options)
{ OptionKind::GLSLForceScalarLayout,
"-force-glsl-scalar-layout", nullptr,
"Force using scalar block layout for uniform and shader storage buffers in GLSL output."},
- { OptionKind::VulkanBindShift, vkShiftNames.getBuffer(), "-vk-<vulkan-shift>-shift <N> <space>",
- "For example '-vk-b-shift <N> <space>' shifts by N the inferred binding numbers for all resources in 'b' registers of space <space>. "
+ { OptionKind::VulkanBindShift, vkShiftNames.getBuffer(), "-fvk-<vulkan-shift>-shift <N> <space>",
+ "For example '-fvk-b-shift <N> <space>' shifts by N the inferred binding numbers for all resources in 'b' registers of space <space>. "
"For a resource attached with :register(bX, <space>) but not [vk::binding(...)], "
"sets its Vulkan descriptor set to <space> and binding number to X + N. If you need to shift the "
"inferred binding numbers for more than one space, provide more than one such option. "
"If more than one such option is provided for the same space, the last one takes effect. "
- "If you need to shift the inferred binding numbers for all sets, use 'all' as <space>." },
+ "If you need to shift the inferred binding numbers for all sets, use 'all' as <space>. "
+ "\n"
+ "* [DXC description](https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#implicit-binding-number-assignment)\n"
+ "* [GLSL wiki](https://github.com/KhronosGroup/glslang/wiki/HLSL-FAQ#auto-mapped-binding-numbers)\n" },
{ OptionKind::VulkanBindGlobals, "-fvk-bind-globals", "-fvk-bind-globals <N> <descriptor-set>",
"Places the $Globals cbuffer at descriptor set <descriptor-set> and binding <N>."},
{ OptionKind::EnableEffectAnnotations,
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp
index e22bc0597..1d38bc2f0 100644
--- a/source/slang/slang-parameter-binding.cpp
+++ b/source/slang/slang-parameter-binding.cpp
@@ -575,7 +575,7 @@ LayoutSemanticInfo extractHLSLLayoutSemanticInfo(
return info;
}
-LayoutSemanticInfo ExtractLayoutSemanticInfo(
+static LayoutSemanticInfo _extractLayoutSemanticInfo(
ParameterBindingContext* context,
HLSLLayoutSemantic* semantic)
{
@@ -938,7 +938,7 @@ static void addExplicitParameterBindings_HLSL(
for (auto semantic : varDecl.getDecl()->getModifiersOfType<HLSLLayoutSemantic>())
{
// Need to extract the information encoded in the semantic
- LayoutSemanticInfo semanticInfo = ExtractLayoutSemanticInfo(context, semantic);
+ LayoutSemanticInfo semanticInfo = _extractLayoutSemanticInfo(context, semantic);
auto kind = semanticInfo.kind;
if (kind == LayoutResourceKind::None)
continue;
@@ -1076,7 +1076,7 @@ static void addExplicitParameterBindings_GLSL(
}
// Get the HLSL binding info
- const auto hlslInfo = ExtractLayoutSemanticInfo(context, hlslRegSemantic);
+ const auto hlslInfo = _extractLayoutSemanticInfo(context, hlslRegSemantic);
if (hlslInfo.kind == LayoutResourceKind::None)
{
// Is no hlsl resource binding