Module: Mesa Branch: main Commit: f1cf7f0d869c6daf2104d1cb975cc21b7a3e5433 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f1cf7f0d869c6daf2104d1cb975cc21b7a3e5433
Author: Faith Ekstrand <faith.ekstr...@collabora.com> Date: Mon Jan 15 12:37:52 2024 -0600 nak: Stop passing --explicit-padding to bindgen It's apparently broken on 32-bit builds and screws up our NIR bindings. Instead, using -Wpadded with a pragma to ensure we don't add padding to the struct. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27078> --- src/nouveau/compiler/meson.build | 2 -- src/nouveau/compiler/nak.h | 8 ++++---- src/nouveau/compiler/nak/api.rs | 21 --------------------- 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src/nouveau/compiler/meson.build b/src/nouveau/compiler/meson.build index f8a55046edb..535294ecf1f 100644 --- a/src/nouveau/compiler/meson.build +++ b/src/nouveau/compiler/meson.build @@ -78,13 +78,11 @@ nak_bindings_rs = rust.bindgen( '--allowlist-type', 'mesa_scope', '--allowlist-type', 'mesa_prim', '--allowlist-type', 'tess_primitive_mode', - '--allowlist-var', 'NAK_.*', '--allowlist-var', 'nir_.*_infos', '--allowlist-function', '_mesa_shader_stage_to_string', '--allowlist-function', 'nak_.*', '--allowlist-function', 'nir_.*', '--allowlist-function', 'glsl_.*', - '--explicit-padding', '--no-prepend-enum-name', ], dependencies : libnak_deps, diff --git a/src/nouveau/compiler/nak.h b/src/nouveau/compiler/nak.h index cfec9e4f738..db768e14e6c 100644 --- a/src/nouveau/compiler/nak.h +++ b/src/nouveau/compiler/nak.h @@ -79,9 +79,6 @@ struct nak_xfb_info { uint8_t attr_index[4][128]; }; -/* This is an enum so bindgen will generate it */ -#define NAK_SHADER_INFO_STAGE_UNION_SIZE 12 - /* This struct MUST have explicit padding fields to ensure that all padding is * zeroed and the zeros get properly copied, even across API boundaries. This * is ensured in two ways: @@ -93,6 +90,8 @@ struct nak_xfb_info { * - There is a set of const asserts in nak/api.rs which ensure that all of * the union fields are equal to NAK_SHADER_INFO_STAGE_UNION_SIZE. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic error "-Wpadded" struct nak_shader_info { gl_shader_stage stage; @@ -137,7 +136,7 @@ struct nak_shader_info { } ts; /* Used to initialize the union for other stages */ - uint8_t _pad[NAK_SHADER_INFO_STAGE_UNION_SIZE]; + uint8_t _pad[12]; }; struct { @@ -153,6 +152,7 @@ struct nak_shader_info { /** Shader header for 3D stages */ uint32_t hdr[32]; }; +#pragma GCC diagnostic pop struct nak_shader_bin { struct nak_shader_info info; diff --git a/src/nouveau/compiler/nak/api.rs b/src/nouveau/compiler/nak/api.rs index 35fad6f2aa2..3ad0aaab8cf 100644 --- a/src/nouveau/compiler/nak/api.rs +++ b/src/nouveau/compiler/nak/api.rs @@ -154,7 +154,6 @@ pub extern "C" fn nak_compiler_create( let nak = Box::new(nak_compiler { sm: dev.sm, nir_options: nir_options(dev), - ..unsafe { std::mem::zeroed() } }); Box::into_raw(nak) @@ -199,7 +198,6 @@ impl ShaderBin { } else { asm.as_ptr() }, - ..unsafe { std::mem::zeroed() } }; ShaderBin { bin: bin, @@ -228,25 +226,6 @@ fn eprint_hex(label: &str, data: &[u32]) { eprintln!(""); } -const _: () = { - assert!( - std::mem::size_of::<nak_shader_info__bindgen_ty_1>() - == NAK_SHADER_INFO_STAGE_UNION_SIZE as usize - ); - assert!( - std::mem::size_of::<nak_shader_info__bindgen_ty_1__bindgen_ty_1>() - == NAK_SHADER_INFO_STAGE_UNION_SIZE as usize - ); - assert!( - std::mem::size_of::<nak_shader_info__bindgen_ty_1__bindgen_ty_2>() - == NAK_SHADER_INFO_STAGE_UNION_SIZE as usize - ); - assert!( - std::mem::size_of::<nak_shader_info__bindgen_ty_1__bindgen_ty_2>() - == NAK_SHADER_INFO_STAGE_UNION_SIZE as usize - ); -}; - #[no_mangle] pub extern "C" fn nak_compile_shader( nir: *mut nir_shader,