]> git.cworth.org Git - apitrace/blobdiff - cli/trace_analyzer.hpp
Rename trim::CallSet to trace::FastCallSet
[apitrace] / cli / trace_analyzer.hpp
index 6619c5736e34b2cd1f193e147a23b58fdbb5e95f..3e4013bcd07fcfe6fd0806f936a22132508a3e06 100644 (file)
 #include <GL/glext.h>
 
 #include "trace_callset.hpp"
+#include "trace_fast_callset.hpp"
 #include "trace_parser.hpp"
 
+typedef unsigned TrimFlags;
+
+/**
+ * Trim flags
+ */
+enum {
+
+    /* Whether to trim calls that have no side effects. */
+    TRIM_FLAG_NO_SIDE_EFFECTS          = (1 << 0),
+
+    /* Whether to trim calls to setup textures that are never used. */
+    TRIM_FLAG_TEXTURES                 = (1 << 1),
+
+    /* Whether to trim calls to setup shaders that are never used. */
+    TRIM_FLAG_SHADERS                  = (1 << 2),
+
+    /* Whether to trim drawing operations outside of the desired call-set. */
+    TRIM_FLAG_DRAWING                  = (1 << 3),
+};
+
 class TraceAnalyzer {
 private:
     std::map<std::string, std::set<unsigned> > resources;
@@ -38,7 +59,7 @@ private:
 
     std::map<GLenum, unsigned> texture_map;
 
-    std::set<unsigned> required;
+    trace::FastCallSet required;
 
     bool transformFeedbackActive;
     bool framebufferObjectActive;
@@ -46,6 +67,7 @@ private:
     GLuint insideNewEndList;
     GLenum activeTextureUnit;
     GLuint activeProgram;
+    unsigned int trimFlags;
 
     void provide(std::string resource, trace::CallNo call_no);
     void providef(std::string resource, int resource_no, trace::CallNo call_no);
@@ -58,7 +80,13 @@ private:
     void unlinkAll(std::string resource);
 
     void stateTrackPreCall(trace::Call *call);
+
     void recordSideEffects(trace::Call *call);
+    bool callHasNoSideEffects(trace::Call *call, const char *name);
+    bool recordTextureSideEffects(trace::Call *call, const char *name);
+    bool recordShaderSideEffects(trace::Call *call, const char *name);
+    bool recordDrawingSideEffects(trace::Call *call, const char *name);
+
     void stateTrackPostCall(trace::Call *call);
 
     bool renderingHasSideEffect(void);
@@ -68,7 +96,7 @@ private:
     void requireDependencies(trace::Call *call);
 
 public:
-    TraceAnalyzer();
+    TraceAnalyzer(TrimFlags trimFlags);
     ~TraceAnalyzer();
 
     /* Analyze this call by tracking state and recording all the
@@ -82,5 +110,5 @@ public:
     /* Return a set of all the required calls, (both those calls added
      * explicitly with require() and those implicitly depended
      * upon. */
-    std::set<unsigned> *get_required(void);
+    trace::FastCallSet *get_required(void);
 };