From 4c78efd0c34442866f20e9d00bbb6908115c9a01 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Nov 2023 14:32:33 -0800 Subject: Unify stdlib `Texture` types into one generic type. (#3327) * Unify Texture types in stdlib into 1 generic type. * Fixes. * Fix. * Fixes. * Fix reflection. * Fix binding reflection. * Add gather intrinsics. * Fix gather intrinsics. * Fix texture type toText. * Fix intrinsic. * fix cuda intrinsic. * Fix project files. * cleanup. * Fix. * Fix. * Fix sampler feedback test. * Fix getDimension intrinsics. * Fix spirv sample image intrinsics. * Fix test. * Fix GLSL intrinsic. * Cleanup. --------- Co-authored-by: Yong He --- source/slang/slang-type-layout.cpp | 51 +++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'source/slang/slang-type-layout.cpp') diff --git a/source/slang/slang-type-layout.cpp b/source/slang/slang-type-layout.cpp index 8c1108870..691e5864c 100644 --- a/source/slang/slang-type-layout.cpp +++ b/source/slang/slang-type-layout.cpp @@ -3813,15 +3813,31 @@ static TypeLayoutResult _createTypeLayout( // TODO: the logic here should really be defined by the rules, // and not at this top level... ShaderParameterKind kind; - switch( textureType->getAccess() ) + if (textureType->isCombined()) { - default: - kind = ShaderParameterKind::MutableTexture; - break; + switch (textureType->getAccess()) + { + default: + kind = ShaderParameterKind::MutableTextureSampler; + break; - case SLANG_RESOURCE_ACCESS_READ: - kind = ShaderParameterKind::Texture; - break; + case SLANG_RESOURCE_ACCESS_READ: + kind = ShaderParameterKind::TextureSampler; + break; + } + } + else + { + switch( textureType->getAccess() ) + { + default: + kind = ShaderParameterKind::MutableTexture; + break; + + case SLANG_RESOURCE_ACCESS_READ: + kind = ShaderParameterKind::Texture; + break; + } } return createSimpleTypeLayout( @@ -3850,27 +3866,6 @@ static TypeLayoutResult _createTypeLayout( type, rules); } - else if (auto textureSamplerType = as(type)) - { - // TODO: the logic here should really be defined by the rules, - // and not at this top level... - ShaderParameterKind kind; - switch( textureSamplerType->getAccess() ) - { - default: - kind = ShaderParameterKind::MutableTextureSampler; - break; - - case SLANG_RESOURCE_ACCESS_READ: - kind = ShaderParameterKind::TextureSampler; - break; - } - - return createSimpleTypeLayout( - rules->GetObjectLayout(kind, context.objectLayoutOptions), - type, - rules); - } // TODO: need a better way to handle this stuff... #define CASE(TYPE, KIND) \ -- cgit v1.2.3