Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bindless layout declaration from compute header #1266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

VReaperV
Copy link
Contributor

Attempt to fix crash on Mesa.

@illwieckz
Copy link
Member

illwieckz commented Aug 27, 2024

It fixes the crash but the render is buggy:

unvanquished_2024-08-28_005436_000

@VReaperV
Copy link
Contributor Author

That's quite weird... I take it it does not happen if r_gpuOcclusionCulling is off?

@illwieckz
Copy link
Member

That's quite weird... I take it it does not happen if r_gpuOcclusionCulling is off?

Right.

@VReaperV
Copy link
Contributor Author

I've added another commit that may or may not fix this issue.

@illwieckz
Copy link
Member

The crash is back:

Thread 1 "daemon" received signal SIGSEGV, Segmentation fault.
tc_create_image_handle (_pipe=0x59c01c7645a0, image=0x7fff49225d00) at ../src/gallium/auxiliary/util/u_threaded_context.c:2403
2403	   if (image->resource->target == PIPE_BUFFER)

Thread 1 (Thread 0x7e5c0fe77a80 (LWP 2001969) "daemon"):
#0  tc_create_image_handle (_pipe=0x59c01c7645a0, image=0x7fff49225d00) at ../src/gallium/auxiliary/util/u_threaded_context.c:2403
#1  0x00007e5bec6e2c95 in st_create_image_handle_from_unit (prog=<optimized out>, imgUnit=<optimized out>, st=0x59c01c072810) at ../src/mesa/state_tracker/st_texture.c:573
#2  st_make_bound_images_resident (st=st@entry=0x59c01c072810, prog=prog@entry=0x7e5b42525a30) at ../src/mesa/state_tracker/st_texture.c:650
#3  0x00007e5bec68fac6 in st_upload_constants (st=0x59c01c072810, prog=0x7e5b42525a30, stage=MESA_SHADER_COMPUTE) at ../src/mesa/state_tracker/st_atom_constbuf.c:108
#4  0x00007e5bec4cc02d in st_validate_state (pipeline_state_mask=18374686479705178112, st=0x59c01c072810) at ../src/util/bitscan.h:117
#5  prepare_compute (ctx=ctx@entry=0x59c01c8c4fb0) at ../src/mesa/main/compute.c:298
#6  0x00007e5bec4cc39a in dispatch_compute (no_error=<optimized out>, num_groups_z=<optimized out>, num_groups_y=<optimized out>, num_groups_x=<optimized out>) at ../src/mesa/main/compute.c:330
#7  _mesa_DispatchCompute (num_groups_x=320, num_groups_y=180, num_groups_z=1) at ../src/mesa/main/compute.c:349
#8  0x00007e5bec476497 in _mesa_unmarshal_DispatchCompute (ctx=<optimized out>, cmd=<optimized out>) at src/mapi/glapi/gen/marshal_generated4.c:1260
#9  0x00007e5bec5bcdda in glthread_unmarshal_batch (job=job@entry=0x59c01c8cb170, gdata=gdata@entry=0x0, thread_index=thread_index@entry=0) at ../src/mesa/main/glthread.c:141
#10 0x00007e5bec5bd7aa in _mesa_glthread_finish (ctx=ctx@entry=0x59c01c8c4fb0) at ../src/mesa/main/glthread.c:422
#11 0x00007e5bec5bda49 in _mesa_glthread_finish_before (ctx=ctx@entry=0x59c01c8c4fb0, func=func@entry=0x7e5bec1f040e "GetError") at ../src/mesa/main/glthread.c:438
#12 0x00007e5bec4464bf in _mesa_marshal_GetError () at src/mapi/glapi/gen/marshal_generated1.c:1534
#13 0x000059c01900825a in GL_CheckErrors_ (fileName=0x59c018db2e18 "Unvanquished/daemon/src/engine/renderer/Material.cpp", line=1896) at Unvanquished/daemon/src/engine/renderer/tr_init.cpp:376
#14 0x000059c018fc754a in MaterialSystem::CullSurfaces (this=0x59c019b61900 <materialSystem>) at Unvanquished/daemon/src/engine/renderer/Material.cpp:1896
#15 0x000059c018f8a141 in RB_RenderPostProcess () at Unvanquished/daemon/src/engine/renderer/tr_backend.cpp:4958
#16 0x000059c018f8cdb6 in RenderPostProcessCommand::ExecuteSelf (this=0x7e5bf279223c) at Unvanquished/daemon/src/engine/renderer/tr_backend.cpp:5807
#17 0x000059c018f8d529 in RB_ExecuteRenderCommands (data=0x7e5bf279104c) at Unvanquished/daemon/src/engine/renderer/tr_backend.cpp:6034
#18 0x000059c018fb0726 in R_IssueRenderCommands (runPerformanceCounters=false) at Unvanquished/daemon/src/engine/renderer/tr_cmds.cpp:183
#19 0x000059c018fb0903 in R_SyncRenderThread () at Unvanquished/daemon/src/engine/renderer/tr_cmds.cpp:211
#20 0x000059c018fe8158 in RE_GenerateTexture (pic=0x59c0256f0980 "\377\377\377", width=256, height=256) at Unvanquished/daemon/src/engine/renderer/tr_image.cpp:3122
#21 0x000059c018e6acfe in operator() (__closure=0x7fff49226788, data=std::vector of length 262144, capacity 262144 = {...}, x=256, y=256, handle=@0x7fff49226624: 0) at Unvanquished/daemon/src/engine/client/cl_cgame.cpp:1297
#22 0x000059c018e7d435 in Util::apply_impl<CGameVM::QVMSyscall(int, Util::Reader&, IPC::Channel&)::<lambda(std::vector<unsigned char>, int, int, qhandle_t&)>, std::tuple<std::vector<unsigned char, std::allocator<unsigned char> >&&, int&&, int&&, int&>, 0, 1, 2, 3>(struct {...} &&, std::tuple<std::vector<unsigned char, std::allocator<unsigned char> >&&, int&&, int&&, int&> &&, Util::seq<0, 1, 2, 3>) (func=..., tuple=...) at Unvanquished/daemon/src/common/Util.h:136
#23 0x000059c018e7ae78 in Util::apply<CGameVM::QVMSyscall(int, Util::Reader&, IPC::Channel&)::<lambda(std::vector<unsigned char>, int, int, qhandle_t&)>, std::tuple<std::vector<unsigned char, std::allocator<unsigned char> >&&, int&&, int&&, int&> >(struct {...} &&, std::tuple<std::vector<unsigned char, std::allocator<unsigned char> >&&, int&&, int&&, int&> &&) (func=..., tuple=...) at Unvanquished/daemon/src/common/Util.h:141
#24 0x000059c018e76e3c in IPC::detail::HandleMsg<CGameVM::QVMSyscall(int, Util::Reader&, IPC::Channel&)::<lambda(std::vector<unsigned char>, int, int, qhandle_t&)>, IPC::Message<IPC::Id<0, 68>, std::vector<unsigned char, std::allocator<unsigned char> >, int, int>, IPC::Reply<int> >(IPC::Channel &, IPC::SyncMessage<IPC::Message<IPC::Id<0, 68>, std::vector<unsigned char, std::allocator<unsigned char> >, int, int>, IPC::Reply<int> >, Util::Reader, struct {...} &&) (channel=..., reader=..., func=...) at Unvanquished/daemon/src/common/IPC/Channel.h:217
#25 0x000059c018e706c9 in IPC::HandleMsg<IPC::SyncMessage<IPC::Message<IPC::Id<0, 68>, std::vector<unsigned char, std::allocator<unsigned char> >, int, int>, IPC::Reply<int> >, CGameVM::QVMSyscall(int, Util::Reader&, IPC::Channel&)::<lambda(std::vector<unsigned char>, int, int, qhandle_t&)> >(IPC::Channel &, Util::Reader, struct {...} &&) (channel=..., reader=..., func=...) at Unvanquished/daemon/src/common/IPC/Channel.h:241
#26 0x000059c018e6c014 in CGameVM::QVMSyscall (this=0x59c01991b600 <cgvm>, syscallNum=68, reader=..., channel=...) at Unvanquished/daemon/src/engine/client/cl_cgame.cpp:1296
#27 0x000059c018e6a17e in CGameVM::Syscall (this=0x59c01991b600 <cgvm>, id=68, reader=..., channel=...) at Unvanquished/daemon/src/engine/client/cl_cgame.cpp:1056
#28 0x000059c018e8207b in VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}::operator()(unsigned int, Util::Reader) (__closure=0x7fff49226aa0, id=68, reader=...) at Unvanquished/daemon/src/engine/framework/VirtualMachine.h:142
#29 0x000059c018e89132 in IPC::detail::SendMsg<VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}&, IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<>, cgClientState_t&>(IPC::Channel&, VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}&, IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&) (channel=..., messageHandler=...) at Unvanquished/daemon/src/common/IPC/Channel.h:174
#30 0x000059c018e83df6 in IPC::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}, cgClientState_t&>(IPC::Channel&, VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&)::{lambda(unsigned int, Util::Reader)#1}&&, cgClientState_t&) (channel=..., messageHandler=...) at Unvanquished/daemon/src/common/IPC/Channel.h:234
#31 0x000059c018e82169 in VM::VMBase::SendMsg<IPC::SyncMessage<IPC::Message<IPC::Id<(unsigned short)0, (unsigned short)9>, cgClientState_t>, IPC::Reply<> >, cgClientState_t&>(cgClientState_t&) (this=0x59c01991b600 <cgvm>) at Unvanquished/daemon/src/engine/framework/VirtualMachine.h:140
#32 0x000059c018e6a0d0 in CGameVM::CGameRocketFrame (this=0x59c01991b600 <cgvm>) at Unvanquished/daemon/src/engine/client/cl_cgame.cpp:1043
#33 0x000059c018ed539f in SCR_DrawScreenField () at Unvanquished/daemon/src/engine/client/cl_scrn.cpp:278
#34 0x000059c018ed542d in SCR_UpdateScreen () at Unvanquished/daemon/src/engine/client/cl_scrn.cpp:318
#35 0x000059c018ec555c in CL_Frame (msec=200) at Unvanquished/daemon/src/engine/client/cl_main.cpp:2086
#36 0x000059c018dea73a in Com_Frame () at Unvanquished/daemon/src/engine/qcommon/common.cpp:942
#37 0x000059c01909fc9f in Application::ClientApplication::Frame (this=0x59c019bd37a0 <Application::GetApp()::app>) at Unvanquished/daemon/src/engine/client/ClientApplication.cpp:96
#38 0x000059c01910885f in Application::Frame () at Unvanquished/daemon/src/engine/framework/Application.cpp:87
#39 0x000059c019149e98 in main (argc=72, argv=0x7fff492279f8) at Unvanquished/daemon/src/engine/framework/System.cpp:784

But maybe the renderer bug is a Mesa bug?

@VReaperV
Copy link
Contributor Author

But maybe the renderer bug is a Mesa bug?

It could be. Given the extension specfication it should work, but I'd need to read it again to make sure.

It looks like it's unable to create an image from a texture that has a bindless handle? I'll try another solution that might make it work.

@VReaperV
Copy link
Contributor Author

The crash is back:

I've added another commit to hopefully fix the issue.

@VReaperV
Copy link
Contributor Author

VReaperV commented Sep 1, 2024

Fixed the issue reported by CI.

@VReaperV
Copy link
Contributor Author

VReaperV commented Sep 4, 2024

Based on extension spec the initial issue appears to be a driver bug:

Interactions with GLSL 4.20

Without GLSL 4.20 support, sampler and image uniforms may only be
initialized through the OpenGL API. With GLSL 4.20, sampler and image
uniforms may be initialized in the shader using

   layout(binding = integer-constant)

as described in section 4.4.4 "Opaque-Uniform Layout Qualifiers". When
ARB_bindless_texture is supported, these initial binding values are always
taken to mean a texture image or image unit number, not a bindless handle.

@illwieckz
Copy link
Member

The initial issue was not reproduced with Mesa llvmpipe (CPU) and Mesa nouveau (Nvidia) but with Mesa radeonsi (AMD), that's also why I suspect a driver bug.

@VReaperV
Copy link
Contributor Author

The bug has been fixed on Mesa's side, but @illwieckz has reported that r_gpuOcclusionCulling on is very slow for him, so maybe there's still something to fix on our side.

@illwieckz
Copy link
Member

Also, I remember this was also causing crashes but I don't know if that was the same as the crash I got without this. If not the same crash, I would like to report it too.

@VReaperV
Copy link
Contributor Author

Do you have any relevant log?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants