mesa/dri: Move context flag validation down into the drivers
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 10 Sep 2012 14:31:24 +0000 (17:31 +0300)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 8 Nov 2013 01:40:05 +0000 (17:40 -0800)
Soon some drivers will support a different set of flags than other
drivers.  If some flags have to be filtered in the driver, we might as
well filter all of them in the driver.

The changes in nouveau use tabs because nouveau seems to have it's own
indentation rules.

v2: Fix some rebase failures noticed by Ken (returning the wrong types,
etc.).

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/gallium/state_trackers/dri/common/dri_context.c
src/mesa/drivers/dri/i915/intel_screen.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/nouveau/nouveau_context.c
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/radeon/radeon_context.c

index 5cfd1edfc81a66bc44d0b07a79665e526368569d..988e28ea244a0b861f5b8a0d6cd2c55ca8f653fe 100644 (file)
@@ -101,6 +101,11 @@ dri_create_context(gl_api api, const struct gl_config * visual,
       goto fail;
    }
 
+   if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
+      *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+      goto fail;
+   }
+
    if (notify_reset) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       goto fail;
index a4b40b74dbbf0777ee0897cfc03be347a72d3e76..9a1b3785374a360c145bab4b1377f94e94427012 100644 (file)
@@ -917,6 +917,11 @@ intelCreateContext(gl_api api,
    __DRIscreen *sPriv = driContextPriv->driScreenPriv;
    struct intel_screen *intelScreen = sPriv->driverPrivate;
 
+   if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+      *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+      return false;
+   }
+
    if (notify_reset) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       return false;
index 01fb988042262df3dd673f7c5d8e67575e9e1af4..3e6dade613d2d6c02067ef5d11190c3c47aaca12 100644 (file)
@@ -580,6 +580,11 @@ brwCreateContext(gl_api api,
    struct dd_function_table functions;
    struct gl_config visual;
 
+   if (flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) {
+      *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+      return false;
+   }
+
    if (notify_reset) {
       *dri_ctx_error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
       return false;
index a7f14b518d1bd7bc48c251bc01b75ea5b8b7d6b1..d44864ca9a95d21965def3682e2c32baa4accf93 100644 (file)
@@ -62,9 +62,10 @@ nouveau_context_create(gl_api api,
        struct nouveau_context *nctx;
        struct gl_context *ctx;
 
-       /* API and flag filtering is handled in dri2CreateContextAttribs.
-        */
-       (void) flags;
+       if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+               *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+               return false;
+       }
 
        if (notify_reset) {
                *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
index 58c300c3d60bdda415b212f46f671730bce0c49a..d4e9ca8cacae1513192e35f62471e1375eccc9c1 100644 (file)
@@ -213,9 +213,10 @@ GLboolean r200CreateContext( gl_api api,
    int i;
    int tcl_mode;
 
-   /* Flag filtering is handled in dri2CreateContextAttribs.
-    */
-   (void) flags;
+   if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+      *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+      return false;
+   }
 
    if (notify_reset) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
index c2200d70e45050cf3045052b21da278505bf0332..76bfe55c0ebf58da3ed5f90ae8c8d5eac13b5082 100644 (file)
@@ -180,9 +180,10 @@ r100CreateContext( gl_api api,
    int i;
    int tcl_mode, fthrottle_mode;
 
-   /* Flag filtering is handled in dri2CreateContextAttribs.
-    */
-   (void) flags;
+   if (flags & ~__DRI_CTX_FLAG_DEBUG) {
+      *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
+      return false;
+   }
 
    if (notify_reset) {
       *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;