From aea6d8b310dede44211fcf994f8ddb42df076d91 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sat, 4 Jul 2026 16:49:31 -0700 Subject: load compiled SPIR-V bytecode (yay) no way to build it except by hand, as-yet. the tutorial doesn't cover that, we'll need to circle back and write a build.rs Force-Push: yes Change-Id: I2b489381f95b4b7505862caa236dea1c60cd9c1a --- src/main.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index f4e93cb..62c6025 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use std::cell::OnceCell; use std::collections::{ BTreeMap, BTreeSet, HashSet }; use std::ffi::{ c_void, CStr }; use vulkanalia::{ Device, Entry, Instance, Version }; +use vulkanalia::bytecode::Bytecode; use vulkanalia::loader::{ LibloadingLoader, LIBRARY }; use vulkanalia::vk::{ self, Handle, HasBuilder, ApplicationInfo, InstanceCreateInfo, @@ -180,6 +181,8 @@ impl Surreality { self.init_vulkan_swapchain()?; } + self.init_pipeline()?; + Ok(()) } @@ -638,6 +641,25 @@ impl Surreality { Ok(()) } + #[allow(unsafe_code)] + fn init_pipeline(&mut self) -> Result<()> { + // TODO integrate with Cargo + let vertex_binary = include_bytes!("../vert.spv"); + let fragment_binary = include_bytes!("../frag.spv"); + + let _ = self.load_spirv_shader_module(vertex_binary)?; + + Ok(()) + } + + fn load_spirv_shader_module(&mut self, binary: &[u8]) + -> Result + { + let bytecode = Bytecode::new(binary)?; + + Err(Error { message: "just because".to_string() }) + } + // 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 -- cgit 1.4.1