зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1510490 - Measure shader cache memory usage and remove total_gpu_bytes. r=mattwoodrow
The latter causes confusion in the memory reports because it gets summed up and thus effectively doubles the reported texture memory usage. I've decided it's best to drop, and so might as well do that while we're already messing around with the memory reports and the associated boilerplate. Depends on D13439 Differential Revision: https://phabricator.services.mozilla.com/D13440 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
df736ea23b
Коммит
bb62909e72
|
@ -704,6 +704,7 @@ WebRenderMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
helper.Report(aReport.images, "resource-cache/images");
|
||||
helper.Report(aReport.rasterized_blobs,
|
||||
"resource-cache/rasterized-blobs");
|
||||
helper.Report(aReport.shader_cache, "shader-cache");
|
||||
|
||||
// GPU Memory.
|
||||
helper.ReportTexture(aReport.gpu_cache_textures, "gpu-cache");
|
||||
|
@ -713,9 +714,6 @@ WebRenderMemoryReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
|||
helper.ReportTexture(aReport.depth_target_textures, "depth-targets");
|
||||
helper.ReportTexture(aReport.swap_chain, "swap-chains");
|
||||
|
||||
// Total GPU bytes, for sanity-checking the above.
|
||||
helper.ReportTotalGPUBytes(aReport.total_gpu_bytes_allocated);
|
||||
|
||||
FinishAsyncMemoryReport();
|
||||
},
|
||||
[](mozilla::ipc::ResponseRejectReason aReason) {
|
||||
|
|
|
@ -30,6 +30,8 @@ using namespace mozilla;
|
|||
|
||||
static already_AddRefed<gl::GLContext> CreateGLContext();
|
||||
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF(WebRenderRendererMallocSizeOf)
|
||||
|
||||
namespace mozilla {
|
||||
namespace wr {
|
||||
|
||||
|
@ -128,14 +130,18 @@ void RenderThread::DoAccumulateMemoryReport(
|
|||
MemoryReport aReport,
|
||||
const RefPtr<MemoryReportPromise::Private>& aPromise) {
|
||||
MOZ_ASSERT(IsInRenderThread());
|
||||
MOZ_ASSERT(aReport.total_gpu_bytes_allocated == 0);
|
||||
|
||||
for (auto& r : mRenderers) {
|
||||
r.second->AccumulateMemoryReport(&aReport);
|
||||
}
|
||||
|
||||
// Note total gpu bytes allocated across all WR instances.
|
||||
aReport.total_gpu_bytes_allocated += wr_total_gpu_bytes_allocated();
|
||||
// Note memory used by the shader cache, which is shared across all WR
|
||||
// instances.
|
||||
MOZ_ASSERT(aReport.shader_cache == 0);
|
||||
if (mProgramCache) {
|
||||
aReport.shader_cache = wr_program_cache_report_memory(
|
||||
mProgramCache->Raw(), &WebRenderRendererMallocSizeOf);
|
||||
}
|
||||
|
||||
aPromise->Resolve(aReport, __func__);
|
||||
}
|
||||
|
|
|
@ -208,7 +208,6 @@ void RendererOGL::AccumulateMemoryReport(MemoryReport* aReport) {
|
|||
BytesPerPixel(SurfaceFormat::B8G8R8A8) *
|
||||
(mCompositor->UseTripleBuffering() ? 3 : 2);
|
||||
aReport->swap_chain += swapChainSize;
|
||||
aReport->total_gpu_bytes_allocated += swapChainSize;
|
||||
}
|
||||
|
||||
static void DoNotifyWebRenderError(layers::CompositorBridgeParent* aBridge,
|
||||
|
|
|
@ -675,11 +675,6 @@ pub unsafe extern "C" fn wr_renderer_accumulate_memory_report(renderer: &mut Ren
|
|||
*report += renderer.report_memory();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wr_total_gpu_bytes_allocated() -> usize {
|
||||
::webrender::total_gpu_bytes_allocated()
|
||||
}
|
||||
|
||||
// cbindgen doesn't support tuples, so we have a little struct instead, with
|
||||
// an Into implementation to convert from the tuple to the struct.
|
||||
#[repr(C)]
|
||||
|
@ -2799,3 +2794,11 @@ pub unsafe extern "C" fn wr_shaders_delete(shaders: *mut WrShaders, gl_context:
|
|||
}
|
||||
// let shaders go out of scope and get dropped
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn wr_program_cache_report_memory(
|
||||
cache: *const WrProgramCache,
|
||||
size_of_op: VoidPtrToSizeFn,
|
||||
) -> usize {
|
||||
(*cache).program_cache.report_memory(size_of_op)
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ impl ProgramCacheObserver for WrProgramCacheObserver {
|
|||
|
||||
|
||||
pub struct WrProgramCache {
|
||||
program_cache: Rc<ProgramCache>,
|
||||
pub program_cache: Rc<ProgramCache>,
|
||||
disk_cache: Option<Rc<RefCell<WrProgramBinaryDiskCache>>>,
|
||||
}
|
||||
|
||||
|
|
|
@ -539,13 +539,13 @@ struct MemoryReport {
|
|||
uintptr_t fonts;
|
||||
uintptr_t images;
|
||||
uintptr_t rasterized_blobs;
|
||||
uintptr_t shader_cache;
|
||||
uintptr_t gpu_cache_textures;
|
||||
uintptr_t vertex_data_textures;
|
||||
uintptr_t render_target_textures;
|
||||
uintptr_t texture_cache_textures;
|
||||
uintptr_t depth_target_textures;
|
||||
uintptr_t swap_chain;
|
||||
uintptr_t total_gpu_bytes_allocated;
|
||||
|
||||
bool operator==(const MemoryReport& aOther) const {
|
||||
return primitive_stores == aOther.primitive_stores &&
|
||||
|
@ -557,13 +557,13 @@ struct MemoryReport {
|
|||
fonts == aOther.fonts &&
|
||||
images == aOther.images &&
|
||||
rasterized_blobs == aOther.rasterized_blobs &&
|
||||
shader_cache == aOther.shader_cache &&
|
||||
gpu_cache_textures == aOther.gpu_cache_textures &&
|
||||
vertex_data_textures == aOther.vertex_data_textures &&
|
||||
render_target_textures == aOther.render_target_textures &&
|
||||
texture_cache_textures == aOther.texture_cache_textures &&
|
||||
depth_target_textures == aOther.depth_target_textures &&
|
||||
swap_chain == aOther.swap_chain &&
|
||||
total_gpu_bytes_allocated == aOther.total_gpu_bytes_allocated;
|
||||
swap_chain == aOther.swap_chain;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1008,6 +1008,12 @@ struct MutByteSlice {
|
|||
}
|
||||
};
|
||||
|
||||
// A C function that takes a pointer to a heap allocation and returns its size.
|
||||
//
|
||||
// This is borrowed from the malloc_size_of crate, upon which we want to avoid
|
||||
// a dependency from WebRender.
|
||||
using VoidPtrToSizeFn = uintptr_t(*)(const void*);
|
||||
|
||||
struct RendererStats {
|
||||
uintptr_t total_draw_calls;
|
||||
uintptr_t alpha_target_count;
|
||||
|
@ -1116,12 +1122,6 @@ struct WrOpacityProperty {
|
|||
}
|
||||
};
|
||||
|
||||
// A C function that takes a pointer to a heap allocation and returns its size.
|
||||
//
|
||||
// This is borrowed from the malloc_size_of crate, upon which we want to avoid
|
||||
// a dependency from WebRender.
|
||||
using VoidPtrToSizeFn = uintptr_t(*)(const void*);
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern void AddBlobFont(WrFontInstanceKey aInstanceKey,
|
||||
|
@ -1656,6 +1656,11 @@ WrProgramCache *wr_program_cache_new(const nsAString *aProfPath,
|
|||
WrThreadPool *aThreadPool)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
uintptr_t wr_program_cache_report_memory(const WrProgramCache *aCache,
|
||||
VoidPtrToSizeFn aSizeOfOp)
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_renderer_accumulate_memory_report(Renderer *aRenderer,
|
||||
MemoryReport *aReport)
|
||||
|
@ -1856,10 +1861,6 @@ WR_INLINE
|
|||
WrThreadPool *wr_thread_pool_new()
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
uintptr_t wr_total_gpu_bytes_allocated()
|
||||
WR_FUNC;
|
||||
|
||||
WR_INLINE
|
||||
void wr_transaction_append_transform_properties(Transaction *aTxn,
|
||||
const WrTransformProperty *aTransformArray,
|
||||
|
|
|
@ -6,6 +6,7 @@ use super::super::shader_source;
|
|||
use api::{ColorF, ImageFormat, MemoryReport};
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::TextureTarget;
|
||||
use api::VoidPtrToSizeFn;
|
||||
#[cfg(any(feature = "debug_renderer", feature="capture"))]
|
||||
use api::ImageDescriptor;
|
||||
use euclid::Transform3D;
|
||||
|
@ -20,6 +21,7 @@ use std::fs::File;
|
|||
use std::io::Read;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::os::raw::c_void;
|
||||
use std::ops::Add;
|
||||
use std::path::PathBuf;
|
||||
use std::ptr;
|
||||
|
@ -741,6 +743,13 @@ impl ProgramCache {
|
|||
let sources = program_binary.sources.clone();
|
||||
self.binaries.borrow_mut().insert(sources, program_binary);
|
||||
}
|
||||
|
||||
/// Returns the number of bytes allocated for shaders in the cache.
|
||||
pub fn report_memory(&self, op: VoidPtrToSizeFn) -> usize {
|
||||
self.binaries.borrow().values()
|
||||
.map(|b| unsafe { op(b.binary.as_ptr() as *const c_void ) })
|
||||
.sum()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
|
@ -196,7 +196,7 @@ pub extern crate webrender_api;
|
|||
#[doc(hidden)]
|
||||
pub use device::{build_shader_strings, ReadPixelsFormat, UploadMethod, VertexUsageHint};
|
||||
pub use device::{ProgramBinary, ProgramCache, ProgramCacheObserver, ProgramSources};
|
||||
pub use device::{Device, total_gpu_bytes_allocated};
|
||||
pub use device::Device;
|
||||
pub use frame_builder::ChasePrimitive;
|
||||
pub use renderer::{AsyncPropertySampler, CpuProfile, DebugFlags, OutputImageHandler, RendererKind};
|
||||
pub use renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource, GpuProfile};
|
||||
|
|
|
@ -847,6 +847,7 @@ pub struct MemoryReport {
|
|||
pub fonts: usize,
|
||||
pub images: usize,
|
||||
pub rasterized_blobs: usize,
|
||||
pub shader_cache: usize,
|
||||
//
|
||||
// GPU memory.
|
||||
//
|
||||
|
@ -856,10 +857,6 @@ pub struct MemoryReport {
|
|||
pub texture_cache_textures: usize,
|
||||
pub depth_target_textures: usize,
|
||||
pub swap_chain: usize,
|
||||
//
|
||||
// GPU memory total (tracked separately, should equal the sum of the above).
|
||||
//
|
||||
pub total_gpu_bytes_allocated: usize,
|
||||
}
|
||||
|
||||
impl ::std::ops::AddAssign for MemoryReport {
|
||||
|
@ -873,16 +870,13 @@ impl ::std::ops::AddAssign for MemoryReport {
|
|||
self.fonts += other.fonts;
|
||||
self.images += other.images;
|
||||
self.rasterized_blobs += other.rasterized_blobs;
|
||||
self.shader_cache += other.shader_cache;
|
||||
self.gpu_cache_textures += other.gpu_cache_textures;
|
||||
self.vertex_data_textures += other.vertex_data_textures;
|
||||
self.render_target_textures += other.render_target_textures;
|
||||
self.texture_cache_textures += other.texture_cache_textures;
|
||||
self.depth_target_textures += other.depth_target_textures;
|
||||
self.swap_chain += other.swap_chain;
|
||||
|
||||
// The total_gpu_memory value accounts for all WebRender instances, and
|
||||
// thus can't be aggregated. It should really be reported out of band,
|
||||
// but putting it in this struct facilitates sending it across Gecko IPC.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче