Keep shader state cached for further analysis 43/250343/2
authorLukasz Kostyra <l.kostyra@samsung.com>
Tue, 22 Dec 2020 16:14:55 +0000 (17:14 +0100)
committerLukasz Kostyra <l.kostyra@samsung.com>
Thu, 7 Jan 2021 16:40:54 +0000 (17:40 +0100)
Change-Id: I55dac1c67109bb867af39079def0bcb827b925ff

GLESv2/yagl_gles2_calls.c
GLESv2/yagl_gles2_shader.c
GLESv2/yagl_gles2_shader.h

index 75a4e1320ffe72e53489510ffe312bdb8bb9a4cd..1f3576cac67a864ac67b78befc897f4b89c2d999 100644 (file)
@@ -1406,7 +1406,6 @@ YAGL_API void glShaderSource(GLuint shader, GLsizei count, const GLchar * const
 
     if (have_strings) {
         uint8_t *tmp_buff;
-        struct yagl_glsl_state glsl_state;
         int ret;
         int patched_len = 0;
         char *patched_source;
@@ -1428,16 +1427,16 @@ YAGL_API void glShaderSource(GLuint shader, GLsizei count, const GLchar * const
 
         YAGL_LOG_TRACE("orig source = %s", tmp_buff);
 
-        yagl_glsl_state_init(&glsl_state,
+        yagl_glsl_state_init(&shader_obj->state,
                              shader_obj->type,
                              (char*)tmp_buff,
                              total_length,
                              (ctx->base.base.client_api == yagl_client_api_gles3));
 
-        ret = yagl_glsl_parse(&glsl_state);
+        ret = yagl_glsl_parse(&shader_obj->state);
 
-        if ((ret == 0) && !glsl_state.have_error) {
-            patched_source = yagl_glsl_state_get_output(&glsl_state,
+        if ((ret == 0) && !shader_obj->state.have_error) {
+            patched_source = yagl_glsl_state_get_output(&shader_obj->state,
                                                         &patched_len);
 
             YAGL_LOG_TRACE("patched source = %s", patched_source);
@@ -1452,13 +1451,12 @@ YAGL_API void glShaderSource(GLuint shader, GLsizei count, const GLchar * const
             /*
              * Unable to parse source, pass as-is.
              */
+            YAGL_LOG_TRACE("unable to patch shader source, passed as-is");
             yagl_gles2_shader_source(shader_obj,
                                      (GLchar*)tmp_buff,
                                      (GLchar*)tmp_buff,
                                      total_length);
         }
-
-        yagl_glsl_state_cleanup(&glsl_state);
     }
 
 out:
index 1ab6bbdfe071a228747ff3511c94782a57c453a0..19f55485860468382ed07850ba1c8a123b77212d 100644 (file)
@@ -45,6 +45,8 @@ static void yagl_gles2_shader_destroy(struct yagl_ref *ref)
 
     yagl_host_glDeleteObjects(&shader->global_name, 1);
 
+    yagl_glsl_state_cleanup(&shader->state);
+
     yagl_object_cleanup(&shader->base);
 
     yagl_free(shader);
index 2c50be50b2ec0b30f31a5112237b0c9196072f65..6cfe8b17908c90b55cb4ee08ce8168b2e4fd6f2f 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "yagl_types.h"
 #include "yagl_object.h"
+#include "yagl_glsl_state.h"
 
 /*
  * Programs and shaders share the same namespace,
@@ -61,6 +62,8 @@ struct yagl_gles2_shader
     GLenum type;
 
     GLchar *source;
+
+    struct yagl_glsl_state state; // for late analysis at draw calls
 };
 
 struct yagl_gles2_shader *yagl_gles2_shader_create(GLenum type);