-
Notifications
You must be signed in to change notification settings - Fork 60
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
Support graphics cards without ARB_half_float_vertex
#1179
base: master
Are you sure you want to change the base?
Conversation
ARB_half_float_vertex
ARB_half_float_vertex
08bd535
to
e6ec633
Compare
5cd8db6
to
c1d888b
Compare
For unknown reasons, this is broken:
|
1898c46
to
38c78e7
Compare
It was just some stupid copy-paste mistake. Now it looks like everything is working. |
Also fixes the version printing.
b5c0125
to
1b58b39
Compare
ARB_half_float_vertex
ARB_half_float_vertex
1b58b39
to
2f8e40f
Compare
2f8e40f
to
4a01370
Compare
Now that I verified the branch works, the branch is now targeting It is ready to review. |
…tToHalf4 to avoid confusion
8d8d9f5
to
0d6b114
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.
Same question w. r. t. vector2Copy()
vs floatToHalf()
usage where the original code only has the former and the branches in this pr seem switched up.
8b162ce
to
ada8fbd
Compare
} | ||
else | ||
{ | ||
factor = (int16_t) v1->texCoords[ 3 ]; |
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.
@slipher may have a comment about those lines.
The changes are a bit verbose because I renamed all related half float variables by prefixing them with |
ada8fbd
to
7c8a8bd
Compare
As an experiment, I implemented a proof of concept of automatic vertex translation at VBO upload time in the branch It doesn't translate every VBO because so far it only acts on "static" VBOs (ones fixed at load time). But I imagine it would be enough to get good performance on the cards with poor implementation quality of the half-float extension. If we were to productionize this, the vertex translation process should probably be combined into R_CopyVertexData which already appears to do some similar work. Usage of half floats in the VBOs can be toggle with |
The As a remind, I would like to not only accelerate r300 (that has a slow half-float vertex driver emulation) but also enable some Intel cards (that also support GL 2.1 but don't provide half-float vertex and provide no emulation). A good way to emulate with Mesa a card only having GL 2.1 and not having half float vertexes is to set some environment variable this way: MESA_GL_VERSION_OVERRIDE='2.1' MESA_EXTENSION_OVERRIDE='-GL_ARB_half_float_vertex' ./daemon +devmap vega This should work with any Mesa driver, even llvmpipe on Windows: More details about Mesa environment variables: |
I don't mind that much the implementation, as long as it works. What I like in my branch is that I renamed the half float variables with an explicit prefix, and I find it better for the code to read and debug, this may be something I would redo even if we merge another implementation. We may even decide to convert in the future some current half float code to float, to avoid useless round trips between float and half float. I especially think about the model code: some parts of the model CPU fallback code may process half floats, but I want this code to be as fast as possible since it's already a fallback for the GPU not being powerful enough… |
What is currently broken in |
@slipher do you have some update on your I will have access to the machine with the Intel card without half-float vertex for two weeks starting with the next week. If you're not available to work on this for now, I may merge my implementation and we can revert it in the future to merge your implementation instead. I would prefer to have yours, but we can take time to improve it. |
I made some progress in implementing a more complete version of the idea, which eliminates some of the unnecessary layers in preparing vertex data (it's often copied about 5 times before reaching the VBO). IIRC I finished 2 of the 3 model formats. Got sidetracked by all the bugs I was finding in the renderer. I'll try to dig that out that code in the next few days. |
I know what it is. 🤣️ Thanks for the update! 🙂️ |
f70345c
to
e86ea98
Compare
This branch makes the Intel GMA 3 working: I needed some other minor patches to not compile some shaders for disabled features like bloom, but nothing more related to vertex float was needed. The output of
|
e86ea98
to
7f896cb
Compare
Generate the layout for interleaved vertex attribute data at runtime. The motivation for this is to support OpenGL implementations that don't provide half float support (#1179). The vertex "struct" may contain a 16-bit or 32-bit float, depending on the graphics card. Now, instead of defining a struct for the data to be uploaded into a VBO, one must separately specify inputs for each attribute. The input is defined by a type, base address, stride, etc.; very similarly to the arguments of glVertexAttribPointer itself. The new version of R_CreateStaticVBO takes these inputs and writes them to an interleaved format, performing any neede type conversions along the way. In this commit just skeletal models (IQM and MD5) are migrated to the new method.
You can see my current progress on the branch slipher/runtime-vbo-layout. The dynamically generated vertex attribute layout, which may be configured to use half float or not, is used for IQM, MD3, and MD5 models. It's not ready to test as other VBOs are not ported yet. Remaining steps:
|
Great! I like the way it looks! As a side note, I prefer the cvar being named |
I spelled out my thoughts on the extension cvar naming. To me it looks like a case of cargo culting gone out of control. Maybe some of the first extensions were |
This is to address those two issues:
ARB_half_float_vertex
like the Intel GMA Gen3 architecture with the Mesa driver.ARB_half_float_vertex
but drivers may provide an unplayable slow emulation, like the ATi r300 architecture with the Mesa driver.Those changes purposes to provide an alternative code path when
ARB_half_float_vertex
is not available or when ther_arb_half_float_vertex
cvar is disabled on purpose to avoid a slow emulation provided by the driver.It is the next step over preparatory work that was already merged:
Implement
f16_t
,f16vec2_t
,f16vec4_t
half float types for safety #728renderer/glimp: new GL detection and selection code #478
This branch doesn't break compatibility with the game but I implemented it over the
illwieckz/image-fistcreen/sync
branch anyway:IF_FITSCREEN
andRSF_2D
#1145I did it that way because this other branch also helps running the game on this kind of hardware (to not upload textures too big for such hardware) and we better test this hardware over
for-0.55.0/sync
because of all compatibility-breaking changes purposed for performance that were merged there. Theillwieckz/image-fistcreen/sync
branch itself is already implemented overfor-0.55.0/sync
because of compatibility breaking.This branch also includes the
GL_DEPTH_CLAMP
disablement whenGL_ARB_depth_clamp
to avoid spamming the console with warnings when running the game on ATi r300 graphics card, to make debugging easier:GL_DEPTH_CLAMP
only ifGL_ARB_depth_clamp
is available #1173I push this branch now because it starts to work and this is so precious I don't want the team to lose that work is something happens to me!It's now ready to be reviewed, it works for me with both code paths, and is rebased on
master
.