rs: make shadermodel clone/copy

This commit is contained in:
chyyran 2023-02-04 23:45:11 -05:00
parent cf2786fc97
commit db2c4d67ce
4 changed files with 23 additions and 5 deletions

6
Cargo.lock generated
View file

@ -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",

View file

@ -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]

View file

@ -0,0 +1,4 @@
pub enum SpirvToDxilError {
CompilerError(String),
RegisterSpaceOverflow(usize)
}

View file

@ -28,6 +28,10 @@ fn spirv_to_dxil_inner(
logger: &spirv_to_dxil_sys::dxil_spirv_logger,
out: &mut MaybeUninit<dxil_spirv_object>,
) -> 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<Vec<spirv_to_dxil_sys::dxil_spirv_specialization>> =
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");
}