Skip to content

Commit

Permalink
fix(ext/webgpu): use correct IDL key name (denoland#15278)
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlKats committed Aug 3, 2022
1 parent bc4ee59 commit 864af52
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
8 changes: 7 additions & 1 deletion ext/webgpu/src/01_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,13 @@
);
}
}
const requiredLimits = descriptor.requiredLimits;
let requiredLimits = descriptor.requiredLimits;
if (requiredLimits) {
requiredLimits = {
...this[_adapter].limits[_limits],
...requiredLimits,
};
}
// TODO(lucacasonato): validate requiredLimits

const { rid, features, limits } = await core.opAsync(
Expand Down
7 changes: 2 additions & 5 deletions ext/webgpu/src/02_idl_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
// DICTIONARY: GPUDeviceDescriptor
const dictMembersGPUDeviceDescriptor = [
{
key: "nonGuaranteedFeatures",
key: "requiredFeatures",
converter: webidl.createSequenceConverter(
webidl.converters["GPUFeatureName"],
),
Expand All @@ -160,14 +160,11 @@
},
},
{
key: "nonGuaranteedLimits",
key: "requiredLimits",
converter: webidl.createRecordConverter(
webidl.converters["DOMString"],
webidl.converters["GPUSize32"],
),
get defaultValue() {
return {};
},
},
];
webidl.converters["GPUDeviceDescriptor"] = webidl.createDictionaryConverter(
Expand Down
24 changes: 16 additions & 8 deletions ext/webgpu/src/command_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ pub struct GpuRenderPassColorAttachment {
pub struct GpuRenderPassDepthStencilAttachment {
view: ResourceId,
depth_clear_value: f32,
depth_load_op: wgpu_core::command::LoadOp,
depth_store_op: wgpu_core::command::StoreOp,
depth_load_op: Option<wgpu_core::command::LoadOp>,
depth_store_op: Option<wgpu_core::command::StoreOp>,
depth_read_only: bool,
stencil_clear_value: u32,
stencil_load_op: wgpu_core::command::LoadOp,
stencil_store_op: wgpu_core::command::StoreOp,
stencil_load_op: Option<wgpu_core::command::LoadOp>,
stencil_store_op: Option<wgpu_core::command::StoreOp>,
stencil_read_only: bool,
}

Expand Down Expand Up @@ -138,14 +138,22 @@ pub fn op_webgpu_command_encoder_begin_render_pass(
Some(wgpu_core::command::RenderPassDepthStencilAttachment {
view: texture_view_resource.0,
depth: wgpu_core::command::PassChannel {
load_op: attachment.depth_load_op,
store_op: attachment.depth_store_op,
load_op: attachment
.depth_load_op
.unwrap_or(wgpu_core::command::LoadOp::Load),
store_op: attachment
.depth_store_op
.unwrap_or(wgpu_core::command::StoreOp::Store),
clear_value: attachment.depth_clear_value,
read_only: attachment.depth_read_only,
},
stencil: wgpu_core::command::PassChannel {
load_op: attachment.stencil_load_op,
store_op: attachment.stencil_store_op,
load_op: attachment
.stencil_load_op
.unwrap_or(wgpu_core::command::LoadOp::Load),
store_op: attachment
.stencil_store_op
.unwrap_or(wgpu_core::command::StoreOp::Store),
clear_value: attachment.stencil_clear_value,
read_only: attachment.stencil_read_only,
},
Expand Down
6 changes: 3 additions & 3 deletions ext/webgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ pub async fn op_webgpu_request_device(
state: Rc<RefCell<OpState>>,
adapter_rid: ResourceId,
label: Option<String>,
required_features: Option<GpuRequiredFeatures>,
required_features: GpuRequiredFeatures,
required_limits: Option<wgpu_types::Limits>,
) -> Result<GpuAdapterDevice, AnyError> {
let mut state = state.borrow_mut();
Expand All @@ -419,8 +419,8 @@ pub async fn op_webgpu_request_device(

let descriptor = wgpu_types::DeviceDescriptor {
label: label.map(Cow::from),
features: required_features.map(Into::into).unwrap_or_default(),
limits: required_limits.map(Into::into).unwrap_or_default(),
features: required_features.into(),
limits: required_limits.unwrap_or_default(),
};

let (device, maybe_err) = gfx_select!(adapter => instance.adapter_request_device(
Expand Down

0 comments on commit 864af52

Please sign in to comment.