mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Only send mapping back on unmap when MapMode = WRITE (#34054)
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
d5554235fe
commit
43d1601016
3 changed files with 20 additions and 23 deletions
|
@ -205,10 +205,15 @@ impl GPUBufferMethods for GPUBuffer {
|
||||||
// Step 5&7
|
// Step 5&7
|
||||||
if let Err(e) = self.channel.0.send(WebGPURequest::UnmapBuffer {
|
if let Err(e) = self.channel.0.send(WebGPURequest::UnmapBuffer {
|
||||||
buffer_id: self.id().0,
|
buffer_id: self.id().0,
|
||||||
array_buffer: IpcSharedMemory::from_bytes(mapping.data.data()),
|
mapping: if mapping.mode >= GPUMapModeConstants::WRITE {
|
||||||
write_back: mapping.mode >= GPUMapModeConstants::WRITE,
|
Some(Mapping {
|
||||||
offset: mapping.range.start,
|
data: IpcSharedMemory::from_bytes(mapping.data.data()),
|
||||||
size: mapping.range.end - mapping.range.start,
|
range: mapping.range.clone(),
|
||||||
|
mode: HostMap::Write,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
}) {
|
}) {
|
||||||
warn!("Failed to send Buffer unmap ({:?}) ({})", self.buffer.0, e);
|
warn!("Failed to send Buffer unmap ({:?}) ({})", self.buffer.0, e);
|
||||||
}
|
}
|
||||||
|
@ -249,8 +254,6 @@ impl GPUBufferMethods for GPUBuffer {
|
||||||
// Step 4
|
// Step 4
|
||||||
*self.pending_map.borrow_mut() = Some(promise.clone());
|
*self.pending_map.borrow_mut() = Some(promise.clone());
|
||||||
// Step 5
|
// Step 5
|
||||||
|
|
||||||
// This should be bitflags in wgpu-core
|
|
||||||
let host_map = match mode {
|
let host_map = match mode {
|
||||||
GPUMapModeConstants::READ => HostMap::Read,
|
GPUMapModeConstants::READ => HostMap::Read,
|
||||||
GPUMapModeConstants::WRITE => HostMap::Write,
|
GPUMapModeConstants::WRITE => HostMap::Write,
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub use {wgpu_core as wgc, wgpu_types as wgt};
|
||||||
use crate::identity::*;
|
use crate::identity::*;
|
||||||
use crate::render_commands::RenderCommand;
|
use crate::render_commands::RenderCommand;
|
||||||
use crate::swapchain::WebGPUContextId;
|
use crate::swapchain::WebGPUContextId;
|
||||||
use crate::{Error, ErrorFilter, WebGPUResponse, PRESENTATION_BUFFER_COUNT};
|
use crate::{Error, ErrorFilter, Mapping, WebGPUResponse, PRESENTATION_BUFFER_COUNT};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
|
||||||
pub struct ContextConfiguration {
|
pub struct ContextConfiguration {
|
||||||
|
@ -276,10 +276,8 @@ pub enum WebGPURequest {
|
||||||
},
|
},
|
||||||
UnmapBuffer {
|
UnmapBuffer {
|
||||||
buffer_id: id::BufferId,
|
buffer_id: id::BufferId,
|
||||||
array_buffer: IpcSharedMemory,
|
/// Return back mapping for writeback
|
||||||
write_back: bool,
|
mapping: Option<Mapping>,
|
||||||
offset: u64,
|
|
||||||
size: u64,
|
|
||||||
},
|
},
|
||||||
WriteBuffer {
|
WriteBuffer {
|
||||||
device_id: id::DeviceId,
|
device_id: id::DeviceId,
|
||||||
|
|
|
@ -995,25 +995,21 @@ impl WGPU {
|
||||||
};
|
};
|
||||||
self.maybe_dispatch_error(device_id, result.err());
|
self.maybe_dispatch_error(device_id, result.err());
|
||||||
},
|
},
|
||||||
WebGPURequest::UnmapBuffer {
|
WebGPURequest::UnmapBuffer { buffer_id, mapping } => {
|
||||||
buffer_id,
|
|
||||||
array_buffer,
|
|
||||||
write_back,
|
|
||||||
offset,
|
|
||||||
size,
|
|
||||||
} => {
|
|
||||||
let global = &self.global;
|
let global = &self.global;
|
||||||
if write_back {
|
if let Some(mapping) = mapping {
|
||||||
if let Ok((slice_pointer, range_size)) =
|
if let Ok((slice_pointer, range_size)) = global.buffer_get_mapped_range(
|
||||||
global.buffer_get_mapped_range(buffer_id, offset, Some(size))
|
buffer_id,
|
||||||
{
|
mapping.range.start,
|
||||||
|
Some(mapping.range.end - mapping.range.start),
|
||||||
|
) {
|
||||||
unsafe {
|
unsafe {
|
||||||
slice::from_raw_parts_mut(
|
slice::from_raw_parts_mut(
|
||||||
slice_pointer.as_ptr(),
|
slice_pointer.as_ptr(),
|
||||||
range_size as usize,
|
range_size as usize,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.copy_from_slice(&array_buffer);
|
.copy_from_slice(&mapping.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ignore result because this operation always succeed from user perspective
|
// Ignore result because this operation always succeed from user perspective
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue