Selaa lähdekoodia

Fix DrawableProxy2D check for large indices: vertex count needs to be over 0xffff. Do not attempt to precache instanced or shadowed pointlight shaders on OpenGL ES.

Lasse Öörni 11 vuotta sitten
vanhempi
sitoutus
e8fdf7a7d8

+ 15 - 2
Source/Engine/Graphics/ShaderPrecache.cpp

@@ -24,6 +24,7 @@
 #include "File.h"
 #include "FileSystem.h"
 #include "Graphics.h"
+#include "GraphicsImpl.h"
 #include "Log.h"
 #include "ShaderPrecache.h"
 #include "ShaderVariation.h"
@@ -112,8 +113,20 @@ void ShaderPrecache::LoadShaders(Graphics* graphics, Deserializer& source)
     XMLElement shader = xmlFile.GetRoot().GetChild("shader");
     while (shader)
     {
-        ShaderVariation* vs = graphics->GetShader(VS, shader.GetAttribute("vs"), shader.GetAttribute("vsdefines"));
-        ShaderVariation* ps = graphics->GetShader(PS, shader.GetAttribute("ps"), shader.GetAttribute("psdefines"));
+        String vsDefines = shader.GetAttribute("vsdefines");
+        String psDefines = shader.GetAttribute("psdefines");
+        
+        // Check for illegal variations on OpenGL ES and skip them
+        #ifdef GL_ES_VERSION_2_0
+        if (vsDefines.Contains("INSTANCED") || (psDefines.Contains("POINTLIGHT") && psDefines.Contains("SHADOW")))
+        {
+            shader = shader.GetNext("shader");
+            continue;
+        }
+        #endif
+        
+        ShaderVariation* vs = graphics->GetShader(VS, shader.GetAttribute("vs"), vsDefines);
+        ShaderVariation* ps = graphics->GetShader(PS, shader.GetAttribute("ps"), psDefines);
         // Set the shaders active to actually compile them
         graphics->SetShaders(vs, ps);
         

+ 1 - 1
Source/Engine/Urho2D/DrawableProxy2D.cpp

@@ -78,7 +78,7 @@ void DrawableProxy2D::UpdateGeometry(const FrameInfo& frame)
     // Fill index buffer
     if (indexBuffer_->GetIndexCount() < indexCount_)
     {
-        bool largeIndices = indexCount_ > 0xffff;
+        bool largeIndices = vertexCount_ > 0xffff;
         indexBuffer_->SetSize(indexCount_, largeIndices, true);
         void* buffer = indexBuffer_->Lock(0, indexCount_, true);
         if (buffer)