diff options
Diffstat (limited to 'src/mesa/drivers/dri/intel')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_context.c | 56 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_context.h | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_screen.c | 31 |
3 files changed, 70 insertions, 30 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 37a8e585c6d..7bfc49a7f05 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -580,13 +580,55 @@ intelInitDriverFunctions(struct dd_function_table *functions) intel_init_syncobj_functions(functions); } +static bool +validate_context_version(struct intel_screen *screen, + int mesa_api, + unsigned major_version, + unsigned minor_version, + unsigned *dri_ctx_error) +{ + unsigned req_version = 10 * major_version + minor_version; + unsigned max_version = 0; + + switch (mesa_api) { + case API_OPENGL_COMPAT: + max_version = screen->max_gl_compat_version; + break; + case API_OPENGL_CORE: + max_version = screen->max_gl_core_version; + break; + case API_OPENGLES: + max_version = screen->max_gl_es1_version; + break; + case API_OPENGLES2: + max_version = screen->max_gl_es2_version; + break; + default: + max_version = 0; + break; + } + + if (max_version == 0) { + *dri_ctx_error = __DRI_CTX_ERROR_BAD_API; + return false; + } else if (req_version > max_version) { + *dri_ctx_error = __DRI_CTX_ERROR_BAD_VERSION; + return false; + } + + return true; +} + bool intelInitContext(struct intel_context *intel, - int api, + int api, + unsigned major_version, + unsigned minor_version, const struct gl_config * mesaVis, __DRIcontext * driContextPriv, void *sharedContextPrivate, - struct dd_function_table *functions) + struct dd_function_table *functions, + unsigned *dri_ctx_error) { struct gl_context *ctx = &intel->ctx; struct gl_context *shareCtx = (struct gl_context *) sharedContextPrivate; @@ -596,7 +638,14 @@ intelInitContext(struct intel_context *intel, struct gl_config visual; /* we can't do anything without a connection to the device */ - if (intelScreen->bufmgr == NULL) + if (intelScreen->bufmgr == NULL) { + *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY; + return false; + } + + if (!validate_context_version(intelScreen, + api, major_version, minor_version, + dri_ctx_error)) return false; /* Can't rely on invalidate events, fall back to glViewport hack */ @@ -614,6 +663,7 @@ intelInitContext(struct intel_context *intel, if (!_mesa_initialize_context(&intel->ctx, api, mesaVis, shareCtx, functions)) { + *dri_ctx_error = __DRI_CTX_ERROR_NO_MEMORY; printf("%s: failed to init mesa context\n", __FUNCTION__); return false; } diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 7ce7c2542a3..80e4cac131d 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -502,11 +502,14 @@ extern int INTEL_DEBUG; */ extern bool intelInitContext(struct intel_context *intel, - int api, - const struct gl_config * mesaVis, - __DRIcontext * driContextPriv, - void *sharedContextPrivate, - struct dd_function_table *functions); + int api, + unsigned major_version, + unsigned minor_version, + const struct gl_config * mesaVis, + __DRIcontext * driContextPriv, + void *sharedContextPrivate, + struct dd_function_table *functions, + unsigned *dri_ctx_error); extern void intelFinish(struct gl_context * ctx); extern void intel_flush_rendering_to_batch(struct gl_context *ctx); diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index a001fddd962..d88c119f427 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -754,8 +754,12 @@ intelDestroyBuffer(__DRIdrawable * driDrawPriv) * functions. */ extern bool -i830CreateContext(const struct gl_config *mesaVis, +i830CreateContext(int api, + const struct gl_config *mesaVis, __DRIcontext *driContextPriv, + unsigned major_version, + unsigned minor_version, + unsigned *error, void *sharedContextPrivate); extern bool @@ -797,27 +801,10 @@ intelCreateContext(gl_api api, major_version, minor_version, error, sharedContextPrivate); } else { - switch (api) { - case API_OPENGL_COMPAT: - if (major_version > 1 || minor_version > 3) { - *error = __DRI_CTX_ERROR_BAD_VERSION; - success = false; - } - break; - case API_OPENGLES: - break; - default: - *error = __DRI_CTX_ERROR_BAD_API; - success = false; - } - - if (success) { - intelScreen->no_vbo = true; - success = i830CreateContext(mesaVis, driContextPriv, - sharedContextPrivate); - if (!success) - *error = __DRI_CTX_ERROR_NO_MEMORY; - } + intelScreen->no_vbo = true; + success = i830CreateContext(api, mesaVis, driContextPriv, + major_version, minor_version, error, + sharedContextPrivate); } #else success = brwCreateContext(api, mesaVis, |