glsl: add sparseTexelsResidentARB builtin function
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14362>
This commit is contained in:
parent
a0b6515ec4
commit
634bb25123
|
@ -884,6 +884,12 @@ is_not_nir(const _mesa_glsl_parse_state *state)
|
|||
return !is_nir(state);
|
||||
}
|
||||
|
||||
static bool
|
||||
sparse_enabled(const _mesa_glsl_parse_state *state)
|
||||
{
|
||||
return state->ARB_sparse_texture2_enable;
|
||||
}
|
||||
|
||||
static bool
|
||||
v130_desktop_and_sparse(const _mesa_glsl_parse_state *state)
|
||||
{
|
||||
|
@ -1167,6 +1173,9 @@ private:
|
|||
BA2(textureSize);
|
||||
BA1(textureSamples);
|
||||
|
||||
B0(is_sparse_texels_resident);
|
||||
B0(is_sparse_texels_resident_intrinsic);
|
||||
|
||||
/** Flags to _texture() */
|
||||
#define TEX_PROJECT 1
|
||||
#define TEX_OFFSET 2
|
||||
|
@ -1682,6 +1691,9 @@ builtin_builder::create_intrinsics()
|
|||
|
||||
add_function("__intrinsic_helper_invocation",
|
||||
_helper_invocation_intrinsic(), NULL);
|
||||
|
||||
add_function("__intrinsic_is_sparse_texels_resident",
|
||||
_is_sparse_texels_resident_intrinsic(), NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4363,6 +4375,8 @@ builtin_builder::create_builtins()
|
|||
_texture(ir_tg4, gpu_shader5_and_sparse, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type, TEX_OFFSET_ARRAY|TEX_SPARSE),
|
||||
NULL);
|
||||
|
||||
add_function("sparseTexelsResidentARB", _is_sparse_texels_resident(), NULL);
|
||||
|
||||
F(dFdx)
|
||||
F(dFdy)
|
||||
F(fwidth)
|
||||
|
@ -6912,6 +6926,30 @@ builtin_builder::_textureSamples(builtin_available_predicate avail,
|
|||
return sig;
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
builtin_builder::_is_sparse_texels_resident(void)
|
||||
{
|
||||
ir_variable *code = in_var(glsl_type::int_type, "code");
|
||||
MAKE_SIG(glsl_type::bool_type, sparse_enabled, 1, code);
|
||||
|
||||
ir_variable *retval = body.make_temp(glsl_type::bool_type, "retval");
|
||||
ir_function *f =
|
||||
shader->symbols->get_function("__intrinsic_is_sparse_texels_resident");
|
||||
|
||||
body.emit(call(f, retval, sig->parameters));
|
||||
body.emit(ret(retval));
|
||||
return sig;
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
builtin_builder::_is_sparse_texels_resident_intrinsic(void)
|
||||
{
|
||||
ir_variable *code = in_var(glsl_type::int_type, "code");
|
||||
MAKE_INTRINSIC(glsl_type::bool_type, ir_intrinsic_is_sparse_texels_resident,
|
||||
sparse_enabled, 1, code);
|
||||
return sig;
|
||||
}
|
||||
|
||||
ir_function_signature *
|
||||
builtin_builder::_texture(ir_texture_opcode opcode,
|
||||
builtin_available_predicate avail,
|
||||
|
|
|
@ -1174,6 +1174,8 @@ enum ir_intrinsic_id {
|
|||
ir_intrinsic_shared_atomic_max = MAKE_INTRINSIC_FOR_TYPE(atomic_max, shared),
|
||||
ir_intrinsic_shared_atomic_exchange = MAKE_INTRINSIC_FOR_TYPE(atomic_exchange, shared),
|
||||
ir_intrinsic_shared_atomic_comp_swap = MAKE_INTRINSIC_FOR_TYPE(atomic_comp_swap, shared),
|
||||
|
||||
ir_intrinsic_is_sparse_texels_resident,
|
||||
};
|
||||
|
||||
/*@{*/
|
||||
|
|
|
@ -4348,6 +4348,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
|
|||
case ir_intrinsic_begin_invocation_interlock:
|
||||
case ir_intrinsic_end_invocation_interlock:
|
||||
case ir_intrinsic_image_sparse_load:
|
||||
case ir_intrinsic_is_sparse_texels_resident:
|
||||
unreachable("Invalid intrinsic");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue