DiligentGraphics / DiligentEngine

A modern cross-platform low-level graphics library and rendering framework
http://diligentgraphics.com/diligent-engine/
Apache License 2.0
3.59k stars 329 forks source link

InterlockedOr for RWTexture2D<uint4> compile collapse #178

Closed 9MW closed 2 years ago

9MW commented 2 years ago

compute shader code that cause collapse blow const int3 xel=(s_objtrans[InstanceID].pos); InterlockedOr( GroupIdMap[xel.xy].x,orv);

call stack: ucrtbased.dll!00007ffc403912b5() Unknown ucrtbased.dll!00007ffc403910d3() Unknown ucrtbased.dll!00007ffc40393a1f() Unknown

GraphicsEngineVk_64d.dll!spv::Builder::accessChainGetLValue() Line 2917 C++ GraphicsEngineVk_64d.dll!anonymous namespace'::TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TIntermAggregate * node) Line 3251 C++ GraphicsEngineVk_64d.dll!glslang::TIntermAggregate::traverse(glslang::TIntermTraverser * it) Line 159 C++ GraphicsEngineVk_64d.dll!glslang::TIntermAggregate::traverse(glslang::TIntermTraverser * it) Line 177 C++ GraphicsEngineVk_64d.dll!glslang::TIntermAggregate::traverse(glslang::TIntermTraverser * it) Line 177 C++ GraphicsEngineVk_64d.dll!anonymous namespace'::TGlslangToSpvTraverser::visitFunctions(const glslang::TVector<TIntermNode > & glslFunctions) Line 5054 C++ GraphicsEngineVk_64d.dll!`anonymous namespace'::TGlslangToSpvTraverser::visitAggregate(glslang::TVisit visit, glslang::TIntermAggregate node) Line 2668 C++ GraphicsEngineVk_64d.dll!glslang::TIntermAggregate::traverse(glslang::TIntermTraverser it) Line 159 C++ GraphicsEngineVk_64d.dll!glslang::GlslangToSpv(const glslang::TIntermediate & intermediate, std::vector<unsigned int,std::allocator> & spirv, spv::SpvBuildLogger logger, glslang::SpvOptions options) Line 9335 C++ GraphicsEngineVk_64d.dll!glslang::GlslangToSpv(const glslang::TIntermediate & intermediate, std::vector<unsigned int,std::allocator> & spirv, glslang::SpvOptions options) Line 9317 C++ GraphicsEngineVk_64d.dll!Diligent::GLSLangUtils::`anonymous namespace'::CompileShaderInternal(glslang::TShader & Shader, EShMessages messages, glslang::TShader::Includer pIncluder, const char ShaderSource, unsigned int64 SourceCodeLen, bool AssignBindings, Diligent::IDataBlob ppCompilerOutput) Line 275 C++ GraphicsEngineVk_64d.dll!Diligent::GLSLangUtils::HLSLtoSPIRV(const Diligent::ShaderCreateInfo & ShaderCI, const char ExtraDefinitions, Diligent::IDataBlob ppCompilerOutput) Line 387 C++ GraphicsEngineVk_64d.dll!Diligent::ShaderVkImpl::ShaderVkImpl(Diligent::IReferenceCounters pRefCounters, Diligent::RenderDeviceVkImpl pRenderDeviceVk, const Diligent::ShaderCreateInfo & ShaderCI) Line 105 C++ GraphicsEngineVk_64d.dll!Diligent::MakeNewRCObj<Diligent::ShaderVkImpl,Diligent::FixedBlockMemoryAllocator>::operator()<Diligent::RenderDeviceVkImpl ,Diligent::ShaderCreateInfo const &>(Diligent::RenderDeviceVkImpl * && , const Diligent::ShaderCreateInfo & ) Line 668 C++ GraphicsEngineVk_64d.dll!Diligent::RenderDeviceBase::CreateShaderImpl::l2::() Line 548 C++ GraphicsEngineVk_64d.dll!Diligent::RenderDeviceBase::CreateDeviceObject<Diligent::IShader,Diligent::ShaderDesc,void (void)>(const char ObjectTypeName, const Diligent::ShaderDesc & Desc, Diligent::IShader ppObject, Diligent::RenderDeviceBase::CreateShaderImpl::__l2::void (void) ConstructObject) Line 485 C++ GraphicsEngineVk_64d.dll!Diligent::RenderDeviceBase::CreateShaderImpl<>(Diligent::IShader ppShader, const Diligent::ShaderCreateInfo & ShaderCI) Line 551 C++ GraphicsEngineVk_64d.dll!Diligent::RenderDeviceVkImpl::CreateShader(const Diligent::ShaderCreateInfo & ShaderCI, Diligent::IShader * ppShader) Line 584 C++

Diligent version : 2.5

use RWTexture2D <int> GroupIdMap; replace
RWTexture2D <int4> GroupIdMap; works fine

TheMostDiligent commented 2 years ago

GLSLang may not support all HLSL constructs, also not all HLSL constructs may map well to SPIRV. You can try to compile this with DXC and see what happens. It is possible that atomics may not be allowed in this scenario.

9MW commented 2 years ago

emulate RWTexture2D with RWStructuredBuffer solved problem

TheMostDiligent commented 2 years ago

FYI, I have just updated glslang and other third-party modules. You can try to get the latest version and see if the shader compiles, just for the sake of experiment.

9MW commented 2 years ago

FYI, I have just updated glslang and other third-party modules. You can try to get the latest version and see if the shader compiles, just for the sake of experiment.

ye. And can I batch computershader indirect like indirectDraw now?

TheMostDiligent commented 2 years ago

There is DispatchComputeIndirect command, it has been there all the time.

9MW commented 2 years ago

well. I expect dispatch array of computershader. it's seems it unsupported by both vulkan & dx12

TheMostDiligent commented 2 years ago

Like MultiDispatchComputeIndirect? This is not currently supported.