]> git.cworth.org Git - vogl/blob - src/vogltrace/vogl_intercept.h
Initial vogl checkin
[vogl] / src / vogltrace / vogl_intercept.h
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 // File: vogl_intercept.h
27 #ifndef VOGL_INTERCEPT_H
28 #define VOGL_INTERCEPT_H
29
30 #include "vogl_command_line_params.h"
31
32 // Globals
33 extern bool g_dump_gl_calls_flag;
34 extern bool g_dump_gl_buffers_flag;
35 extern bool g_dump_gl_shaders_flag;
36 extern bool g_disable_gl_program_binary_flag;
37 extern bool g_null_mode;
38 extern bool g_backtrace_all_calls;
39
40 // Functions
41 void vogl_early_init();
42 void vogl_deinit();
43
44 class vogl_thread_local_data;
45 void vogl_destroy_thread_local_data(vogl_thread_local_data *pData);
46
47 // Capture status callback:
48 //   pFilename will be either NULL on failure, or a pointer to a valid filename on success
49 //   pOpaque is the user provided pointer
50 // Notes:
51 // It's *not* guaranteed that this func will be called at all. If it is, it'll be called asynchronously on whatever thread called glXSwapBuffers().
52 typedef void (*vogl_capture_status_callback_func_ptr)(const char *pFilename, void *pOpaque);
53
54 // vogl_capture_on_next_swap() will cause the tracer to snapshot the state of all GL contexts, then capture the next X frames to a trace file.
55 // total_frames: number of frames to capture, set to cUINT32_MAX to capture all frames until the app exits.
56 // pPath and pBase_filename are both optional:
57 //   If pPath is not NULL, it overrides whatever trace path was specified by the "--vogl_tracepath X" env command line.
58 //   If pBase_filename is not NULL, it overrides the default base filename, which is "capture_".
59 // If not NULL, pStatus_callback will be asynchronously called when the capture succeeds or fails.
60 // There is *no guarantee* that this status func will actually be called - it depends on the client's GL/GLX usage. But the tracer will try pretty hard to close the trace at exit, so there's a high probability it'll be called.
61 // Returns true if the capture was successfully queued up, false if it's not possible to queue up a capture.
62 bool vogl_capture_on_next_swap(uint total_frames, const char *pPath, const char *pBase_filename, vogl_capture_status_callback_func_ptr pStatus_callback, void *pStatus_callback_opaque);
63
64 // Causes the trace to close as soon as the app calls SwapBuffers(), or false if tracing is not active.
65 // Note the status callbackwill version always overrides any status callback set via vogl_capture_on_next_swap().
66 bool vogl_stop_capturing();
67 bool vogl_stop_capturing(vogl_capture_status_callback_func_ptr pStatus_callback, void *pStatus_callback_opaque);
68
69 // Returns true if a full-stream or triggered capturing is currently active.
70 bool vogl_is_capturing();
71
72 #endif // VOGL_INTERCEPT_H