mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
reuse ImageKey for gpucanvascontext (#33517)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
3a0d27b231
commit
bab769a7cf
4 changed files with 22 additions and 37 deletions
|
@ -103,7 +103,7 @@ pub enum WebGPURequest {
|
|||
/// present only on ASYNC versions
|
||||
async_sender: Option<IpcSender<WebGPUResponse>>,
|
||||
},
|
||||
CreateContext(IpcSender<WebGPUContextId>),
|
||||
CreateContext(IpcSender<(WebGPUContextId, ImageKey)>),
|
||||
CreatePipelineLayout {
|
||||
device_id: id::DeviceId,
|
||||
pipeline_layout_id: id::PipelineLayoutId,
|
||||
|
@ -134,7 +134,7 @@ pub enum WebGPURequest {
|
|||
queue_id: id::QueueId,
|
||||
buffer_ids: ArrayVec<id::BufferId, PRESENTATION_BUFFER_COUNT>,
|
||||
context_id: WebGPUContextId,
|
||||
sender: IpcSender<ImageKey>,
|
||||
image_key: ImageKey,
|
||||
format: ImageFormat,
|
||||
size: DeviceIntSize,
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::collections::HashMap;
|
|||
use std::ops::ControlFlow;
|
||||
use std::ptr::NonNull;
|
||||
use std::slice;
|
||||
use std::sync::{Arc, Mutex, MutexGuard};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use euclid::default::Size2D;
|
||||
|
@ -234,7 +234,6 @@ impl crate::WGPU {
|
|||
format: ImageFormat,
|
||||
size: DeviceIntSize,
|
||||
image_key: ImageKey,
|
||||
mut wr: MutexGuard<RenderApi>,
|
||||
) {
|
||||
let image_desc = ImageDescriptor {
|
||||
format,
|
||||
|
@ -265,7 +264,10 @@ impl crate::WGPU {
|
|||
|
||||
let mut txn = Transaction::new();
|
||||
txn.add_image(image_key, image_desc, image_data, None);
|
||||
wr.send_transaction(self.webrender_document, txn);
|
||||
self.webrender_api
|
||||
.lock()
|
||||
.unwrap()
|
||||
.send_transaction(self.webrender_document, txn);
|
||||
}
|
||||
|
||||
/// Copies data async from provided texture using encoder_id to available staging presentation buffer
|
||||
|
|
|
@ -410,7 +410,8 @@ impl WGPU {
|
|||
.lock()
|
||||
.expect("Lock poisoned?")
|
||||
.next_id(WebrenderImageHandlerType::WebGPU);
|
||||
if let Err(e) = sender.send(WebGPUContextId(id.0)) {
|
||||
let image_key = self.webrender_api.lock().unwrap().generate_image_key();
|
||||
if let Err(e) = sender.send((WebGPUContextId(id.0), image_key)) {
|
||||
warn!("Failed to send ExternalImageId to new context ({})", e);
|
||||
};
|
||||
},
|
||||
|
@ -517,20 +518,12 @@ impl WGPU {
|
|||
queue_id,
|
||||
buffer_ids,
|
||||
context_id,
|
||||
sender,
|
||||
image_key,
|
||||
size,
|
||||
format,
|
||||
} => {
|
||||
let wr = self.webrender_api.lock().unwrap();
|
||||
let image_key = wr.generate_image_key();
|
||||
if let Err(e) = sender.send(image_key) {
|
||||
warn!("Failed to send ImageKey ({})", e);
|
||||
}
|
||||
self.create_swapchain(
|
||||
device_id, queue_id, buffer_ids, context_id, format, size, image_key,
|
||||
wr,
|
||||
)
|
||||
},
|
||||
} => self.create_swapchain(
|
||||
device_id, queue_id, buffer_ids, context_id, format, size, image_key,
|
||||
),
|
||||
WebGPURequest::CreateTexture {
|
||||
device_id,
|
||||
texture_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue