Browse Source

shaderpipeline: Changes to support OpenGL ES

rdb 5 years ago
parent
commit
799cfec4a1

+ 0 - 25
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -154,22 +154,12 @@ null_glBlendColor(GLclampf, GLclampf, GLclampf, GLclampf) {
 // default shader just applies a single texture, which is good enough for
 // drawing GUIs and such.
 static const string default_vshader =
-#ifndef OPENGLES
   "#version 330\n"
   "in vec4 p3d_Vertex;\n"
   "in vec4 p3d_Color;\n"
   "in vec2 p3d_MultiTexCoord0;\n"
   "out vec2 texcoord;\n"
   "out vec4 color;\n"
-#else
-  "#version 100\n"
-  "precision mediump float;\n"
-  "attribute vec4 p3d_Vertex;\n"
-  "attribute vec4 p3d_Color;\n"
-  "attribute vec2 p3d_MultiTexCoord0;\n"
-  "varying vec2 texcoord;\n"
-  "varying lowp vec4 color;\n"
-#endif
   "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "void main(void) {\n"
@@ -207,31 +197,16 @@ static const string default_vshader_fp64 =
 #endif
 
 static const string default_fshader =
-#ifndef OPENGLES
   "#version 330\n"
   "in vec2 texcoord;\n"
   "in vec4 color;\n"
   "out vec4 p3d_FragColor;\n"
   "uniform sampler2D p3d_Texture0;\n"
   "uniform vec4 p3d_TexAlphaOnly;\n"
-#else
-  "#version 100\n"
-  "precision mediump float;\n"
-  "varying vec2 texcoord;\n"
-  "varying lowp vec4 color;\n"
-  "uniform lowp sampler2D p3d_Texture0;\n"
-  "uniform lowp vec4 p3d_TexAlphaOnly;\n"
-#endif
   "void main(void) {\n"
-#ifndef OPENGLES
   "  p3d_FragColor = texture(p3d_Texture0, texcoord);\n"
   "  p3d_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering
   "  p3d_FragColor *= color;\n"
-#else
-  "  gl_FragColor = texture2D(p3d_Texture0, texcoord);\n"
-  "  gl_FragColor += p3d_TexAlphaOnly;\n" // Hack for text rendering
-  "  gl_FragColor *= color;\n"
-#endif
   "}\n";
 #endif
 

+ 6 - 5
panda/src/glstuff/glShaderContext_src.cxx

@@ -3354,10 +3354,10 @@ attach_shader(const ShaderModule *module) {
   }
 
   bool needs_compile = false;
-#ifndef OPENGLES
   if (module->is_of_type(ShaderModuleSpirV::get_class_type())) {
     ShaderModuleSpirV *spv = (ShaderModuleSpirV *)module;
 
+#ifndef OPENGLES
     if (_glgsg->_supports_spir_v) {
       // Load a SPIR-V binary.
       if (GLCAT.is_debug()) {
@@ -3411,7 +3411,9 @@ attach_shader(const ShaderModule *module) {
       }
       _glgsg->_glSpecializeShader(handle, "main", 0, nullptr, nullptr);
     }
-    else {
+    else
+#endif  // !OPENGLES
+    {
       // Compile to GLSL using SPIRV-Cross.
       if (GLCAT.is_debug()) {
         GLCAT.debug()
@@ -3520,9 +3522,8 @@ attach_shader(const ShaderModule *module) {
       _glgsg->_glShaderSource(handle, 1, &text_str, nullptr);
       needs_compile = true;
     }
-  } else
-#endif
-  if (module->is_of_type(ShaderModuleGlsl::get_class_type())) {
+  }
+  else if (module->is_of_type(ShaderModuleGlsl::get_class_type())) {
     // Legacy preprocessed GLSL.
     if (GLCAT.is_debug()) {
       GLCAT.debug()

+ 2 - 2
panda/src/shaderpipeline/shaderCompilerGlslang.cxx

@@ -309,7 +309,7 @@ compile_now(ShaderModule::Stage stage, std::istream &in,
     }
   }
 
-  if (!is_cg && glsl_version < 330 && glsl_version != 150) {
+  if (!is_cg && glsl_version < 310 && glsl_version != 150) {
     if (glsl_version != 100 && glsl_version != 110 && glsl_version != 120 &&
         glsl_version != 130 && glsl_version != 140 && glsl_version != 300) {
       shader_cat.error()
@@ -319,7 +319,7 @@ compile_now(ShaderModule::Stage stage, std::istream &in,
 
     shader_cat.warning()
       << filename << " uses deprecated GLSL version " << glsl_version
-      << ".  Some features may not work.  Minimum supported version is 330.\n";
+      << ".  Some features may not work.  Minimum supported version is 330 or 310 es.\n";
 
     // Fall back to GlslPreProc handler.  Cleaner way to do this?
     static ShaderCompilerGlslPreProc preprocessor;