Fix incorrect SPIR-V header bounds

This commit is contained in:
2025-12-27 02:29:38 +00:00
parent 0cb35e8bc4
commit 1c897fbfb7
3 changed files with 36 additions and 5 deletions
+2 -1
View File
@@ -17,7 +17,8 @@ pub(crate) fn compile_interval_function(
.begin_function(
types.vec2,
function_id,
spirv::FunctionControl::DONT_INLINE
//spirv::FunctionControl::DONT_INLINE
spirv::FunctionControl::INLINE
| spirv::FunctionControl::PURE
| spirv::FunctionControl::CONST,
types.interval_fn_type,
+33 -3
View File
@@ -483,6 +483,10 @@ impl SSATape {
let interval_fn_type = b.type_function(vec2, vec![vec4p, vec4p]);
let jit_string = b.string("JIT");
const POINT_FN_LOC: u32 = 1000;
const INTERVAL_FN_LOC: u32 = 2000;
const GRADIENT_FN_LOC: u32 = 3000;
let types = SpirVTypes {
glsl,
void,
@@ -498,25 +502,51 @@ impl SSATape {
jit_string,
};
// Manually fix the header bounds
let mut module = b.module();
let header = module.header.as_mut().unwrap();
header.bound = header.bound.max(POINT_FN_LOC + 1);
let mut b = rspirv::dr::Builder::new_from_module(module);
compile_point_function(
&mut b,
self,
types,
if with_module { Some(1000) } else { None },
if with_module {
Some(POINT_FN_LOC)
} else {
None
},
);
// Manually fix the header bounds
let mut module = b.module();
let header = module.header.as_mut().unwrap();
header.bound = header.bound.max(INTERVAL_FN_LOC + 1);
let mut b = rspirv::dr::Builder::new_from_module(module);
compile_interval_function(
&mut b,
self,
types,
if with_module { Some(2000) } else { None },
if with_module {
Some(INTERVAL_FN_LOC)
} else {
None
},
);
//// Manually fix the header bounds
//let mut module = b.module();
//let header = module.header.as_mut().unwrap();
//header.bound = header.bound.max(GRADIENT_FN_LOC + 1);
//let mut b = rspirv::dr::Builder::new_from_module(module);
//
//compile_gradient_function(
// &mut b,
// self,
// types,
// if with_module { Some(3000) } else { None },
// if with_module { Some(GRADIENT_FN_LOC) } else { None },
//);
let module = b.module();