mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Report errors from void returning operations
This commit is contained in:
parent
6499367fe2
commit
8cb5fad828
10 changed files with 140 additions and 38 deletions
|
@ -29,7 +29,7 @@ use std::borrow::Cow;
|
|||
use std::cell::Cell;
|
||||
use std::collections::HashSet;
|
||||
use webgpu::wgpu::command as wgpu_com;
|
||||
use webgpu::{self, wgt, WebGPU, WebGPURequest};
|
||||
use webgpu::{self, identity::WebGPUOpResult, wgt, WebGPU, WebGPURequest};
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/#enumdef-encoder-state
|
||||
#[derive(MallocSizeOf, PartialEq)]
|
||||
|
@ -103,6 +103,10 @@ impl GPUCommandEncoder {
|
|||
*self.state.borrow_mut() = GPUCommandEncoderState::Closed;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn device(&self) -> &GPUDevice {
|
||||
&*self.device
|
||||
}
|
||||
}
|
||||
|
||||
impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
||||
|
@ -254,9 +258,15 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
size: GPUSize64,
|
||||
) {
|
||||
let valid = *self.state.borrow() == GPUCommandEncoderState::Open;
|
||||
let scope_id = self.device.use_current_scope();
|
||||
|
||||
if !valid {
|
||||
// TODO: Record an error in the current scope.
|
||||
self.device.handle_server_msg(
|
||||
scope_id,
|
||||
WebGPUOpResult::ValidationError(String::from(
|
||||
"CommandEncoder is not in Open State",
|
||||
)),
|
||||
);
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
@ -269,6 +279,8 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
.0
|
||||
.send(WebGPURequest::CopyBufferToBuffer {
|
||||
command_encoder_id: self.encoder.0,
|
||||
device_id: self.device.id().0,
|
||||
scope_id,
|
||||
source_id: source.id().0,
|
||||
source_offset,
|
||||
destination_id: destination.id().0,
|
||||
|
@ -286,9 +298,15 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
copy_size: GPUExtent3D,
|
||||
) {
|
||||
let valid = *self.state.borrow() == GPUCommandEncoderState::Open;
|
||||
let scope_id = self.device.use_current_scope();
|
||||
|
||||
if !valid {
|
||||
// TODO: Record an error in the current scope.
|
||||
self.device.handle_server_msg(
|
||||
scope_id,
|
||||
WebGPUOpResult::ValidationError(String::from(
|
||||
"CommandEncoder is not in Open State",
|
||||
)),
|
||||
);
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
@ -301,6 +319,8 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
.0
|
||||
.send(WebGPURequest::CopyBufferToTexture {
|
||||
command_encoder_id: self.encoder.0,
|
||||
device_id: self.device.id().0,
|
||||
scope_id,
|
||||
source: convert_buffer_cv(source),
|
||||
destination: convert_texture_cv(destination),
|
||||
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(©_size)),
|
||||
|
@ -316,9 +336,15 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
copy_size: GPUExtent3D,
|
||||
) {
|
||||
let valid = *self.state.borrow() == GPUCommandEncoderState::Open;
|
||||
let scope_id = self.device.use_current_scope();
|
||||
|
||||
if !valid {
|
||||
// TODO: Record an error in the current scope.
|
||||
self.device.handle_server_msg(
|
||||
scope_id,
|
||||
WebGPUOpResult::ValidationError(String::from(
|
||||
"CommandEncoder is not in Open State",
|
||||
)),
|
||||
);
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
@ -331,6 +357,8 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
.0
|
||||
.send(WebGPURequest::CopyTextureToBuffer {
|
||||
command_encoder_id: self.encoder.0,
|
||||
device_id: self.device.id().0,
|
||||
scope_id,
|
||||
source: convert_texture_cv(source),
|
||||
destination: convert_buffer_cv(destination),
|
||||
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(©_size)),
|
||||
|
@ -346,9 +374,15 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
copy_size: GPUExtent3D,
|
||||
) {
|
||||
let valid = *self.state.borrow() == GPUCommandEncoderState::Open;
|
||||
let scope_id = self.device.use_current_scope();
|
||||
|
||||
if !valid {
|
||||
// TODO: Record an error in the current scope.
|
||||
self.device.handle_server_msg(
|
||||
scope_id,
|
||||
WebGPUOpResult::ValidationError(String::from(
|
||||
"CommandEncoder is not in Open State",
|
||||
)),
|
||||
);
|
||||
self.valid.set(false);
|
||||
return;
|
||||
}
|
||||
|
@ -357,6 +391,8 @@ impl GPUCommandEncoderMethods for GPUCommandEncoder {
|
|||
.0
|
||||
.send(WebGPURequest::CopyTextureToTexture {
|
||||
command_encoder_id: self.encoder.0,
|
||||
device_id: self.device.id().0,
|
||||
scope_id,
|
||||
source: convert_texture_cv(source),
|
||||
destination: convert_texture_cv(destination),
|
||||
copy_size: convert_texture_size_to_wgt(&convert_texture_size_to_dict(©_size)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue