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
+1 -1
View File
@@ -125,7 +125,7 @@ void main() {
} }
#if AO_ENABLE #if AO_ENABLE
hash = uvec4((v_pos.x + 1.0) * 374799253, (v_pos.y + 1.0) * 615653626, camera_uniforms.campos_and_time.w * 626228781, 713668633); hash = uvec4((v_pos.x + 1.0) * 374799253, (v_pos.y + 1.0) * 615653626, camera_uniforms.campos_and_time.w * 626228, 713668633);
#endif #endif
float depth = subpassLoad(u_depth).x; float depth = subpassLoad(u_depth).x;
+2 -1
View File
@@ -17,7 +17,8 @@ pub(crate) fn compile_interval_function(
.begin_function( .begin_function(
types.vec2, types.vec2,
function_id, function_id,
spirv::FunctionControl::DONT_INLINE //spirv::FunctionControl::DONT_INLINE
spirv::FunctionControl::INLINE
| spirv::FunctionControl::PURE | spirv::FunctionControl::PURE
| spirv::FunctionControl::CONST, | spirv::FunctionControl::CONST,
types.interval_fn_type, 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 interval_fn_type = b.type_function(vec2, vec![vec4p, vec4p]);
let jit_string = b.string("JIT"); 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 { let types = SpirVTypes {
glsl, glsl,
void, void,
@@ -498,25 +502,51 @@ impl SSATape {
jit_string, 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( compile_point_function(
&mut b, &mut b,
self, self,
types, 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( compile_interval_function(
&mut b, &mut b,
self, self,
types, 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( //compile_gradient_function(
// &mut b, // &mut b,
// self, // self,
// types, // types,
// if with_module { Some(3000) } else { None }, // if with_module { Some(GRADIENT_FN_LOC) } else { None },
//); //);
let module = b.module(); let module = b.module();