-
Notifications
You must be signed in to change notification settings - Fork 61
renderer: add non-bitwise alternative for u_Color and u_ColorModulateColorGen #1570
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
Conversation
Context: I noticed that since 0.55.2 we broke GL 2.1 (GLSL 1.20) compatibility. What broke compatibility was the usage of I don't mind if we use bitwise operations and uint in any feature that is not part of So I ported the I have noticed that writing a I don't plan to do this for any other code that is not required by That also means that any feature from some advanced rendering code path (like the bindless one) can rely on |
It's possible to test the code on non-GL 2.1 hardware when running Mesa and setting those environment variables: export MESA_GL_VERSION_OVERRIDE='2.1'
export MESA_GLSL_VERSION_OVERRIDE='120'
export MESA_EXTENSION_OVERRIDE='-GL_EXT_gpu_shader4' Edit: I added the environment variable to explicitly disable the extension responsible for bitwise operations. |
db8bb5a
to
9769812
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disable ARB_shader_draw_parameters on GLSL 1.20,
it's not working.
Is there any specific system where that happens? If a higher GLSL version is not supported, that extension shouldn't even be reported as enabled.
Also, are you sure the bitwise works correctly with any bits with this?
Speaking of those bitwise operations, on master I've been getting compile errors again with the Apple Silicon GPU driver because it doesn't like if you |
Is #1543 (comment) saying 1.20 can use bitwise operators not true? |
The spec for version 120 has bitwise operators, though it does not support |
Probably so. Some drivers fail to do the implicit conversions. I made some change earlier to fix that issue with (IIRC) since dynamic light shader code, by explicitly using uint. |
b2977e7
to
17f48c6
Compare
What? I just tested… and it works, with the original code, just by using But that document says:
Actually it's funny because they say |
The GLSL 1.30 version doesn't say bitwise operators are reserved: |
Oh, I was looking at the pre-processor one. But if it works, then whatever I guess. |
So bitwise operations are not part of GLSL 1.20 but the Mesa driver allows it? Assuming Mesa is usually used for the ancient systems I guess we can just use bitwise operators. |
Something to keep in mind is that I'm currently on the move and testing GL 2.1 using the Mesa environment variables to downgrade the version, but the hardware itself supports 4.6 and all the extensions are listed as available. This can lead to some bugs as seen in one commit where I explicitly disable a GL 4.6 extension when running GL 2.1. So maybe it just works because the driver and the hardware has implemented it and Mesa isn't good enough at disabling what should not be there. I will have physical access back to Intel, Nvidia and ATI GL 2.1 hardware in some hours. |
I remember we had to do a non-bitwise fix in the past: It looks like the extension we look for is
We currently load Though it should also allow
|
17f48c6
to
85a04f9
Compare
So yes with
So replaced At this point I can't exclude it may uncover a dormant bug in the 2D code. |
Then the question would be whether Mesa implements the extension on that hardware. |
Mesa doesn't, I've checked my previous logs, this extension isn't provided. |
So, the function that turns the UI black when I enable the alternative code is |
85a04f9
to
e268533
Compare
I foud the cause of the black UI. The GLSL 1.20 specification says:
I had moved the bits for If I move the bits for It is said the sign representation is not part of those 16-bits, so it means the code can be purged from my sign hack, and it actually bumps the amount of bits to kinda 17-bit with a bit recoverable with an explicit sign test that would not pollute any division like a stray upper bit can do. It also means we should encode colorgen on 16-bits instead of 32-bit on GLSL 1.20, which is fine for a Being limited to 16-bit plus sign means we still have 6 bits available plus the sign (so 7 kinda-bits) to encode future information. |
Maybe it would be easier to just change |
That is |
Yes I'm suggesting to move |
e268533
to
1563921
Compare
I tried this but this is not easy. For example fogGlobal has no material variant. The current branch implements packed data for both Because I haven't checked the performance on real GL 2.1 hardware yet. |
I'm not sure we can do 32-bit bitwise operations on 32-bit
So to be safe I reconstruct the |
Just to make it clear: I now consider this ready. There may be ideas of further improvements to be done over this but that would then belongs to future PRs. |
This PR fixes the GLSL compile errors with the Apple Silicon driver. Yay! Note that this driver does not support extensions needed for material system. For the record, the errors on master look like this:
|
Well, you could have something like a |
Yes, this is fixed by writing I also got those errors on Mesa at some point. I wasn't getting them by default, but by toying with multiple configurations I got them. I'm not surprised macOS is less permissive, as it is more complete (one funny thing is that macOS was even still giving us a GL 2.1 context until 2021). |
050c6d0
to
b2479a2
Compare
I squashed and rebased. |
b2479a2
to
c2beb49
Compare
c2beb49
to
4459552
Compare
I added a commit to disable |
4459552
to
c2beb49
Compare
I removed it because there is no need to delay that PR more. It's ready. I just need an approval. |
c2beb49
to
d92bbe4
Compare
I suppose the |
d92bbe4
to
05f2dc4
Compare
In that branch the material system assumes the |
05f2dc4
to
3cc42d3
Compare
This was tested successfully on Nvidia, Intel, ATI and Broadcom GL 2.1 hardware. |
I see. I didn't bother adding some of the extension checks because it's pretty much impossible for the other extensions to be present but not the older ones. Certainly not a mistake to add them though, so it's fine to keep the change. |
Yes, I prefer to be exhaustive. And now I know that requesting an old GL version for debugging purpose may still bring some extensions, so it's better to double check anyway. So it looks like there is no more questions to answer. Yay! |
|
Apparently, that's a regression from #1577. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It passes my diff tests.
3cc42d3
to
ec4bdaf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add non-bitwise alternative for
u_Color
andu_ColorModulateColorGen
, it is when GLSL 1.20 isn't supported.The material system assumes GLSL 1.20 is supported.
Written on top of: