mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 08:30:10 +01:00
ac/llvm: implement nir_tex_src_{texture,sampler}_handle
nir_tex_src_{texture,sampler}_handle is either the actual descriptor as a
vec4/vec8 or a pointer passed to load_sampler_desc.
The sample index isn't adjusted using FMASK when these are used.
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12773>
This commit is contained in:
parent
53ccb2a9a7
commit
3d52d3cd9b
1 changed files with 61 additions and 18 deletions
|
|
@ -4509,10 +4509,15 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr,
|
|||
struct waterfall_context *wctx, LLVMValueRef *res_ptr,
|
||||
LLVMValueRef *samp_ptr, LLVMValueRef *fmask_ptr)
|
||||
{
|
||||
LLVMValueRef texture_dynamic_handle = NULL;
|
||||
LLVMValueRef sampler_dynamic_handle = NULL;
|
||||
nir_deref_instr *texture_deref_instr = NULL;
|
||||
nir_deref_instr *sampler_deref_instr = NULL;
|
||||
int plane = -1;
|
||||
|
||||
*res_ptr = NULL;
|
||||
*samp_ptr = NULL;
|
||||
*fmask_ptr = NULL;
|
||||
for (unsigned i = 0; i < instr->num_srcs; i++) {
|
||||
switch (instr->src[i].src_type) {
|
||||
case nir_tex_src_texture_deref:
|
||||
|
|
@ -4521,6 +4526,22 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr,
|
|||
case nir_tex_src_sampler_deref:
|
||||
sampler_deref_instr = nir_src_as_deref(instr->src[i].src);
|
||||
break;
|
||||
case nir_tex_src_texture_handle:
|
||||
case nir_tex_src_sampler_handle: {
|
||||
LLVMValueRef val = get_src(ctx, instr->src[i].src);
|
||||
if (LLVMGetTypeKind(LLVMTypeOf(val)) == LLVMVectorTypeKind) {
|
||||
if (instr->src[i].src_type == nir_tex_src_texture_handle)
|
||||
*res_ptr = val;
|
||||
else
|
||||
*samp_ptr = val;
|
||||
} else {
|
||||
if (instr->src[i].src_type == nir_tex_src_texture_handle)
|
||||
texture_dynamic_handle = val;
|
||||
else
|
||||
sampler_dynamic_handle = val;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case nir_tex_src_plane:
|
||||
plane = nir_src_as_int(instr->src[i].src);
|
||||
break;
|
||||
|
|
@ -4529,6 +4550,45 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr,
|
|||
}
|
||||
}
|
||||
|
||||
if (*res_ptr) {
|
||||
/* descriptors given through nir_tex_src_{texture,sampler}_handle */
|
||||
return;
|
||||
}
|
||||
|
||||
enum ac_descriptor_type main_descriptor =
|
||||
instr->sampler_dim == GLSL_SAMPLER_DIM_BUF ? AC_DESC_BUFFER : AC_DESC_IMAGE;
|
||||
|
||||
if (plane >= 0) {
|
||||
assert(instr->op != nir_texop_txf_ms && instr->op != nir_texop_samples_identical);
|
||||
assert(instr->sampler_dim != GLSL_SAMPLER_DIM_BUF);
|
||||
|
||||
main_descriptor = AC_DESC_PLANE_0 + plane;
|
||||
}
|
||||
|
||||
if (instr->op == nir_texop_fragment_mask_fetch_amd || instr->op == nir_texop_samples_identical) {
|
||||
/* The fragment mask is fetched from the compressed
|
||||
* multisampled surface.
|
||||
*/
|
||||
main_descriptor = AC_DESC_FMASK;
|
||||
}
|
||||
|
||||
if (texture_dynamic_handle) {
|
||||
/* descriptor handles given through nir_tex_src_{texture,sampler}_handle */
|
||||
if (instr->texture_non_uniform)
|
||||
texture_dynamic_handle = enter_waterfall(ctx, &wctx[0], texture_dynamic_handle, true);
|
||||
|
||||
if (instr->sampler_non_uniform)
|
||||
sampler_dynamic_handle = enter_waterfall(ctx, &wctx[1], sampler_dynamic_handle, true);
|
||||
|
||||
*res_ptr = ctx->abi->load_sampler_desc(ctx->abi, 0, 0, 0, texture_dynamic_handle,
|
||||
main_descriptor, false, false, true);
|
||||
|
||||
if (samp_ptr)
|
||||
*samp_ptr = ctx->abi->load_sampler_desc(ctx->abi, 0, 0, 0, sampler_dynamic_handle,
|
||||
AC_DESC_SAMPLER, false, false, true);
|
||||
return;
|
||||
}
|
||||
|
||||
LLVMValueRef texture_dynamic_index =
|
||||
get_sampler_desc_index(ctx, texture_deref_instr, &instr->instr, false);
|
||||
if (!sampler_deref_instr)
|
||||
|
|
@ -4542,23 +4602,6 @@ static void tex_fetch_ptrs(struct ac_nir_context *ctx, nir_tex_instr *instr,
|
|||
if (instr->sampler_non_uniform)
|
||||
sampler_dynamic_index = enter_waterfall(ctx, wctx + 1, sampler_dynamic_index, true);
|
||||
|
||||
enum ac_descriptor_type main_descriptor =
|
||||
instr->sampler_dim == GLSL_SAMPLER_DIM_BUF ? AC_DESC_BUFFER : AC_DESC_IMAGE;
|
||||
|
||||
if (plane >= 0) {
|
||||
assert(instr->op != nir_texop_txf_ms && instr->op != nir_texop_samples_identical);
|
||||
assert(instr->sampler_dim != GLSL_SAMPLER_DIM_BUF);
|
||||
|
||||
main_descriptor = AC_DESC_PLANE_0 + plane;
|
||||
}
|
||||
|
||||
if (instr->op == nir_texop_fragment_mask_fetch_amd) {
|
||||
/* The fragment mask is fetched from the compressed
|
||||
* multisampled surface.
|
||||
*/
|
||||
main_descriptor = AC_DESC_FMASK;
|
||||
}
|
||||
|
||||
*res_ptr = get_sampler_desc(ctx, texture_deref_instr, main_descriptor, &instr->instr,
|
||||
texture_dynamic_index, false, false);
|
||||
|
||||
|
|
@ -4815,7 +4858,7 @@ static void visit_tex(struct ac_nir_context *ctx, nir_tex_instr *instr)
|
|||
memcpy(txf_args.coords, args.coords, sizeof(txf_args.coords));
|
||||
|
||||
txf_args.dmask = 0xf;
|
||||
txf_args.resource = fmask_ptr;
|
||||
txf_args.resource = args.resource;
|
||||
txf_args.dim = instr->is_array ? ac_image_2darray : ac_image_2d;
|
||||
result = build_tex_intrinsic(ctx, instr, &txf_args);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue