return LLVMBuildInsertElement(ctx->ac.builder, rsrc, tmp, i32_6, "");
}
+static LLVMValueRef fixup_image_desc(struct si_shader_context *ctx, LLVMValueRef rsrc,
+ bool uses_store)
+{
+ if (uses_store && ctx->ac.chip_class <= GFX9)
+ rsrc = force_dcc_off(ctx, rsrc);
+
+ if (!uses_store && ctx->screen->info.has_image_load_dcc_bug &&
+ ctx->screen->always_allow_dcc_stores)
+ rsrc = force_write_compress_off(ctx, rsrc);
+
+ return rsrc;
+}
+
/* AC_DESC_FMASK is handled exactly like AC_DESC_IMAGE. The caller should
* adjust "index" to point to FMASK. */
static LLVMValueRef si_load_image_desc(struct si_shader_context *ctx, LLVMValueRef list,
else
rsrc = ac_build_load_to_sgpr(&ctx->ac, list, index);
- if (desc_type == AC_DESC_IMAGE && uses_store && ctx->ac.chip_class <= GFX9)
- rsrc = force_dcc_off(ctx, rsrc);
-
- if (desc_type == AC_DESC_IMAGE && !uses_store &&
- ctx->screen->always_allow_dcc_stores && ctx->screen->info.has_image_load_dcc_bug)
- rsrc = force_write_compress_off(ctx, rsrc);
+ if (desc_type == AC_DESC_IMAGE)
+ rsrc = fixup_image_desc(ctx, rsrc, uses_store);
return rsrc;
}
/* Fast path if the image is in user SGPRs. */
if (!dynamic_index &&
const_index < ctx->shader->selector->cs_num_images_in_user_sgprs &&
- (desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_BUFFER))
- return ac_get_arg(&ctx->ac, ctx->cs_image[const_index]);
+ (desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_BUFFER)) {
+ LLVMValueRef rsrc = ac_get_arg(&ctx->ac, ctx->cs_image[const_index]);
+
+ if (desc_type == AC_DESC_IMAGE)
+ rsrc = fixup_image_desc(ctx, rsrc, write);
+ return rsrc;
+ }
/* FMASKs are separate from images. */
if (desc_type == AC_DESC_FMASK) {