| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | # |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 3 | # Vulkan |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 4 | # |
| 5 | # Copyright (C) 2014 LunarG, Inc. |
| 6 | # |
| 7 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | # copy of this software and associated documentation files (the "Software"), |
| 9 | # to deal in the Software without restriction, including without limitation |
| 10 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | # and/or sell copies of the Software, and to permit persons to whom the |
| 12 | # Software is furnished to do so, subject to the following conditions: |
| 13 | # |
| 14 | # The above copyright notice and this permission notice shall be included |
| 15 | # in all copies or substantial portions of the Software. |
| 16 | # |
| 17 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 23 | # DEALINGS IN THE SOFTWARE. |
| 24 | # |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 25 | |
| Peter Lohrmann | d221ea1 | 2015-03-25 21:35:32 -0700 | [diff] [blame] | 26 | import os, sys |
| 27 | |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 28 | # add main repo directory so vulkan.py can be imported. This needs to be a complete path. |
| Peter Lohrmann | d221ea1 | 2015-03-25 21:35:32 -0700 | [diff] [blame] | 29 | glv_scripts_path = os.path.dirname(os.path.abspath(__file__)) |
| 30 | main_path = os.path.abspath(glv_scripts_path + "/../../../") |
| 31 | sys.path.append(main_path) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 32 | |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 33 | import vulkan |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 34 | |
| 35 | class Subcommand(object): |
| 36 | def __init__(self, argv): |
| 37 | self.argv = argv |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 38 | self.headers = vulkan.headers |
| 39 | self.protos = vulkan.protos |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 40 | |
| 41 | def run(self): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 42 | print(self.generate()) |
| 43 | |
| 44 | def generate(self): |
| 45 | copyright = self.generate_copyright() |
| 46 | header = self.generate_header() |
| 47 | body = self.generate_body() |
| 48 | footer = self.generate_footer() |
| 49 | |
| 50 | contents = [] |
| 51 | if copyright: |
| 52 | contents.append(copyright) |
| 53 | if header: |
| 54 | contents.append(header) |
| 55 | if body: |
| 56 | contents.append(body) |
| 57 | if footer: |
| 58 | contents.append(footer) |
| 59 | |
| 60 | return "\n\n".join(contents) |
| 61 | |
| 62 | def generate_copyright(self): |
| 63 | return """/* THIS FILE IS GENERATED. DO NOT EDIT. */ |
| 64 | |
| 65 | /* |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 66 | * Vulkan |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 67 | * |
| 68 | * Copyright (C) 2014 LunarG, Inc. |
| 69 | * |
| 70 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 71 | * copy of this software and associated documentation files (the "Software"), |
| 72 | * to deal in the Software without restriction, including without limitation |
| 73 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 74 | * and/or sell copies of the Software, and to permit persons to whom the |
| 75 | * Software is furnished to do so, subject to the following conditions: |
| 76 | * |
| 77 | * The above copyright notice and this permission notice shall be included |
| 78 | * in all copies or substantial portions of the Software. |
| 79 | * |
| 80 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 81 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 82 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 83 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 84 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 85 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 86 | * DEALINGS IN THE SOFTWARE. |
| 87 | */""" |
| 88 | |
| 89 | def generate_header(self): |
| 90 | return "\n".join(["#include <" + h + ">" for h in self.headers]) |
| 91 | |
| 92 | def generate_body(self): |
| 93 | pass |
| 94 | |
| 95 | def generate_footer(self): |
| 96 | pass |
| 97 | |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 98 | # Return set of printf '%' qualifier, input to that qualifier, and any dereference |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 99 | def _get_printf_params(self, vk_type, name, output_param): |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 100 | deref = "" |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 101 | # TODO : Need ENUM and STRUCT checks here |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 102 | if "VkImage_LAYOUT" in vk_type: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 103 | return ("%s", "string_%s(%s)" % (vk_type.replace('const ', '').strip('*'), name), deref) |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 104 | if "VkClearColor" in vk_type: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 105 | return ("%p", "(void*)&%s" % name, deref) |
| 106 | if "_type" in vk_type.lower(): # TODO : This should be generic ENUM check |
| 107 | return ("%s", "string_%s(%s)" % (vk_type.replace('const ', '').strip('*'), name), deref) |
| 108 | if "char*" == vk_type: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 109 | return ("%s", name, "*") |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 110 | if "uint64_t" in vk_type: |
| 111 | if '*' in vk_type: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 112 | return ("%lu", "(%s == NULL) ? 0 : *(%s)" % (name, name), "*") |
| 113 | return ("%lu", name, deref) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 114 | if "size_t" in vk_type: |
| 115 | if '*' in vk_type: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 116 | return ("%zu", "(%s == NULL) ? 0 : *(%s)" % (name, name), "*") |
| 117 | return ("%zu", name, deref) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 118 | if "float" in vk_type: |
| 119 | if '[' in vk_type: # handle array, current hard-coded to 4 (TODO: Make this dynamic) |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 120 | return ("[%f, %f, %f, %f]", "%s[0], %s[1], %s[2], %s[3]" % (name, name, name, name), deref) |
| 121 | return ("%f", name, deref) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 122 | if "bool" in vk_type or 'xcb_randr_crtc_t' in vk_type: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 123 | return ("%u", name, deref) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 124 | if True in [t in vk_type.lower() for t in ["int", "flags", "mask", "xcb_window_t"]]: |
| 125 | if '[' in vk_type: # handle array, current hard-coded to 4 (TODO: Make this dynamic) |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 126 | return ("[%i, %i, %i, %i]", "%s[0], %s[1], %s[2], %s[3]" % (name, name, name, name), deref) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 127 | if '*' in vk_type: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 128 | return ("%i", "(%s == NULL) ? 0 : *(%s)" % (name, name), "*") |
| 129 | return ("%i", name, deref) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 130 | if output_param: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 131 | return ("%p", "(void*)%s" % name, deref) |
| 132 | return ("%p", "(void*)(%s)" % name, deref) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 133 | |
| 134 | def _generate_trace_func_ptrs(self): |
| 135 | func_ptrs = [] |
| 136 | func_ptrs.append('// Pointers to real functions and declarations of hooked functions') |
| 137 | func_ptrs.append('#ifdef WIN32') |
| 138 | func_ptrs.append('extern INIT_ONCE gInitOnce;') |
| 139 | for proto in self.protos: |
| 140 | if True not in [skip_str in proto.name for skip_str in ['Dbg', 'Wsi']]: #Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 141 | func_ptrs.append('#define __HOOKED_vk%s hooked_vk%s' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 142 | |
| 143 | func_ptrs.append('\n#elif defined(PLATFORM_LINUX)') |
| 144 | func_ptrs.append('extern pthread_once_t gInitOnce;') |
| 145 | for proto in self.protos: |
| 146 | if True not in [skip_str in proto.name for skip_str in ['Dbg', 'Wsi']]: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 147 | func_ptrs.append('#define __HOOKED_vk%s vk%s' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 148 | |
| 149 | func_ptrs.append('#endif\n') |
| 150 | return "\n".join(func_ptrs) |
| 151 | |
| 152 | def _generate_trace_func_ptrs_ext(self, func_class='Wsi'): |
| 153 | func_ptrs = [] |
| 154 | func_ptrs.append('#ifdef WIN32') |
| 155 | for proto in self.protos: |
| 156 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 157 | func_ptrs.append('#define __HOOKED_vk%s hooked_vk%s' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 158 | |
| 159 | func_ptrs.append('#elif defined(__linux__)') |
| 160 | for proto in self.protos: |
| 161 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 162 | func_ptrs.append('#define __HOOKED_vk%s vk%s' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 163 | |
| 164 | func_ptrs.append('#endif\n') |
| 165 | return "\n".join(func_ptrs) |
| 166 | |
| 167 | def _generate_trace_func_protos(self): |
| 168 | func_protos = [] |
| 169 | func_protos.append('// Hooked function prototypes\n') |
| 170 | for proto in self.protos: |
| 171 | if 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 172 | func_protos.append('GLVTRACER_EXPORT %s;' % proto.c_func(prefix="__HOOKED_vk", attr="VKAPI")) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 173 | |
| 174 | return "\n".join(func_protos) |
| 175 | |
| 176 | def _generate_trace_func_protos_ext(self, func_class='Wsi'): |
| 177 | func_protos = [] |
| 178 | func_protos.append('// Hooked function prototypes\n') |
| 179 | for proto in self.protos: |
| 180 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 181 | func_protos.append('GLVTRACER_EXPORT %s;' % proto.c_func(prefix="__HOOKED_vk", attr="VKAPI")) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 182 | |
| 183 | return "\n".join(func_protos) |
| 184 | |
| 185 | |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 186 | def _generate_trace_real_func_ptr_protos(self): |
| 187 | func_ptr_assign = [] |
| 188 | func_ptr_assign.append('') |
| 189 | for proto in self.protos: |
| 190 | if 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 191 | func_ptr_assign.append('extern %s( VKAPI * real_vk%s)(' % (proto.ret, proto.name)) |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 192 | for p in proto.params: |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 193 | func_ptr_assign.append(' %s %s,' % (p.ty, p.name)) |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 194 | func_ptr_assign[-1] = func_ptr_assign[-1].replace(',', ');\n') |
| 195 | return "\n".join(func_ptr_assign) |
| 196 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 197 | def _generate_func_ptr_assignments(self): |
| 198 | func_ptr_assign = [] |
| 199 | for proto in self.protos: |
| 200 | if 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 201 | func_ptr_assign.append('%s( VKAPI * real_vk%s)(' % (proto.ret, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 202 | for p in proto.params: |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 203 | func_ptr_assign.append(' %s %s,' % (p.ty, p.name)) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 204 | func_ptr_assign[-1] = func_ptr_assign[-1].replace(',', ') = vk%s;\n' % (proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 205 | return "\n".join(func_ptr_assign) |
| 206 | |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 207 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 208 | def _generate_func_ptr_assignments_ext(self, func_class='Wsi'): |
| 209 | func_ptr_assign = [] |
| 210 | for proto in self.protos: |
| 211 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 212 | func_ptr_assign.append('static %s( VKAPI * real_vk%s)(' % (proto.ret, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 213 | for p in proto.params: |
| 214 | func_ptr_assign.append(' %s %s,' % (p.ty, p.name)) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 215 | func_ptr_assign[-1] = func_ptr_assign[-1].replace(',', ') = vk%s;\n' % (proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 216 | return "\n".join(func_ptr_assign) |
| 217 | |
| 218 | def _generate_attach_hooks(self): |
| 219 | hooks_txt = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 220 | hooks_txt.append('// declared as extern in glvtrace_vk_helpers.h') |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 221 | hooks_txt.append('BOOL isHooked = FALSE;\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 222 | hooks_txt.append('void AttachHooks()\n{\n BOOL hookSuccess = TRUE;\n#if defined(WIN32)') |
| 223 | hooks_txt.append(' Mhook_BeginMultiOperation(FALSE);') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 224 | # TODO : Verify if CreateInstance is appropriate to key off of here |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 225 | hooks_txt.append(' if (real_vkCreateInstance != NULL)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 226 | hooks_txt.append(' {\n isHooked = TRUE;') |
| 227 | hook_operator = '=' |
| 228 | for proto in self.protos: |
| 229 | if 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 230 | hooks_txt.append(' hookSuccess %s Mhook_SetHook((PVOID*)&real_vk%s, hooked_vk%s);' % (hook_operator, proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 231 | hook_operator = '&=' |
| 232 | hooks_txt.append(' }\n') |
| 233 | hooks_txt.append(' if (!hookSuccess)\n {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 234 | hooks_txt.append(' glv_LogError("Failed to hook Vulkan.");\n }\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 235 | hooks_txt.append(' Mhook_EndMultiOperation();\n') |
| 236 | hooks_txt.append('#elif defined(__linux__)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 237 | hooks_txt.append(' if (real_vkCreateInstance == vkCreateInstance)') |
| 238 | hooks_txt.append(' hookSuccess = glv_platform_get_next_lib_sym((PVOID*)&real_vkCreateInstance,"vkCreateInstance");') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 239 | hooks_txt.append(' isHooked = TRUE;') |
| 240 | for proto in self.protos: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 241 | if 'Dbg' not in proto.name and 'Wsi' not in proto.name and 'CreateInstance' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 242 | hooks_txt.append(' hookSuccess %s glv_platform_get_next_lib_sym((PVOID*)&real_vk%s, "vk%s");' % (hook_operator, proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 243 | hooks_txt.append(' if (!hookSuccess)\n {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 244 | hooks_txt.append(' glv_LogError("Failed to hook Vulkan.");\n }\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 245 | hooks_txt.append('#endif\n}\n') |
| 246 | return "\n".join(hooks_txt) |
| 247 | |
| 248 | def _generate_attach_hooks_ext(self, func_class='Wsi'): |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 249 | func_ext_dict = {'Wsi': '_vkwsix11ext', 'Dbg': '_vkdbg'} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 250 | first_proto_dict = {'Wsi': 'WsiX11AssociateConnection', 'Dbg': 'DbgSetValidationLevel'} |
| 251 | hooks_txt = [] |
| 252 | hooks_txt.append('void AttachHooks%s()\n{\n BOOL hookSuccess = TRUE;\n#if defined(WIN32)' % func_ext_dict[func_class]) |
| 253 | hooks_txt.append(' Mhook_BeginMultiOperation(FALSE);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 254 | hooks_txt.append(' if (real_vk%s != NULL)' % first_proto_dict[func_class]) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 255 | hooks_txt.append(' {') |
| 256 | hook_operator = '=' |
| 257 | for proto in self.protos: |
| 258 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 259 | hooks_txt.append(' hookSuccess %s Mhook_SetHook((PVOID*)&real_vk%s, hooked_vk%s);' % (hook_operator, proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 260 | hook_operator = '&=' |
| 261 | hooks_txt.append(' }\n') |
| 262 | hooks_txt.append(' if (!hookSuccess)\n {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 263 | hooks_txt.append(' glv_LogError("Failed to hook Vulkan ext %s.");\n }\n' % func_class) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 264 | hooks_txt.append(' Mhook_EndMultiOperation();\n') |
| 265 | hooks_txt.append('#elif defined(__linux__)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 266 | hooks_txt.append(' hookSuccess = glv_platform_get_next_lib_sym((PVOID*)&real_vk%s, "vk%s");' % (first_proto_dict[func_class], first_proto_dict[func_class])) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 267 | for proto in self.protos: |
| 268 | if func_class in proto.name and first_proto_dict[func_class] not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 269 | hooks_txt.append(' hookSuccess %s glv_platform_get_next_lib_sym((PVOID*)&real_vk%s, "vk%s");' % (hook_operator, proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 270 | hooks_txt.append(' if (!hookSuccess)\n {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 271 | hooks_txt.append(' glv_LogError("Failed to hook Vulkan ext %s.");\n }\n' % func_class) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 272 | hooks_txt.append('#endif\n}\n') |
| 273 | return "\n".join(hooks_txt) |
| 274 | |
| 275 | def _generate_detach_hooks(self): |
| 276 | hooks_txt = [] |
| 277 | hooks_txt.append('void DetachHooks()\n{\n#ifdef __linux__\n return;\n#elif defined(WIN32)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 278 | hooks_txt.append(' BOOL unhookSuccess = TRUE;\n if (real_vkGetGpuInfo != NULL)\n {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 279 | hook_operator = '=' |
| 280 | for proto in self.protos: |
| 281 | if 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 282 | hooks_txt.append(' unhookSuccess %s Mhook_Unhook((PVOID*)&real_vk%s);' % (hook_operator, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 283 | hook_operator = '&=' |
| 284 | hooks_txt.append(' }\n isHooked = FALSE;') |
| 285 | hooks_txt.append(' if (!unhookSuccess)\n {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 286 | hooks_txt.append(' glv_LogError("Failed to unhook Vulkan.");\n }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 287 | hooks_txt.append('#endif\n}') |
| 288 | hooks_txt.append('#ifdef WIN32\nINIT_ONCE gInitOnce = INIT_ONCE_STATIC_INIT;\n#elif defined(PLATFORM_LINUX)\npthread_once_t gInitOnce = PTHREAD_ONCE_INIT;\n#endif\n') |
| 289 | return "\n".join(hooks_txt) |
| 290 | |
| 291 | def _generate_detach_hooks_ext(self, func_class='Wsi'): |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 292 | func_ext_dict = {'Wsi': '_vkwsix11ext', 'Dbg': '_vkdbg'} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 293 | first_proto_dict = {'Wsi': 'WsiX11AssociateConnection', 'Dbg': 'DbgSetValidationLevel'} |
| 294 | hooks_txt = [] |
| 295 | hooks_txt.append('void DetachHooks%s()\n{\n#ifdef WIN32' % func_ext_dict[func_class]) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 296 | hooks_txt.append(' BOOL unhookSuccess = TRUE;\n if (real_vk%s != NULL)\n {' % first_proto_dict[func_class]) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 297 | hook_operator = '=' |
| 298 | for proto in self.protos: |
| 299 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 300 | hooks_txt.append(' unhookSuccess %s Mhook_Unhook((PVOID*)&real_vk%s);' % (hook_operator, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 301 | hook_operator = '&=' |
| 302 | hooks_txt.append(' }') |
| 303 | hooks_txt.append(' if (!unhookSuccess)\n {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 304 | hooks_txt.append(' glv_LogError("Failed to unhook Vulkan ext %s.");\n }' % func_class) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 305 | hooks_txt.append('#elif defined(__linux__)\n return;\n#endif\n}\n') |
| 306 | return "\n".join(hooks_txt) |
| 307 | |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 308 | def _generate_init_funcs(self): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 309 | init_tracer = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 310 | init_tracer.append('void send_vk_api_version_packet()\n{') |
| 311 | init_tracer.append(' struct_vkApiVersion* pPacket;') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 312 | init_tracer.append(' glv_trace_packet_header* pHeader;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 313 | init_tracer.append(' pHeader = glv_create_trace_packet(GLV_TID_VULKAN, GLV_TPI_VK_vkApiVersion, sizeof(struct_vkApiVersion), 0);') |
| 314 | init_tracer.append(' pPacket = interpret_body_as_vkApiVersion(pHeader, FALSE);') |
| 315 | init_tracer.append(' pPacket->version = VK_API_VERSION;') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 316 | init_tracer.append(' FINISH_TRACE_PACKET();\n}\n') |
| 317 | |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 318 | init_tracer.append('extern GLV_CRITICAL_SECTION g_memInfoLock;') |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 319 | init_tracer.append('void InitTracer(void)\n{') |
| Jon Ashburn | 1ba771d | 2015-02-19 17:04:06 -0700 | [diff] [blame] | 320 | init_tracer.append(' char *ipAddr = glv_get_global_var("GLVLIB_TRACE_IPADDR");') |
| 321 | init_tracer.append(' if (ipAddr == NULL)') |
| 322 | init_tracer.append(' ipAddr = "127.0.0.1";') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 323 | init_tracer.append(' gMessageStream = glv_MessageStream_create(FALSE, ipAddr, GLV_BASE_PORT + GLV_TID_VULKAN);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 324 | init_tracer.append(' glv_trace_set_trace_file(glv_FileLike_create_msg(gMessageStream));') |
| 325 | init_tracer.append('// glv_tracelog_set_log_file(glv_FileLike_create_file(fopen("glv_log_traceside.txt","w")));') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 326 | init_tracer.append(' glv_tracelog_set_tracer_id(GLV_TID_VULKAN);') |
| Jon Ashburn | 1ba771d | 2015-02-19 17:04:06 -0700 | [diff] [blame] | 327 | init_tracer.append(' glv_create_critical_section(&g_memInfoLock);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 328 | init_tracer.append(' send_vk_api_version_packet();\n}\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 329 | return "\n".join(init_tracer) |
| 330 | |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 331 | # Take a list of params and return a list of dicts w/ ptr param details |
| 332 | def _get_packet_ptr_param_list(self, params): |
| 333 | ptr_param_list = [] |
| 334 | # TODO : This is a slightly nicer way to handle custom cases than initial code, however |
| 335 | # this can still be further generalized to eliminate more custom code |
| 336 | # big case to handle is when ptrs to structs have embedded data that needs to be accounted for in packet |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 337 | custom_ptr_dict = {'VkDeviceCreateInfo': {'add_txt': 'add_VkDeviceCreateInfo_to_packet(pHeader, (VkDeviceCreateInfo**) &(pPacket->pCreateInfo), pCreateInfo)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 338 | 'finalize_txt': ''}, |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 339 | 'VkApplicationInfo': {'add_txt': 'add_VkApplicationInfo_to_packet(pHeader, (VkApplicationInfo**)&(pPacket->pAppInfo), pAppInfo)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 340 | 'finalize_txt': ''}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 341 | 'VK_PHYSICAL_GPU': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pGpus), *pGpuCount*sizeof(VK_PHYSICAL_GPU), pGpus)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 342 | 'finalize_txt': 'default'}, |
| 343 | 'pDataSize': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pDataSize), sizeof(size_t), &_dataSize)', |
| 344 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pDataSize))'}, |
| 345 | 'pData': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pData), _dataSize, pData)', |
| 346 | 'finalize_txt': 'default'}, |
| 347 | 'pName': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pName), ((pName != NULL) ? strlen(pName) + 1 : 0), pName)', |
| 348 | 'finalize_txt': 'default'}, |
| 349 | 'pExtName': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pExtName), ((pExtName != NULL) ? strlen(pExtName) + 1 : 0), pExtName)', |
| 350 | 'finalize_txt': 'default'}, |
| 351 | 'pDescriptorSets': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pDescriptorSets), customSize, pDescriptorSets)', |
| 352 | 'finalize_txt': 'default'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 353 | 'VkShaderCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkShaderCreateInfo), pCreateInfo);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pCode), ((pCreateInfo != NULL) ? pCreateInfo->codeSize : 0), pCreateInfo->pCode)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 354 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pCode));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 355 | 'VkFramebufferCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkFramebufferCreateInfo), pCreateInfo);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pColorAttachments), colorCount * sizeof(VkColorAttachmentBindInfo), pCreateInfo->pColorAttachments);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pDepthStencilAttachment), dsSize, pCreateInfo->pDepthStencilAttachment)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 356 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pColorAttachments));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pDepthStencilAttachment));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Jon Ashburn | 4e063af | 2015-04-15 15:45:22 -0600 | [diff] [blame] | 357 | 'VkRenderPassCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkRenderPassCreateInfo), pCreateInfo);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pColorFormats), colorCount * sizeof(VkFormat), pCreateInfo->pColorFormats);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pColorLayouts), colorCount * sizeof(VkImageLayout), pCreateInfo->pColorLayouts);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pColorLoadOps), colorCount * sizeof(VkAttachmentLoadOp), pCreateInfo->pColorLoadOps);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pColorStoreOps), colorCount * sizeof(VkAttachmentStoreOp), pCreateInfo->pColorStoreOps);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pColorLoadClearValues), colorCount * sizeof(VkClearColor), pCreateInfo->pColorLoadClearValues)', |
| 358 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pColorFormats));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pColorLayouts));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pColorLoadOps));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pColorStoreOps));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pColorLoadClearValues));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 359 | 'VkCmdBufferBeginInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pBeginInfo), sizeof(VkCmdBufferBeginInfo), pBeginInfo);\n add_begin_cmdbuf_to_trace_packet(pHeader, (void**)&(pPacket->pBeginInfo->pNext), pBeginInfo->pNext)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 360 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pBeginInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 361 | 'VkDynamicVpStateCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkDynamicVpStateCreateInfo), pCreateInfo);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pViewports), vpsCount * sizeof(VkViewport), pCreateInfo->pViewports);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pScissors), vpsCount * sizeof(VkRect), pCreateInfo->pScissors)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 362 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pViewports));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pScissors));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 363 | 'VkMemoryAllocInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pAllocInfo), sizeof(VkMemoryAllocInfo), pAllocInfo);\n add_alloc_memory_to_trace_packet(pHeader, (void**)&(pPacket->pAllocInfo->pNext), pAllocInfo->pNext)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 364 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pAllocInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 365 | 'VkGraphicsPipelineCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkGraphicsPipelineCreateInfo), pCreateInfo);\n add_pipeline_state_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pNext), pCreateInfo->pNext)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 366 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 367 | 'VkDescriptorPoolCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkDescriptorPoolCreateInfo), pCreateInfo);\n glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pTypeCount), pCreateInfo->count * sizeof(VkDescriptorTypeCount), pCreateInfo->pTypeCount)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 368 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo->pTypeCount));\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 369 | 'VkComputePipelineCreateInfo': {'add_txt': 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo), sizeof(VkComputePipelineCreateInfo), pCreateInfo);\n add_pipeline_state_to_trace_packet(pHeader, (void**)&(pPacket->pCreateInfo->pNext), pCreateInfo->pNext);\n add_pipeline_shader_to_trace_packet(pHeader, (VkPipelineShader*)&pPacket->pCreateInfo->cs, &pCreateInfo->cs)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 370 | 'finalize_txt': 'finalize_pipeline_shader_address(pHeader, &pPacket->pCreateInfo->cs);\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| 371 | } |
| 372 | for p in params: |
| 373 | pp_dict = {} |
| 374 | if '*' in p.ty and p.name not in ['pSysMem', 'pReserved']: |
| 375 | if 'const' in p.ty.lower() and 'count' in params[params.index(p)-1].name.lower(): |
| 376 | pp_dict['add_txt'] = 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->%s), %s*sizeof(%s), %s)' % (p.name, params[params.index(p)-1].name, p.ty.strip('*').replace('const ', ''), p.name) |
| 377 | elif p.ty.strip('*').replace('const ', '') in custom_ptr_dict: |
| 378 | pp_dict['add_txt'] = custom_ptr_dict[p.ty.strip('*').replace('const ', '')]['add_txt'] |
| 379 | pp_dict['finalize_txt'] = custom_ptr_dict[p.ty.strip('*').replace('const ', '')]['finalize_txt'] |
| 380 | elif p.name in custom_ptr_dict: |
| 381 | pp_dict['add_txt'] = custom_ptr_dict[p.name]['add_txt'] |
| 382 | pp_dict['finalize_txt'] = custom_ptr_dict[p.name]['finalize_txt'] |
| 383 | # TODO : This is custom hack to account for 2 pData items with dataSize param for sizing |
| 384 | if 'pData' == p.name and 'dataSize' == params[params.index(p)-1].name: |
| 385 | pp_dict['add_txt'] = pp_dict['add_txt'].replace('_dataSize', 'dataSize') |
| 386 | else: |
| 387 | pp_dict['add_txt'] = 'glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->%s), sizeof(%s), %s)' % (p.name, p.ty.strip('*').replace('const ', ''), p.name) |
| 388 | if 'finalize_txt' not in pp_dict or 'default' == pp_dict['finalize_txt']: |
| 389 | pp_dict['finalize_txt'] = 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->%s))' % (p.name) |
| 390 | pp_dict['index'] = params.index(p) |
| 391 | ptr_param_list.append(pp_dict) |
| 392 | return ptr_param_list |
| 393 | |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 394 | # Take a list of params and return a list of packet size elements |
| 395 | def _get_packet_size(self, params): |
| Tobin Ehlis | f57562c | 2015-03-13 07:18:05 -0600 | [diff] [blame] | 396 | ps = [] # List of elements to be added together to account for packet size for given params |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 397 | skip_list = [] # store params that are already accounted for so we don't count them twice |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 398 | # Dict of specific params with unique custom sizes |
| 399 | custom_size_dict = {'pSetBindPoints': '(VK_SHADER_STAGE_COMPUTE * sizeof(uint32_t))', # Accounting for largest possible array |
| 400 | } |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 401 | for p in params: |
| 402 | #First handle custom cases |
| Tobin Ehlis | 2957cf9 | 2015-04-15 16:52:42 -0600 | [diff] [blame] | 403 | if p.name in ['pCreateInfo', 'pSetLayoutInfoList', 'pBeginInfo', 'pAllocInfo']: |
| Tobin Ehlis | f57562c | 2015-03-13 07:18:05 -0600 | [diff] [blame] | 404 | ps.append('get_struct_chain_size((void*)%s)' % p.name) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 405 | skip_list.append(p.name) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 406 | elif p.name in custom_size_dict: |
| 407 | ps.append(custom_size_dict[p.name]) |
| 408 | skip_list.append(p.name) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 409 | # Skip any params already handled |
| 410 | if p.name in skip_list: |
| 411 | continue |
| 412 | # Now check to identify dynamic arrays which depend on two params |
| 413 | if 'count' in p.name.lower(): |
| 414 | next_idx = params.index(p)+1 |
| 415 | # If next element is a const *, then multiply count and array type |
| 416 | if next_idx < len(params) and '*' in params[next_idx].ty and 'const' in params[next_idx].ty.lower(): |
| 417 | if '*' in p.ty: |
| 418 | ps.append('*%s*sizeof(%s)' % (p.name, params[next_idx].ty.strip('*').replace('const ', ''))) |
| 419 | else: |
| 420 | ps.append('%s*sizeof(%s)' % (p.name, params[next_idx].ty.strip('*').replace('const ', ''))) |
| 421 | skip_list.append(params[next_idx].name) |
| 422 | elif '*' in p.ty and p.name not in ['pSysMem', 'pReserved']: |
| 423 | if 'pData' == p.name: |
| 424 | if 'dataSize' == params[params.index(p)-1].name: |
| 425 | ps.append('dataSize') |
| 426 | elif 'counterCount' == params[params.index(p)-1].name: |
| 427 | ps.append('sizeof(%s)' % p.ty.strip('*').replace('const ', '')) |
| 428 | else: |
| 429 | ps.append('((pDataSize != NULL && pData != NULL) ? *pDataSize : 0)') |
| 430 | elif '**' in p.ty and 'void' in p.ty: |
| 431 | ps.append('sizeof(void*)') |
| 432 | elif 'void' in p.ty: |
| 433 | ps.append('sizeof(%s)' % p.name) |
| 434 | elif 'char' in p.ty: |
| 435 | ps.append('((%s != NULL) ? strlen(%s) + 1 : 0)' % (p.name, p.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 436 | elif 'pDataSize' in p.name: |
| 437 | ps.append('((pDataSize != NULL) ? sizeof(size_t) : 0)') |
| 438 | elif 'IMAGE_SUBRESOURCE' in p.ty and 'pSubresource' == p.name: |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 439 | ps.append('((pSubresource != NULL) ? sizeof(VkImage_SUBRESOURCE) : 0)') |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 440 | else: |
| 441 | ps.append('sizeof(%s)' % (p.ty.strip('*').replace('const ', ''))) |
| 442 | return ps |
| 443 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 444 | # Generate functions used to trace API calls and store the input and result data into a packet |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 445 | # Here's the general flow of code insertion w/ option items flagged w/ "?" |
| 446 | # Result decl? |
| 447 | # Packet struct decl |
| 448 | # ?Special case : setup call to function first and do custom API call time tracking |
| 449 | # CREATE_PACKET |
| 450 | # Call (w/ result?) |
| 451 | # Assign packet values |
| 452 | # FINISH packet |
| 453 | # return result? |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 454 | def _generate_trace_funcs(self): |
| 455 | func_body = [] |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 456 | manually_written_hooked_funcs = ['CreateInstance', 'EnumerateLayers', 'EnumerateGpus', |
| 457 | 'AllocDescriptorSets', 'MapMemory', 'UnmapMemory', |
| 458 | 'CmdPipelineBarrier', 'CmdWaitEvents'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 459 | for proto in self.protos: |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 460 | if proto.name in manually_written_hooked_funcs: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 461 | func_body.append( '// __HOOKED_vk%s is manually written. Look in glvtrace_vk_trace.c\n' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 462 | elif 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 463 | raw_packet_update_list = [] # non-ptr elements placed directly into packet |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 464 | ptr_packet_update_list = [] # ptr elements to be updated into packet |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 465 | return_txt = '' |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 466 | packet_size = [] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 467 | in_data_size = False # flag when we need to capture local input size variable for in/out size |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 468 | func_body.append('GLVTRACER_EXPORT %s VKAPI __HOOKED_vk%s(' % (proto.ret, proto.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 469 | for p in proto.params: # TODO : For all of the ptr types, check them for NULL and return 0 if NULL |
| 470 | if '[' in p.ty: # Correctly declare static arrays in function parameters |
| 471 | func_body.append(' %s %s[%s],' % (p.ty[:p.ty.find('[')], p.name, p.ty[p.ty.find('[')+1:p.ty.find(']')])) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 472 | else: |
| 473 | func_body.append(' %s %s,' % (p.ty, p.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 474 | if '*' in p.ty and p.name not in ['pSysMem', 'pReserved']: |
| 475 | if 'pDataSize' in p.name: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 476 | in_data_size = True; |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 477 | else: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 478 | if '[' in p.ty: |
| Tobin Ehlis | 8a5a85b | 2015-02-25 11:30:27 -0700 | [diff] [blame] | 479 | array_str = p.ty[p.ty.find('[')+1:p.ty.find(']')] |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 480 | raw_packet_update_list.append(' memcpy((void*)pPacket->color, color, %s * sizeof(%s));' % (array_str, p.ty.strip('*').replace('const ', '').replace('[%s]' % array_str, ''))) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 481 | else: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 482 | raw_packet_update_list.append(' pPacket->%s = %s;' % (p.name, p.name)) |
| 483 | # Get list of packet size modifiers due to ptr params |
| 484 | packet_size = self._get_packet_size(proto.params) |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 485 | ptr_packet_update_list = self._get_packet_ptr_param_list(proto.params) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 486 | func_body[-1] = func_body[-1].replace(',', ')') |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 487 | # End of function declaration portion, begin function body |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 488 | func_body.append('{\n glv_trace_packet_header* pHeader;') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 489 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 490 | func_body.append(' %s result;' % proto.ret) |
| 491 | return_txt = 'result = ' |
| 492 | if in_data_size: |
| Jon Ashburn | 53f54a3 | 2015-02-11 09:32:29 -0700 | [diff] [blame] | 493 | func_body.append(' size_t _dataSize;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 494 | func_body.append(' struct_vk%s* pPacket = NULL;' % proto.name) |
| Jon Ashburn | 8cb39a3 | 2015-02-02 12:39:24 -0700 | [diff] [blame] | 495 | # functions that have non-standard sequence of packet creation and calling real function |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 496 | # NOTE: Anytime we call the function before CREATE_TRACE_PACKET, need to add custom code for correctly tracking API call time |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 497 | if proto.name in ['CreateFramebuffer', 'CreateRenderPass', 'CreateDynamicViewportState', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 498 | 'CreateDescriptorRegion']: |
| Tobin Ehlis | f57562c | 2015-03-13 07:18:05 -0600 | [diff] [blame] | 499 | # these are regular case as far as sequence of tracing but have some custom size element |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 500 | if 'CreateFramebuffer' == proto.name: |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 501 | func_body.append(' int dsSize = (pCreateInfo != NULL && pCreateInfo->pDepthStencilAttachment != NULL) ? sizeof(VkDepthStencilBindInfo) : 0;') |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 502 | func_body.append(' uint32_t colorCount = (pCreateInfo != NULL && pCreateInfo->pColorAttachments != NULL) ? pCreateInfo->colorAttachmentCount : 0;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 503 | func_body.append(' CREATE_TRACE_PACKET(vkCreateFramebuffer, get_struct_chain_size((void*)pCreateInfo) + sizeof(VkFramebuffer));') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 504 | elif 'CreateRenderPass' == proto.name: |
| Jon Ashburn | 4e063af | 2015-04-15 15:45:22 -0600 | [diff] [blame] | 505 | func_body.append(' uint32_t colorCount = (pCreateInfo != NULL && (pCreateInfo->pColorFormats != NULL || pCreateInfo->pColorLayouts != NULL || pCreateInfo->pColorLoadOps != NULL || pCreateInfo->pColorStoreOps != NULL || pCreateInfo->pColorLoadClearValues != NULL)) ? pCreateInfo->colorAttachmentCount : 0;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 506 | func_body.append(' CREATE_TRACE_PACKET(vkCreateRenderPass, get_struct_chain_size((void*)pCreateInfo) + sizeof(VkRenderPass));') |
| Jon Ashburn | 8e7dcd0 | 2015-02-04 08:50:35 -0700 | [diff] [blame] | 507 | elif 'CreateDynamicViewportState' == proto.name: |
| Courtney Goeltzenleuchter | c6e32f9 | 2015-02-11 14:13:34 -0700 | [diff] [blame] | 508 | func_body.append(' uint32_t vpsCount = (pCreateInfo != NULL && pCreateInfo->pViewports != NULL) ? pCreateInfo->viewportAndScissorCount : 0;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 509 | func_body.append(' CREATE_TRACE_PACKET(vkCreateDynamicViewportState, get_struct_chain_size((void*)pCreateInfo) + sizeof(VkDynamicVpState));') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 510 | elif 'CreateDescriptorRegion' == proto.name: |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 511 | func_body.append(' uint32_t rgCount = (pCreateInfo != NULL && pCreateInfo->pTypeCount != NULL) ? pCreateInfo->count : 0;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 512 | func_body.append(' CREATE_TRACE_PACKET(vkCreateDescriptorRegion, get_struct_chain_size((void*)pCreateInfo) + sizeof(VkDescriptorRegion));') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 513 | func_body.append(' %sreal_vk%s;' % (return_txt, proto.c_call())) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 514 | else: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 515 | if (0 == len(packet_size)): |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 516 | func_body.append(' CREATE_TRACE_PACKET(vk%s, 0);' % (proto.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 517 | else: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 518 | func_body.append(' CREATE_TRACE_PACKET(vk%s, %s);' % (proto.name, ' + '.join(packet_size))) |
| 519 | func_body.append(' %sreal_vk%s;' % (return_txt, proto.c_call())) |
| Jon Ashburn | 53f54a3 | 2015-02-11 09:32:29 -0700 | [diff] [blame] | 520 | if in_data_size: |
| 521 | func_body.append(' _dataSize = (pDataSize == NULL || pData == NULL) ? 0 : *pDataSize;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 522 | func_body.append(' pPacket = interpret_body_as_vk%s(pHeader);' % proto.name) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 523 | func_body.append('\n'.join(raw_packet_update_list)) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 524 | for pp_dict in ptr_packet_update_list: #buff_ptr_indices: |
| 525 | func_body.append(' %s;' % (pp_dict['add_txt'])) |
| 526 | if 'void' not in proto.ret or '*' in proto.ret: |
| 527 | func_body.append(' pPacket->result = result;') |
| 528 | for pp_dict in ptr_packet_update_list: |
| Tobin Ehlis | 2957cf9 | 2015-04-15 16:52:42 -0600 | [diff] [blame] | 529 | if ('DeviceCreateInfo' not in proto.params[pp_dict['index']].ty) and ('APPLICATION_INFO' not in proto.params[pp_dict['index']].ty): |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 530 | func_body.append(' %s;' % (pp_dict['finalize_txt'])) |
| 531 | func_body.append(' FINISH_TRACE_PACKET();') |
| 532 | if 'AllocMemory' in proto.name: |
| 533 | func_body.append(' add_new_handle_to_mem_info(*pMem, pAllocInfo->allocationSize, NULL);') |
| 534 | elif 'FreeMemory' in proto.name: |
| 535 | func_body.append(' rm_handle_from_mem_info(mem);') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 536 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 537 | func_body.append(' return result;') |
| 538 | func_body.append('}\n') |
| 539 | return "\n".join(func_body) |
| 540 | |
| 541 | def _generate_trace_funcs_ext(self, func_class='Wsi'): |
| 542 | thread_once_funcs = ['DbgRegisterMsgCallback', 'DbgUnregisterMsgCallback', 'DbgSetGlobalOption'] |
| 543 | func_body = [] |
| 544 | for proto in self.protos: |
| 545 | if func_class in proto.name: |
| 546 | packet_update_txt = '' |
| 547 | return_txt = '' |
| 548 | packet_size = '' |
| 549 | buff_ptr_indices = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 550 | func_body.append('GLVTRACER_EXPORT %s VKAPI __HOOKED_vk%s(' % (proto.ret, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 551 | for p in proto.params: # TODO : For all of the ptr types, check them for NULL and return 0 is NULL |
| 552 | func_body.append(' %s %s,' % (p.ty, p.name)) |
| 553 | if 'Size' in p.name: |
| 554 | packet_size += p.name |
| 555 | if '*' in p.ty and 'pSysMem' != p.name: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 556 | if 'char' in p.ty: |
| Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 557 | packet_size += '((%s != NULL) ? strlen(%s) + 1 : 0) + ' % (p.name, p.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 558 | elif 'Size' not in packet_size: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 559 | packet_size += 'sizeof(%s) + ' % p.ty.strip('*').replace('const ', '') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 560 | buff_ptr_indices.append(proto.params.index(p)) |
| 561 | if 'pConnectionInfo' in p.name: |
| 562 | packet_size += '((pConnectionInfo->pConnection != NULL) ? sizeof(void *) : 0)' |
| 563 | else: |
| 564 | packet_update_txt += ' pPacket->%s = %s;\n' % (p.name, p.name) |
| 565 | if '' == packet_size: |
| 566 | packet_size = '0' |
| 567 | else: |
| 568 | packet_size = packet_size.strip(' + ') |
| 569 | func_body[-1] = func_body[-1].replace(',', ')') |
| 570 | func_body.append('{\n glv_trace_packet_header* pHeader;') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 571 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 572 | func_body.append(' %s result;' % proto.ret) |
| 573 | return_txt = 'result = ' |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 574 | func_body.append(' struct_vk%s* pPacket = NULL;' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 575 | if proto.name in thread_once_funcs: |
| 576 | func_body.append(' glv_platform_thread_once(&gInitOnce, InitTracer);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 577 | func_body.append(' SEND_ENTRYPOINT_ID(vk%s);' % proto.name) |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 578 | if 'DbgRegisterMsgCallback' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 579 | func_body.append(' CREATE_TRACE_PACKET(vk%s, sizeof(char));' % proto.name) |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 580 | else: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 581 | func_body.append(' CREATE_TRACE_PACKET(vk%s, %s);' % (proto.name, packet_size)) |
| 582 | func_body.append(' %sreal_vk%s;' % (return_txt, proto.c_call())) |
| 583 | func_body.append(' pPacket = interpret_body_as_vk%s(pHeader);' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 584 | func_body.append(packet_update_txt.strip('\n')) |
| 585 | for idx in buff_ptr_indices: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 586 | if 'char' in proto.params[idx].ty: |
| Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 587 | func_body.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->%s), ((%s != NULL) ? strlen(%s) + 1 : 0), %s);' % (proto.params[idx].name, proto.params[idx].name, proto.params[idx].name, proto.params[idx].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 588 | elif 'Size' in proto.params[idx-1].name: |
| 589 | func_body.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->%s), %s, %s);' % (proto.params[idx].name, proto.params[idx-1].name, proto.params[idx].name)) |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 590 | elif 'DbgRegisterMsgCallback' in proto.name: |
| 591 | func_body.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->%s), sizeof(%s), %s);' % (proto.params[idx].name, 'char', proto.params[idx].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 592 | else: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 593 | func_body.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&(pPacket->%s), sizeof(%s), %s);' % (proto.params[idx].name, proto.params[idx].ty.strip('*').replace('const ', ''), proto.params[idx].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 594 | if 'WsiX11AssociateConnection' in proto.name: |
| 595 | func_body.append(' if (pConnectionInfo->pConnection != NULL) {') |
| 596 | func_body.append(' glv_add_buffer_to_trace_packet(pHeader, (void**) &(pPacket->pConnectionInfo->pConnection), sizeof(void *), pConnectionInfo->pConnection);') |
| 597 | func_body.append(' glv_finalize_buffer_address(pHeader, (void**) &(pPacket->pConnectionInfo->pConnection));') |
| 598 | func_body.append(' }') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 599 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 600 | func_body.append(' pPacket->result = result;') |
| 601 | for idx in buff_ptr_indices: |
| 602 | func_body.append(' glv_finalize_buffer_address(pHeader, (void**)&(pPacket->%s));' % (proto.params[idx].name)) |
| 603 | func_body.append(' FINISH_TRACE_PACKET();') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 604 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 605 | func_body.append(' return result;') |
| 606 | func_body.append('}\n') |
| 607 | return "\n".join(func_body) |
| 608 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 609 | def _generate_packet_id_enum(self): |
| 610 | pid_enum = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 611 | pid_enum.append('enum GLV_TRACE_PACKET_ID_VK') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 612 | pid_enum.append('{') |
| 613 | first_func = True |
| 614 | for proto in self.protos: |
| 615 | if first_func: |
| 616 | first_func = False |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 617 | pid_enum.append(' GLV_TPI_VK_vkApiVersion = GLV_TPI_BEGIN_API_HERE,') |
| 618 | pid_enum.append(' GLV_TPI_VK_vk%s,' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 619 | else: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 620 | pid_enum.append(' GLV_TPI_VK_vk%s,' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 621 | pid_enum.append('};\n') |
| 622 | return "\n".join(pid_enum) |
| 623 | |
| 624 | def _generate_stringify_func(self): |
| 625 | func_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 626 | func_body.append('static const char *stringify_vk_packet_id(const enum GLV_TRACE_PACKET_ID_VK id, const glv_trace_packet_header* pHeader)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 627 | func_body.append('{') |
| 628 | func_body.append(' static char str[1024];') |
| 629 | func_body.append(' switch(id) {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 630 | func_body.append(' case GLV_TPI_VK_vkApiVersion:') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 631 | func_body.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 632 | func_body.append(' struct_vkApiVersion* pPacket = (struct_vkApiVersion*)(pHeader->pBody);') |
| 633 | func_body.append(' snprintf(str, 1024, "vkApiVersion = 0x%x", pPacket->version);') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 634 | func_body.append(' return str;') |
| 635 | func_body.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 636 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 637 | func_body.append(' case GLV_TPI_VK_vk%s:' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 638 | func_body.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 639 | func_str = 'vk%s(' % proto.name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 640 | print_vals = '' |
| 641 | create_func = False |
| 642 | if 'Create' in proto.name or 'Alloc' in proto.name or 'MapMemory' in proto.name: |
| 643 | create_func = True |
| 644 | for p in proto.params: |
| 645 | last_param = False |
| 646 | if (p.name == proto.params[-1].name): |
| 647 | last_param = True |
| 648 | if last_param and create_func: # last param of create func |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 649 | (pft, pfi, ptr) = self._get_printf_params(p.ty,'pPacket->%s' % p.name, True) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 650 | else: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 651 | (pft, pfi, ptr) = self._get_printf_params(p.ty, 'pPacket->%s' % p.name, False) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 652 | if last_param == True: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 653 | func_str += '%s%s = %s)' % (ptr, p.name, pft) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 654 | print_vals += ', %s' % (pfi) |
| 655 | else: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 656 | func_str += '%s%s = %s, ' % (ptr, p.name, pft) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 657 | print_vals += ', %s' % (pfi) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 658 | func_body.append(' struct_vk%s* pPacket = (struct_vk%s*)(pHeader->pBody);' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 659 | func_body.append(' snprintf(str, 1024, "%s"%s);' % (func_str, print_vals)) |
| 660 | func_body.append(' return str;') |
| 661 | func_body.append(' }') |
| 662 | func_body.append(' default:') |
| 663 | func_body.append(' return NULL;') |
| 664 | func_body.append(' }') |
| 665 | func_body.append('};\n') |
| 666 | return "\n".join(func_body) |
| 667 | |
| 668 | def _generate_interp_func(self): |
| 669 | interp_func_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 670 | interp_func_body.append('static glv_trace_packet_header* interpret_trace_packet_vk(glv_trace_packet_header* pHeader)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 671 | interp_func_body.append('{') |
| 672 | interp_func_body.append(' if (pHeader == NULL)') |
| 673 | interp_func_body.append(' {') |
| 674 | interp_func_body.append(' return NULL;') |
| 675 | interp_func_body.append(' }') |
| 676 | interp_func_body.append(' switch (pHeader->packet_id)') |
| 677 | interp_func_body.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 678 | interp_func_body.append(' case GLV_TPI_VK_vkApiVersion:\n {') |
| 679 | interp_func_body.append(' return interpret_body_as_vkApiVersion(pHeader, TRUE)->header;\n }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 680 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 681 | interp_func_body.append(' case GLV_TPI_VK_vk%s:\n {' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 682 | header_prefix = 'h' |
| 683 | if 'Wsi' in proto.name or 'Dbg' in proto.name: |
| 684 | header_prefix = 'pH' |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 685 | interp_func_body.append(' return interpret_body_as_vk%s(pHeader)->%seader;\n }' % (proto.name, header_prefix)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 686 | interp_func_body.append(' default:') |
| 687 | interp_func_body.append(' return NULL;') |
| 688 | interp_func_body.append(' }') |
| 689 | interp_func_body.append(' return NULL;') |
| 690 | interp_func_body.append('}') |
| 691 | return "\n".join(interp_func_body) |
| 692 | |
| 693 | def _generate_struct_util_funcs(self): |
| 694 | pid_enum = [] |
| 695 | pid_enum.append('//=============================================================================') |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 696 | pid_enum.append('static void add_VkApplicationInfo_to_packet(glv_trace_packet_header* pHeader, VkApplicationInfo** ppStruct, const VkApplicationInfo *pInStruct)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 697 | pid_enum.append('{') |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 698 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)ppStruct, sizeof(VkApplicationInfo), pInStruct);') |
| Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 699 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&((*ppStruct)->pAppName), strlen(pInStruct->pAppName) + 1, pInStruct->pAppName);') |
| 700 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&((*ppStruct)->pEngineName), strlen(pInStruct->pEngineName) + 1, pInStruct->pEngineName);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 701 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&((*ppStruct)->pAppName));') |
| 702 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&((*ppStruct)->pEngineName));') |
| 703 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&*ppStruct);') |
| 704 | pid_enum.append('};\n') |
| Jon Ashburn | 4e063af | 2015-04-15 15:45:22 -0600 | [diff] [blame] | 705 | pid_enum.append('static void add_VkInstanceCreateInfo_to_packet(glv_trace_packet_header* pHeader, VkInstanceCreateInfo** ppStruct, VkInstanceCreateInfo *pInStruct)') |
| 706 | pid_enum.append('{') |
| 707 | pid_enum.append(' uint32_t i;') |
| 708 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)ppStruct, sizeof(VkInstanceCreateInfo), pInStruct);') |
| 709 | pid_enum.append(' add_VkApplicationInfo_to_packet(pHeader, (VkApplicationInfo**)&((*ppStruct)->pAppInfo), pInStruct->pAppInfo);') |
| 710 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&((*ppStruct)->pAllocCb), sizeof(VkAllocCallbacks), pInStruct->pAllocCb);') |
| 711 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&((*ppStruct)->pAllocCb));') |
| 712 | pid_enum.append(' if (pInStruct->extensionCount > 0) ') |
| 713 | pid_enum.append(' {') |
| 714 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&(*ppStruct)->ppEnabledExtensionNames), pInStruct->extensionCount * sizeof(char *), pInStruct->ppEnabledExtensionNames);') |
| 715 | pid_enum.append(' for (i = 0; i < pInStruct->extensionCount; i++)') |
| 716 | pid_enum.append(' {') |
| 717 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppStruct)->ppEnabledExtensionNames[i])), strlen(pInStruct->ppEnabledExtensionNames[i]) + 1, pInStruct->ppEnabledExtensionNames[i]);') |
| 718 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppStruct)->ppEnabledExtensionNames[i])));') |
| 719 | pid_enum.append(' }') |
| 720 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void **)&(*ppStruct)->ppEnabledExtensionNames);') |
| 721 | pid_enum.append(' }') |
| 722 | pid_enum.append(' VkLayerCreateInfo *pNext = ( VkLayerCreateInfo *) pInStruct->pNext;') |
| 723 | pid_enum.append(' while (pNext != NULL)') |
| 724 | pid_enum.append(' {') |
| 725 | pid_enum.append(' if ((pNext->sType == VK_STRUCTURE_TYPE_LAYER_CREATE_INFO) && pNext->layerCount > 0)') |
| 726 | pid_enum.append(' {') |
| 727 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppStruct)->pNext)), sizeof(VkLayerCreateInfo), pNext);') |
| 728 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppStruct)->pNext)));') |
| 729 | pid_enum.append(' VkLayerCreateInfo **ppOutStruct = (VkLayerCreateInfo **) &((*ppStruct)->pNext);') |
| 730 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&(*ppOutStruct)->ppActiveLayerNames), pNext->layerCount * sizeof(char *), pNext->ppActiveLayerNames);') |
| 731 | pid_enum.append(' for (i = 0; i < pNext->layerCount; i++)') |
| 732 | pid_enum.append(' {') |
| 733 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppOutStruct)->ppActiveLayerNames[i])), strlen(pNext->ppActiveLayerNames[i]) + 1, pNext->ppActiveLayerNames[i]);') |
| 734 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppOutStruct)->ppActiveLayerNames[i])));') |
| 735 | pid_enum.append(' }') |
| 736 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void **)&(*ppOutStruct)->ppActiveLayerNames);') |
| 737 | pid_enum.append(' }') |
| 738 | pid_enum.append(' pNext = ( VkLayerCreateInfo *) pNext->pNext;') |
| 739 | pid_enum.append(' }') |
| 740 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)ppStruct);') |
| 741 | pid_enum.append('}\n') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 742 | pid_enum.append('static void add_VkDeviceCreateInfo_to_packet(glv_trace_packet_header* pHeader, VkDeviceCreateInfo** ppStruct, const VkDeviceCreateInfo *pInStruct)') |
| Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 743 | pid_enum.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 744 | pid_enum.append(' uint32_t i;') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 745 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)ppStruct, sizeof(VkDeviceCreateInfo), pInStruct);') |
| 746 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&(*ppStruct)->pRequestedQueues, pInStruct->queueRecordCount*sizeof(VkDeviceQueueCreateInfo), pInStruct->pRequestedQueues);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 747 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&(*ppStruct)->pRequestedQueues);') |
| Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 748 | pid_enum.append(' if (pInStruct->extensionCount > 0) ') |
| 749 | pid_enum.append(' {') |
| 750 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&(*ppStruct)->ppEnabledExtensionNames), pInStruct->extensionCount * sizeof(char *), pInStruct->ppEnabledExtensionNames);') |
| 751 | pid_enum.append(' for (i = 0; i < pInStruct->extensionCount; i++)') |
| 752 | pid_enum.append(' {') |
| 753 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppStruct)->ppEnabledExtensionNames[i])), strlen(pInStruct->ppEnabledExtensionNames[i]) + 1, pInStruct->ppEnabledExtensionNames[i]);') |
| 754 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppStruct)->ppEnabledExtensionNames[i])));') |
| 755 | pid_enum.append(' }') |
| 756 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void **)&(*ppStruct)->ppEnabledExtensionNames);') |
| 757 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 758 | pid_enum.append(' VkLayerCreateInfo *pNext = ( VkLayerCreateInfo *) pInStruct->pNext;') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 759 | pid_enum.append(' while (pNext != NULL)') |
| 760 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 761 | pid_enum.append(' if ((pNext->sType == VK_STRUCTURE_TYPE_LAYER_CREATE_INFO) && pNext->layerCount > 0)') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 762 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 763 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppStruct)->pNext)), sizeof(VkLayerCreateInfo), pNext);') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 764 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppStruct)->pNext)));') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 765 | pid_enum.append(' VkLayerCreateInfo **ppOutStruct = (VkLayerCreateInfo **) &((*ppStruct)->pNext);') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 766 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&(*ppOutStruct)->ppActiveLayerNames), pNext->layerCount * sizeof(char *), pNext->ppActiveLayerNames);') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 767 | pid_enum.append(' for (i = 0; i < pNext->layerCount; i++)') |
| 768 | pid_enum.append(' {') |
| 769 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppOutStruct)->ppActiveLayerNames[i])), strlen(pNext->ppActiveLayerNames[i]) + 1, pNext->ppActiveLayerNames[i]);') |
| 770 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppOutStruct)->ppActiveLayerNames[i])));') |
| 771 | pid_enum.append(' }') |
| 772 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void **)&(*ppOutStruct)->ppActiveLayerNames);') |
| 773 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 774 | pid_enum.append(' pNext = ( VkLayerCreateInfo *) pNext->pNext;') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 775 | pid_enum.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 776 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)ppStruct);') |
| 777 | pid_enum.append('}\n') |
| Jon Ashburn | a80335f | 2015-04-15 18:17:34 -0600 | [diff] [blame^] | 778 | pid_enum.append('//=============================================================================\n') |
| 779 | pid_enum.append('static VkInstanceCreateInfo* interpret_VkInstanceCreateInfo(glv_trace_packet_header* pHeader, intptr_t ptr_variable)') |
| 780 | pid_enum.append('{') |
| 781 | pid_enum.append(' VkInstanceCreateInfo* pVkInstanceCreateInfo = (VkInstanceCreateInfo*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)ptr_variable);\n') |
| 782 | pid_enum.append(' if (pVkInstanceCreateInfo != NULL)') |
| 783 | pid_enum.append(' {') |
| 784 | pid_enum.append(' uint32_t i;') |
| 785 | pid_enum.append(' const char** pNames;') |
| 786 | pid_enum.append(' pVkInstanceCreateInfo->pAppInfo = (VkApplicationInfo*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkInstanceCreateInfo->pAppInfo);') |
| 787 | pid_enum.append(' pVkInstanceCreateInfo->pAllocCb = (VkAllocCallbacks*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkInstanceCreateInfo->pAllocCb);') |
| 788 | pid_enum.append(' VkApplicationInfo** ppAppInfo = (VkApplicationInfo**) &pVkInstanceCreateInfo->pAppInfo;') |
| 789 | pid_enum.append(' (*ppAppInfo)->pAppName = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkInstanceCreateInfo->pAppInfo->pAppName);') |
| 790 | pid_enum.append(' (*ppAppInfo)->pEngineName = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkInstanceCreateInfo->pAppInfo->pEngineName);') |
| 791 | |
| 792 | pid_enum.append(' if (pVkInstanceCreateInfo->extensionCount > 0)') |
| 793 | pid_enum.append(' {') |
| 794 | pid_enum.append(' pVkInstanceCreateInfo->ppEnabledExtensionNames = (const char *const*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkInstanceCreateInfo->ppEnabledExtensionNames);') |
| 795 | pid_enum.append(' pNames = (const char**)pVkInstanceCreateInfo->ppEnabledExtensionNames;') |
| 796 | pid_enum.append(' for (i = 0; i < pVkInstanceCreateInfo->extensionCount; i++)') |
| 797 | pid_enum.append(' {') |
| 798 | pid_enum.append(' pNames[i] = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pVkInstanceCreateInfo->ppEnabledExtensionNames[i]));') |
| 799 | pid_enum.append(' }') |
| 800 | pid_enum.append(' }') |
| 801 | pid_enum.append(' VkLayerCreateInfo *pNext = ( VkLayerCreateInfo *) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkInstanceCreateInfo->pNext);') |
| 802 | pid_enum.append(' while (pNext != NULL)') |
| 803 | pid_enum.append(' {') |
| 804 | pid_enum.append(' if ((pNext->sType == VK_STRUCTURE_TYPE_LAYER_CREATE_INFO) && pNext->layerCount > 0)') |
| 805 | pid_enum.append(' {') |
| 806 | pid_enum.append(' pNext->ppActiveLayerNames = (const char**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pNext->ppActiveLayerNames));') |
| 807 | pid_enum.append(' pNames = (const char**)pNext->ppActiveLayerNames;') |
| 808 | pid_enum.append(' for (i = 0; i < pNext->layerCount; i++)') |
| 809 | pid_enum.append(' {') |
| 810 | pid_enum.append(' pNames[i] = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pNext->ppActiveLayerNames[i]));') |
| 811 | pid_enum.append(' }') |
| 812 | pid_enum.append(' }') |
| 813 | pid_enum.append(' pNext = ( VkLayerCreateInfo *) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);') |
| 814 | pid_enum.append(' }') |
| 815 | pid_enum.append(' }\n') |
| 816 | pid_enum.append(' return pVkInstanceCreateInfo;') |
| 817 | pid_enum.append('}\n') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 818 | pid_enum.append('static VkDeviceCreateInfo* interpret_VkDeviceCreateInfo(glv_trace_packet_header* pHeader, intptr_t ptr_variable)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 819 | pid_enum.append('{') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 820 | pid_enum.append(' VkDeviceCreateInfo* pVkDeviceCreateInfo = (VkDeviceCreateInfo*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)ptr_variable);\n') |
| 821 | pid_enum.append(' if (pVkDeviceCreateInfo != NULL)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 822 | pid_enum.append(' {') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 823 | pid_enum.append(' uint32_t i;') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 824 | pid_enum.append(' const char** pNames;') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 825 | pid_enum.append(' pVkDeviceCreateInfo->pRequestedQueues = (const VkDeviceQueueCreateInfo *)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkDeviceCreateInfo->pRequestedQueues);\n') |
| 826 | pid_enum.append(' if (pVkDeviceCreateInfo->extensionCount > 0)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 827 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 828 | pid_enum.append(' pVkDeviceCreateInfo->ppEnabledExtensionNames = (const char *const*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkDeviceCreateInfo->ppEnabledExtensionNames);') |
| 829 | pid_enum.append(' pNames = (const char**)pVkDeviceCreateInfo->ppEnabledExtensionNames;') |
| 830 | pid_enum.append(' for (i = 0; i < pVkDeviceCreateInfo->extensionCount; i++)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 831 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 832 | pid_enum.append(' pNames[i] = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pVkDeviceCreateInfo->ppEnabledExtensionNames[i]));') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 833 | pid_enum.append(' }') |
| 834 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 835 | pid_enum.append(' VkLayerCreateInfo *pNext = ( VkLayerCreateInfo *) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkDeviceCreateInfo->pNext);') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 836 | pid_enum.append(' while (pNext != NULL)') |
| 837 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 838 | pid_enum.append(' if ((pNext->sType == VK_STRUCTURE_TYPE_LAYER_CREATE_INFO) && pNext->layerCount > 0)') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 839 | pid_enum.append(' {') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 840 | pid_enum.append(' pNext->ppActiveLayerNames = (const char**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pNext->ppActiveLayerNames));') |
| 841 | pid_enum.append(' pNames = (const char**)pNext->ppActiveLayerNames;') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 842 | pid_enum.append(' for (i = 0; i < pNext->layerCount; i++)') |
| 843 | pid_enum.append(' {') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 844 | pid_enum.append(' pNames[i] = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pNext->ppActiveLayerNames[i]));') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 845 | pid_enum.append(' }') |
| 846 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 847 | pid_enum.append(' pNext = ( VkLayerCreateInfo *) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 848 | pid_enum.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 849 | pid_enum.append(' }\n') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 850 | pid_enum.append(' return pVkDeviceCreateInfo;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 851 | pid_enum.append('}\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 852 | pid_enum.append('static void interpret_pipeline_shader(glv_trace_packet_header* pHeader, VkPipelineShader* pShader)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 853 | pid_enum.append('{') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 854 | pid_enum.append(' if (pShader != NULL)') |
| 855 | pid_enum.append(' {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 856 | pid_enum.append(' // constant buffers') |
| 857 | pid_enum.append(' if (pShader->linkConstBufferCount > 0)') |
| 858 | pid_enum.append(' {') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 859 | pid_enum.append(' uint32_t i;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 860 | pid_enum.append(' pShader->pLinkConstBufferInfo = (const VkLinkConstBuffer*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pShader->pLinkConstBufferInfo);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 861 | pid_enum.append(' for (i = 0; i < pShader->linkConstBufferCount; i++)') |
| 862 | pid_enum.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 863 | pid_enum.append(' VkLinkConstBuffer* pBuffer = (VkLinkConstBuffer*)pShader->pLinkConstBufferInfo;') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 864 | pid_enum.append(' pBuffer[i].pBufferData = (const void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pShader->pLinkConstBufferInfo[i].pBufferData);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 865 | pid_enum.append(' }') |
| 866 | pid_enum.append(' }') |
| 867 | pid_enum.append(' }') |
| 868 | pid_enum.append('}\n') |
| 869 | pid_enum.append('//=============================================================================') |
| 870 | return "\n".join(pid_enum) |
| 871 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 872 | # Interpret functions used on replay to read in packets and interpret their contents |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 873 | # This code gets generated into glv_vk_vk_structs.h file |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 874 | def _generate_interp_funcs(self): |
| 875 | # Custom txt for given function and parameter. First check if param is NULL, then insert txt if not |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 876 | # TODO : This code is now too large and complex, need to make codegen smarter for pointers embedded in struct params to handle those cases automatically |
| Jon Ashburn | a80335f | 2015-04-15 18:17:34 -0600 | [diff] [blame^] | 877 | custom_case_dict = { 'CreateShader' : {'param': 'pCreateInfo', 'txt': ['VkShaderCreateInfo* pInfo = (VkShaderCreateInfo*)pPacket->pCreateInfo;\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 878 | 'pInfo->pCode = glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pCode);']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 879 | 'CreateDynamicViewportState' : {'param': 'pCreateInfo', 'txt': ['VkDynamicVpStateCreateInfo* pInfo = (VkDynamicVpStateCreateInfo*)pPacket->pCreateInfo;\n', |
| 880 | 'pInfo->pViewports = (VkViewport*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pViewports);\n', |
| 881 | 'pInfo->pScissors = (VkRect*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pScissors);']}, |
| 882 | 'CreateFramebuffer' : {'param': 'pCreateInfo', 'txt': ['VkFramebufferCreateInfo* pInfo = (VkFramebufferCreateInfo*)pPacket->pCreateInfo;\n', |
| 883 | 'pInfo->pColorAttachments = (VkColorAttachmentBindInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorAttachments);\n', |
| 884 | 'pInfo->pDepthStencilAttachment = (VkDepthStencilBindInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pDepthStencilAttachment);\n']}, |
| 885 | 'CreateRenderPass' : {'param': 'pCreateInfo', 'txt': ['VkRenderPassCreateInfo* pInfo = (VkRenderPassCreateInfo*)pPacket->pCreateInfo;\n', |
| Jon Ashburn | 4e063af | 2015-04-15 15:45:22 -0600 | [diff] [blame] | 886 | 'pInfo->pColorLayouts = (VkImageLayout*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorLayouts);\n', |
| 887 | 'pInfo->pColorFormats = (VkFormat*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorFormats);\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 888 | 'pInfo->pColorLoadOps = (VkAttachmentLoadOp*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorLoadOps);\n', |
| 889 | 'pInfo->pColorStoreOps = (VkAttachmentStoreOp*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorStoreOps);\n', |
| 890 | 'pInfo->pColorLoadClearValues = (VkClearColor*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorLoadClearValues);\n']}, |
| 891 | 'CreateDescriptorPool' : {'param': 'pCreateInfo', 'txt': ['VkDescriptorPoolCreateInfo* pInfo = (VkDescriptorPoolCreateInfo*)pPacket->pCreateInfo;\n', |
| 892 | 'pInfo->pTypeCount = (VkDescriptorTypeCount*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pTypeCount);\n']}, |
| 893 | 'CmdWaitEvents' : {'param': 'pWaitInfo', 'txt': ['VkEventWaitInfo* pInfo = (VkEventWaitInfo*)pPacket->pWaitInfo;\n', |
| 894 | 'pInfo->pEvents = (VkEvent*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pWaitInfo->pEvents);\n', |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 895 | 'pInfo->ppMemBarriers = (const void**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pWaitInfo->ppMemBarriers);\n', |
| 896 | 'uint32_t i;\n', |
| 897 | 'for (i = 0; i < pInfo->memBarrierCount; i++) {\n', |
| 898 | ' void** ppLocalMemBarriers = (void**)&pInfo->ppMemBarriers[i];\n', |
| 899 | ' *ppLocalMemBarriers = (void*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pInfo->ppMemBarriers[i]);\n', |
| 900 | '}']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 901 | 'CmdPipelineBarrier' : {'param': 'pBarrier', 'txt': ['VkPipelineBarrier* pBarrier = (VkPipelineBarrier*)pPacket->pBarrier;\n', |
| 902 | 'pBarrier->pEvents = (VkPipeEvent*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pBarrier->pEvents);\n', |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 903 | 'pBarrier->ppMemBarriers = (const void**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pBarrier->ppMemBarriers);\n', |
| 904 | 'uint32_t i;\n', |
| 905 | 'for (i = 0; i < pBarrier->memBarrierCount; i++) {\n', |
| 906 | ' void** ppLocalMemBarriers = (void**)&pBarrier->ppMemBarriers[i];\n', |
| 907 | ' *ppLocalMemBarriers = (void*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pBarrier->ppMemBarriers[i]);\n', |
| 908 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 909 | 'CreateDescriptorSetLayout' : {'param': 'pSetLayoutInfoList', 'txt': ['if (pPacket->pSetLayoutInfoList->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO) {\n', |
| 910 | ' // need to make a non-const pointer to the pointer so that we can properly change the original pointer to the interpretted one\n', |
| 911 | ' void** ppNextVoidPtr = (void**)&(pPacket->pSetLayoutInfoList->pNext);\n', |
| 912 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pSetLayoutInfoList->pNext);\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 913 | ' VkDescriptorSetLayoutCreateInfo* pNext = (VkDescriptorSetLayoutCreateInfo*)pPacket->pSetLayoutInfoList->pNext;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 914 | ' while (NULL != pNext)\n', ' {\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 915 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 916 | ' case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 917 | ' {\n' , |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 918 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 919 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 920 | ' break;\n', |
| 921 | ' }\n', |
| 922 | ' default:\n', |
| 923 | ' {\n', |
| 924 | ' glv_LogError("Encountered an unexpected type in descriptor set layout create list.\\n");\n', |
| 925 | ' pPacket->header = NULL;\n', |
| 926 | ' pNext->pNext = NULL;\n', |
| 927 | ' }\n', |
| Jon Ashburn | 7fd7eff | 2015-02-04 10:55:47 -0700 | [diff] [blame] | 928 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 929 | ' pNext = (VkDescriptorSetLayoutCreateInfo*)pNext->pNext;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 930 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 931 | '} else {\n', |
| 932 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 933 | ' glv_LogError("CreateDescriptorSetLayout must have LayoutInfoList stype of VK_STRCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO\\n");\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 934 | ' pPacket->header = NULL;\n', |
| Jon Ashburn | 7fd7eff | 2015-02-04 10:55:47 -0700 | [diff] [blame] | 935 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 936 | 'BeginCommandBuffer' : {'param': 'pBeginInfo', 'txt': ['if (pPacket->pBeginInfo->sType == VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO) {\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 937 | ' // need to make a non-const pointer to the pointer so that we can properly change the original pointer to the interpretted one\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 938 | ' VkCmdBufferGraphicsBeginInfo** ppNext = (VkCmdBufferGraphicsBeginInfo**)&(pPacket->pBeginInfo->pNext);\n', |
| 939 | ' *ppNext = (VkCmdBufferGraphicsBeginInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pBeginInfo->pNext);\n', |
| 940 | ' VkCmdBufferGraphicsBeginInfo* pNext = *ppNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 941 | ' while (NULL != pNext)\n', ' {\n', |
| 942 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 943 | ' case VK_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 944 | ' {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 945 | ' ppNext = (VkCmdBufferGraphicsBeginInfo**) &pNext->pNext;\n', |
| 946 | ' *ppNext = (VkCmdBufferGraphicsBeginInfo*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 947 | ' break;\n', |
| 948 | ' }\n', |
| 949 | ' default:\n', |
| 950 | ' {\n', |
| 951 | ' glv_LogError("Encountered an unexpected type in begin command buffer list.\\n");\n', |
| 952 | ' pPacket->header = NULL;\n', |
| 953 | ' pNext->pNext = NULL;\n', |
| 954 | ' }\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 955 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 956 | ' pNext = (VkCmdBufferGraphicsBeginInfo*)pNext->pNext;\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 957 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 958 | '} else {\n', |
| 959 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 960 | ' glv_LogError("BeginCommandBuffer must have BeginInfo stype of VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO.\\n");\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 961 | ' pPacket->header = NULL;\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 962 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 963 | 'AllocMemory' : {'param': 'pAllocInfo', 'txt': ['if (pPacket->pAllocInfo->sType == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO) {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 964 | ' VkMemoryAllocInfo** ppNext = (VkMemoryAllocInfo**) &(pPacket->pAllocInfo->pNext);\n', |
| 965 | ' *ppNext = (VkMemoryAllocInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pAllocInfo->pNext);\n', |
| 966 | ' VkMemoryAllocInfo* pNext = (VkMemoryAllocInfo*) *ppNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 967 | ' while (NULL != pNext)\n', ' {\n', |
| 968 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 969 | ' case VK_STRUCTURE_TYPE_MEMORY_ALLOC_BUFFER_INFO:\n', |
| 970 | ' case VK_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 971 | ' {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 972 | ' ppNext = (VkMemoryAllocInfo **) &(pNext->pNext);\n', |
| 973 | ' *ppNext = (VkMemoryAllocInfo*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 974 | ' break;\n', |
| 975 | ' }\n', |
| 976 | ' default:\n', |
| 977 | ' {\n', |
| 978 | ' glv_LogError("Encountered an unexpected type alloc memory list.\\n");\n', |
| 979 | ' pPacket->header = NULL;\n', |
| 980 | ' pNext->pNext = NULL;\n', |
| 981 | ' }\n', |
| Jon Ashburn | 3039e9c | 2015-02-03 07:33:48 -0700 | [diff] [blame] | 982 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 983 | ' pNext = (VkMemoryAllocInfo*)pNext->pNext;\n', |
| Jon Ashburn | 3039e9c | 2015-02-03 07:33:48 -0700 | [diff] [blame] | 984 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 985 | '} else {\n', |
| 986 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 987 | ' glv_LogError("AllocMemory must have AllocInfo stype of VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO.\\n");\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 988 | ' pPacket->header = NULL;\n', |
| Jon Ashburn | 3039e9c | 2015-02-03 07:33:48 -0700 | [diff] [blame] | 989 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 990 | 'CreateGraphicsPipeline' : {'param': 'pCreateInfo', 'txt': ['if (pPacket->pCreateInfo->sType == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO) {\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 991 | ' // need to make a non-const pointer to the pointer so that we can properly change the original pointer to the interpretted one\n', |
| 992 | ' void** ppNextVoidPtr = (void**)&pPacket->pCreateInfo->pNext;\n', |
| 993 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pNext);\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 994 | ' VkPipelineShaderStageCreateInfo* pNext = (VkPipelineShaderStageCreateInfo*)pPacket->pCreateInfo->pNext;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 995 | ' while ((NULL != pNext) && (VK_NULL_HANDLE != pNext))\n', '{\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 996 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 997 | ' case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO:\n', |
| 998 | ' case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO:\n', |
| 999 | ' case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO:\n', |
| 1000 | ' case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO:\n', |
| 1001 | ' case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO:\n', |
| 1002 | ' case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1003 | ' {\n', |
| 1004 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 1005 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| 1006 | ' break;\n', |
| 1007 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1008 | ' case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1009 | ' {\n', |
| 1010 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1011 | ' VkPipelineCbStateCreateInfo *pCb = (VkPipelineCbStateCreateInfo *) pNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1012 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1013 | ' pCb->pAttachments = (VkPipelineCbAttachmentState*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pCb->pAttachments);\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1014 | ' break;\n', |
| 1015 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1016 | ' case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1017 | ' {\n', |
| 1018 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 1019 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| 1020 | ' interpret_pipeline_shader(pHeader, &pNext->shader);\n', |
| 1021 | ' break;\n', |
| 1022 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1023 | ' case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1024 | ' {\n', |
| 1025 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1026 | ' VkPipelineVertexInputCreateInfo *pVi = (VkPipelineVertexInputCreateInfo *) pNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1027 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1028 | ' pVi->pVertexBindingDescriptions = (VkVertexInputBindingDescription*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVi->pVertexBindingDescriptions);\n', |
| 1029 | ' pVi->pVertexAttributeDescriptions = (VkVertexInputAttributeDescription*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVi->pVertexAttributeDescriptions);\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1030 | ' break;\n', |
| 1031 | ' }\n', |
| 1032 | ' default:\n', |
| 1033 | ' {\n', |
| 1034 | ' glv_LogError("Encountered an unexpected type in pipeline state list.\\n");\n', |
| 1035 | ' pPacket->header = NULL;\n', |
| 1036 | ' pNext->pNext = NULL;\n', |
| 1037 | ' }\n', |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1038 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1039 | ' pNext = (VkPipelineShaderStageCreateInfo*)pNext->pNext;\n', |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1040 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1041 | '} else {\n', |
| 1042 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1043 | ' glv_LogError("CreateGraphicsPipeline must have CreateInfo stype of VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO.\\n");\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1044 | ' pPacket->header = NULL;\n', |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1045 | '}']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1046 | 'CreateComputePipeline' : {'param': 'pCreateInfo', 'txt': ['interpret_pipeline_shader(pHeader, (VkPipelineShader*)(&pPacket->pCreateInfo->cs));']}} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1047 | if_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1048 | if_body.append('typedef struct struct_vkApiVersion {') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1049 | if_body.append(' glv_trace_packet_header* header;') |
| 1050 | if_body.append(' uint32_t version;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1051 | if_body.append('} struct_vkApiVersion;\n') |
| 1052 | if_body.append('static struct_vkApiVersion* interpret_body_as_vkApiVersion(glv_trace_packet_header* pHeader, BOOL check_version)') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1053 | if_body.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1054 | if_body.append(' struct_vkApiVersion* pPacket = (struct_vkApiVersion*)pHeader->pBody;') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1055 | if_body.append(' pPacket->header = pHeader;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1056 | if_body.append(' if (check_version && pPacket->version != VK_API_VERSION)') |
| 1057 | if_body.append(' glv_LogError("Trace file from older VK version 0x%x, vk replayer built from version 0x%x, replayer may fail\\n", pPacket->version, VK_API_VERSION);') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1058 | if_body.append(' return pPacket;') |
| 1059 | if_body.append('}\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1060 | for proto in self.protos: |
| 1061 | if 'Wsi' not in proto.name and 'Dbg' not in proto.name: |
| 1062 | if 'UnmapMemory' == proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1063 | proto.params.append(vulkan.Param("void*", "pData")) |
| 1064 | if_body.append('typedef struct struct_vk%s {' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1065 | if_body.append(' glv_trace_packet_header* header;') |
| 1066 | for p in proto.params: |
| 1067 | if '[4]' in p.ty: |
| 1068 | if_body.append(' %s %s[4];' % (p.ty.strip('[4]'), p.name)) |
| 1069 | else: |
| 1070 | if_body.append(' %s %s;' % (p.ty, p.name)) |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1071 | if 'void' != proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1072 | if_body.append(' %s result;' % proto.ret) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1073 | if_body.append('} struct_vk%s;\n' % proto.name) |
| 1074 | if_body.append('static struct_vk%s* interpret_body_as_vk%s(glv_trace_packet_header* pHeader)' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1075 | if_body.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1076 | if_body.append(' struct_vk%s* pPacket = (struct_vk%s*)pHeader->pBody;' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1077 | if_body.append(' pPacket->header = pHeader;') |
| 1078 | for p in proto.params: |
| 1079 | if '*' in p.ty: |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 1080 | if 'DeviceCreateInfo' in p.ty: |
| 1081 | if_body.append(' pPacket->%s = interpret_VkDeviceCreateInfo(pHeader, (intptr_t)pPacket->%s);' % (p.name, p.name)) |
| Jon Ashburn | a80335f | 2015-04-15 18:17:34 -0600 | [diff] [blame^] | 1082 | elif 'InstanceCreateInfo' in p.ty: |
| 1083 | if_body.append(' pPacket->%s = interpret_VkInstanceCreateInfo(pHeader, (intptr_t)pPacket->%s);' % (p.name, p.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1084 | else: |
| 1085 | if_body.append(' pPacket->%s = (%s)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->%s);' % (p.name, p.ty, p.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 1086 | # TODO : Generalize this custom code to kill dict data struct above. |
| 1087 | # Really the point of this block is to catch params w/ embedded ptrs to structs and chains of structs |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1088 | if proto.name in custom_case_dict and p.name == custom_case_dict[proto.name]['param']: |
| 1089 | if_body.append(' if (pPacket->%s != NULL)' % custom_case_dict[proto.name]['param']) |
| 1090 | if_body.append(' {') |
| 1091 | if_body.append(' %s' % " ".join(custom_case_dict[proto.name]['txt'])) |
| 1092 | if_body.append(' }') |
| 1093 | if_body.append(' return pPacket;') |
| 1094 | if_body.append('}\n') |
| 1095 | return "\n".join(if_body) |
| 1096 | |
| 1097 | def _generate_interp_funcs_ext(self, func_class='Wsi'): |
| 1098 | if_body = [] |
| 1099 | for proto in self.protos: |
| 1100 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1101 | if_body.append('typedef struct struct_vk%s {' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1102 | if_body.append(' glv_trace_packet_header* pHeader;') |
| 1103 | for p in proto.params: |
| 1104 | if_body.append(' %s %s;' % (p.ty, p.name)) |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1105 | if 'void' != proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1106 | if_body.append(' %s result;' % proto.ret) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1107 | if_body.append('} struct_vk%s;\n' % proto.name) |
| 1108 | if_body.append('static struct_vk%s* interpret_body_as_vk%s(glv_trace_packet_header* pHeader)' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1109 | if_body.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1110 | if_body.append(' struct_vk%s* pPacket = (struct_vk%s*)pHeader->pBody;' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1111 | if_body.append(' pPacket->pHeader = pHeader;') |
| 1112 | for p in proto.params: |
| 1113 | if '*' in p.ty: |
| 1114 | if_body.append(' pPacket->%s = (%s)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->%s);' % (p.name, p.ty, p.name)) |
| 1115 | if_body.append(' return pPacket;') |
| 1116 | if_body.append('}\n') |
| 1117 | return "\n".join(if_body) |
| 1118 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1119 | def _generate_replay_func_ptrs(self): |
| 1120 | xf_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1121 | xf_body.append('struct vkFuncs {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1122 | xf_body.append(' void init_funcs(void * libHandle);') |
| 1123 | xf_body.append(' void *m_libHandle;\n') |
| 1124 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1125 | xf_body.append(' typedef %s( VKAPI * type_vk%s)(' % (proto.ret, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1126 | for p in proto.params: |
| 1127 | if '[4]' in p.ty: |
| 1128 | xf_body.append(' %s %s[4],' % (p.ty.strip('[4]'), p.name)) |
| 1129 | else: |
| 1130 | xf_body.append(' %s %s,' % (p.ty, p.name)) |
| 1131 | xf_body[-1] = xf_body[-1].replace(',', ');') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1132 | xf_body.append(' type_vk%s real_vk%s;' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1133 | xf_body.append('};') |
| 1134 | return "\n".join(xf_body) |
| 1135 | |
| 1136 | def _map_decl(self, type1, type2, name): |
| 1137 | return ' std::map<%s, %s> %s;' % (type1, type2, name) |
| 1138 | |
| 1139 | def _add_to_map_decl(self, type1, type2, name): |
| 1140 | txt = ' void add_to_map(%s* pTraceVal, %s* pReplayVal)\n {\n' % (type1, type2) |
| 1141 | txt += ' assert(pTraceVal != NULL);\n' |
| 1142 | txt += ' assert(pReplayVal != NULL);\n' |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1143 | txt += ' %s[*pTraceVal] = *pReplayVal;\n }\n' % name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1144 | return txt |
| 1145 | |
| 1146 | def _rm_from_map_decl(self, ty, name): |
| 1147 | txt = ' void rm_from_map(const %s& key)\n {\n' % (ty) |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1148 | txt += ' %s.erase(key);\n }\n' % name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1149 | return txt |
| 1150 | |
| 1151 | def _remap_decl(self, ty, name): |
| 1152 | txt = ' %s remap(const %s& value)\n {\n' % (ty, ty) |
| 1153 | txt += ' std::map<%s, %s>::const_iterator q = %s.find(value);\n' % (ty, ty, name) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1154 | txt += ' return (q == %s.end()) ? VK_NULL_HANDLE : q->second;\n }\n' % name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1155 | return txt |
| 1156 | |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1157 | def _generate_replay_objMemory_funcs(self): |
| 1158 | rof_body = [] |
| 1159 | # Custom code for memory mapping functions for app writes into mapped memory |
| 1160 | rof_body.append('// memory mapping functions for app writes into mapped memory') |
| 1161 | rof_body.append(' bool isPendingAlloc()') |
| 1162 | rof_body.append(' {') |
| 1163 | rof_body.append(' return m_pendingAlloc;') |
| 1164 | rof_body.append(' }') |
| 1165 | rof_body.append('') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1166 | rof_body.append(' void setAllocInfo(const VkMemoryAllocInfo *info, const bool pending)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1167 | rof_body.append(' {') |
| 1168 | rof_body.append(' m_pendingAlloc = pending;') |
| 1169 | rof_body.append(' m_allocInfo = *info;') |
| 1170 | rof_body.append(' }') |
| 1171 | rof_body.append('') |
| 1172 | rof_body.append(' void setMemoryDataAddr(void *pBuf)') |
| 1173 | rof_body.append(' {') |
| 1174 | rof_body.append(' if (m_mapRange.empty())') |
| 1175 | rof_body.append(' {') |
| 1176 | rof_body.append(' glv_LogError("gpuMemory::setMemoryDataAddr() m_mapRange is empty\\n");') |
| 1177 | rof_body.append(' return;') |
| 1178 | rof_body.append(' }') |
| 1179 | rof_body.append(' MapRange mr = m_mapRange.back();') |
| 1180 | rof_body.append(' if (mr.pData != NULL)') |
| 1181 | rof_body.append(' glv_LogWarn("gpuMemory::setMemoryDataAddr() data already mapped overwrite old mapping\\n");') |
| 1182 | rof_body.append(' else if (pBuf == NULL)') |
| 1183 | rof_body.append(' glv_LogWarn("gpuMemory::setMemoryDataAddr() adding NULL pointer\\n");') |
| 1184 | rof_body.append(' mr.pData = pBuf;') |
| 1185 | rof_body.append(' }') |
| 1186 | rof_body.append('') |
| 1187 | rof_body.append(' void setMemoryMapRange(void *pBuf, const size_t size, const size_t offset, const bool pending)') |
| 1188 | rof_body.append(' {') |
| 1189 | rof_body.append(' MapRange mr;') |
| 1190 | rof_body.append(' mr.pData = pBuf;') |
| 1191 | rof_body.append(' mr.size = size;') |
| 1192 | rof_body.append(' mr.offset = offset;') |
| 1193 | rof_body.append(' mr.pending = pending;') |
| 1194 | rof_body.append(' m_mapRange.push_back(mr);') |
| 1195 | rof_body.append(' }') |
| 1196 | rof_body.append('') |
| 1197 | rof_body.append(' void copyMappingData(const void* pSrcData)') |
| 1198 | rof_body.append(' {') |
| 1199 | rof_body.append(' if (m_mapRange.empty())') |
| 1200 | rof_body.append(' {') |
| 1201 | rof_body.append(' glv_LogError("gpuMemory::copyMappingData() m_mapRange is empty\\n");') |
| 1202 | rof_body.append(' return;') |
| 1203 | rof_body.append(' }') |
| 1204 | rof_body.append(' MapRange mr = m_mapRange.back();') |
| 1205 | rof_body.append(' if (!pSrcData || !mr.pData)') |
| 1206 | rof_body.append(' {') |
| 1207 | rof_body.append(' if (!pSrcData)') |
| 1208 | rof_body.append(' glv_LogError("gpuMemory::copyMappingData() null src pointer\\n");') |
| 1209 | rof_body.append(' else') |
| 1210 | rof_body.append(' glv_LogError("gpuMemory::copyMappingData() null dest pointer size=%u\\n", m_allocInfo.allocationSize);') |
| 1211 | rof_body.append(' m_mapRange.pop_back();') |
| 1212 | rof_body.append(' return;') |
| 1213 | rof_body.append(' }') |
| 1214 | rof_body.append(' memcpy(mr.pData, pSrcData, m_allocInfo.allocationSize);') |
| 1215 | rof_body.append(' if (!mr.pending)') |
| 1216 | rof_body.append(' m_mapRange.pop_back();') |
| 1217 | rof_body.append(' }') |
| 1218 | rof_body.append('') |
| 1219 | rof_body.append(' size_t getMemoryMapSize()') |
| 1220 | rof_body.append(' {') |
| 1221 | rof_body.append(' return (!m_mapRange.empty()) ? m_mapRange.back().size : 0;') |
| 1222 | rof_body.append(' }\n') |
| 1223 | return "\n".join(rof_body) |
| 1224 | |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1225 | def _generate_replay_objmapper_class(self): |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1226 | # Create dict mapping member var names to VK type (i.e. 'm_imageViews' : 'VkImage_VIEW') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1227 | obj_map_dict = {} |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1228 | for ty in vulkan.object_type_list: |
| 1229 | if ty in vulkan.object_parent_list: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1230 | continue |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1231 | if (ty.startswith('Vk')): |
| 1232 | mem_var = ty.replace('Vk', '').lower() |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1233 | mem_var_list = mem_var.split('_') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1234 | mem_var = 'm_%s%ss' % (mem_var_list[0], "".join([m.title() for m in mem_var_list[1:]])) |
| 1235 | obj_map_dict[mem_var] = ty |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1236 | rc_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1237 | rc_body.append('typedef struct _VKAllocInfo {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1238 | rc_body.append(' VkGpuSize size;') |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 1239 | rc_body.append(' void *pData;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1240 | rc_body.append('} VKAllocInfo;') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1241 | rc_body.append('') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1242 | rc_body.append('class objMemory {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1243 | rc_body.append('public:') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1244 | rc_body.append(' objMemory() : m_numAllocations(0), m_pMemReqs(NULL) {}') |
| 1245 | rc_body.append(' ~objMemory() { free(m_pMemReqs);}') |
| 1246 | rc_body.append(' void setCount(const uint32_t num)') |
| 1247 | rc_body.append(' {') |
| 1248 | rc_body.append(' m_numAllocations = num;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1249 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1250 | rc_body.append(' void setReqs(const VkMemoryRequirements *pReqs, const uint32_t num)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1251 | rc_body.append(' {') |
| 1252 | rc_body.append(' if (m_numAllocations != num && m_numAllocations != 0)') |
| 1253 | rc_body.append(' glv_LogError("objMemory::setReqs, internal mismatch on number of allocations");') |
| 1254 | rc_body.append(' if (m_pMemReqs == NULL && pReqs != NULL)') |
| 1255 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1256 | rc_body.append(' m_pMemReqs = (VkMemoryRequirements *) glv_malloc(num * sizeof(VkMemoryRequirements));') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1257 | rc_body.append(' if (m_pMemReqs == NULL)') |
| 1258 | rc_body.append(' {') |
| 1259 | rc_body.append(' glv_LogError("objMemory::setReqs out of memory");') |
| 1260 | rc_body.append(' return;') |
| 1261 | rc_body.append(' }') |
| 1262 | rc_body.append(' memcpy(m_pMemReqs, pReqs, num);') |
| 1263 | rc_body.append(' }') |
| 1264 | rc_body.append(' }\n') |
| 1265 | rc_body.append('private:') |
| 1266 | rc_body.append(' uint32_t m_numAllocations;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1267 | rc_body.append(' VkMemoryRequirements *m_pMemReqs;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1268 | rc_body.append('};') |
| 1269 | rc_body.append('') |
| 1270 | rc_body.append('class gpuMemory {') |
| 1271 | rc_body.append('public:') |
| 1272 | rc_body.append(' gpuMemory() : m_pendingAlloc(false) {m_allocInfo.allocationSize = 0;}') |
| 1273 | rc_body.append(' ~gpuMemory() {}') |
| 1274 | rc_body.append(self._generate_replay_objMemory_funcs()) |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1275 | rc_body.append('private:') |
| 1276 | rc_body.append(' bool m_pendingAlloc;') |
| 1277 | rc_body.append(' struct MapRange {') |
| 1278 | rc_body.append(' bool pending;') |
| 1279 | rc_body.append(' size_t size;') |
| 1280 | rc_body.append(' size_t offset;') |
| 1281 | rc_body.append(' void* pData;') |
| 1282 | rc_body.append(' };') |
| 1283 | rc_body.append(' std::vector<MapRange> m_mapRange;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1284 | rc_body.append(' VkMemoryAllocInfo m_allocInfo;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1285 | rc_body.append('};') |
| 1286 | rc_body.append('') |
| 1287 | rc_body.append('typedef struct _imageObj {') |
| 1288 | rc_body.append(' objMemory imageMem;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1289 | rc_body.append(' VkImage replayImage;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1290 | rc_body.append(' } imageObj;') |
| 1291 | rc_body.append('') |
| 1292 | rc_body.append('typedef struct _bufferObj {') |
| 1293 | rc_body.append(' objMemory bufferMem;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1294 | rc_body.append(' VkBuffer replayBuffer;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1295 | rc_body.append(' } bufferObj;') |
| 1296 | rc_body.append('') |
| 1297 | rc_body.append('typedef struct _gpuMemObj {') |
| 1298 | rc_body.append(' gpuMemory *pGpuMem;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1299 | rc_body.append(' VkGpuMemory replayGpuMem;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1300 | rc_body.append(' } gpuMemObj;') |
| 1301 | rc_body.append('') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1302 | rc_body.append('class vkReplayObjMapper {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1303 | rc_body.append('public:') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1304 | rc_body.append(' vkReplayObjMapper() {}') |
| 1305 | rc_body.append(' ~vkReplayObjMapper() {}') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1306 | rc_body.append('') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1307 | rc_body.append(' bool m_adjustForGPU; // true if replay adjusts behavior based on GPU') |
| 1308 | # Code for memory objects for handling replay GPU != trace GPU object memory requirements |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1309 | rc_body.append(' void init_objMemCount(const VkBaseObject& object, const uint32_t &num)\n {') |
| 1310 | rc_body.append(' VkImage img = static_cast <VkImage> (object);') |
| 1311 | rc_body.append(' std::map<VkImage, imageObj>::const_iterator it = m_images.find(img);') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1312 | rc_body.append(' if (it != m_images.end())') |
| 1313 | rc_body.append(' {') |
| 1314 | rc_body.append(' objMemory obj = it->second.imageMem;') |
| 1315 | rc_body.append(' obj.setCount(num);') |
| 1316 | rc_body.append(' return;') |
| 1317 | rc_body.append(' }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1318 | rc_body.append(' VkBuffer buf = static_cast <VkBuffer> (object);') |
| 1319 | rc_body.append(' std::map<VkBuffer, bufferObj>::const_iterator itb = m_buffers.find(buf);') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1320 | rc_body.append(' if (itb != m_buffers.end())') |
| 1321 | rc_body.append(' {') |
| 1322 | rc_body.append(' objMemory obj = itb->second.bufferMem;') |
| 1323 | rc_body.append(' obj.setCount(num);') |
| 1324 | rc_body.append(' return;') |
| 1325 | rc_body.append(' }') |
| 1326 | rc_body.append(' return;') |
| 1327 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1328 | rc_body.append(' void init_objMemReqs(const VkBaseObject& object, const VkMemoryRequirements *pMemReqs, const unsigned int num)\n {') |
| 1329 | rc_body.append(' VkImage img = static_cast <VkImage> (object);') |
| 1330 | rc_body.append(' std::map<VkImage, imageObj>::const_iterator it = m_images.find(img);') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1331 | rc_body.append(' if (it != m_images.end())') |
| 1332 | rc_body.append(' {') |
| 1333 | rc_body.append(' objMemory obj = it->second.imageMem;') |
| 1334 | rc_body.append(' obj.setReqs(pMemReqs, num);') |
| 1335 | rc_body.append(' return;') |
| 1336 | rc_body.append(' }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1337 | rc_body.append(' VkBuffer buf = static_cast <VkBuffer> (object);') |
| 1338 | rc_body.append(' std::map<VkBuffer, bufferObj>::const_iterator itb = m_buffers.find(buf);') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1339 | rc_body.append(' if (itb != m_buffers.end())') |
| 1340 | rc_body.append(' {') |
| 1341 | rc_body.append(' objMemory obj = itb->second.bufferMem;') |
| 1342 | rc_body.append(' obj.setReqs(pMemReqs, num);') |
| 1343 | rc_body.append(' return;') |
| 1344 | rc_body.append(' }') |
| 1345 | rc_body.append(' return;') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1346 | rc_body.append(' }') |
| 1347 | rc_body.append('') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1348 | rc_body.append(' void clear_all_map_handles()\n {') |
| 1349 | for var in sorted(obj_map_dict): |
| 1350 | rc_body.append(' %s.clear();' % var) |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1351 | rc_body.append(' }\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1352 | for var in sorted(obj_map_dict): |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1353 | if obj_map_dict[var] == 'VkImage': |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1354 | rc_body.append(self._map_decl(obj_map_dict[var], 'imageObj', var)) |
| 1355 | rc_body.append(self._add_to_map_decl(obj_map_dict[var], 'imageObj', var)) |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1356 | rc_body.append(self._rm_from_map_decl(obj_map_dict[var], var)) |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1357 | rc_body.append(' VkImage remap(const VkImage& value)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1358 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1359 | rc_body.append(' std::map<VkImage, imageObj>::const_iterator q = m_images.find(value);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1360 | rc_body.append(' return (q == m_images.end()) ? VK_NULL_HANDLE : q->second.replayImage;') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1361 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1362 | elif obj_map_dict[var] == 'VkBuffer': |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1363 | rc_body.append(self._map_decl(obj_map_dict[var], 'bufferObj', var)) |
| 1364 | rc_body.append(self._add_to_map_decl(obj_map_dict[var], 'bufferObj', var)) |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1365 | rc_body.append(self._rm_from_map_decl(obj_map_dict[var], var)) |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1366 | rc_body.append(' VkBuffer remap(const VkBuffer& value)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1367 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1368 | rc_body.append(' std::map<VkBuffer, bufferObj>::const_iterator q = m_buffers.find(value);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1369 | rc_body.append(' return (q == m_buffers.end()) ? VK_NULL_HANDLE : q->second.replayBuffer;') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1370 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1371 | elif obj_map_dict[var] == 'VkGpuMemory': |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1372 | rc_body.append(self._map_decl(obj_map_dict[var], 'gpuMemObj', var)) |
| 1373 | rc_body.append(self._add_to_map_decl(obj_map_dict[var], 'gpuMemObj', var)) |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1374 | rc_body.append(self._rm_from_map_decl(obj_map_dict[var], var)) |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1375 | rc_body.append(' VkGpuMemory remap(const VkGpuMemory& value)') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1376 | rc_body.append(' {') |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1377 | rc_body.append(' std::map<VkGpuMemory, gpuMemObj>::const_iterator q = m_gpumemorys.find(value);') |
| 1378 | rc_body.append(' return (q == m_gpumemorys.end()) ? VK_NULL_HANDLE : q->second.replayGpuMem;') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1379 | rc_body.append(' }\n') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1380 | else: |
| 1381 | rc_body.append(self._map_decl(obj_map_dict[var], obj_map_dict[var], var)) |
| 1382 | rc_body.append(self._add_to_map_decl(obj_map_dict[var], obj_map_dict[var], var)) |
| 1383 | rc_body.append(self._rm_from_map_decl(obj_map_dict[var], var)) |
| 1384 | rc_body.append(self._remap_decl(obj_map_dict[var], var)) |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1385 | # VkDynamicStateObject code |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1386 | state_obj_remap_types = vulkan.object_dynamic_state_list |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1387 | rc_body.append(' VkDynamicStateObject remap(const VkDynamicStateObject& state)\n {') |
| 1388 | rc_body.append(' VkDynamicStateObject obj;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1389 | for t in state_obj_remap_types: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1390 | rc_body.append(' if ((obj = remap(static_cast <%s> (state))) != VK_NULL_HANDLE)' % t) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1391 | rc_body.append(' return obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1392 | rc_body.append(' return VK_NULL_HANDLE;\n }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1393 | rc_body.append(' void rm_from_map(const VkDynamicStateObject& state)\n {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1394 | for t in state_obj_remap_types: |
| 1395 | rc_body.append(' rm_from_map(static_cast <%s> (state));' % t) |
| 1396 | rc_body.append(' }') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1397 | rc_body.append('') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1398 | # OBJECT code |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1399 | rc_body.append(' VkObject remap(const VkObject& object)\n {') |
| 1400 | rc_body.append(' VkObject obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1401 | obj_remap_types = vulkan.object_list |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1402 | for var in obj_remap_types: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1403 | rc_body.append(' if ((obj = remap(static_cast <%s> (object))) != VK_NULL_HANDLE)' % (var)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1404 | rc_body.append(' return obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1405 | rc_body.append(' return VK_NULL_HANDLE;\n }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1406 | rc_body.append(' void rm_from_map(const VkObject & objKey)\n {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1407 | for var in obj_remap_types: |
| 1408 | rc_body.append(' rm_from_map(static_cast <%s> (objKey));' % (var)) |
| 1409 | rc_body.append(' }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame] | 1410 | rc_body.append(' VkBaseObject remap(const VkBaseObject& object)\n {') |
| 1411 | rc_body.append(' VkBaseObject obj;') |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1412 | base_obj_remap_types = ['VkDevice', 'VkQueue', 'VkGpuMemory', 'VkObject'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1413 | for t in base_obj_remap_types: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1414 | rc_body.append(' if ((obj = remap(static_cast <%s> (object))) != VK_NULL_HANDLE)' % t) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1415 | rc_body.append(' return obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1416 | rc_body.append(' return VK_NULL_HANDLE;') |
| Tony Barbour | b30dcd4 | 2015-02-02 13:21:18 -0700 | [diff] [blame] | 1417 | rc_body.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1418 | rc_body.append('};') |
| 1419 | return "\n".join(rc_body) |
| 1420 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1421 | def _generate_replay_init_funcs(self): |
| 1422 | rif_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1423 | rif_body.append('void vkFuncs::init_funcs(void * handle)\n{\n m_libHandle = handle;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1424 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1425 | rif_body.append(' real_vk%s = (type_vk%s)(glv_platform_get_library_entrypoint(handle, "vk%s"));' % (proto.name, proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1426 | rif_body.append('}') |
| 1427 | return "\n".join(rif_body) |
| 1428 | |
| 1429 | def _get_packet_param(self, t, n): |
| 1430 | # list of types that require remapping |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1431 | remap_list = vulkan.object_type_list |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1432 | param_exclude_list = ['p1', 'p2', 'pGpus', 'pDescriptorSets'] |
| 1433 | if t.strip('*').replace('const ', '') in remap_list and n not in param_exclude_list: |
| 1434 | if '*' in t: |
| 1435 | if 'const ' not in t: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1436 | return 'm_objMapper.remap(*pPacket->%s)' % (n) |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1437 | else: # TODO : Don't remap array ptrs? |
| 1438 | return 'pPacket->%s' % (n) |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1439 | return 'm_objMapper.remap(pPacket->%s)' % (n) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1440 | return 'pPacket->%s' % (n) |
| 1441 | |
| Jon Ashburn | a80335f | 2015-04-15 18:17:34 -0600 | [diff] [blame^] | 1442 | def _gen_replay_create_instance(self): |
| 1443 | ci_body = [] |
| 1444 | ci_body.append(' returnValue = manually_handle_vkCreateInstance(pPacket);') |
| 1445 | return "\n".join(ci_body) |
| 1446 | |
| Tobin Ehlis | 45bc7f8 | 2015-01-16 15:13:34 -0700 | [diff] [blame] | 1447 | def _gen_replay_enum_gpus(self): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1448 | ieg_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1449 | ieg_body.append(' returnValue = manually_handle_vkEnumerateGpus(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1450 | return "\n".join(ieg_body) |
| 1451 | |
| 1452 | def _gen_replay_get_gpu_info(self): |
| 1453 | ggi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1454 | ggi_body.append(' returnValue = manually_handle_vkGetGpuInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1455 | return "\n".join(ggi_body) |
| 1456 | |
| 1457 | def _gen_replay_create_device(self): |
| 1458 | cd_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1459 | cd_body.append(' returnValue = manually_handle_vkCreateDevice(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1460 | return "\n".join(cd_body) |
| 1461 | |
| 1462 | def _gen_replay_get_extension_support(self): |
| 1463 | ges_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1464 | ges_body.append(' returnValue = manually_handle_vkGetExtensionSupport(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1465 | return "\n".join(ges_body) |
| 1466 | |
| 1467 | def _gen_replay_queue_submit(self): |
| 1468 | qs_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1469 | qs_body.append(' returnValue = manually_handle_vkQueueSubmit(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1470 | return "\n".join(qs_body) |
| 1471 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1472 | def _gen_replay_get_object_info(self): |
| 1473 | goi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1474 | goi_body.append(' returnValue = manually_handle_vkGetObjectInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1475 | return "\n".join(goi_body) |
| 1476 | |
| 1477 | def _gen_replay_get_format_info(self): |
| 1478 | gfi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1479 | gfi_body.append(' returnValue = manually_handle_vkGetFormatInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1480 | return "\n".join(gfi_body) |
| 1481 | |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1482 | def _gen_replay_create_image(self): |
| 1483 | ci_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1484 | ci_body.append(' imageObj local_imageObj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1485 | ci_body.append(' replayResult = m_vkFuncs.real_vkCreateImage(m_objMapper.remap(pPacket->device), pPacket->pCreateInfo, &local_imageObj.replayImage);') |
| 1486 | ci_body.append(' if (replayResult == VK_SUCCESS)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1487 | ci_body.append(' {') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1488 | ci_body.append(' m_objMapper.add_to_map(pPacket->pImage, &local_imageObj);') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1489 | ci_body.append(' }') |
| 1490 | return "\n".join(ci_body) |
| 1491 | |
| 1492 | def _gen_replay_create_buffer(self): |
| 1493 | cb_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1494 | cb_body.append(' bufferObj local_bufferObj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1495 | cb_body.append(' replayResult = m_vkFuncs.real_vkCreateBuffer(m_objMapper.remap(pPacket->device), pPacket->pCreateInfo, &local_bufferObj.replayBuffer);') |
| 1496 | cb_body.append(' if (replayResult == VK_SUCCESS)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1497 | cb_body.append(' {') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1498 | cb_body.append(' m_objMapper.add_to_map(pPacket->pBuffer, &local_bufferObj);') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1499 | cb_body.append(' }') |
| 1500 | return "\n".join(cb_body) |
| 1501 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1502 | def _gen_replay_get_image_subresource_info(self): |
| 1503 | isi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1504 | isi_body.append(' returnValue = manually_handle_vkGetImageSubresourceInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1505 | return "\n".join(isi_body) |
| 1506 | |
| Tobin Ehlis | fc04b89 | 2015-01-22 12:29:31 -0700 | [diff] [blame] | 1507 | def _gen_replay_update_descriptors(self): |
| 1508 | ud_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1509 | ud_body.append(' returnValue = manually_handle_vkUpdateDescriptors(pPacket);') |
| Tobin Ehlis | 8361b56 | 2015-02-03 14:41:26 -0700 | [diff] [blame] | 1510 | return "\n".join(ud_body) |
| Tobin Ehlis | fc04b89 | 2015-01-22 12:29:31 -0700 | [diff] [blame] | 1511 | |
| 1512 | def _gen_replay_create_descriptor_set_layout(self): |
| 1513 | cdsl_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1514 | cdsl_body.append(' returnValue = manually_handle_vkCreateDescriptorSetLayout(pPacket);') |
| Tobin Ehlis | 8361b56 | 2015-02-03 14:41:26 -0700 | [diff] [blame] | 1515 | return "\n".join(cdsl_body) |
| Tobin Ehlis | fc04b89 | 2015-01-22 12:29:31 -0700 | [diff] [blame] | 1516 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1517 | def _gen_replay_create_graphics_pipeline(self): |
| 1518 | cgp_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1519 | cgp_body.append(' returnValue = manually_handle_vkCreateGraphicsPipeline(pPacket);') |
| Courtney Goeltzenleuchter | 32876a1 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1520 | return "\n".join(cgp_body) |
| 1521 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1522 | def _gen_replay_cmd_wait_events(self): |
| 1523 | cwe_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1524 | cwe_body.append(' returnValue = manually_handle_vkCmdWaitEvents(pPacket);') |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1525 | return "\n".join(cwe_body) |
| 1526 | |
| Jon Ashburn | c46fc50 | 2015-02-10 10:36:22 -0700 | [diff] [blame] | 1527 | def _gen_replay_cmd_pipeline_barrier(self): |
| 1528 | cpb_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1529 | cpb_body.append(' returnValue = manually_handle_vkCmdPipelineBarrier(pPacket);') |
| Jon Ashburn | c46fc50 | 2015-02-10 10:36:22 -0700 | [diff] [blame] | 1530 | return "\n".join(cpb_body) |
| 1531 | |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1532 | def _gen_replay_create_framebuffer(self): |
| 1533 | cf_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1534 | cf_body.append(' returnValue = manually_handle_vkCreateFramebuffer(pPacket);') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1535 | return "\n".join(cf_body) |
| 1536 | |
| 1537 | def _gen_replay_create_renderpass(self): |
| 1538 | cr_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1539 | cr_body.append(' returnValue = manually_handle_vkCreateRenderPass(pPacket);') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1540 | return "\n".join(cr_body) |
| 1541 | |
| 1542 | def _gen_replay_begin_command_buffer(self): |
| 1543 | bcb_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1544 | bcb_body.append(' returnValue = manually_handle_vkBeginCommandBuffer(pPacket);') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1545 | return "\n".join(bcb_body) |
| 1546 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1547 | def _gen_replay_store_pipeline(self): |
| 1548 | sp_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1549 | sp_body.append(' returnValue = manually_handle_vkStorePipeline(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1550 | return "\n".join(sp_body) |
| 1551 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1552 | def _gen_replay_get_multi_gpu_compatibility(self): |
| 1553 | gmgc_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1554 | gmgc_body.append(' returnValue = manually_handle_vkGetMultiGpuCompatibility(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1555 | return "\n".join(gmgc_body) |
| 1556 | |
| 1557 | def _gen_replay_destroy_object(self): |
| 1558 | do_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1559 | do_body.append(' returnValue = manually_handle_vkDestroyObject(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1560 | return "\n".join(do_body) |
| 1561 | |
| 1562 | def _gen_replay_wait_for_fences(self): |
| 1563 | wf_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1564 | wf_body.append(' returnValue = manually_handle_vkWaitForFences(pPacket);') |
| Mark Lobodzinski | ebe814d | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1565 | return "\n".join(wf_body) |
| 1566 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1567 | def _gen_replay_wsi_associate_connection(self): |
| 1568 | wac_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1569 | wac_body.append(' returnValue = manually_handle_vkWsiX11AssociateConnection(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1570 | return "\n".join(wac_body) |
| 1571 | |
| 1572 | def _gen_replay_wsi_get_msc(self): |
| 1573 | wgm_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1574 | wgm_body.append(' returnValue = manually_handle_vkWsiX11GetMSC(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1575 | return "\n".join(wgm_body) |
| 1576 | |
| 1577 | def _gen_replay_wsi_create_presentable_image(self): |
| 1578 | cpi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1579 | cpi_body.append(' returnValue = manually_handle_vkWsiX11CreatePresentableImage(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1580 | return "\n".join(cpi_body) |
| 1581 | |
| 1582 | def _gen_replay_wsi_queue_present(self): |
| 1583 | wqp_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1584 | wqp_body.append(' returnValue = manually_handle_vkWsiX11QueuePresent(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1585 | return "\n".join(wqp_body) |
| 1586 | |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1587 | def _gen_replay_alloc_memory(self): |
| 1588 | am_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1589 | am_body.append(' gpuMemObj local_mem;') |
| 1590 | am_body.append(' if (!m_objMapper.m_adjustForGPU)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1591 | am_body.append(' replayResult = m_vkFuncs.real_vkAllocMemory(m_objMapper.remap(pPacket->device), pPacket->pAllocInfo, &local_mem.replayGpuMem);') |
| 1592 | am_body.append(' if (replayResult == VK_SUCCESS || m_objMapper.m_adjustForGPU)') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1593 | am_body.append(' {') |
| Jon Ashburn | cce1cb5 | 2015-03-26 16:15:18 -0600 | [diff] [blame] | 1594 | am_body.append(' local_mem.pGpuMem = new (gpuMemory);') |
| 1595 | am_body.append(' if (local_mem.pGpuMem)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1596 | am_body.append(' local_mem.pGpuMem->setAllocInfo(pPacket->pAllocInfo, m_objMapper.m_adjustForGPU);') |
| 1597 | am_body.append(' m_objMapper.add_to_map(pPacket->pMem, &local_mem);') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1598 | am_body.append(' }') |
| 1599 | return "\n".join(am_body) |
| 1600 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1601 | def _gen_replay_free_memory(self): |
| 1602 | fm_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1603 | fm_body.append(' returnValue = manually_handle_vkFreeMemory(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1604 | return "\n".join(fm_body) |
| 1605 | |
| 1606 | def _gen_replay_map_memory(self): |
| 1607 | mm_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1608 | mm_body.append(' returnValue = manually_handle_vkMapMemory(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1609 | return "\n".join(mm_body) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1610 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1611 | def _gen_replay_unmap_memory(self): |
| 1612 | um_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1613 | um_body.append(' returnValue = manually_handle_vkUnmapMemory(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1614 | return "\n".join(um_body) |
| 1615 | |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1616 | def _gen_replay_pin_system_memory(self): |
| 1617 | psm_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1618 | psm_body.append(' gpuMemObj local_mem;') |
| Jon Ashburn | d4daf59 | 2015-03-27 16:23:47 -0600 | [diff] [blame] | 1619 | psm_body.append(' /* TODO do we need to skip (make pending) this call for m_adjustForGPU */') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1620 | psm_body.append(' replayResult = m_vkFuncs.real_vkPinSystemMemory(m_objMapper.remap(pPacket->device), pPacket->pSysMem, pPacket->memSize, &local_mem.replayGpuMem);') |
| 1621 | psm_body.append(' if (replayResult == VK_SUCCESS)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1622 | psm_body.append(' m_objMapper.add_to_map(pPacket->pMem, &local_mem);') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1623 | return "\n".join(psm_body) |
| 1624 | |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1625 | # I don't think this function is being generated anymore (ie, it may have been removed from VK) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1626 | def _gen_replay_bind_dynamic_memory_view(self): |
| 1627 | bdmv_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1628 | bdmv_body.append(' VK_MEMORY_VIEW_ATTACH_INFO memView;') |
| 1629 | bdmv_body.append(' memcpy(&memView, pPacket->pMemView, sizeof(VK_MEMORY_VIEW_ATTACH_INFO));') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1630 | bdmv_body.append(' memView.mem = m_objMapper.remap(pPacket->pMemView->mem);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1631 | bdmv_body.append(' m_vkFuncs.real_vkCmdBindDynamicMemoryView(m_objMapper.remap(pPacket->cmdBuffer), pPacket->pipelineBindPoint, &memView);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1632 | return "\n".join(bdmv_body) |
| 1633 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1634 | # Generate main replay case statements where actual replay API call is dispatched based on input packet data |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1635 | def _generate_replay(self): |
| 1636 | # map protos to custom functions if body is fully custom |
| Jon Ashburn | a80335f | 2015-04-15 18:17:34 -0600 | [diff] [blame^] | 1637 | custom_body_dict = {'CreateInstance': self._gen_replay_create_instance, |
| 1638 | 'EnumerateGpus': self._gen_replay_enum_gpus, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1639 | 'GetGpuInfo': self._gen_replay_get_gpu_info, |
| 1640 | 'CreateDevice': self._gen_replay_create_device, |
| 1641 | 'GetExtensionSupport': self._gen_replay_get_extension_support, |
| 1642 | 'QueueSubmit': self._gen_replay_queue_submit, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1643 | 'GetObjectInfo': self._gen_replay_get_object_info, |
| 1644 | 'GetFormatInfo': self._gen_replay_get_format_info, |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1645 | 'CreateImage': self._gen_replay_create_image, |
| 1646 | 'CreateBuffer': self._gen_replay_create_buffer, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1647 | 'GetImageSubresourceInfo': self._gen_replay_get_image_subresource_info, |
| 1648 | 'CreateGraphicsPipeline': self._gen_replay_create_graphics_pipeline, |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1649 | 'CreateFramebuffer': self._gen_replay_create_framebuffer, |
| 1650 | 'CreateRenderPass': self._gen_replay_create_renderpass, |
| 1651 | 'BeginCommandBuffer': self._gen_replay_begin_command_buffer, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1652 | 'StorePipeline': self._gen_replay_store_pipeline, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1653 | 'GetMultiGpuCompatibility': self._gen_replay_get_multi_gpu_compatibility, |
| 1654 | 'DestroyObject': self._gen_replay_destroy_object, |
| 1655 | 'WaitForFences': self._gen_replay_wait_for_fences, |
| 1656 | 'WsiX11AssociateConnection': self._gen_replay_wsi_associate_connection, |
| 1657 | 'WsiX11GetMSC': self._gen_replay_wsi_get_msc, |
| 1658 | 'WsiX11CreatePresentableImage': self._gen_replay_wsi_create_presentable_image, |
| 1659 | 'WsiX11QueuePresent': self._gen_replay_wsi_queue_present, |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1660 | 'AllocMemory': self._gen_replay_alloc_memory, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1661 | 'FreeMemory': self._gen_replay_free_memory, |
| 1662 | 'MapMemory': self._gen_replay_map_memory, |
| 1663 | 'UnmapMemory': self._gen_replay_unmap_memory, |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1664 | 'PinSystemMemory': self._gen_replay_pin_system_memory, |
| Tobin Ehlis | 8361b56 | 2015-02-03 14:41:26 -0700 | [diff] [blame] | 1665 | 'CmdBindDynamicMemoryView': self._gen_replay_bind_dynamic_memory_view, |
| 1666 | 'UpdateDescriptors': self._gen_replay_update_descriptors, |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1667 | 'CreateDescriptorSetLayout': self._gen_replay_create_descriptor_set_layout, |
| Jon Ashburn | c46fc50 | 2015-02-10 10:36:22 -0700 | [diff] [blame] | 1668 | 'CmdWaitEvents': self._gen_replay_cmd_wait_events, |
| 1669 | 'CmdPipelineBarrier': self._gen_replay_cmd_pipeline_barrier} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1670 | # Despite returning a value, don't check these funcs b/c custom code includes check already |
| Jon Ashburn | a80335f | 2015-04-15 18:17:34 -0600 | [diff] [blame^] | 1671 | custom_check_ret_val = ['CreateInstance', 'EnumerateGpus', 'GetGpuInfo', 'CreateDevice', 'GetExtensionSupport', 'QueueSubmit', 'GetObjectInfo', |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 1672 | 'GetFormatInfo', 'GetImageSubresourceInfo', 'CreateDescriptorSetLayout', 'CreateGraphicsPipeline', |
| 1673 | 'CreateFramebuffer', 'CreateRenderPass', 'BeginCommandBuffer', 'StorePipeline', 'GetMultiGpuCompatibility', |
| Peter Lohrmann | 95c369a | 2015-04-02 10:06:19 -0700 | [diff] [blame] | 1674 | 'DestroyObject', 'WaitForFences', 'FreeMemory', 'MapMemory', 'UnmapMemory', |
| 1675 | 'WsiX11AssociateConnection', 'WsiX11GetMSC', 'WsiX11CreatePresentableImage', 'WsiX11QueuePresent'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1676 | # multi-gpu Open funcs w/ list of local params to create |
| 1677 | custom_open_params = {'OpenSharedMemory': (-1,), |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1678 | 'OpenSharedSemaphore': (-1,), |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1679 | 'OpenPeerMemory': (-1,), |
| 1680 | 'OpenPeerImage': (-1, -2,)} |
| 1681 | # Functions that create views are unique from other create functions |
| Jon Ashburn | b1b63ed | 2015-02-03 11:24:08 -0700 | [diff] [blame] | 1682 | create_view_list = ['CreateBufferView', 'CreateImageView', 'CreateColorAttachmentView', 'CreateDepthStencilView', 'CreateComputePipeline'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1683 | # Functions to treat as "Create' that don't have 'Create' in the name |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1684 | special_create_list = ['LoadPipeline', 'LoadPipelineDerivative', 'AllocMemory', 'GetDeviceQueue', 'PinSystemMemory', 'AllocDescriptorSets'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1685 | # A couple funcs use do while loops |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1686 | do_while_dict = {'GetFenceStatus': 'replayResult != pPacket->result && pPacket->result == VK_SUCCESS', 'GetEventStatus': '(pPacket->result == VK_EVENT_SET || pPacket->result == VK_EVENT_RESET) && replayResult != pPacket->result'} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1687 | rbody = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1688 | rbody.append('glv_replay::GLV_REPLAY_RESULT vkReplay::replay(glv_trace_packet_header *packet)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1689 | rbody.append('{') |
| 1690 | rbody.append(' glv_replay::GLV_REPLAY_RESULT returnValue = glv_replay::GLV_REPLAY_SUCCESS;') |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 1691 | rbody.append(' VkResult replayResult = VK_ERROR_UNKNOWN;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1692 | rbody.append(' switch (packet->packet_id)') |
| 1693 | rbody.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1694 | rbody.append(' case GLV_TPI_VK_vkApiVersion:') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1695 | rbody.append(' break; // nothing to replay on the version packet') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1696 | for proto in self.protos: |
| 1697 | ret_value = False |
| 1698 | create_view = False |
| 1699 | create_func = False |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1700 | # TODO : How to handle void* return of GetProcAddr? |
| 1701 | if ('void' not in proto.ret) and (proto.name not in custom_check_ret_val): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1702 | ret_value = True |
| 1703 | if proto.name in create_view_list: |
| 1704 | create_view = True |
| 1705 | elif 'Create' in proto.name or proto.name in special_create_list: |
| 1706 | create_func = True |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1707 | rbody.append(' case GLV_TPI_VK_vk%s:' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1708 | rbody.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1709 | rbody.append(' struct_vk%s* pPacket = (struct_vk%s*)(packet->pBody);' % (proto.name, proto.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1710 | if proto.name in custom_body_dict: |
| 1711 | rbody.append(custom_body_dict[proto.name]()) |
| 1712 | else: |
| 1713 | if proto.name in custom_open_params: |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1714 | rbody.append(' VkDevice handle;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1715 | for pidx in custom_open_params[proto.name]: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1716 | rbody.append(' %s local_%s;' % (proto.params[pidx].ty.replace('const ', '').strip('*'), proto.params[pidx].name)) |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1717 | rbody.append(' handle = m_objMapper.remap(pPacket->device);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1718 | elif create_view: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1719 | rbody.append(' %s createInfo;' % (proto.params[1].ty.strip('*').replace('const ', ''))) |
| 1720 | rbody.append(' memcpy(&createInfo, pPacket->pCreateInfo, sizeof(%s));' % (proto.params[1].ty.strip('*').replace('const ', ''))) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1721 | if 'CreateComputePipeline' == proto.name: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1722 | rbody.append(' createInfo.cs.shader = m_objMapper.remap(pPacket->pCreateInfo->cs.shader);') |
| Jon Ashburn | b1b63ed | 2015-02-03 11:24:08 -0700 | [diff] [blame] | 1723 | elif 'CreateBufferView' == proto.name: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1724 | rbody.append(' createInfo.buffer = m_objMapper.remap(pPacket->pCreateInfo->buffer);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1725 | else: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1726 | rbody.append(' createInfo.image = m_objMapper.remap(pPacket->pCreateInfo->image);') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1727 | rbody.append(' %s local_%s;' % (proto.params[-1].ty.strip('*').replace('const ', ''), proto.params[-1].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1728 | elif create_func: # Declare local var to store created handle into |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1729 | rbody.append(' %s local_%s;' % (proto.params[-1].ty.strip('*').replace('const ', ''), proto.params[-1].name)) |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1730 | if 'AllocDescriptorSets' == proto.name: |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1731 | rbody.append(' %s local_%s[100];' % (proto.params[-2].ty.strip('*').replace('const ', ''), proto.params[-2].name)) |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1732 | rbody.append(' VkDescriptorSetLayout localDescSets[100];') |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1733 | rbody.append(' assert(pPacket->count <= 100);') |
| 1734 | rbody.append(' for (uint32_t i = 0; i < pPacket->count; i++)') |
| 1735 | rbody.append(' {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1736 | rbody.append(' localDescSets[i] = m_objMapper.remap(pPacket->%s[i]);' % (proto.params[-3].name)) |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1737 | rbody.append(' }') |
| 1738 | elif proto.name == 'ClearDescriptorSets': |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1739 | rbody.append(' VkDescriptorSet localDescSets[100];') |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1740 | rbody.append(' assert(pPacket->count <= 100);') |
| 1741 | rbody.append(' for (uint32_t i = 0; i < pPacket->count; i++)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1742 | rbody.append(' {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1743 | rbody.append(' localDescSets[i] = m_objMapper.remap(pPacket->%s[i]);' % (proto.params[-1].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1744 | rbody.append(' }') |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1745 | elif proto.name == 'ResetFences': |
| 1746 | rbody.append(' VkFence* fences = GLV_NEW_ARRAY(VkFence, pPacket->fenceCount);') |
| 1747 | rbody.append(' for (uint32_t i = 0; i < pPacket->fenceCount; i++)') |
| 1748 | rbody.append(' {') |
| 1749 | rbody.append(' fences[i] = m_objMapper.remap(pPacket->%s[i]);' % (proto.params[-1].name)) |
| 1750 | rbody.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1751 | elif proto.name in do_while_dict: |
| 1752 | rbody.append(' do {') |
| Jon Ashburn | ffd5f14 | 2015-02-03 13:39:05 -0700 | [diff] [blame] | 1753 | elif proto.name == 'EnumerateLayers': |
| 1754 | rbody.append(' char **bufptr = GLV_NEW_ARRAY(char *, pPacket->maxLayerCount);') |
| 1755 | rbody.append(' char **ptrLayers = (pPacket->pOutLayers == NULL) ? bufptr : (char **) pPacket->pOutLayers;') |
| 1756 | rbody.append(' for (unsigned int i = 0; i < pPacket->maxLayerCount; i++)') |
| 1757 | rbody.append(' bufptr[i] = GLV_NEW_ARRAY(char, pPacket->maxStringSize);') |
| Jon Ashburn | d698ca2 | 2015-02-12 12:37:46 -0700 | [diff] [blame] | 1758 | elif proto.name == 'DestroyInstance': |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1759 | rbody.append(' vkDbgUnregisterMsgCallback(m_objMapper.remap(pPacket->instance), g_fpDbgMsgCallback);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1760 | rr_string = ' ' |
| 1761 | if ret_value: |
| 1762 | rr_string = ' replayResult = ' |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1763 | rr_string += 'm_vkFuncs.real_vk%s(' % proto.name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1764 | for p in proto.params: |
| 1765 | # For last param of Create funcs, pass address of param |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1766 | if create_func: |
| 1767 | if p.name == proto.params[-1].name: |
| 1768 | rr_string += '&local_%s, ' % p.name |
| 1769 | elif proto.name == 'AllocDescriptorSets' and p.name == proto.params[-2].name: |
| 1770 | rr_string += 'local_%s, ' % p.name |
| 1771 | else: |
| 1772 | rr_string += '%s, ' % self._get_packet_param(p.ty, p.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1773 | else: |
| 1774 | rr_string += '%s, ' % self._get_packet_param(p.ty, p.name) |
| 1775 | rr_string = '%s);' % rr_string[:-2] |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1776 | if proto.name in custom_open_params: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1777 | rr_list = rr_string.split(', ') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1778 | rr_list[0] = rr_list[0].replace('m_objMapper.remap(pPacket->device)', 'handle') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1779 | for pidx in custom_open_params[proto.name]: |
| 1780 | rr_list[pidx] = '&local_%s' % proto.params[pidx].name |
| 1781 | rr_string = ', '.join(rr_list) |
| 1782 | rr_string += ');' |
| 1783 | elif create_view: |
| 1784 | rr_list = rr_string.split(', ') |
| 1785 | rr_list[-2] = '&createInfo' |
| 1786 | rr_list[-1] = '&local_%s);' % proto.params[-1].name |
| 1787 | rr_string = ', '.join(rr_list) |
| 1788 | # this is a sneaky shortcut to use generic create code below to add_to_map |
| 1789 | create_func = True |
| Jon Ashburn | ffd5f14 | 2015-02-03 13:39:05 -0700 | [diff] [blame] | 1790 | elif proto.name == 'EnumerateLayers': |
| 1791 | rr_string = rr_string.replace('pPacket->pOutLayers', 'ptrLayers') |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1792 | elif proto.name == 'ClearDescriptorSets': |
| 1793 | rr_string = rr_string.replace('pPacket->pDescriptorSets', 'localDescSets') |
| 1794 | elif proto.name == 'AllocDescriptorSets': |
| 1795 | rr_string = rr_string.replace('pPacket->pSetLayouts', 'localDescSets') |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1796 | elif proto.name == 'ResetFences': |
| 1797 | rr_string = rr_string.replace('m_objMapper.remap(*pPacket->pFences)', 'fences') |
| 1798 | |
| 1799 | # insert the real_*(..) call |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1800 | rbody.append(rr_string) |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1801 | |
| 1802 | # handle return values or anything that needs to happen after the real_*(..) call |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1803 | if 'DestroyDevice' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1804 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1805 | rbody.append(' {') |
| Peter Lohrmann | 53e8924 | 2015-02-27 15:35:15 -0800 | [diff] [blame] | 1806 | rbody.append(' m_pCBDump = NULL;') |
| 1807 | rbody.append(' m_pDSDump = NULL;') |
| Peter Lohrmann | caf39d5 | 2015-03-24 17:19:24 -0700 | [diff] [blame] | 1808 | rbody.append(' m_pGlvSnapshotPrint = NULL;') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1809 | rbody.append(' m_objMapper.rm_from_map(pPacket->device);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1810 | rbody.append(' m_display->m_initedVK = false;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1811 | rbody.append(' }') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1812 | if 'DestroyInstance' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1813 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1814 | rbody.append(' {') |
| Jon Ashburn | 6f58a16 | 2015-02-03 09:17:12 -0700 | [diff] [blame] | 1815 | rbody.append(' // TODO need to handle multiple instances and only clearing maps within an instance.') |
| 1816 | rbody.append(' // TODO this only works with a single instance used at any given time.') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1817 | rbody.append(' m_objMapper.clear_all_map_handles();') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1818 | rbody.append(' }') |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1819 | elif 'AllocDescriptorSets' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1820 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1821 | rbody.append(' {') |
| 1822 | rbody.append(' for (uint32_t i = 0; i < local_pCount; i++) {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1823 | rbody.append(' m_objMapper.add_to_map(&pPacket->%s[i], &local_%s[i]);' % (proto.params[-2].name, proto.params[-2].name)) |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1824 | rbody.append(' }') |
| 1825 | rbody.append(' }') |
| Peter Lohrmann | e70d139 | 2015-04-15 12:45:51 -0700 | [diff] [blame] | 1826 | elif proto.name == 'ResetFences': |
| 1827 | rbody.append(' GLV_DELETE(fences);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1828 | elif create_func: # save handle mapping if create successful |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1829 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1830 | rbody.append(' {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1831 | rbody.append(' m_objMapper.add_to_map(pPacket->%s, &local_%s);' % (proto.params[-1].name, proto.params[-1].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1832 | if 'AllocMemory' == proto.name: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1833 | rbody.append(' m_objMapper.add_entry_to_mapData(local_%s, pPacket->pAllocInfo->allocationSize);' % (proto.params[-1].name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1834 | rbody.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1835 | elif proto.name in do_while_dict: |
| 1836 | rbody[-1] = ' %s' % rbody[-1] |
| 1837 | rbody.append(' } while (%s);' % do_while_dict[proto.name]) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1838 | rbody.append(' if (pPacket->result != VK_NOT_READY || replayResult != VK_SUCCESS)') |
| Jon Ashburn | ffd5f14 | 2015-02-03 13:39:05 -0700 | [diff] [blame] | 1839 | elif proto.name == 'EnumerateLayers': |
| 1840 | rbody.append(' for (unsigned int i = 0; i < pPacket->maxLayerCount; i++)') |
| 1841 | rbody.append(' GLV_DELETE(bufptr[i]);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1842 | if ret_value: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1843 | rbody.append(' CHECK_RETURN_VALUE(vk%s);' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1844 | if 'MsgCallback' in proto.name: |
| 1845 | rbody.pop() |
| 1846 | rbody.pop() |
| 1847 | rbody.pop() |
| 1848 | rbody.append(' // Just eating these calls as no way to restore dbg func ptr.') |
| 1849 | rbody.append(' break;') |
| 1850 | rbody.append(' }') |
| 1851 | rbody.append(' default:') |
| 1852 | rbody.append(' glv_LogWarn("Unrecognized packet_id %u, skipping\\n", packet->packet_id);') |
| 1853 | rbody.append(' returnValue = glv_replay::GLV_REPLAY_INVALID_ID;') |
| 1854 | rbody.append(' break;') |
| 1855 | rbody.append(' }') |
| 1856 | rbody.append(' return returnValue;') |
| 1857 | rbody.append('}') |
| 1858 | return "\n".join(rbody) |
| 1859 | |
| 1860 | class GlaveTraceHeader(Subcommand): |
| 1861 | def generate_header(self): |
| 1862 | header_txt = [] |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 1863 | header_txt.append('#include "glv_vk_vk_structs.h"') |
| 1864 | header_txt.append('#include "glv_vk_packet_id.h"\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1865 | header_txt.append('void AttachHooks();') |
| 1866 | header_txt.append('void DetachHooks();') |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 1867 | header_txt.append('void InitTracer(void);\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1868 | return "\n".join(header_txt) |
| 1869 | |
| 1870 | def generate_body(self): |
| 1871 | body = [self._generate_trace_func_ptrs(), |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 1872 | self._generate_trace_func_protos(), |
| 1873 | self._generate_trace_real_func_ptr_protos()] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1874 | |
| 1875 | return "\n".join(body) |
| 1876 | |
| 1877 | class GlaveTraceC(Subcommand): |
| 1878 | def generate_header(self): |
| 1879 | header_txt = [] |
| 1880 | header_txt.append('#include "glv_platform.h"') |
| 1881 | header_txt.append('#include "glv_common.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1882 | header_txt.append('#include "glvtrace_vk_helpers.h"') |
| 1883 | header_txt.append('#include "glvtrace_vk_vk.h"') |
| 1884 | header_txt.append('#include "glvtrace_vk_vkdbg.h"') |
| 1885 | header_txt.append('#include "glvtrace_vk_vkwsix11ext.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1886 | header_txt.append('#include "glv_interconnect.h"') |
| 1887 | header_txt.append('#include "glv_filelike.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1888 | header_txt.append('#include "vk_struct_size_helper.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1889 | header_txt.append('#ifdef WIN32') |
| 1890 | header_txt.append('#include "mhook/mhook-lib/mhook.h"') |
| 1891 | header_txt.append('#endif') |
| 1892 | header_txt.append('#include "glv_trace_packet_utils.h"') |
| 1893 | header_txt.append('#include <stdio.h>\n') |
| 1894 | return "\n".join(header_txt) |
| 1895 | |
| 1896 | def generate_body(self): |
| 1897 | body = [self._generate_func_ptr_assignments(), |
| 1898 | self._generate_attach_hooks(), |
| 1899 | self._generate_detach_hooks(), |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1900 | self._generate_init_funcs(), |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1901 | self._generate_trace_funcs()] |
| 1902 | |
| 1903 | return "\n".join(body) |
| 1904 | |
| 1905 | class GlavePacketID(Subcommand): |
| 1906 | def generate_header(self): |
| 1907 | header_txt = [] |
| 1908 | header_txt.append('#pragma once\n') |
| 1909 | header_txt.append('#include "glv_trace_packet_utils.h"') |
| 1910 | header_txt.append('#include "glv_trace_packet_identifiers.h"') |
| 1911 | header_txt.append('#include "glv_interconnect.h"') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 1912 | header_txt.append('#include "glv_vk_vk_structs.h"') |
| 1913 | header_txt.append('#include "glv_vk_vkdbg_structs.h"') |
| 1914 | header_txt.append('#include "glv_vk_vkwsix11ext_structs.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1915 | header_txt.append('#include "vk_enum_string_helper.h"') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 1916 | header_txt.append('#if defined(WIN32)') |
| 1917 | header_txt.append('#define snprintf _snprintf') |
| 1918 | header_txt.append('#endif') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1919 | header_txt.append('#define SEND_ENTRYPOINT_ID(entrypoint) ;') |
| 1920 | header_txt.append('//#define SEND_ENTRYPOINT_ID(entrypoint) glv_TraceInfo(#entrypoint "\\n");\n') |
| 1921 | header_txt.append('#define SEND_ENTRYPOINT_PARAMS(entrypoint, ...) ;') |
| 1922 | header_txt.append('//#define SEND_ENTRYPOINT_PARAMS(entrypoint, ...) glv_TraceInfo(entrypoint, __VA_ARGS__);\n') |
| 1923 | header_txt.append('#define CREATE_TRACE_PACKET(entrypoint, buffer_bytes_needed) \\') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1924 | header_txt.append(' pHeader = glv_create_trace_packet(GLV_TID_VULKAN, GLV_TPI_VK_##entrypoint, sizeof(struct_##entrypoint), buffer_bytes_needed);\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1925 | header_txt.append('#define FINISH_TRACE_PACKET() \\') |
| 1926 | header_txt.append(' glv_finalize_trace_packet(pHeader); \\') |
| 1927 | header_txt.append(' glv_write_trace_packet(pHeader, glv_trace_get_trace_file()); \\') |
| 1928 | header_txt.append(' glv_delete_trace_packet(&pHeader);') |
| 1929 | return "\n".join(header_txt) |
| 1930 | |
| 1931 | def generate_body(self): |
| 1932 | body = [self._generate_packet_id_enum(), |
| 1933 | self._generate_stringify_func(), |
| 1934 | self._generate_interp_func()] |
| 1935 | |
| 1936 | return "\n".join(body) |
| 1937 | |
| 1938 | class GlaveCoreStructs(Subcommand): |
| 1939 | def generate_header(self): |
| 1940 | header_txt = [] |
| 1941 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1942 | header_txt.append('#include "vulkan.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1943 | header_txt.append('#include "glv_trace_packet_utils.h"\n') |
| 1944 | return "\n".join(header_txt) |
| 1945 | |
| 1946 | def generate_body(self): |
| 1947 | body = [self._generate_struct_util_funcs(), |
| 1948 | self._generate_interp_funcs()] |
| 1949 | |
| 1950 | return "\n".join(body) |
| 1951 | |
| 1952 | class GlaveWsiHeader(Subcommand): |
| 1953 | def generate_header(self): |
| 1954 | header_txt = [] |
| 1955 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1956 | header_txt.append('#include "vulkan.h"') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 1957 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1958 | header_txt.append('#include "vkWsiX11Ext.h"\n') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1959 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1960 | header_txt.append('#include "vkWsiWinExt.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1961 | header_txt.append('#endif') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1962 | header_txt.append('void AttachHooks_vkwsix11ext();') |
| 1963 | header_txt.append('void DetachHooks_vkwsix11ext();') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1964 | return "\n".join(header_txt) |
| 1965 | |
| 1966 | def generate_body(self): |
| 1967 | body = [self._generate_trace_func_ptrs_ext(), |
| 1968 | self._generate_trace_func_protos_ext()] |
| 1969 | |
| 1970 | return "\n".join(body) |
| 1971 | |
| 1972 | class GlaveWsiC(Subcommand): |
| 1973 | def generate_header(self): |
| 1974 | header_txt = [] |
| 1975 | header_txt.append('#include "glv_platform.h"') |
| 1976 | header_txt.append('#include "glv_common.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1977 | header_txt.append('#include "glvtrace_vk_vkwsix11ext.h"') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 1978 | header_txt.append('#include "glv_vk_vkwsix11ext_structs.h"') |
| 1979 | header_txt.append('#include "glv_vk_packet_id.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1980 | header_txt.append('#ifdef WIN32') |
| 1981 | header_txt.append('#include "mhook/mhook-lib/mhook.h"') |
| 1982 | header_txt.append('#endif') |
| 1983 | return "\n".join(header_txt) |
| 1984 | |
| 1985 | def generate_body(self): |
| 1986 | body = [self._generate_func_ptr_assignments_ext(), |
| 1987 | self._generate_attach_hooks_ext(), |
| 1988 | self._generate_detach_hooks_ext(), |
| 1989 | self._generate_trace_funcs_ext()] |
| 1990 | |
| 1991 | return "\n".join(body) |
| 1992 | |
| 1993 | class GlaveWsiStructs(Subcommand): |
| 1994 | def generate_header(self): |
| 1995 | header_txt = [] |
| 1996 | header_txt.append('#pragma once\n') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 1997 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1998 | header_txt.append('#include "vkWsiX11Ext.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1999 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2000 | header_txt.append('#include "vkWsiWinExt.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2001 | header_txt.append('#endif') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2002 | header_txt.append('#include "glv_trace_packet_utils.h"\n') |
| 2003 | return "\n".join(header_txt) |
| 2004 | |
| 2005 | def generate_body(self): |
| 2006 | body = [self._generate_interp_funcs_ext()] |
| 2007 | |
| 2008 | return "\n".join(body) |
| 2009 | |
| 2010 | class GlaveDbgHeader(Subcommand): |
| 2011 | def generate_header(self): |
| 2012 | header_txt = [] |
| 2013 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2014 | header_txt.append('#include "vulkan.h"') |
| 2015 | header_txt.append('#include "vkDbg.h"\n') |
| 2016 | header_txt.append('void AttachHooks_vkdbg();') |
| 2017 | header_txt.append('void DetachHooks_vkdbg();') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2018 | return "\n".join(header_txt) |
| 2019 | |
| 2020 | def generate_body(self): |
| 2021 | body = [self._generate_trace_func_ptrs_ext('Dbg'), |
| 2022 | self._generate_trace_func_protos_ext('Dbg')] |
| 2023 | |
| 2024 | return "\n".join(body) |
| 2025 | |
| 2026 | class GlaveDbgC(Subcommand): |
| 2027 | def generate_header(self): |
| 2028 | header_txt = [] |
| 2029 | header_txt.append('#include "glv_platform.h"') |
| 2030 | header_txt.append('#include "glv_common.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2031 | header_txt.append('#include "glvtrace_vk_vk.h"') |
| 2032 | header_txt.append('#include "glvtrace_vk_vkdbg.h"') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 2033 | header_txt.append('#include "glv_vk_vkdbg_structs.h"') |
| 2034 | header_txt.append('#include "glv_vk_packet_id.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2035 | header_txt.append('#ifdef WIN32') |
| 2036 | header_txt.append('#include "mhook/mhook-lib/mhook.h"') |
| 2037 | header_txt.append('#endif') |
| 2038 | return "\n".join(header_txt) |
| 2039 | |
| 2040 | def generate_body(self): |
| 2041 | body = [self._generate_func_ptr_assignments_ext('Dbg'), |
| 2042 | self._generate_attach_hooks_ext('Dbg'), |
| 2043 | self._generate_detach_hooks_ext('Dbg'), |
| 2044 | self._generate_trace_funcs_ext('Dbg')] |
| 2045 | |
| 2046 | return "\n".join(body) |
| 2047 | |
| 2048 | class GlaveDbgStructs(Subcommand): |
| 2049 | def generate_header(self): |
| 2050 | header_txt = [] |
| 2051 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2052 | header_txt.append('#include "vkDbg.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2053 | header_txt.append('#include "glv_trace_packet_utils.h"\n') |
| 2054 | return "\n".join(header_txt) |
| 2055 | |
| 2056 | def generate_body(self): |
| 2057 | body = [self._generate_interp_funcs_ext('Dbg')] |
| 2058 | |
| 2059 | return "\n".join(body) |
| 2060 | |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2061 | class GlaveReplayVkFuncPtrs(Subcommand): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2062 | def generate_header(self): |
| 2063 | header_txt = [] |
| 2064 | header_txt.append('#pragma once\n') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 2065 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2066 | header_txt.append('#include <xcb/xcb.h>\n') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2067 | header_txt.append('#endif') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2068 | header_txt.append('#include "vulkan.h"') |
| 2069 | header_txt.append('#include "vkDbg.h"') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 2070 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2071 | header_txt.append('#include "vkWsiX11Ext.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2072 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2073 | header_txt.append('#include "vkWsiWinExt.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2074 | header_txt.append('#endif') |
| Peter Lohrmann | af44b45 | 2015-03-30 18:29:22 -0700 | [diff] [blame] | 2075 | |
| 2076 | def generate_body(self): |
| 2077 | body = [self._generate_replay_func_ptrs()] |
| 2078 | return "\n".join(body) |
| 2079 | |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 2080 | class GlaveReplayObjMapperHeader(Subcommand): |
| Jon Ashburn | 013aa1c | 2015-02-13 11:25:53 -0700 | [diff] [blame] | 2081 | def generate_header(self): |
| Ian Elliott | 91e681e | 2015-02-18 15:35:00 -0700 | [diff] [blame] | 2082 | header_txt = [] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2083 | header_txt.append('#pragma once\n') |
| 2084 | header_txt.append('#include <set>') |
| 2085 | header_txt.append('#include <map>') |
| 2086 | header_txt.append('#include <vector>') |
| 2087 | header_txt.append('#include <string>') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2088 | header_txt.append('#include "vulkan.h"') |
| 2089 | header_txt.append('#include "vkDbg.h"') |
| Jon Ashburn | 1590877 | 2015-02-17 13:28:11 -0700 | [diff] [blame] | 2090 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2091 | header_txt.append('#include "vkWsiX11Ext.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2092 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2093 | header_txt.append('#include "vkWsiWinExt.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2094 | header_txt.append('#endif') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2095 | return "\n".join(header_txt) |
| 2096 | |
| 2097 | def generate_body(self): |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 2098 | body = [self._generate_replay_objmapper_class()] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2099 | return "\n".join(body) |
| 2100 | |
| 2101 | class GlaveReplayC(Subcommand): |
| 2102 | def generate_header(self): |
| 2103 | header_txt = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2104 | header_txt.append('#include "glvreplay_vk_vkreplay.h"\n') |
| 2105 | header_txt.append('#include "glvreplay_vk.h"\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2106 | header_txt.append('#include "glvreplay_main.h"\n') |
| 2107 | header_txt.append('#include <algorithm>') |
| 2108 | header_txt.append('#include <queue>') |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 2109 | header_txt.append('\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2110 | header_txt.append('extern "C" {') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 2111 | header_txt.append('#include "glv_vk_vk_structs.h"') |
| 2112 | header_txt.append('#include "glv_vk_vkdbg_structs.h"') |
| 2113 | header_txt.append('#include "glv_vk_vkwsix11ext_structs.h"') |
| 2114 | header_txt.append('#include "glv_vk_packet_id.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2115 | header_txt.append('#include "vk_enum_string_helper.h"\n}\n') |
| 2116 | header_txt.append('#define APP_NAME "glvreplay_vk"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2117 | header_txt.append('#define IDI_ICON 101\n') |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 2118 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2119 | return "\n".join(header_txt) |
| 2120 | |
| 2121 | def generate_body(self): |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 2122 | body = [self._generate_replay_init_funcs(), |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2123 | self._generate_replay()] |
| 2124 | |
| 2125 | return "\n".join(body) |
| 2126 | |
| 2127 | def main(): |
| 2128 | subcommands = { |
| 2129 | "glave-trace-h" : GlaveTraceHeader, |
| 2130 | "glave-trace-c" : GlaveTraceC, |
| 2131 | "glave-packet-id" : GlavePacketID, |
| 2132 | "glave-core-structs" : GlaveCoreStructs, |
| 2133 | "glave-wsi-trace-h" : GlaveWsiHeader, |
| 2134 | "glave-wsi-trace-c" : GlaveWsiC, |
| 2135 | "glave-wsi-trace-structs" : GlaveWsiStructs, |
| 2136 | "glave-dbg-trace-h" : GlaveDbgHeader, |
| 2137 | "glave-dbg-trace-c" : GlaveDbgC, |
| 2138 | "glave-dbg-trace-structs" : GlaveDbgStructs, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2139 | "glave-replay-vk-funcs" : GlaveReplayVkFuncPtrs, |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 2140 | "glave-replay-obj-mapper-h" : GlaveReplayObjMapperHeader, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2141 | "glave-replay-c" : GlaveReplayC, |
| 2142 | } |
| 2143 | |
| 2144 | if len(sys.argv) < 2 or sys.argv[1] not in subcommands: |
| 2145 | print("Usage: %s <subcommand> [options]" % sys.argv[0]) |
| 2146 | print |
| 2147 | print("Available sucommands are: %s" % " ".join(subcommands)) |
| 2148 | exit(1) |
| 2149 | |
| 2150 | subcmd = subcommands[sys.argv[1]](sys.argv[2:]) |
| 2151 | subcmd.run() |
| 2152 | |
| 2153 | if __name__ == "__main__": |
| 2154 | main() |