diff --git a/Cargo.toml b/Cargo.toml index eb94669..ed5d1f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,5 +11,5 @@ members = [ ] [patch.crates-io] -rspirv = { git = 'https://github.com/vosen/rspirv', branch = 'notcuda' } -spirv_headers = { git = 'https://github.com/vosen/rspirv', branch = 'notcuda' } \ No newline at end of file +rspirv = { git = 'https://github.com/vosen/rspirv', rev = '4523d54d785faff59c1e928dd1f210c531a70258' } +spirv_headers = { git = 'https://github.com/vosen/rspirv', rev = '4523d54d785faff59c1e928dd1f210c531a70258' } \ No newline at end of file diff --git a/ptx/src/test/spirv_run/mod.rs b/ptx/src/test/spirv_run/mod.rs index 394e757..c1ef574 100644 --- a/ptx/src/test/spirv_run/mod.rs +++ b/ptx/src/test/spirv_run/mod.rs @@ -1,6 +1,9 @@ use crate::ptx; use crate::translate; -use rspirv::{binary::Disassemble, dr::{Block, Function, Instruction, Loader, Operand}}; +use rspirv::{ + binary::Assemble, + dr::{Block, Function, Instruction, Loader, Operand}, +}; use spirv_headers::Word; use spirv_tools_sys::{ spv_binary, spv_endianness_t, spv_parsed_instruction_t, spv_result_t, spv_target_env, @@ -37,9 +40,9 @@ macro_rules! test_ptx { } test_ptx!(ld_st, [1u64], [1u64]); -//test_ptx!(mov, [1u64], [1u64]); -//test_ptx!(mul_lo, [1u64], [2u64]); -//test_ptx!(mul_hi, [u64::max_value()], [1u64]); +test_ptx!(mov, [1u64], [1u64]); +test_ptx!(mul_lo, [1u64], [2u64]); +test_ptx!(mul_hi, [u64::max_value()], [1u64]); struct DisplayError { err: T, @@ -155,9 +158,31 @@ fn test_spvtxt_assert<'a>( let mut loader = Loader::new(); rspirv::binary::parse_words(&parsed_spirv, &mut loader)?; let spvtxt_mod = loader.module(); + unsafe { spirv_tools::spvBinaryDestroy(spv_binary) }; if !is_spirv_fn_equal(&ptx_mod.functions[0], &spvtxt_mod.functions[0]) { - panic!(ptx_mod.disassemble()) + // We could simply use ptx_mod.disassemble, but SPIRV-Tools text formattinmg is so much nicer + let spv_from_ptx_binary = ptx_mod.assemble(); + let mut spv_text: spirv_tools::spv_text = ptr::null_mut(); + let result = unsafe { + spirv_tools::spvBinaryToText( + spv_context, + spv_from_ptx_binary.as_ptr(), + spv_from_ptx_binary.len(), + (spirv_tools::spv_binary_to_text_options_t::SPV_BINARY_TO_TEXT_OPTION_INDENT | spirv_tools::spv_binary_to_text_options_t::SPV_BINARY_TO_TEXT_OPTION_NO_HEADER | spirv_tools::spv_binary_to_text_options_t::SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES).0, + &mut spv_text as *mut _, + ptr::null_mut() + ) + }; + assert_eq!(result, spv_result_t::SPV_SUCCESS); + let raw_text = unsafe { + std::slice::from_raw_parts((*spv_text).str_ as *const u8, (*spv_text).length) + }; + let spv_from_ptx_text = unsafe { str::from_utf8_unchecked(raw_text) }; + // TODO: stop leaking kernel text + unsafe { spirv_tools::spvContextDestroy(spv_context) }; + panic!(spv_from_ptx_text); } + unsafe { spirv_tools::spvContextDestroy(spv_context) }; Ok(()) } diff --git a/ptx/src/test/spirv_run/mov.spvtxt b/ptx/src/test/spirv_run/mov.spvtxt index 3f11b26..367a92a 100644 --- a/ptx/src/test/spirv_run/mov.spvtxt +++ b/ptx/src/test/spirv_run/mov.spvtxt @@ -1,26 +1,43 @@ -OpCapability GenericPointer -OpCapability Linkage -OpCapability Addresses -OpCapability Kernel -OpCapability Int64 -OpCapability Int8 -%1 = OpExtInstImport "OpenCL.std" -OpMemoryModel Physical64 OpenCL -OpEntryPoint Kernel %5 "mov" -%2 = OpTypeVoid -%3 = OpTypeInt 64 0 -%4 = OpTypeFunction %2 %3 %3 -%19 = OpTypePointer Generic %3 -%5 = OpFunction %2 None %4 -%6 = OpFunctionParameter %3 -%7 = OpFunctionParameter %3 -%18 = OpLabel -%13 = OpCopyObject %3 %6 -%14 = OpCopyObject %3 %7 -%15 = OpConvertUToPtr %19 %13 -%16 = OpLoad %3 %15 -%100 = OpCopyObject %3 %16 -%17 = OpConvertUToPtr %19 %14 -OpStore %17 %100 -OpReturn -OpFunctionEnd +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 23 +; Schema: 0 + OpCapability GenericPointer + OpCapability Linkage + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "mov" + %void = OpTypeVoid + %ulong = OpTypeInt 64 0 + %5 = OpTypeFunction %void %ulong %ulong +%_ptr_Function_ulong = OpTypePointer Function %ulong +%_ptr_Generic_ulong = OpTypePointer Generic %ulong + %2 = OpFunction %void None %5 + %8 = OpFunctionParameter %ulong + %9 = OpFunctionParameter %ulong + %10 = OpLabel + %11 = OpVariable %_ptr_Function_ulong Function + %12 = OpVariable %_ptr_Function_ulong Function + %13 = OpVariable %_ptr_Function_ulong Function + %14 = OpVariable %_ptr_Function_ulong Function + OpStore %11 %8 + OpStore %12 %9 + %15 = OpLoad %ulong %11 + %16 = OpConvertUToPtr %_ptr_Generic_ulong %15 + %17 = OpLoad %ulong %16 + OpStore %13 %17 + %18 = OpLoad %ulong %13 + %19 = OpCopyObject %ulong %18 + OpStore %14 %19 + %20 = OpLoad %ulong %12 + %21 = OpLoad %ulong %14 + %22 = OpConvertUToPtr %_ptr_Generic_ulong %20 + OpStore %22 %21 + OpReturn + OpFunctionEnd + \ No newline at end of file diff --git a/ptx/src/test/spirv_run/mul_hi.spvtxt b/ptx/src/test/spirv_run/mul_hi.spvtxt index db8943f..d25dd8a 100644 --- a/ptx/src/test/spirv_run/mul_hi.spvtxt +++ b/ptx/src/test/spirv_run/mul_hi.spvtxt @@ -1,26 +1,43 @@ -OpCapability GenericPointer -OpCapability Linkage -OpCapability Addresses -OpCapability Kernel -OpCapability Int64 -OpCapability Int8 -%1 = OpExtInstImport "OpenCL.std" -OpMemoryModel Physical64 OpenCL -OpEntryPoint Kernel %5 "mul_hi" -%2 = OpTypeVoid -%3 = OpTypeInt 64 0 -%4 = OpTypeFunction %2 %3 %3 -%19 = OpTypePointer Generic %3 -%5 = OpFunction %2 None %4 -%6 = OpFunctionParameter %3 -%7 = OpFunctionParameter %3 -%18 = OpLabel -%13 = OpCopyObject %3 %6 -%14 = OpCopyObject %3 %7 -%15 = OpConvertUToPtr %19 %13 -%16 = OpLoad %3 %15 -%100 = OpCopyObject %3 %16 -%17 = OpConvertUToPtr %19 %14 -OpStore %17 %100 -OpReturn -OpFunctionEnd +; SPIR-V +; Version: 1.5 +; Generator: Khronos SPIR-V Tools Assembler; 0 +; Bound: 24 +; Schema: 0 + OpCapability GenericPointer + OpCapability Linkage + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %2 "mul_hi" + %void = OpTypeVoid + %ulong = OpTypeInt 64 0 + %5 = OpTypeFunction %void %ulong %ulong +%_ptr_Function_ulong = OpTypePointer Function %ulong +%_ptr_Generic_ulong = OpTypePointer Generic %ulong + %ulong_2 = OpConstant %ulong 2 + %2 = OpFunction %void None %5 + %9 = OpFunctionParameter %ulong + %10 = OpFunctionParameter %ulong + %11 = OpLabel + %12 = OpVariable %_ptr_Function_ulong Function + %13 = OpVariable %_ptr_Function_ulong Function + %14 = OpVariable %_ptr_Function_ulong Function + %15 = OpVariable %_ptr_Function_ulong Function + OpStore %12 %9 + OpStore %13 %10 + %16 = OpLoad %ulong %12 + %17 = OpConvertUToPtr %_ptr_Generic_ulong %16 + %18 = OpLoad %ulong %17 + OpStore %14 %18 + %19 = OpLoad %ulong %14 + %20 = OpExtInst %ulong %1 u_mul_hi %19 %ulong_2 + OpStore %15 %20 + %21 = OpLoad %ulong %13 + %22 = OpLoad %ulong %15 + %23 = OpConvertUToPtr %_ptr_Generic_ulong %21 + OpStore %23 %22 + OpReturn + OpFunctionEnd diff --git a/ptx/src/test/spirv_run/mul_lo.spvtxt b/ptx/src/test/spirv_run/mul_lo.spvtxt index 66e7bc1..4d7c2d8 100644 --- a/ptx/src/test/spirv_run/mul_lo.spvtxt +++ b/ptx/src/test/spirv_run/mul_lo.spvtxt @@ -1,26 +1,38 @@ -OpCapability GenericPointer -OpCapability Linkage -OpCapability Addresses -OpCapability Kernel -OpCapability Int64 -OpCapability Int8 -%1 = OpExtInstImport "OpenCL.std" -OpMemoryModel Physical64 OpenCL -OpEntryPoint Kernel %5 "mul_lo" -%2 = OpTypeVoid -%3 = OpTypeInt 64 0 -%4 = OpTypeFunction %2 %3 %3 -%19 = OpTypePointer Generic %3 -%5 = OpFunction %2 None %4 -%6 = OpFunctionParameter %3 -%7 = OpFunctionParameter %3 -%18 = OpLabel -%13 = OpCopyObject %3 %6 -%14 = OpCopyObject %3 %7 -%15 = OpConvertUToPtr %19 %13 -%16 = OpLoad %3 %15 -%100 = OpCopyObject %3 %16 -%17 = OpConvertUToPtr %19 %14 -OpStore %17 %100 -OpReturn -OpFunctionEnd + OpCapability GenericPointer + OpCapability Linkage + OpCapability Addresses + OpCapability Kernel + OpCapability Int64 + OpCapability Int8 + %1 = OpExtInstImport "OpenCL.std" + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %5 "mul_lo" + %void = OpTypeVoid + %ulong = OpTypeInt 64 0 + %4 = OpTypeFunction %void %ulong %ulong +%_ptr_Function_ulong = OpTypePointer Function %ulong +%_ptr_Generic_ulong = OpTypePointer Generic %ulong + %ulong_2 = OpConstant %ulong 2 + %5 = OpFunction %void None %4 + %6 = OpFunctionParameter %ulong + %7 = OpFunctionParameter %ulong + %21 = OpLabel + %8 = OpVariable %_ptr_Function_ulong Function + %9 = OpVariable %_ptr_Function_ulong Function + %10 = OpVariable %_ptr_Function_ulong Function + %11 = OpVariable %_ptr_Function_ulong Function + OpStore %8 %6 + OpStore %9 %7 + %12 = OpLoad %ulong %8 + %19 = OpConvertUToPtr %_ptr_Generic_ulong %12 + %13 = OpLoad %ulong %19 + OpStore %10 %13 + %14 = OpLoad %ulong %10 + %15 = OpIMul %ulong %14 %ulong_2 + OpStore %11 %15 + %16 = OpLoad %ulong %9 + %17 = OpLoad %ulong %11 + %20 = OpConvertUToPtr %_ptr_Generic_ulong %16 + OpStore %20 %17 + OpReturn + OpFunctionEnd diff --git a/ptx/src/translate.rs b/ptx/src/translate.rs index 1ad077c..7512545 100644 --- a/ptx/src/translate.rs +++ b/ptx/src/translate.rs @@ -107,11 +107,11 @@ pub fn to_spirv_module(ast: ast::Module) -> Result { builder.set_version(1, 0); emit_capabilities(&mut builder); emit_extensions(&mut builder); - emit_extended_instruction_sets(&mut builder); + let opencl_id = emit_opencl_import(&mut builder); emit_memory_model(&mut builder); let mut map = TypeWordMap::new(&mut builder); for f in ast.functions { - emit_function(&mut builder, &mut map, f)?; + emit_function(&mut builder, &mut map, opencl_id, f)?; } Ok(builder.module()) } @@ -132,8 +132,8 @@ fn emit_capabilities(builder: &mut dr::Builder) { fn emit_extensions(_: &mut dr::Builder) {} -fn emit_extended_instruction_sets(builder: &mut dr::Builder) { - builder.ext_inst_import("OpenCL.std"); +fn emit_opencl_import(builder: &mut dr::Builder) -> spirv::Word { + builder.ext_inst_import("OpenCL.std") } fn emit_memory_model(builder: &mut dr::Builder) { @@ -146,6 +146,7 @@ fn emit_memory_model(builder: &mut dr::Builder) { fn emit_function<'a>( builder: &mut dr::Builder, map: &mut TypeWordMap, + opencl_id: spirv::Word, f: ast::Function<'a>, ) -> Result { let func_type = get_function_type(builder, map, &f.args); @@ -158,7 +159,7 @@ fn emit_function<'a>( let id_offset = builder.reserve_ids(unique_ids); emit_function_args(builder, id_offset, map, &f.args); apply_id_offset(&mut func_body, id_offset); - emit_function_body_ops(builder, map, &func_body)?; + emit_function_body_ops(builder, map, opencl_id, &func_body)?; builder.end_function()?; Ok(func_id) } @@ -265,7 +266,9 @@ fn insert_mem_ssa_statements( match s { Statement::Instruction(inst) => match inst { Instruction::Ld( - ld @ ast::LdData { + ld + @ + ast::LdData { state_space: ast::LdStateSpace::Param, .. }, @@ -638,6 +641,7 @@ fn collect_label_ids<'a>( fn emit_function_body_ops( builder: &mut dr::Builder, map: &mut TypeWordMap, + opencl: spirv::Word, func: &[ExpandedStatement], ) -> Result<(), dr::Error> { for s in func { @@ -658,7 +662,36 @@ fn emit_function_body_ops( } builder.variable(type_id, Some(*id), spirv::StorageClass::Function, None); } - Statement::Constant(_) => todo!(), + Statement::Constant(cnst) => { + let typ_id = map.get_or_add_scalar(builder, cnst.typ); + match cnst.typ { + ast::ScalarType::B8 | ast::ScalarType::U8 => { + builder.constant_u32(typ_id, Some(cnst.dst), cnst.value as u8 as u32); + } + ast::ScalarType::B16 | ast::ScalarType::U16 => { + builder.constant_u32(typ_id, Some(cnst.dst), cnst.value as u16 as u32); + } + ast::ScalarType::B32 | ast::ScalarType::U32 => { + builder.constant_u32(typ_id, Some(cnst.dst), cnst.value as u32); + } + ast::ScalarType::B64 | ast::ScalarType::U64 => { + builder.constant_u64(typ_id, Some(cnst.dst), cnst.value as u64); + } + ast::ScalarType::S8 => { + builder.constant_u32(typ_id, Some(cnst.dst), cnst.value as i8 as u32); + } + ast::ScalarType::S16 => { + builder.constant_u32(typ_id, Some(cnst.dst), cnst.value as i16 as u32); + } + ast::ScalarType::S32 => { + builder.constant_u32(typ_id, Some(cnst.dst), cnst.value as i32 as u32); + } + ast::ScalarType::S64 => { + builder.constant_u64(typ_id, Some(cnst.dst), cnst.value as i64 as u64); + } + _ => unreachable!(), + } + } Statement::Converison(cv) => emit_implicit_conversion(builder, map, cv)?, Statement::Conditional(bra) => { builder.branch_conditional(bra.predicate, bra.if_true, bra.if_false, [])?; @@ -700,17 +733,14 @@ fn emit_function_body_ops( } Instruction::Mul(mul, arg) => match mul.desc { ast::MulDescriptor::Int(ref ctr) => { - emit_mul_int(builder, map, mul.typ, ctr, arg) + emit_mul_int(builder, map, opencl, mul.typ, ctr, arg)?; } ast::MulDescriptor::Float(_) => todo!(), }, _ => todo!(), }, Statement::LoadVar(arg, typ) => { - let type_id = map.get_or_add( - builder, - SpirvType::from(*typ), - ); + let type_id = map.get_or_add(builder, SpirvType::from(*typ)); builder.load(type_id, Some(arg.dst), arg.src, None, [])?; } Statement::StoreVar(arg, typ) => { @@ -722,14 +752,36 @@ fn emit_function_body_ops( } fn emit_mul_int( - _builder: &mut dr::Builder, - _map: &mut TypeWordMap, - _typ: ast::Type, - _ctr: &ast::MulIntControl, - _arg: &Arg3, -) { - //let inst_type = map.get_or_add(builder, SpirvType::from(typ)); - //builder.i_mul(inst_type, Some(arg.dst), Some(arg.src1), Some(arg.src2)); + builder: &mut dr::Builder, + map: &mut TypeWordMap, + opencl: spirv::Word, + typ: ast::Type, + ctr: &ast::MulIntControl, + arg: &Arg3, +) -> Result<(), dr::Error> { + let inst_type = map.get_or_add(builder, SpirvType::from(typ)); + match ctr { + ast::MulIntControl::Low => { + builder.i_mul(inst_type, Some(arg.dst), arg.src1, arg.src2)?; + } + ast::MulIntControl::High => { + let ocl_mul_hi = match typ.try_as_scalar().unwrap().kind() { + ScalarKind::Signed => spirv::CLOp::s_mul_hi, + ScalarKind::Unsigned => spirv::CLOp::u_mul_hi, + ScalarKind::Float => unreachable!(), + ScalarKind::Byte => unreachable!(), + }; + builder.ext_inst( + inst_type, + Some(arg.dst), + 1, + ocl_mul_hi as spirv::Word, + [arg.src1, arg.src2], + )?; + } + ast::MulIntControl::Wide => todo!(), + } + Ok(()) } fn emit_implicit_conversion( diff --git a/spirv_tools-sys/README b/spirv_tools-sys/README index 5865dc6..3152164 100644 --- a/spirv_tools-sys/README +++ b/spirv_tools-sys/README @@ -1 +1 @@ -bindgen --whitelist-type="spv.*" --whitelist-function="spv.*" --size_t-is-usize --default-enum-style=rust ext/SPIRV-Tools/include/spirv-tools/libspirv.h -o lib.rs \ No newline at end of file +bindgen --whitelist-type="spv.*" --whitelist-function="spv.*" --size_t-is-usize --default-enum-style=rust --bitfield-enum="spv_text_to_binary_options_t|spv_binary_to_text_options_t" ../ext/SPIRV-Tools/include/spirv-tools/libspirv.h -o src/spirv_tools.rs \ No newline at end of file diff --git a/spirv_tools-sys/src/spirv_tools.rs b/spirv_tools-sys/src/spirv_tools.rs index 44b86f4..fe9640b 100644 --- a/spirv_tools-sys/src/spirv_tools.rs +++ b/spirv_tools-sys/src/spirv_tools.rs @@ -1,889 +1,972 @@ -/* automatically generated by rust-bindgen 0.54.1 */ - -pub type __uint16_t = ::std::os::raw::c_ushort; -pub type __uint32_t = ::std::os::raw::c_uint; -#[repr(i32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_result_t { - SPV_SUCCESS = 0, - SPV_UNSUPPORTED = 1, - SPV_END_OF_STREAM = 2, - SPV_WARNING = 3, - SPV_FAILED_MATCH = 4, - SPV_REQUESTED_TERMINATION = 5, - SPV_ERROR_INTERNAL = -1, - SPV_ERROR_OUT_OF_MEMORY = -2, - SPV_ERROR_INVALID_POINTER = -3, - SPV_ERROR_INVALID_BINARY = -4, - SPV_ERROR_INVALID_TEXT = -5, - SPV_ERROR_INVALID_TABLE = -6, - SPV_ERROR_INVALID_VALUE = -7, - SPV_ERROR_INVALID_DIAGNOSTIC = -8, - SPV_ERROR_INVALID_LOOKUP = -9, - SPV_ERROR_INVALID_ID = -10, - SPV_ERROR_INVALID_CFG = -11, - SPV_ERROR_INVALID_LAYOUT = -12, - SPV_ERROR_INVALID_CAPABILITY = -13, - SPV_ERROR_INVALID_DATA = -14, - SPV_ERROR_MISSING_EXTENSION = -15, - SPV_ERROR_WRONG_VERSION = -16, - _spv_result_t = 2147483647, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_message_level_t { - SPV_MSG_FATAL = 0, - SPV_MSG_INTERNAL_ERROR = 1, - SPV_MSG_ERROR = 2, - SPV_MSG_WARNING = 3, - SPV_MSG_INFO = 4, - SPV_MSG_DEBUG = 5, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_endianness_t { - SPV_ENDIANNESS_LITTLE = 0, - SPV_ENDIANNESS_BIG = 1, - _spv_endianness_t = 2147483647, -} -impl spv_operand_type_t { - pub const SPV_OPERAND_TYPE_FIRST_OPTIONAL_TYPE: spv_operand_type_t = - spv_operand_type_t::SPV_OPERAND_TYPE_OPTIONAL_ID; -} -impl spv_operand_type_t { - pub const SPV_OPERAND_TYPE_FIRST_VARIABLE_TYPE: spv_operand_type_t = - spv_operand_type_t::SPV_OPERAND_TYPE_VARIABLE_ID; -} -impl spv_operand_type_t { - pub const SPV_OPERAND_TYPE_LAST_VARIABLE_TYPE: spv_operand_type_t = - spv_operand_type_t::SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER; -} -impl spv_operand_type_t { - pub const SPV_OPERAND_TYPE_LAST_OPTIONAL_TYPE: spv_operand_type_t = - spv_operand_type_t::SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER; -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_operand_type_t { - SPV_OPERAND_TYPE_NONE = 0, - SPV_OPERAND_TYPE_ID = 1, - SPV_OPERAND_TYPE_TYPE_ID = 2, - SPV_OPERAND_TYPE_RESULT_ID = 3, - SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID = 4, - SPV_OPERAND_TYPE_SCOPE_ID = 5, - SPV_OPERAND_TYPE_LITERAL_INTEGER = 6, - SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER = 7, - SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER = 8, - SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER = 9, - SPV_OPERAND_TYPE_LITERAL_STRING = 10, - SPV_OPERAND_TYPE_SOURCE_LANGUAGE = 11, - SPV_OPERAND_TYPE_EXECUTION_MODEL = 12, - SPV_OPERAND_TYPE_ADDRESSING_MODEL = 13, - SPV_OPERAND_TYPE_MEMORY_MODEL = 14, - SPV_OPERAND_TYPE_EXECUTION_MODE = 15, - SPV_OPERAND_TYPE_STORAGE_CLASS = 16, - SPV_OPERAND_TYPE_DIMENSIONALITY = 17, - SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE = 18, - SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE = 19, - SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT = 20, - SPV_OPERAND_TYPE_IMAGE_CHANNEL_ORDER = 21, - SPV_OPERAND_TYPE_IMAGE_CHANNEL_DATA_TYPE = 22, - SPV_OPERAND_TYPE_FP_ROUNDING_MODE = 23, - SPV_OPERAND_TYPE_LINKAGE_TYPE = 24, - SPV_OPERAND_TYPE_ACCESS_QUALIFIER = 25, - SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE = 26, - SPV_OPERAND_TYPE_DECORATION = 27, - SPV_OPERAND_TYPE_BUILT_IN = 28, - SPV_OPERAND_TYPE_GROUP_OPERATION = 29, - SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS = 30, - SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO = 31, - SPV_OPERAND_TYPE_CAPABILITY = 32, - SPV_OPERAND_TYPE_RAY_FLAGS = 33, - SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION = 34, - SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE = 35, - SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE = 36, - SPV_OPERAND_TYPE_IMAGE = 37, - SPV_OPERAND_TYPE_FP_FAST_MATH_MODE = 38, - SPV_OPERAND_TYPE_SELECTION_CONTROL = 39, - SPV_OPERAND_TYPE_LOOP_CONTROL = 40, - SPV_OPERAND_TYPE_FUNCTION_CONTROL = 41, - SPV_OPERAND_TYPE_MEMORY_ACCESS = 42, - SPV_OPERAND_TYPE_OPTIONAL_ID = 43, - SPV_OPERAND_TYPE_OPTIONAL_IMAGE = 44, - SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS = 45, - SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER = 46, - SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER = 47, - SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER = 48, - SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING = 49, - SPV_OPERAND_TYPE_OPTIONAL_ACCESS_QUALIFIER = 50, - SPV_OPERAND_TYPE_OPTIONAL_CIV = 51, - SPV_OPERAND_TYPE_VARIABLE_ID = 52, - SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER = 53, - SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID = 54, - SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER = 55, - SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS = 56, - SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING = 57, - SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE = 58, - SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER = 59, - SPV_OPERAND_TYPE_DEBUG_OPERATION = 60, - SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS = 61, - SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING = 62, - SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE = 63, - SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER = 64, - SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION = 65, - SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY = 66, - SPV_OPERAND_TYPE_NUM_OPERAND_TYPES = 67, - _spv_operand_type_t = 2147483647, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_ext_inst_type_t { - SPV_EXT_INST_TYPE_NONE = 0, - SPV_EXT_INST_TYPE_GLSL_STD_450 = 1, - SPV_EXT_INST_TYPE_OPENCL_STD = 2, - SPV_EXT_INST_TYPE_SPV_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER = 3, - SPV_EXT_INST_TYPE_SPV_AMD_SHADER_TRINARY_MINMAX = 4, - SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER = 5, - SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT = 6, - SPV_EXT_INST_TYPE_DEBUGINFO = 7, - SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 = 8, - SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN = 9, - _spv_ext_inst_type_t = 2147483647, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_number_kind_t { - SPV_NUMBER_NONE = 0, - SPV_NUMBER_UNSIGNED_INT = 1, - SPV_NUMBER_SIGNED_INT = 2, - SPV_NUMBER_FLOATING = 3, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_text_to_binary_options_t { - SPV_TEXT_TO_BINARY_OPTION_NONE = 1, - SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS = 2, - _spv_text_to_binary_options_t = 2147483647, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_binary_to_text_options_t { - SPV_BINARY_TO_TEXT_OPTION_NONE = 1, - SPV_BINARY_TO_TEXT_OPTION_PRINT = 2, - SPV_BINARY_TO_TEXT_OPTION_COLOR = 4, - SPV_BINARY_TO_TEXT_OPTION_INDENT = 8, - SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET = 16, - SPV_BINARY_TO_TEXT_OPTION_NO_HEADER = 32, - SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES = 64, - _spv_binary_to_text_options_t = 2147483647, -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_parsed_operand_t { - pub offset: u16, - pub num_words: u16, - pub type_: spv_operand_type_t, - pub number_kind: spv_number_kind_t, - pub number_bit_width: u32, -} -#[test] -fn bindgen_test_layout_spv_parsed_operand_t() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(spv_parsed_operand_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(spv_parsed_operand_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_operand_t), - "::", - stringify!(offset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).num_words as *const _ as usize }, - 2usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_operand_t), - "::", - stringify!(num_words) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, - 4usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_operand_t), - "::", - stringify!(type_) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).number_kind as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_operand_t), - "::", - stringify!(number_kind) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).number_bit_width as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_operand_t), - "::", - stringify!(number_bit_width) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_parsed_instruction_t { - pub words: *const u32, - pub num_words: u16, - pub opcode: u16, - pub ext_inst_type: spv_ext_inst_type_t, - pub type_id: u32, - pub result_id: u32, - pub operands: *const spv_parsed_operand_t, - pub num_operands: u16, -} -#[test] -fn bindgen_test_layout_spv_parsed_instruction_t() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(spv_parsed_instruction_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(spv_parsed_instruction_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).words as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(words) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).num_words as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(num_words) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).opcode as *const _ as usize }, - 10usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(opcode) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).ext_inst_type as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(ext_inst_type) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).type_id as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(type_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).result_id as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(result_id) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).operands as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(operands) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).num_operands as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(spv_parsed_instruction_t), - "::", - stringify!(num_operands) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_const_binary_t { - pub code: *const u32, - pub wordCount: usize, -} -#[test] -fn bindgen_test_layout_spv_const_binary_t() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(spv_const_binary_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(spv_const_binary_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_const_binary_t), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).wordCount as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(spv_const_binary_t), - "::", - stringify!(wordCount) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_binary_t { - pub code: *mut u32, - pub wordCount: usize, -} -#[test] -fn bindgen_test_layout_spv_binary_t() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(spv_binary_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(spv_binary_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_binary_t), - "::", - stringify!(code) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).wordCount as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(spv_binary_t), - "::", - stringify!(wordCount) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_text_t { - pub str_: *const ::std::os::raw::c_char, - pub length: usize, -} -#[test] -fn bindgen_test_layout_spv_text_t() { - assert_eq!( - ::std::mem::size_of::(), - 16usize, - concat!("Size of: ", stringify!(spv_text_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(spv_text_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).str_ as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_text_t), - "::", - stringify!(str_) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(spv_text_t), - "::", - stringify!(length) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_position_t { - pub line: usize, - pub column: usize, - pub index: usize, -} -#[test] -fn bindgen_test_layout_spv_position_t() { - assert_eq!( - ::std::mem::size_of::(), - 24usize, - concat!("Size of: ", stringify!(spv_position_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(spv_position_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).line as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_position_t), - "::", - stringify!(line) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).column as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(spv_position_t), - "::", - stringify!(column) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, - 16usize, - concat!( - "Offset of field: ", - stringify!(spv_position_t), - "::", - stringify!(index) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_diagnostic_t { - pub position: spv_position_t, - pub error: *mut ::std::os::raw::c_char, - pub isTextSource: bool, -} -#[test] -fn bindgen_test_layout_spv_diagnostic_t() { - assert_eq!( - ::std::mem::size_of::(), - 40usize, - concat!("Size of: ", stringify!(spv_diagnostic_t)) - ); - assert_eq!( - ::std::mem::align_of::(), - 8usize, - concat!("Alignment of ", stringify!(spv_diagnostic_t)) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).position as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(spv_diagnostic_t), - "::", - stringify!(position) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).error as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(spv_diagnostic_t), - "::", - stringify!(error) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).isTextSource as *const _ as usize }, - 32usize, - concat!( - "Offset of field: ", - stringify!(spv_diagnostic_t), - "::", - stringify!(isTextSource) - ) - ); -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_context_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_validator_options_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_optimizer_options_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_reducer_options_t { - _unused: [u8; 0], -} -#[repr(C)] -#[derive(Debug, Copy, Clone)] -pub struct spv_fuzzer_options_t { - _unused: [u8; 0], -} -pub type spv_const_binary = *mut spv_const_binary_t; -pub type spv_binary = *mut spv_binary_t; -pub type spv_text = *mut spv_text_t; -pub type spv_position = *mut spv_position_t; -pub type spv_diagnostic = *mut spv_diagnostic_t; -pub type spv_const_context = *const spv_context_t; -pub type spv_context = *mut spv_context_t; -pub type spv_validator_options = *mut spv_validator_options_t; -pub type spv_const_validator_options = *const spv_validator_options_t; -pub type spv_optimizer_options = *mut spv_optimizer_options_t; -pub type spv_const_optimizer_options = *const spv_optimizer_options_t; -pub type spv_reducer_options = *mut spv_reducer_options_t; -pub type spv_const_reducer_options = *const spv_reducer_options_t; -pub type spv_fuzzer_options = *mut spv_fuzzer_options_t; -pub type spv_const_fuzzer_options = *const spv_fuzzer_options_t; -extern "C" { - pub fn spvSoftwareVersionString() -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn spvSoftwareVersionDetailsString() -> *const ::std::os::raw::c_char; -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_target_env { - SPV_ENV_UNIVERSAL_1_0 = 0, - SPV_ENV_VULKAN_1_0 = 1, - SPV_ENV_UNIVERSAL_1_1 = 2, - SPV_ENV_OPENCL_2_1 = 3, - SPV_ENV_OPENCL_2_2 = 4, - SPV_ENV_OPENGL_4_0 = 5, - SPV_ENV_OPENGL_4_1 = 6, - SPV_ENV_OPENGL_4_2 = 7, - SPV_ENV_OPENGL_4_3 = 8, - SPV_ENV_OPENGL_4_5 = 9, - SPV_ENV_UNIVERSAL_1_2 = 10, - SPV_ENV_OPENCL_1_2 = 11, - SPV_ENV_OPENCL_EMBEDDED_1_2 = 12, - SPV_ENV_OPENCL_2_0 = 13, - SPV_ENV_OPENCL_EMBEDDED_2_0 = 14, - SPV_ENV_OPENCL_EMBEDDED_2_1 = 15, - SPV_ENV_OPENCL_EMBEDDED_2_2 = 16, - SPV_ENV_UNIVERSAL_1_3 = 17, - SPV_ENV_VULKAN_1_1 = 18, - SPV_ENV_WEBGPU_0 = 19, - SPV_ENV_UNIVERSAL_1_4 = 20, - SPV_ENV_VULKAN_1_1_SPIRV_1_4 = 21, - SPV_ENV_UNIVERSAL_1_5 = 22, - SPV_ENV_VULKAN_1_2 = 23, -} -#[repr(u32)] -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum spv_validator_limit { - spv_validator_limit_max_struct_members = 0, - spv_validator_limit_max_struct_depth = 1, - spv_validator_limit_max_local_variables = 2, - spv_validator_limit_max_global_variables = 3, - spv_validator_limit_max_switch_branches = 4, - spv_validator_limit_max_function_args = 5, - spv_validator_limit_max_control_flow_nesting_depth = 6, - spv_validator_limit_max_access_chain_indexes = 7, - spv_validator_limit_max_id_bound = 8, -} -extern "C" { - pub fn spvTargetEnvDescription(env: spv_target_env) -> *const ::std::os::raw::c_char; -} -extern "C" { - pub fn spvParseTargetEnv(s: *const ::std::os::raw::c_char, env: *mut spv_target_env) -> bool; -} -extern "C" { - pub fn spvParseVulkanEnv(vulkan_ver: u32, spirv_ver: u32, env: *mut spv_target_env) -> bool; -} -extern "C" { - pub fn spvContextCreate(env: spv_target_env) -> spv_context; -} -extern "C" { - pub fn spvContextDestroy(context: spv_context); -} -extern "C" { - pub fn spvValidatorOptionsCreate() -> spv_validator_options; -} -extern "C" { - pub fn spvValidatorOptionsDestroy(options: spv_validator_options); -} -extern "C" { - pub fn spvValidatorOptionsSetUniversalLimit( - options: spv_validator_options, - limit_type: spv_validator_limit, - limit: u32, - ); -} -extern "C" { - pub fn spvValidatorOptionsSetRelaxStoreStruct(options: spv_validator_options, val: bool); -} -extern "C" { - pub fn spvValidatorOptionsSetRelaxLogicalPointer(options: spv_validator_options, val: bool); -} -extern "C" { - pub fn spvValidatorOptionsSetBeforeHlslLegalization(options: spv_validator_options, val: bool); -} -extern "C" { - pub fn spvValidatorOptionsSetRelaxBlockLayout(options: spv_validator_options, val: bool); -} -extern "C" { - pub fn spvValidatorOptionsSetUniformBufferStandardLayout( - options: spv_validator_options, - val: bool, - ); -} -extern "C" { - pub fn spvValidatorOptionsSetScalarBlockLayout(options: spv_validator_options, val: bool); -} -extern "C" { - pub fn spvValidatorOptionsSetSkipBlockLayout(options: spv_validator_options, val: bool); -} -extern "C" { - pub fn spvOptimizerOptionsCreate() -> spv_optimizer_options; -} -extern "C" { - pub fn spvOptimizerOptionsDestroy(options: spv_optimizer_options); -} -extern "C" { - pub fn spvOptimizerOptionsSetRunValidator(options: spv_optimizer_options, val: bool); -} -extern "C" { - pub fn spvOptimizerOptionsSetValidatorOptions( - options: spv_optimizer_options, - val: spv_validator_options, - ); -} -extern "C" { - pub fn spvOptimizerOptionsSetMaxIdBound(options: spv_optimizer_options, val: u32); -} -extern "C" { - pub fn spvOptimizerOptionsSetPreserveBindings(options: spv_optimizer_options, val: bool); -} -extern "C" { - pub fn spvOptimizerOptionsSetPreserveSpecConstants(options: spv_optimizer_options, val: bool); -} -extern "C" { - pub fn spvReducerOptionsCreate() -> spv_reducer_options; -} -extern "C" { - pub fn spvReducerOptionsDestroy(options: spv_reducer_options); -} -extern "C" { - pub fn spvReducerOptionsSetStepLimit(options: spv_reducer_options, step_limit: u32); -} -extern "C" { - pub fn spvReducerOptionsSetFailOnValidationError( - options: spv_reducer_options, - fail_on_validation_error: bool, - ); -} -extern "C" { - pub fn spvFuzzerOptionsCreate() -> spv_fuzzer_options; -} -extern "C" { - pub fn spvFuzzerOptionsDestroy(options: spv_fuzzer_options); -} -extern "C" { - pub fn spvFuzzerOptionsEnableReplayValidation(options: spv_fuzzer_options); -} -extern "C" { - pub fn spvFuzzerOptionsSetRandomSeed(options: spv_fuzzer_options, seed: u32); -} -extern "C" { - pub fn spvFuzzerOptionsSetShrinkerStepLimit( - options: spv_fuzzer_options, - shrinker_step_limit: u32, - ); -} -extern "C" { - pub fn spvFuzzerOptionsEnableFuzzerPassValidation(options: spv_fuzzer_options); -} -extern "C" { - pub fn spvTextToBinary( - context: spv_const_context, - text: *const ::std::os::raw::c_char, - length: usize, - binary: *mut spv_binary, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} -extern "C" { - pub fn spvTextToBinaryWithOptions( - context: spv_const_context, - text: *const ::std::os::raw::c_char, - length: usize, - options: u32, - binary: *mut spv_binary, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} -extern "C" { - pub fn spvTextDestroy(text: spv_text); -} -extern "C" { - pub fn spvBinaryToText( - context: spv_const_context, - binary: *const u32, - word_count: usize, - options: u32, - text: *mut spv_text, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} -extern "C" { - pub fn spvBinaryDestroy(binary: spv_binary); -} -extern "C" { - pub fn spvValidate( - context: spv_const_context, - binary: spv_const_binary, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} -extern "C" { - pub fn spvValidateWithOptions( - context: spv_const_context, - options: spv_const_validator_options, - binary: spv_const_binary, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} -extern "C" { - pub fn spvValidateBinary( - context: spv_const_context, - words: *const u32, - num_words: usize, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} -extern "C" { - pub fn spvDiagnosticCreate( - position: spv_position, - message: *const ::std::os::raw::c_char, - ) -> spv_diagnostic; -} -extern "C" { - pub fn spvDiagnosticDestroy(diagnostic: spv_diagnostic); -} -extern "C" { - pub fn spvDiagnosticPrint(diagnostic: spv_diagnostic) -> spv_result_t; -} -extern "C" { - pub fn spvOpcodeString(opcode: u32) -> *const ::std::os::raw::c_char; -} -pub type spv_parsed_header_fn_t = ::std::option::Option< - unsafe extern "C" fn( - user_data: *mut ::std::os::raw::c_void, - endian: spv_endianness_t, - magic: u32, - version: u32, - generator: u32, - id_bound: u32, - reserved: u32, - ) -> spv_result_t, ->; -pub type spv_parsed_instruction_fn_t = ::std::option::Option< - unsafe extern "C" fn( - user_data: *mut ::std::os::raw::c_void, - parsed_instruction: *const spv_parsed_instruction_t, - ) -> spv_result_t, ->; -extern "C" { - pub fn spvBinaryParse( - context: spv_const_context, - user_data: *mut ::std::os::raw::c_void, - words: *const u32, - num_words: usize, - parse_header: spv_parsed_header_fn_t, - parse_instruction: spv_parsed_instruction_fn_t, - diagnostic: *mut spv_diagnostic, - ) -> spv_result_t; -} +/* automatically generated by rust-bindgen 0.54.1 */ + +pub type __uint16_t = ::std::os::raw::c_ushort; +pub type __uint32_t = ::std::os::raw::c_uint; +#[repr(i32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_result_t { + SPV_SUCCESS = 0, + SPV_UNSUPPORTED = 1, + SPV_END_OF_STREAM = 2, + SPV_WARNING = 3, + SPV_FAILED_MATCH = 4, + SPV_REQUESTED_TERMINATION = 5, + SPV_ERROR_INTERNAL = -1, + SPV_ERROR_OUT_OF_MEMORY = -2, + SPV_ERROR_INVALID_POINTER = -3, + SPV_ERROR_INVALID_BINARY = -4, + SPV_ERROR_INVALID_TEXT = -5, + SPV_ERROR_INVALID_TABLE = -6, + SPV_ERROR_INVALID_VALUE = -7, + SPV_ERROR_INVALID_DIAGNOSTIC = -8, + SPV_ERROR_INVALID_LOOKUP = -9, + SPV_ERROR_INVALID_ID = -10, + SPV_ERROR_INVALID_CFG = -11, + SPV_ERROR_INVALID_LAYOUT = -12, + SPV_ERROR_INVALID_CAPABILITY = -13, + SPV_ERROR_INVALID_DATA = -14, + SPV_ERROR_MISSING_EXTENSION = -15, + SPV_ERROR_WRONG_VERSION = -16, + _spv_result_t = 2147483647, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_message_level_t { + SPV_MSG_FATAL = 0, + SPV_MSG_INTERNAL_ERROR = 1, + SPV_MSG_ERROR = 2, + SPV_MSG_WARNING = 3, + SPV_MSG_INFO = 4, + SPV_MSG_DEBUG = 5, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_endianness_t { + SPV_ENDIANNESS_LITTLE = 0, + SPV_ENDIANNESS_BIG = 1, + _spv_endianness_t = 2147483647, +} +impl spv_operand_type_t { + pub const SPV_OPERAND_TYPE_FIRST_OPTIONAL_TYPE: spv_operand_type_t = + spv_operand_type_t::SPV_OPERAND_TYPE_OPTIONAL_ID; +} +impl spv_operand_type_t { + pub const SPV_OPERAND_TYPE_FIRST_VARIABLE_TYPE: spv_operand_type_t = + spv_operand_type_t::SPV_OPERAND_TYPE_VARIABLE_ID; +} +impl spv_operand_type_t { + pub const SPV_OPERAND_TYPE_LAST_VARIABLE_TYPE: spv_operand_type_t = + spv_operand_type_t::SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER; +} +impl spv_operand_type_t { + pub const SPV_OPERAND_TYPE_LAST_OPTIONAL_TYPE: spv_operand_type_t = + spv_operand_type_t::SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_operand_type_t { + SPV_OPERAND_TYPE_NONE = 0, + SPV_OPERAND_TYPE_ID = 1, + SPV_OPERAND_TYPE_TYPE_ID = 2, + SPV_OPERAND_TYPE_RESULT_ID = 3, + SPV_OPERAND_TYPE_MEMORY_SEMANTICS_ID = 4, + SPV_OPERAND_TYPE_SCOPE_ID = 5, + SPV_OPERAND_TYPE_LITERAL_INTEGER = 6, + SPV_OPERAND_TYPE_EXTENSION_INSTRUCTION_NUMBER = 7, + SPV_OPERAND_TYPE_SPEC_CONSTANT_OP_NUMBER = 8, + SPV_OPERAND_TYPE_TYPED_LITERAL_NUMBER = 9, + SPV_OPERAND_TYPE_LITERAL_STRING = 10, + SPV_OPERAND_TYPE_SOURCE_LANGUAGE = 11, + SPV_OPERAND_TYPE_EXECUTION_MODEL = 12, + SPV_OPERAND_TYPE_ADDRESSING_MODEL = 13, + SPV_OPERAND_TYPE_MEMORY_MODEL = 14, + SPV_OPERAND_TYPE_EXECUTION_MODE = 15, + SPV_OPERAND_TYPE_STORAGE_CLASS = 16, + SPV_OPERAND_TYPE_DIMENSIONALITY = 17, + SPV_OPERAND_TYPE_SAMPLER_ADDRESSING_MODE = 18, + SPV_OPERAND_TYPE_SAMPLER_FILTER_MODE = 19, + SPV_OPERAND_TYPE_SAMPLER_IMAGE_FORMAT = 20, + SPV_OPERAND_TYPE_IMAGE_CHANNEL_ORDER = 21, + SPV_OPERAND_TYPE_IMAGE_CHANNEL_DATA_TYPE = 22, + SPV_OPERAND_TYPE_FP_ROUNDING_MODE = 23, + SPV_OPERAND_TYPE_LINKAGE_TYPE = 24, + SPV_OPERAND_TYPE_ACCESS_QUALIFIER = 25, + SPV_OPERAND_TYPE_FUNCTION_PARAMETER_ATTRIBUTE = 26, + SPV_OPERAND_TYPE_DECORATION = 27, + SPV_OPERAND_TYPE_BUILT_IN = 28, + SPV_OPERAND_TYPE_GROUP_OPERATION = 29, + SPV_OPERAND_TYPE_KERNEL_ENQ_FLAGS = 30, + SPV_OPERAND_TYPE_KERNEL_PROFILING_INFO = 31, + SPV_OPERAND_TYPE_CAPABILITY = 32, + SPV_OPERAND_TYPE_RAY_FLAGS = 33, + SPV_OPERAND_TYPE_RAY_QUERY_INTERSECTION = 34, + SPV_OPERAND_TYPE_RAY_QUERY_COMMITTED_INTERSECTION_TYPE = 35, + SPV_OPERAND_TYPE_RAY_QUERY_CANDIDATE_INTERSECTION_TYPE = 36, + SPV_OPERAND_TYPE_IMAGE = 37, + SPV_OPERAND_TYPE_FP_FAST_MATH_MODE = 38, + SPV_OPERAND_TYPE_SELECTION_CONTROL = 39, + SPV_OPERAND_TYPE_LOOP_CONTROL = 40, + SPV_OPERAND_TYPE_FUNCTION_CONTROL = 41, + SPV_OPERAND_TYPE_MEMORY_ACCESS = 42, + SPV_OPERAND_TYPE_OPTIONAL_ID = 43, + SPV_OPERAND_TYPE_OPTIONAL_IMAGE = 44, + SPV_OPERAND_TYPE_OPTIONAL_MEMORY_ACCESS = 45, + SPV_OPERAND_TYPE_OPTIONAL_LITERAL_INTEGER = 46, + SPV_OPERAND_TYPE_OPTIONAL_LITERAL_NUMBER = 47, + SPV_OPERAND_TYPE_OPTIONAL_TYPED_LITERAL_INTEGER = 48, + SPV_OPERAND_TYPE_OPTIONAL_LITERAL_STRING = 49, + SPV_OPERAND_TYPE_OPTIONAL_ACCESS_QUALIFIER = 50, + SPV_OPERAND_TYPE_OPTIONAL_CIV = 51, + SPV_OPERAND_TYPE_VARIABLE_ID = 52, + SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER = 53, + SPV_OPERAND_TYPE_VARIABLE_LITERAL_INTEGER_ID = 54, + SPV_OPERAND_TYPE_VARIABLE_ID_LITERAL_INTEGER = 55, + SPV_OPERAND_TYPE_DEBUG_INFO_FLAGS = 56, + SPV_OPERAND_TYPE_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING = 57, + SPV_OPERAND_TYPE_DEBUG_COMPOSITE_TYPE = 58, + SPV_OPERAND_TYPE_DEBUG_TYPE_QUALIFIER = 59, + SPV_OPERAND_TYPE_DEBUG_OPERATION = 60, + SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_INFO_FLAGS = 61, + SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_BASE_TYPE_ATTRIBUTE_ENCODING = 62, + SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_COMPOSITE_TYPE = 63, + SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_TYPE_QUALIFIER = 64, + SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_OPERATION = 65, + SPV_OPERAND_TYPE_CLDEBUG100_DEBUG_IMPORTED_ENTITY = 66, + SPV_OPERAND_TYPE_NUM_OPERAND_TYPES = 67, + _spv_operand_type_t = 2147483647, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_ext_inst_type_t { + SPV_EXT_INST_TYPE_NONE = 0, + SPV_EXT_INST_TYPE_GLSL_STD_450 = 1, + SPV_EXT_INST_TYPE_OPENCL_STD = 2, + SPV_EXT_INST_TYPE_SPV_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER = 3, + SPV_EXT_INST_TYPE_SPV_AMD_SHADER_TRINARY_MINMAX = 4, + SPV_EXT_INST_TYPE_SPV_AMD_GCN_SHADER = 5, + SPV_EXT_INST_TYPE_SPV_AMD_SHADER_BALLOT = 6, + SPV_EXT_INST_TYPE_DEBUGINFO = 7, + SPV_EXT_INST_TYPE_OPENCL_DEBUGINFO_100 = 8, + SPV_EXT_INST_TYPE_NONSEMANTIC_UNKNOWN = 9, + _spv_ext_inst_type_t = 2147483647, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_number_kind_t { + SPV_NUMBER_NONE = 0, + SPV_NUMBER_UNSIGNED_INT = 1, + SPV_NUMBER_SIGNED_INT = 2, + SPV_NUMBER_FLOATING = 3, +} +impl spv_text_to_binary_options_t { + pub const SPV_TEXT_TO_BINARY_OPTION_NONE: spv_text_to_binary_options_t = + spv_text_to_binary_options_t(1); +} +impl spv_text_to_binary_options_t { + pub const SPV_TEXT_TO_BINARY_OPTION_PRESERVE_NUMERIC_IDS: spv_text_to_binary_options_t = + spv_text_to_binary_options_t(2); +} +impl spv_text_to_binary_options_t { + pub const _spv_text_to_binary_options_t: spv_text_to_binary_options_t = + spv_text_to_binary_options_t(2147483647); +} +impl ::std::ops::BitOr for spv_text_to_binary_options_t { + type Output = Self; + #[inline] + fn bitor(self, other: Self) -> Self { + spv_text_to_binary_options_t(self.0 | other.0) + } +} +impl ::std::ops::BitOrAssign for spv_text_to_binary_options_t { + #[inline] + fn bitor_assign(&mut self, rhs: spv_text_to_binary_options_t) { + self.0 |= rhs.0; + } +} +impl ::std::ops::BitAnd for spv_text_to_binary_options_t { + type Output = Self; + #[inline] + fn bitand(self, other: Self) -> Self { + spv_text_to_binary_options_t(self.0 & other.0) + } +} +impl ::std::ops::BitAndAssign for spv_text_to_binary_options_t { + #[inline] + fn bitand_assign(&mut self, rhs: spv_text_to_binary_options_t) { + self.0 &= rhs.0; + } +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct spv_text_to_binary_options_t(pub u32); +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_NONE: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(1); +} +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_PRINT: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(2); +} +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_COLOR: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(4); +} +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_INDENT: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(8); +} +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_SHOW_BYTE_OFFSET: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(16); +} +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_NO_HEADER: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(32); +} +impl spv_binary_to_text_options_t { + pub const SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(64); +} +impl spv_binary_to_text_options_t { + pub const _spv_binary_to_text_options_t: spv_binary_to_text_options_t = + spv_binary_to_text_options_t(2147483647); +} +impl ::std::ops::BitOr for spv_binary_to_text_options_t { + type Output = Self; + #[inline] + fn bitor(self, other: Self) -> Self { + spv_binary_to_text_options_t(self.0 | other.0) + } +} +impl ::std::ops::BitOrAssign for spv_binary_to_text_options_t { + #[inline] + fn bitor_assign(&mut self, rhs: spv_binary_to_text_options_t) { + self.0 |= rhs.0; + } +} +impl ::std::ops::BitAnd for spv_binary_to_text_options_t { + type Output = Self; + #[inline] + fn bitand(self, other: Self) -> Self { + spv_binary_to_text_options_t(self.0 & other.0) + } +} +impl ::std::ops::BitAndAssign for spv_binary_to_text_options_t { + #[inline] + fn bitand_assign(&mut self, rhs: spv_binary_to_text_options_t) { + self.0 &= rhs.0; + } +} +#[repr(transparent)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct spv_binary_to_text_options_t(pub u32); +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_parsed_operand_t { + pub offset: u16, + pub num_words: u16, + pub type_: spv_operand_type_t, + pub number_kind: spv_number_kind_t, + pub number_bit_width: u32, +} +#[test] +fn bindgen_test_layout_spv_parsed_operand_t() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(spv_parsed_operand_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 4usize, + concat!("Alignment of ", stringify!(spv_parsed_operand_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).offset as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_operand_t), + "::", + stringify!(offset) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).num_words as *const _ as usize }, + 2usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_operand_t), + "::", + stringify!(num_words) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).type_ as *const _ as usize }, + 4usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_operand_t), + "::", + stringify!(type_) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).number_kind as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_operand_t), + "::", + stringify!(number_kind) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).number_bit_width as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_operand_t), + "::", + stringify!(number_bit_width) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_parsed_instruction_t { + pub words: *const u32, + pub num_words: u16, + pub opcode: u16, + pub ext_inst_type: spv_ext_inst_type_t, + pub type_id: u32, + pub result_id: u32, + pub operands: *const spv_parsed_operand_t, + pub num_operands: u16, +} +#[test] +fn bindgen_test_layout_spv_parsed_instruction_t() { + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(spv_parsed_instruction_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(spv_parsed_instruction_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).words as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(words) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).num_words as *const _ as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(num_words) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).opcode as *const _ as usize }, + 10usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(opcode) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).ext_inst_type as *const _ as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(ext_inst_type) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).type_id as *const _ as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(type_id) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).result_id as *const _ as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(result_id) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).operands as *const _ as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(operands) + ) + ); + assert_eq!( + unsafe { + &(*(::std::ptr::null::())).num_operands as *const _ as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(spv_parsed_instruction_t), + "::", + stringify!(num_operands) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_const_binary_t { + pub code: *const u32, + pub wordCount: usize, +} +#[test] +fn bindgen_test_layout_spv_const_binary_t() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(spv_const_binary_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(spv_const_binary_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_const_binary_t), + "::", + stringify!(code) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wordCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(spv_const_binary_t), + "::", + stringify!(wordCount) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_binary_t { + pub code: *mut u32, + pub wordCount: usize, +} +#[test] +fn bindgen_test_layout_spv_binary_t() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(spv_binary_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(spv_binary_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).code as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_binary_t), + "::", + stringify!(code) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).wordCount as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(spv_binary_t), + "::", + stringify!(wordCount) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_text_t { + pub str_: *const ::std::os::raw::c_char, + pub length: usize, +} +#[test] +fn bindgen_test_layout_spv_text_t() { + assert_eq!( + ::std::mem::size_of::(), + 16usize, + concat!("Size of: ", stringify!(spv_text_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(spv_text_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).str_ as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_text_t), + "::", + stringify!(str_) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).length as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(spv_text_t), + "::", + stringify!(length) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_position_t { + pub line: usize, + pub column: usize, + pub index: usize, +} +#[test] +fn bindgen_test_layout_spv_position_t() { + assert_eq!( + ::std::mem::size_of::(), + 24usize, + concat!("Size of: ", stringify!(spv_position_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(spv_position_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).line as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_position_t), + "::", + stringify!(line) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).column as *const _ as usize }, + 8usize, + concat!( + "Offset of field: ", + stringify!(spv_position_t), + "::", + stringify!(column) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).index as *const _ as usize }, + 16usize, + concat!( + "Offset of field: ", + stringify!(spv_position_t), + "::", + stringify!(index) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_diagnostic_t { + pub position: spv_position_t, + pub error: *mut ::std::os::raw::c_char, + pub isTextSource: bool, +} +#[test] +fn bindgen_test_layout_spv_diagnostic_t() { + assert_eq!( + ::std::mem::size_of::(), + 40usize, + concat!("Size of: ", stringify!(spv_diagnostic_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 8usize, + concat!("Alignment of ", stringify!(spv_diagnostic_t)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).position as *const _ as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(spv_diagnostic_t), + "::", + stringify!(position) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).error as *const _ as usize }, + 24usize, + concat!( + "Offset of field: ", + stringify!(spv_diagnostic_t), + "::", + stringify!(error) + ) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::())).isTextSource as *const _ as usize }, + 32usize, + concat!( + "Offset of field: ", + stringify!(spv_diagnostic_t), + "::", + stringify!(isTextSource) + ) + ); +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_context_t { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_validator_options_t { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_optimizer_options_t { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_reducer_options_t { + _unused: [u8; 0], +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct spv_fuzzer_options_t { + _unused: [u8; 0], +} +pub type spv_const_binary = *mut spv_const_binary_t; +pub type spv_binary = *mut spv_binary_t; +pub type spv_text = *mut spv_text_t; +pub type spv_position = *mut spv_position_t; +pub type spv_diagnostic = *mut spv_diagnostic_t; +pub type spv_const_context = *const spv_context_t; +pub type spv_context = *mut spv_context_t; +pub type spv_validator_options = *mut spv_validator_options_t; +pub type spv_const_validator_options = *const spv_validator_options_t; +pub type spv_optimizer_options = *mut spv_optimizer_options_t; +pub type spv_const_optimizer_options = *const spv_optimizer_options_t; +pub type spv_reducer_options = *mut spv_reducer_options_t; +pub type spv_const_reducer_options = *const spv_reducer_options_t; +pub type spv_fuzzer_options = *mut spv_fuzzer_options_t; +pub type spv_const_fuzzer_options = *const spv_fuzzer_options_t; +extern "C" { + pub fn spvSoftwareVersionString() -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn spvSoftwareVersionDetailsString() -> *const ::std::os::raw::c_char; +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_target_env { + SPV_ENV_UNIVERSAL_1_0 = 0, + SPV_ENV_VULKAN_1_0 = 1, + SPV_ENV_UNIVERSAL_1_1 = 2, + SPV_ENV_OPENCL_2_1 = 3, + SPV_ENV_OPENCL_2_2 = 4, + SPV_ENV_OPENGL_4_0 = 5, + SPV_ENV_OPENGL_4_1 = 6, + SPV_ENV_OPENGL_4_2 = 7, + SPV_ENV_OPENGL_4_3 = 8, + SPV_ENV_OPENGL_4_5 = 9, + SPV_ENV_UNIVERSAL_1_2 = 10, + SPV_ENV_OPENCL_1_2 = 11, + SPV_ENV_OPENCL_EMBEDDED_1_2 = 12, + SPV_ENV_OPENCL_2_0 = 13, + SPV_ENV_OPENCL_EMBEDDED_2_0 = 14, + SPV_ENV_OPENCL_EMBEDDED_2_1 = 15, + SPV_ENV_OPENCL_EMBEDDED_2_2 = 16, + SPV_ENV_UNIVERSAL_1_3 = 17, + SPV_ENV_VULKAN_1_1 = 18, + SPV_ENV_WEBGPU_0 = 19, + SPV_ENV_UNIVERSAL_1_4 = 20, + SPV_ENV_VULKAN_1_1_SPIRV_1_4 = 21, + SPV_ENV_UNIVERSAL_1_5 = 22, + SPV_ENV_VULKAN_1_2 = 23, +} +#[repr(u32)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub enum spv_validator_limit { + spv_validator_limit_max_struct_members = 0, + spv_validator_limit_max_struct_depth = 1, + spv_validator_limit_max_local_variables = 2, + spv_validator_limit_max_global_variables = 3, + spv_validator_limit_max_switch_branches = 4, + spv_validator_limit_max_function_args = 5, + spv_validator_limit_max_control_flow_nesting_depth = 6, + spv_validator_limit_max_access_chain_indexes = 7, + spv_validator_limit_max_id_bound = 8, +} +extern "C" { + pub fn spvTargetEnvDescription(env: spv_target_env) -> *const ::std::os::raw::c_char; +} +extern "C" { + pub fn spvParseTargetEnv(s: *const ::std::os::raw::c_char, env: *mut spv_target_env) -> bool; +} +extern "C" { + pub fn spvParseVulkanEnv(vulkan_ver: u32, spirv_ver: u32, env: *mut spv_target_env) -> bool; +} +extern "C" { + pub fn spvContextCreate(env: spv_target_env) -> spv_context; +} +extern "C" { + pub fn spvContextDestroy(context: spv_context); +} +extern "C" { + pub fn spvValidatorOptionsCreate() -> spv_validator_options; +} +extern "C" { + pub fn spvValidatorOptionsDestroy(options: spv_validator_options); +} +extern "C" { + pub fn spvValidatorOptionsSetUniversalLimit( + options: spv_validator_options, + limit_type: spv_validator_limit, + limit: u32, + ); +} +extern "C" { + pub fn spvValidatorOptionsSetRelaxStoreStruct(options: spv_validator_options, val: bool); +} +extern "C" { + pub fn spvValidatorOptionsSetRelaxLogicalPointer(options: spv_validator_options, val: bool); +} +extern "C" { + pub fn spvValidatorOptionsSetBeforeHlslLegalization(options: spv_validator_options, val: bool); +} +extern "C" { + pub fn spvValidatorOptionsSetRelaxBlockLayout(options: spv_validator_options, val: bool); +} +extern "C" { + pub fn spvValidatorOptionsSetUniformBufferStandardLayout( + options: spv_validator_options, + val: bool, + ); +} +extern "C" { + pub fn spvValidatorOptionsSetScalarBlockLayout(options: spv_validator_options, val: bool); +} +extern "C" { + pub fn spvValidatorOptionsSetSkipBlockLayout(options: spv_validator_options, val: bool); +} +extern "C" { + pub fn spvOptimizerOptionsCreate() -> spv_optimizer_options; +} +extern "C" { + pub fn spvOptimizerOptionsDestroy(options: spv_optimizer_options); +} +extern "C" { + pub fn spvOptimizerOptionsSetRunValidator(options: spv_optimizer_options, val: bool); +} +extern "C" { + pub fn spvOptimizerOptionsSetValidatorOptions( + options: spv_optimizer_options, + val: spv_validator_options, + ); +} +extern "C" { + pub fn spvOptimizerOptionsSetMaxIdBound(options: spv_optimizer_options, val: u32); +} +extern "C" { + pub fn spvOptimizerOptionsSetPreserveBindings(options: spv_optimizer_options, val: bool); +} +extern "C" { + pub fn spvOptimizerOptionsSetPreserveSpecConstants(options: spv_optimizer_options, val: bool); +} +extern "C" { + pub fn spvReducerOptionsCreate() -> spv_reducer_options; +} +extern "C" { + pub fn spvReducerOptionsDestroy(options: spv_reducer_options); +} +extern "C" { + pub fn spvReducerOptionsSetStepLimit(options: spv_reducer_options, step_limit: u32); +} +extern "C" { + pub fn spvReducerOptionsSetFailOnValidationError( + options: spv_reducer_options, + fail_on_validation_error: bool, + ); +} +extern "C" { + pub fn spvFuzzerOptionsCreate() -> spv_fuzzer_options; +} +extern "C" { + pub fn spvFuzzerOptionsDestroy(options: spv_fuzzer_options); +} +extern "C" { + pub fn spvFuzzerOptionsEnableReplayValidation(options: spv_fuzzer_options); +} +extern "C" { + pub fn spvFuzzerOptionsSetRandomSeed(options: spv_fuzzer_options, seed: u32); +} +extern "C" { + pub fn spvFuzzerOptionsSetShrinkerStepLimit( + options: spv_fuzzer_options, + shrinker_step_limit: u32, + ); +} +extern "C" { + pub fn spvFuzzerOptionsEnableFuzzerPassValidation(options: spv_fuzzer_options); +} +extern "C" { + pub fn spvTextToBinary( + context: spv_const_context, + text: *const ::std::os::raw::c_char, + length: usize, + binary: *mut spv_binary, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +} +extern "C" { + pub fn spvTextToBinaryWithOptions( + context: spv_const_context, + text: *const ::std::os::raw::c_char, + length: usize, + options: u32, + binary: *mut spv_binary, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +} +extern "C" { + pub fn spvTextDestroy(text: spv_text); +} +extern "C" { + pub fn spvBinaryToText( + context: spv_const_context, + binary: *const u32, + word_count: usize, + options: u32, + text: *mut spv_text, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +} +extern "C" { + pub fn spvBinaryDestroy(binary: spv_binary); +} +extern "C" { + pub fn spvValidate( + context: spv_const_context, + binary: spv_const_binary, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +} +extern "C" { + pub fn spvValidateWithOptions( + context: spv_const_context, + options: spv_const_validator_options, + binary: spv_const_binary, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +} +extern "C" { + pub fn spvValidateBinary( + context: spv_const_context, + words: *const u32, + num_words: usize, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +} +extern "C" { + pub fn spvDiagnosticCreate( + position: spv_position, + message: *const ::std::os::raw::c_char, + ) -> spv_diagnostic; +} +extern "C" { + pub fn spvDiagnosticDestroy(diagnostic: spv_diagnostic); +} +extern "C" { + pub fn spvDiagnosticPrint(diagnostic: spv_diagnostic) -> spv_result_t; +} +extern "C" { + pub fn spvOpcodeString(opcode: u32) -> *const ::std::os::raw::c_char; +} +pub type spv_parsed_header_fn_t = ::std::option::Option< + unsafe extern "C" fn( + user_data: *mut ::std::os::raw::c_void, + endian: spv_endianness_t, + magic: u32, + version: u32, + generator: u32, + id_bound: u32, + reserved: u32, + ) -> spv_result_t, +>; +pub type spv_parsed_instruction_fn_t = ::std::option::Option< + unsafe extern "C" fn( + user_data: *mut ::std::os::raw::c_void, + parsed_instruction: *const spv_parsed_instruction_t, + ) -> spv_result_t, +>; +extern "C" { + pub fn spvBinaryParse( + context: spv_const_context, + user_data: *mut ::std::os::raw::c_void, + words: *const u32, + num_words: usize, + parse_header: spv_parsed_header_fn_t, + parse_instruction: spv_parsed_instruction_fn_t, + diagnostic: *mut spv_diagnostic, + ) -> spv_result_t; +}