Re: [Mesa-dev] [PATCH 1/5] (gles3) intel: Set screen's api mask according to hw capabilities
On 11/21/2012 05:43 PM, Chad Versace wrote: Before this patch, intelInitScreen2 set DRIScreen::api_mask with the hacky heuristic below: if (gen = 3) api_mask = GL | GLES1 | GLES2; else api_mask = 0; I don't understand why this hack works with gen2 (i830), or even if it works properly at all. I don't care enough to investigate. On first glance, it appears that this will cause every EGLConfig on i830 to have EGL_RENDERABLE_TYPE=0, and thus prevent eglCreateContext from ever succeeding. Anyway, moving on to living drivers... I think this doesn't work. My guess is that EGL just won't work on i8xx. With the arrival of EGL_OPENGL_ES3_BIT_KHR, this heuristic is now insufficient. We must enable the GLES3 bit if and only if the driver is capable of creating a GLES3 context. This requires us to determine the maximum supported context version supported by the hardware/driver for each api *during initialization of intel_screen*. Therefore, this patch adds four new fields to intel_screen which indicate the maximum supported context version for each api: max_gl_core_version max_gl_compat_version max_gl_es1_version max_gl_es2_version The api mask is now correctly set as: if (max_gl_core_version 0 || max_gl_compat_version 0) api_mask |= GL; if (max_gl_es1_version 0) api_mask |= GLES1; if (max_gl_es2_version 0) api_mask |= GLES2; Tested against gen6 with piglit egl-create-context-verify-gl-flavor. Verified that this patch does not change the set of exposed EGL context flavors. Signed-off-by: Chad Versace chad.vers...@linux.intel.com --- src/mesa/drivers/dri/intel/intel_screen.c | 99 +++ src/mesa/drivers/dri/intel/intel_screen.h | 5 ++ 2 files changed, 93 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 0194804..b63e4f7 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -1046,6 +1046,85 @@ intel_screen_make_configs(__DRIscreen *dri_screen) return configs; } +static void +set_max_gl_versions(struct intel_screen *screen) +{ +#ifdef TEXTURE_FLOAT_ENABLED + bool has_texture_float = true; +#else + bool has_texture_float = false; +#endif + + if (screen-gen = 7) { + screen-max_gl_es1_version = 11; + + if (has_texture_float screen-kernel_has_gen7_sol_reset) { + screen-max_gl_core_version = 31; + screen-max_gl_compat_version = 30; + screen-max_gl_es2_version = 30; + } else { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + } + + } else if (screen-gen = 6) { + screen-max_gl_es1_version = 11; + + if (has_texture_float) { + screen-max_gl_core_version = 31; + screen-max_gl_compat_version = 30; + screen-max_gl_es2_version = 30; + } else { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + } + + } else if (screen-gen = 4) { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + screen-max_gl_es1_version = 11; + + } else if (screen-gen = 3) { + bool has_fragment_shader = driQueryOptionb(screen-optionCache, fragment_shader); + bool has_occlusion_query = driQueryOptionb(screen-optionCache, stub_occlusion_query); + + screen-max_gl_core_version = 0; + screen-max_gl_es1_version = 11; + + if (has_fragment_shader has_occlusion_query) { + screen-max_gl_compat_version = 21; + } else { + screen-max_gl_compat_version = 15; + } + + if (has_fragment_shader) { + screen-max_gl_es2_version = 20; + } else { + screen-max_gl_es2_version = 0; + } + + } else if (screen-gen = 2) { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 13; + screen-max_gl_es2_version = 0; + screen-max_gl_es1_version = 11; + + } else { + assert(false); + } I'd make this just else with 'assert(screen-gen == 2)'. I also think this would be better as a switch-statement. + +#ifndef FEATURE_ES1 + screen-max_gl_es1_version = 0; +#endif + +#ifndef FEATURE_ES2 + screen-max_gl_es2_version = 0; +#endif +} + /** * This is the driver specific part of the createNewScreen entry point. * Called when using DRI2. @@ -1056,7 +1135,6 @@ static const __DRIconfig **intelInitScreen2(__DRIscreen *psp) { struct intel_screen *intelScreen; - unsigned int api_mask; if (psp-dri2.loader-base.version = 2 || psp-dri2.loader-getBuffersWithFormat == NULL) { @@ -1115,18 +1193,17 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) intel_override_separate_stencil(intelScreen); - api_mask = (1 __DRI_API_OPENGL); -#if
Re: [Mesa-dev] [PATCH 1/5] (gles3) intel: Set screen's api mask according to hw capabilities
On 11/27/2012 01:04 PM, Ian Romanick wrote: On 11/21/2012 05:43 PM, Chad Versace wrote: Before this patch, intelInitScreen2 set DRIScreen::api_mask with the hacky heuristic below: if (gen = 3) api_mask = GL | GLES1 | GLES2; else api_mask = 0; I don't understand why this hack works with gen2 (i830), or even if it works properly at all. I don't care enough to investigate. On first glance, it appears that this will cause every EGLConfig on i830 to have EGL_RENDERABLE_TYPE=0, and thus prevent eglCreateContext from ever succeeding. Anyway, moving on to living drivers... I think this doesn't work. My guess is that EGL just won't work on i8xx. With the arrival of EGL_OPENGL_ES3_BIT_KHR, this heuristic is now insufficient. We must enable the GLES3 bit if and only if the driver is capable of creating a GLES3 context. This requires us to determine the maximum supported context version supported by the hardware/driver for each api *during initialization of intel_screen*. Therefore, this patch adds four new fields to intel_screen which indicate the maximum supported context version for each api: max_gl_core_version max_gl_compat_version max_gl_es1_version max_gl_es2_version The api mask is now correctly set as: if (max_gl_core_version 0 || max_gl_compat_version 0) api_mask |= GL; if (max_gl_es1_version 0) api_mask |= GLES1; if (max_gl_es2_version 0) api_mask |= GLES2; Tested against gen6 with piglit egl-create-context-verify-gl-flavor. Verified that this patch does not change the set of exposed EGL context flavors. Signed-off-by: Chad Versace chad.vers...@linux.intel.com +static void +set_max_gl_versions(struct intel_screen *screen) +{ +#ifdef TEXTURE_FLOAT_ENABLED + bool has_texture_float = true; +#else + bool has_texture_float = false; +#endif + + if (screen-gen = 7) { + screen-max_gl_es1_version = 11; + + if (has_texture_float screen-kernel_has_gen7_sol_reset) { + screen-max_gl_core_version = 31; + screen-max_gl_compat_version = 30; + screen-max_gl_es2_version = 30; + } else { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + } + + } else if (screen-gen = 6) { + screen-max_gl_es1_version = 11; + + if (has_texture_float) { + screen-max_gl_core_version = 31; + screen-max_gl_compat_version = 30; + screen-max_gl_es2_version = 30; + } else { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + } + + } else if (screen-gen = 4) { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + screen-max_gl_es1_version = 11; + + } else if (screen-gen = 3) { + bool has_fragment_shader = driQueryOptionb(screen-optionCache, fragment_shader); + bool has_occlusion_query = driQueryOptionb(screen-optionCache, stub_occlusion_query); + + screen-max_gl_core_version = 0; + screen-max_gl_es1_version = 11; + + if (has_fragment_shader has_occlusion_query) { + screen-max_gl_compat_version = 21; + } else { + screen-max_gl_compat_version = 15; + } + + if (has_fragment_shader) { + screen-max_gl_es2_version = 20; + } else { + screen-max_gl_es2_version = 0; + } + + } else if (screen-gen = 2) { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 13; + screen-max_gl_es2_version = 0; + screen-max_gl_es1_version = 11; + + } else { + assert(false); + } I'd make this just else with 'assert(screen-gen == 2)'. I also think this would be better as a switch-statement. Agreed that a switch statement is better. Expect a v2 of this patch. @@ -1115,18 +1193,17 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) intel_override_separate_stencil(intelScreen); - api_mask = (1 __DRI_API_OPENGL); -#if FEATURE_ES1 - api_mask |= (1 __DRI_API_GLES); -#endif -#if FEATURE_ES2 - api_mask |= (1 __DRI_API_GLES2); -#endif + intelScreen-hw_has_swizzling = intel_detect_swizzling(intelScreen); - if (IS_9XX(intelScreen-deviceID) || IS_965(intelScreen-deviceID)) - psp-api_mask = api_mask; + set_max_gl_versions(intelScreen); - intelScreen-hw_has_swizzling = intel_detect_swizzling(intelScreen); + psp-api_mask = 0; + if (intelScreen-max_gl_compat_version 0) + psp-api_mask |= (1 __DRI_API_OPENGL); It seems like this should be unconditional. I know that's different behavior than the existing code, but desktop OpenGL is supported by every piece of hardware this driver can drive. I'll make the change. Unless we start supporting building the driver *without*
[Mesa-dev] [PATCH 1/5] (gles3) intel: Set screen's api mask according to hw capabilities
Before this patch, intelInitScreen2 set DRIScreen::api_mask with the hacky heuristic below: if (gen = 3) api_mask = GL | GLES1 | GLES2; else api_mask = 0; I don't understand why this hack works with gen2 (i830), or even if it works properly at all. I don't care enough to investigate. On first glance, it appears that this will cause every EGLConfig on i830 to have EGL_RENDERABLE_TYPE=0, and thus prevent eglCreateContext from ever succeeding. Anyway, moving on to living drivers... With the arrival of EGL_OPENGL_ES3_BIT_KHR, this heuristic is now insufficient. We must enable the GLES3 bit if and only if the driver is capable of creating a GLES3 context. This requires us to determine the maximum supported context version supported by the hardware/driver for each api *during initialization of intel_screen*. Therefore, this patch adds four new fields to intel_screen which indicate the maximum supported context version for each api: max_gl_core_version max_gl_compat_version max_gl_es1_version max_gl_es2_version The api mask is now correctly set as: if (max_gl_core_version 0 || max_gl_compat_version 0) api_mask |= GL; if (max_gl_es1_version 0) api_mask |= GLES1; if (max_gl_es2_version 0) api_mask |= GLES2; Tested against gen6 with piglit egl-create-context-verify-gl-flavor. Verified that this patch does not change the set of exposed EGL context flavors. Signed-off-by: Chad Versace chad.vers...@linux.intel.com --- src/mesa/drivers/dri/intel/intel_screen.c | 99 +++ src/mesa/drivers/dri/intel/intel_screen.h | 5 ++ 2 files changed, 93 insertions(+), 11 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 0194804..b63e4f7 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -1046,6 +1046,85 @@ intel_screen_make_configs(__DRIscreen *dri_screen) return configs; } +static void +set_max_gl_versions(struct intel_screen *screen) +{ +#ifdef TEXTURE_FLOAT_ENABLED + bool has_texture_float = true; +#else + bool has_texture_float = false; +#endif + + if (screen-gen = 7) { + screen-max_gl_es1_version = 11; + + if (has_texture_float screen-kernel_has_gen7_sol_reset) { + screen-max_gl_core_version = 31; + screen-max_gl_compat_version = 30; + screen-max_gl_es2_version = 30; + } else { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + } + + } else if (screen-gen = 6) { + screen-max_gl_es1_version = 11; + + if (has_texture_float) { + screen-max_gl_core_version = 31; + screen-max_gl_compat_version = 30; + screen-max_gl_es2_version = 30; + } else { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + } + + } else if (screen-gen = 4) { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 21; + screen-max_gl_es2_version = 20; + screen-max_gl_es1_version = 11; + + } else if (screen-gen = 3) { + bool has_fragment_shader = driQueryOptionb(screen-optionCache, fragment_shader); + bool has_occlusion_query = driQueryOptionb(screen-optionCache, stub_occlusion_query); + + screen-max_gl_core_version = 0; + screen-max_gl_es1_version = 11; + + if (has_fragment_shader has_occlusion_query) { + screen-max_gl_compat_version = 21; + } else { + screen-max_gl_compat_version = 15; + } + + if (has_fragment_shader) { + screen-max_gl_es2_version = 20; + } else { + screen-max_gl_es2_version = 0; + } + + } else if (screen-gen = 2) { + screen-max_gl_core_version = 0; + screen-max_gl_compat_version = 13; + screen-max_gl_es2_version = 0; + screen-max_gl_es1_version = 11; + + } else { + assert(false); + } + +#ifndef FEATURE_ES1 + screen-max_gl_es1_version = 0; +#endif + +#ifndef FEATURE_ES2 + screen-max_gl_es2_version = 0; +#endif +} + /** * This is the driver specific part of the createNewScreen entry point. * Called when using DRI2. @@ -1056,7 +1135,6 @@ static const __DRIconfig **intelInitScreen2(__DRIscreen *psp) { struct intel_screen *intelScreen; - unsigned int api_mask; if (psp-dri2.loader-base.version = 2 || psp-dri2.loader-getBuffersWithFormat == NULL) { @@ -1115,18 +1193,17 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp) intel_override_separate_stencil(intelScreen); - api_mask = (1 __DRI_API_OPENGL); -#if FEATURE_ES1 - api_mask |= (1 __DRI_API_GLES); -#endif -#if FEATURE_ES2 - api_mask |= (1 __DRI_API_GLES2); -#endif + intelScreen-hw_has_swizzling = intel_detect_swizzling(intelScreen); - if (IS_9XX(intelScreen-deviceID) || IS_965(intelScreen-deviceID)) -