mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +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
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1895,7 +1895,6 @@ dependencies = [
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"smallvec 1.3.0",
|
"smallvec 1.3.0",
|
||||||
"winapi",
|
"winapi",
|
||||||
"x11",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -6592,7 +6591,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-core"
|
name = "wgpu-core"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/gfx-rs/wgpu#a203333c3e144cfd431c812213966ee32ae59d98"
|
source = "git+https://github.com/gfx-rs/wgpu#ac9587e9ced5b043abad68e260cb8c9e812cffb5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec 0.5.1",
|
"arrayvec 0.5.1",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
|
@ -6621,7 +6620,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-types"
|
name = "wgpu-types"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
source = "git+https://github.com/gfx-rs/wgpu#a203333c3e144cfd431c812213966ee32ae59d98"
|
source = "git+https://github.com/gfx-rs/wgpu#ac9587e9ced5b043abad68e260cb8c9e812cffb5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"peek-poke 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -39,8 +39,8 @@ impl GPUAdapter {
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
extensions: Heap<*mut JSObject>,
|
extensions: Heap<*mut JSObject>,
|
||||||
adapter: WebGPUAdapter,
|
adapter: WebGPUAdapter,
|
||||||
) -> GPUAdapter {
|
) -> Self {
|
||||||
GPUAdapter {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
channel,
|
channel,
|
||||||
name,
|
name,
|
||||||
|
@ -55,7 +55,7 @@ impl GPUAdapter {
|
||||||
name: DOMString,
|
name: DOMString,
|
||||||
extensions: Heap<*mut JSObject>,
|
extensions: Heap<*mut JSObject>,
|
||||||
adapter: WebGPUAdapter,
|
adapter: WebGPUAdapter,
|
||||||
) -> DomRoot<GPUAdapter> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUAdapter::new_inherited(
|
Box::new(GPUAdapter::new_inherited(
|
||||||
channel, name, extensions, adapter,
|
channel, name, extensions, adapter,
|
||||||
|
@ -81,9 +81,7 @@ impl GPUAdapterMethods for GPUAdapter {
|
||||||
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
let promise = Promise::new_in_current_realm(&self.global(), comp);
|
||||||
let sender = response_async(&promise, self);
|
let sender = response_async(&promise, self);
|
||||||
let desc = wgt::DeviceDescriptor {
|
let desc = wgt::DeviceDescriptor {
|
||||||
extensions: wgt::Extensions {
|
extensions: wgt::Extensions::empty(),
|
||||||
anisotropic_filtering: descriptor.extensions.anisotropicFiltering,
|
|
||||||
},
|
|
||||||
limits: wgt::Limits {
|
limits: wgt::Limits {
|
||||||
max_bind_groups: descriptor.limits.maxBindGroups,
|
max_bind_groups: descriptor.limits.maxBindGroups,
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,7 +21,7 @@ pub struct GPUBindGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUBindGroup {
|
impl GPUBindGroup {
|
||||||
fn new_inherited(bind_group: WebGPUBindGroup, valid: bool) -> GPUBindGroup {
|
fn new_inherited(bind_group: WebGPUBindGroup, valid: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
label: DomRefCell::new(None),
|
label: DomRefCell::new(None),
|
||||||
|
@ -30,11 +30,7 @@ impl GPUBindGroup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(global: &GlobalScope, bind_group: WebGPUBindGroup, valid: bool) -> DomRoot<Self> {
|
||||||
global: &GlobalScope,
|
|
||||||
bind_group: WebGPUBindGroup,
|
|
||||||
valid: bool,
|
|
||||||
) -> DomRoot<GPUBindGroup> {
|
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUBindGroup::new_inherited(bind_group, valid)),
|
Box::new(GPUBindGroup::new_inherited(bind_group, valid)),
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl GPUBindGroupLayout {
|
||||||
bind_group_layout: WebGPUBindGroupLayout,
|
bind_group_layout: WebGPUBindGroupLayout,
|
||||||
bindings: Vec<GPUBindGroupLayoutEntry>,
|
bindings: Vec<GPUBindGroupLayoutEntry>,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> GPUBindGroupLayout {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
channel,
|
channel,
|
||||||
|
@ -49,7 +49,7 @@ impl GPUBindGroupLayout {
|
||||||
bind_group_layout: WebGPUBindGroupLayout,
|
bind_group_layout: WebGPUBindGroupLayout,
|
||||||
bindings: Vec<GPUBindGroupLayoutEntry>,
|
bindings: Vec<GPUBindGroupLayoutEntry>,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> DomRoot<GPUBindGroupLayout> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUBindGroupLayout::new_inherited(
|
Box::new(GPUBindGroupLayout::new_inherited(
|
||||||
channel,
|
channel,
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl GPUBuffer {
|
||||||
usage: u32,
|
usage: u32,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
mapping: RootedTraceableBox<Heap<*mut JSObject>>,
|
mapping: RootedTraceableBox<Heap<*mut JSObject>>,
|
||||||
) -> GPUBuffer {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
channel,
|
channel,
|
||||||
|
@ -83,7 +83,7 @@ impl GPUBuffer {
|
||||||
usage: u32,
|
usage: u32,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
mapping: RootedTraceableBox<Heap<*mut JSObject>>,
|
mapping: RootedTraceableBox<Heap<*mut JSObject>>,
|
||||||
) -> DomRoot<GPUBuffer> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUBuffer::new_inherited(
|
Box::new(GPUBuffer::new_inherited(
|
||||||
channel, buffer, device, state, size, usage, valid, mapping,
|
channel, buffer, device, state, size, usage, valid, mapping,
|
||||||
|
|
|
@ -37,8 +37,8 @@ impl GPUCommandBuffer {
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
command_buffer: WebGPUCommandBuffer,
|
command_buffer: WebGPUCommandBuffer,
|
||||||
buffers: HashSet<DomRoot<GPUBuffer>>,
|
buffers: HashSet<DomRoot<GPUBuffer>>,
|
||||||
) -> GPUCommandBuffer {
|
) -> Self {
|
||||||
GPUCommandBuffer {
|
Self {
|
||||||
channel,
|
channel,
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
label: DomRefCell::new(None),
|
label: DomRefCell::new(None),
|
||||||
|
@ -52,7 +52,7 @@ impl GPUCommandBuffer {
|
||||||
channel: WebGPU,
|
channel: WebGPU,
|
||||||
command_buffer: WebGPUCommandBuffer,
|
command_buffer: WebGPUCommandBuffer,
|
||||||
buffers: HashSet<DomRoot<GPUBuffer>>,
|
buffers: HashSet<DomRoot<GPUBuffer>>,
|
||||||
) -> DomRoot<GPUCommandBuffer> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUCommandBuffer::new_inherited(
|
Box::new(GPUCommandBuffer::new_inherited(
|
||||||
channel,
|
channel,
|
||||||
|
|
|
@ -192,12 +192,14 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||||
GPUStoreOp::Clear => wgt::StoreOp::Clear,
|
GPUStoreOp::Clear => wgt::StoreOp::Clear,
|
||||||
},
|
},
|
||||||
clear_depth,
|
clear_depth,
|
||||||
|
depth_read_only: depth.depthReadOnly,
|
||||||
stencil_load_op,
|
stencil_load_op,
|
||||||
stencil_store_op: match depth.stencilStoreOp {
|
stencil_store_op: match depth.stencilStoreOp {
|
||||||
GPUStoreOp::Store => wgt::StoreOp::Store,
|
GPUStoreOp::Store => wgt::StoreOp::Store,
|
||||||
GPUStoreOp::Clear => wgt::StoreOp::Clear,
|
GPUStoreOp::Clear => wgt::StoreOp::Clear,
|
||||||
},
|
},
|
||||||
clear_stencil,
|
clear_stencil,
|
||||||
|
stencil_read_only: depth.stencilReadOnly,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub struct GPUComputePipeline {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUComputePipeline {
|
impl GPUComputePipeline {
|
||||||
fn new_inherited(compute_pipeline: WebGPUComputePipeline) -> GPUComputePipeline {
|
fn new_inherited(compute_pipeline: WebGPUComputePipeline) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
label: DomRefCell::new(None),
|
label: DomRefCell::new(None),
|
||||||
|
@ -28,10 +28,7 @@ impl GPUComputePipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(global: &GlobalScope, compute_pipeline: WebGPUComputePipeline) -> DomRoot<Self> {
|
||||||
global: &GlobalScope,
|
|
||||||
compute_pipeline: WebGPUComputePipeline,
|
|
||||||
) -> DomRoot<GPUComputePipeline> {
|
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUComputePipeline::new_inherited(compute_pipeline)),
|
Box::new(GPUComputePipeline::new_inherited(compute_pipeline)),
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -85,7 +85,7 @@ impl GPUDevice {
|
||||||
limits: Heap<*mut JSObject>,
|
limits: Heap<*mut JSObject>,
|
||||||
device: webgpu::WebGPUDevice,
|
device: webgpu::WebGPUDevice,
|
||||||
queue: &GPUQueue,
|
queue: &GPUQueue,
|
||||||
) -> GPUDevice {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
eventtarget: EventTarget::new_inherited(),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
channel,
|
channel,
|
||||||
|
@ -106,7 +106,7 @@ impl GPUDevice {
|
||||||
limits: Heap<*mut JSObject>,
|
limits: Heap<*mut JSObject>,
|
||||||
device: webgpu::WebGPUDevice,
|
device: webgpu::WebGPUDevice,
|
||||||
queue: webgpu::WebGPUQueue,
|
queue: webgpu::WebGPUQueue,
|
||||||
) -> DomRoot<GPUDevice> {
|
) -> DomRoot<Self> {
|
||||||
let queue = GPUQueue::new(global, channel.clone(), queue);
|
let queue = GPUQueue::new(global, channel.clone(), queue);
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUDevice::new_inherited(
|
Box::new(GPUDevice::new_inherited(
|
||||||
|
@ -121,6 +121,7 @@ impl GPUDevice {
|
||||||
fn validate_buffer_descriptor(
|
fn validate_buffer_descriptor(
|
||||||
&self,
|
&self,
|
||||||
descriptor: &GPUBufferDescriptor,
|
descriptor: &GPUBufferDescriptor,
|
||||||
|
mapped_at_creation: bool,
|
||||||
) -> (bool, wgt::BufferDescriptor<std::string::String>) {
|
) -> (bool, wgt::BufferDescriptor<std::string::String>) {
|
||||||
// TODO: Record a validation error in the current scope if the descriptor is invalid.
|
// TODO: Record a validation error in the current scope if the descriptor is invalid.
|
||||||
let wgpu_usage = wgt::BufferUsage::from_bits(descriptor.usage);
|
let wgpu_usage = wgt::BufferUsage::from_bits(descriptor.usage);
|
||||||
|
@ -132,6 +133,7 @@ impl GPUDevice {
|
||||||
wgt::BufferDescriptor {
|
wgt::BufferDescriptor {
|
||||||
size: descriptor.size,
|
size: descriptor.size,
|
||||||
usage: wgpu_usage.unwrap(),
|
usage: wgpu_usage.unwrap(),
|
||||||
|
mapped_at_creation,
|
||||||
label: Default::default(),
|
label: Default::default(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -141,6 +143,7 @@ impl GPUDevice {
|
||||||
wgt::BufferDescriptor {
|
wgt::BufferDescriptor {
|
||||||
size: 0,
|
size: 0,
|
||||||
usage: wgt::BufferUsage::empty(),
|
usage: wgt::BufferUsage::empty(),
|
||||||
|
mapped_at_creation,
|
||||||
label: Default::default(),
|
label: Default::default(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -181,7 +184,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
|
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer
|
/// https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer
|
||||||
fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> DomRoot<GPUBuffer> {
|
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
|
let id = self
|
||||||
.global()
|
.global()
|
||||||
.wgpu_id_hub()
|
.wgpu_id_hub()
|
||||||
|
@ -217,7 +220,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
cx: SafeJSContext,
|
cx: SafeJSContext,
|
||||||
descriptor: &GPUBufferDescriptor,
|
descriptor: &GPUBufferDescriptor,
|
||||||
) -> Vec<JSVal> {
|
) -> 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
|
let buffer_id = self
|
||||||
.global()
|
.global()
|
||||||
.wgpu_id_hub()
|
.wgpu_id_hub()
|
||||||
|
@ -225,7 +228,7 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
.create_buffer_id(self.device.0.backend());
|
.create_buffer_id(self.device.0.backend());
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
.send(WebGPURequest::CreateBufferMapped {
|
.send(WebGPURequest::CreateBuffer {
|
||||||
device_id: self.device.0,
|
device_id: self.device.0,
|
||||||
buffer_id,
|
buffer_id,
|
||||||
descriptor: wgpu_descriptor.clone(),
|
descriptor: wgpu_descriptor.clone(),
|
||||||
|
@ -546,7 +549,9 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
resource: BindingResource::Buffer(BufferBinding {
|
resource: BindingResource::Buffer(BufferBinding {
|
||||||
buffer: bind.resource.buffer.id().0,
|
buffer: bind.resource.buffer.id().0,
|
||||||
offset: bind.resource.offset,
|
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<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
@ -729,11 +734,8 @@ impl GPUDeviceMethods for GPUDevice {
|
||||||
mipmap_filter: convert_filter_mode(descriptor.mipmapFilter),
|
mipmap_filter: convert_filter_mode(descriptor.mipmapFilter),
|
||||||
lod_min_clamp: *descriptor.lodMinClamp,
|
lod_min_clamp: *descriptor.lodMinClamp,
|
||||||
lod_max_clamp: *descriptor.lodMaxClamp,
|
lod_max_clamp: *descriptor.lodMaxClamp,
|
||||||
compare: if let Some(c) = descriptor.compare {
|
compare: descriptor.compare.map(|c| convert_compare_function(c)),
|
||||||
convert_compare_function(c)
|
anisotropy_clamp: None,
|
||||||
} else {
|
|
||||||
wgt::CompareFunction::Undefined
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
self.channel
|
self.channel
|
||||||
.0
|
.0
|
||||||
|
|
|
@ -26,7 +26,7 @@ impl GPUPipelineLayout {
|
||||||
bind_group_layouts: Vec<WebGPUBindGroupLayout>,
|
bind_group_layouts: Vec<WebGPUBindGroupLayout>,
|
||||||
pipeline_layout: WebGPUPipelineLayout,
|
pipeline_layout: WebGPUPipelineLayout,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> GPUPipelineLayout {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
bind_group_layouts,
|
bind_group_layouts,
|
||||||
|
@ -41,7 +41,7 @@ impl GPUPipelineLayout {
|
||||||
bind_group_layouts: Vec<WebGPUBindGroupLayout>,
|
bind_group_layouts: Vec<WebGPUBindGroupLayout>,
|
||||||
pipeline_layout: WebGPUPipelineLayout,
|
pipeline_layout: WebGPUPipelineLayout,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> DomRoot<GPUPipelineLayout> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUPipelineLayout::new_inherited(
|
Box::new(GPUPipelineLayout::new_inherited(
|
||||||
bind_group_layouts,
|
bind_group_layouts,
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub struct GPUQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUQueue {
|
impl GPUQueue {
|
||||||
fn new_inherited(channel: WebGPU, queue: WebGPUQueue) -> GPUQueue {
|
fn new_inherited(channel: WebGPU, queue: WebGPUQueue) -> Self {
|
||||||
GPUQueue {
|
GPUQueue {
|
||||||
channel,
|
channel,
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
|
@ -32,7 +32,7 @@ impl GPUQueue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(global: &GlobalScope, channel: WebGPU, queue: WebGPUQueue) -> DomRoot<GPUQueue> {
|
pub fn new(global: &GlobalScope, channel: WebGPU, queue: WebGPUQueue) -> DomRoot<Self> {
|
||||||
reflect_dom_object(Box::new(GPUQueue::new_inherited(channel, queue)), global)
|
reflect_dom_object(Box::new(GPUQueue::new_inherited(channel, queue)), global)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,12 +173,11 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
|
||||||
|
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderencoderbase-setindexbuffer
|
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderencoderbase-setindexbuffer
|
||||||
fn SetIndexBuffer(&self, buffer: &GPUBuffer, offset: u64, size: u64) {
|
fn SetIndexBuffer(&self, buffer: &GPUBuffer, offset: u64, size: u64) {
|
||||||
let s;
|
let s = if size == 0 {
|
||||||
if size == 0 {
|
wgt::BufferSize::WHOLE
|
||||||
s = buffer.size() - offset;
|
|
||||||
} else {
|
} else {
|
||||||
s = size;
|
wgt::BufferSize(size)
|
||||||
}
|
};
|
||||||
|
|
||||||
if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() {
|
if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -189,12 +188,11 @@ impl GPURenderPassEncoderMethods for GPURenderPassEncoder {
|
||||||
|
|
||||||
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderencoderbase-setvertexbuffer
|
/// https://gpuweb.github.io/gpuweb/#dom-gpurenderencoderbase-setvertexbuffer
|
||||||
fn SetVertexBuffer(&self, slot: u32, buffer: &GPUBuffer, offset: u64, size: u64) {
|
fn SetVertexBuffer(&self, slot: u32, buffer: &GPUBuffer, offset: u64, size: u64) {
|
||||||
let s;
|
let s = if size == 0 {
|
||||||
if size == 0 {
|
wgt::BufferSize::WHOLE
|
||||||
s = buffer.size() - offset;
|
|
||||||
} else {
|
} else {
|
||||||
s = size;
|
wgt::BufferSize(size)
|
||||||
}
|
};
|
||||||
|
|
||||||
if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() {
|
if let Some(raw_pass) = self.raw_pass.borrow_mut().as_mut() {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl GPURenderPipeline {
|
||||||
render_pipeline: WebGPURenderPipeline,
|
render_pipeline: WebGPURenderPipeline,
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> GPURenderPipeline {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
label: DomRefCell::new(None),
|
label: DomRefCell::new(None),
|
||||||
|
@ -42,7 +42,7 @@ impl GPURenderPipeline {
|
||||||
render_pipeline: WebGPURenderPipeline,
|
render_pipeline: WebGPURenderPipeline,
|
||||||
device: WebGPUDevice,
|
device: WebGPUDevice,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> DomRoot<GPURenderPipeline> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPURenderPipeline::new_inherited(
|
Box::new(GPURenderPipeline::new_inherited(
|
||||||
render_pipeline,
|
render_pipeline,
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl GPUSampler {
|
||||||
compare_enable: bool,
|
compare_enable: bool,
|
||||||
sampler: WebGPUSampler,
|
sampler: WebGPUSampler,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> GPUSampler {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
channel,
|
channel,
|
||||||
|
@ -50,7 +50,7 @@ impl GPUSampler {
|
||||||
compare_enable: bool,
|
compare_enable: bool,
|
||||||
sampler: WebGPUSampler,
|
sampler: WebGPUSampler,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> DomRoot<GPUSampler> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUSampler::new_inherited(
|
Box::new(GPUSampler::new_inherited(
|
||||||
channel,
|
channel,
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub struct GPUShaderModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GPUShaderModule {
|
impl GPUShaderModule {
|
||||||
fn new_inherited(shader_module: WebGPUShaderModule) -> GPUShaderModule {
|
fn new_inherited(shader_module: WebGPUShaderModule) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
label: DomRefCell::new(None),
|
label: DomRefCell::new(None),
|
||||||
|
@ -27,10 +27,7 @@ impl GPUShaderModule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(
|
pub fn new(global: &GlobalScope, shader_module: WebGPUShaderModule) -> DomRoot<Self> {
|
||||||
global: &GlobalScope,
|
|
||||||
shader_module: WebGPUShaderModule,
|
|
||||||
) -> DomRoot<GPUShaderModule> {
|
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUShaderModule::new_inherited(shader_module)),
|
Box::new(GPUShaderModule::new_inherited(shader_module)),
|
||||||
global,
|
global,
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl GPUTexture {
|
||||||
format: GPUTextureFormat,
|
format: GPUTextureFormat,
|
||||||
texture_usage: u32,
|
texture_usage: u32,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> GPUTexture {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
texture,
|
texture,
|
||||||
|
@ -78,7 +78,7 @@ impl GPUTexture {
|
||||||
format: GPUTextureFormat,
|
format: GPUTextureFormat,
|
||||||
texture_usage: u32,
|
texture_usage: u32,
|
||||||
valid: bool,
|
valid: bool,
|
||||||
) -> DomRoot<GPUTexture> {
|
) -> DomRoot<Self> {
|
||||||
reflect_dom_object(
|
reflect_dom_object(
|
||||||
Box::new(GPUTexture::new_inherited(
|
Box::new(GPUTexture::new_inherited(
|
||||||
texture,
|
texture,
|
||||||
|
|
|
@ -14,12 +14,13 @@ interface GPUAdapter {
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
|
dictionary GPUDeviceDescriptor : GPUObjectDescriptorBase {
|
||||||
GPUExtensions extensions = {};
|
sequence<GPUExtensionName> extensions = [];
|
||||||
GPULimits limits = {};
|
GPULimits limits = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPUExtensions {
|
enum GPUExtensionName {
|
||||||
boolean anisotropicFiltering = false;
|
"texture-compression-bc",
|
||||||
|
"pipeline-statistics-query"
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary GPULimits {
|
dictionary GPULimits {
|
||||||
|
|
|
@ -74,11 +74,6 @@ pub enum WebGPURequest {
|
||||||
buffer_id: id::BufferId,
|
buffer_id: id::BufferId,
|
||||||
descriptor: wgt::BufferDescriptor<String>,
|
descriptor: wgt::BufferDescriptor<String>,
|
||||||
},
|
},
|
||||||
CreateBufferMapped {
|
|
||||||
device_id: id::DeviceId,
|
|
||||||
buffer_id: id::BufferId,
|
|
||||||
descriptor: wgt::BufferDescriptor<String>,
|
|
||||||
},
|
|
||||||
CreateCommandEncoder {
|
CreateCommandEncoder {
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
// TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core
|
// TODO(zakorgy): Serialize CommandEncoderDescriptor in wgpu-core
|
||||||
|
@ -315,26 +310,9 @@ impl WGPU {
|
||||||
descriptor,
|
descriptor,
|
||||||
} => {
|
} => {
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
let desc = wgt::BufferDescriptor {
|
let st = CString::new(descriptor.label.as_bytes()).unwrap();
|
||||||
size: descriptor.size,
|
|
||||||
usage: descriptor.usage,
|
|
||||||
label: ptr::null(),
|
|
||||||
};
|
|
||||||
let _ = gfx_select!(buffer_id => global.device_create_buffer(device_id, &desc, buffer_id));
|
|
||||||
},
|
|
||||||
WebGPURequest::CreateBufferMapped {
|
|
||||||
device_id,
|
|
||||||
buffer_id,
|
|
||||||
descriptor,
|
|
||||||
} => {
|
|
||||||
let global = &self.global;
|
|
||||||
let desc = wgt::BufferDescriptor {
|
|
||||||
size: descriptor.size,
|
|
||||||
usage: descriptor.usage,
|
|
||||||
label: ptr::null(),
|
|
||||||
};
|
|
||||||
let _ = gfx_select!(buffer_id =>
|
let _ = gfx_select!(buffer_id =>
|
||||||
global.device_create_buffer_mapped(device_id, &desc, buffer_id));
|
global.device_create_buffer(device_id, &descriptor.map_label(|_| st.as_ptr()), buffer_id));
|
||||||
},
|
},
|
||||||
WebGPURequest::CreateCommandEncoder {
|
WebGPURequest::CreateCommandEncoder {
|
||||||
device_id,
|
device_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue