mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
add pipeline constants plumbing
This commit is contained in:
parent
fb305b85f6
commit
3bda381812
@ -8,6 +8,7 @@ use deno_core::ResourceId;
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use super::error::WebGpuError;
|
use super::error::WebGpuError;
|
||||||
@ -75,7 +76,7 @@ pub enum GPUPipelineLayoutOrGPUAutoLayoutMode {
|
|||||||
pub struct GpuProgrammableStage {
|
pub struct GpuProgrammableStage {
|
||||||
module: ResourceId,
|
module: ResourceId,
|
||||||
entry_point: Option<String>,
|
entry_point: Option<String>,
|
||||||
// constants: HashMap<String, GPUPipelineConstantValue>
|
constants: HashMap<String, f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[op2]
|
#[op2]
|
||||||
@ -111,7 +112,7 @@ pub fn op_webgpu_create_compute_pipeline(
|
|||||||
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
||||||
module: compute_shader_module_resource.1,
|
module: compute_shader_module_resource.1,
|
||||||
entry_point: compute.entry_point.map(Cow::from),
|
entry_point: compute.entry_point.map(Cow::from),
|
||||||
// TODO(lucacasonato): support args.compute.constants
|
constants: Cow::Owned(compute.constants),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let implicit_pipelines = match layout {
|
let implicit_pipelines = match layout {
|
||||||
@ -279,6 +280,7 @@ impl<'a> From<GpuVertexBufferLayout> for wgpu_core::pipeline::VertexBufferLayout
|
|||||||
struct GpuVertexState {
|
struct GpuVertexState {
|
||||||
module: ResourceId,
|
module: ResourceId,
|
||||||
entry_point: String,
|
entry_point: String,
|
||||||
|
constants: HashMap<String, f64>,
|
||||||
buffers: Vec<Option<GpuVertexBufferLayout>>,
|
buffers: Vec<Option<GpuVertexBufferLayout>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +308,7 @@ struct GpuFragmentState {
|
|||||||
targets: Vec<Option<wgpu_types::ColorTargetState>>,
|
targets: Vec<Option<wgpu_types::ColorTargetState>>,
|
||||||
module: u32,
|
module: u32,
|
||||||
entry_point: String,
|
entry_point: String,
|
||||||
// TODO(lucacasonato): constants
|
constants: HashMap<String, f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@ -356,8 +358,9 @@ pub fn op_webgpu_create_render_pipeline(
|
|||||||
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
||||||
module: fragment_shader_module_resource.1,
|
module: fragment_shader_module_resource.1,
|
||||||
entry_point: Some(Cow::from(fragment.entry_point)),
|
entry_point: Some(Cow::from(fragment.entry_point)),
|
||||||
|
constants: Cow::Owned(fragment.constants),
|
||||||
},
|
},
|
||||||
targets: Cow::from(fragment.targets),
|
targets: Cow::Owned(fragment.targets),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -378,6 +381,7 @@ pub fn op_webgpu_create_render_pipeline(
|
|||||||
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
stage: wgpu_core::pipeline::ProgrammableStageDescriptor {
|
||||||
module: vertex_shader_module_resource.1,
|
module: vertex_shader_module_resource.1,
|
||||||
entry_point: Some(Cow::Owned(args.vertex.entry_point)),
|
entry_point: Some(Cow::Owned(args.vertex.entry_point)),
|
||||||
|
constants: Cow::Owned(args.vertex.constants),
|
||||||
},
|
},
|
||||||
buffers: Cow::Owned(vertex_buffers),
|
buffers: Cow::Owned(vertex_buffers),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -132,6 +132,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &draw_shader,
|
module: &draw_shader,
|
||||||
entry_point: "main_vs",
|
entry_point: "main_vs",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[
|
buffers: &[
|
||||||
wgpu::VertexBufferLayout {
|
wgpu::VertexBufferLayout {
|
||||||
array_stride: 4 * 4,
|
array_stride: 4 * 4,
|
||||||
@ -148,6 +149,7 @@ impl crate::framework::Example for Example {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &draw_shader,
|
module: &draw_shader,
|
||||||
entry_point: "main_fs",
|
entry_point: "main_fs",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
@ -163,6 +165,7 @@ impl crate::framework::Example for Example {
|
|||||||
layout: Some(&compute_pipeline_layout),
|
layout: Some(&compute_pipeline_layout),
|
||||||
module: &compute_shader,
|
module: &compute_shader,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// buffer for the three 2d triangle vertices of each instance
|
// buffer for the three 2d triangle vertices of each instance
|
||||||
|
|||||||
@ -203,11 +203,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: config.view_formats[0],
|
format: config.view_formats[0],
|
||||||
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
||||||
|
|||||||
@ -97,11 +97,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader_triangle_and_lines,
|
module: &shader_triangle_and_lines,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader_triangle_and_lines,
|
module: &shader_triangle_and_lines,
|
||||||
entry_point: "fs_main_red",
|
entry_point: "fs_main_red",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(RENDER_TARGET_FORMAT.into())],
|
targets: &[Some(RENDER_TARGET_FORMAT.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
@ -120,11 +122,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader_triangle_and_lines,
|
module: &shader_triangle_and_lines,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader_triangle_and_lines,
|
module: &shader_triangle_and_lines,
|
||||||
entry_point: "fs_main_blue",
|
entry_point: "fs_main_blue",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(RENDER_TARGET_FORMAT.into())],
|
targets: &[Some(RENDER_TARGET_FORMAT.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
@ -144,11 +148,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader_triangle_and_lines,
|
module: &shader_triangle_and_lines,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader_triangle_and_lines,
|
module: &shader_triangle_and_lines,
|
||||||
entry_point: "fs_main_white",
|
entry_point: "fs_main_white",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
@ -205,11 +211,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
|
|||||||
@ -244,11 +244,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &vertex_buffers,
|
buffers: &vertex_buffers,
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
@ -270,11 +272,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &vertex_buffers,
|
buffers: &vertex_buffers,
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_wire",
|
entry_point: "fs_wire",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: config.view_formats[0],
|
format: config.view_formats[0],
|
||||||
blend: Some(wgpu::BlendState {
|
blend: Some(wgpu::BlendState {
|
||||||
|
|||||||
@ -109,6 +109,7 @@ async fn execute_gpu_inner(
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &cs_module,
|
module: &cs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Instantiates the bind group, once again specifying the binding of buffers.
|
// Instantiates the bind group, once again specifying the binding of buffers.
|
||||||
|
|||||||
@ -103,12 +103,14 @@ async fn execute(
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shaders_module,
|
module: &shaders_module,
|
||||||
entry_point: "patient_main",
|
entry_point: "patient_main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
let hasty_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
|
let hasty_pipeline = device.create_compute_pipeline(&wgpu::ComputePipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shaders_module,
|
module: &shaders_module,
|
||||||
entry_point: "hasty_main",
|
entry_point: "hasty_main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|||||||
@ -60,10 +60,12 @@ async fn run(event_loop: EventLoop<()>, window: Window) {
|
|||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
|
constants: &Default::default(),
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(swapchain_format.into())],
|
targets: &[Some(swapchain_format.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
|
|||||||
@ -110,6 +110,7 @@ async fn run() {
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
|
|||||||
@ -93,11 +93,13 @@ impl Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(TEXTURE_FORMAT.into())],
|
targets: &[Some(TEXTURE_FORMAT.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
@ -290,11 +292,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -54,6 +54,7 @@ impl Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: shader,
|
module: shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[wgpu::VertexBufferLayout {
|
buffers: &[wgpu::VertexBufferLayout {
|
||||||
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||||
step_mode: wgpu::VertexStepMode::Vertex,
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
@ -63,6 +64,7 @@ impl Example {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: shader,
|
module: shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -59,11 +59,13 @@ async fn run(_path: Option<String>) {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::TextureFormat::Rgba8UnormSrgb.into())],
|
targets: &[Some(wgpu::TextureFormat::Rgba8UnormSrgb.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
|
|||||||
@ -245,6 +245,7 @@ impl WgpuContext {
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
WgpuContext {
|
WgpuContext {
|
||||||
|
|||||||
@ -500,6 +500,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_bake",
|
entry_point: "vs_bake",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[vb_desc.clone()],
|
buffers: &[vb_desc.clone()],
|
||||||
},
|
},
|
||||||
fragment: None,
|
fragment: None,
|
||||||
@ -632,6 +633,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[vb_desc],
|
buffers: &[vb_desc],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
@ -641,6 +643,7 @@ impl crate::framework::Example for Example {
|
|||||||
} else {
|
} else {
|
||||||
"fs_main_without_storage"
|
"fs_main_without_storage"
|
||||||
},
|
},
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -199,11 +199,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_sky",
|
entry_point: "vs_sky",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_sky",
|
entry_point: "fs_sky",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
@ -226,6 +228,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_entity",
|
entry_point: "vs_entity",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[wgpu::VertexBufferLayout {
|
buffers: &[wgpu::VertexBufferLayout {
|
||||||
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
array_stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||||
step_mode: wgpu::VertexStepMode::Vertex,
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
@ -235,6 +238,7 @@ impl crate::framework::Example for Example {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_entity",
|
entry_point: "fs_entity",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -131,11 +131,13 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &vertex_buffers,
|
buffers: &vertex_buffers,
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: config.view_formats[0],
|
format: config.view_formats[0],
|
||||||
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
|
||||||
|
|||||||
@ -74,11 +74,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &vertex_buffers,
|
buffers: &vertex_buffers,
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: config.view_formats[0],
|
format: config.view_formats[0],
|
||||||
blend: None,
|
blend: None,
|
||||||
@ -112,11 +114,13 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &vertex_buffers,
|
buffers: &vertex_buffers,
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: Default::default(),
|
primitive: Default::default(),
|
||||||
|
|||||||
@ -100,6 +100,7 @@ async fn run(_path: Option<String>) {
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
log::info!("Wgpu context set up.");
|
log::info!("Wgpu context set up.");
|
||||||
|
|||||||
@ -321,6 +321,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &base_shader_module,
|
module: &base_shader_module,
|
||||||
entry_point: "vert_main",
|
entry_point: "vert_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[wgpu::VertexBufferLayout {
|
buffers: &[wgpu::VertexBufferLayout {
|
||||||
array_stride: vertex_size as wgpu::BufferAddress,
|
array_stride: vertex_size as wgpu::BufferAddress,
|
||||||
step_mode: wgpu::VertexStepMode::Vertex,
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
@ -330,6 +331,7 @@ impl crate::framework::Example for Example {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: fragment_shader_module,
|
module: fragment_shader_module,
|
||||||
entry_point: fragment_entry_point,
|
entry_point: fragment_entry_point,
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -298,6 +298,7 @@ fn compute_pass(
|
|||||||
layout: None,
|
layout: None,
|
||||||
module,
|
module,
|
||||||
entry_point: "main_cs",
|
entry_point: "main_cs",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
let bind_group_layout = compute_pipeline.get_bind_group_layout(0);
|
let bind_group_layout = compute_pipeline.get_bind_group_layout(0);
|
||||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
@ -352,11 +353,13 @@ fn render_pass(
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module,
|
module,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module,
|
module,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(format.into())],
|
targets: &[Some(format.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
|
|||||||
@ -179,11 +179,13 @@ impl WgpuContext {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(swapchain_format.into())],
|
targets: &[Some(swapchain_format.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
|
|||||||
@ -512,6 +512,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &water_module,
|
module: &water_module,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
// Layout of our vertices. This should match the structs
|
// Layout of our vertices. This should match the structs
|
||||||
// which are uploaded to the GPU. This should also be
|
// which are uploaded to the GPU. This should also be
|
||||||
// ensured by tagging on either a `#[repr(C)]` onto a
|
// ensured by tagging on either a `#[repr(C)]` onto a
|
||||||
@ -527,6 +528,7 @@ impl crate::framework::Example for Example {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &water_module,
|
module: &water_module,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
// Describes how the colour will be interpolated
|
// Describes how the colour will be interpolated
|
||||||
// and assigned to the output attachment.
|
// and assigned to the output attachment.
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
@ -581,6 +583,7 @@ impl crate::framework::Example for Example {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &terrain_module,
|
module: &terrain_module,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[wgpu::VertexBufferLayout {
|
buffers: &[wgpu::VertexBufferLayout {
|
||||||
array_stride: terrain_vertex_size as wgpu::BufferAddress,
|
array_stride: terrain_vertex_size as wgpu::BufferAddress,
|
||||||
step_mode: wgpu::VertexStepMode::Vertex,
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
@ -590,6 +593,7 @@ impl crate::framework::Example for Example {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &terrain_module,
|
module: &terrain_module,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(config.view_formats[0].into())],
|
targets: &[Some(config.view_formats[0].into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -593,6 +593,7 @@ fn write_output(
|
|||||||
pipeline_options_owned = spv::PipelineOptions {
|
pipeline_options_owned = spv::PipelineOptions {
|
||||||
entry_point: name.clone(),
|
entry_point: name.clone(),
|
||||||
shader_stage: module.entry_points[ep_index].stage,
|
shader_stage: module.entry_points[ep_index].stage,
|
||||||
|
constants: naga::back::PipelineConstants::default(),
|
||||||
};
|
};
|
||||||
Some(&pipeline_options_owned)
|
Some(&pipeline_options_owned)
|
||||||
}
|
}
|
||||||
@ -633,6 +634,7 @@ fn write_output(
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
multiview: None,
|
multiview: None,
|
||||||
|
constants: naga::back::PipelineConstants::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
@ -668,6 +670,7 @@ fn write_output(
|
|||||||
"Generating hlsl output requires validation to \
|
"Generating hlsl output requires validation to \
|
||||||
succeed, and it failed in a previous step",
|
succeed, and it failed in a previous step",
|
||||||
))?,
|
))?,
|
||||||
|
&hlsl::PipelineOptions::default(),
|
||||||
)
|
)
|
||||||
.unwrap_pretty();
|
.unwrap_pretty();
|
||||||
fs::write(output_path, buffer)?;
|
fs::write(output_path, buffer)?;
|
||||||
|
|||||||
@ -193,6 +193,7 @@ fn backends(c: &mut Criterion) {
|
|||||||
let pipeline_options = naga::back::spv::PipelineOptions {
|
let pipeline_options = naga::back::spv::PipelineOptions {
|
||||||
shader_stage: ep.stage,
|
shader_stage: ep.stage,
|
||||||
entry_point: ep.name.clone(),
|
entry_point: ep.name.clone(),
|
||||||
|
constants: naga::back::PipelineConstants::default(),
|
||||||
};
|
};
|
||||||
writer
|
writer
|
||||||
.write(module, info, Some(&pipeline_options), &None, &mut data)
|
.write(module, info, Some(&pipeline_options), &None, &mut data)
|
||||||
@ -223,10 +224,11 @@ fn backends(c: &mut Criterion) {
|
|||||||
group.bench_function("hlsl", |b| {
|
group.bench_function("hlsl", |b| {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
let options = naga::back::hlsl::Options::default();
|
let options = naga::back::hlsl::Options::default();
|
||||||
|
let pipeline_options = naga::back::hlsl::PipelineOptions::default();
|
||||||
let mut string = String::new();
|
let mut string = String::new();
|
||||||
for &(ref module, ref info) in inputs.iter() {
|
for &(ref module, ref info) in inputs.iter() {
|
||||||
let mut writer = naga::back::hlsl::Writer::new(&mut string, &options);
|
let mut writer = naga::back::hlsl::Writer::new(&mut string, &options);
|
||||||
let _ = writer.write(module, info); // may fail on unimplemented things
|
let _ = writer.write(module, info, &pipeline_options); // may fail on unimplemented things
|
||||||
string.clear();
|
string.clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -248,6 +250,7 @@ fn backends(c: &mut Criterion) {
|
|||||||
shader_stage: ep.stage,
|
shader_stage: ep.stage,
|
||||||
entry_point: ep.name.clone(),
|
entry_point: ep.name.clone(),
|
||||||
multiview: None,
|
multiview: None,
|
||||||
|
constants: naga::back::PipelineConstants::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// might be `Err` if missing features
|
// might be `Err` if missing features
|
||||||
|
|||||||
@ -282,7 +282,7 @@ impl Default for Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A subset of options meant to be changed per pipeline.
|
/// A subset of options meant to be changed per pipeline.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||||
pub struct PipelineOptions {
|
pub struct PipelineOptions {
|
||||||
@ -294,6 +294,8 @@ pub struct PipelineOptions {
|
|||||||
pub entry_point: String,
|
pub entry_point: String,
|
||||||
/// How many views to render to, if doing multiview rendering.
|
/// How many views to render to, if doing multiview rendering.
|
||||||
pub multiview: Option<std::num::NonZeroU32>,
|
pub multiview: Option<std::num::NonZeroU32>,
|
||||||
|
/// Pipeline constants.
|
||||||
|
pub constants: back::PipelineConstants,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@ -195,6 +195,14 @@ pub struct Options {
|
|||||||
pub zero_initialize_workgroup_memory: bool,
|
pub zero_initialize_workgroup_memory: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default)]
|
||||||
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
|
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||||
|
pub struct PipelineOptions {
|
||||||
|
/// Pipeline constants.
|
||||||
|
pub constants: back::PipelineConstants,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Options {
|
impl Default for Options {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Options {
|
Options {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use super::{
|
use super::{
|
||||||
help::{WrappedArrayLength, WrappedConstructor, WrappedImageQuery, WrappedStructMatrixAccess},
|
help::{WrappedArrayLength, WrappedConstructor, WrappedImageQuery, WrappedStructMatrixAccess},
|
||||||
storage::StoreValue,
|
storage::StoreValue,
|
||||||
BackendResult, Error, Options,
|
BackendResult, Error, Options, PipelineOptions,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
back,
|
back,
|
||||||
@ -167,6 +167,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
module: &Module,
|
module: &Module,
|
||||||
module_info: &valid::ModuleInfo,
|
module_info: &valid::ModuleInfo,
|
||||||
|
_pipeline_options: &PipelineOptions,
|
||||||
) -> Result<super::ReflectionInfo, Error> {
|
) -> Result<super::ReflectionInfo, Error> {
|
||||||
self.reset(module);
|
self.reset(module);
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,15 @@ pub const BAKE_PREFIX: &str = "_e";
|
|||||||
/// Expressions that need baking.
|
/// Expressions that need baking.
|
||||||
pub type NeedBakeExpressions = crate::FastHashSet<crate::Handle<crate::Expression>>;
|
pub type NeedBakeExpressions = crate::FastHashSet<crate::Handle<crate::Expression>>;
|
||||||
|
|
||||||
|
/// Specifies the values of pipeline-overridable constants in the shader module.
|
||||||
|
///
|
||||||
|
/// If an `@id` attribute was specified on the declaration,
|
||||||
|
/// the key must be the pipeline constant ID as a decimal ASCII number; if not,
|
||||||
|
/// the key must be the constant's identifier name.
|
||||||
|
///
|
||||||
|
/// The value may represent any of WGSL's concrete scalar types.
|
||||||
|
pub type PipelineConstants = std::collections::HashMap<String, f64>;
|
||||||
|
|
||||||
/// Indentation level.
|
/// Indentation level.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Level(pub usize);
|
pub struct Level(pub usize);
|
||||||
|
|||||||
@ -221,7 +221,7 @@ impl Default for Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A subset of options that are meant to be changed per pipeline.
|
/// A subset of options that are meant to be changed per pipeline.
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Default, Clone)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||||
pub struct PipelineOptions {
|
pub struct PipelineOptions {
|
||||||
@ -232,6 +232,8 @@ pub struct PipelineOptions {
|
|||||||
///
|
///
|
||||||
/// Enable this for vertex shaders with point primitive topologies.
|
/// Enable this for vertex shaders with point primitive topologies.
|
||||||
pub allow_and_force_point_size: bool,
|
pub allow_and_force_point_size: bool,
|
||||||
|
/// Pipeline constants.
|
||||||
|
pub constants: crate::back::PipelineConstants,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Options {
|
impl Options {
|
||||||
|
|||||||
@ -725,7 +725,7 @@ impl<'a> Default for Options<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A subset of options meant to be changed per pipeline.
|
// A subset of options meant to be changed per pipeline.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
|
||||||
pub struct PipelineOptions {
|
pub struct PipelineOptions {
|
||||||
@ -735,6 +735,8 @@ pub struct PipelineOptions {
|
|||||||
///
|
///
|
||||||
/// If no entry point that matches is found while creating a [`Writer`], a error will be thrown.
|
/// If no entry point that matches is found while creating a [`Writer`], a error will be thrown.
|
||||||
pub entry_point: String,
|
pub entry_point: String,
|
||||||
|
/// Pipeline constants.
|
||||||
|
pub constants: crate::back::PipelineConstants,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_vec(
|
pub fn write_vec(
|
||||||
|
|||||||
@ -27,5 +27,6 @@
|
|||||||
),
|
),
|
||||||
msl_pipeline: (
|
msl_pipeline: (
|
||||||
allow_and_force_point_size: true,
|
allow_and_force_point_size: true,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -428,6 +428,7 @@ fn write_output_spv(
|
|||||||
let pipeline_options = spv::PipelineOptions {
|
let pipeline_options = spv::PipelineOptions {
|
||||||
entry_point: ep.name.clone(),
|
entry_point: ep.name.clone(),
|
||||||
shader_stage: ep.stage,
|
shader_stage: ep.stage,
|
||||||
|
constants: naga::back::PipelineConstants::default(),
|
||||||
};
|
};
|
||||||
write_output_spv_inner(
|
write_output_spv_inner(
|
||||||
input,
|
input,
|
||||||
@ -516,6 +517,7 @@ fn write_output_glsl(
|
|||||||
shader_stage: stage,
|
shader_stage: stage,
|
||||||
entry_point: ep_name.to_string(),
|
entry_point: ep_name.to_string(),
|
||||||
multiview,
|
multiview,
|
||||||
|
constants: naga::back::PipelineConstants::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
@ -548,7 +550,9 @@ fn write_output_hlsl(
|
|||||||
|
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
let mut writer = hlsl::Writer::new(&mut buffer, options);
|
let mut writer = hlsl::Writer::new(&mut buffer, options);
|
||||||
let reflection_info = writer.write(module, info).expect("HLSL write failed");
|
let reflection_info = writer
|
||||||
|
.write(module, info, &hlsl::PipelineOptions::default())
|
||||||
|
.expect("HLSL write failed");
|
||||||
|
|
||||||
input.write_output_file("hlsl", "hlsl", buffer);
|
input.write_output_file("hlsl", "hlsl", buffer);
|
||||||
|
|
||||||
|
|||||||
@ -57,6 +57,7 @@
|
|||||||
stage: (
|
stage: (
|
||||||
module: Id(0, 1, Empty),
|
module: Id(0, 1, Empty),
|
||||||
entry_point: None,
|
entry_point: None,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
stage: (
|
stage: (
|
||||||
module: Id(0, 1, Empty),
|
module: Id(0, 1, Empty),
|
||||||
entry_point: None,
|
entry_point: None,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -58,6 +58,7 @@
|
|||||||
stage: (
|
stage: (
|
||||||
module: Id(0, 1, Empty),
|
module: Id(0, 1, Empty),
|
||||||
entry_point: None,
|
entry_point: None,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
buffers: [],
|
buffers: [],
|
||||||
),
|
),
|
||||||
@ -65,6 +66,7 @@
|
|||||||
stage: (
|
stage: (
|
||||||
module: Id(0, 1, Empty),
|
module: Id(0, 1, Empty),
|
||||||
entry_point: None,
|
entry_point: None,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
targets: [
|
targets: [
|
||||||
Some((
|
Some((
|
||||||
|
|||||||
@ -134,6 +134,7 @@
|
|||||||
stage: (
|
stage: (
|
||||||
module: Id(0, 1, Empty),
|
module: Id(0, 1, Empty),
|
||||||
entry_point: None,
|
entry_point: None,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -135,6 +135,7 @@
|
|||||||
stage: (
|
stage: (
|
||||||
module: Id(0, 1, Empty),
|
module: Id(0, 1, Empty),
|
||||||
entry_point: None,
|
entry_point: None,
|
||||||
|
constants: {},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -369,6 +369,7 @@ fn copy_via_compute(
|
|||||||
layout: Some(&pll),
|
layout: Some(&pll),
|
||||||
module: &sm,
|
module: &sm,
|
||||||
entry_point: "copy_texture_to_buffer",
|
entry_point: "copy_texture_to_buffer",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@ -96,6 +96,7 @@ static BGRA8_UNORM_STORAGE: GpuTestConfiguration = GpuTestConfiguration::new()
|
|||||||
label: None,
|
label: None,
|
||||||
layout: Some(&pl),
|
layout: Some(&pl),
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
module: &module,
|
module: &module,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,7 @@ async fn bgl_dedupe(ctx: TestingContext) {
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "no_resources",
|
entry_point: "no_resources",
|
||||||
|
constants: &Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let pipeline = ctx.device.create_compute_pipeline(&desc);
|
let pipeline = ctx.device.create_compute_pipeline(&desc);
|
||||||
@ -218,6 +219,7 @@ fn bgl_dedupe_with_dropped_user_handle(ctx: TestingContext) {
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "no_resources",
|
entry_point: "no_resources",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut encoder = ctx.device.create_command_encoder(&Default::default());
|
let mut encoder = ctx.device.create_command_encoder(&Default::default());
|
||||||
@ -263,6 +265,7 @@ fn bgl_dedupe_derived(ctx: TestingContext) {
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "resources",
|
entry_point: "resources",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// We create two bind groups, pulling the bind_group_layout from the pipeline each time.
|
// We create two bind groups, pulling the bind_group_layout from the pipeline each time.
|
||||||
@ -333,6 +336,7 @@ fn separate_programs_have_incompatible_derived_bgls(ctx: TestingContext) {
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "resources",
|
entry_point: "resources",
|
||||||
|
constants: &Default::default(),
|
||||||
};
|
};
|
||||||
// Create two pipelines, creating a BG from the second.
|
// Create two pipelines, creating a BG from the second.
|
||||||
let pipeline1 = ctx.device.create_compute_pipeline(&desc);
|
let pipeline1 = ctx.device.create_compute_pipeline(&desc);
|
||||||
@ -394,6 +398,7 @@ fn derived_bgls_incompatible_with_regular_bgls(ctx: TestingContext) {
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "resources",
|
entry_point: "resources",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create a matching BGL
|
// Create a matching BGL
|
||||||
|
|||||||
@ -224,6 +224,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_LAYOUT: GpuTestConfiguration = GpuTestConfigu
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shader_module,
|
module: &shader_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -292,6 +293,7 @@ static MINIMUM_BUFFER_BINDING_SIZE_DISPATCH: GpuTestConfiguration = GpuTestConfi
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &shader_module,
|
module: &shader_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
|
let buffer = ctx.device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
|||||||
@ -480,6 +480,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader_module,
|
module: &shader_module,
|
||||||
entry_point: "",
|
entry_point: "",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
@ -498,6 +499,7 @@ static DEVICE_DESTROY_THEN_MORE: GpuTestConfiguration = GpuTestConfiguration::ne
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &shader_module,
|
module: &shader_module,
|
||||||
entry_point: "",
|
entry_point: "",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -734,6 +736,7 @@ fn vs_main() -> @builtin(position) vec4<f32> {
|
|||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &trivial_shaders_with_some_reversed_bindings,
|
module: &trivial_shaders_with_some_reversed_bindings,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgt::ColorTargetState {
|
targets: &[Some(wgt::ColorTargetState {
|
||||||
format: wgt::TextureFormat::Bgra8Unorm,
|
format: wgt::TextureFormat::Bgra8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
@ -747,6 +750,7 @@ fn vs_main() -> @builtin(position) vec4<f32> {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &trivial_shaders_with_some_reversed_bindings,
|
module: &trivial_shaders_with_some_reversed_bindings,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
primitive: wgt::PrimitiveState::default(),
|
primitive: wgt::PrimitiveState::default(),
|
||||||
|
|||||||
@ -95,15 +95,17 @@ async fn draw_test_with_reports(
|
|||||||
layout: Some(&ppl),
|
layout: Some(&ppl),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
entry_point: "vs_main_builtin",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "vs_main_builtin",
|
||||||
|
constants: &Default::default(),
|
||||||
},
|
},
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
entry_point: "fs_main",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
|
|||||||
@ -24,11 +24,13 @@ static NV12_TEXTURE_CREATION_SAMPLING: GpuTestConfiguration = GpuTestConfigurati
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(target_format.into())],
|
targets: &[Some(target_format.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -37,6 +37,7 @@ static OCCLUSION_QUERY: GpuTestConfiguration = GpuTestConfiguration::new()
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: None,
|
fragment: None,
|
||||||
|
|||||||
@ -69,6 +69,7 @@ static PARTIALLY_BOUNDED_ARRAY: GpuTestConfiguration = GpuTestConfiguration::new
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &cs_module,
|
module: &cs_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {
|
||||||
|
|||||||
@ -28,6 +28,7 @@ static PIPELINE_DEFAULT_LAYOUT_BAD_MODULE: GpuTestConfiguration = GpuTestConfigu
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "doesn't exist",
|
entry_point: "doesn't exist",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
pipeline.get_bind_group_layout(0);
|
pipeline.get_bind_group_layout(0);
|
||||||
|
|||||||
@ -103,6 +103,7 @@ async fn partial_update_test(ctx: TestingContext) {
|
|||||||
layout: Some(&pipeline_layout),
|
layout: Some(&pipeline_layout),
|
||||||
module: &sm,
|
module: &sm,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut encoder = ctx
|
let mut encoder = ctx
|
||||||
|
|||||||
@ -102,11 +102,13 @@ async fn multi_stage_data_binding_test(ctx: TestingContext) {
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &vs_sm,
|
module: &vs_sm,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &fs_sm,
|
module: &fs_sm,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
|
|||||||
@ -52,6 +52,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration =
|
|||||||
vertex: VertexState {
|
vertex: VertexState {
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "double_buffer_vert",
|
entry_point: "double_buffer_vert",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[
|
buffers: &[
|
||||||
VertexBufferLayout {
|
VertexBufferLayout {
|
||||||
array_stride: 16,
|
array_stride: 16,
|
||||||
@ -71,6 +72,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration =
|
|||||||
fragment: Some(FragmentState {
|
fragment: Some(FragmentState {
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "double_buffer_frag",
|
entry_point: "double_buffer_frag",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(ColorTargetState {
|
targets: &[Some(ColorTargetState {
|
||||||
format: TextureFormat::Rgba8Unorm,
|
format: TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
@ -88,6 +90,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration =
|
|||||||
vertex: VertexState {
|
vertex: VertexState {
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "single_buffer_vert",
|
entry_point: "single_buffer_vert",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[VertexBufferLayout {
|
buffers: &[VertexBufferLayout {
|
||||||
array_stride: 16,
|
array_stride: 16,
|
||||||
step_mode: VertexStepMode::Vertex,
|
step_mode: VertexStepMode::Vertex,
|
||||||
@ -100,6 +103,7 @@ static PASS_RESET_VERTEX_BUFFER: GpuTestConfiguration =
|
|||||||
fragment: Some(FragmentState {
|
fragment: Some(FragmentState {
|
||||||
module: &module,
|
module: &module,
|
||||||
entry_point: "single_buffer_frag",
|
entry_point: "single_buffer_frag",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(ColorTargetState {
|
targets: &[Some(ColorTargetState {
|
||||||
format: TextureFormat::Rgba8Unorm,
|
format: TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
|
|||||||
@ -42,16 +42,18 @@ async fn scissor_test_impl(
|
|||||||
label: Some("Pipeline"),
|
label: Some("Pipeline"),
|
||||||
layout: None,
|
layout: None,
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
entry_point: "vs_main",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
entry_point: "fs_main",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
|
|||||||
@ -307,6 +307,7 @@ async fn shader_input_output_test(
|
|||||||
layout: Some(&pll),
|
layout: Some(&pll),
|
||||||
module: &sm,
|
module: &sm,
|
||||||
entry_point: "cs_main",
|
entry_point: "cs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// -- Initializing data --
|
// -- Initializing data --
|
||||||
|
|||||||
@ -87,6 +87,7 @@ static ZERO_INIT_WORKGROUP_MEMORY: GpuTestConfiguration = GpuTestConfiguration::
|
|||||||
layout: Some(&pll),
|
layout: Some(&pll),
|
||||||
module: &sm,
|
module: &sm,
|
||||||
entry_point: "read",
|
entry_point: "read",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let pipeline_write = ctx
|
let pipeline_write = ctx
|
||||||
@ -96,6 +97,7 @@ static ZERO_INIT_WORKGROUP_MEMORY: GpuTestConfiguration = GpuTestConfiguration::
|
|||||||
layout: None,
|
layout: None,
|
||||||
module: &sm,
|
module: &sm,
|
||||||
entry_point: "write",
|
entry_point: "write",
|
||||||
|
constants: &Default::default(),
|
||||||
});
|
});
|
||||||
|
|
||||||
// -- Initializing data --
|
// -- Initializing data --
|
||||||
|
|||||||
@ -120,6 +120,9 @@ async fn pulling_common(
|
|||||||
label: None,
|
label: None,
|
||||||
layout: None,
|
layout: None,
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
|
module: &shader,
|
||||||
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[wgpu::VertexBufferLayout {
|
buffers: &[wgpu::VertexBufferLayout {
|
||||||
array_stride: 8,
|
array_stride: 8,
|
||||||
step_mode: wgpu::VertexStepMode::Vertex,
|
step_mode: wgpu::VertexStepMode::Vertex,
|
||||||
@ -129,15 +132,14 @@ async fn pulling_common(
|
|||||||
shader_location: 0,
|
shader_location: 0,
|
||||||
}],
|
}],
|
||||||
}],
|
}],
|
||||||
entry_point: "vs_main",
|
|
||||||
module: &shader,
|
|
||||||
},
|
},
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
entry_point: "fs_main",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
|
|||||||
@ -93,11 +93,13 @@ async fn reinterpret(
|
|||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: shader,
|
module: shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: shader,
|
module: shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &Default::default(),
|
||||||
targets: &[Some(src_format.into())],
|
targets: &[Some(src_format.into())],
|
||||||
}),
|
}),
|
||||||
primitive: wgpu::PrimitiveState {
|
primitive: wgpu::PrimitiveState {
|
||||||
|
|||||||
@ -272,20 +272,23 @@ async fn vertex_index_common(ctx: TestingContext) {
|
|||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let constants = &Default::default();
|
||||||
let mut pipeline_desc = wgpu::RenderPipelineDescriptor {
|
let mut pipeline_desc = wgpu::RenderPipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: Some(&ppl),
|
layout: Some(&ppl),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
entry_point: "vs_main_builtin",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "vs_main_builtin",
|
||||||
|
constants,
|
||||||
},
|
},
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
multisample: wgpu::MultisampleState::default(),
|
multisample: wgpu::MultisampleState::default(),
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
entry_point: "fs_main",
|
|
||||||
module: &shader,
|
module: &shader,
|
||||||
|
entry_point: "fs_main",
|
||||||
|
constants,
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Rgba8Unorm,
|
format: wgpu::TextureFormat::Rgba8Unorm,
|
||||||
blend: None,
|
blend: None,
|
||||||
|
|||||||
@ -2762,8 +2762,9 @@ impl<A: HalApi> Device<A> {
|
|||||||
label: desc.label.to_hal(self.instance_flags),
|
label: desc.label.to_hal(self.instance_flags),
|
||||||
layout: pipeline_layout.raw(),
|
layout: pipeline_layout.raw(),
|
||||||
stage: hal::ProgrammableStage {
|
stage: hal::ProgrammableStage {
|
||||||
entry_point: final_entry_point_name.as_ref(),
|
|
||||||
module: shader_module.raw(),
|
module: shader_module.raw(),
|
||||||
|
entry_point: final_entry_point_name.as_ref(),
|
||||||
|
constants: desc.stage.constants.as_ref(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3178,6 +3179,7 @@ impl<A: HalApi> Device<A> {
|
|||||||
hal::ProgrammableStage {
|
hal::ProgrammableStage {
|
||||||
module: vertex_shader_module.raw(),
|
module: vertex_shader_module.raw(),
|
||||||
entry_point: &vertex_entry_point_name,
|
entry_point: &vertex_entry_point_name,
|
||||||
|
constants: stage_desc.constants.as_ref(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3237,6 +3239,7 @@ impl<A: HalApi> Device<A> {
|
|||||||
Some(hal::ProgrammableStage {
|
Some(hal::ProgrammableStage {
|
||||||
module: shader_module.raw(),
|
module: shader_module.raw(),
|
||||||
entry_point: &fragment_entry_point_name,
|
entry_point: &fragment_entry_point_name,
|
||||||
|
constants: fragment_state.stage.constants.as_ref(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
None => None,
|
None => None,
|
||||||
|
|||||||
@ -233,6 +233,14 @@ pub struct ProgrammableStageDescriptor<'a> {
|
|||||||
/// * If a single entry point associated with this stage must be in the shader, then proceed as
|
/// * If a single entry point associated with this stage must be in the shader, then proceed as
|
||||||
/// if `Some(…)` was specified with that entry point's name.
|
/// if `Some(…)` was specified with that entry point's name.
|
||||||
pub entry_point: Option<Cow<'a, str>>,
|
pub entry_point: Option<Cow<'a, str>>,
|
||||||
|
/// Specifies the values of pipeline-overridable constants in the shader module.
|
||||||
|
///
|
||||||
|
/// If an `@id` attribute was specified on the declaration,
|
||||||
|
/// the key must be the pipeline constant ID as a decimal ASCII number; if not,
|
||||||
|
/// the key must be the constant's identifier name.
|
||||||
|
///
|
||||||
|
/// The value may represent any of WGSL's concrete scalar types.
|
||||||
|
pub constants: Cow<'a, naga::back::PipelineConstants>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Number of implicit bind groups derived at pipeline creation.
|
/// Number of implicit bind groups derived at pipeline creation.
|
||||||
|
|||||||
@ -245,17 +245,20 @@ impl<A: hal::Api> Example<A> {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let constants = naga::back::PipelineConstants::default();
|
||||||
let pipeline_desc = hal::RenderPipelineDescriptor {
|
let pipeline_desc = hal::RenderPipelineDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
layout: &pipeline_layout,
|
layout: &pipeline_layout,
|
||||||
vertex_stage: hal::ProgrammableStage {
|
vertex_stage: hal::ProgrammableStage {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: "vs_main",
|
||||||
|
constants: &constants,
|
||||||
},
|
},
|
||||||
vertex_buffers: &[],
|
vertex_buffers: &[],
|
||||||
fragment_stage: Some(hal::ProgrammableStage {
|
fragment_stage: Some(hal::ProgrammableStage {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: "fs_main",
|
||||||
|
constants: &constants,
|
||||||
}),
|
}),
|
||||||
primitive: wgt::PrimitiveState {
|
primitive: wgt::PrimitiveState {
|
||||||
topology: wgt::PrimitiveTopology::TriangleStrip,
|
topology: wgt::PrimitiveTopology::TriangleStrip,
|
||||||
|
|||||||
@ -371,6 +371,7 @@ impl<A: hal::Api> Example<A> {
|
|||||||
stage: hal::ProgrammableStage {
|
stage: hal::ProgrammableStage {
|
||||||
module: &shader_module,
|
module: &shader_module,
|
||||||
entry_point: "main",
|
entry_point: "main",
|
||||||
|
constants: &Default::default(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,10 +222,13 @@ impl super::Device {
|
|||||||
//TODO: reuse the writer
|
//TODO: reuse the writer
|
||||||
let mut source = String::new();
|
let mut source = String::new();
|
||||||
let mut writer = hlsl::Writer::new(&mut source, &layout.naga_options);
|
let mut writer = hlsl::Writer::new(&mut source, &layout.naga_options);
|
||||||
|
let pipeline_options = hlsl::PipelineOptions {
|
||||||
|
constants: stage.constants.to_owned(),
|
||||||
|
};
|
||||||
let reflection_info = {
|
let reflection_info = {
|
||||||
profiling::scope!("naga::back::hlsl::write");
|
profiling::scope!("naga::back::hlsl::write");
|
||||||
writer
|
writer
|
||||||
.write(module, &stage.module.naga.info)
|
.write(module, &stage.module.naga.info, &pipeline_options)
|
||||||
.map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("HLSL: {e:?}")))?
|
.map_err(|e| crate::PipelineError::Linkage(stage_bit, format!("HLSL: {e:?}")))?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -218,6 +218,7 @@ impl super::Device {
|
|||||||
shader_stage: naga_stage,
|
shader_stage: naga_stage,
|
||||||
entry_point: stage.entry_point.to_string(),
|
entry_point: stage.entry_point.to_string(),
|
||||||
multiview: context.multiview,
|
multiview: context.multiview,
|
||||||
|
constants: stage.constants.to_owned(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let shader = &stage.module.naga;
|
let shader = &stage.module.naga;
|
||||||
|
|||||||
@ -1318,6 +1318,8 @@ pub struct ProgrammableStage<'a, A: Api> {
|
|||||||
/// The name of the entry point in the compiled shader. There must be a function with this name
|
/// The name of the entry point in the compiled shader. There must be a function with this name
|
||||||
/// in the shader.
|
/// in the shader.
|
||||||
pub entry_point: &'a str,
|
pub entry_point: &'a str,
|
||||||
|
/// Pipeline constants
|
||||||
|
pub constants: &'a naga::back::PipelineConstants,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rust gets confused about the impl requirements for `A`
|
// Rust gets confused about the impl requirements for `A`
|
||||||
@ -1326,6 +1328,7 @@ impl<A: Api> Clone for ProgrammableStage<'_, A> {
|
|||||||
Self {
|
Self {
|
||||||
module: self.module,
|
module: self.module,
|
||||||
entry_point: self.entry_point,
|
entry_point: self.entry_point,
|
||||||
|
constants: self.constants,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -112,6 +112,7 @@ impl super::Device {
|
|||||||
metal::MTLPrimitiveTopologyClass::Point => true,
|
metal::MTLPrimitiveTopologyClass::Point => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
|
constants: stage.constants.to_owned(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (source, info) = naga::back::msl::write_string(
|
let (source, info) = naga::back::msl::write_string(
|
||||||
|
|||||||
@ -734,6 +734,7 @@ impl super::Device {
|
|||||||
let pipeline_options = naga::back::spv::PipelineOptions {
|
let pipeline_options = naga::back::spv::PipelineOptions {
|
||||||
entry_point: stage.entry_point.to_string(),
|
entry_point: stage.entry_point.to_string(),
|
||||||
shader_stage: naga_stage,
|
shader_stage: naga_stage,
|
||||||
|
constants: stage.constants.to_owned(),
|
||||||
};
|
};
|
||||||
let needs_temp_options = !runtime_checks
|
let needs_temp_options = !runtime_checks
|
||||||
|| !binding_map.is_empty()
|
|| !binding_map.is_empty()
|
||||||
|
|||||||
@ -1143,6 +1143,7 @@ impl crate::Context for ContextWgpuCore {
|
|||||||
stage: pipe::ProgrammableStageDescriptor {
|
stage: pipe::ProgrammableStageDescriptor {
|
||||||
module: desc.vertex.module.id.into(),
|
module: desc.vertex.module.id.into(),
|
||||||
entry_point: Some(Borrowed(desc.vertex.entry_point)),
|
entry_point: Some(Borrowed(desc.vertex.entry_point)),
|
||||||
|
constants: Borrowed(desc.vertex.constants),
|
||||||
},
|
},
|
||||||
buffers: Borrowed(&vertex_buffers),
|
buffers: Borrowed(&vertex_buffers),
|
||||||
},
|
},
|
||||||
@ -1153,6 +1154,7 @@ impl crate::Context for ContextWgpuCore {
|
|||||||
stage: pipe::ProgrammableStageDescriptor {
|
stage: pipe::ProgrammableStageDescriptor {
|
||||||
module: frag.module.id.into(),
|
module: frag.module.id.into(),
|
||||||
entry_point: Some(Borrowed(frag.entry_point)),
|
entry_point: Some(Borrowed(frag.entry_point)),
|
||||||
|
constants: Borrowed(frag.constants),
|
||||||
},
|
},
|
||||||
targets: Borrowed(frag.targets),
|
targets: Borrowed(frag.targets),
|
||||||
}),
|
}),
|
||||||
@ -1201,6 +1203,7 @@ impl crate::Context for ContextWgpuCore {
|
|||||||
stage: pipe::ProgrammableStageDescriptor {
|
stage: pipe::ProgrammableStageDescriptor {
|
||||||
module: desc.module.id.into(),
|
module: desc.module.id.into(),
|
||||||
entry_point: Some(Borrowed(desc.entry_point)),
|
entry_point: Some(Borrowed(desc.entry_point)),
|
||||||
|
constants: Borrowed(desc.constants),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ use std::{
|
|||||||
any::Any,
|
any::Any,
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp::Ordering,
|
cmp::Ordering,
|
||||||
|
collections::HashMap,
|
||||||
error, fmt,
|
error, fmt,
|
||||||
future::Future,
|
future::Future,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
@ -1467,6 +1468,14 @@ pub struct VertexState<'a> {
|
|||||||
/// The name of the entry point in the compiled shader. There must be a function with this name
|
/// The name of the entry point in the compiled shader. There must be a function with this name
|
||||||
/// in the shader.
|
/// in the shader.
|
||||||
pub entry_point: &'a str,
|
pub entry_point: &'a str,
|
||||||
|
/// Specifies the values of pipeline-overridable constants in the shader module.
|
||||||
|
///
|
||||||
|
/// If an `@id` attribute was specified on the declaration,
|
||||||
|
/// the key must be the pipeline constant ID as a decimal ASCII number; if not,
|
||||||
|
/// the key must be the constant's identifier name.
|
||||||
|
///
|
||||||
|
/// The value may represent any of WGSL's concrete scalar types.
|
||||||
|
pub constants: &'a HashMap<String, f64>,
|
||||||
/// The format of any vertex buffers used with this pipeline.
|
/// The format of any vertex buffers used with this pipeline.
|
||||||
pub buffers: &'a [VertexBufferLayout<'a>],
|
pub buffers: &'a [VertexBufferLayout<'a>],
|
||||||
}
|
}
|
||||||
@ -1486,6 +1495,14 @@ pub struct FragmentState<'a> {
|
|||||||
/// The name of the entry point in the compiled shader. There must be a function with this name
|
/// The name of the entry point in the compiled shader. There must be a function with this name
|
||||||
/// in the shader.
|
/// in the shader.
|
||||||
pub entry_point: &'a str,
|
pub entry_point: &'a str,
|
||||||
|
/// Specifies the values of pipeline-overridable constants in the shader module.
|
||||||
|
///
|
||||||
|
/// If an `@id` attribute was specified on the declaration,
|
||||||
|
/// the key must be the pipeline constant ID as a decimal ASCII number; if not,
|
||||||
|
/// the key must be the constant's identifier name.
|
||||||
|
///
|
||||||
|
/// The value may represent any of WGSL's concrete scalar types.
|
||||||
|
pub constants: &'a HashMap<String, f64>,
|
||||||
/// The color state of the render targets.
|
/// The color state of the render targets.
|
||||||
pub targets: &'a [Option<ColorTargetState>],
|
pub targets: &'a [Option<ColorTargetState>],
|
||||||
}
|
}
|
||||||
@ -1575,6 +1592,14 @@ pub struct ComputePipelineDescriptor<'a> {
|
|||||||
/// The name of the entry point in the compiled shader. There must be a function with this name
|
/// The name of the entry point in the compiled shader. There must be a function with this name
|
||||||
/// and no return value in the shader.
|
/// and no return value in the shader.
|
||||||
pub entry_point: &'a str,
|
pub entry_point: &'a str,
|
||||||
|
/// Specifies the values of pipeline-overridable constants in the shader module.
|
||||||
|
///
|
||||||
|
/// If an `@id` attribute was specified on the declaration,
|
||||||
|
/// the key must be the pipeline constant ID as a decimal ASCII number; if not,
|
||||||
|
/// the key must be the constant's identifier name.
|
||||||
|
///
|
||||||
|
/// The value may represent any of WGSL's concrete scalar types.
|
||||||
|
pub constants: &'a HashMap<String, f64>,
|
||||||
}
|
}
|
||||||
#[cfg(send_sync)]
|
#[cfg(send_sync)]
|
||||||
static_assertions::assert_impl_all!(ComputePipelineDescriptor<'_>: Send, Sync);
|
static_assertions::assert_impl_all!(ComputePipelineDescriptor<'_>: Send, Sync);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user