diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-emit-wgsl.cpp | 2 | ||||
| -rw-r--r-- | source/slang/slang-parameter-binding.cpp | 19 |
2 files changed, 18 insertions, 3 deletions
diff --git a/source/slang/slang-emit-wgsl.cpp b/source/slang/slang-emit-wgsl.cpp index 13c14cf34..cba9c1b54 100644 --- a/source/slang/slang-emit-wgsl.cpp +++ b/source/slang/slang-emit-wgsl.cpp @@ -663,7 +663,7 @@ void WGSLSourceEmitter::emitLayoutQualifiersImpl(IRVarLayout* layout) EmitVarChain chain = {}; chain.varLayout = layout; - auto space = getBindingSpaceForKinds(&chain, kind); + auto space = getBindingSpaceForKinds(&chain, LayoutResourceKindFlag::make(kind)); m_writer->emit("@group("); m_writer->emit(space); m_writer->emit(") "); 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; |
