Commit 38f0c078 authored by Erik Faye-Lund 's avatar Erik Faye-Lund

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 's avatarErik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: Gurchetan Singh's avatarGurchetan Singh <gurchetansingh@chromium.org>
parent a805e4e9
......@@ -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 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment