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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
Cc: Sean Paul <seanpaul@xxxxxxxxxx>
Cc: Dmitry Shmidt <dimitrysh@xxxxxxxxxx>
Cc: Robert Foss <robert.foss@xxxxxxxxxxxxx>
Cc: Matt Szczesiak <matt.szczesiak@xxxxxxx>
Cc: Liviu Dudau <Liviu.Dudau@xxxxxxx>
Cc: David Hanna <david.hanna11@xxxxxxxxx>
Cc: Rob Herring <rob.herring@xxxxxxxxxx>
Signed-off-by: John Stutlz <john.stultz@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux