mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
refactor: use include_wgsl!(…)
more (#6326)
This change uses `include_wgsl!(…)` in usages where an `include_str!("….wgsl")` was used to construct a `ShaderModuleDescriptor`'s `source, but the `label` was set to `None`. This should (1) showcase a nice idiomatic convenience we offer in our examples better, (2) make code more concise, and (3) get some automatically generated labels in diagnostics where it seems it won't hurt.
This commit is contained in:
parent
e7f891bf2b
commit
765c20235e
@ -142,6 +142,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).
|
|||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
- Removed some OpenGL and Vulkan references from `wgpu-types` documentation. Fixed Storage texel types in examples. By @Nelarius in [#6271](https://github.com/gfx-rs/wgpu/pull/6271)
|
- Removed some OpenGL and Vulkan references from `wgpu-types` documentation. Fixed Storage texel types in examples. By @Nelarius in [#6271](https://github.com/gfx-rs/wgpu/pull/6271)
|
||||||
|
- Used `wgpu::include_wgsl!(…)` more in examples and tests. By @ErichDonGubler in [#6326](https://github.com/gfx-rs/wgpu/pull/6326).
|
||||||
|
|
||||||
### Dependency Updates
|
### Dependency Updates
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// adapted from https://github.com/austinEng/webgpu-samples/blob/master/src/examples/computeBoids.ts
|
// adapted from https://github.com/austinEng/webgpu-samples/blob/master/src/examples/computeBoids.ts
|
||||||
|
|
||||||
use nanorand::{Rng, WyRand};
|
use nanorand::{Rng, WyRand};
|
||||||
use std::{borrow::Cow, mem::size_of};
|
use std::mem::size_of;
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
// number of boid particles to simulate
|
// number of boid particles to simulate
|
||||||
@ -43,14 +43,8 @@ impl crate::framework::Example for Example {
|
|||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
_queue: &wgpu::Queue,
|
_queue: &wgpu::Queue,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let compute_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let compute_shader = device.create_shader_module(wgpu::include_wgsl!("compute.wgsl"));
|
||||||
label: None,
|
let draw_shader = device.create_shader_module(wgpu::include_wgsl!("draw.wgsl"));
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("compute.wgsl"))),
|
|
||||||
});
|
|
||||||
let draw_shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("draw.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
// buffer for simulation parameters uniform
|
// buffer for simulation parameters uniform
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
const RENDER_TARGET_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
const RENDER_TARGET_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
||||||
|
|
||||||
struct Example {
|
struct Example {
|
||||||
@ -83,12 +81,8 @@ impl crate::framework::Example for Example {
|
|||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let shader_triangle_and_lines = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader_triangle_and_lines =
|
||||||
label: None,
|
device.create_shader_module(wgpu::include_wgsl!("triangle_and_lines.wgsl"));
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!(
|
|
||||||
"triangle_and_lines.wgsl"
|
|
||||||
))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let pipeline_triangle_conservative =
|
let pipeline_triangle_conservative =
|
||||||
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
@ -203,10 +197,7 @@ impl crate::framework::Example for Example {
|
|||||||
bind_group_layouts: &[&bind_group_layout],
|
bind_group_layouts: &[&bind_group_layout],
|
||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("upscale.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("upscale.wgsl"))),
|
|
||||||
});
|
|
||||||
(
|
(
|
||||||
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("Upscale"),
|
label: Some("Upscale"),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::{borrow::Cow, f32::consts, mem::size_of};
|
use std::{f32::consts, mem::size_of};
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -216,10 +216,7 @@ impl crate::framework::Example for Example {
|
|||||||
label: None,
|
label: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let vertex_buffers = [wgpu::VertexBufferLayout {
|
let vertex_buffers = [wgpu::VertexBufferLayout {
|
||||||
array_stride: vertex_size as wgpu::BufferAddress,
|
array_stride: vertex_size as wgpu::BufferAddress,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::Cow, mem::size_of_val, str::FromStr};
|
use std::{mem::size_of_val, str::FromStr};
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
// Indicates a u32 overflow in an intermediate Collatz value
|
// Indicates a u32 overflow in an intermediate Collatz value
|
||||||
@ -66,10 +66,7 @@ async fn execute_gpu_inner(
|
|||||||
numbers: &[u32],
|
numbers: &[u32],
|
||||||
) -> Option<Vec<u32>> {
|
) -> Option<Vec<u32>> {
|
||||||
// Loads the shader from WGSL
|
// Loads the shader from WGSL
|
||||||
let cs_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let cs_module = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Gets the size in bytes of the buffer.
|
// Gets the size in bytes of the buffer.
|
||||||
let size = size_of_val(numbers) as wgpu::BufferAddress;
|
let size = size_of_val(numbers) as wgpu::BufferAddress;
|
||||||
|
@ -56,10 +56,7 @@ async fn execute(
|
|||||||
let mut local_patient_workgroup_results = vec![0u32; result_vec_size];
|
let mut local_patient_workgroup_results = vec![0u32; result_vec_size];
|
||||||
let mut local_hasty_workgroup_results = local_patient_workgroup_results.clone();
|
let mut local_hasty_workgroup_results = local_patient_workgroup_results.clone();
|
||||||
|
|
||||||
let shaders_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shaders_module = device.create_shader_module(wgpu::include_wgsl!("shaders.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shaders.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let storage_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
let storage_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -41,10 +41,7 @@ async fn run() {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let storage_buffer_a = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
let storage_buffer_a = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::{borrow::Cow, f32::consts, mem::size_of};
|
use std::{f32::consts, mem::size_of};
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
const TEXTURE_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Rgba8UnormSrgb;
|
||||||
@ -81,10 +81,7 @@ impl Example {
|
|||||||
query_sets: &Option<QuerySets>,
|
query_sets: &Option<QuerySets>,
|
||||||
mip_count: u32,
|
mip_count: u32,
|
||||||
) {
|
) {
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("blit.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("blit.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("blit"),
|
label: Some("blit"),
|
||||||
@ -281,10 +278,7 @@ impl crate::framework::Example for Example {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create the render pipeline
|
// Create the render pipeline
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("draw.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("draw.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let draw_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
let draw_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
label: Some("draw"),
|
label: Some("draw"),
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
//! * Set the primitive_topology to PrimitiveTopology::LineList.
|
//! * Set the primitive_topology to PrimitiveTopology::LineList.
|
||||||
//! * Vertices and Indices describe the two points that make up a line.
|
//! * Vertices and Indices describe the two points that make up a line.
|
||||||
|
|
||||||
use std::{borrow::Cow, iter, mem::size_of};
|
use std::{iter, mem::size_of};
|
||||||
|
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
@ -156,10 +156,7 @@ impl crate::framework::Example for Example {
|
|||||||
|
|
||||||
let sample_count = max_sample_count;
|
let sample_count = max_sample_count;
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -28,10 +28,7 @@ async fn run(_path: Option<String>) {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let render_target = device.create_texture(&wgpu::TextureDescriptor {
|
let render_target = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -180,12 +180,7 @@ impl WgpuContext {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Our shader, kindly compiled with Naga.
|
// Our shader, kindly compiled with Naga.
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!(
|
|
||||||
"shader.wgsl"
|
|
||||||
))),
|
|
||||||
});
|
|
||||||
|
|
||||||
// This is where the GPU will read from and write to.
|
// This is where the GPU will read from and write to.
|
||||||
let storage_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
let storage_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::Cow, f32::consts, iter, mem::size_of, ops::Range, sync::Arc};
|
use std::{f32::consts, iter, mem::size_of, ops::Range, sync::Arc};
|
||||||
|
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use wgpu::util::{align_to, DeviceExt};
|
use wgpu::util::{align_to, DeviceExt};
|
||||||
@ -447,10 +447,7 @@ impl crate::framework::Example for Example {
|
|||||||
attributes: &vertex_attr,
|
attributes: &vertex_attr,
|
||||||
};
|
};
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let shadow_pass = {
|
let shadow_pass = {
|
||||||
let uniform_size = size_of::<GlobalUniforms>() as wgpu::BufferAddress;
|
let uniform_size = size_of::<GlobalUniforms>() as wgpu::BufferAddress;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::{borrow::Cow, f32::consts, mem::size_of};
|
use std::{f32::consts, mem::size_of};
|
||||||
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
|
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
|
||||||
|
|
||||||
const IMAGE_SIZE: u32 = 256;
|
const IMAGE_SIZE: u32 = 256;
|
||||||
@ -168,10 +168,7 @@ impl crate::framework::Example for Example {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Create the render pipeline
|
// Create the render pipeline
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let camera = Camera {
|
let camera = Camera {
|
||||||
screen_size: (config.width, config.height),
|
screen_size: (config.width, config.height),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::{borrow::Cow, mem};
|
use std::mem;
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -103,10 +103,7 @@ impl<const SRGB: bool> crate::framework::Example for Example<SRGB> {
|
|||||||
label: None,
|
label: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let vertex_buffers = [wgpu::VertexBufferLayout {
|
let vertex_buffers = [wgpu::VertexBufferLayout {
|
||||||
array_stride: vertex_size as wgpu::BufferAddress,
|
array_stride: vertex_size as wgpu::BufferAddress,
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
@ -53,10 +52,7 @@ impl crate::framework::Example for Example {
|
|||||||
push_constant_ranges: &[],
|
push_constant_ranges: &[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let vertex_buffers = [wgpu::VertexBufferLayout {
|
let vertex_buffers = [wgpu::VertexBufferLayout {
|
||||||
array_stride: vertex_size as wgpu::BufferAddress,
|
array_stride: vertex_size as wgpu::BufferAddress,
|
||||||
|
@ -44,10 +44,7 @@ async fn run(_path: Option<String>) {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let storage_texture = device.create_texture(&wgpu::TextureDescriptor {
|
let storage_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
|
@ -239,10 +239,7 @@ fn submit_render_and_compute_pass_with_queries(
|
|||||||
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
|
||||||
|
|
||||||
let mut queries = Queries::new(device, QueryResults::NUM_QUERIES);
|
let mut queries = Queries::new(device, QueryResults::NUM_QUERIES);
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
if device
|
if device
|
||||||
.features()
|
.features()
|
||||||
|
@ -122,12 +122,7 @@ impl WgpuContext {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let shader = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let shader = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!(
|
|
||||||
"shader.wgsl"
|
|
||||||
))),
|
|
||||||
});
|
|
||||||
|
|
||||||
// (2)
|
// (2)
|
||||||
let uniform_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
let uniform_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
@ -3,7 +3,7 @@ mod point_gen;
|
|||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use glam::Vec3;
|
use glam::Vec3;
|
||||||
use nanorand::{Rng, WyRand};
|
use nanorand::{Rng, WyRand};
|
||||||
use std::{borrow::Cow, f32::consts, iter, mem::size_of};
|
use std::{f32::consts, iter, mem::size_of};
|
||||||
use wgpu::util::DeviceExt;
|
use wgpu::util::DeviceExt;
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -493,14 +493,8 @@ impl crate::framework::Example for Example {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Upload/compile them to GPU code.
|
// Upload/compile them to GPU code.
|
||||||
let terrain_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let terrain_module = device.create_shader_module(wgpu::include_wgsl!("terrain.wgsl"));
|
||||||
label: Some("terrain"),
|
let water_module = device.create_shader_module(wgpu::include_wgsl!("water.wgsl"));
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("terrain.wgsl"))),
|
|
||||||
});
|
|
||||||
let water_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
|
||||||
label: Some("water"),
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("water.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the render pipelines. These describe how the data will flow through the GPU, and what
|
// Create the render pipelines. These describe how the data will flow through the GPU, and what
|
||||||
// constraints and modifiers it will have.
|
// constraints and modifiers it will have.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::Cow, mem::size_of};
|
use std::mem::size_of;
|
||||||
use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration, TestParameters};
|
use wgpu_test::{gpu_test, FailureCase, GpuTestConfiguration, TestParameters};
|
||||||
|
|
||||||
#[gpu_test]
|
#[gpu_test]
|
||||||
@ -25,10 +25,7 @@ static OCCLUSION_QUERY: GpuTestConfiguration = GpuTestConfiguration::new()
|
|||||||
// Setup pipeline using a simple shader with hardcoded vertices
|
// Setup pipeline using a simple shader with hardcoded vertices
|
||||||
let shader = ctx
|
let shader = ctx
|
||||||
.device
|
.device
|
||||||
.create_shader_module(wgpu::ShaderModuleDescriptor {
|
.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: Some("Shader module"),
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
let pipeline = ctx
|
let pipeline = ctx
|
||||||
.device
|
.device
|
||||||
.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::Cow, num::NonZeroU32};
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
use wgpu_test::{gpu_test, image::ReadbackBuffers, GpuTestConfiguration, TestParameters};
|
use wgpu_test::{gpu_test, image::ReadbackBuffers, GpuTestConfiguration, TestParameters};
|
||||||
|
|
||||||
@ -53,10 +53,7 @@ static PARTIALLY_BOUNDED_ARRAY: GpuTestConfiguration = GpuTestConfiguration::new
|
|||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
let cs_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let cs_module = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some("main"),
|
label: Some("main"),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::{borrow::Cow, mem::size_of, num::NonZeroU64};
|
use std::{mem::size_of, num::NonZeroU64};
|
||||||
|
|
||||||
use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters};
|
use wgpu_test::{gpu_test, GpuTestConfiguration, TestParameters};
|
||||||
|
|
||||||
@ -56,10 +56,7 @@ static SUBGROUP_OPERATIONS: GpuTestConfiguration = GpuTestConfiguration::new()
|
|||||||
}],
|
}],
|
||||||
});
|
});
|
||||||
|
|
||||||
let cs_module = device.create_shader_module(wgpu::ShaderModuleDescriptor {
|
let cs_module = device.create_shader_module(wgpu::include_wgsl!("shader.wgsl"));
|
||||||
label: None,
|
|
||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
|
||||||
});
|
|
||||||
|
|
||||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||||
label: Some("main"),
|
label: Some("main"),
|
||||||
|
Loading…
Reference in New Issue
Block a user