gallium: remove st_profile_type in favor of gl_api, move out st_context_attribs
authorMarek Olšák <marek.olsak@amd.com>
Sun, 27 Nov 2022 20:19:57 +0000 (15:19 -0500)
committerMarge Bot <emma+marge@anholt.net>
Fri, 9 Dec 2022 13:14:03 +0000 (13:14 +0000)
st_context_attribs is moved into st_context.h.

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Yonggang Luo <luoyonggang@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20027>

src/gallium/frontends/dri/dri_context.c
src/gallium/frontends/glx/xlib/xm_api.c
src/gallium/frontends/osmesa/osmesa.c
src/gallium/frontends/wgl/stw_context.c
src/gallium/include/frontend/api.h
src/gallium/targets/haiku-softpipe/GalliumContext.cpp
src/mesa/state_tracker/st_context.h
src/mesa/state_tracker/st_manager.c

index a9d9a55..660cc5d 100644 (file)
@@ -84,18 +84,18 @@ dri_create_context(struct dri_screen *screen,
    memset(&attribs, 0, sizeof(attribs));
    switch (api) {
    case API_OPENGLES:
-      attribs.profile = ST_PROFILE_OPENGL_ES1;
+      attribs.profile = API_OPENGLES;
       break;
    case API_OPENGLES2:
-      attribs.profile = ST_PROFILE_OPENGL_ES2;
+      attribs.profile = API_OPENGLES2;
       break;
    case API_OPENGL_COMPAT:
    case API_OPENGL_CORE:
       if (driQueryOptionb(optionCache, "force_compat_profile")) {
-         attribs.profile = ST_PROFILE_DEFAULT;
+         attribs.profile = API_OPENGL_COMPAT;
       } else {
-         attribs.profile = api == API_OPENGL_COMPAT ? ST_PROFILE_DEFAULT
-                                                    : ST_PROFILE_OPENGL_CORE;
+         attribs.profile = api == API_OPENGL_COMPAT ? API_OPENGL_COMPAT
+                                                    : API_OPENGL_CORE;
       }
 
       attribs.major = ctx_config->major_version;
index 4b1187c..0f075b3 100644 (file)
@@ -971,7 +971,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
        *     of the context is determined solely by the requested version."
        */
       if (major > 3 || (major == 3 && minor >= 2)) {
-         attribs.profile = ST_PROFILE_OPENGL_CORE;
+         attribs.profile = API_OPENGL_CORE;
          break;
       }
       FALLTHROUGH;
@@ -990,16 +990,16 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list,
        * honour a 3.1 context is through core profile.
        */
       if (major == 3 && minor == 1) {
-         attribs.profile = ST_PROFILE_OPENGL_CORE;
+         attribs.profile = API_OPENGL_CORE;
       } else {
-         attribs.profile = ST_PROFILE_DEFAULT;
+         attribs.profile = API_OPENGL_COMPAT;
       }
       break;
    case GLX_CONTEXT_ES_PROFILE_BIT_EXT:
       if (major >= 2) {
-         attribs.profile = ST_PROFILE_OPENGL_ES2;
+         attribs.profile = API_OPENGLES2;
       } else {
-         attribs.profile = ST_PROFILE_OPENGL_ES1;
+         attribs.profile = API_OPENGLES;
       }
       break;
    default:
index 1636331..3db12c8 100644 (file)
@@ -668,7 +668,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist)
     */
    memset(&attribs, 0, sizeof(attribs));
    attribs.profile = (profile == OSMESA_CORE_PROFILE)
-      ? ST_PROFILE_OPENGL_CORE : ST_PROFILE_DEFAULT;
+      ? API_OPENGL_CORE : API_OPENGL_COMPAT;
    attribs.major = version_major;
    attribs.minor = version_minor;
    attribs.flags = 0;  /* ST_CONTEXT_FLAG_x */
index c93aa3f..fcb41b9 100644 (file)
@@ -207,7 +207,7 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt
        *     of the context is determined solely by the requested version."
        */
       if (majorVersion > 3 || (majorVersion == 3 && minorVersion >= 2)) {
-         attribs.profile = ST_PROFILE_OPENGL_CORE;
+         attribs.profile = API_OPENGL_CORE;
          break;
       }
       FALLTHROUGH;
@@ -228,13 +228,13 @@ stw_create_context_attribs(HDC hdc, INT iLayerPlane, struct stw_context *shareCt
        * GL_ARB_compatibility, so returning a core profile here does more harm
        * than good.
        */
-      attribs.profile = ST_PROFILE_DEFAULT;
+      attribs.profile = API_OPENGL_COMPAT;
       break;
    case WGL_CONTEXT_ES_PROFILE_BIT_EXT:
       if (majorVersion >= 2) {
-         attribs.profile = ST_PROFILE_OPENGL_ES2;
+         attribs.profile = API_OPENGLES2;
       } else {
-         attribs.profile = ST_PROFILE_OPENGL_ES1;
+         attribs.profile = API_OPENGLES;
       }
       break;
    default:
index ab741fb..90c99d8 100644 (file)
@@ -39,17 +39,6 @@ struct st_context;
  * their managers.
  */
 
-/**
- * The profile of a context.
- */
-enum st_profile_type
-{
-   ST_PROFILE_DEFAULT,                 /**< OpenGL compatibility profile */
-   ST_PROFILE_OPENGL_CORE,             /**< OpenGL 3.2+ core profile */
-   ST_PROFILE_OPENGL_ES1,              /**< OpenGL ES 1.x */
-   ST_PROFILE_OPENGL_ES2               /**< OpenGL ES 2.0 */
-};
-
 
 /**
  * New context flags for GL 3.0 and beyond.
@@ -222,37 +211,6 @@ struct st_config_options
    unsigned char config_options_sha1[20];
 };
 
-/**
- * Represent the attributes of a context.
- */
-struct st_context_attribs
-{
-   /**
-    * The profile and minimal version to support.
-    *
-    * The valid profiles and versions are rendering API dependent.  The latest
-    * version satisfying the request should be returned.
-    */
-   enum st_profile_type profile;
-   int major, minor;
-
-   /** Mask of ST_CONTEXT_FLAG_x bits */
-   unsigned flags;
-
-   /** Mask of PIPE_CONTEXT_x bits */
-   unsigned context_flags;
-
-   /**
-    * The visual of the framebuffers the context will be bound to.
-    */
-   struct st_visual visual;
-
-   /**
-    * Configuration options.
-    */
-   struct st_config_options options;
-};
-
 struct pipe_frontend_screen;
 
 /**
index 62a3217..8940e40 100644 (file)
@@ -163,7 +163,7 @@ GalliumContext::CreateContext(HGLWinsysContext *wsContext)
        struct st_context_attribs attribs;
        memset(&attribs, 0, sizeof(attribs));
        attribs.options.force_glsl_extensions_warn = false;
-       attribs.profile = ST_PROFILE_DEFAULT;
+       attribs.profile = API_OPENGL_COMPAT;
        attribs.visual = *context->stVisual;
        attribs.major = 1;
        attribs.minor = 0;
index b3c3ef4..0a558bf 100644 (file)
@@ -395,6 +395,37 @@ struct st_context
    struct hash_table *hw_select_shaders;
 };
 
+/**
+ * Represent the attributes of a context.
+ */
+struct st_context_attribs
+{
+   /**
+    * The profile and minimal version to support.
+    *
+    * The valid profiles and versions are rendering API dependent.  The latest
+    * version satisfying the request should be returned.
+    */
+   gl_api profile;
+   int major, minor;
+
+   /** Mask of ST_CONTEXT_FLAG_x bits */
+   unsigned flags;
+
+   /** Mask of PIPE_CONTEXT_x bits */
+   unsigned context_flags;
+
+   /**
+    * The visual of the framebuffers the context will be bound to.
+    */
+   struct st_visual visual;
+
+   /**
+    * Configuration options.
+    */
+   struct st_config_options options;
+};
+
 
 /*
  * Get the state tracker context for the given Mesa context.
index 5fc27ed..44c425d 100644 (file)
@@ -943,27 +943,8 @@ st_api_create_context(struct pipe_frontend_screen *fscreen,
    struct st_context *st;
    struct pipe_context *pipe;
    struct gl_config mode, *mode_ptr = &mode;
-   gl_api api;
    bool no_error = false;
 
-   switch (attribs->profile) {
-   case ST_PROFILE_DEFAULT:
-      api = API_OPENGL_COMPAT;
-      break;
-   case ST_PROFILE_OPENGL_ES1:
-      api = API_OPENGLES;
-      break;
-   case ST_PROFILE_OPENGL_ES2:
-      api = API_OPENGLES2;
-      break;
-   case ST_PROFILE_OPENGL_CORE:
-      api = API_OPENGL_CORE;
-      break;
-   default:
-      *error = ST_CONTEXT_ERROR_BAD_API;
-      return NULL;
-   }
-
    _mesa_initialize(attribs->options.mesa_extension_override);
 
    /* Create a hash table for the framebuffer interface objects
@@ -995,7 +976,7 @@ st_api_create_context(struct pipe_frontend_screen *fscreen,
    st_visual_to_context_mode(&attribs->visual, &mode);
    if (attribs->visual.color_format == PIPE_FORMAT_NONE)
       mode_ptr = NULL;
-   st = st_create_context(api, pipe, mode_ptr, shared_ctx,
+   st = st_create_context(attribs->profile, pipe, mode_ptr, shared_ctx,
                           &attribs->options, no_error,
                           !!fscreen->validate_egl_image);
    if (!st) {