On Mon, Oct 19, 2015 at 12:08:41PM +0100, Chris Wilson wrote: > The amount of memory that the GPU can use in any single batch is the > amount of memory it can map into its page tables, that is the GTT size. > With per-process GTT (i.e. every context has its own set of page tables), > this value may differ from the global GTT size (and is often larger). > When reporting how much memory a client may use with the GPU, it is the > size of the context GTT that is the limiting factor. > > (Additionally, get_aperture_ioctl is relatively expensive for our query > of the constant GTT size as it also computes addition information not > used here and has the side-effect of doing a sysfs scan for PCI > devices.) > > Signed-off-by: Chris Wilson <ch...@chris-wilson.co.uk>
Since I just pulled in the kernel side earlier today: Reviewed-by: Daniel Vetter <daniel.vet...@ffwll.ch> > Cc: Daniel Vetter <dan...@ffwll.ch> > Cc: Kristian Høgsberg <k...@bitplanet.net> > Cc: Kenneth Graunke <kenn...@whitecape.org> > Cc: Ian Romanick <ian.d.roman...@intel.com> > --- > src/mesa/drivers/dri/i965/intel_screen.c | 22 +++++++++++++++++----- > 1 file changed, 17 insertions(+), 5 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/intel_screen.c > b/src/mesa/drivers/dri/i965/intel_screen.c > index b77b747..cdf5b0d 100644 > --- a/src/mesa/drivers/dri/i965/intel_screen.c > +++ b/src/mesa/drivers/dri/i965/intel_screen.c > @@ -787,6 +787,22 @@ static const __DRIimageExtension intelImageExtension = { > .getCapabilities = NULL > }; > > +static uint64_t intel_get_gtt_size(int fd) > +{ > + struct drm_i915_gem_context_param p; > + size_t mappable_size, aper_size; > + > + memset(&p, 0, sizeof(p)); > +#define I915_CONTEXT_PARAM_GTT_SIZE 0x3 /* XXX requires future libdrm */ > + p.param = I915_CONTEXT_PARAM_GTT_SIZE; Optional bikeshed: Maybe explicitly set the context to 0 to make it clear we're querying the (always present) default context here. > + if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p) == 0) > + return p.value; > + > + drm_intel_get_aperture_sizes(fd, &mappable_size, &aper_size); > + > + return aper_size; > +} > + > static int > brw_query_renderer_integer(__DRIscreen *psp, int param, unsigned int *value) > { > @@ -808,11 +824,7 @@ brw_query_renderer_integer(__DRIscreen *psp, int param, > unsigned int *value) > * assume that there's some fragmentation, and we start doing extra > * flushing, etc. That's the big cliff apps will care about. > */ > - size_t aper_size; > - size_t mappable_size; > - > - drm_intel_get_aperture_sizes(psp->fd, &mappable_size, &aper_size); > - > + uint64_t aper_size = intel_get_gtt_size(psp->fd); > const unsigned gpu_mappable_megabytes = > (aper_size / (1024 * 1024)) * 3 / 4; > > -- > 2.6.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev