static int i915_query_renderer_integer(__DRIscreen *psp, int param, unsigned int *value) { const struct intel_screen *const intelScreen = (struct intel_screen *) psp->driverPrivate; switch (param) { case __DRI2_RENDERER_VENDOR_ID: value[0] = 0x8086; return 0; case __DRI2_RENDERER_DEVICE_ID: value[0] = intelScreen->deviceID; return 0; case __DRI2_RENDERER_ACCELERATED: value[0] = 1; return 0; case __DRI2_RENDERER_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(psp->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 -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); value[0] = MIN2(system_memory_megabytes, gpu_mappable_megabytes); return 0; } case __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE: value[0] = 1; return 0; case __DRI2_RENDERER_PREFERRED_PROFILE: value[0] = (1U << __DRI_API_OPENGL); return 0; default: return driQueryRendererIntegerCommon(psp, param, value); } return -1; }
static bool probe_winsys(struct intel_winsys *winsys) { struct intel_winsys_info *info = &winsys->info; int val; /* * When we need the Nth vertex from a user vertex buffer, and the vertex is * uploaded to, say, the beginning of a bo, we want the first vertex in the * bo to be fetched. One way to do this is to set the base address of the * vertex buffer to * * bo->offset64 + (vb->buffer_offset - vb->stride * N). * * The second term may be negative, and we need kernel support to do that. * * This check is taken from the classic driver. u_vbuf_upload_buffers() * guarantees the term is never negative, but it is good to require a * recent kernel. */ get_param(winsys, I915_PARAM_HAS_RELAXED_DELTA, &val); if (!val) { debug_error("kernel 2.6.39 required"); return false; } info->devid = drm_intel_bufmgr_gem_get_devid(winsys->bufmgr); if (drm_intel_get_aperture_sizes(winsys->fd, &info->aperture_mappable, &info->aperture_total)) { debug_error("failed to query aperture sizes"); return false; } get_param(winsys, I915_PARAM_HAS_LLC, &val); info->has_llc = val; info->has_address_swizzling = test_address_swizzling(winsys); winsys->first_gem_ctx = drm_intel_gem_context_create(winsys->bufmgr); info->has_logical_context = (winsys->first_gem_ctx != NULL); get_param(winsys, I915_PARAM_HAS_ALIASING_PPGTT, &val); info->has_ppgtt = val; /* test TIMESTAMP read */ info->has_timestamp = test_reg_read(winsys, 0x2358); get_param(winsys, I915_PARAM_HAS_GEN7_SOL_RESET, &val); info->has_gen7_sol_reset = val; return true; }