#[allow(unused_imports)]
use rafx::RafxResult;
#[allow(unused_imports)]
use rafx::framework::{
DescriptorSetAllocator, DescriptorSetArc, DescriptorSetBindings, DescriptorSetInitializer,
DescriptorSetWriter, DescriptorSetWriterContext, DynDescriptorSet, ImageViewResource,
ResourceArc,
};
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct LightBitfieldsDataStd430 {
pub light_count: [u32; 3072], pub bitfields: [u32; 49152], }
pub type LightBitfieldsDataBuffer = LightBitfieldsDataStd430;
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct LightBitfieldsStd430 {
pub data: LightBitfieldsDataStd430, }
pub type LightBitfieldsBuffer = LightBitfieldsStd430;
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct LightBuildListsOutputStd430 {
pub data: LightBinningOutputStd430, }
pub type LightBuildListsOutputBuffer = LightBuildListsOutputStd430;
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct LightBinningOutputStd430 {
pub data_write_ptr: u32, pub pad0: u32, pub pad1: u32, pub pad2: u32, pub offsets: [ClusterMetaStd430; 3072], pub data: [u32; 1572864], }
pub type LightBinningOutputBuffer = LightBinningOutputStd430;
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct ClusterMetaStd430 {
pub count: u32, pub first_light: u32, }
pub type ClusterMetaBuffer = ClusterMetaStd430;
pub const INPUT_DATA_DESCRIPTOR_SET_INDEX: usize = 0;
pub const INPUT_DATA_DESCRIPTOR_BINDING_INDEX: usize = 0;
pub const OUTPUT_DATA_DESCRIPTOR_SET_INDEX: usize = 0;
pub const OUTPUT_DATA_DESCRIPTOR_BINDING_INDEX: usize = 1;
pub struct DescriptorSet0Args<'a> {
pub input_data: &'a LightBitfieldsBuffer,
pub output_data: &'a LightBuildListsOutputBuffer,
}
impl<'a> DescriptorSetInitializer<'a> for DescriptorSet0Args<'a> {
type Output = DescriptorSet0;
fn create_dyn_descriptor_set(
descriptor_set: DynDescriptorSet,
args: Self,
) -> Self::Output {
let mut descriptor = DescriptorSet0(descriptor_set);
descriptor.set_args(args);
descriptor
}
fn create_descriptor_set(
descriptor_set_allocator: &mut DescriptorSetAllocator,
descriptor_set: DynDescriptorSet,
args: Self,
) -> RafxResult<DescriptorSetArc> {
let mut descriptor = Self::create_dyn_descriptor_set(descriptor_set, args);
descriptor.0.flush(descriptor_set_allocator)?;
Ok(descriptor.0.descriptor_set().clone())
}
}
impl<'a> DescriptorSetWriter<'a> for DescriptorSet0Args<'a> {
fn write_to(
descriptor_set: &mut DescriptorSetWriterContext,
args: Self,
) {
descriptor_set.set_buffer_data(INPUT_DATA_DESCRIPTOR_BINDING_INDEX as u32, args.input_data);
descriptor_set.set_buffer_data(
OUTPUT_DATA_DESCRIPTOR_BINDING_INDEX as u32,
args.output_data,
);
}
}
pub struct DescriptorSet0(pub DynDescriptorSet);
impl DescriptorSet0 {
pub fn set_args_static(
descriptor_set: &mut DynDescriptorSet,
args: DescriptorSet0Args,
) {
descriptor_set.set_buffer_data(INPUT_DATA_DESCRIPTOR_BINDING_INDEX as u32, args.input_data);
descriptor_set.set_buffer_data(
OUTPUT_DATA_DESCRIPTOR_BINDING_INDEX as u32,
args.output_data,
);
}
pub fn set_args(
&mut self,
args: DescriptorSet0Args,
) {
self.set_input_data(args.input_data);
self.set_output_data(args.output_data);
}
pub fn set_input_data(
&mut self,
input_data: &LightBitfieldsBuffer,
) {
self.0
.set_buffer_data(INPUT_DATA_DESCRIPTOR_BINDING_INDEX as u32, input_data);
}
pub fn set_output_data(
&mut self,
output_data: &LightBuildListsOutputBuffer,
) {
self.0
.set_buffer_data(OUTPUT_DATA_DESCRIPTOR_BINDING_INDEX as u32, output_data);
}
pub fn flush(
&mut self,
descriptor_set_allocator: &mut DescriptorSetAllocator,
) -> RafxResult<()> {
self.0.flush(descriptor_set_allocator)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_struct_light_bitfields_data_std430() {
assert_eq!(std::mem::size_of::<LightBitfieldsDataStd430>(), 208896);
assert_eq!(std::mem::size_of::<[u32; 3072]>(), 12288);
assert_eq!(std::mem::align_of::<[u32; 3072]>(), 4);
assert_eq!(
memoffset::offset_of!(LightBitfieldsDataStd430, light_count),
0
);
assert_eq!(std::mem::size_of::<[u32; 49152]>(), 196608);
assert_eq!(std::mem::align_of::<[u32; 49152]>(), 4);
assert_eq!(
memoffset::offset_of!(LightBitfieldsDataStd430, bitfields),
12288
);
}
#[test]
fn test_struct_light_bitfields_std430() {
assert_eq!(std::mem::size_of::<LightBitfieldsStd430>(), 208896);
assert_eq!(std::mem::size_of::<LightBitfieldsDataStd430>(), 208896);
assert_eq!(std::mem::align_of::<LightBitfieldsDataStd430>(), 4);
assert_eq!(memoffset::offset_of!(LightBitfieldsStd430, data), 0);
}
#[test]
fn test_struct_light_build_lists_output_std430() {
assert_eq!(std::mem::size_of::<LightBuildListsOutputStd430>(), 6316048);
assert_eq!(std::mem::size_of::<LightBinningOutputStd430>(), 6316048);
assert_eq!(std::mem::align_of::<LightBinningOutputStd430>(), 4);
}
#[test]
fn test_struct_light_binning_output_std430() {
assert_eq!(std::mem::size_of::<LightBinningOutputStd430>(), 6316048);
assert_eq!(std::mem::size_of::<u32>(), 4);
assert_eq!(std::mem::align_of::<u32>(), 4);
assert_eq!(std::mem::size_of::<u32>(), 4);
assert_eq!(std::mem::align_of::<u32>(), 4);
assert_eq!(std::mem::size_of::<u32>(), 4);
assert_eq!(std::mem::align_of::<u32>(), 4);
assert_eq!(std::mem::size_of::<u32>(), 4);
assert_eq!(std::mem::align_of::<u32>(), 4);
assert_eq!(std::mem::size_of::<[ClusterMetaStd430; 3072]>(), 24576);
assert_eq!(std::mem::align_of::<[ClusterMetaStd430; 3072]>(), 4);
assert_eq!(std::mem::size_of::<[u32; 1572864]>(), 6291456);
assert_eq!(std::mem::align_of::<[u32; 1572864]>(), 4);
}
#[test]
fn test_struct_cluster_meta_std430() {
assert_eq!(std::mem::size_of::<ClusterMetaStd430>(), 8);
assert_eq!(std::mem::size_of::<u32>(), 4);
assert_eq!(std::mem::align_of::<u32>(), 4);
assert_eq!(memoffset::offset_of!(ClusterMetaStd430, count), 0);
assert_eq!(std::mem::size_of::<u32>(), 4);
assert_eq!(std::mem::align_of::<u32>(), 4);
assert_eq!(memoffset::offset_of!(ClusterMetaStd430, first_light), 4);
}
}