0538-drm-vc4-Add-support-for-rendering-with-ETC1-textures.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 466102927ee6a21eb58d0f5f98b85155e7ee8e5b Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Thu, 3 Nov 2016 18:53:10 -0700
  4. Subject: [PATCH] drm/vc4: Add support for rendering with ETC1 textures.
  5. The validation for it ends up being quite simple, but I hadn't got
  6. around to it before merging the driver. For backwards compatibility,
  7. we also need to add a flag so that the userspace GL driver can easily
  8. tell if the kernel will allow ETC1 textures (on an old kernel, it will
  9. continue to convert to RGBA8)
  10. Signed-off-by: Eric Anholt <eric@anholt.net>
  11. (cherry picked from commit 7154d76fedf549607afbc0d13db9aaf02da5cebf)
  12. ---
  13. drivers/gpu/drm/vc4/vc4_drv.c | 1 +
  14. drivers/gpu/drm/vc4/vc4_validate.c | 7 +++++++
  15. include/uapi/drm/vc4_drm.h | 1 +
  16. 3 files changed, 9 insertions(+)
  17. --- a/drivers/gpu/drm/vc4/vc4_drv.c
  18. +++ b/drivers/gpu/drm/vc4/vc4_drv.c
  19. @@ -103,6 +103,7 @@ static int vc4_get_param_ioctl(struct dr
  20. pm_runtime_put(&vc4->v3d->pdev->dev);
  21. break;
  22. case DRM_VC4_PARAM_SUPPORTS_BRANCHES:
  23. + case DRM_VC4_PARAM_SUPPORTS_ETC1:
  24. args->value = true;
  25. break;
  26. default:
  27. --- a/drivers/gpu/drm/vc4/vc4_validate.c
  28. +++ b/drivers/gpu/drm/vc4/vc4_validate.c
  29. @@ -644,6 +644,13 @@ reloc_tex(struct vc4_exec_info *exec,
  30. cpp = 1;
  31. break;
  32. case VC4_TEXTURE_TYPE_ETC1:
  33. + /* ETC1 is arranged as 64-bit blocks, where each block is 4x4
  34. + * pixels.
  35. + */
  36. + cpp = 8;
  37. + width = (width + 3) >> 2;
  38. + height = (height + 3) >> 2;
  39. + break;
  40. case VC4_TEXTURE_TYPE_BW1:
  41. case VC4_TEXTURE_TYPE_A4:
  42. case VC4_TEXTURE_TYPE_A1:
  43. --- a/include/uapi/drm/vc4_drm.h
  44. +++ b/include/uapi/drm/vc4_drm.h
  45. @@ -286,6 +286,7 @@ struct drm_vc4_get_hang_state {
  46. #define DRM_VC4_PARAM_V3D_IDENT1 1
  47. #define DRM_VC4_PARAM_V3D_IDENT2 2
  48. #define DRM_VC4_PARAM_SUPPORTS_BRANCHES 3
  49. +#define DRM_VC4_PARAM_SUPPORTS_ETC1 4
  50. struct drm_vc4_get_param {
  51. __u32 param;