0023-dri-use-a-supported-API-in-driCreateNewContext.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. From bad7401b26d84646293aef242c710af5f2addf06 Mon Sep 17 00:00:00 2001
  2. From: Brendan King <Brendan.King@imgtec.com>
  3. Date: Thu, 23 Nov 2017 15:50:21 +0000
  4. Subject: [PATCH] dri: use a supported API in driCreateNewContext
  5. Don't assume the screen supports OpenGL when creating a new context,
  6. use an API that the screen supports.
  7. ---
  8. src/mesa/drivers/dri/common/dri_util.c | 14 +++++++++++++-
  9. 1 file changed, 13 insertions(+), 1 deletion(-)
  10. diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
  11. index caed5fa..6c45eb0 100644
  12. --- a/src/mesa/drivers/dri/common/dri_util.c
  13. +++ b/src/mesa/drivers/dri/common/dri_util.c
  14. @@ -50,6 +50,7 @@
  15. #include "main/debug_output.h"
  16. #include "main/errors.h"
  17. #include "main/macros.h"
  18. +#include "util/bitscan.h"
  19. driOptionDescription __dri2ConfigOptions[] = {
  20. DRI_CONF_SECTION_DEBUG
  21. @@ -332,7 +333,11 @@ driCreateContextAttribs(__DRIscreen *screen, int api,
  22. mesa_api = API_OPENGLES;
  23. break;
  24. case __DRI_API_GLES2:
  25. + ctx_config.major_version = 2;
  26. + mesa_api = API_OPENGLES2;
  27. + break;
  28. case __DRI_API_GLES3:
  29. + ctx_config.major_version = 3;
  30. mesa_api = API_OPENGLES2;
  31. break;
  32. case __DRI_API_OPENGL_CORE:
  33. @@ -515,7 +520,14 @@ static __DRIcontext *
  34. driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
  35. __DRIcontext *shared, void *data)
  36. {
  37. - return driCreateNewContextForAPI(screen, __DRI_API_OPENGL,
  38. + int apifs;
  39. +
  40. + apifs = ffs(screen->api_mask);
  41. +
  42. + if (!apifs)
  43. + return NULL;
  44. +
  45. + return driCreateNewContextForAPI(screen, apifs - 1,
  46. config, shared, data);
  47. }