mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
ac/nir: Use correct LLVM intrinsics for atomic ops on imageBuffers
The buffer intrinsics should be used instead of the image ones.
Signed-off-by: Alex Smith <asmith@feralinteractive.com>
Cc: <mesa-stable@lists.freedesktop.org>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
(cherry picked from commit 909184ac9c)
[Andres Gomez: resolve trivial conflicts]
Signed-off-by: Andres Gomez <agomez@igalia.com>
This commit is contained in:
parent
5b8b891a45
commit
cc2a62991a
1 changed files with 34 additions and 29 deletions
|
|
@ -3302,37 +3302,14 @@ static LLVMValueRef visit_image_atomic(struct nir_to_llvm_context *ctx,
|
|||
int param_count = 0;
|
||||
const nir_variable *var = instr->variables[0]->var;
|
||||
|
||||
const char *base_name = "llvm.amdgcn.image.atomic";
|
||||
const char *atomic_name;
|
||||
LLVMValueRef coords;
|
||||
char intrinsic_name[41], coords_type[8];
|
||||
char intrinsic_name[41];
|
||||
const struct glsl_type *type = glsl_without_array(var->type);
|
||||
MAYBE_UNUSED int length;
|
||||
|
||||
if (ctx->stage == MESA_SHADER_FRAGMENT)
|
||||
ctx->shader_info->fs.writes_memory = true;
|
||||
|
||||
params[param_count++] = get_src(ctx, instr->src[2]);
|
||||
if (instr->intrinsic == nir_intrinsic_image_atomic_comp_swap)
|
||||
params[param_count++] = get_src(ctx, instr->src[3]);
|
||||
|
||||
if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF) {
|
||||
params[param_count++] = get_sampler_desc(ctx, instr->variables[0], DESC_BUFFER);
|
||||
coords = params[param_count++] = LLVMBuildExtractElement(ctx->builder, get_src(ctx, instr->src[0]),
|
||||
LLVMConstInt(ctx->i32, 0, false), ""); /* vindex */
|
||||
params[param_count++] = ctx->i32zero; /* voffset */
|
||||
params[param_count++] = ctx->i1false; /* glc */
|
||||
params[param_count++] = ctx->i1false; /* slc */
|
||||
} else {
|
||||
bool da = glsl_sampler_type_is_array(type) ||
|
||||
glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE;
|
||||
|
||||
coords = params[param_count++] = get_image_coords(ctx, instr);
|
||||
params[param_count++] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
|
||||
params[param_count++] = ctx->i1false; /* r128 */
|
||||
params[param_count++] = da ? ctx->i1true : ctx->i1false; /* da */
|
||||
params[param_count++] = ctx->i1false; /* slc */
|
||||
}
|
||||
|
||||
switch (instr->intrinsic) {
|
||||
case nir_intrinsic_image_atomic_add:
|
||||
atomic_name = "add";
|
||||
|
|
@ -3361,11 +3338,39 @@ static LLVMValueRef visit_image_atomic(struct nir_to_llvm_context *ctx,
|
|||
default:
|
||||
abort();
|
||||
}
|
||||
build_int_type_name(LLVMTypeOf(coords),
|
||||
coords_type, sizeof(coords_type));
|
||||
|
||||
snprintf(intrinsic_name, sizeof(intrinsic_name),
|
||||
"%s.%s.%s", base_name, atomic_name, coords_type);
|
||||
params[param_count++] = get_src(ctx, instr->src[2]);
|
||||
if (instr->intrinsic == nir_intrinsic_image_atomic_comp_swap)
|
||||
params[param_count++] = get_src(ctx, instr->src[3]);
|
||||
|
||||
if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF) {
|
||||
params[param_count++] = get_sampler_desc(ctx, instr->variables[0], DESC_BUFFER);
|
||||
params[param_count++] = LLVMBuildExtractElement(ctx->builder, get_src(ctx, instr->src[0]),
|
||||
LLVMConstInt(ctx->i32, 0, false), ""); /* vindex */
|
||||
params[param_count++] = ctx->i32zero; /* voffset */
|
||||
params[param_count++] = ctx->i1false; /* slc */
|
||||
|
||||
length = snprintf(intrinsic_name, sizeof(intrinsic_name),
|
||||
"llvm.amdgcn.buffer.atomic.%s", atomic_name);
|
||||
} else {
|
||||
char coords_type[8];
|
||||
|
||||
bool da = glsl_sampler_type_is_array(type) ||
|
||||
glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE;
|
||||
|
||||
LLVMValueRef coords = params[param_count++] = get_image_coords(ctx, instr);
|
||||
params[param_count++] = get_sampler_desc(ctx, instr->variables[0], DESC_IMAGE);
|
||||
params[param_count++] = ctx->i1false; /* r128 */
|
||||
params[param_count++] = da ? ctx->i1true : ctx->i1false; /* da */
|
||||
params[param_count++] = ctx->i1false; /* slc */
|
||||
|
||||
build_int_type_name(LLVMTypeOf(coords),
|
||||
coords_type, sizeof(coords_type));
|
||||
|
||||
length = snprintf(intrinsic_name, sizeof(intrinsic_name),
|
||||
"llvm.amdgcn.image.atomic.%s.%s", atomic_name, coords_type);
|
||||
}
|
||||
|
||||
return ac_build_intrinsic(&ctx->ac, intrinsic_name, ctx->i32, params, param_count, 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue