diff options
| author | Yong He <yonghe@outlook.com> | 2024-12-05 19:33:55 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-06 03:33:55 +0000 |
| commit | 7dabfa76ccfb396e9d2019e2b6e01259d1661dc5 (patch) | |
| tree | 8f9a39b9d25d04051d02e63450f66c852d744e62 /source/slang/slang-parameter-binding.cpp | |
| parent | ecc5a39feecbf73feedf352214406c8752af798a (diff) | |
Implement explciit binding for metal and wgsl. (#5778)
* Respect explicit bindings in wgsl emit.
* Implement explciit binding generation for metal and wgsl.
* Update toc.
* Fix warnings in tests.
* Fix tests.
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'source/slang/slang-parameter-binding.cpp')
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/source/slang/slang-parameter-binding.cpp b/source/slang/slang-parameter-binding.cpp index e45eb4652..f9c4f0c94 100644 --- a/source/slang/slang-parameter-binding.cpp +++ b/source/slang/slang-parameter-binding.cpp @@ -984,7 +984,8 @@ static void addExplicitParameterBindings_HLSL( // // For now we do the filtering on target in a very direct fashion: // - if (!isD3DTarget(context->getTargetRequest()) && !isMetalTarget(context->getTargetRequest())) + bool isMetal = isMetalTarget(context->getTargetRequest()); + if (!isD3DTarget(context->getTargetRequest()) && !isMetal) return; auto typeLayout = varLayout->typeLayout; @@ -1018,6 +1019,7 @@ static void addExplicitParameterBindings_HLSL( if (kind == LayoutResourceKind::None) continue; + // TODO: need to special-case when this is a `c` register binding... // Find the appropriate resource-binding information @@ -1025,6 +1027,19 @@ static void addExplicitParameterBindings_HLSL( // of the given kind. auto typeRes = typeLayout->FindResourceInfo(kind); + if (isMetal && !typeRes) + { + // Metal doesn't distinguish a unordered access and a readonly/uniform buffer. + switch (kind) + { + case LayoutResourceKind::UnorderedAccess: + case LayoutResourceKind::ShaderResource: + semanticInfo.kind = LayoutResourceKind::MetalBuffer; + typeRes = typeLayout->FindResourceInfo(LayoutResourceKind::MetalBuffer); + break; + } + } + LayoutSize count = 0; if (typeRes) { @@ -1073,7 +1088,7 @@ static void addExplicitParameterBindings_GLSL( // so that we are able to distinguish between // Vulkan and OpenGL as targets. // - if (!isKhronosTarget(context->getTargetRequest())) + if (!isKhronosTarget(context->getTargetRequest()) && !isWGPUTarget(context->getTargetRequest())) return; auto typeLayout = varLayout->typeLayout; |
