aboutsummaryrefslogtreecommitdiffstats
path: root/components/webgpu/lib.rs
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-08-27 13:12:27 -0400
committerGitHub <noreply@github.com>2020-08-27 13:12:27 -0400
commit9e6da58d7793a4576fef38446457e1073a19cd5e (patch)
tree9413f55965530db94a2c82d68bbb33a4f3d765a9 /components/webgpu/lib.rs
parent84185eb1daf1420597f38a77e40ed3baedb5d521 (diff)
parent85b6bbb33ace8b433ed279d2cb73ed8d96bb9690 (diff)
downloadservo-9e6da58d7793a4576fef38446457e1073a19cd5e.tar.gz
servo-9e6da58d7793a4576fef38446457e1073a19cd5e.zip
Auto merge of #27614 - kunalmohan:webgpu-cts, r=kvark
Minor fixes and update cts <!-- Please describe your changes on the following line: --> - Prevent redundant buffer and texture destroy calls. - More subtests for B2B copy pass now. - All tests under `setViewport()` and `setScissorRect()` pass now. - Tests for `createTexture()` do not crash. More than 50% of them pass now. r?@kvark --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/webgpu/lib.rs')
-rw-r--r--components/webgpu/lib.rs28
1 files changed, 13 insertions, 15 deletions
diff --git a/components/webgpu/lib.rs b/components/webgpu/lib.rs
index 7d4dbd3e808..0d6ece51273 100644
--- a/components/webgpu/lib.rs
+++ b/components/webgpu/lib.rs
@@ -21,7 +21,6 @@ use servo_config::pref;
use smallvec::SmallVec;
use std::borrow::Cow;
use std::cell::RefCell;
-use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::num::NonZeroU64;
use std::rc::Rc;
@@ -475,9 +474,7 @@ impl<'a> WGPU<'a> {
))
.map_err(|e| format!("{:?}", e))
};
- if result.is_err() {
- self.encoder_record_error(command_encoder_id, result.clone());
- }
+ self.encoder_record_error(command_encoder_id, &result);
self.send_result(device_id, scope_id, result);
},
WebGPURequest::CopyBufferToBuffer {
@@ -497,7 +494,7 @@ impl<'a> WGPU<'a> {
destination_offset,
size
));
- self.encoder_record_error(command_encoder_id, result);
+ self.encoder_record_error(command_encoder_id, &result);
},
WebGPURequest::CopyBufferToTexture {
command_encoder_id,
@@ -512,7 +509,7 @@ impl<'a> WGPU<'a> {
&destination,
&copy_size
));
- self.encoder_record_error(command_encoder_id, result);
+ self.encoder_record_error(command_encoder_id, &result);
},
WebGPURequest::CopyTextureToBuffer {
command_encoder_id,
@@ -527,7 +524,7 @@ impl<'a> WGPU<'a> {
&destination,
&copy_size
));
- self.encoder_record_error(command_encoder_id, result);
+ self.encoder_record_error(command_encoder_id, &result);
},
WebGPURequest::CopyTextureToTexture {
command_encoder_id,
@@ -542,7 +539,7 @@ impl<'a> WGPU<'a> {
&destination,
&copy_size
));
- self.encoder_record_error(command_encoder_id, result);
+ self.encoder_record_error(command_encoder_id, &result);
},
WebGPURequest::CreateBindGroup {
device_id,
@@ -985,7 +982,7 @@ impl<'a> WGPU<'a> {
} else {
Err(String::from("Invalid ComputePass"))
};
- self.encoder_record_error(command_encoder_id, result);
+ self.encoder_record_error(command_encoder_id, &result);
},
WebGPURequest::RunRenderPass {
command_encoder_id,
@@ -1000,7 +997,7 @@ impl<'a> WGPU<'a> {
} else {
Err(String::from("Invalid RenderPass"))
};
- self.encoder_record_error(command_encoder_id, result);
+ self.encoder_record_error(command_encoder_id, &result);
},
WebGPURequest::Submit {
queue_id,
@@ -1279,12 +1276,13 @@ impl<'a> WGPU<'a> {
fn encoder_record_error<U, T: std::fmt::Debug>(
&self,
encoder_id: id::CommandEncoderId,
- result: Result<U, T>,
+ result: &Result<U, T>,
) {
- if let Err(e) = result {
- if let Entry::Vacant(v) = self.error_command_encoders.borrow_mut().entry(encoder_id) {
- v.insert(format!("{:?}", e));
- }
+ if let Err(ref e) = result {
+ self.error_command_encoders
+ .borrow_mut()
+ .entry(encoder_id)
+ .or_insert_with(|| format!("{:?}", e));
}
}
}