rusticl/nir: add helper functions we need for a NIR_PASS macro
Signed-off-by: Karol Herbst <git@karolherbst.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21451>
This commit is contained in:
@@ -150,6 +150,38 @@ impl NirShader {
|
||||
unsafe { pass(self.nir.as_ptr(), a, b, c) }
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn metadata_check_validation_flag(&self) {
|
||||
unsafe { nir_metadata_check_validation_flag(self.nir.as_ptr()) }
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn metadata_set_validation_flag(&mut self) {
|
||||
unsafe { nir_metadata_set_validation_flag(self.nir.as_ptr()) }
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn validate(&self, when: &str) {
|
||||
let cstr = CString::new(when).unwrap();
|
||||
unsafe { nir_validate_shader(self.nir.as_ptr(), cstr.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn should_print(&self) -> bool {
|
||||
unsafe { should_print_nir(self.nir.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn validate_serialize_deserialize(&self) {
|
||||
unsafe { nir_shader_serialize_deserialize(self.nir.as_ptr()) }
|
||||
}
|
||||
|
||||
pub fn validate_clone(&mut self) {
|
||||
unsafe {
|
||||
let nir_ptr = self.nir.as_ptr();
|
||||
let clone = nir_shader_clone(ralloc_parent(nir_ptr.cast()), nir_ptr);
|
||||
nir_shader_replace(nir_ptr, clone)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn entrypoint(&self) -> *mut nir_function_impl {
|
||||
unsafe { nir_shader_get_entrypoint(self.nir.as_ptr()) }
|
||||
}
|
||||
|
||||
@@ -270,6 +270,7 @@ rusticl_mesa_bindings_rs = rust.bindgen(
|
||||
'--bitfield-enum', 'nir_lower_int64_options',
|
||||
'--bitfield-enum', 'nir_opt_if_options',
|
||||
'--bitfield-enum', 'nir_variable_mode',
|
||||
'--allowlist-function', 'should_.*_nir',
|
||||
'--allowlist-function', 'spirv_.*',
|
||||
|
||||
# gallium
|
||||
|
||||
@@ -31,6 +31,18 @@ pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src)
|
||||
__pipe_resource_reference_wraped(dst, src);
|
||||
}
|
||||
|
||||
bool
|
||||
should_skip_nir(const char *name)
|
||||
{
|
||||
return __should_skip_nir(name);
|
||||
}
|
||||
|
||||
bool
|
||||
should_print_nir(nir_shader *shader)
|
||||
{
|
||||
return __should_print_nir(shader);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_pack_rgba(enum pipe_format format, void *dst, const void *src, unsigned w)
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#define mesa_bytes_to_hex __mesa_bytes_to_hex
|
||||
#define nir_shader_get_entrypoint __nir_shader_get_entrypoint_wraped
|
||||
#define pipe_resource_reference __pipe_resource_reference_wraped
|
||||
#define should_print_nir __should_print_nir
|
||||
#define should_skip_nir __should_skip_nir
|
||||
#define util_format_pack_rgba __util_format_pack_rgba
|
||||
#include "nir.h"
|
||||
#include "util/blob.h"
|
||||
@@ -15,6 +17,8 @@
|
||||
#undef disk_cache_get_function_identifier
|
||||
#undef nir_shader_get_entrypoint
|
||||
#undef pipe_resource_reference
|
||||
#undef should_print_nir
|
||||
#undef should_skip_nir
|
||||
#undef util_format_pack_rgba
|
||||
|
||||
void blob_finish(struct blob *);
|
||||
@@ -23,4 +27,6 @@ bool disk_cache_get_function_identifier(void *ptr, struct mesa_sha1 *ctx);
|
||||
const char* mesa_version_string(void);
|
||||
nir_function_impl *nir_shader_get_entrypoint(const nir_shader *shader);
|
||||
void pipe_resource_reference(struct pipe_resource **dst, struct pipe_resource *src);
|
||||
bool should_skip_nir(const char *);
|
||||
bool should_print_nir(nir_shader *);
|
||||
void util_format_pack_rgba(enum pipe_format format, void *dst, const void *src, unsigned w);
|
||||
|
||||
Reference in New Issue
Block a user