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

Runtime VBO layout: make half float usage optional #1344

Merged
merged 9 commits into from
Oct 10, 2024

Conversation

slipher
Copy link
Member

@slipher slipher commented Oct 9, 2024

Choose vertex attribute layouts at runtime. For attributes designated as wanting half float, use half float if GL_ARB_half_float_vertex is available or full-sized float otherwise, #1179 explains the situation in detail.

TODO: grab the commit adding a workaround for the cards that support the half float vertex extension, but with poor quality of implementation.

The first 4 commits are from #1341.

@illwieckz
Copy link
Member

OK I've finished reading everything. I'll do some tests on r300 hardware to see the performances when I disable the extension.

@illwieckz
Copy link
Member

illwieckz commented Oct 10, 2024

For some unknown reasons I don't reproduce the 55fps I had on default Vega scene on one of the slowest r300 ever some months ago, I only get 37 fps today.

But the good news is that I also get 37 fps with my own branch #1179, so that's not your branch's fault. Either we merged something bad in between, either I got a regression in the system (I updated from Ubuntu 23.10 to Ubuntu 24.04 since the last time and then I got updated systems libs including Mesa).

I confirm this unlocks the fps on the hardware and does the job, as with half float vertexes I get 5 fps on the same vega scene.

I can't test right now on Intel GMA3 as I'm not next to it and probably not before some months, but I assume it's fine as well.

So, LGTM.

@illwieckz
Copy link
Member

The 37fps was likely due to some bad options, I reapplied the lowest preset and I now get 75fps:

unvanquished_2024-10-10_061046_000

@illwieckz
Copy link
Member

In fact the 75fps was caped by the monitor refresh rate. For some reasons with that driver the vsync is always forced, I had to write some Xorg config to unlock it.

I get 90fps:

unvanquished_2024-10-10_132342_000

I even get 31fps with a 720p resolution:

unvanquished_2024-10-10_133359_000

This is the lowest-end range of hardware among the slowest family of ATI cards that are supported, and it's possible to play at 90fps.

For the curious people the Xorg trick to unlock the framerate is this file /etc/X11/xorg.conf.d/00-disable-vsync.conf:

Section "Device"
	Identifier  "Card0"
	Driver "All"
	Option "SwapbuffersWait" "false"
EndSection

@slipher
Copy link
Member Author

slipher commented Oct 10, 2024

So now we're just waiting on #1341.

Some duplicated version of map geometry which was used by static light
code.
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.
MD3 introduces an additional wrinkles: it has per-frame-per-vertex data
in addition to the usual per-vertex data. The VBO really contains two
separate arrays of different structs (both before and after this
commit).
shaderVertex_t is the type used for vertex data which is generated and
uploaded to the GPU on every frame. The motivation behind getting rid of
the half floats is to run on graphics backends that don't support half
float vertex data. I assume there is not much benefit to using half floats
here: normally you would use them to save memory in data which is stored
long-term. But with shaderVertex_t we're only uploading a few thousand
verts each frame and then throwing them away. Though systems that aren't
able to run all skeletal models on the GPU could be an exception as they
have to additionally upload a lot of model verts each frame.

GL_ARB_half_float_vertex is now an optional extension.
@slipher slipher merged commit 65e810c into for-0.55.0/sync Oct 10, 2024
8 of 9 checks passed
@slipher slipher deleted the slipher/runtime-vbo-layout branch October 10, 2024 17:22
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.

2 participants