mesa: GL_EXT_secondary_color is not optional
[mesa.git] / src / mesa / drivers / dri / nouveau / nouveau_context.c
index 2625b76d14fb6e596c659b95daa80f4a143321fe..a403c24c80985f335e8ed3c79bc8dfcae4d8e91a 100644 (file)
 #include "nouveau_fbo.h"
 #include "nv_object.xml.h"
 
+#include "main/api_exec.h"
 #include "main/dd.h"
 #include "main/framebuffer.h"
 #include "main/fbobject.h"
 #include "main/light.h"
 #include "main/state.h"
 #include "main/version.h"
+#include "main/vtxfmt.h"
 #include "drivers/common/meta.h"
 #include "drivers/common/driverfuncs.h"
 #include "swrast/swrast.h"
@@ -59,9 +61,31 @@ nouveau_context_create(gl_api api,
        struct nouveau_context *nctx;
        struct gl_context *ctx;
 
+       switch (api) {
+       case API_OPENGL_COMPAT:
+               /* Do after-the-fact version checking (below).
+                */
+               break;
+       case API_OPENGLES:
+               /* NV10 and NV20 can support OpenGL ES 1.0 only.  Older chips
+                * cannot do even that.
+                */
+               if ((screen->device->chipset & 0xf0) == 0x00) {
+                       *error = __DRI_CTX_ERROR_BAD_API;
+                       return GL_FALSE;
+               } else if (minor_version != 0) {
+                       *error = __DRI_CTX_ERROR_BAD_VERSION;
+                       return GL_FALSE;
+               }
+               break;
+       case API_OPENGLES2:
+       case API_OPENGL_CORE:
+               *error = __DRI_CTX_ERROR_BAD_API;
+               return GL_FALSE;
+       }
+
        /* API and flag filtering is handled in dri2CreateContextAttribs.
         */
-       (void) api;
        (void) flags;
 
        ctx = screen->driver->context_create(screen, visual, share_ctx);
@@ -75,14 +99,23 @@ nouveau_context_create(gl_api api,
        dri_ctx->driverPrivate = ctx;
 
        _mesa_compute_version(ctx);
-       if (ctx->VersionMajor < major_version
-           || (ctx->VersionMajor == major_version
-               && ctx->VersionMinor < minor_version)) {
+       if (ctx->Version < major_version * 10 + minor_version) {
           nouveau_context_destroy(dri_ctx);
           *error = __DRI_CTX_ERROR_BAD_VERSION;
           return GL_FALSE;
        }
 
+       /* Exec table initialization requires the version to be computed */
+       _mesa_initialize_dispatch_tables(ctx);
+       _mesa_initialize_vbo_vtxfmt(ctx);
+
+       if (nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_VRAM, 0, 4096,
+                          NULL, &nctx->fence)) {
+               nouveau_context_destroy(dri_ctx);
+               *error = __DRI_CTX_ERROR_NO_MEMORY;
+               return GL_FALSE;
+       }
+
        *error = __DRI_CTX_ERROR_SUCCESS;
        return GL_TRUE;
 }
@@ -106,8 +139,8 @@ nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen,
        nouveau_fbo_functions_init(&functions);
 
        /* Initialize the mesa context. */
-       _mesa_initialize_context(ctx, API_OPENGL, visual,
-                                 share_ctx, &functions, NULL);
+       _mesa_initialize_context(ctx, API_OPENGL_COMPAT, visual,
+                                 share_ctx, &functions);
 
        nouveau_state_init(ctx);
        nouveau_scratch_init(ctx);
@@ -167,9 +200,7 @@ nouveau_context_init(struct gl_context *ctx, struct nouveau_screen *screen,
        ctx->Extensions.EXT_blend_minmax = true;
        ctx->Extensions.EXT_fog_coord = true;
        ctx->Extensions.EXT_framebuffer_blit = true;
-       ctx->Extensions.EXT_framebuffer_object = true;
        ctx->Extensions.EXT_packed_depth_stencil = true;
-       ctx->Extensions.EXT_secondary_color = true;
        ctx->Extensions.EXT_texture_filter_anisotropic = true;
        ctx->Extensions.NV_blend_square = true;
        ctx->Extensions.NV_texture_env_combine4 = true;
@@ -209,6 +240,7 @@ nouveau_context_destroy(__DRIcontext *dri_ctx)
        struct nouveau_context *nctx = dri_ctx->driverPrivate;
        struct gl_context *ctx = &nctx->base;
 
+       nouveau_bo_ref(NULL, &nctx->fence);
        context_drv(ctx)->context_destroy(ctx);
 }