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

Fix shader_dxbc.h compiling on linux with vulkan #3382

Closed
wants to merge 2 commits into from

Conversation

L3nn0x
Copy link

@L3nn0x L3nn0x commented Nov 25, 2024

On linux when trying to build with vulkan on and opengl off, shader_dxbc.h is included after Xlib.h which includes X.h which in turn #define None 0. Undefining so we can properly compile the file.

@L3nn0x L3nn0x requested a review from bkaradzic as a code owner November 25, 2024 21:47
@mcourteaux
Copy link
Contributor

This should probably be wrapped in an #ifdef None ... #endif.

@bkaradzic
Copy link
Owner

bkaradzic commented Dec 7, 2024

I'm not getting this error when building on Linux with D3D11 and D3D12 only.

Env var: BGFX_CONFIG is set to "RENDERER_DIRECT3D11=1 RENDERER_DIRECT3D12=1"

@L3nn0x
Copy link
Author

L3nn0x commented Dec 9, 2024

I haven't tried with D3D11 nor D3D12. What I observed is that the vulkan header includes Xlib.h which causes the define issue. Looking at the D3D code, I don't see any Xlib.h include.
Building bgfx with only vulkan support seems to cause the issue, because if I build with both vulkan and openGL support, I do not get the issue.

@bkaradzic
Copy link
Owner

../../../src/bgfx.cpp (1613): BGFX Supported renderer backends (2):
../../../src/bgfx.cpp (1616): BGFX 	 - Noop
../../../src/bgfx.cpp (1616): BGFX 	 - Vulkan

Just built with VK only and still don't get the issue...

@L3nn0x
Copy link
Author

L3nn0x commented Dec 9, 2024

I'm so sorry, I completely forgot to mention that I'm building the amalgamated version of bgfx.
The order of includes is as follow:

  • renderer_vk.cpp
  • renderer_vk.h (because BGFX_CONFIG_RENDERER_VULKAN is set)
  • vulkan-local/vulkan.h
  • X11/Xlib.h (because VK_USE_PLATFORM_XLIB_KHR is set, I'm using the Kronos version from the 3rdparty in bgfx)
  • X11/X.h -> contains #define None 0
  • shader_dbxbc.cpp
  • shader_dbxbc.h -> contains DxbcOperandModifier::None which gets pre-processed to DxbcOperandModifier::0 because of the define higher up

One other possibility would be to put renderer_vk.cpp after shader_dbxbc.cpp in the amalgamated source.

Hopefully that helps diagnose the issue.

@bkaradzic
Copy link
Owner

Ok lets try like this...

I modify src/config.h near top of the file:

#define BGFX_CONFIG_RENDERER_VULKAN 1

And then I run this:

genie --with-combined-examples --with-amalgamated --gcc=linux-gcc gmake
make --no-print-directory -C .build/projects/gmake-linux-gcc config=debug64 -j 6 examples

I get no issues.

@mcourteaux
Copy link
Contributor

@L3nn0x You should try to figure out what it is on your system that causes this to not work:

bgfx/src/renderer_vk.h

Lines 35 to 38 in a37185e

// vulkan.h pulls X11 crap...
#if defined(None)
# undef None
#endif // defined(None)

This #undef is already there, so something seems off...

@L3nn0x
Copy link
Author

L3nn0x commented Dec 11, 2024

I'll try to figure out what's wrong with my system and if I can repro I'll reopen. Thank you for your time both 😄

@L3nn0x L3nn0x closed this Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants