mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
update wgpu
This commit is contained in:
parent
216c13cdc4
commit
732efdacbd
5 changed files with 127 additions and 133 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -6955,7 +6955,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-core"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu#430b29d781200009ef02839e41136718ff62456a"
|
||||
source = "git+https://github.com/gfx-rs/wgpu#7e8b51b4286bd9452567eb1a56edb8e9b7c7f684"
|
||||
dependencies = [
|
||||
"arrayvec 0.5.1",
|
||||
"bitflags",
|
||||
|
@ -6982,7 +6982,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "wgpu-types"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/gfx-rs/wgpu#430b29d781200009ef02839e41136718ff62456a"
|
||||
source = "git+https://github.com/gfx-rs/wgpu#7e8b51b4286bd9452567eb1a56edb8e9b7c7f684"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"serde",
|
||||
|
|
|
@ -73,7 +73,7 @@ use std::collections::HashMap;
|
|||
use std::ptr::NonNull;
|
||||
use std::rc::Rc;
|
||||
use webgpu::wgpu::{
|
||||
binding_model as wgpu_bind, command::RenderBundleEncoder, pipeline as wgpu_pipe,
|
||||
binding_model as wgpu_bind, command as wgpu_com, pipeline as wgpu_pipe, resource as wgpu_res,
|
||||
};
|
||||
use webgpu::{self, identity::WebGPUOpResult, wgt, ErrorScopeId, WebGPU, WebGPURequest};
|
||||
|
||||
|
@ -320,9 +320,14 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer
|
||||
fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> DomRoot<GPUBuffer> {
|
||||
let desc = wgt::BufferUsage::from_bits(descriptor.usage).map(|usg| wgt::BufferDescriptor {
|
||||
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
|
||||
size: descriptor.size,
|
||||
let desc =
|
||||
wgt::BufferUsage::from_bits(descriptor.usage).map(|usg| wgpu_res::BufferDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|s| Cow::Owned(s.to_string())),
|
||||
size: descriptor.size as wgt::BufferAddress,
|
||||
usage: usg,
|
||||
mapped_at_creation: descriptor.mappedAtCreation,
|
||||
});
|
||||
|
@ -464,14 +469,19 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
},
|
||||
};
|
||||
|
||||
wgt::BindGroupLayoutEntry::new(bind.binding, visibility, ty)
|
||||
wgt::BindGroupLayoutEntry {
|
||||
binding: bind.binding,
|
||||
visibility: visibility,
|
||||
ty,
|
||||
count: None,
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let scope_id = self.use_current_scope();
|
||||
|
||||
let desc = if valid {
|
||||
Some(wgt::BindGroupLayoutDescriptor {
|
||||
Some(wgpu_bind::BindGroupLayoutDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
|
@ -518,7 +528,12 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
&self,
|
||||
descriptor: &GPUPipelineLayoutDescriptor,
|
||||
) -> DomRoot<GPUPipelineLayout> {
|
||||
let desc = wgt::PipelineLayoutDescriptor {
|
||||
let desc = wgpu_bind::PipelineLayoutDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|s| Cow::Owned(s.to_string())),
|
||||
bind_group_layouts: Cow::Owned(
|
||||
descriptor
|
||||
.bindGroupLayouts
|
||||
|
@ -673,7 +688,13 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
let scope_id = self.use_current_scope();
|
||||
|
||||
let desc = wgpu_pipe::ComputePipelineDescriptor {
|
||||
layout: descriptor.parent.layout.id().0,
|
||||
label: descriptor
|
||||
.parent
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|s| Cow::Owned(s.to_string())),
|
||||
layout: Some(descriptor.parent.layout.id().0),
|
||||
compute_stage: wgpu_pipe::ProgrammableStageDescriptor {
|
||||
module: descriptor.computeStage.module.id().0,
|
||||
entry_point: Cow::Owned(descriptor.computeStage.entryPoint.to_string()),
|
||||
|
@ -718,7 +739,11 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
WebGPURequest::CreateCommandEncoder {
|
||||
device_id: self.device.0,
|
||||
command_encoder_id,
|
||||
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|l| Cow::Owned(l.to_string())),
|
||||
},
|
||||
))
|
||||
.expect("Failed to create WebGPU command encoder");
|
||||
|
@ -739,8 +764,12 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> DomRoot<GPUTexture> {
|
||||
let size = convert_texture_size_to_dict(&descriptor.size);
|
||||
let desc =
|
||||
wgt::TextureUsage::from_bits(descriptor.usage).map(|usg| wgt::TextureDescriptor {
|
||||
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
|
||||
wgt::TextureUsage::from_bits(descriptor.usage).map(|usg| wgpu_res::TextureDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|l| Cow::Owned(l.to_string())),
|
||||
size: convert_texture_size_to_wgt(&size),
|
||||
mip_level_count: descriptor.mipLevelCount,
|
||||
sample_count: descriptor.sampleCount,
|
||||
|
@ -803,11 +832,17 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
.lock()
|
||||
.create_sampler_id(self.device.0.backend());
|
||||
let compare_enable = descriptor.compare.is_some();
|
||||
let desc = wgt::SamplerDescriptor {
|
||||
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
|
||||
address_mode_u: convert_address_mode(descriptor.addressModeU),
|
||||
address_mode_v: convert_address_mode(descriptor.addressModeV),
|
||||
address_mode_w: convert_address_mode(descriptor.addressModeW),
|
||||
let desc = wgpu_res::SamplerDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|s| Cow::Owned(s.to_string())),
|
||||
address_modes: [
|
||||
convert_address_mode(descriptor.addressModeU),
|
||||
convert_address_mode(descriptor.addressModeV),
|
||||
convert_address_mode(descriptor.addressModeW),
|
||||
],
|
||||
mag_filter: convert_filter_mode(descriptor.magFilter),
|
||||
min_filter: convert_filter_mode(descriptor.minFilter),
|
||||
mipmap_filter: convert_filter_mode(descriptor.mipmapFilter),
|
||||
|
@ -872,7 +907,13 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
let desc = if valid {
|
||||
Some(wgpu_pipe::RenderPipelineDescriptor {
|
||||
layout: descriptor.parent.layout.id().0,
|
||||
label: descriptor
|
||||
.parent
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|s| Cow::Owned(s.to_string())),
|
||||
layout: Some(descriptor.parent.layout.id().0),
|
||||
vertex_stage: wgpu_pipe::ProgrammableStageDescriptor {
|
||||
module: descriptor.vertexStage.module.id().0,
|
||||
entry_point: Cow::Owned(descriptor.vertexStage.entryPoint.to_string()),
|
||||
|
@ -911,23 +952,27 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
format: convert_texture_format(dss_desc.format),
|
||||
depth_write_enabled: dss_desc.depthWriteEnabled,
|
||||
depth_compare: convert_compare_function(dss_desc.depthCompare),
|
||||
stencil_front: wgt::StencilStateFaceDescriptor {
|
||||
stencil: wgt::StencilStateDescriptor {
|
||||
front: wgt::StencilStateFaceDescriptor {
|
||||
compare: convert_compare_function(dss_desc.stencilFront.compare),
|
||||
fail_op: convert_stencil_op(dss_desc.stencilFront.failOp),
|
||||
depth_fail_op: convert_stencil_op(dss_desc.stencilFront.depthFailOp),
|
||||
depth_fail_op: convert_stencil_op(
|
||||
dss_desc.stencilFront.depthFailOp,
|
||||
),
|
||||
pass_op: convert_stencil_op(dss_desc.stencilFront.passOp),
|
||||
},
|
||||
stencil_back: wgt::StencilStateFaceDescriptor {
|
||||
back: wgt::StencilStateFaceDescriptor {
|
||||
compare: convert_compare_function(dss_desc.stencilBack.compare),
|
||||
fail_op: convert_stencil_op(dss_desc.stencilBack.failOp),
|
||||
depth_fail_op: convert_stencil_op(dss_desc.stencilBack.depthFailOp),
|
||||
pass_op: convert_stencil_op(dss_desc.stencilBack.passOp),
|
||||
},
|
||||
stencil_read_mask: dss_desc.stencilReadMask,
|
||||
stencil_write_mask: dss_desc.stencilWriteMask,
|
||||
read_mask: dss_desc.stencilReadMask,
|
||||
write_mask: dss_desc.stencilWriteMask,
|
||||
},
|
||||
}
|
||||
}),
|
||||
vertex_state: wgt::VertexStateDescriptor {
|
||||
vertex_state: wgpu_pipe::VertexStateDescriptor {
|
||||
index_format: match vs_desc.indexFormat {
|
||||
GPUIndexFormat::Uint16 => wgt::IndexFormat::Uint16,
|
||||
GPUIndexFormat::Uint32 => wgt::IndexFormat::Uint32,
|
||||
|
@ -936,7 +981,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
vs_desc
|
||||
.vertexBuffers
|
||||
.iter()
|
||||
.map(|buffer| wgt::VertexBufferDescriptor {
|
||||
.map(|buffer| wgpu_pipe::VertexBufferDescriptor {
|
||||
stride: buffer.arrayStride,
|
||||
step_mode: match buffer.stepMode {
|
||||
GPUInputStepMode::Vertex => wgt::InputStepMode::Vertex,
|
||||
|
@ -1002,7 +1047,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
&self,
|
||||
descriptor: &GPURenderBundleEncoderDescriptor,
|
||||
) -> DomRoot<GPURenderBundleEncoder> {
|
||||
let desc = wgt::RenderBundleEncoderDescriptor {
|
||||
let desc = wgpu_com::RenderBundleEncoderDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
|
@ -1022,7 +1067,8 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
};
|
||||
|
||||
// Handle error gracefully
|
||||
let render_bundle_encoder = RenderBundleEncoder::new(&desc, self.device.0, None).unwrap();
|
||||
let render_bundle_encoder =
|
||||
wgpu_com::RenderBundleEncoder::new(&desc, self.device.0, None).unwrap();
|
||||
|
||||
GPURenderBundleEncoder::new(
|
||||
&self.global(),
|
||||
|
|
|
@ -15,6 +15,7 @@ use crate::dom::gpudevice::GPUDevice;
|
|||
use crate::dom::gpurenderbundle::GPURenderBundle;
|
||||
use crate::dom::gpurenderpipeline::GPURenderPipeline;
|
||||
use dom_struct::dom_struct;
|
||||
use std::borrow::Cow;
|
||||
use webgpu::{
|
||||
wgpu::command::{bundle_ffi as wgpu_bundle, RenderBundleEncoder},
|
||||
wgt, WebGPU, WebGPURenderBundle, WebGPURequest,
|
||||
|
@ -184,7 +185,11 @@ impl GPURenderBundleEncoderMethods for GPURenderBundleEncoder {
|
|||
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderbundleencoder-finish
|
||||
fn Finish(&self, descriptor: &GPURenderBundleDescriptor) -> DomRoot<GPURenderBundle> {
|
||||
let desc = wgt::RenderBundleDescriptor {
|
||||
label: descriptor.parent.label.as_ref().map(|s| s.to_string()),
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|l| Cow::Owned(l.to_string())),
|
||||
};
|
||||
let encoder = self.render_bundle_encoder.borrow_mut().take().unwrap();
|
||||
let render_bundle_id = self
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::dom::bindings::codegen::Bindings::GPUTextureBinding::{
|
|||
GPUExtent3DDict, GPUTextureDimension, GPUTextureFormat, GPUTextureMethods,
|
||||
};
|
||||
use crate::dom::bindings::codegen::Bindings::GPUTextureViewBinding::{
|
||||
GPUTextureAspect, GPUTextureViewDescriptor, GPUTextureViewDimension,
|
||||
GPUTextureAspect, GPUTextureViewDescriptor,
|
||||
};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject, Reflector};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
|
@ -16,10 +16,12 @@ use crate::dom::globalscope::GlobalScope;
|
|||
use crate::dom::gpudevice::{convert_texture_format, convert_texture_view_dimension, GPUDevice};
|
||||
use crate::dom::gputextureview::GPUTextureView;
|
||||
use dom_struct::dom_struct;
|
||||
use std::borrow::Cow;
|
||||
use std::num::NonZeroU32;
|
||||
use std::string::String;
|
||||
use webgpu::{
|
||||
identity::WebGPUOpResult, wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView,
|
||||
identity::WebGPUOpResult, wgpu::resource, wgt, WebGPU, WebGPURequest, WebGPUTexture,
|
||||
WebGPUTextureView,
|
||||
};
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -123,23 +125,6 @@ impl GPUTextureMethods for GPUTexture {
|
|||
|
||||
/// https://gpuweb.github.io/gpuweb/#dom-gputexture-createview
|
||||
fn CreateView(&self, descriptor: &GPUTextureViewDescriptor) -> DomRoot<GPUTextureView> {
|
||||
let dimension = if let Some(d) = descriptor.dimension {
|
||||
d
|
||||
} else {
|
||||
match self.dimension {
|
||||
GPUTextureDimension::_1d => GPUTextureViewDimension::_1d,
|
||||
GPUTextureDimension::_2d => {
|
||||
if self.texture_size.depth > 1 && descriptor.arrayLayerCount.is_none() {
|
||||
GPUTextureViewDimension::_2d_array
|
||||
} else {
|
||||
GPUTextureViewDimension::_2d
|
||||
}
|
||||
},
|
||||
GPUTextureDimension::_3d => GPUTextureViewDimension::_3d,
|
||||
}
|
||||
};
|
||||
|
||||
let format = descriptor.format.unwrap_or(self.format);
|
||||
let scope_id = self.device.use_current_scope();
|
||||
let mut valid = true;
|
||||
let level_count = descriptor.mipLevelCount.and_then(|count| {
|
||||
|
@ -156,14 +141,16 @@ impl GPUTextureMethods for GPUTexture {
|
|||
});
|
||||
|
||||
let desc = if valid {
|
||||
Some(wgt::TextureViewDescriptor {
|
||||
Some(resource::TextureViewDescriptor {
|
||||
label: descriptor
|
||||
.parent
|
||||
.label
|
||||
.as_ref()
|
||||
.map(|s| String::from(s.as_ref())),
|
||||
format: convert_texture_format(format),
|
||||
dimension: convert_texture_view_dimension(dimension),
|
||||
.map(|l| Cow::Owned(l.to_string())),
|
||||
format: descriptor.format.map(|fr| convert_texture_format(fr)),
|
||||
dimension: descriptor
|
||||
.dimension
|
||||
.map(|dm| convert_texture_view_dimension(dm)),
|
||||
aspect: match descriptor.aspect {
|
||||
GPUTextureAspect::All => wgt::TextureAspect::All,
|
||||
GPUTextureAspect::Stencil_only => wgt::TextureAspect::StencilOnly,
|
||||
|
|
|
@ -21,9 +21,7 @@ use servo_config::pref;
|
|||
use smallvec::SmallVec;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::ffi::CString;
|
||||
use std::num::NonZeroU64;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::slice;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
@ -33,13 +31,19 @@ use webrender_traits::{
|
|||
WebrenderImageSource,
|
||||
};
|
||||
use wgpu::{
|
||||
binding_model::BindGroupDescriptor,
|
||||
command::{BufferCopyView, ComputePass, RenderBundleEncoder, RenderPass, TextureCopyView},
|
||||
binding_model::{BindGroupDescriptor, BindGroupLayoutDescriptor, PipelineLayoutDescriptor},
|
||||
command::{
|
||||
BufferCopyView, ComputePass, RenderBundleDescriptor, RenderBundleEncoder, RenderPass,
|
||||
TextureCopyView,
|
||||
},
|
||||
device::HostMap,
|
||||
id,
|
||||
instance::RequestAdapterOptions,
|
||||
pipeline::{ComputePipelineDescriptor, RenderPipelineDescriptor},
|
||||
resource::{BufferMapAsyncStatus, BufferMapOperation},
|
||||
resource::{
|
||||
BufferDescriptor, BufferMapAsyncStatus, BufferMapOperation, SamplerDescriptor,
|
||||
TextureDescriptor, TextureViewDescriptor,
|
||||
},
|
||||
};
|
||||
|
||||
pub type ErrorScopeId = NonZeroU64;
|
||||
|
@ -119,19 +123,19 @@ pub enum WebGPURequest {
|
|||
CreateBindGroupLayout {
|
||||
device_id: id::DeviceId,
|
||||
bind_group_layout_id: id::BindGroupLayoutId,
|
||||
descriptor: Option<wgt::BindGroupLayoutDescriptor<'static>>,
|
||||
descriptor: Option<BindGroupLayoutDescriptor<'static>>,
|
||||
},
|
||||
CreateBuffer {
|
||||
device_id: id::DeviceId,
|
||||
buffer_id: id::BufferId,
|
||||
descriptor: Option<wgt::BufferDescriptor<Option<String>>>,
|
||||
descriptor: Option<BufferDescriptor<'static>>,
|
||||
},
|
||||
CreateCommandEncoder {
|
||||
device_id: id::DeviceId,
|
||||
// TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core
|
||||
// wgpu::command::CommandEncoderDescriptor,
|
||||
command_encoder_id: id::CommandEncoderId,
|
||||
label: Option<String>,
|
||||
label: Option<Cow<'static, str>>,
|
||||
},
|
||||
CreateComputePipeline {
|
||||
device_id: id::DeviceId,
|
||||
|
@ -142,7 +146,7 @@ pub enum WebGPURequest {
|
|||
CreatePipelineLayout {
|
||||
device_id: id::DeviceId,
|
||||
pipeline_layout_id: id::PipelineLayoutId,
|
||||
descriptor: wgt::PipelineLayoutDescriptor<'static, id::BindGroupLayoutId>,
|
||||
descriptor: PipelineLayoutDescriptor<'static>,
|
||||
},
|
||||
CreateRenderPipeline {
|
||||
device_id: id::DeviceId,
|
||||
|
@ -152,7 +156,7 @@ pub enum WebGPURequest {
|
|||
CreateSampler {
|
||||
device_id: id::DeviceId,
|
||||
sampler_id: id::SamplerId,
|
||||
descriptor: wgt::SamplerDescriptor<Option<String>>,
|
||||
descriptor: SamplerDescriptor<'static>,
|
||||
},
|
||||
CreateShaderModule {
|
||||
device_id: id::DeviceId,
|
||||
|
@ -170,13 +174,13 @@ pub enum WebGPURequest {
|
|||
CreateTexture {
|
||||
device_id: id::DeviceId,
|
||||
texture_id: id::TextureId,
|
||||
descriptor: Option<wgt::TextureDescriptor<Option<String>>>,
|
||||
descriptor: Option<TextureDescriptor<'static>>,
|
||||
},
|
||||
CreateTextureView {
|
||||
texture_id: id::TextureId,
|
||||
texture_view_id: id::TextureViewId,
|
||||
device_id: id::DeviceId,
|
||||
descriptor: Option<wgt::TextureViewDescriptor<Option<String>>>,
|
||||
descriptor: Option<TextureViewDescriptor<'static>>,
|
||||
},
|
||||
DestroyBuffer(id::BufferId),
|
||||
DestroySwapChain {
|
||||
|
@ -189,7 +193,7 @@ pub enum WebGPURequest {
|
|||
FreeDevice(id::DeviceId),
|
||||
RenderBundleEncoderFinish {
|
||||
render_bundle_encoder: RenderBundleEncoder,
|
||||
descriptor: wgt::RenderBundleDescriptor<Option<String>>,
|
||||
descriptor: RenderBundleDescriptor<'static>,
|
||||
render_bundle_id: id::RenderBundleId,
|
||||
device_id: id::DeviceId,
|
||||
},
|
||||
|
@ -579,16 +583,8 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
let st;
|
||||
let label = match desc.label {
|
||||
Some(ref s) => {
|
||||
st = CString::new(s.as_bytes()).unwrap();
|
||||
st.as_ptr()
|
||||
},
|
||||
None => ptr::null(),
|
||||
};
|
||||
let result = gfx_select!(buffer_id =>
|
||||
global.device_create_buffer(device_id, &desc.map_label(|_| label), buffer_id));
|
||||
global.device_create_buffer(device_id, &desc, buffer_id));
|
||||
if result.is_err() {
|
||||
let _ = gfx_select!(buffer_id => global.buffer_error(buffer_id));
|
||||
}
|
||||
|
@ -603,14 +599,6 @@ impl<'a> WGPU<'a> {
|
|||
label,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let st;
|
||||
let label = match label {
|
||||
Some(ref s) => {
|
||||
st = CString::new(s.as_bytes()).unwrap();
|
||||
st.as_ptr()
|
||||
},
|
||||
None => ptr::null(),
|
||||
};
|
||||
let desc = wgt::CommandEncoderDescriptor { label };
|
||||
let result = gfx_select!(command_encoder_id =>
|
||||
global.device_create_command_encoder(device_id, &desc, command_encoder_id));
|
||||
|
@ -626,7 +614,7 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
let result = gfx_select!(compute_pipeline_id =>
|
||||
global.device_create_compute_pipeline(device_id, &descriptor, compute_pipeline_id));
|
||||
global.device_create_compute_pipeline(device_id, &descriptor, compute_pipeline_id, None));
|
||||
if result.is_err() {
|
||||
let _ = gfx_select!(compute_pipeline_id =>
|
||||
global.compute_pipeline_error(compute_pipeline_id));
|
||||
|
@ -664,7 +652,7 @@ impl<'a> WGPU<'a> {
|
|||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
let result = gfx_select!(render_pipeline_id =>
|
||||
global.device_create_render_pipeline(device_id, &desc, render_pipeline_id));
|
||||
global.device_create_render_pipeline(device_id, &desc, render_pipeline_id, None));
|
||||
if result.is_err() {
|
||||
let _ = gfx_select!(render_pipeline_id =>
|
||||
global.render_pipeline_error(render_pipeline_id));
|
||||
|
@ -680,17 +668,9 @@ impl<'a> WGPU<'a> {
|
|||
descriptor,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let st;
|
||||
let label = match descriptor.label {
|
||||
Some(ref s) => {
|
||||
st = CString::new(s.as_bytes()).unwrap();
|
||||
st.as_ptr()
|
||||
},
|
||||
None => ptr::null(),
|
||||
};
|
||||
let result = gfx_select!(sampler_id => global.device_create_sampler(
|
||||
device_id,
|
||||
&descriptor.map_label(|_| label),
|
||||
&descriptor,
|
||||
sampler_id
|
||||
));
|
||||
if result.is_err() {
|
||||
|
@ -763,17 +743,9 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
let st;
|
||||
let label = match desc.label {
|
||||
Some(ref s) => {
|
||||
st = CString::new(s.as_bytes()).unwrap();
|
||||
st.as_ptr()
|
||||
},
|
||||
None => ptr::null(),
|
||||
};
|
||||
let result = gfx_select!(texture_id => global.device_create_texture(
|
||||
device_id,
|
||||
&desc.map_label(|_| label),
|
||||
&desc,
|
||||
texture_id
|
||||
));
|
||||
if result.is_err() {
|
||||
|
@ -792,17 +764,9 @@ impl<'a> WGPU<'a> {
|
|||
} => {
|
||||
let global = &self.global;
|
||||
if let Some(desc) = descriptor {
|
||||
let st;
|
||||
let label = match desc.label {
|
||||
Some(ref s) => {
|
||||
st = CString::new(s.as_bytes()).unwrap();
|
||||
st.as_ptr()
|
||||
},
|
||||
None => ptr::null(),
|
||||
};
|
||||
let result = gfx_select!(texture_view_id => global.texture_create_view(
|
||||
texture_id,
|
||||
Some(&desc.map_label(|_| label)),
|
||||
&desc,
|
||||
texture_view_id
|
||||
));
|
||||
if result.is_err() {
|
||||
|
@ -877,17 +841,9 @@ impl<'a> WGPU<'a> {
|
|||
device_id,
|
||||
} => {
|
||||
let global = &self.global;
|
||||
let st;
|
||||
let label = match descriptor.label {
|
||||
Some(ref s) => {
|
||||
st = CString::new(s.as_bytes()).unwrap();
|
||||
st.as_ptr()
|
||||
},
|
||||
None => ptr::null(),
|
||||
};
|
||||
let result = gfx_select!(render_bundle_id => global.render_bundle_encoder_finish(
|
||||
render_bundle_encoder,
|
||||
&descriptor.map_label(|_| label),
|
||||
&descriptor,
|
||||
render_bundle_id
|
||||
));
|
||||
if result.is_err() {
|
||||
|
@ -1051,7 +1007,7 @@ impl<'a> WGPU<'a> {
|
|||
let buffer_size =
|
||||
(buffer_stride * size.height as u32) as wgt::BufferAddress;
|
||||
let buffer_desc = wgt::BufferDescriptor {
|
||||
label: ptr::null(),
|
||||
label: None,
|
||||
size: buffer_size,
|
||||
usage: wgt::BufferUsage::MAP_READ |
|
||||
wgt::BufferUsage::COPY_DST,
|
||||
|
@ -1079,7 +1035,7 @@ impl<'a> WGPU<'a> {
|
|||
|
||||
let buffer_size =
|
||||
(size.height as u32 * buffer_stride) as wgt::BufferAddress;
|
||||
let comm_desc = wgt::CommandEncoderDescriptor { label: ptr::null() };
|
||||
let comm_desc = wgt::CommandEncoderDescriptor { label: None };
|
||||
let _ = gfx_select!(encoder_id => global.device_create_command_encoder(
|
||||
device_id,
|
||||
&comm_desc,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue