mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
refactor: propagate CanGc arguments through callers (#35591)
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
This commit is contained in:
parent
02199520f2
commit
b0b0289014
74 changed files with 403 additions and 275 deletions
|
@ -245,7 +245,7 @@ impl AsyncWGPUListener for GPUAdapter {
|
|||
String::new(),
|
||||
can_gc,
|
||||
);
|
||||
device.lose(GPUDeviceLostReason::Unknown, e.to_string());
|
||||
device.lose(GPUDeviceLostReason::Unknown, e.to_string(), can_gc);
|
||||
promise.resolve_native(&device);
|
||||
},
|
||||
WebGPUResponse::None => unreachable!("Failed to get a response for RequestDevice"),
|
||||
|
|
|
@ -81,6 +81,7 @@ impl GPUBindGroup {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUBindGroupDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<GPUBindGroup> {
|
||||
let entries = descriptor
|
||||
.entries
|
||||
|
@ -114,7 +115,7 @@ impl GPUBindGroup {
|
|||
device.id(),
|
||||
&descriptor.layout,
|
||||
descriptor.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ impl GPUBindGroupLayout {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUBindGroupLayoutDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
||||
let entries = descriptor
|
||||
.entries
|
||||
|
@ -111,7 +112,7 @@ impl GPUBindGroupLayout {
|
|||
device.channel().clone(),
|
||||
bgl,
|
||||
descriptor.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,7 @@ impl GPUBuffer {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUBufferDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<GPUBuffer>> {
|
||||
let desc = wgt::BufferDescriptor {
|
||||
label: (&descriptor.parent).convert(),
|
||||
|
@ -175,7 +176,7 @@ impl GPUBuffer {
|
|||
descriptor.usage,
|
||||
mapping,
|
||||
descriptor.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ impl GPUCommandEncoder {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUCommandEncoderDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<GPUCommandEncoder> {
|
||||
let command_encoder_id = device.global().wgpu_id_hub().create_command_encoder_id();
|
||||
device
|
||||
|
@ -110,7 +111,7 @@ impl GPUCommandEncoder {
|
|||
device,
|
||||
encoder,
|
||||
descriptor.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ impl GPUCompilationInfo {
|
|||
Self::new(
|
||||
global,
|
||||
if let Some(error) = error {
|
||||
vec![GPUCompilationMessage::from(global, error)]
|
||||
vec![GPUCompilationMessage::from(global, error, can_gc)]
|
||||
} else {
|
||||
Vec::new()
|
||||
},
|
||||
|
|
|
@ -68,7 +68,11 @@ impl GPUCompilationMessage {
|
|||
)
|
||||
}
|
||||
|
||||
pub(crate) fn from(global: &GlobalScope, info: ShaderCompilationInfo) -> DomRoot<Self> {
|
||||
pub(crate) fn from(
|
||||
global: &GlobalScope,
|
||||
info: ShaderCompilationInfo,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<Self> {
|
||||
GPUCompilationMessage::new(
|
||||
global,
|
||||
info.message.into(),
|
||||
|
@ -77,7 +81,7 @@ impl GPUCompilationMessage {
|
|||
info.line_pos,
|
||||
info.offset,
|
||||
info.length,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -369,10 +369,10 @@ impl GPUDevice {
|
|||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#lose-the-device>
|
||||
pub(crate) fn lose(&self, reason: GPUDeviceLostReason, msg: String) {
|
||||
pub(crate) fn lose(&self, reason: GPUDeviceLostReason, msg: String, can_gc: CanGc) {
|
||||
let lost_promise = &(*self.lost_promise.borrow());
|
||||
let global = &self.global();
|
||||
let lost = GPUDeviceLostInfo::new(global, msg.into(), reason, CanGc::note());
|
||||
let lost = GPUDeviceLostInfo::new(global, msg.into(), reason, can_gc);
|
||||
lost_promise.resolve_native(&*lost);
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ impl GPUDeviceMethods<crate::DomTypeHolder> for GPUDevice {
|
|||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbuffer>
|
||||
fn CreateBuffer(&self, descriptor: &GPUBufferDescriptor) -> Fallible<DomRoot<GPUBuffer>> {
|
||||
GPUBuffer::create(self, descriptor)
|
||||
GPUBuffer::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#GPUDevice-createBindGroupLayout>
|
||||
|
@ -419,7 +419,7 @@ impl GPUDeviceMethods<crate::DomTypeHolder> for GPUDevice {
|
|||
&self,
|
||||
descriptor: &GPUBindGroupLayoutDescriptor,
|
||||
) -> Fallible<DomRoot<GPUBindGroupLayout>> {
|
||||
GPUBindGroupLayout::create(self, descriptor)
|
||||
GPUBindGroupLayout::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createpipelinelayout>
|
||||
|
@ -427,12 +427,12 @@ impl GPUDeviceMethods<crate::DomTypeHolder> for GPUDevice {
|
|||
&self,
|
||||
descriptor: &GPUPipelineLayoutDescriptor,
|
||||
) -> DomRoot<GPUPipelineLayout> {
|
||||
GPUPipelineLayout::create(self, descriptor)
|
||||
GPUPipelineLayout::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createbindgroup>
|
||||
fn CreateBindGroup(&self, descriptor: &GPUBindGroupDescriptor) -> DomRoot<GPUBindGroup> {
|
||||
GPUBindGroup::create(self, descriptor)
|
||||
GPUBindGroup::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createshadermodule>
|
||||
|
@ -478,17 +478,17 @@ impl GPUDeviceMethods<crate::DomTypeHolder> for GPUDevice {
|
|||
&self,
|
||||
descriptor: &GPUCommandEncoderDescriptor,
|
||||
) -> DomRoot<GPUCommandEncoder> {
|
||||
GPUCommandEncoder::create(self, descriptor)
|
||||
GPUCommandEncoder::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createtexture>
|
||||
fn CreateTexture(&self, descriptor: &GPUTextureDescriptor) -> Fallible<DomRoot<GPUTexture>> {
|
||||
GPUTexture::create(self, descriptor)
|
||||
GPUTexture::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createsampler>
|
||||
fn CreateSampler(&self, descriptor: &GPUSamplerDescriptor) -> DomRoot<GPUSampler> {
|
||||
GPUSampler::create(self, descriptor)
|
||||
GPUSampler::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-createrenderpipeline>
|
||||
|
@ -526,7 +526,7 @@ impl GPUDeviceMethods<crate::DomTypeHolder> for GPUDevice {
|
|||
&self,
|
||||
descriptor: &GPURenderBundleEncoderDescriptor,
|
||||
) -> Fallible<DomRoot<GPURenderBundleEncoder>> {
|
||||
GPURenderBundleEncoder::create(self, descriptor)
|
||||
GPURenderBundleEncoder::create(self, descriptor, CanGc::note())
|
||||
}
|
||||
|
||||
/// <https://gpuweb.github.io/gpuweb/#dom-gpudevice-pusherrorscope>
|
||||
|
|
|
@ -83,6 +83,7 @@ impl GPUPipelineLayout {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUPipelineLayoutDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<GPUPipelineLayout> {
|
||||
let bgls = descriptor
|
||||
.bindGroupLayouts
|
||||
|
@ -114,7 +115,7 @@ impl GPUPipelineLayout {
|
|||
pipeline_layout,
|
||||
descriptor.parent.label.clone(),
|
||||
bgls,
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ impl GPURenderBundleEncoder {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPURenderBundleEncoderDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<GPURenderBundleEncoder>> {
|
||||
let desc = RenderBundleEncoderDescriptor {
|
||||
label: (&descriptor.parent.parent).convert(),
|
||||
|
@ -124,7 +125,7 @@ impl GPURenderBundleEncoder {
|
|||
device,
|
||||
device.channel().clone(),
|
||||
descriptor.parent.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ impl GPUSampler {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUSamplerDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<GPUSampler> {
|
||||
let sampler_id = device.global().wgpu_id_hub().create_sampler_id();
|
||||
let compare_enable = descriptor.compare.is_some();
|
||||
|
@ -121,7 +122,7 @@ impl GPUSampler {
|
|||
compare_enable,
|
||||
sampler,
|
||||
descriptor.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ impl GPUShaderModule {
|
|||
WebGPUShaderModule(program_id),
|
||||
descriptor.parent.label.clone(),
|
||||
promise.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
);
|
||||
let sender = response_async(&promise, &*shader_module);
|
||||
device
|
||||
|
|
|
@ -131,6 +131,7 @@ impl GPUTexture {
|
|||
pub(crate) fn create(
|
||||
device: &GPUDevice,
|
||||
descriptor: &GPUTextureDescriptor,
|
||||
can_gc: CanGc,
|
||||
) -> Fallible<DomRoot<GPUTexture>> {
|
||||
let (desc, size) = convert_texture_descriptor(descriptor, device)?;
|
||||
|
||||
|
@ -160,7 +161,7 @@ impl GPUTexture {
|
|||
descriptor.format,
|
||||
descriptor.usage,
|
||||
descriptor.parent.label.clone(),
|
||||
CanGc::note(),
|
||||
can_gc,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue