asahi: Add hooks for SSBO and images

Copy paste from Panfrost. This should be close to what we need for Asahi, and
this lets us run dEQP-GLES31 without crashing immediately.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21062>
This commit is contained in:
Alyssa Rosenzweig 2022-10-22 11:15:44 -04:00 committed by Marge Bot
parent c1a6465644
commit f4b553d55a
3 changed files with 81 additions and 1 deletions

View file

@ -1443,6 +1443,12 @@ agx_get_shader_param(struct pipe_screen *pscreen, enum pipe_shader_type shader,
!(shader == PIPE_SHADER_COMPUTE && is_deqp))
return 0;
/* Don't allow side effects with vertex processing. The APIs don't require it
* and it may be problematic on our hardware.
*/
bool allow_side_effects = (shader != PIPE_SHADER_VERTEX);
/* this is probably not totally correct.. but it's a start: */
switch (param) {
case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
@ -1507,10 +1513,14 @@ agx_get_shader_param(struct pipe_screen *pscreen, enum pipe_shader_type shader,
return PIPE_SHADER_IR_NIR;
case PIPE_SHADER_CAP_SUPPORTED_IRS:
return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_NIR_SERIALIZED);
return (1 << PIPE_SHADER_IR_NIR);
case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
return (is_deqp && allow_side_effects) ? 16 : 0;
case PIPE_SHADER_CAP_MAX_SHADER_IMAGES:
return (is_deqp && allow_side_effects) ? PIPE_MAX_SHADER_IMAGES : 0;
case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS:
case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS:
return 0;

View file

@ -106,6 +106,68 @@ agx_set_stream_output_targets(struct pipe_context *pctx, unsigned num_targets,
so->num_targets = num_targets;
}
static void
agx_set_shader_images(
struct pipe_context *pctx,
enum pipe_shader_type shader,
unsigned start_slot, unsigned count, unsigned unbind_num_trailing_slots,
const struct pipe_image_view *iviews)
{
struct agx_context *ctx = agx_context(pctx);
ctx->stage[shader].dirty = ~0;
/* Unbind start_slot...start_slot+count */
if (!iviews) {
for (int i = start_slot; i < start_slot + count + unbind_num_trailing_slots; i++) {
pipe_resource_reference(&ctx->stage[shader].images[i].resource, NULL);
}
ctx->stage[shader].image_mask &= ~(((1ull << count) - 1) << start_slot);
return;
}
/* Bind start_slot...start_slot+count */
for (int i = 0; i < count; i++) {
const struct pipe_image_view *image = &iviews[i];
if (image->resource)
ctx->stage[shader].image_mask |= BITFIELD_BIT(start_slot + i);
else
ctx->stage[shader].image_mask &= ~BITFIELD_BIT(start_slot + i);
if (!image->resource) {
util_copy_image_view(&ctx->stage[shader].images[start_slot+i], NULL);
continue;
}
/* FIXME: Decompress here once we have texture compression */
util_copy_image_view(&ctx->stage[shader].images[start_slot+i], image);
}
/* Unbind start_slot+count...start_slot+count+unbind_num_trailing_slots */
for (int i = 0; i < unbind_num_trailing_slots; i++) {
ctx->stage[shader].image_mask &= ~BITFIELD_BIT(start_slot + count + i);
util_copy_image_view(&ctx->stage[shader].images[start_slot+count+i], NULL);
}
}
static void
agx_set_shader_buffers(
struct pipe_context *pctx,
enum pipe_shader_type shader,
unsigned start, unsigned count,
const struct pipe_shader_buffer *buffers,
unsigned writable_bitmask)
{
struct agx_context *ctx = agx_context(pctx);
util_set_shader_buffers_mask(ctx->stage[shader].ssbo,
&ctx->stage[shader].ssbo_mask,
buffers, start, count);
ctx->stage[shader].dirty = ~0;
}
static void
agx_set_blend_color(struct pipe_context *pctx,
const struct pipe_blend_color *state)
@ -2517,6 +2579,8 @@ agx_init_state_functions(struct pipe_context *ctx)
ctx->set_blend_color = agx_set_blend_color;
ctx->set_clip_state = agx_set_clip_state;
ctx->set_constant_buffer = agx_set_constant_buffer;
ctx->set_shader_buffers = agx_set_shader_buffers;
ctx->set_shader_images = agx_set_shader_images;
ctx->set_sampler_views = agx_set_sampler_views;
ctx->set_framebuffer_state = agx_set_framebuffer_state;
ctx->set_polygon_stipple = agx_set_polygon_stipple;

View file

@ -132,6 +132,12 @@ struct agx_stage {
struct pipe_constant_buffer cb[PIPE_MAX_CONSTANT_BUFFERS];
uint32_t cb_mask;
struct pipe_shader_buffer ssbo[PIPE_MAX_SHADER_BUFFERS];
uint32_t ssbo_mask;
struct pipe_image_view images[PIPE_MAX_SHADER_IMAGES];
uint32_t image_mask;
/* Need full CSOs for u_blitter */
struct agx_sampler_state *samplers[PIPE_MAX_SAMPLERS];
struct agx_sampler_view *textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];