update wgpu

This commit is contained in:
Kunal Mohan 2020-08-06 00:21:45 +05:30
parent 6e28d7b3ec
commit 01c8b24e9f
3 changed files with 15 additions and 15 deletions

4
Cargo.lock generated
View file

@ -6945,7 +6945,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#872a6c4c2bab5591838219c34e0cbf5fa9c2ec85" source = "git+https://github.com/gfx-rs/wgpu#8057acf120f9944056a6b5de6cf326f18ae7671d"
dependencies = [ dependencies = [
"arrayvec 0.5.1", "arrayvec 0.5.1",
"bitflags", "bitflags",
@ -6972,7 +6972,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#872a6c4c2bab5591838219c34e0cbf5fa9c2ec85" source = "git+https://github.com/gfx-rs/wgpu#8057acf120f9944056a6b5de6cf326f18ae7671d"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"serde", "serde",

View file

@ -16,6 +16,7 @@ use crate::dom::globalscope::GlobalScope;
use crate::dom::gpudevice::{convert_texture_format, convert_texture_view_dimension, GPUDevice}; use crate::dom::gpudevice::{convert_texture_format, convert_texture_view_dimension, GPUDevice};
use crate::dom::gputextureview::GPUTextureView; use crate::dom::gputextureview::GPUTextureView;
use dom_struct::dom_struct; use dom_struct::dom_struct;
use std::num::NonZeroU32;
use std::string::String; use std::string::String;
use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView}; use webgpu::{wgt, WebGPU, WebGPURequest, WebGPUTexture, WebGPUTextureView};
@ -152,9 +153,9 @@ impl GPUTextureMethods for GPUTexture {
GPUTextureAspect::Depth_only => wgt::TextureAspect::DepthOnly, GPUTextureAspect::Depth_only => wgt::TextureAspect::DepthOnly,
}, },
base_mip_level: descriptor.baseMipLevel, base_mip_level: descriptor.baseMipLevel,
level_count: descriptor.mipLevelCount.as_ref().copied(), level_count: descriptor.mipLevelCount.and_then(NonZeroU32::new),
base_array_layer: descriptor.baseArrayLayer, base_array_layer: descriptor.baseArrayLayer,
array_layer_count: descriptor.arrayLayerCount.as_ref().copied(), array_layer_count: descriptor.arrayLayerCount.and_then(NonZeroU32::new),
}; };
let texture_view_id = self let texture_view_id = self

View file

@ -744,7 +744,7 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::DestroyBuffer(buffer) => { WebGPURequest::DestroyBuffer(buffer) => {
let global = &self.global; let global = &self.global;
gfx_select!(buffer => global.buffer_destroy(buffer, false)); gfx_select!(buffer => global.buffer_drop(buffer, false));
}, },
WebGPURequest::DestroySwapChain { WebGPURequest::DestroySwapChain {
external_id, external_id,
@ -758,10 +758,10 @@ impl<'a> WGPU<'a> {
.unwrap(); .unwrap();
let global = &self.global; let global = &self.global;
for b_id in data.available_buffer_ids.iter() { for b_id in data.available_buffer_ids.iter() {
gfx_select!(b_id => global.buffer_destroy(*b_id, false)); gfx_select!(b_id => global.buffer_drop(*b_id, false));
} }
for b_id in data.queued_buffer_ids.iter() { for b_id in data.queued_buffer_ids.iter() {
gfx_select!(b_id => global.buffer_destroy(*b_id, false)); gfx_select!(b_id => global.buffer_drop(*b_id, false));
} }
for b_id in data.unassigned_buffer_ids.iter() { for b_id in data.unassigned_buffer_ids.iter() {
if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(*b_id)) { if let Err(e) = self.script_sender.send(WebGPUMsg::FreeBuffer(*b_id)) {
@ -775,7 +775,7 @@ impl<'a> WGPU<'a> {
}, },
WebGPURequest::DestroyTexture(texture) => { WebGPURequest::DestroyTexture(texture) => {
let global = &self.global; let global = &self.global;
gfx_select!(texture => global.texture_destroy(texture)); gfx_select!(texture => global.texture_drop(texture));
}, },
WebGPURequest::Exit(sender) => { WebGPURequest::Exit(sender) => {
if let Err(e) = self.script_sender.send(WebGPUMsg::Exit) { if let Err(e) = self.script_sender.send(WebGPUMsg::Exit) {
@ -823,15 +823,13 @@ impl<'a> WGPU<'a> {
options, options,
ids, ids,
} => { } => {
let adapter_id = match self.global.pick_adapter( let adapter_id = match self.global.request_adapter(
&options, &options,
wgpu::instance::AdapterInputs::IdSet(&ids, |id| id.backend()), wgpu::instance::AdapterInputs::IdSet(&ids, |id| id.backend()),
) { ) {
Some(id) => id, Ok(id) => id,
None => { Err(w) => {
if let Err(e) = if let Err(e) = sender.send(Err(format!("{:?}", w))) {
sender.send(Err("Failed to get webgpu adapter".to_string()))
{
warn!( warn!(
"Failed to send response to WebGPURequest::RequestAdapter ({})", "Failed to send response to WebGPURequest::RequestAdapter ({})",
e e
@ -843,7 +841,8 @@ impl<'a> WGPU<'a> {
let adapter = WebGPUAdapter(adapter_id); let adapter = WebGPUAdapter(adapter_id);
self.adapters.push(adapter); self.adapters.push(adapter);
let global = &self.global; let global = &self.global;
let info = gfx_select!(adapter_id => global.adapter_get_info(adapter_id)); let info =
gfx_select!(adapter_id => global.adapter_get_info(adapter_id)).unwrap();
if let Err(e) = sender.send(Ok(WebGPUResponse::RequestAdapter { if let Err(e) = sender.send(Ok(WebGPUResponse::RequestAdapter {
adapter_name: info.name, adapter_name: info.name,
adapter_id: adapter, adapter_id: adapter,