st/dri: constify dri_fill_st_visual's screen
[mesa.git] / src / gallium / state_trackers / dri / dri_screen.c
index f888abd6e7047c675368f43bfed5e8cdfc9a6b06..87729c190a890b12ab5b0b86f0e5cc916f54aacd 100644 (file)
@@ -72,10 +72,12 @@ dri_fill_st_options(struct dri_screen *screen)
       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_const_expression =
+      driQueryOptionb(optionCache, "allow_glsl_builtin_const_expression");
+   options->allow_glsl_relaxed_es =
+      driQueryOptionb(optionCache, "allow_glsl_relaxed_es");
    options->allow_glsl_builtin_variable_redeclaration =
       driQueryOptionb(optionCache, "allow_glsl_builtin_variable_redeclaration");
    options->allow_higher_compat_version =
@@ -83,6 +85,8 @@ dri_fill_st_options(struct dri_screen *screen)
    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);
 }
@@ -93,10 +97,12 @@ 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)
+   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)
+   if (image_loader && image_loader->base.version >= 2 &&
+       image_loader->getCapability)
       return image_loader->getCapability(screen->sPriv->loaderPrivate, cap);
 
    return 0;
@@ -106,6 +112,10 @@ 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_R10G10B10A2_UNORM,
+      MESA_FORMAT_R10G10B10X2_UNORM,
       MESA_FORMAT_B8G8R8A8_UNORM,
       MESA_FORMAT_B8G8R8X8_UNORM,
       MESA_FORMAT_B8G8R8A8_SRGB,
@@ -134,6 +144,10 @@ dri_fill_in_modes(struct dri_screen *screen)
       MESA_FORMAT_R8G8B8X8_UNORM,
    };
    static const enum pipe_format pipe_formats[] = {
+      PIPE_FORMAT_B10G10R10A2_UNORM,
+      PIPE_FORMAT_B10G10R10X2_UNORM,
+      PIPE_FORMAT_R10G10B10A2_UNORM,
+      PIPE_FORMAT_R10G10B10X2_UNORM,
       PIPE_FORMAT_BGRA8888_UNORM,
       PIPE_FORMAT_BGRX8888_UNORM,
       PIPE_FORMAT_BGRA8888_SRGB,
@@ -152,9 +166,11 @@ dri_fill_in_modes(struct dri_screen *screen)
    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->dev->option_cache, "always_have_depth_buffer")) {
@@ -167,6 +183,8 @@ dri_fill_in_modes(struct dri_screen *screen)
       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;
 
@@ -218,7 +236,7 @@ dri_fill_in_modes(struct dri_screen *screen)
    if (dri_loader_get_cap(screen, DRI_LOADER_CAP_RGBA_ORDERING))
       num_formats = ARRAY_SIZE(mesa_formats);
    else
-      num_formats = 5;
+      num_formats = ARRAY_SIZE(mesa_formats) - 2; /* all - RGBA_ORDERING formats */
 
    /* Add configs. */
    for (format = 0; format < num_formats; format++) {
@@ -226,9 +244,17 @@ dri_fill_in_modes(struct dri_screen *screen)
       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 ||
+           mesa_formats[format] == MESA_FORMAT_R10G10B10A2_UNORM ||
+           mesa_formats[format] == MESA_FORMAT_R10G10B10X2_UNORM))
+         continue;
+
       if (!p_screen->is_format_supported(p_screen, pipe_formats[format],
                                          PIPE_TEXTURE_2D, 0,
-                                         PIPE_BIND_RENDER_TARGET))
+                                         PIPE_BIND_RENDER_TARGET |
+                                         PIPE_BIND_DISPLAY_TARGET))
          continue;
 
       for (i = 1; i <= msaa_samples_max; i++) {
@@ -276,7 +302,8 @@ dri_fill_in_modes(struct dri_screen *screen)
  * Roughly the converse of dri_fill_in_modes.
  */
 void
-dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
+dri_fill_st_visual(struct st_visual *stvis,
+                   const struct dri_screen *screen,
                    const struct gl_config *mode)
 {
    memset(stvis, 0, sizeof(*stvis));
@@ -286,6 +313,24 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
 
    /* 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 0x000003FF:
+      if (mode->alphaMask) {
+         assert(mode->alphaMask == 0xC0000000);
+         stvis->color_format = PIPE_FORMAT_R10G10B10A2_UNORM;
+      } else {
+         stvis->color_format = PIPE_FORMAT_R10G10B10X2_UNORM;
+      }
+      break;
+
    case 0x00FF0000:
       if (mode->alphaMask) {
          assert(mode->alphaMask == 0xFF000000);
@@ -476,20 +521,12 @@ dri_set_background_context(struct st_context_iface *st,
       hud_add_queue_for_monitoring(ctx->hud, queue_info);
 }
 
-unsigned
-dri_init_options_get_screen_flags(struct dri_screen *screen)
+void
+dri_init_options(struct dri_screen *screen)
 {
-   unsigned flags = 0;
-
    pipe_loader_load_options(screen->dev);
 
    dri_fill_st_options(screen);
-
-   if (driQueryOptionb(&screen->dev->option_cache,
-                       "glsl_correct_derivatives_after_discard"))
-      flags |= PIPE_SCREEN_ENABLE_CORRECT_TGSI_DERIVATIVES_AFTER_KILL;
-
-   return flags;
 }
 
 const __DRIconfig **
@@ -510,19 +547,6 @@ dri_init_screen_helper(struct dri_screen *screen,
    else
       screen->target = PIPE_TEXTURE_RECT;
 
-   /* 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,