diff mbox series

[RFC,2/5] drm_hwcomposer: glworker: Add build time options for certain shader feature names

Message ID 1515564345-1339-3-git-send-email-john.stultz@linaro.org
State New
Headers show
Series drm_hwcomposer: Changes to support HiKey/HiKey960 | expand

Commit Message

John Stultz Jan. 10, 2018, 6:05 a.m. UTC
In order to get the hikey960, which uses the mali bifrost driver
working with drm_hwcomposer, its needed to tweak some extension
and funciton names used in the shaders.

Specifically:
* GL_OES_EGL_image_external_essl3 instead of
  GL_OES_EGL_image_external
* texture() instead of texture2D()

Which is configured using a build time definition.

Credit to Matt Szczesiak for suggesting these changes to get
hikey960 working!

I'm a bit new to all this, and I expect there may be a better
way to do this, so I'd love any feedback or comments!

Change-Id: I2c8f08341ad086479b66241b903c79b00f2a0feb
Cc: Marissa Wall <marissaw@google.com>
Cc: Sean Paul <seanpaul@google.com>
Cc: Dmitry Shmidt <dimitrysh@google.com>
Cc: Robert Foss <robert.foss@collabora.com>
Cc: Matt Szczesiak <matt.szczesiak@arm.com>
Cc: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: David Hanna <david.hanna11@gmail.com>
Cc: Rob Herring <rob.herring@linaro.org>
Signed-off-by: John Stutlz <john.stultz@linaro.org>

---
 glworker.cpp | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

-- 
2.7.4

Comments

Daniel Vetter Jan. 10, 2018, 8:10 a.m. UTC | #1
On Tue, Jan 09, 2018 at 10:05:42PM -0800, John Stultz wrote:
> In order to get the hikey960, which uses the mali bifrost driver
> working with drm_hwcomposer, its needed to tweak some extension
> and funciton names used in the shaders.
> 
> Specifically:
> * GL_OES_EGL_image_external_essl3 instead of
>   GL_OES_EGL_image_external
> * texture() instead of texture2D()
> 
> Which is configured using a build time definition.

Build time is kinda uncool, at least in the spirit of multiarch kernels
:-) Can't we try a few alternatives until the glsl compiler takes it? For
extensions you could/should even query them upfront and then pick the
right one.
-Daniel

> Credit to Matt Szczesiak for suggesting these changes to get
> hikey960 working!
> 
> I'm a bit new to all this, and I expect there may be a better
> way to do this, so I'd love any feedback or comments!
> 
> Change-Id: I2c8f08341ad086479b66241b903c79b00f2a0feb
> Cc: Marissa Wall <marissaw@google.com>
> Cc: Sean Paul <seanpaul@google.com>
> Cc: Dmitry Shmidt <dimitrysh@google.com>
> Cc: Robert Foss <robert.foss@collabora.com>
> Cc: Matt Szczesiak <matt.szczesiak@arm.com>
> Cc: Liviu Dudau <Liviu.Dudau@arm.com>
> Cc: David Hanna <david.hanna11@gmail.com>
> Cc: Rob Herring <rob.herring@linaro.org>
> Signed-off-by: John Stutlz <john.stultz@linaro.org>
> ---
>  glworker.cpp | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/glworker.cpp b/glworker.cpp
> index ca726bf..c35d1b6 100644
> --- a/glworker.cpp
> +++ b/glworker.cpp
> @@ -41,6 +41,17 @@
>  
>  #define MAX_OVERLAPPING_LAYERS 64
>  
> +#ifdef USE_TEXTURE_FN
> + #define TEXTURE_STR "texture"
> +#else
> + #define TEXTURE_STR "texture2D"
> +#endif
> +
> +#ifdef USE_IMAGE_EXTERNAL_ESSL3
> + #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external_essl3"
> +#else
> + #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external"
> +#endif
>  namespace android {
>  
>  // clang-format off
> @@ -237,7 +248,7 @@ static std::string GenerateFragmentShader(int layer_count) {
>    std::ostringstream fragment_shader_stream;
>    fragment_shader_stream << "#version 300 es\n"
>                           << "#define LAYER_COUNT " << layer_count << "\n"
> -                         << "#extension GL_OES_EGL_image_external : require\n"
> +                         << "#extension " << IMAGE_EXTERNAL_STR << " : require\n"
>                           << "precision mediump float;\n";
>    for (int i = 0; i < layer_count; ++i) {
>      fragment_shader_stream << "uniform samplerExternalOES uLayerTexture" << i
> @@ -257,7 +268,7 @@ static std::string GenerateFragmentShader(int layer_count) {
>        fragment_shader_stream << "  if (alphaCover > 0.5/255.0) {\n";
>      // clang-format off
>      fragment_shader_stream
> -        << "  texSample = texture2D(uLayerTexture" << i << ",\n"
> +        << "  texSample = " << TEXTURE_STR << "(uLayerTexture" << i << ",\n"
>          << "                        fTexCoords[" << i << "]);\n"
>          << "  multRgb = texSample.rgb *\n"
>          << "            max(texSample.a, uLayerPremult[" << i << "]);\n"
> -- 
> 2.7.4
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/glworker.cpp b/glworker.cpp
index ca726bf..c35d1b6 100644
--- a/glworker.cpp
+++ b/glworker.cpp
@@ -41,6 +41,17 @@ 
 
 #define MAX_OVERLAPPING_LAYERS 64
 
+#ifdef USE_TEXTURE_FN
+ #define TEXTURE_STR "texture"
+#else
+ #define TEXTURE_STR "texture2D"
+#endif
+
+#ifdef USE_IMAGE_EXTERNAL_ESSL3
+ #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external_essl3"
+#else
+ #define IMAGE_EXTERNAL_STR "GL_OES_EGL_image_external"
+#endif
 namespace android {
 
 // clang-format off
@@ -237,7 +248,7 @@  static std::string GenerateFragmentShader(int layer_count) {
   std::ostringstream fragment_shader_stream;
   fragment_shader_stream << "#version 300 es\n"
                          << "#define LAYER_COUNT " << layer_count << "\n"
-                         << "#extension GL_OES_EGL_image_external : require\n"
+                         << "#extension " << IMAGE_EXTERNAL_STR << " : require\n"
                          << "precision mediump float;\n";
   for (int i = 0; i < layer_count; ++i) {
     fragment_shader_stream << "uniform samplerExternalOES uLayerTexture" << i
@@ -257,7 +268,7 @@  static std::string GenerateFragmentShader(int layer_count) {
       fragment_shader_stream << "  if (alphaCover > 0.5/255.0) {\n";
     // clang-format off
     fragment_shader_stream
-        << "  texSample = texture2D(uLayerTexture" << i << ",\n"
+        << "  texSample = " << TEXTURE_STR << "(uLayerTexture" << i << ",\n"
         << "                        fTexCoords[" << i << "]);\n"
         << "  multRgb = texSample.rgb *\n"
         << "            max(texSample.a, uLayerPremult[" << i << "]);\n"