1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
24 **************************************************************************/
26 // File: vogl_gl_object.h
27 #ifndef VOGL_GL_OBJECT_H
28 #define VOGL_GL_OBJECT_H
30 #include "vogl_common.h"
32 class vogl_blob_manager;
34 struct vogl_handle_remapper
36 virtual ~vogl_handle_remapper()
40 virtual bool is_default_remapper() const
45 virtual uint64_t remap_handle(vogl_namespace_t handle_namespace, uint64_t from_handle)
49 VOGL_NOTE_UNUSED(handle_namespace);
53 // Note: This may not be fully implemented during tracing!
54 virtual bool is_valid_handle(vogl_namespace_t handle_namespace, uint64_t from_handle)
58 VOGL_NOTE_UNUSED(handle_namespace);
59 VOGL_NOTE_UNUSED(from_handle);
64 virtual int32 remap_location(uint32 program, int32 from_location)
68 VOGL_NOTE_UNUSED(program);
72 virtual vogl_trace_ptr_value remap_vertex_attrib_ptr(uint index, vogl_trace_ptr_value ptr_val)
76 VOGL_NOTE_UNUSED(index);
80 virtual vogl_trace_ptr_value remap_vertex_array_ptr(vogl_client_side_array_desc_id_t id, uint index, vogl_trace_ptr_value ptr_val)
85 VOGL_NOTE_UNUSED(index);
89 virtual void declare_handle(vogl_namespace_t handle_namespace, uint64_t from_handle, uint64_t to_handle, GLenum target)
93 VOGL_NOTE_UNUSED(handle_namespace);
94 VOGL_NOTE_UNUSED(from_handle);
95 VOGL_NOTE_UNUSED(to_handle);
96 VOGL_NOTE_UNUSED(target);
99 virtual void delete_handle_and_object(vogl_namespace_t handle_namespace, uint64_t from_handle, uint64_t to_handle);
101 virtual void declare_location(uint32 from_program_handle, uint32 to_program_handle, int32 from_location, int32 to_location)
105 VOGL_NOTE_UNUSED(from_program_handle);
106 VOGL_NOTE_UNUSED(to_program_handle);
107 VOGL_NOTE_UNUSED(from_location);
108 VOGL_NOTE_UNUSED(to_location);
111 // Note: This may not be fully implemented during tracing!
112 virtual bool determine_from_object_target(vogl_namespace_t handle_namespace, uint64_t from_handle, GLenum &target)
116 VOGL_NOTE_UNUSED(handle_namespace);
117 VOGL_NOTE_UNUSED(from_handle);
124 // Note: This may not be fully implemented during tracing!
125 virtual bool determine_to_object_target(vogl_namespace_t handle_namespace, uint64_t to_handle, GLenum &target)
129 VOGL_NOTE_UNUSED(handle_namespace);
130 VOGL_NOTE_UNUSED(to_handle);
138 // Update this macro if you add more GL state object types!
139 #define VOGL_GL_OBJECT_STATE_TYPES \
153 enum vogl_gl_object_state_type
155 #define DEF(x) cGLST##x,
156 VOGL_GL_OBJECT_STATE_TYPES
161 const char *get_gl_object_state_type_str(vogl_gl_object_state_type type);
163 vogl_gl_object_state_type determine_gl_object_state_type_from_str(const char *pStr);
165 void vogl_destroy_gl_object(vogl_namespace_t handle_namespace, GLuint64 handle);
166 void vogl_destroy_gl_object(vogl_gl_object_state_type type, GLuint64 handle);
168 class vogl_gl_object_state
171 vogl_gl_object_state()
175 virtual ~vogl_gl_object_state()
179 virtual vogl_gl_object_state_type get_type() const = 0;
181 virtual vogl_namespace_t get_handle_namespace() const = 0;
183 virtual bool snapshot(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 handle, GLenum target) = 0;
185 virtual bool restore(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 &handle) const = 0;
187 virtual bool remap_handles(vogl_handle_remapper &remapper) = 0;
189 virtual GLuint64 get_snapshot_handle() const = 0;
191 virtual void clear() = 0;
193 virtual bool is_valid() const = 0;
195 virtual bool serialize(json_node &node, vogl_blob_manager &blob_manager) const = 0;
196 virtual bool deserialize(const json_node &node, const vogl_blob_manager &blob_manager) = 0;
198 virtual bool compare_restorable_state(const vogl_gl_object_state &rhs) const = 0;
200 virtual bool get_marked_for_deletion() const
206 typedef vogl::vector<vogl_gl_object_state *> vogl_gl_object_state_ptr_vec;
207 typedef vogl::vector<const vogl_gl_object_state *> vogl_const_gl_object_state_ptr_vec;
209 vogl_gl_object_state *vogl_gl_object_state_factory(vogl_gl_object_state_type type);
211 #endif // VOGL_GL_OBJECT_H