[Mesa-dev] [PATCH 20/25] gallium/ilo: handle query_renderer caps
Chia-I Wu
olvaffe at gmail.com
Sat Feb 22 06:41:43 PST 2014
On Sat, Feb 22, 2014 at 11:04 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> Implementation is a verbatim copy from the classic driver.
>
> This introduces a driver dependency on libdrm-intel, as the winsys does not
> cache the aperture size of the device.
>
> This implemetation duplicates the fd from intel_winsys to intel_winsys_info
> and ultimatelly to ilo_dev_info, due to the design of the former two.
>
> Cc: Chia-I Wu <olvaffe at gmail.com>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>
> Hi Chia-I
>
> I've looked at a cleaner way of doing things but I fell a bit short.
> Perhaps you can spare a minute and take a look if this can be handled
> in a cleaner way.
I think it is better to move the logic for video memory size
computation to winsys, and make winsys export the computed value. See
below.
>
> -Emil
>
> src/gallium/drivers/ilo/Makefile.am | 3 +-
> src/gallium/drivers/ilo/ilo_common.h | 1 +
> src/gallium/drivers/ilo/ilo_screen.c | 38 +++++++++++++++++++++++++
> src/gallium/winsys/intel/drm/intel_drm_winsys.c | 1 +
> src/gallium/winsys/intel/intel_winsys.h | 1 +
> 5 files changed, 43 insertions(+), 1 deletion(-)
>
> diff --git a/src/gallium/drivers/ilo/Makefile.am b/src/gallium/drivers/ilo/Makefile.am
> index 04d4da8..92906ea 100644
> --- a/src/gallium/drivers/ilo/Makefile.am
> +++ b/src/gallium/drivers/ilo/Makefile.am
> @@ -28,7 +28,8 @@ include $(top_srcdir)/src/gallium/Automake.inc
>
> AM_CPPFLAGS = \
> -I$(top_srcdir)/src/gallium/winsys/intel \
> - $(GALLIUM_DRIVER_CFLAGS)
> + $(GALLIUM_DRIVER_CFLAGS) \
> + $(INTEL_CFLAGS)
>
> noinst_LTLIBRARIES = libilo.la
>
> diff --git a/src/gallium/drivers/ilo/ilo_common.h b/src/gallium/drivers/ilo/ilo_common.h
> index 9145d32..c11aa86 100644
> --- a/src/gallium/drivers/ilo/ilo_common.h
> +++ b/src/gallium/drivers/ilo/ilo_common.h
> @@ -68,6 +68,7 @@ enum ilo_debug {
> struct ilo_dev_info {
> /* these mirror intel_winsys_info */
> int devid;
> + int fd;
> bool has_llc;
> bool has_gen7_sol_reset;
> bool has_address_swizzling;
> diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c
> index 4b595a6..43fb288 100644
> --- a/src/gallium/drivers/ilo/ilo_screen.c
> +++ b/src/gallium/drivers/ilo/ilo_screen.c
> @@ -25,6 +25,7 @@
> * Chia-I Wu <olv at lunarg.com>
> */
>
> +#include <intel_bufmgr.h>
> #include "util/u_format_s3tc.h"
> #include "vl/vl_decoder.h"
> #include "vl/vl_video_buffer.h"
> @@ -444,6 +445,42 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_MAX_GL_ES2_VERSION:
> return 20;
>
> + case PIPE_CAP_VENDOR_ID:
> + return 0x8086;
> + case PIPE_CAP_DEVICE_ID:
> + return is->dev.devid;
> + case PIPE_CAP_ACCELERATED:
> + return 1;
The convention for ilo is to return true.
> + 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.
> + */
> + size_t aper_size;
> + size_t mappable_size;
> +
> + drm_intel_get_aperture_sizes(is->dev.fd, &mappable_size, &aper_size);
> +
> + const unsigned gpu_mappable_megabytes =
> + (aper_size / (1024 * 1024)) * 3 / 4;
> +
> + 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 0;
> +
> + 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);
> + }
This should be moved to winsys, and variable declarations should be
moved to top (no C99 mixed declarations and code).
> + case PIPE_CAP_UMA:
> + return 1;
Return true.
> +
> default:
> return 0;
> }
> @@ -653,6 +690,7 @@ static bool
> init_dev(struct ilo_dev_info *dev, const struct intel_winsys_info *info)
> {
> dev->devid = info->devid;
> + dev->fd = info->fd;
> dev->has_llc = info->has_llc;
> dev->has_gen7_sol_reset = info->has_gen7_sol_reset;
> dev->has_address_swizzling = info->has_address_swizzling;
> diff --git a/src/gallium/winsys/intel/drm/intel_drm_winsys.c b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
> index d7ec919..7deb43e 100644
> --- a/src/gallium/winsys/intel/drm/intel_drm_winsys.c
> +++ b/src/gallium/winsys/intel/drm/intel_drm_winsys.c
> @@ -107,6 +107,7 @@ init_info(struct intel_winsys *winsys)
> }
>
> info->devid = drm_intel_bufmgr_gem_get_devid(winsys->bufmgr);
> + info->fd = winsys->fd;
>
> get_param(winsys, I915_PARAM_HAS_LLC, &val);
> info->has_llc = val;
> diff --git a/src/gallium/winsys/intel/intel_winsys.h b/src/gallium/winsys/intel/intel_winsys.h
> index 89df2a1..341975b 100644
> --- a/src/gallium/winsys/intel/intel_winsys.h
> +++ b/src/gallium/winsys/intel/intel_winsys.h
> @@ -74,6 +74,7 @@ struct intel_bo;
>
> struct intel_winsys_info {
> int devid;
> + int fd;
> bool has_llc;
> bool has_gen7_sol_reset;
> bool has_address_swizzling;
> --
> 1.9.0
>
--
olv at LunarG.com
More information about the mesa-dev
mailing list