gallium: add flags parameter to pipe_screen::context_create
[mesa.git] / src / mesa / state_tracker / st_manager.c
index 7bc33268e76392613265fa4430c72752bc4dbb2b..7abd128e719c0eee847bddd9ae2c959294217de2 100644 (file)
@@ -61,7 +61,7 @@
  * We'll only return non-null for window system framebuffers.
  * Note that this function may fail.
  */
-static INLINE struct st_framebuffer *
+static inline struct st_framebuffer *
 st_ws_framebuffer(struct gl_framebuffer *fb)
 {
    /* FBO cannot be casted.  See st_new_framebuffer */
@@ -73,7 +73,7 @@ st_ws_framebuffer(struct gl_framebuffer *fb)
 /**
  * Map an attachment to a buffer index.
  */
-static INLINE gl_buffer_index
+static inline gl_buffer_index
 attachment_to_buffer_index(enum st_attachment_type statt)
 {
    gl_buffer_index index;
@@ -109,7 +109,7 @@ attachment_to_buffer_index(enum st_attachment_type statt)
 /**
  * Map a buffer index to an attachment.
  */
-static INLINE enum st_attachment_type
+static inline enum st_attachment_type
 buffer_index_to_attachment(gl_buffer_index index)
 {
    enum st_attachment_type statt;
@@ -368,6 +368,7 @@ st_visual_to_context_mode(const struct st_visual *visual,
 
       mode->rgbBits = mode->redBits +
          mode->greenBits + mode->blueBits + mode->alphaBits;
+      mode->sRGBCapable = util_format_is_srgb(visual->color_format);
    }
 
    if (visual->depth_stencil_format != PIPE_FORMAT_NONE) {
@@ -452,7 +453,8 @@ st_framebuffer_create(struct st_context *st,
           st_pipe_format_to_mesa_format(srgb_format) != MESA_FORMAT_NONE &&
           screen->is_format_supported(screen, srgb_format,
                                       PIPE_TEXTURE_2D, stfbi->visual->samples,
-                                      PIPE_BIND_RENDER_TARGET))
+                                      (PIPE_BIND_DISPLAY_TARGET |
+                                       PIPE_BIND_RENDER_TARGET)))
          mode.sRGBCapable = GL_TRUE;
    }
 
@@ -655,7 +657,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
       break;
    }
 
-   pipe = smapi->screen->context_create(smapi->screen, NULL);
+   pipe = smapi->screen->context_create(smapi->screen, NULL, 0);
    if (!pipe) {
       *error = ST_CONTEXT_ERROR_NO_MEMORY;
       return NULL;
@@ -679,12 +681,16 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
 
    if (attribs->flags & ST_CONTEXT_FLAG_FORWARD_COMPATIBLE)
       st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+   if (attribs->flags & ST_CONTEXT_FLAG_ROBUST_ACCESS)
+      st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
+   if (attribs->flags & ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED)
+      st->ctx->Const.ResetStrategy = GL_LOSE_CONTEXT_ON_RESET_ARB;
 
    /* need to perform version check */
    if (attribs->major > 1 || attribs->minor > 0) {
       /* Is the actual version less than the requested version?
        */
-      if (st->ctx->Version < attribs->major * 10 + attribs->minor) {
+      if (st->ctx->Version < attribs->major * 10U + attribs->minor) {
         *error = ST_CONTEXT_ERROR_BAD_VERSION;
          st_destroy_context(st);
          return NULL;
@@ -919,8 +925,7 @@ static unsigned get_version(struct pipe_screen *screen,
    struct gl_extensions extensions = {0};
    GLuint version;
 
-   if ((api == API_OPENGL_COMPAT || api == API_OPENGL_CORE) &&
-       _mesa_override_gl_version_contextless(&consts, &api, &version)) {
+   if (_mesa_override_gl_version_contextless(&consts, &api, &version)) {
       return version;
    }
 
@@ -928,7 +933,7 @@ static unsigned get_version(struct pipe_screen *screen,
    _mesa_init_extensions(&extensions);
 
    st_init_limits(screen, &consts, &extensions);
-   st_init_extensions(screen, api, &consts, &extensions, options, GL_TRUE);
+   st_init_extensions(screen, &consts, &extensions, options, GL_TRUE);
 
    return _mesa_get_version(&extensions, &consts, api);
 }