*/
#include "utils.h"
-#include "xmlpool.h"
#include "dri_screen.h"
+#include "dri_context.h"
#include "util/u_inlines.h"
#include "pipe/p_screen.h"
#undef false
const __DRIconfigOptionsExtension gallium_config_options = {
- .base = { __DRI_CONFIG_OPTIONS, 1 },
- .xml =
-
- DRI_CONF_BEGIN
- DRI_CONF_SECTION_QUALITY
- DRI_CONF_FORCE_S3TC_ENABLE("false")
- DRI_CONF_PP_CELSHADE(0)
- DRI_CONF_PP_NORED(0)
- DRI_CONF_PP_NOGREEN(0)
- DRI_CONF_PP_NOBLUE(0)
- DRI_CONF_PP_JIMENEZMLAA(0, 0, 32)
- DRI_CONF_PP_JIMENEZMLAA_COLOR(0, 0, 32)
- DRI_CONF_SECTION_END
-
- DRI_CONF_SECTION_DEBUG
- DRI_CONF_FORCE_GLSL_EXTENSIONS_WARN("false")
- DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS("false")
- DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED("false")
- DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false")
- DRI_CONF_FORCE_GLSL_VERSION(0)
- DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
- DRI_CONF_SECTION_END
-
- DRI_CONF_SECTION_MISCELLANEOUS
- DRI_CONF_ALWAYS_HAVE_DEPTH_BUFFER("false")
- DRI_CONF_GLSL_ZERO_INIT("false")
- DRI_CONF_SECTION_END
- DRI_CONF_END
+ .base = { __DRI_CONFIG_OPTIONS, 2 },
+ .xml = gallium_driinfo_xml,
+ .getXml = pipe_loader_get_driinfo_xml
};
#define false 0
static void
-dri_fill_st_options(struct st_config_options *options,
- const struct driOptionCache * optionCache)
+dri_fill_st_options(struct dri_screen *screen)
{
+ struct st_config_options *options = &screen->options;
+ const struct driOptionCache *optionCache = &screen->dev->option_cache;
+
options->disable_blend_func_extended =
driQueryOptionb(optionCache, "disable_blend_func_extended");
options->disable_glsl_line_continuations =
driQueryOptionb(optionCache, "force_glsl_extensions_warn");
options->force_glsl_version =
driQueryOptioni(optionCache, "force_glsl_version");
- options->force_s3tc_enable =
- driQueryOptionb(optionCache, "force_s3tc_enable");
options->allow_glsl_extension_directive_midshader =
driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
+ options->allow_glsl_builtin_variable_redeclaration =
+ driQueryOptionb(optionCache, "allow_glsl_builtin_variable_redeclaration");
+ options->allow_higher_compat_version =
+ driQueryOptionb(optionCache, "allow_higher_compat_version");
options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
+ options->force_glsl_abs_sqrt =
+ driQueryOptionb(optionCache, "force_glsl_abs_sqrt");
+ options->allow_glsl_cross_stage_interpolation_mismatch =
+ driQueryOptionb(optionCache, "allow_glsl_cross_stage_interpolation_mismatch");
+
+ driComputeOptionsSha1(optionCache, options->config_options_sha1);
+}
+
+static unsigned
+dri_loader_get_cap(struct dri_screen *screen, enum dri_loader_cap cap)
+{
+ const __DRIdri2LoaderExtension *dri2_loader = screen->sPriv->dri2.loader;
+ const __DRIimageLoaderExtension *image_loader = screen->sPriv->image.loader;
+
+ if (dri2_loader && dri2_loader->base.version >= 4 &&
+ dri2_loader->getCapability)
+ return dri2_loader->getCapability(screen->sPriv->loaderPrivate, cap);
+
+ if (image_loader && image_loader->base.version >= 2 &&
+ image_loader->getCapability)
+ return image_loader->getCapability(screen->sPriv->loaderPrivate, cap);
+
+ return 0;
}
static const __DRIconfig **
dri_fill_in_modes(struct dri_screen *screen)
{
static const mesa_format mesa_formats[] = {
+ MESA_FORMAT_B10G10R10A2_UNORM,
+ MESA_FORMAT_B10G10R10X2_UNORM,
MESA_FORMAT_B8G8R8A8_UNORM,
MESA_FORMAT_B8G8R8X8_UNORM,
MESA_FORMAT_B8G8R8A8_SRGB,
MESA_FORMAT_B8G8R8X8_SRGB,
MESA_FORMAT_B5G6R5_UNORM,
+
+ /* The 32-bit RGBA format must not precede the 32-bit BGRA format.
+ * Likewise for RGBX and BGRX. Otherwise, the GLX client and the GLX
+ * server may disagree on which format the GLXFBConfig represents,
+ * resulting in swapped color channels.
+ *
+ * The problem, as of 2017-05-30:
+ * When matching a GLXFBConfig to a __DRIconfig, GLX ignores the channel
+ * order and chooses the first __DRIconfig with the expected channel
+ * sizes. Specifically, GLX compares the GLXFBConfig's and __DRIconfig's
+ * __DRI_ATTRIB_{CHANNEL}_SIZE but ignores __DRI_ATTRIB_{CHANNEL}_MASK.
+ *
+ * EGL does not suffer from this problem. It correctly compares the
+ * channel masks when matching EGLConfig to __DRIconfig.
+ */
+
+ /* Required by Android, for HAL_PIXEL_FORMAT_RGBA_8888. */
+ MESA_FORMAT_R8G8B8A8_UNORM,
+
+ /* Required by Android, for HAL_PIXEL_FORMAT_RGBX_8888. */
+ MESA_FORMAT_R8G8B8X8_UNORM,
};
static const enum pipe_format pipe_formats[] = {
+ PIPE_FORMAT_B10G10R10A2_UNORM,
+ PIPE_FORMAT_B10G10R10X2_UNORM,
PIPE_FORMAT_BGRA8888_UNORM,
PIPE_FORMAT_BGRX8888_UNORM,
PIPE_FORMAT_BGRA8888_SRGB,
PIPE_FORMAT_BGRX8888_SRGB,
PIPE_FORMAT_B5G6R5_UNORM,
+ PIPE_FORMAT_RGBA8888_UNORM,
+ PIPE_FORMAT_RGBX8888_UNORM,
};
mesa_format format;
__DRIconfig **configs = NULL;
struct pipe_screen *p_screen = screen->base.screen;
boolean pf_z16, pf_x8z24, pf_z24x8, pf_s8z24, pf_z24s8, pf_z32;
boolean mixed_color_depth;
+ boolean allow_rgb10;
static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ __DRI_ATTRIB_SWAP_NONE, __DRI_ATTRIB_SWAP_UNDEFINED,
+ __DRI_ATTRIB_SWAP_COPY
};
- if (driQueryOptionb(&screen->optionCache, "always_have_depth_buffer")) {
+ if (driQueryOptionb(&screen->dev->option_cache, "always_have_depth_buffer")) {
/* all visuals will have a depth buffer */
depth_buffer_factor = 0;
}
stencil_bits_array[0] = 0;
depth_buffer_factor = 1;
}
-
+
+ allow_rgb10 = driQueryOptionb(&screen->dev->option_cache, "allow_rgb10_configs");
+
msaa_samples_max = (screen->st_api->feature_mask & ST_API_FEATURE_MS_VISUALS_MASK)
? MSAA_VISUAL_MAX_SAMPLES : 1;
assert(ARRAY_SIZE(mesa_formats) == ARRAY_SIZE(pipe_formats));
+ /* Expose only BGRA ordering if the loader doesn't support RGBA ordering. */
+ unsigned num_formats;
+ if (dri_loader_get_cap(screen, DRI_LOADER_CAP_RGBA_ORDERING))
+ num_formats = ARRAY_SIZE(mesa_formats);
+ else
+ num_formats = ARRAY_SIZE(mesa_formats) - 2; /* all - RGBA_ORDERING formats */
+
/* Add configs. */
- for (format = 0; format < ARRAY_SIZE(mesa_formats); format++) {
+ for (format = 0; format < num_formats; format++) {
__DRIconfig **new_configs = NULL;
unsigned num_msaa_modes = 0; /* includes a single-sample mode */
uint8_t msaa_modes[MSAA_VISUAL_MAX_SAMPLES];
+ if (!allow_rgb10 &&
+ (mesa_formats[format] == MESA_FORMAT_B10G10R10A2_UNORM ||
+ mesa_formats[format] == MESA_FORMAT_B10G10R10X2_UNORM))
+ continue;
+
if (!p_screen->is_format_supported(p_screen, pipe_formats[format],
PIPE_TEXTURE_2D, 0,
PIPE_BIND_RENDER_TARGET))
if (!mode)
return;
- if (mode->redBits == 8) {
- if (mode->alphaBits == 8)
- if (mode->sRGBCapable)
- stvis->color_format = PIPE_FORMAT_BGRA8888_SRGB;
- else
- stvis->color_format = PIPE_FORMAT_BGRA8888_UNORM;
- else
- if (mode->sRGBCapable)
- stvis->color_format = PIPE_FORMAT_BGRX8888_SRGB;
- else
- stvis->color_format = PIPE_FORMAT_BGRX8888_UNORM;
- } else {
+ /* Deduce the color format. */
+ switch (mode->redMask) {
+ case 0x3FF00000:
+ if (mode->alphaMask) {
+ assert(mode->alphaMask == 0xC0000000);
+ stvis->color_format = PIPE_FORMAT_B10G10R10A2_UNORM;
+ } else {
+ stvis->color_format = PIPE_FORMAT_B10G10R10X2_UNORM;
+ }
+ break;
+
+ case 0x00FF0000:
+ if (mode->alphaMask) {
+ assert(mode->alphaMask == 0xFF000000);
+ stvis->color_format = mode->sRGBCapable ?
+ PIPE_FORMAT_BGRA8888_SRGB :
+ PIPE_FORMAT_BGRA8888_UNORM;
+ } else {
+ stvis->color_format = mode->sRGBCapable ?
+ PIPE_FORMAT_BGRX8888_SRGB :
+ PIPE_FORMAT_BGRX8888_UNORM;
+ }
+ break;
+
+ case 0x000000FF:
+ if (mode->alphaMask) {
+ assert(mode->alphaMask == 0xFF000000);
+ stvis->color_format = mode->sRGBCapable ?
+ PIPE_FORMAT_RGBA8888_SRGB :
+ PIPE_FORMAT_RGBA8888_UNORM;
+ } else {
+ stvis->color_format = mode->sRGBCapable ?
+ PIPE_FORMAT_RGBX8888_SRGB :
+ PIPE_FORMAT_RGBX8888_UNORM;
+ }
+ break;
+
+ case 0x0000F800:
stvis->color_format = PIPE_FORMAT_B5G6R5_UNORM;
+ break;
+
+ default:
+ assert(!"unsupported visual: invalid red mask");
+ return;
}
if (mode->sampleBuffers) {
stimg->texture = NULL;
pipe_resource_reference(&stimg->texture, img->texture);
+ switch (img->dri_components) {
+ case __DRI_IMAGE_COMPONENTS_Y_U_V:
+ stimg->format = PIPE_FORMAT_IYUV;
+ break;
+ case __DRI_IMAGE_COMPONENTS_Y_UV:
+ stimg->format = PIPE_FORMAT_NV12;
+ break;
+ default:
+ stimg->format = img->texture->format;
+ break;
+ }
stimg->level = img->level;
stimg->layer = img->layer;
}
}
-static void
-dri_destroy_option_cache(struct dri_screen * screen)
-{
- int i;
-
- if (screen->optionCache.info) {
- for (i = 0; i < (1 << screen->optionCache.tableSize); ++i) {
- free(screen->optionCache.info[i].name);
- free(screen->optionCache.info[i].ranges);
- }
- free(screen->optionCache.info);
- }
-
- free(screen->optionCache.values);
-
- /* Default values are copied to screen->optionCache->values in
- * initOptionCache. The info field, however, is a pointer copy, so don't free
- * that twice.
- */
- free(screen->optionCacheDefaults.values);
-}
-
void
dri_destroy_screen_helper(struct dri_screen * screen)
{
+ if (screen->base.destroy)
+ screen->base.destroy(&screen->base);
+
if (screen->st_api && screen->st_api->destroy)
screen->st_api->destroy(screen->st_api);
if (screen->base.screen)
screen->base.screen->destroy(screen->base.screen);
- dri_destroy_option_cache(screen);
- pipe_mutex_destroy(screen->opencl_func_mutex);
+ mtx_destroy(&screen->opencl_func_mutex);
}
void
unsigned i;
for (i = 0; i < PP_FILTERS; i++) {
- screen->pp_enabled[i] = driQueryOptioni(&screen->optionCache,
+ screen->pp_enabled[i] = driQueryOptioni(&screen->dev->option_cache,
pp_filters[i].name);
}
}
+static void
+dri_set_background_context(struct st_context_iface *st,
+ struct util_queue_monitoring *queue_info)
+{
+ struct dri_context *ctx = (struct dri_context *)st->st_manager_private;
+ const __DRIbackgroundCallableExtension *backgroundCallable =
+ ctx->sPriv->dri2.backgroundCallable;
+
+ /* Note: Mesa will only call this function if GL multithreading is enabled
+ * We only do that if the loader exposed the __DRI_BACKGROUND_CALLABLE
+ * extension. So we know that backgroundCallable is not NULL.
+ */
+ assert(backgroundCallable);
+ backgroundCallable->setBackgroundContext(ctx->cPriv->loaderPrivate);
+
+ if (ctx->hud)
+ hud_add_queue_for_monitoring(ctx->hud, queue_info);
+}
+
+void
+dri_init_options(struct dri_screen *screen)
+{
+ pipe_loader_load_options(screen->dev);
+
+ dri_fill_st_options(screen);
+}
+
const __DRIconfig **
dri_init_screen_helper(struct dri_screen *screen,
- struct pipe_screen *pscreen,
- const char* driver_name)
+ struct pipe_screen *pscreen)
{
screen->base.screen = pscreen;
screen->base.get_egl_image = dri_get_egl_image;
screen->base.get_param = dri_get_param;
+ screen->base.set_background_context = dri_set_background_context;
screen->st_api = st_gl_api_create();
if (!screen->st_api)
else
screen->target = PIPE_TEXTURE_RECT;
- driParseOptionInfo(&screen->optionCacheDefaults, gallium_config_options.xml);
-
- driParseConfigFiles(&screen->optionCache,
- &screen->optionCacheDefaults,
- screen->sPriv->myNum,
- driver_name);
-
- dri_fill_st_options(&screen->options, &screen->optionCache);
-
- /* Handle force_s3tc_enable. */
- if (!util_format_s3tc_enabled && screen->options.force_s3tc_enable) {
- /* Ensure libtxc_dxtn has been loaded if available.
- * Forcing S3TC on before calling this would prevent loading
- * the library.
- * This is just a precaution, the driver should have called it
- * already.
- */
- util_format_s3tc_init();
-
- util_format_s3tc_enabled = TRUE;
- }
-
dri_postprocessing_init(screen);
screen->st_api->query_versions(screen->st_api, &screen->base,