From fd9ce461c2668dcbf7ac6a5ecd543cd12952d698 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 18 Jul 2026 07:39:38 +0400 Subject: feat(render): sample original TEXM in Vulkan --- adapters/fparkan-render-vulkan/src/ffi/smoke.rs | 49 ++++++++++++++++++------- 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'adapters/fparkan-render-vulkan/src/ffi/smoke.rs') diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs index a57394e..d8cc0d5 100644 --- a/adapters/fparkan-render-vulkan/src/ffi/smoke.rs +++ b/adapters/fparkan-render-vulkan/src/ffi/smoke.rs @@ -181,21 +181,25 @@ impl VulkanSmokeRenderer { return Err(error); } }; - let texture = match create_info.texture.as_ref() { - None => None, - Some(texture) => { - match create_static_texture_image(&instance, &device, command_pool, texture) { - Ok(image) => Some(image), - Err(error) => { - // SAFETY: These resources belong to this live device and are rolled back before it drops. - unsafe { device.device().destroy_command_pool(command_pool, None) }; - destroy_allocated_buffer(&device, &index_buffer); - destroy_allocated_buffer(&device, &vertex_buffer); - return Err(error); - } - } - } + // Keep the compatibility triangle path valid: it samples a white texel + // when no original TEXM was supplied. + let fallback_texture = super::VulkanStaticTexture { + width: 1, + height: 1, + rgba8: vec![255, 255, 255, 255], }; + let texture_source = create_info.texture.as_ref().unwrap_or(&fallback_texture); + let texture = + match create_static_texture_image(&instance, &device, command_pool, texture_source) { + Ok(image) => Some(image), + Err(error) => { + // SAFETY: These resources belong to this live device and are rolled back before it drops. + unsafe { device.device().destroy_command_pool(command_pool, None) }; + destroy_allocated_buffer(&device, &index_buffer); + destroy_allocated_buffer(&device, &vertex_buffer); + return Err(error); + } + }; let mut renderer = Self { instance: Some(instance), validation, @@ -318,6 +322,14 @@ impl VulkanSmokeRenderer { }) } + fn texture_ref(&self) -> Result<&super::VulkanAllocatedImage, VulkanSmokeRendererError> { + self.texture + .as_ref() + .ok_or(VulkanSmokeRendererError::InvariantViolation { + context: "static material texture", + }) + } + fn surface_ref(&self) -> Result<&VulkanSurfaceProbe, VulkanSmokeRendererError> { self.surface .as_ref() @@ -532,6 +544,7 @@ impl VulkanSmokeRenderer { self.command_pool, self.vertex_buffer_ref()?, self.index_buffer_ref()?, + self.texture_ref()?, reuse_command_pool, )?, |resources| destroy_swapchain_resources(device, self.command_pool, resources), @@ -608,6 +621,14 @@ impl VulkanSmokeRenderer { vk::PipelineBindPoint::GRAPHICS, resources.pipeline, ); + device.device().cmd_bind_descriptor_sets( + command_buffer, + vk::PipelineBindPoint::GRAPHICS, + resources.pipeline_layout, + 0, + &[resources.descriptor_set], + &[], + ); let vertex_buffers = [self.vertex_buffer_ref()?.buffer]; let offsets = [0_u64]; device -- cgit v1.2.3