зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1713486. Fix per context swgl memory reporting. r=lsalzman
This passes the swgl context down from the renderer instead of using the current context. This ensures we report all of the contexts and don't double report. Differential Revision: https://phabricator.services.mozilla.com/D116474
This commit is contained in:
Родитель
78bfa75ec7
Коммит
6826ec4fff
|
@ -413,7 +413,7 @@ RenderTextureHost* RendererOGL::GetRenderTexture(
|
|||
}
|
||||
|
||||
void RendererOGL::AccumulateMemoryReport(MemoryReport* aReport) {
|
||||
wr_renderer_accumulate_memory_report(GetRenderer(), aReport);
|
||||
wr_renderer_accumulate_memory_report(GetRenderer(), aReport, swgl());
|
||||
|
||||
LayoutDeviceIntSize size = mCompositor->GetBufferSize();
|
||||
|
||||
|
|
|
@ -784,8 +784,8 @@ pub unsafe extern "C" fn wr_renderer_delete(renderer: *mut Renderer) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wr_renderer_accumulate_memory_report(renderer: &mut Renderer, report: &mut MemoryReport) {
|
||||
*report += renderer.report_memory();
|
||||
pub unsafe extern "C" fn wr_renderer_accumulate_memory_report(renderer: &mut Renderer, report: &mut MemoryReport, swgl: *mut c_void) {
|
||||
*report += renderer.report_memory(swgl);
|
||||
}
|
||||
|
||||
// cbindgen doesn't support tuples, so we have a little struct instead, with
|
||||
|
|
|
@ -2793,7 +2793,7 @@ void DestroyContext(Context* c) {
|
|||
delete c;
|
||||
}
|
||||
|
||||
size_t ReportMemory(size_t (*size_of_op)(void*)) {
|
||||
size_t ReportMemory(Context *ctx, size_t (*size_of_op)(void*)) {
|
||||
size_t size = 0;
|
||||
if (ctx) {
|
||||
for (auto& t : ctx->textures) {
|
||||
|
|
|
@ -316,7 +316,7 @@ extern "C" {
|
|||
fn ReferenceContext(ctx: *mut c_void);
|
||||
fn DestroyContext(ctx: *mut c_void);
|
||||
fn MakeCurrent(ctx: *mut c_void);
|
||||
fn ReportMemory(size_of_op: unsafe extern "C" fn(ptr: *const c_void) -> usize) -> usize;
|
||||
fn ReportMemory(ctx: *mut c_void, size_of_op: unsafe extern "C" fn(ptr: *const c_void) -> usize) -> usize;
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
|
@ -451,8 +451,8 @@ impl Context {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn report_memory(size_of_op: unsafe extern "C" fn(ptr: *const c_void) -> usize) -> usize {
|
||||
unsafe { ReportMemory(size_of_op) }
|
||||
pub fn report_memory(&self, size_of_op: unsafe extern "C" fn(ptr: *const c_void) -> usize) -> usize {
|
||||
unsafe { ReportMemory(self.0, size_of_op) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3916,17 +3916,18 @@ impl Device {
|
|||
}
|
||||
|
||||
/// Generates a memory report for the resources managed by the device layer.
|
||||
pub fn report_memory(&self, size_op_funs: &MallocSizeOfOps) -> MemoryReport {
|
||||
pub fn report_memory(&self, size_op_funs: &MallocSizeOfOps, swgl: *mut c_void) -> MemoryReport {
|
||||
let mut report = MemoryReport::default();
|
||||
for dim in self.depth_targets.keys() {
|
||||
report.depth_target_textures += depth_target_size_in_bytes(dim);
|
||||
}
|
||||
#[cfg(feature = "sw_compositor")]
|
||||
{
|
||||
report.swgl += swgl::Context::report_memory(size_op_funs.size_of_op);
|
||||
if !swgl.is_null() {
|
||||
report.swgl += swgl::Context::from(swgl).report_memory(size_op_funs.size_of_op);
|
||||
}
|
||||
// unconditionally use size_op_funs
|
||||
// unconditionally use swgl stuff
|
||||
let _ = size_op_funs;
|
||||
let _ = swgl;
|
||||
report
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ use std::{
|
|||
cell::RefCell,
|
||||
collections::VecDeque,
|
||||
f32,
|
||||
ffi::c_void,
|
||||
mem,
|
||||
num::NonZeroUsize,
|
||||
path::PathBuf,
|
||||
|
@ -5142,7 +5143,7 @@ impl Renderer {
|
|||
}
|
||||
|
||||
/// Collects a memory report.
|
||||
pub fn report_memory(&self) -> MemoryReport {
|
||||
pub fn report_memory(&self, swgl: *mut c_void) -> MemoryReport {
|
||||
let mut report = MemoryReport::default();
|
||||
|
||||
// GPU cache CPU memory.
|
||||
|
@ -5168,7 +5169,7 @@ impl Renderer {
|
|||
report += self.texture_upload_pbo_pool.report_memory();
|
||||
|
||||
// Textures held internally within the device layer.
|
||||
report += self.device.report_memory(self.size_of_ops.as_ref().unwrap());
|
||||
report += self.device.report_memory(self.size_of_ops.as_ref().unwrap(), swgl);
|
||||
|
||||
report
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче