mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 08:20:12 +01:00
rusticl: add memory debugging
Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32942>
This commit is contained in:
parent
da4de8d7e3
commit
c7d09eca27
6 changed files with 43 additions and 2 deletions
|
|
@ -1196,6 +1196,7 @@ Rusticl environment variables
|
|||
|
||||
- ``allow_invalid_spirv`` disables validation of any input SPIR-V
|
||||
- ``clc`` dumps all OpenCL C source being compiled
|
||||
- ``memory`` enables debugging of memory objects
|
||||
- ``nir`` dumps nirs in various compilation stages. Might print nothing if shader caching is
|
||||
enabled.
|
||||
- ``no_reuse_context`` pipe_contexts are not recycled
|
||||
|
|
|
|||
|
|
@ -348,6 +348,10 @@ impl Context {
|
|||
|
||||
let res = res.ok_or(CL_OUT_OF_RESOURCES)?;
|
||||
if !dev.system_svm_supported() {
|
||||
if Platform::dbg().memory {
|
||||
eprintln!("assigning {address:x} to {res:?}");
|
||||
}
|
||||
|
||||
if !dev.screen().resource_assign_vma(&res, address) {
|
||||
return Err(CL_OUT_OF_RESOURCES);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use std::collections::HashMap;
|
|||
use std::convert::TryInto;
|
||||
use std::env;
|
||||
use std::ffi::CStr;
|
||||
use std::fmt::Debug;
|
||||
use std::mem::transmute;
|
||||
use std::num::NonZeroU64;
|
||||
use std::os::raw::*;
|
||||
|
|
@ -1257,6 +1258,14 @@ impl Device {
|
|||
}
|
||||
}
|
||||
|
||||
impl Debug for Device {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct(&format!("Device@{:?}", self as *const _))
|
||||
.field("name", &self.screen().name())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn devs() -> &'static [Device] {
|
||||
&Platform::get().devs
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use crate::core::context::*;
|
|||
use crate::core::device::*;
|
||||
use crate::core::format::*;
|
||||
use crate::core::gl::*;
|
||||
use crate::core::platform::*;
|
||||
use crate::core::queue::*;
|
||||
use crate::core::util::*;
|
||||
use crate::impl_cl_type_trait;
|
||||
|
|
@ -28,6 +29,7 @@ use std::cmp;
|
|||
use std::collections::btree_map::Entry;
|
||||
use std::collections::HashMap;
|
||||
use std::convert::TryInto;
|
||||
use std::fmt::Debug;
|
||||
use std::mem;
|
||||
use std::mem::size_of;
|
||||
use std::num::NonZeroU64;
|
||||
|
|
@ -109,6 +111,12 @@ impl ConstMemoryPtr {
|
|||
}
|
||||
}
|
||||
|
||||
impl Debug for ConstMemoryPtr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.ptr.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<MutMemoryPtr> for ConstMemoryPtr {
|
||||
fn from(value: MutMemoryPtr) -> Self {
|
||||
Self {
|
||||
|
|
@ -125,6 +133,12 @@ pub struct MutMemoryPtr {
|
|||
unsafe impl Send for MutMemoryPtr {}
|
||||
unsafe impl Sync for MutMemoryPtr {}
|
||||
|
||||
impl Debug for MutMemoryPtr {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.ptr.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl MutMemoryPtr {
|
||||
pub fn as_ptr(&self) -> *mut c_void {
|
||||
self.ptr
|
||||
|
|
@ -139,7 +153,7 @@ impl MutMemoryPtr {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum ResourceValidityEntity {
|
||||
Host,
|
||||
Device(&'static Device),
|
||||
|
|
@ -222,6 +236,10 @@ impl ResourceAllocation {
|
|||
let map;
|
||||
let flush;
|
||||
|
||||
if Platform::dbg().memory {
|
||||
eprintln!("migrating {self:?} from {entity:?} to {dev_entity:?}");
|
||||
}
|
||||
|
||||
if to_res.is_buffer() {
|
||||
let ptr;
|
||||
match entity {
|
||||
|
|
@ -391,6 +409,12 @@ impl ResourceAllocation {
|
|||
}
|
||||
}
|
||||
|
||||
impl Debug for ResourceAllocation {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.write_fmt(format_args!("ResourceAllocation@{:?}", self as *const _))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SubAllocation {
|
||||
mem: Mem,
|
||||
// offset relative to the actual resource, not relative to `mem`. This saves us a few
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ pub struct PlatformDebug {
|
|||
pub allow_invalid_spirv: bool,
|
||||
pub clc: bool,
|
||||
pub max_grid_size: u32,
|
||||
pub memory: bool,
|
||||
pub nir: bool,
|
||||
pub no_variants: bool,
|
||||
pub perf: PerfDebugLevel,
|
||||
|
|
@ -85,6 +86,7 @@ static mut PLATFORM_DBG: PlatformDebug = PlatformDebug {
|
|||
allow_invalid_spirv: false,
|
||||
clc: false,
|
||||
max_grid_size: 0,
|
||||
memory: false,
|
||||
nir: false,
|
||||
no_variants: false,
|
||||
perf: PerfDebugLevel::None,
|
||||
|
|
@ -107,6 +109,7 @@ fn load_env() {
|
|||
match flag {
|
||||
"allow_invalid_spirv" => debug.allow_invalid_spirv = true,
|
||||
"clc" => debug.clc = true,
|
||||
"memory" => debug.memory = true,
|
||||
"nir" => debug.nir = true,
|
||||
"no_reuse_context" => debug.reuse_context = false,
|
||||
"no_variants" => debug.no_variants = true,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::{
|
|||
|
||||
use super::context::PipeContext;
|
||||
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub struct PipeResource {
|
||||
pipe: NonNull<pipe_resource>,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue