mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Update wgpu-core and wgpu-types
This commit is contained in:
parent
1d4efb48ba
commit
3b5ede153d
18 changed files with 58 additions and 90 deletions
|
@ -85,7 +85,7 @@ impl GPUDevice {
|
|||
limits: Heap<*mut JSObject>,
|
||||
device: webgpu::WebGPUDevice,
|
||||
queue: &GPUQueue,
|
||||
) -> GPUDevice {
|
||||
) -> Self {
|
||||
Self {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
channel,
|
||||
|
@ -106,7 +106,7 @@ impl GPUDevice {
|
|||
limits: Heap<*mut JSObject>,
|
||||
device: webgpu::WebGPUDevice,
|
||||
queue: webgpu::WebGPUQueue,
|
||||
) -> DomRoot<GPUDevice> {
|
||||
) -> DomRoot<Self> {
|
||||
let queue = GPUQueue::new(global, channel.clone(), queue);
|
||||
reflect_dom_object(
|
||||
Box::new(GPUDevice::new_inherited(
|
||||
|
@ -121,6 +121,7 @@ impl GPUDevice {
|
|||
fn validate_buffer_descriptor(
|
||||
&self,
|
||||
descriptor: &GPUBufferDescriptor,
|
||||
mapped_at_creation: bool,
|
||||
) -> (bool, wgt::BufferDescriptor<std::string::String>) {
|
||||
// TODO: Record a validation error in the current scope if the descriptor is invalid.
|
||||
let wgpu_usage = wgt::BufferUsage::from_bits(descriptor.usage);
|
||||
|
@ -132,6 +133,7 @@ impl GPUDevice {
|
|||
wgt::BufferDescriptor {
|
||||
size: descriptor.size,
|
||||
usage: wgpu_usage.unwrap(),
|
||||
mapped_at_creation,
|
||||
label: Default::default(),
|
||||
},
|
||||
)
|
||||
|
@ -141,6 +143,7 @@ impl GPUDevice {
|
|||
wgt::BufferDescriptor {
|
||||
size: 0,
|
||||
usage: wgt::BufferUsage::empty(),
|
||||
mapped_at_creation,
|
||||
label: Default::default(),
|
||||
},
|
||||
)
|
||||
|
@ -181,7 +184,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
|
||||
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer
|
||||
fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> DomRoot<GPUBuffer> {
|
||||
let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor);
|
||||
let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor, false);
|
||||
let id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
|
@ -217,7 +220,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
cx: SafeJSContext,
|
||||
descriptor: &GPUBufferDescriptor,
|
||||
) -> Vec<JSVal> {
|
||||
let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor);
|
||||
let (valid, wgpu_descriptor) = self.validate_buffer_descriptor(descriptor, true);
|
||||
let buffer_id = self
|
||||
.global()
|
||||
.wgpu_id_hub()
|
||||
|
@ -225,7 +228,7 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
.create_buffer_id(self.device.0.backend());
|
||||
self.channel
|
||||
.0
|
||||
.send(WebGPURequest::CreateBufferMapped {
|
||||
.send(WebGPURequest::CreateBuffer {
|
||||
device_id: self.device.0,
|
||||
buffer_id,
|
||||
descriptor: wgpu_descriptor.clone(),
|
||||
|
@ -546,7 +549,9 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
resource: BindingResource::Buffer(BufferBinding {
|
||||
buffer: bind.resource.buffer.id().0,
|
||||
offset: bind.resource.offset,
|
||||
size: bind.resource.size.unwrap_or(bind.resource.buffer.size()),
|
||||
size: wgt::BufferSize(
|
||||
bind.resource.size.unwrap_or(bind.resource.buffer.size()),
|
||||
),
|
||||
}),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -729,11 +734,8 @@ impl GPUDeviceMethods for GPUDevice {
|
|||
mipmap_filter: convert_filter_mode(descriptor.mipmapFilter),
|
||||
lod_min_clamp: *descriptor.lodMinClamp,
|
||||
lod_max_clamp: *descriptor.lodMaxClamp,
|
||||
compare: if let Some(c) = descriptor.compare {
|
||||
convert_compare_function(c)
|
||||
} else {
|
||||
wgt::CompareFunction::Undefined
|
||||
},
|
||||
compare: descriptor.compare.map(|c| convert_compare_function(c)),
|
||||
anisotropy_clamp: None,
|
||||
};
|
||||
self.channel
|
||||
.0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue