diff options
author | Erik Faye-Lund <[email protected]> | 2018-08-29 15:35:11 +0200 |
---|---|---|
committer | Erik Faye-Lund <[email protected]> | 2018-09-05 05:46:27 +0100 |
commit | 38f0c078de9628bd5d429021d9c6e210b66da0fa (patch) | |
tree | 6c2e14b0390b50715536361862be94a8e0669fd4 /src/mesa/state_tracker | |
parent | a805e4e9de2540ec7a7115efb76337f39826e017 (diff) |
st/mesa: clean up atomic vs ssbo code
This makes the code a bit easier to follow; we first set up
MaxShaderStorageBlocks, then we either set up a dedicated
MaxAtomicBuffers, or we split MaxShaderStorageBlocks in two.
While we're at it, also make the SSBO-splitting code tolerate the
hypothetical case of having an odd number of SSBOs without incorrectly
dropping the last SSBO.
This has the nice result that the SSBOs and atomic buffers are dealt
with almost completely orthogonally, easing some upcoming patches.
Signed-off-by: Erik Faye-Lund <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Gurchetan Singh <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 8cb80f99324..83fc09f52b8 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -241,6 +241,10 @@ void st_init_limits(struct pipe_screen *screen, pc->MaxUniformComponents + (uint64_t)c->MaxUniformBlockSize / 4 * pc->MaxUniformBlocks; + pc->MaxShaderStorageBlocks = + screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_MAX_SHADER_BUFFERS); + temp = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS); if (temp) { /* @@ -250,11 +254,14 @@ void st_init_limits(struct pipe_screen *screen, ssbo_atomic = false; pc->MaxAtomicCounters = temp; pc->MaxAtomicBuffers = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS); - pc->MaxShaderStorageBlocks = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS); } else { pc->MaxAtomicCounters = MAX_ATOMIC_COUNTERS; - pc->MaxAtomicBuffers = screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_SHADER_BUFFERS) / 2; - pc->MaxShaderStorageBlocks = pc->MaxAtomicBuffers; + /* + * without separate atomic counters, reserve half of the available + * SSBOs for atomic buffers, and the other half for normal SSBOs. + */ + pc->MaxAtomicBuffers = pc->MaxShaderStorageBlocks / 2; + pc->MaxShaderStorageBlocks -= pc->MaxAtomicBuffers; } pc->MaxImageUniforms = screen->get_shader_param( screen, sh, PIPE_SHADER_CAP_MAX_SHADER_IMAGES); @@ -465,9 +472,17 @@ void st_init_limits(struct pipe_screen *screen, screen->get_param(screen, PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT); if (c->ShaderStorageBufferOffsetAlignment) { /* for hw atomic counters leaves these at default for now */ - if (ssbo_atomic) - c->MaxCombinedShaderStorageBlocks = c->MaxShaderStorageBufferBindings = - c->MaxCombinedAtomicBuffers; + if (ssbo_atomic) { + c->MaxCombinedShaderStorageBlocks = + c->Program[MESA_SHADER_VERTEX].MaxShaderStorageBlocks + + c->Program[MESA_SHADER_TESS_CTRL].MaxShaderStorageBlocks + + c->Program[MESA_SHADER_TESS_EVAL].MaxShaderStorageBlocks + + c->Program[MESA_SHADER_GEOMETRY].MaxShaderStorageBlocks + + c->Program[MESA_SHADER_FRAGMENT].MaxShaderStorageBlocks; + assert(c->MaxCombinedShaderStorageBlocks < MAX_COMBINED_SHADER_STORAGE_BUFFERS); + } + c->MaxShaderStorageBufferBindings = c->MaxCombinedShaderStorageBlocks; + c->MaxCombinedShaderOutputResources += c->MaxCombinedShaderStorageBlocks; c->MaxShaderStorageBlockSize = |