Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shaders macro crash (unwrap called on None value) when attempting to create a buffer of structs which contain arrays #1976

Closed
XoToM opened this issue Sep 13, 2022 · 1 comment

Comments

@XoToM
Copy link

XoToM commented Sep 13, 2022

  • Version of vulkano: 0.30.0
  • Version of vulkano-shaders: 0.30.0
  • Version of bytemuck: 1.8.0
  • OS: Windows 10 Pro
  • GPU (the selected PhysicalDevice): Nvidia RTX 3070 Laptop
  • GPU Driver: 31.0.15.1659
vulkano_shaders::shader!{
	ty: "fragment",
	src: "#version 460

	layout(location = 0) out vec4 fragColor;
	
	struct TestNode {
		uint mask[2];
	};
	
	layout( set = 1, binding = 0) buffer NodeStorage {
		TestNode nodes[];
	};
	
	void main()
	{
		//Placeholder code to prevent the macro from removing unused struct definitions. 
		TestNode abc = nodes[0];
		uint cde = abc.mask[0];
	
		fragColor = vec4(0.0+cde, 0.5, 0.5, 1.0);
	}
	
	
	",
	types_meta: {
		use bytemuck::{Pod, Zeroable};

		#[derive(Clone, Copy, Zeroable, Pod, Default)]
	},
}

fn main() {
	println!("Hello, world!");
}

Issue

The vulkano-shaders macro crashes when the shader code contains a definition of a buffer with an array of structs which have arrays in them. The compilation error given by cargo build:

error: proc macro panicked
  --> src\main.rs:1:1
   |
1  | / vulkano_shaders::shader!{
2  | |     ty: "fragment",
3  | |     src: "#version 460
4  | |
...  |
30 | |     },
31 | | }
   | |_^
   |
   = help: message: called `Option::unwrap()` on a `None` value

error: could not compile `project` due to previous error

This code appears to compile just fine on several glsl compilers (with target set to vulkan), which leads me to believe the macro crashes during the creation of types defined in the shader.

#1220 might be a related issue.

@marc0246
Copy link
Contributor

marc0246 commented Jul 7, 2023

This was fixed in #1945.

@marc0246 marc0246 closed this as completed Jul 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants