Skip to content

make graph_vram_allocate() return an aligned pointer#810

Merged
rickgaiser merged 1 commit intops2dev:masterfrom
F0bes:graph-align
Jan 31, 2026
Merged

make graph_vram_allocate() return an aligned pointer#810
rickgaiser merged 1 commit intops2dev:masterfrom
F0bes:graph-align

Conversation

@F0bes
Copy link
Contributor

@F0bes F0bes commented Jan 30, 2026

Currently if you

graph_vram_allocate(..., GRAPH_ALIGN_BLOCK)
graph_vram_allocate(..., GRAPH_ALIGN_PAGE)

The second call doesn't actually guarantee you a page aligned word address, graph was only aligning the size. I think this is a massive footgun. Speaking as someone who just continuously blew off their foot for the past few hours.

This PR makes it so you are guaranteed to get an aligned pointer.

There is a cost, this can introduce fragmentation since we aren't tracking alignment padding. If you need good recycling of VRAM though, you probably wouldn't be using this bump allocator anyways.

@fjtrujy
Copy link
Member

fjtrujy commented Jan 30, 2026

LGTM!
@rickgaiser ?

@rickgaiser
Copy link
Member

Is -alignment & the same as & ~(alignment-1)? It reads a bit strange to me, but other than that, adding the alignment is a bugfix if you ask me. Great find.

@F0bes
Copy link
Contributor Author

F0bes commented Jan 31, 2026

Yeah, it is as long as it is a power of 2. It is a little bit weird, but I just used the same masking method used in the file already.

@rickgaiser rickgaiser merged commit dc136c5 into ps2dev:master Jan 31, 2026
3 checks passed
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