mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 13:00:09 +01:00
zink/ntv: fix coherent image load/store
The SPIR-V didn't seem to use coherent load/store. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37417>
This commit is contained in:
parent
f99230cc67
commit
d1e230454d
3 changed files with 20 additions and 15 deletions
|
|
@ -308,6 +308,8 @@ emit_access_decorations(struct ntv_context *ctx, nir_variable *var, SpvId var_id
|
|||
switch (1 << bit) {
|
||||
case ACCESS_COHERENT:
|
||||
/* SpvDecorationCoherent can't be used with vulkan memory model */
|
||||
if (!ctx->sinfo->have_vulkan_memory_model)
|
||||
spirv_builder_emit_decoration(&ctx->builder, var_id, SpvDecorationCoherent);
|
||||
break;
|
||||
case ACCESS_RESTRICT:
|
||||
spirv_builder_emit_decoration(&ctx->builder, var_id, SpvDecorationRestrict);
|
||||
|
|
@ -2968,7 +2970,8 @@ emit_image_deref_store(struct ntv_context *ctx, nir_intrinsic_instr *intr)
|
|||
glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_SUBPASS_MS;
|
||||
SpvId sample = use_sample ? get_src(ctx, &intr->src[2], &atype) : 0;
|
||||
assert(nir_src_bit_size(intr->src[3]) == glsl_base_type_bit_size(glsl_get_sampler_result_type(type)));
|
||||
spirv_builder_emit_image_write(&ctx->builder, img, coord, texel, 0, sample, 0);
|
||||
bool coherent = ctx->sinfo->have_vulkan_memory_model && (nir_intrinsic_access(intr) & ACCESS_COHERENT);
|
||||
spirv_builder_emit_image_write(&ctx->builder, img, coord, texel, 0, sample, coherent);
|
||||
}
|
||||
|
||||
static SpvId
|
||||
|
|
@ -3023,9 +3026,11 @@ emit_image_deref_load(struct ntv_context *ctx, nir_intrinsic_instr *intr)
|
|||
SpvId sample = use_sample ? get_src(ctx, &intr->src[2], &atype) : 0;
|
||||
SpvId dest_type = spirv_builder_type_vector(&ctx->builder, base_type,
|
||||
intr->def.num_components);
|
||||
|
||||
bool coherent = ctx->sinfo->have_vulkan_memory_model && (nir_intrinsic_access(intr) & ACCESS_COHERENT);
|
||||
SpvId result = spirv_builder_emit_image_read(&ctx->builder,
|
||||
dest_type,
|
||||
img, coord, 0, sample, 0, sparse);
|
||||
img, coord, 0, sample, sparse, coherent);
|
||||
if (sparse)
|
||||
result = extract_sparse_load(ctx, result, dest_type, &intr->def);
|
||||
|
||||
|
|
|
|||
|
|
@ -1023,8 +1023,8 @@ spirv_builder_emit_image_read(struct spirv_builder *b,
|
|||
SpvId coordinate,
|
||||
SpvId lod,
|
||||
SpvId sample,
|
||||
SpvId offset,
|
||||
bool sparse)
|
||||
bool sparse,
|
||||
bool coherent)
|
||||
{
|
||||
SpvId result = spirv_builder_new_id(b);
|
||||
|
||||
|
|
@ -1041,9 +1041,9 @@ spirv_builder_emit_image_read(struct spirv_builder *b,
|
|||
extra_operands[num_extra_operands++] = sample;
|
||||
operand_mask |= SpvImageOperandsSampleMask;
|
||||
}
|
||||
if (offset) {
|
||||
extra_operands[num_extra_operands++] = offset;
|
||||
operand_mask |= SpvImageOperandsOffsetMask;
|
||||
if (coherent) {
|
||||
extra_operands[num_extra_operands++] = spirv_builder_const_uint(b, 32, SpvScopeDevice);
|
||||
operand_mask |= SpvImageOperandsMakeTexelVisibleMask | SpvImageOperandsNonPrivateTexelMask;
|
||||
}
|
||||
/* finalize num_extra_operands / extra_operands */
|
||||
extra_operands[0] = operand_mask;
|
||||
|
|
@ -1067,10 +1067,10 @@ spirv_builder_emit_image_write(struct spirv_builder *b,
|
|||
SpvId texel,
|
||||
SpvId lod,
|
||||
SpvId sample,
|
||||
SpvId offset)
|
||||
bool coherent)
|
||||
{
|
||||
SpvImageOperandsMask operand_mask = SpvImageOperandsMaskNone;
|
||||
SpvId extra_operands[5];
|
||||
SpvId extra_operands[7];
|
||||
int num_extra_operands = 1;
|
||||
if (lod) {
|
||||
extra_operands[num_extra_operands++] = lod;
|
||||
|
|
@ -1080,9 +1080,9 @@ spirv_builder_emit_image_write(struct spirv_builder *b,
|
|||
extra_operands[num_extra_operands++] = sample;
|
||||
operand_mask |= SpvImageOperandsSampleMask;
|
||||
}
|
||||
if (offset) {
|
||||
extra_operands[num_extra_operands++] = offset;
|
||||
operand_mask |= SpvImageOperandsOffsetMask;
|
||||
if (coherent) {
|
||||
extra_operands[num_extra_operands++] = spirv_builder_const_uint(b, 32, SpvScopeDevice);
|
||||
operand_mask |= SpvImageOperandsMakeTexelAvailableMask | SpvImageOperandsNonPrivateTexelMask;
|
||||
}
|
||||
/* finalize num_extra_operands / extra_operands */
|
||||
extra_operands[0] = operand_mask;
|
||||
|
|
|
|||
|
|
@ -347,8 +347,8 @@ spirv_builder_emit_image_read(struct spirv_builder *b,
|
|||
SpvId coordinate,
|
||||
SpvId lod,
|
||||
SpvId sample,
|
||||
SpvId offset,
|
||||
bool sparse);
|
||||
bool sparse,
|
||||
bool coherent);
|
||||
|
||||
void
|
||||
spirv_builder_emit_image_write(struct spirv_builder *b,
|
||||
|
|
@ -357,7 +357,7 @@ spirv_builder_emit_image_write(struct spirv_builder *b,
|
|||
SpvId texel,
|
||||
SpvId lod,
|
||||
SpvId sample,
|
||||
SpvId offset);
|
||||
bool coherent);
|
||||
|
||||
SpvId
|
||||
spirv_builder_emit_image_fetch(struct spirv_builder *b,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue