mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[rs] Merge #477
477: Add more cows r=cwfitzgerald,kvark a=Kimundi Co-authored-by: Marvin Löbel <loebel.marvin@gmail.com>
This commit is contained in:
@@ -141,7 +141,7 @@ impl Example {
|
||||
});
|
||||
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
label: Some("mip"),
|
||||
label: Some(Borrowed("mip")),
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
@@ -154,7 +154,7 @@ impl Example {
|
||||
let views = (0..mip_count)
|
||||
.map(|mip| {
|
||||
texture.create_view(&wgpu::TextureViewDescriptor {
|
||||
label: Some("mip"),
|
||||
label: Some(Borrowed("mip")),
|
||||
format: TEXTURE_FORMAT,
|
||||
dimension: wgpu::TextureViewDimension::D2,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#[path = "../framework.rs"]
|
||||
mod framework;
|
||||
|
||||
use std::{borrow::Cow, iter};
|
||||
use std::{borrow::Cow::Borrowed, iter};
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
@@ -53,11 +53,11 @@ impl Example {
|
||||
layout: &pipeline_layout,
|
||||
vertex_stage: wgpu::ProgrammableStageDescriptor {
|
||||
module: vs_module,
|
||||
entry_point: Cow::Borrowed("main"),
|
||||
entry_point: Borrowed("main"),
|
||||
},
|
||||
fragment_stage: Some(wgpu::ProgrammableStageDescriptor {
|
||||
module: fs_module,
|
||||
entry_point: Cow::Borrowed("main"),
|
||||
entry_point: Borrowed("main"),
|
||||
}),
|
||||
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
@@ -65,7 +65,7 @@ impl Example {
|
||||
..Default::default()
|
||||
}),
|
||||
primitive_topology: wgpu::PrimitiveTopology::LineList,
|
||||
color_states: Cow::Borrowed(&[wgpu::ColorStateDescriptor {
|
||||
color_states: Borrowed(&[wgpu::ColorStateDescriptor {
|
||||
format: sc_desc.format,
|
||||
color_blend: wgpu::BlendDescriptor::REPLACE,
|
||||
alpha_blend: wgpu::BlendDescriptor::REPLACE,
|
||||
@@ -74,10 +74,10 @@ impl Example {
|
||||
depth_stencil_state: None,
|
||||
vertex_state: wgpu::VertexStateDescriptor {
|
||||
index_format: wgpu::IndexFormat::Uint16,
|
||||
vertex_buffers: Cow::Borrowed(&[wgpu::VertexBufferDescriptor {
|
||||
vertex_buffers: Borrowed(&[wgpu::VertexBufferDescriptor {
|
||||
stride: std::mem::size_of::<Vertex>() as wgpu::BufferAddress,
|
||||
step_mode: wgpu::InputStepMode::Vertex,
|
||||
attributes: Cow::Borrowed(&wgpu::vertex_attr_array![0 => Float2, 1 => Float4]),
|
||||
attributes: Borrowed(&wgpu::vertex_attr_array![0 => Float2, 1 => Float4]),
|
||||
}]),
|
||||
},
|
||||
sample_count,
|
||||
@@ -87,7 +87,7 @@ impl Example {
|
||||
let mut encoder =
|
||||
device.create_render_bundle_encoder(&wgpu::RenderBundleEncoderDescriptor {
|
||||
label: None,
|
||||
color_formats: Cow::Borrowed(&[sc_desc.format]),
|
||||
color_formats: Borrowed(&[sc_desc.format]),
|
||||
depth_stencil_format: None,
|
||||
sample_count,
|
||||
});
|
||||
@@ -95,7 +95,7 @@ impl Example {
|
||||
encoder.set_vertex_buffer(0, vertex_buffer.slice(..));
|
||||
encoder.draw(0..vertex_count, 0..1);
|
||||
encoder.finish(&wgpu::RenderBundleDescriptor {
|
||||
label: Some("main"),
|
||||
label: Some(Borrowed("main")),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ impl framework::Example for Example {
|
||||
let fs_module = device.create_shader_module(wgpu::include_spirv!("shader.frag.spv"));
|
||||
|
||||
let pipeline_layout = device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
|
||||
bind_group_layouts: Cow::Borrowed(&[]),
|
||||
push_constant_ranges: Cow::Borrowed(&[]),
|
||||
bind_group_layouts: Borrowed(&[]),
|
||||
push_constant_ranges: Borrowed(&[]),
|
||||
});
|
||||
|
||||
let multisampled_framebuffer =
|
||||
@@ -274,7 +274,7 @@ impl framework::Example for Example {
|
||||
|
||||
encoder
|
||||
.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
color_attachments: Cow::Borrowed(&[rpass_color_attachment]),
|
||||
color_attachments: Borrowed(&[rpass_color_attachment]),
|
||||
depth_stencil_attachment: None,
|
||||
})
|
||||
.execute_bundles(iter::once(&self.bundle));
|
||||
|
||||
@@ -350,7 +350,7 @@ impl framework::Example for Example {
|
||||
|
||||
// Create other resources
|
||||
let shadow_sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
label: Some("shadow"),
|
||||
label: Some(Borrowed("shadow")),
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
@@ -375,7 +375,7 @@ impl framework::Example for Example {
|
||||
let mut shadow_target_views = (0..2)
|
||||
.map(|i| {
|
||||
Some(shadow_texture.create_view(&wgpu::TextureViewDescriptor {
|
||||
label: Some("shadow"),
|
||||
label: Some(Borrowed("shadow")),
|
||||
format: Self::SHADOW_FORMAT,
|
||||
dimension: wgpu::TextureViewDimension::D2,
|
||||
aspect: wgpu::TextureAspect::All,
|
||||
|
||||
@@ -150,11 +150,11 @@ impl framework::Example for Example {
|
||||
label: None,
|
||||
};
|
||||
let red_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("red"),
|
||||
label: Some(Borrowed("red")),
|
||||
..texture_descriptor
|
||||
});
|
||||
let green_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("green"),
|
||||
label: Some(Borrowed("green")),
|
||||
..texture_descriptor
|
||||
});
|
||||
|
||||
@@ -321,7 +321,7 @@ impl framework::Example for Example {
|
||||
_spawner: &impl futures::task::LocalSpawn,
|
||||
) {
|
||||
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||
label: Some("primary"),
|
||||
label: Some(Borrowed("primary")),
|
||||
});
|
||||
|
||||
let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
|
||||
|
||||
@@ -195,7 +195,7 @@ impl Example {
|
||||
};
|
||||
|
||||
let reflection_texture = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("Reflection Render Texture"),
|
||||
label: Some(Borrowed("Reflection Render Texture")),
|
||||
size: texture_extent,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
@@ -207,7 +207,7 @@ impl Example {
|
||||
});
|
||||
|
||||
let draw_depth_buffer = device.create_texture(&wgpu::TextureDescriptor {
|
||||
label: Some("Depth Buffer"),
|
||||
label: Some(Borrowed("Depth Buffer")),
|
||||
size: texture_extent,
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
@@ -219,7 +219,7 @@ impl Example {
|
||||
});
|
||||
|
||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||
label: Some("Texture Sampler"),
|
||||
label: Some(Borrowed("Texture Sampler")),
|
||||
address_mode_u: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_v: wgpu::AddressMode::ClampToEdge,
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
@@ -424,21 +424,21 @@ impl framework::Example for Example {
|
||||
});
|
||||
|
||||
let water_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("Water Uniforms"),
|
||||
label: Some(Borrowed("Water Uniforms")),
|
||||
size: mem::size_of::<WaterUniforms>() as _,
|
||||
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
|
||||
mapped_at_creation: false,
|
||||
});
|
||||
|
||||
let terrain_normal_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("Normal Terrain Uniforms"),
|
||||
label: Some(Borrowed("Normal Terrain Uniforms")),
|
||||
size: mem::size_of::<TerrainUniforms>() as _,
|
||||
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
|
||||
mapped_at_creation: false,
|
||||
});
|
||||
|
||||
let terrain_flipped_uniform_buf = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("Flipped Terrain Uniforms"),
|
||||
label: Some(Borrowed("Flipped Terrain Uniforms")),
|
||||
size: mem::size_of::<TerrainUniforms>() as _,
|
||||
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
|
||||
mapped_at_creation: false,
|
||||
@@ -710,7 +710,7 @@ impl framework::Example for Example {
|
||||
// The encoder provides a way to turn our instructions here, into
|
||||
// a command buffer the GPU can understand.
|
||||
let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
|
||||
label: Some("Main Command Encoder"),
|
||||
label: Some(Borrowed("Main Command Encoder")),
|
||||
});
|
||||
|
||||
// First pass: render the reflection.
|
||||
|
||||
@@ -1052,7 +1052,7 @@ impl crate::Context for Context {
|
||||
) -> Self::BufferId {
|
||||
let mut mapped_desc =
|
||||
web_sys::GpuBufferDescriptor::new(desc.size as f64, desc.usage.bits());
|
||||
if let Some(label) = desc.label {
|
||||
if let Some(ref label) = desc.label {
|
||||
mapped_desc.label(label);
|
||||
}
|
||||
Sendable(device.0.create_buffer(&mapped_desc))
|
||||
@@ -1068,7 +1068,7 @@ impl crate::Context for Context {
|
||||
&map_extent_3d(desc.size),
|
||||
desc.usage.bits(),
|
||||
);
|
||||
if let Some(label) = desc.label {
|
||||
if let Some(ref label) = desc.label {
|
||||
mapped_desc.label(label);
|
||||
}
|
||||
mapped_desc.dimension(map_texture_dimension(desc.dimension));
|
||||
@@ -1104,7 +1104,7 @@ impl crate::Context for Context {
|
||||
desc: &CommandEncoderDescriptor,
|
||||
) -> Self::CommandEncoderId {
|
||||
let mut mapped_desc = web_sys::GpuCommandEncoderDescriptor::new();
|
||||
if let Some(label) = desc.label {
|
||||
if let Some(ref label) = desc.label {
|
||||
mapped_desc.label(label);
|
||||
}
|
||||
device
|
||||
|
||||
@@ -890,23 +890,23 @@ pub type RequestAdapterOptions<'a> = RequestAdapterOptionsBase<&'a Surface>;
|
||||
|
||||
pub use wgt::BufferDescriptor as BufferDescriptorBase;
|
||||
/// Describes a [`Buffer`].
|
||||
pub type BufferDescriptor<'a> = BufferDescriptorBase<Option<&'a str>>;
|
||||
pub type BufferDescriptor<'a> = BufferDescriptorBase<Option<Cow<'a, str>>>;
|
||||
|
||||
pub use wgt::CommandEncoderDescriptor as CommandEncoderDescriptorBase;
|
||||
/// Describes a [`CommandEncoder`].
|
||||
pub type CommandEncoderDescriptor<'a> = CommandEncoderDescriptorBase<Option<&'a str>>;
|
||||
pub type CommandEncoderDescriptor<'a> = CommandEncoderDescriptorBase<Option<Cow<'a, str>>>;
|
||||
|
||||
pub use wgt::RenderBundleDescriptor as RenderBundleDescriptorBase;
|
||||
/// Describes a [`RenderBundle`].
|
||||
pub type RenderBundleDescriptor<'a> = RenderBundleDescriptorBase<Option<&'a str>>;
|
||||
pub type RenderBundleDescriptor<'a> = RenderBundleDescriptorBase<Option<Cow<'a, str>>>;
|
||||
|
||||
pub use wgt::TextureDescriptor as TextureDescriptorBase;
|
||||
/// Describes a [`Texture`].
|
||||
pub type TextureDescriptor<'a> = TextureDescriptorBase<Option<&'a str>>;
|
||||
pub type TextureDescriptor<'a> = TextureDescriptorBase<Option<Cow<'a, str>>>;
|
||||
|
||||
pub use wgt::TextureViewDescriptor as TextureViewDescriptorBase;
|
||||
/// Describes a [`TextureView`].
|
||||
pub type TextureViewDescriptor<'a> = TextureViewDescriptorBase<Option<&'a str>>;
|
||||
pub type TextureViewDescriptor<'a> = TextureViewDescriptorBase<Option<Cow<'a, str>>>;
|
||||
|
||||
pub use wgt::PipelineLayoutDescriptor as PipelineLayoutDescriptorBase;
|
||||
/// Describes a [`PipelineLayout`].
|
||||
@@ -914,7 +914,7 @@ pub type PipelineLayoutDescriptor<'a> = PipelineLayoutDescriptorBase<'a, &'a Bin
|
||||
|
||||
pub use wgt::SamplerDescriptor as SamplerDescriptorBase;
|
||||
/// Describes a [`Sampler`].
|
||||
pub type SamplerDescriptor<'a> = SamplerDescriptorBase<Option<&'a str>>;
|
||||
pub type SamplerDescriptor<'a> = SamplerDescriptorBase<Option<Cow<'a, str>>>;
|
||||
|
||||
pub use wgt::BindGroupEntry as BindGroupEntryBase;
|
||||
/// Bindable resource and the slot to bind it to.
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{
|
||||
CommandEncoder, CommandEncoderDescriptor, Device, MapMode,
|
||||
};
|
||||
use futures::{future::join_all, FutureExt};
|
||||
use std::{future::Future, mem, sync::mpsc};
|
||||
use std::{borrow::Cow::Borrowed, future::Future, mem, sync::mpsc};
|
||||
|
||||
struct Chunk {
|
||||
buffer: Buffer,
|
||||
@@ -77,7 +77,7 @@ impl StagingBelt {
|
||||
wgc::span!(_guard, INFO, "Creating chunk of size {}", size);
|
||||
Chunk {
|
||||
buffer: device.create_buffer(&BufferDescriptor {
|
||||
label: Some("staging"),
|
||||
label: Some(Borrowed("staging")),
|
||||
size,
|
||||
usage: BufferUsage::MAP_WRITE | BufferUsage::COPY_SRC,
|
||||
mapped_at_creation: true,
|
||||
|
||||
Reference in New Issue
Block a user