ac/nir: Don't load the descriptor in vulkan_resource_index.
To support the reindex intrinsic, we need the result to be something on which we can adjust the index/address. Since it is all within a basic block, the compiler should be able to merge any extra loads. v2: Change visit_get_buffer_size too. Reviewed-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
bf0904e31f
commit
368f49b284
|
@ -2227,7 +2227,7 @@ static LLVMValueRef visit_vulkan_resource_index(struct nir_to_llvm_context *ctx,
|
||||||
desc_ptr = cast_ptr(ctx, desc_ptr, ctx->ac.v4i32);
|
desc_ptr = cast_ptr(ctx, desc_ptr, ctx->ac.v4i32);
|
||||||
LLVMSetMetadata(desc_ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
|
LLVMSetMetadata(desc_ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
|
||||||
|
|
||||||
return LLVMBuildLoad(ctx->builder, desc_ptr, "");
|
return desc_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LLVMValueRef visit_load_push_constant(struct nir_to_llvm_context *ctx,
|
static LLVMValueRef visit_load_push_constant(struct nir_to_llvm_context *ctx,
|
||||||
|
@ -2247,9 +2247,9 @@ static LLVMValueRef visit_load_push_constant(struct nir_to_llvm_context *ctx,
|
||||||
static LLVMValueRef visit_get_buffer_size(struct ac_nir_context *ctx,
|
static LLVMValueRef visit_get_buffer_size(struct ac_nir_context *ctx,
|
||||||
const nir_intrinsic_instr *instr)
|
const nir_intrinsic_instr *instr)
|
||||||
{
|
{
|
||||||
LLVMValueRef desc = get_src(ctx, instr->src[0]);
|
LLVMValueRef ptr = get_src(ctx, instr->src[0]);
|
||||||
|
|
||||||
return get_buffer_size(ctx, desc, false);
|
return get_buffer_size(ctx, LLVMBuildLoad(ctx->ac.builder, ptr, ""), false);
|
||||||
}
|
}
|
||||||
static void visit_store_ssbo(struct ac_nir_context *ctx,
|
static void visit_store_ssbo(struct ac_nir_context *ctx,
|
||||||
nir_intrinsic_instr *instr)
|
nir_intrinsic_instr *instr)
|
||||||
|
@ -4233,14 +4233,21 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
static LLVMValueRef radv_load_ssbo(struct ac_shader_abi *abi,
|
static LLVMValueRef radv_load_ssbo(struct ac_shader_abi *abi,
|
||||||
LLVMValueRef buffer, bool write)
|
LLVMValueRef buffer_ptr, bool write)
|
||||||
{
|
{
|
||||||
struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
|
struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
|
||||||
|
|
||||||
if (write && ctx->stage == MESA_SHADER_FRAGMENT)
|
if (write && ctx->stage == MESA_SHADER_FRAGMENT)
|
||||||
ctx->shader_info->fs.writes_memory = true;
|
ctx->shader_info->fs.writes_memory = true;
|
||||||
|
|
||||||
return buffer;
|
return LLVMBuildLoad(ctx->builder, buffer_ptr, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
static LLVMValueRef radv_load_ubo(struct ac_shader_abi *abi, LLVMValueRef buffer_ptr)
|
||||||
|
{
|
||||||
|
struct nir_to_llvm_context *ctx = nir_to_llvm_context_from_abi(abi);
|
||||||
|
|
||||||
|
return LLVMBuildLoad(ctx->builder, buffer_ptr, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi,
|
static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi,
|
||||||
|
@ -6541,6 +6548,7 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm,
|
||||||
ctx.abi.inputs = &ctx.inputs[0];
|
ctx.abi.inputs = &ctx.inputs[0];
|
||||||
ctx.abi.emit_outputs = handle_shader_outputs_post;
|
ctx.abi.emit_outputs = handle_shader_outputs_post;
|
||||||
ctx.abi.emit_vertex = visit_emit_vertex;
|
ctx.abi.emit_vertex = visit_emit_vertex;
|
||||||
|
ctx.abi.load_ubo = radv_load_ubo;
|
||||||
ctx.abi.load_ssbo = radv_load_ssbo;
|
ctx.abi.load_ssbo = radv_load_ssbo;
|
||||||
ctx.abi.load_sampler_desc = radv_get_sampler_desc;
|
ctx.abi.load_sampler_desc = radv_get_sampler_desc;
|
||||||
ctx.abi.clamp_shadow_reference = false;
|
ctx.abi.clamp_shadow_reference = false;
|
||||||
|
|
Loading…
Reference in New Issue