enum pipe_shader_type shader_type)
{
struct virgl_winsys *vws = virgl_screen(vctx->base.screen)->vws;
+ const struct virgl_shader_binding_state *binding =
+ &vctx->shader_bindings[shader_type];
+ uint32_t remaining_mask = binding->ssbo_enabled_mask;
struct virgl_resource *res;
- unsigned i;
- for (i = 0; i < PIPE_MAX_SHADER_BUFFERS; i++) {
- res = virgl_resource(vctx->ssbos[shader_type][i]);
- if (res) {
- vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
- }
+
+ while (remaining_mask) {
+ int i = u_bit_scan(&remaining_mask);
+ res = virgl_resource(binding->ssbos[i].buffer);
+ assert(res);
+ vws->emit_res(vws, vctx->cbuf, res->hw_res, FALSE);
}
}
{
struct virgl_context *vctx = virgl_context(ctx);
struct virgl_screen *rs = virgl_screen(ctx->screen);
+ struct virgl_shader_binding_state *binding =
+ &vctx->shader_bindings[shader];
+ binding->ssbo_enabled_mask &= ~u_bit_consecutive(start_slot, count);
for (unsigned i = 0; i < count; i++) {
unsigned idx = start_slot + i;
-
- if (buffers) {
- if (buffers[i].buffer) {
- pipe_resource_reference(&vctx->ssbos[shader][idx], buffers[i].buffer);
- continue;
- }
+ if (buffers && buffers[i].buffer) {
+ pipe_resource_reference(&binding->ssbos[idx].buffer, buffers[i].buffer);
+ binding->ssbos[idx] = buffers[i];
+ binding->ssbo_enabled_mask |= 1 << idx;
+ } else {
+ pipe_resource_reference(&binding->ssbos[idx].buffer, NULL);
}
- pipe_resource_reference(&vctx->ssbos[shader][idx], NULL);
}
uint32_t max_shader_buffer = (shader == PIPE_SHADER_FRAGMENT || shader == PIPE_SHADER_COMPUTE) ?
int i = u_bit_scan(&binding->ubo_enabled_mask);
pipe_resource_reference(&binding->ubos[i].buffer, NULL);
}
+
+ while (binding->ssbo_enabled_mask) {
+ int i = u_bit_scan(&binding->ssbo_enabled_mask);
+ pipe_resource_reference(&binding->ssbos[i].buffer, NULL);
+ }
}
static void
struct pipe_constant_buffer ubos[PIPE_MAX_CONSTANT_BUFFERS];
uint32_t ubo_enabled_mask;
+
+ struct pipe_shader_buffer ssbos[PIPE_MAX_SHADER_BUFFERS];
+ uint32_t ssbo_enabled_mask;
};
struct virgl_context {
struct virgl_so_target so_targets[PIPE_MAX_SO_BUFFERS];
unsigned num_so_targets;
- struct pipe_resource *ssbos[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
struct pipe_resource *images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
uint32_t num_draws, num_compute;