-
Notifications
You must be signed in to change notification settings - Fork 827
Closed
Labels
spirvWork related to SPIR-VWork related to SPIR-V
Description
Title
Crash on assertion when compiling shaders containing SubpassInputs and global struct instances with resource only members
Functional impact
Compiler crashes. Can't use SubpassInputs and sampler2D types emulated via custom structs and functions in the same shader.
Minimal repro steps
- Compile the following pixel shader with
dxc.exe -T ps_6_0 -E frag -spirv repro_shader.hlsl
struct sampler2D {Texture2D t; SamplerState s;};
//float4 tex2D (sampler2D x, float2 v) {return x.t.Sample(x.s, v);}
sampler2D emulatedSampler2D;
[[vk::input_attachment_index (0)]] SubpassInput<min16float4> MySubpassInput;
float4 frag () : SV_TARGET
{
return float4(1, 1, 1, 1);
}
Expected result
Shader compiles successfully
Actual result
Compiler crashes at Tools\clang\lib\SPIRV\DeclResultIdMapper.cpp:72: assert(hlsl::IsHLSLResourceType(type) || isResourceOnlyStructure(type));
Crash stack when debugging the compilation with Visual Studio:
> dxcompiler.dll!llvm_assert(const char * _Message, const char * _File, unsigned int _Line, const char * _Function) Line 23 C++
dxcompiler.dll!clang::spirv::`anonymous namespace'::getNumBindingsUsedByResourceType(clang::QualType type) Line 72 C++
dxcompiler.dll!clang::spirv::DeclResultIdMapper::decorateResourceBindings() Line 1824 C++
dxcompiler.dll!clang::spirv::SpirvEmitter::HandleTranslationUnit(clang::ASTContext & context) Line 571 C++
dxcompiler.dll!clang::ParseAST(clang::Sema & S, bool PrintStats, bool SkipFunctionBodies) Line 162 C++
dxcompiler.dll!clang::ASTFrontendAction::ExecuteAction() Line 556 C++
dxcompiler.dll!clang::FrontendAction::Execute() Line 468 C++
dxcompiler.dll!DxcCompiler::Compile(const DxcBuffer * pSource, const wchar_t * * pArguments, unsigned int argCount, IDxcIncludeHandler * pIncludeHandler, const _GUID & riid, void * * ppResult) Line 777 C++
dxcompiler.dll!hlsl::DxcCompilerAdapter::WrapCompile(int bPreprocess, IDxcBlob * pSource, const wchar_t * pSourceName, const wchar_t * pEntryPoint, const wchar_t * pTargetProfile, const wchar_t * * pArguments, unsigned int argCount, const DxcDefine * pDefines, unsigned int defineCount, IDxcIncludeHandler * pIncludeHandler, IDxcOperationResult * * ppResult, wchar_t * * ppDebugBlobName, IDxcBlob * * ppDebugBlob) Line 1418 C++
dxcompiler.dll!hlsl::DxcCompilerAdapter::CompileWithDebug(IDxcBlob * pSource, const wchar_t * pSourceName, const wchar_t * pEntryPoint, const wchar_t * pTargetProfile, const wchar_t * * pArguments, unsigned int argCount, const DxcDefine * pDefines, unsigned int defineCount, IDxcIncludeHandler * pIncludeHandler, IDxcOperationResult * * ppResult, wchar_t * * ppDebugBlobName, IDxcBlob * * ppDebugBlob) Line 1332 C++
dxcompiler.dll!hlsl::DxcCompilerAdapter::Compile(IDxcBlob * pSource, const wchar_t * pSourceName, const wchar_t * pEntryPoint, const wchar_t * pTargetProfile, const wchar_t * * pArguments, unsigned int argCount, const DxcDefine * pDefines, unsigned int defineCount, IDxcIncludeHandler * pIncludeHandler, IDxcOperationResult * * ppResult) Line 72 C++
dxc.exe!DxcContext::Compile() Line 868 C++
dxc.exe!dxc::main(int argc, const wchar_t * * argv_) Line 1323 C++
dxc.exe!wmain(int argc, const wchar_t * * argv_) Line 22 C++
dxc.exe!invoke_main() Line 91 C++
dxc.exe!__scrt_common_main_seh() Line 288 C++
dxc.exe!__scrt_common_main() Line 331 C++
dxc.exe!wmainCRTStartup() Line 17 C++
kernel32.dll!00007fffca727974() Unknown
Further technical details
The issue will not reproduce if either the SubpassInput or the sampler2D declaration line is removed. Most likely related to #2695. DXC built from 530958e
Metadata
Metadata
Assignees
Labels
spirvWork related to SPIR-VWork related to SPIR-V