nir: add nir_call_serialized helper
this will be used internally in vtn_bindgen2. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33099>
This commit is contained in:
committed by
Marge Bot
parent
0727b7a079
commit
e6b22e2309
@@ -23,6 +23,11 @@
|
||||
*/
|
||||
|
||||
#include "nir_builder.h"
|
||||
#include "glsl/list.h"
|
||||
#include "util/list.h"
|
||||
#include "util/ralloc.h"
|
||||
#include "nir.h"
|
||||
#include "nir_serialize.h"
|
||||
|
||||
nir_builder MUST_CHECK PRINTFLIKE(3, 4)
|
||||
nir_builder_init_simple_shader(gl_shader_stage stage,
|
||||
@@ -655,3 +660,30 @@ nir_gen_rect_vertices(nir_builder *b, nir_def *z, nir_def *w)
|
||||
|
||||
return nir_vec(b, comp, 4);
|
||||
}
|
||||
|
||||
nir_def *
|
||||
nir_call_serialized(nir_builder *b, const uint32_t *serialized,
|
||||
size_t serialized_size_B, nir_def **args)
|
||||
{
|
||||
/* Deserialize the NIR. */
|
||||
void *memctx = ralloc_context(NULL);
|
||||
struct blob_reader blob;
|
||||
blob_reader_init(&blob, (const void *)serialized, serialized_size_B);
|
||||
nir_function *func = nir_deserialize_function(memctx, b->shader->options,
|
||||
&blob);
|
||||
|
||||
/* Validate the arguments, since this won't happen anywhere else */
|
||||
for (unsigned i = 0; i < func->num_params; ++i) {
|
||||
assert(func->params[i].num_components == args[i]->num_components);
|
||||
assert(func->params[i].bit_size == args[i]->bit_size);
|
||||
}
|
||||
|
||||
/* Insert the function at the cursor position */
|
||||
nir_def *ret = nir_inline_function_impl(b, func->impl, args, NULL);
|
||||
|
||||
/* Indices & metadata are completely messed up now */
|
||||
nir_index_ssa_defs(b->impl);
|
||||
nir_metadata_preserve(b->impl, nir_metadata_none);
|
||||
ralloc_free(memctx);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2342,6 +2342,12 @@ void nir_printf_fmt(nir_builder *b,
|
||||
unsigned ptr_bit_size,
|
||||
const char *fmt, ...);
|
||||
|
||||
/* Call a serialized function. This is used internally by vtn_bindgen, it is not
|
||||
* intended for end-users of NIR.
|
||||
*/
|
||||
nir_def *nir_call_serialized(nir_builder *build, const uint32_t *serialized,
|
||||
size_t serialized_size_B, nir_def **args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user