zink: hook up ssbo shader bindings
this is just the struct zink_shader binding point stuff, but nothing is using it yet Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8330>
This commit is contained in:
parent
f5ab1a1f00
commit
6e22f52ba1
|
@ -547,7 +547,8 @@ zink_binding(gl_shader_stage stage, VkDescriptorType type, int index)
|
|||
unreachable("not supported");
|
||||
} else {
|
||||
uint32_t stage_offset = (uint32_t)stage * (PIPE_MAX_CONSTANT_BUFFERS +
|
||||
PIPE_MAX_SAMPLERS);
|
||||
PIPE_MAX_SAMPLERS +
|
||||
PIPE_MAX_SHADER_BUFFERS);
|
||||
|
||||
switch (type) {
|
||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
|
@ -559,6 +560,10 @@ zink_binding(gl_shader_stage stage, VkDescriptorType type, int index)
|
|||
assert(index < PIPE_MAX_SAMPLERS);
|
||||
return stage_offset + PIPE_MAX_CONSTANT_BUFFERS + index;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
assert(index < PIPE_MAX_SHADER_BUFFERS);
|
||||
return stage_offset + PIPE_MAX_CONSTANT_BUFFERS + PIPE_MAX_SHADER_SAMPLER_VIEWS + index;
|
||||
|
||||
default:
|
||||
unreachable("unexpected type");
|
||||
}
|
||||
|
|
|
@ -488,6 +488,15 @@ zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
|||
ret->bindings[ret->num_bindings].size = 1;
|
||||
ret->num_bindings++;
|
||||
}
|
||||
} else if (var->data.mode == nir_var_mem_ssbo) {
|
||||
int binding = zink_binding(nir->info.stage,
|
||||
VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||
var->data.binding);
|
||||
ret->bindings[ret->num_bindings].index = var->data.binding;
|
||||
ret->bindings[ret->num_bindings].binding = binding;
|
||||
ret->bindings[ret->num_bindings].type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||
ret->bindings[ret->num_bindings].size = 1;
|
||||
ret->num_bindings++;
|
||||
} else {
|
||||
assert(var->data.mode == nir_var_uniform);
|
||||
const struct glsl_type *type = glsl_without_array(var->type);
|
||||
|
|
|
@ -309,9 +309,9 @@ zink_draw_vbo(struct pipe_context *pctx,
|
|||
}
|
||||
}
|
||||
|
||||
VkWriteDescriptorSet wds[PIPE_SHADER_TYPES * PIPE_MAX_CONSTANT_BUFFERS + PIPE_SHADER_TYPES * PIPE_MAX_SAMPLERS];
|
||||
struct zink_resource *write_desc_resources[PIPE_SHADER_TYPES * PIPE_MAX_CONSTANT_BUFFERS + PIPE_SHADER_TYPES * PIPE_MAX_SAMPLERS];
|
||||
VkDescriptorBufferInfo buffer_infos[PIPE_SHADER_TYPES * PIPE_MAX_CONSTANT_BUFFERS];
|
||||
VkWriteDescriptorSet wds[PIPE_SHADER_TYPES * (PIPE_MAX_CONSTANT_BUFFERS + PIPE_MAX_SAMPLERS + PIPE_MAX_SHADER_BUFFERS)];
|
||||
struct zink_resource *write_desc_resources[PIPE_SHADER_TYPES * (PIPE_MAX_CONSTANT_BUFFERS + PIPE_MAX_SAMPLERS + PIPE_MAX_SHADER_BUFFERS)];
|
||||
VkDescriptorBufferInfo buffer_infos[PIPE_SHADER_TYPES * (PIPE_MAX_CONSTANT_BUFFERS + PIPE_MAX_SHADER_BUFFERS)];
|
||||
VkDescriptorImageInfo image_infos[PIPE_SHADER_TYPES * PIPE_MAX_SAMPLERS];
|
||||
VkBufferView buffer_view[] = {VK_NULL_HANDLE};
|
||||
int num_wds = 0, num_buffer_info = 0, num_image_info = 0;
|
||||
|
@ -350,6 +350,17 @@ zink_draw_vbo(struct pipe_context *pctx,
|
|||
buffer_infos[num_buffer_info].range = res ? ctx->ubos[i][index].buffer_size : VK_WHOLE_SIZE;
|
||||
wds[num_wds].pBufferInfo = buffer_infos + num_buffer_info;
|
||||
++num_buffer_info;
|
||||
} else if (shader->bindings[j].type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) {
|
||||
assert(ctx->ssbos[i][index].buffer_size > 0);
|
||||
assert(ctx->ssbos[i][index].buffer_size <= screen->info.props.limits.maxStorageBufferRange);
|
||||
assert(ctx->ssbos[i][index].buffer);
|
||||
struct zink_resource *res = zink_resource(ctx->ssbos[i][index].buffer);
|
||||
write_desc_resources[num_wds] = res;
|
||||
buffer_infos[num_buffer_info].buffer = res->buffer;
|
||||
buffer_infos[num_buffer_info].offset = ctx->ssbos[i][index].buffer_offset;
|
||||
buffer_infos[num_buffer_info].range = ctx->ssbos[i][index].buffer_size;
|
||||
wds[num_wds].pBufferInfo = buffer_infos + num_buffer_info;
|
||||
++num_buffer_info;
|
||||
} else {
|
||||
for (unsigned k = 0; k < shader->bindings[j].size; k++) {
|
||||
struct pipe_sampler_view *psampler_view = ctx->image_views[i][index + k];
|
||||
|
|
Loading…
Reference in New Issue