vello/piet-gpu/shader
Elias Naur d9d518b248 avoid non-uniform barrier control flow when exhausting memory
The compute shaders have a check for the succesful completion of their
preceding stage. However, consider a shader execution path like the
following:

	void main()
		if (mem_error != NO_ERROR) {
		    return;
		}
		...
		malloc(...);
		...
		barrier();
		...
	}

and  shader execution that fails to allocate memory, thereby setting
mem_error to ERR_MALLOC_FAILED in malloc before reaching the barrier. If
another shader execution then begins execution, its mem_eror check will
make it return early and not reach the barrier.

All GPU APIs require (dynamically) uniform control flow for barriers,
and the above case may lead to GPU hangs in practice.

Fix this issue by replacing the early exits with careful checks that
don't interrupt barrier control flow.

Unfortunately, it's harder to prove the soundness of the new checks, so
this change also clears dynamic memory ranges in MEM_DEBUG mode when
memory is exhausted. The result is that accessing memory after
exhaustion triggers an error.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-04-20 10:15:29 +02:00
..
annotated.h support stroked fills for clips, images 2021-03-19 16:43:33 +01:00
backdrop.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
backdrop.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
binning.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
binning.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
bins.h all: add optional memory checks 2021-02-15 16:07:45 +01:00
build.ninja Query extensions at runtime 2021-04-08 15:11:15 -07:00
coarse.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
coarse.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
elements.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
elements.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
kernel4.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
kernel4.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
kernel4_idx.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
mem.h avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
path_coarse.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
path_coarse.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
pathseg.h collapse FillCubic and StrokeCubic into Cubic with flags for fill mode 2021-03-19 12:50:12 +01:00
ptcl.h coarse,kernel4: make stroke, (non-zero) fill, solid separate commands 2021-03-19 16:43:33 +01:00
scene.h replace per-element fill mode flags with a SetFillMode element 2021-03-29 21:10:25 +02:00
setup.h Query extensions at runtime 2021-04-08 15:11:15 -07:00
state.h ensure consistent path segment transformation 2021-03-19 12:45:23 +01:00
tile.h ensure consistent path segment transformation 2021-03-19 12:45:23 +01:00
tile_alloc.comp avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00
tile_alloc.spv avoid non-uniform barrier control flow when exhausting memory 2021-04-20 10:15:29 +02:00