1 /**************************************************************************
3 * Copyright 2011-2012 Jose Fonseca
4 * Copyright (C) 2013 Intel Corporation. All rights reversed.
5 * Author: Shuang He <shuang.he@intel.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 **************************************************************************/
38 #include "trace_model.hpp"
39 #include "trace_parser.hpp"
40 #include "trace_profiler.hpp"
42 #include "scoped_allocator.hpp"
53 extern trace::Parser parser;
54 extern trace::Profiler profiler;
57 class ScopedAllocator : public ::ScopedAllocator
61 * Allocate an array with the same dimensions as the specified value.
64 alloc(const trace::Value *value, size_t size) {
65 const trace::Array *array = dynamic_cast<const trace::Array *>(value);
67 return ::ScopedAllocator::alloc(array->size() * size);
69 const trace::Null *null = dynamic_cast<const trace::Null *>(value);
81 * Output verbosity when retracing files.
91 * Add profiling data to the dump when retracing.
93 extern bool profiling;
94 extern bool profilingCpuTimes;
95 extern bool profilingGpuTimes;
96 extern bool profilingPixelsDrawn;
97 extern bool profilingMemoryUsage;
102 extern bool dumpingState;
107 DRIVER_HARDWARE, // force hardware
114 extern Driver driver;
115 extern const char *driverModule;
117 extern bool doubleBuffer;
118 extern bool coreProfile;
120 extern unsigned frameNo;
121 extern unsigned callNo;
124 std::ostream &warning(trace::Call &call);
127 void ignore(trace::Call &call);
128 void unsupported(trace::Call &call);
131 typedef void (*Callback)(trace::Call &call);
139 struct stringComparer {
140 bool operator() (const char *a, const char *b) const {
141 return strcmp(a, b) < 0;
146 extern const Entry stdc_callbacks[];
151 typedef std::map<const char *, Callback, stringComparer> Map;
154 std::vector<Callback> callbacks;
158 addCallbacks(stdc_callbacks);
161 virtual ~Retracer() {}
163 void addCallback(const Entry *entry);
164 void addCallbacks(const Entry *entries);
166 void retrace(trace::Call &call);
173 virtual image::Image *
179 dumpState(std::ostream &os) {
185 extern Dumper *dumper;
192 addCallbacks(retrace::Retracer &retracer);
195 frameComplete(trace::Call &call);
200 flushRendering(void);
209 } /* namespace retrace */
211 #endif /* _RETRACE_HPP_ */