diff --git a/Cargo.lock b/Cargo.lock index 9f12ccb..453b6c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,9 +162,9 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -207,7 +207,7 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "spirv-to-dxil" -version = "0.2.2" +version = "0.2.4" dependencies = [ "bitflags", "bytemuck", diff --git a/spirv-to-dxil/Cargo.toml b/spirv-to-dxil/Cargo.toml index 6dab2fb..ea2d080 100644 --- a/spirv-to-dxil/Cargo.toml +++ b/spirv-to-dxil/Cargo.toml @@ -10,7 +10,7 @@ readme = "../README.md" [lib] [dependencies] -spirv-to-dxil-sys = { version = "0.2.0", path = "../spirv-to-dxil-sys" } +spirv-to-dxil-sys = { version = "0.2", path = "../spirv-to-dxil-sys" } bitflags = "1.3.2" [features] diff --git a/spirv-to-dxil/src/error.rs b/spirv-to-dxil/src/error.rs new file mode 100644 index 0000000..20974c5 --- /dev/null +++ b/spirv-to-dxil/src/error.rs @@ -0,0 +1,4 @@ +pub enum SpirvToDxilError { + CompilerError(String), + RegisterSpaceOverflow(usize) +} \ No newline at end of file diff --git a/spirv-to-dxil/src/lib.rs b/spirv-to-dxil/src/lib.rs index d1c7af4..cc5081f 100644 --- a/spirv-to-dxil/src/lib.rs +++ b/spirv-to-dxil/src/lib.rs @@ -28,6 +28,10 @@ fn spirv_to_dxil_inner( logger: &spirv_to_dxil_sys::dxil_spirv_logger, out: &mut MaybeUninit, ) -> bool { + if runtime_conf.push_constant_cbv.register_space > 31 + || runtime_conf.runtime_data_cbv.register_space > 31 { + panic!("register space can not be greater than 31") + } let num_specializations = specializations.map(|o| o.len()).unwrap_or(0) as u32; let mut specializations: Option> = specializations.map(|o| o.into_iter().map(|o| (*o).into()).collect()); @@ -158,7 +162,17 @@ mod tests { None, "main", ShaderStage::Fragment, ShaderModel::ShaderModel6_0, ValidatorVersion::None, - RuntimeConfig::default()) + RuntimeConfig { + runtime_data_cbv: ConstantBufferConfig { + register_space: 0, + base_shader_register: 0, + }, + push_constant_cbv: ConstantBufferConfig { + register_space: 128, + base_shader_register: 1, + }, + ..RuntimeConfig::default() + }) .expect("failed to compile"); }