diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-07-13 13:25:16 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-07-15 22:35:16 -0700 |
| commit | 5dddb64f6a2fd072f2a26d4400f9a2a84386dc4e (patch) | |
| tree | db4e3b75cb5230f97f068b5e9455856cecba8807 /src/graphics_permanent.rs | |
| parent | ec66f7419f2155d1b4bd852fdc3da87646d865c0 (diff) | |
it spins!!!!
ahem. more formally: provide animated uniforms to the shader, and use them the tutorial just wants us to do three matrices, and to defer all the actual math to a library it recommends. that would certainly be simpler. anyway, we use quaterion+offset for everything but the projection frustum, and do all the math ourselves Change-Id: I399f432bebb1e7ca4d4342efa1d5aaf37b32f427 Force-Push: yes
Diffstat (limited to 'src/graphics_permanent.rs')
| -rw-r--r-- | src/graphics_permanent.rs | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/src/graphics_permanent.rs b/src/graphics_permanent.rs index c2225a3..b58e8a4 100644 --- a/src/graphics_permanent.rs +++ b/src/graphics_permanent.rs @@ -127,11 +127,13 @@ impl PermanentGraphicsState { = init_vulkan_device(&instance, &surface, enable_validation, enable_portability)?; + let descriptor_set_layout = init_descriptor_set_layout(&device)?; + Ok((PermanentGraphicsState { window, entry, instance, debug_messager, surface, device, - graphics_queue, presentation_queue, + graphics_queue, presentation_queue }, GraphicsStateForReinit { - physical_device, indices + physical_device, indices, descriptor_set_layout }, enable_swapchain)) } @@ -214,6 +216,17 @@ impl PermanentGraphicsState { pub struct GraphicsStateForReinit { pub physical_device: vk::PhysicalDevice, pub indices: QueueFamilyIndices, + pub descriptor_set_layout: vk::DescriptorSetLayout, +} + + +impl GraphicsStateForReinit { + #[allow(unsafe_code)] + pub fn destroy(self, device: &Device) -> () { + unsafe { + device.destroy_descriptor_set_layout(self.descriptor_set_layout, None) + }; + } } @@ -517,6 +530,29 @@ fn init_vulkan_device(instance: &Instance, surface: &vk::SurfaceKHR, } +#[allow(unsafe_code)] +fn init_descriptor_set_layout(device: &Device) + -> Result<vk::DescriptorSetLayout> +{ + let uniform_block_binding = vk::DescriptorSetLayoutBinding::builder() + .binding(0) + .descriptor_type(vk::DescriptorType::UNIFORM_BUFFER) + .descriptor_count(1) + .stage_flags(vk::ShaderStageFlags::VERTEX); + + let bindings = [uniform_block_binding]; + let descriptor_set_layout_info + = vk::DescriptorSetLayoutCreateInfo::builder() + .bindings(&bindings); + let descriptor_set_layout = unsafe { + device.create_descriptor_set_layout(&descriptor_set_layout_info, None) + }?; + + Ok(descriptor_set_layout) +} + + + // To Vulkan, a "physical" device is the actual GPU, and a "logical" // device is per-process state that represents a connection to the GPU. // Before we can create a logical device, we must choose which physical |