Skip to content
This repository was archived by the owner on Oct 22, 2020. It is now read-only.
This repository was archived by the owner on Oct 22, 2020. It is now read-only.

Entrypoint definition  #69

@Kamayuq

Description

@Kamayuq

Have you given any thought on how the binding model from the CPU part of rust could look like? I have been thinking about this and wanted to ask what would you think to have something along the lines of this on the GPU side:

#[spirv(DescriptorLayout)]
struct InputData
{
	#[spirv(ShaderVisible_PS ...)]
	diffuse_textures: &[Texture],  //dynamic (un)bounded array slice
	
	#[spirv(ShaderVisible_ALL ...)]
	some_constant: u32,
	
	...
}

#[spirv(Interpolants)]
struct Interpolants
{
	color : vec3,
	uv: vec2,
	#[spirv(NoInterpolation)]
	index: u32,
}

#[spirv(vertex)]
fn vertex_shader(..., input: InputData) -> Interpolants
{ ... }

#[spirv(OutputMerger)]
struct OutputData
{
	#[spirv(Blendmode_Additive, ...)]
	color : vec3
}

#[spirv(fragment)]
fn fragment_shader(... , interp: Interpolants, input: InputData) -> OutputData
{
 	let color = input.diffuse_textures[interp.index].Sample(interp.uv);
 	...
}

#[spirv(ShaderPipeline)]
struct VSPSPipeline
{
	descriptor: InputData
	blendmode: OutputData
	vertex: typeof(vertex_shader)
	pixel: typeof(pixel_shader)
}

and some code similar to this on the CPU to create and launch a draw:

fn main()
{	
	let some_textures : Vec<Texture> = get_textures();
	let some_constant = 42;
	let input_data = InputData::new(some_textures , some_constant);

	let rendertarget: RenderTarget<vec3> = get_rendertarget()
	let output_data = OutputData::new(rendertarget);
	
	let pipeline = VSPSPipeline::new(input_data, output_data, vertex_shader, fragment_shader);
	
	cmd_buffer.set_pipeline(pipeline);
	cmd_buffer.draw_indexed(...);
}

One reason behind this is that I would like to have a typesafe interface between CPU and GPU maybe even go further down the road of having units of measure and types like NormalMapTexture to bind against. And the other reason would be that I am really really sick of writing all that CPU binding code which is super super boring. I am not attached to any particular syntax maybe you have another proposal?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions