mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 05:01:24 +00:00
[qfcc] Allow aligned despace allocs to be overridden
GLSL (and in the end, spir-v) needs more control over allocation than does the Ruamoko VM.
This commit is contained in:
parent
7742450e03
commit
f0e770b972
2 changed files with 16 additions and 0 deletions
|
@ -60,6 +60,19 @@ typedef struct defspace_s {
|
|||
int size; ///< current high-water mark for alloced data
|
||||
int max_size; ///< size of backing memory, or highwater mark
|
||||
///< for ds_virtual
|
||||
/** Optional callback for aligned allocation of space
|
||||
|
||||
Overrides defspace_alloc_aligned_loc.
|
||||
|
||||
\param space This defspace.
|
||||
\param size Size of space to allocate. Must be > 0.
|
||||
\param alignment Requested alignment for the space. Must be > 0.
|
||||
\return The offset of the allocated space. If allocation fails
|
||||
(because the backing memory cannot be grown), it is
|
||||
treated as an internal error.
|
||||
*/
|
||||
int (*alloc_aligned) (struct defspace_s *space, int size,
|
||||
int alignment);
|
||||
/** Grow the backing memory of the defspace.
|
||||
|
||||
This function is called when more memory is needed for the space.
|
||||
|
|
|
@ -159,6 +159,9 @@ defspace_alloc_loc (defspace_t *space, int size)
|
|||
int
|
||||
defspace_alloc_aligned_loc (defspace_t *space, int size, int alignment)
|
||||
{
|
||||
if (space->alloc_aligned) {
|
||||
return space->alloc_aligned (space, size, alignment);
|
||||
}
|
||||
int ofs, pad;
|
||||
locref_t *loc;
|
||||
locref_t **l = &space->free_locs;
|
||||
|
|
Loading…
Reference in a new issue