summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/iris
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2019-05-08 12:37:32 -0700
committerKenneth Graunke <[email protected]>2019-05-08 12:43:08 -0700
commitd9b9bb91ff1f6f519d69191fefe82c32c666633e (patch)
treefcc322a3077f3b9e08aa22d0afeee1e6ba069958 /src/gallium/drivers/iris
parent5f8d29ab4be861fc424b033ebb098d14d90ed099 (diff)
iris: Report the same video memory settings as i965.
This just copy and pastes Ian's code from i965.
Diffstat (limited to 'src/gallium/drivers/iris')
-rw-r--r--src/gallium/drivers/iris/iris_screen.c34
-rw-r--r--src/gallium/drivers/iris/iris_screen.h2
2 files changed, 34 insertions, 2 deletions
diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c
index 30d32b2ed43..b42c359d833 100644
--- a/src/gallium/drivers/iris/iris_screen.c
+++ b/src/gallium/drivers/iris/iris_screen.c
@@ -93,6 +93,14 @@ iris_get_name(struct pipe_screen *pscreen)
return buf;
}
+static uint64_t
+get_aperture_size(int fd)
+{
+ struct drm_i915_gem_get_aperture aperture = {};
+ drm_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture);
+ return aperture.aper_size;
+}
+
static int
iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
{
@@ -250,8 +258,28 @@ iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
return 0x8086;
case PIPE_CAP_DEVICE_ID:
return screen->pci_id;
- case PIPE_CAP_VIDEO_MEMORY:
- return INT_MAX; // XXX: bogus
+ case PIPE_CAP_VIDEO_MEMORY: {
+ /* Once a batch uses more than 75% of the maximum mappable size, we
+ * assume that there's some fragmentation, and we start doing extra
+ * flushing, etc. That's the big cliff apps will care about.
+ */
+ const unsigned gpu_mappable_megabytes =
+ (screen->aperture_bytes * 3 / 4) / (1024 * 1024);
+
+ const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
+ const long system_page_size = sysconf(_SC_PAGE_SIZE);
+
+ if (system_memory_pages <= 0 || system_page_size <= 0)
+ return -1;
+
+ const uint64_t system_memory_bytes =
+ (uint64_t) system_memory_pages * (uint64_t) system_page_size;
+
+ const unsigned system_memory_megabytes =
+ (unsigned) (system_memory_bytes / (1024 * 1024));
+
+ return MIN2(system_memory_megabytes, gpu_mappable_megabytes);
+ }
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
case PIPE_CAP_MAX_VARYINGS:
return 32;
@@ -575,6 +603,8 @@ iris_screen_create(int fd, const struct pipe_screen_config *config)
screen->devinfo.timestamp_frequency =
iris_getparam_integer(screen, I915_PARAM_CS_TIMESTAMP_FREQUENCY);
+ screen->aperture_bytes = get_aperture_size(fd);
+
if (getenv("INTEL_NO_HW") != NULL)
screen->no_hw = true;
diff --git a/src/gallium/drivers/iris/iris_screen.h b/src/gallium/drivers/iris/iris_screen.h
index a8f33dc3236..270597a46d0 100644
--- a/src/gallium/drivers/iris/iris_screen.h
+++ b/src/gallium/drivers/iris/iris_screen.h
@@ -68,6 +68,8 @@ struct iris_screen {
unsigned subslice_total;
+ uint64_t aperture_bytes;
+
struct gen_device_info devinfo;
struct isl_device isl_dev;
struct iris_bufmgr *bufmgr;