#include "main/version.h"
#include "swrast/s_renderbuffer.h"
#include "util/ralloc.h"
+#include "util/disk_cache.h"
#include "brw_defines.h"
#include "brw_state.h"
#include "compiler/nir/nir.h"
#include "utils.h"
+#include "util/disk_cache.h"
#include "util/xmlpool.h"
+#include "common/gen_defines.h"
+
static const __DRIconfigOptionsExtension brw_config_options = {
.base = { __DRI_CONFIG_OPTIONS, 1 },
.xml =
.setTexBuffer = intelSetTexBuffer,
.setTexBuffer2 = intelSetTexBuffer2,
- .releaseTexBuffer = NULL,
+ .releaseTexBuffer = intelReleaseTexBuffer,
};
static void
{ __DRI_IMAGE_FOURCC_XRGB2101010, __DRI_IMAGE_COMPONENTS_RGB, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_XRGB2101010, 4 } } },
+ { __DRI_IMAGE_FOURCC_ABGR2101010, __DRI_IMAGE_COMPONENTS_RGBA, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_ABGR2101010, 4 } } },
+
+ { __DRI_IMAGE_FOURCC_XBGR2101010, __DRI_IMAGE_COMPONENTS_RGB, 1,
+ { { 0, 0, 0, __DRI_IMAGE_FORMAT_XBGR2101010, 4 } } },
+
{ __DRI_IMAGE_FOURCC_ARGB8888, __DRI_IMAGE_COMPONENTS_RGBA, 1,
{ { 0, 0, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } },
}
mesa_format format = driImageFormatToGLFormat(dri_format);
+ /* Whether or not we support compression is based on the RGBA non-sRGB
+ * version of the format.
+ */
+ format = _mesa_format_fallback_rgbx_to_rgba(format);
format = _mesa_get_srgb_format_linear(format);
if (!isl_format_supports_ccs_e(devinfo,
brw_isl_format_for_mesa_format(format)))
return NULL;
}
-static boolean intel_lookup_fourcc(int dri_format, int *fourcc)
+static boolean
+intel_image_get_fourcc(__DRIimage *image, int *fourcc)
{
+ if (image->planar_format) {
+ *fourcc = image->planar_format->fourcc;
+ return true;
+ }
+
for (unsigned i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
- if (intel_image_formats[i].planes[0].dri_format == dri_format) {
+ if (intel_image_formats[i].planes[0].dri_format == image->dri_format) {
*fourcc = intel_image_formats[i].fourcc;
return true;
}
intel_setup_image_from_mipmap_tree(brw, image, iobj->mt, level, zoffset);
image->dri_format = driGLFormatToImageFormat(image->format);
image->has_depthstencil = iobj->mt->stencil_mt? true : false;
- if (image->dri_format == MESA_FORMAT_NONE) {
+ image->planar_format = iobj->planar_format;
+ if (image->dri_format == __DRI_IMAGE_FORMAT_NONE) {
*error = __DRI_IMAGE_ERROR_BAD_PARAMETER;
free(image);
return NULL;
*/
image->bo = brw_bo_alloc_tiled(screen->bufmgr, "image",
surf.size + aux_surf.size,
+ BRW_MEMZONE_OTHER,
isl_tiling_to_i915_tiling(mod_info->tiling),
surf.row_pitch, BO_ALLOC_ZEROED);
if (image->bo == NULL) {
if (aux_surf.size) {
image->aux_offset = surf.size;
image->aux_pitch = aux_surf.row_pitch;
+ image->aux_size = aux_surf.size;
}
return image;
case __DRI_IMAGE_ATTRIB_FD:
return !brw_bo_gem_export_to_prime(image->bo, value);
case __DRI_IMAGE_ATTRIB_FOURCC:
- return intel_lookup_fourcc(image->dri_format, value);
+ return intel_image_get_fourcc(image, value);
case __DRI_IMAGE_ATTRIB_NUM_PLANES:
if (isl_drm_modifier_has_aux(image->modifier)) {
assert(!image->planar_format || image->planar_format->nplanes == 1);
image->planar_format = f;
- image->bo = brw_bo_gem_create_from_prime(screen->bufmgr, fds[0]);
+ if (modifier != DRM_FORMAT_MOD_INVALID) {
+ const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(modifier);
+ uint32_t tiling = isl_tiling_to_i915_tiling(mod_info->tiling);
+ image->bo = brw_bo_gem_create_from_prime_tiled(screen->bufmgr, fds[0],
+ tiling, strides[0]);
+ } else {
+ image->bo = brw_bo_gem_create_from_prime(screen->bufmgr, fds[0]);
+ }
+
if (image->bo == NULL) {
free(image);
return NULL;
image->strides[index] = strides[index];
mesa_format format = driImageFormatToGLFormat(f->planes[i].dri_format);
+ /* The images we will create are actually based on the RGBA non-sRGB
+ * version of the format.
+ */
+ format = _mesa_format_fallback_rgbx_to_rgba(format);
+ format = _mesa_get_srgb_format_linear(format);
ok = isl_surf_init(&screen->isl_dev, &surf,
.dim = ISL_SURF_DIM_2D,
return NULL;
}
+ image->aux_size = aux_surf.size;
+
const int end = image->aux_offset + aux_surf.size;
if (size < end)
size = end;
loaderPrivate);
}
+static bool
+intel_image_format_is_supported(const struct gen_device_info *devinfo,
+ const struct intel_image_format *fmt)
+{
+ if (fmt->fourcc == __DRI_IMAGE_FOURCC_SARGB8888 ||
+ fmt->fourcc == __DRI_IMAGE_FOURCC_SABGR8888)
+ return false;
+
+#ifndef NDEBUG
+ if (fmt->nplanes == 1) {
+ mesa_format format = driImageFormatToGLFormat(fmt->planes[0].dri_format);
+ /* The images we will create are actually based on the RGBA non-sRGB
+ * version of the format.
+ */
+ format = _mesa_format_fallback_rgbx_to_rgba(format);
+ format = _mesa_get_srgb_format_linear(format);
+ enum isl_format isl_format = brw_isl_format_for_mesa_format(format);
+ assert(isl_format_supports_rendering(devinfo, isl_format));
+ }
+#endif
+
+ return true;
+}
+
static GLboolean
-intel_query_dma_buf_formats(__DRIscreen *screen, int max,
+intel_query_dma_buf_formats(__DRIscreen *_screen, int max,
int *formats, int *count)
{
- int i, j = 0;
+ struct intel_screen *screen = _screen->driverPrivate;
+ int num_formats = 0, i;
- if (max == 0) {
- *count = ARRAY_SIZE(intel_image_formats) - 1; /* not SARGB */
- return true;
- }
+ for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) {
+ if (!intel_image_format_is_supported(&screen->devinfo,
+ &intel_image_formats[i]))
+ continue;
- for (i = 0; i < (ARRAY_SIZE(intel_image_formats)) && j < max; i++) {
- if (intel_image_formats[i].fourcc == __DRI_IMAGE_FOURCC_SARGB8888)
- continue;
- formats[j++] = intel_image_formats[i].fourcc;
+ num_formats++;
+ if (max == 0)
+ continue;
+
+ formats[num_formats - 1] = intel_image_formats[i].fourcc;
+ if (num_formats >= max)
+ break;
}
- *count = j;
+ *count = num_formats;
return true;
}
if (f == NULL)
return false;
+ if (!intel_image_format_is_supported(&screen->devinfo, f))
+ return false;
+
for (i = 0; i < ARRAY_SIZE(supported_modifiers); i++) {
uint64_t modifier = supported_modifiers[i].modifier;
if (!modifier_is_supported(&screen->devinfo, f, 0, modifier))
static __DRIimage *
intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
{
- int width, height, offset, stride, dri_format, index;
- const struct intel_image_format *f;
+ int width, height, offset, stride, size, dri_format;
__DRIimage *image;
- if (parent == NULL) {
+ if (parent == NULL)
return NULL;
- } else if (parent->planar_format == NULL) {
- const bool is_aux =
- isl_drm_modifier_has_aux(parent->modifier) && plane == 1;
- if (!is_aux)
- return NULL;
-
- width = parent->width;
- height = parent->height;
- dri_format = parent->dri_format;
- offset = parent->aux_offset;
- stride = parent->aux_pitch;
- } else {
- /* Planar formats don't support aux buffers/images */
- assert(!isl_drm_modifier_has_aux(parent->modifier));
- f = parent->planar_format;
- if (plane >= f->nplanes)
- return NULL;
+ width = parent->width;
+ height = parent->height;
+
+ const struct intel_image_format *f = parent->planar_format;
- width = parent->width >> f->planes[plane].width_shift;
- height = parent->height >> f->planes[plane].height_shift;
+ if (f && plane < f->nplanes) {
+ /* Use the planar format definition. */
+ width >>= f->planes[plane].width_shift;
+ height >>= f->planes[plane].height_shift;
dri_format = f->planes[plane].dri_format;
- index = f->planes[plane].buffer_index;
+ int index = f->planes[plane].buffer_index;
offset = parent->offsets[index];
stride = parent->strides[index];
+ size = height * stride;
+ } else if (plane == 0) {
+ /* The only plane of a non-planar image: copy the parent definition
+ * directly. */
+ dri_format = parent->dri_format;
+ offset = parent->offset;
+ stride = parent->pitch;
+ size = height * stride;
+ } else if (plane == 1 && parent->modifier != DRM_FORMAT_MOD_INVALID &&
+ isl_drm_modifier_has_aux(parent->modifier)) {
+ /* Auxiliary plane */
+ dri_format = parent->dri_format;
+ offset = parent->aux_offset;
+ stride = parent->aux_pitch;
+ size = parent->aux_size;
+ } else {
+ return NULL;
+ }
- if (offset + height * stride > parent->bo->size) {
- _mesa_warning(NULL, "intel_create_sub_image: subimage out of bounds");
- return NULL;
- }
+ if (offset + size > parent->bo->size) {
+ _mesa_warning(NULL, "intel_from_planar: subimage out of bounds");
+ return NULL;
}
image = intel_allocate_image(parent->screen, dri_format, loaderPrivate);
case __DRI2_RENDERER_HAS_CONTEXT_PRIORITY:
value[0] = 0;
if (brw_hw_context_set_priority(screen->bufmgr,
- 0, BRW_CONTEXT_HIGH_PRIORITY) == 0)
+ 0, GEN_CONTEXT_HIGH_PRIORITY) == 0)
value[0] |= __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH;
if (brw_hw_context_set_priority(screen->bufmgr,
- 0, BRW_CONTEXT_LOW_PRIORITY) == 0)
+ 0, GEN_CONTEXT_LOW_PRIORITY) == 0)
value[0] |= __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW;
/* reset to default last, just in case */
if (brw_hw_context_set_priority(screen->bufmgr,
- 0, BRW_CONTEXT_MEDIUM_PRIORITY) == 0)
+ 0, GEN_CONTEXT_MEDIUM_PRIORITY) == 0)
value[0] |= __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM;
return 0;
case __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB:
return -1;
}
+static void
+brw_set_cache_funcs(__DRIscreen *dri_screen,
+ __DRIblobCacheSet set, __DRIblobCacheGet get)
+{
+ const struct intel_screen *const screen =
+ (struct intel_screen *) dri_screen->driverPrivate;
+
+ if (!screen->disk_cache)
+ return;
+
+ disk_cache_set_callbacks(screen->disk_cache, set, get);
+}
+
static const __DRI2rendererQueryExtension intelRendererQueryExtension = {
.base = { __DRI2_RENDERER_QUERY, 1 },
.base = { __DRI2_ROBUSTNESS, 1 }
};
+static const __DRI2blobExtension intelBlobExtension = {
+ .base = { __DRI2_BLOB, 1 },
+ .set_cache_funcs = brw_set_cache_funcs
+};
+
static const __DRIextension *screenExtensions[] = {
&intelTexBufferExtension.base,
&intelFenceExtension.base,
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
&dri2NoErrorExtension.base,
- &dri2FlushControlExtension.base,
+ &intelBlobExtension.base,
NULL
};
&intelImageExtension.base,
&intelRendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
- &dri2FlushControlExtension.base,
&dri2Robustness.base,
&dri2NoErrorExtension.base,
+ &intelBlobExtension.base,
NULL
};
brw_bufmgr_destroy(screen->bufmgr);
driDestroyOptionInfo(&screen->optionCache);
+ disk_cache_destroy(screen->disk_cache);
+
ralloc_free(screen);
sPriv->driverPrivate = NULL;
}
return false;
}
- if (!intel_get_boolean(screen, I915_PARAM_HAS_WAIT_TIMEOUT)) {
- fprintf(stderr, "[%s: %u] Kernel 3.6 required.\n", __func__, __LINE__);
+ if (!intel_get_boolean(screen, I915_PARAM_HAS_EXEC_NO_RELOC)) {
+ fprintf(stderr, "[%s: %u] Kernel 3.9 required.\n", __func__, __LINE__);
return false;
}
static bool
intel_detect_swizzling(struct intel_screen *screen)
{
- struct brw_bo *buffer;
- unsigned flags = 0;
- uint32_t aligned_pitch;
uint32_t tiling = I915_TILING_X;
uint32_t swizzle_mode = 0;
-
- buffer = brw_bo_alloc_tiled_2d(screen->bufmgr, "swizzle test",
- 64, 64, 4, tiling, &aligned_pitch, flags);
+ struct brw_bo *buffer =
+ brw_bo_alloc_tiled(screen->bufmgr, "swizzle test", 32768,
+ BRW_MEMZONE_OTHER, tiling, 512, 0);
if (buffer == NULL)
return false;
brw_bo_get_tiling(buffer, &tiling, &swizzle_mode);
brw_bo_unreference(buffer);
- if (swizzle_mode == I915_BIT_6_SWIZZLE_NONE)
- return false;
- else
- return true;
+ return swizzle_mode != I915_BIT_6_SWIZZLE_NONE;
}
static int
bool success = false;
/* Create a zero'ed temporary buffer for reading our results */
- results = brw_bo_alloc(screen->bufmgr, "registers", 4096, 0);
+ results = brw_bo_alloc(screen->bufmgr, "registers", 4096, BRW_MEMZONE_OTHER);
if (results == NULL)
goto err;
- bo = brw_bo_alloc(screen->bufmgr, "batchbuffer", 4096, 0);
+ bo = brw_bo_alloc(screen->bufmgr, "batchbuffer", 4096, BRW_MEMZONE_OTHER);
if (bo == NULL)
goto err_results;
/* Required by Android, for HAL_PIXEL_FORMAT_RGBX_8888. */
MESA_FORMAT_R8G8B8X8_UNORM,
+
+ MESA_FORMAT_R8G8B8A8_SRGB,
};
/* GLX_SWAP_COPY_OML is not supported due to page flipping. */
if (intel_loader_get_cap(dri_screen, DRI_LOADER_CAP_RGBA_ORDERING))
num_formats = ARRAY_SIZE(formats);
else
- num_formats = ARRAY_SIZE(formats) - 2; /* all - RGBA_ORDERING formats */
+ num_formats = ARRAY_SIZE(formats) - 3; /* all - RGBA_ORDERING formats */
/* Shall we expose 10 bpc formats? */
bool allow_rgb10_configs = driQueryOptionb(&screen->optionCache,
const bool has_astc = screen->devinfo.gen >= 9;
switch (screen->devinfo.gen) {
+ case 11:
case 10:
case 9:
case 8:
va_end(args);
}
-static int
-parse_devid_override(const char *devid_override)
-{
- static const struct {
- const char *name;
- int pci_id;
- } name_map[] = {
- { "brw", 0x2a02 },
- { "g4x", 0x2a42 },
- { "ilk", 0x0042 },
- { "snb", 0x0126 },
- { "ivb", 0x016a },
- { "hsw", 0x0d2e },
- { "byt", 0x0f33 },
- { "bdw", 0x162e },
- { "chv", 0x22B3 },
- { "skl", 0x1912 },
- { "bxt", 0x5A85 },
- { "kbl", 0x5912 },
- { "glk", 0x3185 },
- { "cnl", 0x5a52 },
- };
-
- for (unsigned i = 0; i < ARRAY_SIZE(name_map); i++) {
- if (!strcmp(name_map[i].name, devid_override))
- return name_map[i].pci_id;
- }
-
- return strtol(devid_override, NULL, 0);
-}
-
-/**
- * Get the PCI ID for the device. This can be overridden by setting the
- * INTEL_DEVID_OVERRIDE environment variable to the desired ID.
- *
- * Returns -1 on ioctl failure.
- */
-static int
-get_pci_device_id(struct intel_screen *screen)
-{
- if (geteuid() == getuid()) {
- char *devid_override = getenv("INTEL_DEVID_OVERRIDE");
- if (devid_override) {
- screen->no_hw = true;
- return parse_devid_override(devid_override);
- }
- }
-
- return intel_get_integer(screen, I915_PARAM_CHIPSET_ID);
-}
-
/**
* This is the driver specific part of the createNewScreen entry point.
* Called when using DRI2.
return NULL;
}
/* parse information in __driConfigOptions */
- driParseOptionInfo(&screen->optionCache, brw_config_options.xml);
+ driOptionCache options;
+ memset(&options, 0, sizeof(options));
+
+ driParseOptionInfo(&options, brw_config_options.xml);
+ driParseConfigFiles(&screen->optionCache, &options, dri_screen->myNum, "i965");
+ driDestroyOptionCache(&options);
screen->driScrnPriv = dri_screen;
dri_screen->driverPrivate = (void *) screen;
- screen->deviceID = get_pci_device_id(screen);
+ screen->deviceID = gen_get_pci_device_id_override();
+ if (screen->deviceID < 0)
+ screen->deviceID = intel_get_integer(screen, I915_PARAM_CHIPSET_ID);
+ else
+ screen->no_hw = true;
if (!gen_get_device_info(screen->deviceID, &screen->devinfo))
return NULL;
if (devinfo->gen >= 8 || screen->cmd_parser_version >= 5)
screen->kernel_features |= KERNEL_ALLOWS_COMPUTE_DISPATCH;
+ if (intel_get_boolean(screen, I915_PARAM_HAS_CONTEXT_ISOLATION))
+ screen->kernel_features |= KERNEL_ALLOWS_CONTEXT_ISOLATION;
+
const char *force_msaa = getenv("INTEL_FORCE_MSAA");
if (force_msaa) {
screen->winsys_msaa_samples_override =
screen->compiler = brw_compiler_create(screen, devinfo);
screen->compiler->shader_debug_log = shader_debug_log_mesa;
screen->compiler->shader_perf_log = shader_perf_log_mesa;
- screen->compiler->constant_buffer_0_is_relative = true;
+
+ /* Changing the meaning of constant buffer pointers from a dynamic state
+ * offset to an absolute address is only safe if the kernel isolates other
+ * contexts from our changes.
+ */
+ screen->compiler->constant_buffer_0_is_relative = devinfo->gen < 8 ||
+ !(screen->kernel_features & KERNEL_ALLOWS_CONTEXT_ISOLATION);
+
screen->compiler->supports_pull_constants = true;
screen->has_exec_fence =
}
}
+ brw_disk_cache_init(screen);
+
return (const __DRIconfig**) intel_screen_make_configs(dri_screen);
}
width,
height,
cpp,
+ BRW_MEMZONE_OTHER,
I915_TILING_X, &pitch,
BO_ALLOC_BUSY);