mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 00:45:35 +00:00
gpu/shaders: ensure dynamically uniform barriers when malloc fails
GPU APIs require that barrier() calls are dynamically uniform, that is for every barrier in the code, every shader invocation in a workgroup must all call it, or all not call it. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -87,10 +87,6 @@ SubdivResult estimate_subdiv(vec2 p0, vec2 p1, vec2 p2, float sqrt_tol) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
if (mem_error != NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint element_ix = gl_GlobalInvocationID.x;
|
||||
PathSegRef ref = PathSegRef(conf.pathseg_alloc.offset + element_ix * PathSeg_size);
|
||||
|
||||
@@ -98,6 +94,7 @@ void main() {
|
||||
if (element_ix < conf.n_pathseg) {
|
||||
tag = PathSeg_tag(conf.pathseg_alloc, ref);
|
||||
}
|
||||
bool mem_ok = mem_error == NO_ERROR;
|
||||
switch (tag.tag) {
|
||||
case PathSeg_Cubic:
|
||||
PathCubic cubic = PathSeg_Cubic_read(conf.pathseg_alloc, ref);
|
||||
@@ -135,7 +132,7 @@ void main() {
|
||||
bool is_stroke = fill_mode_from_flags(tag.flags) == MODE_STROKE;
|
||||
uint path_ix = cubic.path_ix;
|
||||
Path path = Path_read(conf.tile_alloc, PathRef(conf.tile_alloc.offset + path_ix * Path_size));
|
||||
Alloc path_alloc = new_alloc(path.tiles.offset, (path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y) * Tile_size);
|
||||
Alloc path_alloc = new_alloc(path.tiles.offset, (path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y) * Tile_size, mem_ok);
|
||||
ivec4 bbox = ivec4(path.bbox);
|
||||
vec2 p0 = cubic.p0;
|
||||
qp0 = cubic.p0;
|
||||
@@ -195,7 +192,7 @@ void main() {
|
||||
uint n_tile_alloc = uint((x1 - x0) * (y1 - y0));
|
||||
// Consider using subgroups to aggregate atomic add.
|
||||
MallocResult tile_alloc = malloc(n_tile_alloc * TileSeg_size);
|
||||
if (tile_alloc.failed) {
|
||||
if (tile_alloc.failed || !mem_ok) {
|
||||
return;
|
||||
}
|
||||
uint tile_offset = tile_alloc.alloc.offset;
|
||||
|
||||
Reference in New Issue
Block a user