| 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'}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 353 | 'pUpdateChain': {'add_txt': 'add_update_descriptors_to_trace_packet(pHeader, (void**)&(pPacket->pUpdateChain), pUpdateChain)', |
| 354 | 'finalize_txt': 'default'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 355 | '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] | 356 | '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^] | 357 | '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] | 358 | '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))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 359 | '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->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)', |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 360 | 'finalize_txt': '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^] | 361 | '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] | 362 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pBeginInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 363 | '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] | 364 | '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^] | 365 | '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] | 366 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pAllocInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 367 | '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] | 368 | 'finalize_txt': 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 369 | '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] | 370 | '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^] | 371 | '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] | 372 | 'finalize_txt': 'finalize_pipeline_shader_address(pHeader, &pPacket->pCreateInfo->cs);\n glv_finalize_buffer_address(pHeader, (void**)&(pPacket->pCreateInfo))'}, |
| 373 | } |
| 374 | for p in params: |
| 375 | pp_dict = {} |
| 376 | if '*' in p.ty and p.name not in ['pSysMem', 'pReserved']: |
| 377 | if 'const' in p.ty.lower() and 'count' in params[params.index(p)-1].name.lower(): |
| 378 | 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) |
| 379 | elif p.ty.strip('*').replace('const ', '') in custom_ptr_dict: |
| 380 | pp_dict['add_txt'] = custom_ptr_dict[p.ty.strip('*').replace('const ', '')]['add_txt'] |
| 381 | pp_dict['finalize_txt'] = custom_ptr_dict[p.ty.strip('*').replace('const ', '')]['finalize_txt'] |
| 382 | elif p.name in custom_ptr_dict: |
| 383 | pp_dict['add_txt'] = custom_ptr_dict[p.name]['add_txt'] |
| 384 | pp_dict['finalize_txt'] = custom_ptr_dict[p.name]['finalize_txt'] |
| 385 | # TODO : This is custom hack to account for 2 pData items with dataSize param for sizing |
| 386 | if 'pData' == p.name and 'dataSize' == params[params.index(p)-1].name: |
| 387 | pp_dict['add_txt'] = pp_dict['add_txt'].replace('_dataSize', 'dataSize') |
| 388 | else: |
| 389 | 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) |
| 390 | if 'finalize_txt' not in pp_dict or 'default' == pp_dict['finalize_txt']: |
| 391 | pp_dict['finalize_txt'] = 'glv_finalize_buffer_address(pHeader, (void**)&(pPacket->%s))' % (p.name) |
| 392 | pp_dict['index'] = params.index(p) |
| 393 | ptr_param_list.append(pp_dict) |
| 394 | return ptr_param_list |
| 395 | |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 396 | # Take a list of params and return a list of packet size elements |
| 397 | def _get_packet_size(self, params): |
| Tobin Ehlis | f57562c | 2015-03-13 07:18:05 -0600 | [diff] [blame] | 398 | 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] | 399 | 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] | 400 | # Dict of specific params with unique custom sizes |
| 401 | custom_size_dict = {'pSetBindPoints': '(VK_SHADER_STAGE_COMPUTE * sizeof(uint32_t))', # Accounting for largest possible array |
| 402 | } |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 403 | for p in params: |
| 404 | #First handle custom cases |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 405 | if p.name in ['pCreateInfo', 'pUpdateChain', 'pSetLayoutInfoList', 'pBeginInfo', 'pAllocInfo']: |
| Tobin Ehlis | f57562c | 2015-03-13 07:18:05 -0600 | [diff] [blame] | 406 | ps.append('get_struct_chain_size((void*)%s)' % p.name) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 407 | skip_list.append(p.name) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 408 | elif p.name in custom_size_dict: |
| 409 | ps.append(custom_size_dict[p.name]) |
| 410 | skip_list.append(p.name) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 411 | # Skip any params already handled |
| 412 | if p.name in skip_list: |
| 413 | continue |
| 414 | # Now check to identify dynamic arrays which depend on two params |
| 415 | if 'count' in p.name.lower(): |
| 416 | next_idx = params.index(p)+1 |
| 417 | # If next element is a const *, then multiply count and array type |
| 418 | if next_idx < len(params) and '*' in params[next_idx].ty and 'const' in params[next_idx].ty.lower(): |
| 419 | if '*' in p.ty: |
| 420 | ps.append('*%s*sizeof(%s)' % (p.name, params[next_idx].ty.strip('*').replace('const ', ''))) |
| 421 | else: |
| 422 | ps.append('%s*sizeof(%s)' % (p.name, params[next_idx].ty.strip('*').replace('const ', ''))) |
| 423 | skip_list.append(params[next_idx].name) |
| 424 | elif '*' in p.ty and p.name not in ['pSysMem', 'pReserved']: |
| 425 | if 'pData' == p.name: |
| 426 | if 'dataSize' == params[params.index(p)-1].name: |
| 427 | ps.append('dataSize') |
| 428 | elif 'counterCount' == params[params.index(p)-1].name: |
| 429 | ps.append('sizeof(%s)' % p.ty.strip('*').replace('const ', '')) |
| 430 | else: |
| 431 | ps.append('((pDataSize != NULL && pData != NULL) ? *pDataSize : 0)') |
| 432 | elif '**' in p.ty and 'void' in p.ty: |
| 433 | ps.append('sizeof(void*)') |
| 434 | elif 'void' in p.ty: |
| 435 | ps.append('sizeof(%s)' % p.name) |
| 436 | elif 'char' in p.ty: |
| 437 | ps.append('((%s != NULL) ? strlen(%s) + 1 : 0)' % (p.name, p.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 438 | elif 'pDataSize' in p.name: |
| 439 | ps.append('((pDataSize != NULL) ? sizeof(size_t) : 0)') |
| 440 | elif 'IMAGE_SUBRESOURCE' in p.ty and 'pSubresource' == p.name: |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 441 | ps.append('((pSubresource != NULL) ? sizeof(VkImage_SUBRESOURCE) : 0)') |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 442 | else: |
| 443 | ps.append('sizeof(%s)' % (p.ty.strip('*').replace('const ', ''))) |
| 444 | return ps |
| 445 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 446 | # 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] | 447 | # Here's the general flow of code insertion w/ option items flagged w/ "?" |
| 448 | # Result decl? |
| 449 | # Packet struct decl |
| 450 | # ?Special case : setup call to function first and do custom API call time tracking |
| 451 | # CREATE_PACKET |
| 452 | # Call (w/ result?) |
| 453 | # Assign packet values |
| 454 | # FINISH packet |
| 455 | # return result? |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 456 | def _generate_trace_funcs(self): |
| 457 | func_body = [] |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 458 | manually_written_hooked_funcs = ['CreateInstance', 'EnumerateLayers', 'EnumerateGpus', |
| 459 | 'AllocDescriptorSets', 'MapMemory', 'UnmapMemory', |
| 460 | 'CmdPipelineBarrier', 'CmdWaitEvents'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 461 | for proto in self.protos: |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 462 | if proto.name in manually_written_hooked_funcs: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 463 | 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] | 464 | elif 'Dbg' not in proto.name and 'Wsi' not in proto.name: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 465 | raw_packet_update_list = [] # non-ptr elements placed directly into packet |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 466 | ptr_packet_update_list = [] # ptr elements to be updated into packet |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 467 | return_txt = '' |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 468 | packet_size = [] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 469 | 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] | 470 | 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] | 471 | for p in proto.params: # TODO : For all of the ptr types, check them for NULL and return 0 if NULL |
| 472 | if '[' in p.ty: # Correctly declare static arrays in function parameters |
| 473 | 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] | 474 | else: |
| 475 | func_body.append(' %s %s,' % (p.ty, p.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 476 | if '*' in p.ty and p.name not in ['pSysMem', 'pReserved']: |
| 477 | if 'pDataSize' in p.name: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 478 | in_data_size = True; |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 479 | else: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 480 | if '[' in p.ty: |
| Tobin Ehlis | 8a5a85b | 2015-02-25 11:30:27 -0700 | [diff] [blame] | 481 | array_str = p.ty[p.ty.find('[')+1:p.ty.find(']')] |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 482 | 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] | 483 | else: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 484 | raw_packet_update_list.append(' pPacket->%s = %s;' % (p.name, p.name)) |
| 485 | # Get list of packet size modifiers due to ptr params |
| 486 | packet_size = self._get_packet_size(proto.params) |
| Tobin Ehlis | 1d3dd2b | 2015-03-11 17:19:54 -0600 | [diff] [blame] | 487 | ptr_packet_update_list = self._get_packet_ptr_param_list(proto.params) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 488 | func_body[-1] = func_body[-1].replace(',', ')') |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 489 | # End of function declaration portion, begin function body |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 490 | func_body.append('{\n glv_trace_packet_header* pHeader;') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 491 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 492 | func_body.append(' %s result;' % proto.ret) |
| 493 | return_txt = 'result = ' |
| 494 | if in_data_size: |
| Jon Ashburn | 53f54a3 | 2015-02-11 09:32:29 -0700 | [diff] [blame] | 495 | func_body.append(' size_t _dataSize;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 496 | func_body.append(' struct_vk%s* pPacket = NULL;' % proto.name) |
| Jon Ashburn | 8cb39a3 | 2015-02-02 12:39:24 -0700 | [diff] [blame] | 497 | # 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] | 498 | # 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] | 499 | if proto.name in ['CreateFramebuffer', 'CreateRenderPass', 'CreateDynamicViewportState', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 500 | 'CreateDescriptorRegion']: |
| Tobin Ehlis | f57562c | 2015-03-13 07:18:05 -0600 | [diff] [blame] | 501 | # 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] | 502 | if 'CreateFramebuffer' == proto.name: |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 503 | 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] | 504 | 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^] | 505 | 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] | 506 | elif 'CreateRenderPass' == proto.name: |
| Jon Ashburn | ec7dcb4 | 2015-02-20 10:30:32 -0700 | [diff] [blame] | 507 | func_body.append(' uint32_t colorCount = (pCreateInfo != 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^] | 508 | 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] | 509 | elif 'CreateDynamicViewportState' == proto.name: |
| Courtney Goeltzenleuchter | c6e32f9 | 2015-02-11 14:13:34 -0700 | [diff] [blame] | 510 | 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^] | 511 | 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] | 512 | elif 'CreateDescriptorRegion' == proto.name: |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 513 | 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^] | 514 | 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] | 515 | func_body.append(' %sreal_vk%s;' % (return_txt, proto.c_call())) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 516 | else: |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 517 | if (0 == len(packet_size)): |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 518 | func_body.append(' CREATE_TRACE_PACKET(vk%s, 0);' % (proto.name)) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 519 | else: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 520 | func_body.append(' CREATE_TRACE_PACKET(vk%s, %s);' % (proto.name, ' + '.join(packet_size))) |
| 521 | func_body.append(' %sreal_vk%s;' % (return_txt, proto.c_call())) |
| Jon Ashburn | 53f54a3 | 2015-02-11 09:32:29 -0700 | [diff] [blame] | 522 | if in_data_size: |
| 523 | func_body.append(' _dataSize = (pDataSize == NULL || pData == NULL) ? 0 : *pDataSize;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 524 | func_body.append(' pPacket = interpret_body_as_vk%s(pHeader);' % proto.name) |
| Tobin Ehlis | 81b1b3d | 2015-03-10 11:04:17 -0600 | [diff] [blame] | 525 | func_body.append('\n'.join(raw_packet_update_list)) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 526 | for pp_dict in ptr_packet_update_list: #buff_ptr_indices: |
| 527 | func_body.append(' %s;' % (pp_dict['add_txt'])) |
| 528 | if 'void' not in proto.ret or '*' in proto.ret: |
| 529 | func_body.append(' pPacket->result = result;') |
| 530 | for pp_dict in ptr_packet_update_list: |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 531 | if ('DeviceCreateInfo' not in proto.params[pp_dict['index']].ty) and ('APPLICATION_INFO' not in proto.params[pp_dict['index']].ty) and ('pUpdateChain' != proto.params[pp_dict['index']].name): |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 532 | func_body.append(' %s;' % (pp_dict['finalize_txt'])) |
| 533 | func_body.append(' FINISH_TRACE_PACKET();') |
| 534 | if 'AllocMemory' in proto.name: |
| 535 | func_body.append(' add_new_handle_to_mem_info(*pMem, pAllocInfo->allocationSize, NULL);') |
| 536 | elif 'FreeMemory' in proto.name: |
| 537 | func_body.append(' rm_handle_from_mem_info(mem);') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 538 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 539 | func_body.append(' return result;') |
| 540 | func_body.append('}\n') |
| 541 | return "\n".join(func_body) |
| 542 | |
| 543 | def _generate_trace_funcs_ext(self, func_class='Wsi'): |
| 544 | thread_once_funcs = ['DbgRegisterMsgCallback', 'DbgUnregisterMsgCallback', 'DbgSetGlobalOption'] |
| 545 | func_body = [] |
| 546 | for proto in self.protos: |
| 547 | if func_class in proto.name: |
| 548 | packet_update_txt = '' |
| 549 | return_txt = '' |
| 550 | packet_size = '' |
| 551 | buff_ptr_indices = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 552 | 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] | 553 | for p in proto.params: # TODO : For all of the ptr types, check them for NULL and return 0 is NULL |
| 554 | func_body.append(' %s %s,' % (p.ty, p.name)) |
| 555 | if 'Size' in p.name: |
| 556 | packet_size += p.name |
| 557 | if '*' in p.ty and 'pSysMem' != p.name: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 558 | if 'char' in p.ty: |
| Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 559 | packet_size += '((%s != NULL) ? strlen(%s) + 1 : 0) + ' % (p.name, p.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 560 | elif 'Size' not in packet_size: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 561 | packet_size += 'sizeof(%s) + ' % p.ty.strip('*').replace('const ', '') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 562 | buff_ptr_indices.append(proto.params.index(p)) |
| 563 | if 'pConnectionInfo' in p.name: |
| 564 | packet_size += '((pConnectionInfo->pConnection != NULL) ? sizeof(void *) : 0)' |
| 565 | else: |
| 566 | packet_update_txt += ' pPacket->%s = %s;\n' % (p.name, p.name) |
| 567 | if '' == packet_size: |
| 568 | packet_size = '0' |
| 569 | else: |
| 570 | packet_size = packet_size.strip(' + ') |
| 571 | func_body[-1] = func_body[-1].replace(',', ')') |
| 572 | func_body.append('{\n glv_trace_packet_header* pHeader;') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 573 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 574 | func_body.append(' %s result;' % proto.ret) |
| 575 | return_txt = 'result = ' |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 576 | func_body.append(' struct_vk%s* pPacket = NULL;' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 577 | if proto.name in thread_once_funcs: |
| 578 | func_body.append(' glv_platform_thread_once(&gInitOnce, InitTracer);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 579 | func_body.append(' SEND_ENTRYPOINT_ID(vk%s);' % proto.name) |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 580 | if 'DbgRegisterMsgCallback' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 581 | func_body.append(' CREATE_TRACE_PACKET(vk%s, sizeof(char));' % proto.name) |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 582 | else: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 583 | func_body.append(' CREATE_TRACE_PACKET(vk%s, %s);' % (proto.name, packet_size)) |
| 584 | func_body.append(' %sreal_vk%s;' % (return_txt, proto.c_call())) |
| 585 | func_body.append(' pPacket = interpret_body_as_vk%s(pHeader);' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 586 | func_body.append(packet_update_txt.strip('\n')) |
| 587 | for idx in buff_ptr_indices: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 588 | if 'char' in proto.params[idx].ty: |
| Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 589 | 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] | 590 | elif 'Size' in proto.params[idx-1].name: |
| 591 | 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] | 592 | elif 'DbgRegisterMsgCallback' in proto.name: |
| 593 | 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] | 594 | else: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 595 | 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] | 596 | if 'WsiX11AssociateConnection' in proto.name: |
| 597 | func_body.append(' if (pConnectionInfo->pConnection != NULL) {') |
| 598 | func_body.append(' glv_add_buffer_to_trace_packet(pHeader, (void**) &(pPacket->pConnectionInfo->pConnection), sizeof(void *), pConnectionInfo->pConnection);') |
| 599 | func_body.append(' glv_finalize_buffer_address(pHeader, (void**) &(pPacket->pConnectionInfo->pConnection));') |
| 600 | func_body.append(' }') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 601 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 602 | func_body.append(' pPacket->result = result;') |
| 603 | for idx in buff_ptr_indices: |
| 604 | func_body.append(' glv_finalize_buffer_address(pHeader, (void**)&(pPacket->%s));' % (proto.params[idx].name)) |
| 605 | func_body.append(' FINISH_TRACE_PACKET();') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 606 | if 'void' not in proto.ret or '*' in proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 607 | func_body.append(' return result;') |
| 608 | func_body.append('}\n') |
| 609 | return "\n".join(func_body) |
| 610 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 611 | def _generate_packet_id_enum(self): |
| 612 | pid_enum = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 613 | pid_enum.append('enum GLV_TRACE_PACKET_ID_VK') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 614 | pid_enum.append('{') |
| 615 | first_func = True |
| 616 | for proto in self.protos: |
| 617 | if first_func: |
| 618 | first_func = False |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 619 | pid_enum.append(' GLV_TPI_VK_vkApiVersion = GLV_TPI_BEGIN_API_HERE,') |
| 620 | pid_enum.append(' GLV_TPI_VK_vk%s,' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 621 | else: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 622 | pid_enum.append(' GLV_TPI_VK_vk%s,' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 623 | pid_enum.append('};\n') |
| 624 | return "\n".join(pid_enum) |
| 625 | |
| 626 | def _generate_stringify_func(self): |
| 627 | func_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 628 | 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] | 629 | func_body.append('{') |
| 630 | func_body.append(' static char str[1024];') |
| 631 | func_body.append(' switch(id) {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 632 | func_body.append(' case GLV_TPI_VK_vkApiVersion:') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 633 | func_body.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 634 | func_body.append(' struct_vkApiVersion* pPacket = (struct_vkApiVersion*)(pHeader->pBody);') |
| 635 | func_body.append(' snprintf(str, 1024, "vkApiVersion = 0x%x", pPacket->version);') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 636 | func_body.append(' return str;') |
| 637 | func_body.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 638 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 639 | func_body.append(' case GLV_TPI_VK_vk%s:' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 640 | func_body.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 641 | func_str = 'vk%s(' % proto.name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 642 | print_vals = '' |
| 643 | create_func = False |
| 644 | if 'Create' in proto.name or 'Alloc' in proto.name or 'MapMemory' in proto.name: |
| 645 | create_func = True |
| 646 | for p in proto.params: |
| 647 | last_param = False |
| 648 | if (p.name == proto.params[-1].name): |
| 649 | last_param = True |
| 650 | if last_param and create_func: # last param of create func |
| 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, True) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 652 | else: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 653 | (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] | 654 | if last_param == True: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 655 | func_str += '%s%s = %s)' % (ptr, p.name, pft) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 656 | print_vals += ', %s' % (pfi) |
| 657 | else: |
| Jon Ashburn | 8f44563 | 2015-02-12 10:38:36 -0700 | [diff] [blame] | 658 | func_str += '%s%s = %s, ' % (ptr, p.name, pft) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 659 | print_vals += ', %s' % (pfi) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 660 | 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] | 661 | func_body.append(' snprintf(str, 1024, "%s"%s);' % (func_str, print_vals)) |
| 662 | func_body.append(' return str;') |
| 663 | func_body.append(' }') |
| 664 | func_body.append(' default:') |
| 665 | func_body.append(' return NULL;') |
| 666 | func_body.append(' }') |
| 667 | func_body.append('};\n') |
| 668 | return "\n".join(func_body) |
| 669 | |
| 670 | def _generate_interp_func(self): |
| 671 | interp_func_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 672 | 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] | 673 | interp_func_body.append('{') |
| 674 | interp_func_body.append(' if (pHeader == NULL)') |
| 675 | interp_func_body.append(' {') |
| 676 | interp_func_body.append(' return NULL;') |
| 677 | interp_func_body.append(' }') |
| 678 | interp_func_body.append(' switch (pHeader->packet_id)') |
| 679 | interp_func_body.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 680 | interp_func_body.append(' case GLV_TPI_VK_vkApiVersion:\n {') |
| 681 | 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] | 682 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 683 | 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] | 684 | header_prefix = 'h' |
| 685 | if 'Wsi' in proto.name or 'Dbg' in proto.name: |
| 686 | header_prefix = 'pH' |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 687 | 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] | 688 | interp_func_body.append(' default:') |
| 689 | interp_func_body.append(' return NULL;') |
| 690 | interp_func_body.append(' }') |
| 691 | interp_func_body.append(' return NULL;') |
| 692 | interp_func_body.append('}') |
| 693 | return "\n".join(interp_func_body) |
| 694 | |
| 695 | def _generate_struct_util_funcs(self): |
| 696 | pid_enum = [] |
| 697 | pid_enum.append('//=============================================================================') |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 698 | 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] | 699 | pid_enum.append('{') |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 700 | 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] | 701 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)&((*ppStruct)->pAppName), strlen(pInStruct->pAppName) + 1, pInStruct->pAppName);') |
| 702 | 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] | 703 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&((*ppStruct)->pAppName));') |
| 704 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&((*ppStruct)->pEngineName));') |
| 705 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&*ppStruct);') |
| 706 | pid_enum.append('};\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 707 | pid_enum.append('//=============================================================================\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 708 | # TODO : Create add_VkInstanceCreateInfo_to_packet() function here - used in glvtrace_vk_trace.c = add_VkInstanceCreateInfo_to_packet(pHeader, (VkInstanceCreateInfo**)&(pPacket->pCreateInfo), pCreateInfo); |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 709 | 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] | 710 | pid_enum.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 711 | pid_enum.append(' uint32_t i;') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 712 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)ppStruct, sizeof(VkDeviceCreateInfo), pInStruct);') |
| 713 | 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] | 714 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)&(*ppStruct)->pRequestedQueues);') |
| Jon Ashburn | 29669a4 | 2015-04-04 14:52:07 -0600 | [diff] [blame] | 715 | pid_enum.append(' if (pInStruct->extensionCount > 0) ') |
| 716 | pid_enum.append(' {') |
| 717 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&(*ppStruct)->ppEnabledExtensionNames), pInStruct->extensionCount * sizeof(char *), pInStruct->ppEnabledExtensionNames);') |
| 718 | pid_enum.append(' for (i = 0; i < pInStruct->extensionCount; i++)') |
| 719 | pid_enum.append(' {') |
| 720 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppStruct)->ppEnabledExtensionNames[i])), strlen(pInStruct->ppEnabledExtensionNames[i]) + 1, pInStruct->ppEnabledExtensionNames[i]);') |
| 721 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppStruct)->ppEnabledExtensionNames[i])));') |
| 722 | pid_enum.append(' }') |
| 723 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void **)&(*ppStruct)->ppEnabledExtensionNames);') |
| 724 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 725 | pid_enum.append(' VkLayerCreateInfo *pNext = ( VkLayerCreateInfo *) pInStruct->pNext;') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 726 | pid_enum.append(' while (pNext != NULL)') |
| 727 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 728 | 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] | 729 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 730 | 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] | 731 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppStruct)->pNext)));') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 732 | pid_enum.append(' VkLayerCreateInfo **ppOutStruct = (VkLayerCreateInfo **) &((*ppStruct)->pNext);') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 733 | 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] | 734 | pid_enum.append(' for (i = 0; i < pNext->layerCount; i++)') |
| 735 | pid_enum.append(' {') |
| 736 | pid_enum.append(' glv_add_buffer_to_trace_packet(pHeader, (void**)(&((*ppOutStruct)->ppActiveLayerNames[i])), strlen(pNext->ppActiveLayerNames[i]) + 1, pNext->ppActiveLayerNames[i]);') |
| 737 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)(&((*ppOutStruct)->ppActiveLayerNames[i])));') |
| 738 | pid_enum.append(' }') |
| 739 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void **)&(*ppOutStruct)->ppActiveLayerNames);') |
| 740 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 741 | pid_enum.append(' pNext = ( VkLayerCreateInfo *) pNext->pNext;') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 742 | pid_enum.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 743 | pid_enum.append(' glv_finalize_buffer_address(pHeader, (void**)ppStruct);') |
| 744 | pid_enum.append('}\n') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 745 | 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] | 746 | pid_enum.append('{') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 747 | pid_enum.append(' VkDeviceCreateInfo* pVkDeviceCreateInfo = (VkDeviceCreateInfo*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)ptr_variable);\n') |
| 748 | pid_enum.append(' if (pVkDeviceCreateInfo != NULL)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 749 | pid_enum.append(' {') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 750 | pid_enum.append(' uint32_t i;') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 751 | pid_enum.append(' const char** pNames;') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 752 | pid_enum.append(' pVkDeviceCreateInfo->pRequestedQueues = (const VkDeviceQueueCreateInfo *)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkDeviceCreateInfo->pRequestedQueues);\n') |
| 753 | pid_enum.append(' if (pVkDeviceCreateInfo->extensionCount > 0)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 754 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 755 | pid_enum.append(' pVkDeviceCreateInfo->ppEnabledExtensionNames = (const char *const*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVkDeviceCreateInfo->ppEnabledExtensionNames);') |
| 756 | pid_enum.append(' pNames = (const char**)pVkDeviceCreateInfo->ppEnabledExtensionNames;') |
| 757 | pid_enum.append(' for (i = 0; i < pVkDeviceCreateInfo->extensionCount; i++)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 758 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 759 | 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] | 760 | pid_enum.append(' }') |
| 761 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 762 | 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] | 763 | pid_enum.append(' while (pNext != NULL)') |
| 764 | pid_enum.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 765 | 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] | 766 | pid_enum.append(' {') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 767 | pid_enum.append(' pNext->ppActiveLayerNames = (const char**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)(pNext->ppActiveLayerNames));') |
| 768 | pid_enum.append(' pNames = (const char**)pNext->ppActiveLayerNames;') |
| Jon Ashburn | 780112b | 2015-01-09 17:30:41 -0700 | [diff] [blame] | 769 | pid_enum.append(' for (i = 0; i < pNext->layerCount; i++)') |
| 770 | pid_enum.append(' {') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 771 | 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] | 772 | pid_enum.append(' }') |
| 773 | pid_enum.append(' }') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 774 | 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] | 775 | pid_enum.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 776 | pid_enum.append(' }\n') |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 777 | pid_enum.append(' return pVkDeviceCreateInfo;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 778 | pid_enum.append('}\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 779 | 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] | 780 | pid_enum.append('{') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 781 | pid_enum.append(' if (pShader != NULL)') |
| 782 | pid_enum.append(' {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 783 | pid_enum.append(' // constant buffers') |
| 784 | pid_enum.append(' if (pShader->linkConstBufferCount > 0)') |
| 785 | pid_enum.append(' {') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 786 | pid_enum.append(' uint32_t i;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 787 | 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] | 788 | pid_enum.append(' for (i = 0; i < pShader->linkConstBufferCount; i++)') |
| 789 | pid_enum.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 790 | pid_enum.append(' VkLinkConstBuffer* pBuffer = (VkLinkConstBuffer*)pShader->pLinkConstBufferInfo;') |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 791 | 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] | 792 | pid_enum.append(' }') |
| 793 | pid_enum.append(' }') |
| 794 | pid_enum.append(' }') |
| 795 | pid_enum.append('}\n') |
| 796 | pid_enum.append('//=============================================================================') |
| 797 | return "\n".join(pid_enum) |
| 798 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 799 | # 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] | 800 | # This code gets generated into glv_vk_vk_structs.h file |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 801 | def _generate_interp_funcs(self): |
| 802 | # 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] | 803 | # 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 |
| Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 804 | custom_case_dict = { 'CreateInstance' : {'param': 'pAppInfo', 'txt': ['VkApplicationInfo* pInfo = (VkApplicationInfo*)pPacket->pAppInfo;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 805 | 'pInfo->pAppName = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pAppInfo->pAppName);\n', |
| 806 | 'pInfo->pEngineName = (const char*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pAppInfo->pEngineName);']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 807 | 'CreateShader' : {'param': 'pCreateInfo', 'txt': ['VkShaderCreateInfo* pInfo = (VkShaderCreateInfo*)pPacket->pCreateInfo;\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 808 | '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^] | 809 | 'CreateDynamicViewportState' : {'param': 'pCreateInfo', 'txt': ['VkDynamicVpStateCreateInfo* pInfo = (VkDynamicVpStateCreateInfo*)pPacket->pCreateInfo;\n', |
| 810 | 'pInfo->pViewports = (VkViewport*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pViewports);\n', |
| 811 | 'pInfo->pScissors = (VkRect*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pScissors);']}, |
| 812 | 'CreateFramebuffer' : {'param': 'pCreateInfo', 'txt': ['VkFramebufferCreateInfo* pInfo = (VkFramebufferCreateInfo*)pPacket->pCreateInfo;\n', |
| 813 | 'pInfo->pColorAttachments = (VkColorAttachmentBindInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorAttachments);\n', |
| 814 | 'pInfo->pDepthStencilAttachment = (VkDepthStencilBindInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pDepthStencilAttachment);\n']}, |
| 815 | 'CreateRenderPass' : {'param': 'pCreateInfo', 'txt': ['VkRenderPassCreateInfo* pInfo = (VkRenderPassCreateInfo*)pPacket->pCreateInfo;\n', |
| 816 | 'pInfo->pColorLoadOps = (VkAttachmentLoadOp*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorLoadOps);\n', |
| 817 | 'pInfo->pColorStoreOps = (VkAttachmentStoreOp*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorStoreOps);\n', |
| 818 | 'pInfo->pColorLoadClearValues = (VkClearColor*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pColorLoadClearValues);\n']}, |
| 819 | 'CreateDescriptorPool' : {'param': 'pCreateInfo', 'txt': ['VkDescriptorPoolCreateInfo* pInfo = (VkDescriptorPoolCreateInfo*)pPacket->pCreateInfo;\n', |
| 820 | 'pInfo->pTypeCount = (VkDescriptorTypeCount*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pCreateInfo->pTypeCount);\n']}, |
| 821 | 'CmdWaitEvents' : {'param': 'pWaitInfo', 'txt': ['VkEventWaitInfo* pInfo = (VkEventWaitInfo*)pPacket->pWaitInfo;\n', |
| 822 | '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] | 823 | 'pInfo->ppMemBarriers = (const void**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pWaitInfo->ppMemBarriers);\n', |
| 824 | 'uint32_t i;\n', |
| 825 | 'for (i = 0; i < pInfo->memBarrierCount; i++) {\n', |
| 826 | ' void** ppLocalMemBarriers = (void**)&pInfo->ppMemBarriers[i];\n', |
| 827 | ' *ppLocalMemBarriers = (void*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pInfo->ppMemBarriers[i]);\n', |
| 828 | '}']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 829 | 'CmdPipelineBarrier' : {'param': 'pBarrier', 'txt': ['VkPipelineBarrier* pBarrier = (VkPipelineBarrier*)pPacket->pBarrier;\n', |
| 830 | '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] | 831 | 'pBarrier->ppMemBarriers = (const void**) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pBarrier->ppMemBarriers);\n', |
| 832 | 'uint32_t i;\n', |
| 833 | 'for (i = 0; i < pBarrier->memBarrierCount; i++) {\n', |
| 834 | ' void** ppLocalMemBarriers = (void**)&pBarrier->ppMemBarriers[i];\n', |
| 835 | ' *ppLocalMemBarriers = (void*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pBarrier->ppMemBarriers[i]);\n', |
| 836 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 837 | 'CreateDescriptorSetLayout' : {'param': 'pSetLayoutInfoList', 'txt': ['if (pPacket->pSetLayoutInfoList->sType == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO) {\n', |
| 838 | ' // need to make a non-const pointer to the pointer so that we can properly change the original pointer to the interpretted one\n', |
| 839 | ' void** ppNextVoidPtr = (void**)&(pPacket->pSetLayoutInfoList->pNext);\n', |
| 840 | ' *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^] | 841 | ' VkDescriptorSetLayoutCreateInfo* pNext = (VkDescriptorSetLayoutCreateInfo*)pPacket->pSetLayoutInfoList->pNext;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 842 | ' while (NULL != pNext)\n', ' {\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 843 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 844 | ' case VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 845 | ' {\n' , |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 846 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 847 | ' *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] | 848 | ' break;\n', |
| 849 | ' }\n', |
| 850 | ' default:\n', |
| 851 | ' {\n', |
| 852 | ' glv_LogError("Encountered an unexpected type in descriptor set layout create list.\\n");\n', |
| 853 | ' pPacket->header = NULL;\n', |
| 854 | ' pNext->pNext = NULL;\n', |
| 855 | ' }\n', |
| Jon Ashburn | 7fd7eff | 2015-02-04 10:55:47 -0700 | [diff] [blame] | 856 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 857 | ' pNext = (VkDescriptorSetLayoutCreateInfo*)pNext->pNext;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 858 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 859 | '} else {\n', |
| 860 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 861 | ' 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] | 862 | ' pPacket->header = NULL;\n', |
| Jon Ashburn | 7fd7eff | 2015-02-04 10:55:47 -0700 | [diff] [blame] | 863 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 864 | '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] | 865 | ' // 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^] | 866 | ' VkCmdBufferGraphicsBeginInfo** ppNext = (VkCmdBufferGraphicsBeginInfo**)&(pPacket->pBeginInfo->pNext);\n', |
| 867 | ' *ppNext = (VkCmdBufferGraphicsBeginInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pBeginInfo->pNext);\n', |
| 868 | ' VkCmdBufferGraphicsBeginInfo* pNext = *ppNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 869 | ' while (NULL != pNext)\n', ' {\n', |
| 870 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 871 | ' case VK_STRUCTURE_TYPE_CMD_BUFFER_GRAPHICS_BEGIN_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 872 | ' {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 873 | ' ppNext = (VkCmdBufferGraphicsBeginInfo**) &pNext->pNext;\n', |
| 874 | ' *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] | 875 | ' break;\n', |
| 876 | ' }\n', |
| 877 | ' default:\n', |
| 878 | ' {\n', |
| 879 | ' glv_LogError("Encountered an unexpected type in begin command buffer list.\\n");\n', |
| 880 | ' pPacket->header = NULL;\n', |
| 881 | ' pNext->pNext = NULL;\n', |
| 882 | ' }\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 883 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 884 | ' pNext = (VkCmdBufferGraphicsBeginInfo*)pNext->pNext;\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 885 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 886 | '} else {\n', |
| 887 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 888 | ' 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] | 889 | ' pPacket->header = NULL;\n', |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 890 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 891 | '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^] | 892 | ' VkMemoryAllocInfo** ppNext = (VkMemoryAllocInfo**) &(pPacket->pAllocInfo->pNext);\n', |
| 893 | ' *ppNext = (VkMemoryAllocInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->pAllocInfo->pNext);\n', |
| 894 | ' VkMemoryAllocInfo* pNext = (VkMemoryAllocInfo*) *ppNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 895 | ' while (NULL != pNext)\n', ' {\n', |
| 896 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 897 | ' case VK_STRUCTURE_TYPE_MEMORY_ALLOC_BUFFER_INFO:\n', |
| 898 | ' case VK_STRUCTURE_TYPE_MEMORY_ALLOC_IMAGE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 899 | ' {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 900 | ' ppNext = (VkMemoryAllocInfo **) &(pNext->pNext);\n', |
| 901 | ' *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] | 902 | ' break;\n', |
| 903 | ' }\n', |
| 904 | ' default:\n', |
| 905 | ' {\n', |
| 906 | ' glv_LogError("Encountered an unexpected type alloc memory list.\\n");\n', |
| 907 | ' pPacket->header = NULL;\n', |
| 908 | ' pNext->pNext = NULL;\n', |
| 909 | ' }\n', |
| Jon Ashburn | 3039e9c | 2015-02-03 07:33:48 -0700 | [diff] [blame] | 910 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 911 | ' pNext = (VkMemoryAllocInfo*)pNext->pNext;\n', |
| Jon Ashburn | 3039e9c | 2015-02-03 07:33:48 -0700 | [diff] [blame] | 912 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 913 | '} else {\n', |
| 914 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 915 | ' 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] | 916 | ' pPacket->header = NULL;\n', |
| Jon Ashburn | 3039e9c | 2015-02-03 07:33:48 -0700 | [diff] [blame] | 917 | '}']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 918 | 'UpdateDescriptors' : {'param': 'pUpdateChain', 'txt': ['VkUpdateSamplers* pNext = (VkUpdateSamplers*)pPacket->pUpdateChain;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 919 | 'while ((NULL != pNext) && (VK_NULL_HANDLE != pNext))\n', '{\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 920 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 921 | ' case VK_STRUCTURE_TYPE_UPDATE_AS_COPY:\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 922 | ' {\n', |
| 923 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 924 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| 925 | ' break;\n', |
| 926 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 927 | ' case VK_STRUCTURE_TYPE_UPDATE_SAMPLERS:\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 928 | ' {\n', |
| 929 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 930 | ' VkUpdateSamplers* pUS = (VkUpdateSamplers*)pNext;\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 931 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 932 | ' pUS->pSamplers = (VK_SAMPLER*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUS->pSamplers);\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 933 | ' break;\n', |
| 934 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 935 | ' case VK_STRUCTURE_TYPE_UPDATE_SAMPLER_TEXTURES:\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 936 | ' {\n', |
| 937 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 938 | ' VkUpdateSamplerTextures* pUST = (VkUpdateSamplerTextures*)pNext;\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 939 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 940 | ' pUST->pSamplerImageViews = (VK_SAMPLER_IMAGE_VIEW_INFO*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUST->pSamplerImageViews);\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 941 | ' uint32_t i;\n', |
| 942 | ' for (i = 0; i < pUST->count; i++) {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 943 | ' VkImageViewAttachInfo** ppLocalImageView = (VkImageViewAttachInfo**)&pUST->pSamplerImageViews[i].pImageView;\n', |
| 944 | ' *ppLocalImageView = (VkImageViewAttachInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUST->pSamplerImageViews[i].pImageView);\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 945 | ' }\n', |
| 946 | ' break;\n', |
| 947 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 948 | ' case VK_STRUCTURE_TYPE_UPDATE_IMAGES:\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 949 | ' {\n', |
| 950 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 951 | ' VkUpdateImages* pUI = (VkUpdateImages*)pNext;\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 952 | ' *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^] | 953 | ' VkImageViewAttachInfo** ppLocalImageView = (VkImageViewAttachInfo**)&pUI->pImageViews;\n', |
| 954 | ' *ppLocalImageView = (VkImageViewAttachInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUI->pImageViews);\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 955 | ' uint32_t i;\n', |
| 956 | ' for (i = 0; i < pUI->count; i++) {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 957 | ' VkImageViewAttachInfo** ppLocalImageViews = (VkImageViewAttachInfo**)&pUI->pImageViews[i];\n', |
| 958 | ' *ppLocalImageViews = (VkImageViewAttachInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUI->pImageViews[i]);\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 959 | ' }\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 960 | ' break;\n', |
| 961 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 962 | ' case VK_STRUCTURE_TYPE_UPDATE_BUFFERS:\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 963 | ' {\n', |
| 964 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 965 | ' VkUpdateBuffers* pUB = (VkUpdateBuffers*)pNext;\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 966 | ' *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^] | 967 | ' VkBufferViewAttachInfo** ppLocalBufferView = (VkBufferViewAttachInfo**)&pUB->pBufferViews;\n', |
| 968 | ' *ppLocalBufferView = (VkBufferViewAttachInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUB->pBufferViews);\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 969 | ' uint32_t i;\n', |
| 970 | ' for (i = 0; i < pUB->count; i++) {\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 971 | ' VkBufferViewAttachInfo** ppLocalBufferViews = (VkBufferViewAttachInfo**)&pUB->pBufferViews[i];\n', |
| 972 | ' *ppLocalBufferViews = (VkBufferViewAttachInfo*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pUB->pBufferViews[i]);\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 973 | ' }\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 974 | ' break;\n', |
| 975 | ' }\n', |
| 976 | ' default:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 977 | ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 978 | ' glv_LogError("Encountered an unexpected type in update descriptors pUpdateChain.\\n");\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 979 | ' pPacket->header = NULL;\n', |
| 980 | ' pNext->pNext = NULL;\n', |
| 981 | ' }\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 982 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 983 | ' pNext = (VkUpdateSamplers*)pNext->pNext;\n', |
| Tobin Ehlis | 9570fc4 | 2015-02-04 10:53:31 -0700 | [diff] [blame] | 984 | '}']}, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 985 | '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] | 986 | ' // need to make a non-const pointer to the pointer so that we can properly change the original pointer to the interpretted one\n', |
| 987 | ' void** ppNextVoidPtr = (void**)&pPacket->pCreateInfo->pNext;\n', |
| 988 | ' *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^] | 989 | ' VkPipelineShaderStageCreateInfo* pNext = (VkPipelineShaderStageCreateInfo*)pPacket->pCreateInfo->pNext;\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 990 | ' while ((NULL != pNext) && (VK_NULL_HANDLE != pNext))\n', '{\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 991 | ' switch(pNext->sType)\n', ' {\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 992 | ' case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO:\n', |
| 993 | ' case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO:\n', |
| 994 | ' case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO:\n', |
| 995 | ' case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO:\n', |
| 996 | ' case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO:\n', |
| 997 | ' case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 998 | ' {\n', |
| 999 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 1000 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| 1001 | ' break;\n', |
| 1002 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1003 | ' case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1004 | ' {\n', |
| 1005 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1006 | ' VkPipelineCbStateCreateInfo *pCb = (VkPipelineCbStateCreateInfo *) pNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1007 | ' *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^] | 1008 | ' 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] | 1009 | ' break;\n', |
| 1010 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1011 | ' case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1012 | ' {\n', |
| 1013 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| 1014 | ' *ppNextVoidPtr = (void*)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pNext->pNext);\n', |
| 1015 | ' interpret_pipeline_shader(pHeader, &pNext->shader);\n', |
| 1016 | ' break;\n', |
| 1017 | ' }\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1018 | ' case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO:\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1019 | ' {\n', |
| 1020 | ' void** ppNextVoidPtr = (void**)&pNext->pNext;\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1021 | ' VkPipelineVertexInputCreateInfo *pVi = (VkPipelineVertexInputCreateInfo *) pNext;\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1022 | ' *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^] | 1023 | ' pVi->pVertexBindingDescriptions = (VkVertexInputBindingDescription*) glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pVi->pVertexBindingDescriptions);\n', |
| 1024 | ' 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] | 1025 | ' break;\n', |
| 1026 | ' }\n', |
| 1027 | ' default:\n', |
| 1028 | ' {\n', |
| 1029 | ' glv_LogError("Encountered an unexpected type in pipeline state list.\\n");\n', |
| 1030 | ' pPacket->header = NULL;\n', |
| 1031 | ' pNext->pNext = NULL;\n', |
| 1032 | ' }\n', |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1033 | ' }\n', |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1034 | ' pNext = (VkPipelineShaderStageCreateInfo*)pNext->pNext;\n', |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1035 | ' }\n', |
| Peter Lohrmann | 7810957 | 2015-03-10 15:30:36 -0700 | [diff] [blame] | 1036 | '} else {\n', |
| 1037 | ' // This is unexpected.\n', |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1038 | ' 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] | 1039 | ' pPacket->header = NULL;\n', |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1040 | '}']}, |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1041 | 'CreateComputePipeline' : {'param': 'pCreateInfo', 'txt': ['interpret_pipeline_shader(pHeader, (VkPipelineShader*)(&pPacket->pCreateInfo->cs));']}} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1042 | if_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1043 | if_body.append('typedef struct struct_vkApiVersion {') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1044 | if_body.append(' glv_trace_packet_header* header;') |
| 1045 | if_body.append(' uint32_t version;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1046 | if_body.append('} struct_vkApiVersion;\n') |
| 1047 | 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] | 1048 | if_body.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1049 | if_body.append(' struct_vkApiVersion* pPacket = (struct_vkApiVersion*)pHeader->pBody;') |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1050 | if_body.append(' pPacket->header = pHeader;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1051 | if_body.append(' if (check_version && pPacket->version != VK_API_VERSION)') |
| 1052 | 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] | 1053 | if_body.append(' return pPacket;') |
| 1054 | if_body.append('}\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1055 | for proto in self.protos: |
| 1056 | if 'Wsi' not in proto.name and 'Dbg' not in proto.name: |
| 1057 | if 'UnmapMemory' == proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1058 | proto.params.append(vulkan.Param("void*", "pData")) |
| 1059 | if_body.append('typedef struct struct_vk%s {' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1060 | if_body.append(' glv_trace_packet_header* header;') |
| 1061 | for p in proto.params: |
| 1062 | if '[4]' in p.ty: |
| 1063 | if_body.append(' %s %s[4];' % (p.ty.strip('[4]'), p.name)) |
| 1064 | else: |
| 1065 | if_body.append(' %s %s;' % (p.ty, p.name)) |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1066 | if 'void' != proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1067 | if_body.append(' %s result;' % proto.ret) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1068 | if_body.append('} struct_vk%s;\n' % proto.name) |
| 1069 | 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] | 1070 | if_body.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1071 | 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] | 1072 | if_body.append(' pPacket->header = pHeader;') |
| 1073 | for p in proto.params: |
| 1074 | if '*' in p.ty: |
| Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 1075 | if 'DeviceCreateInfo' in p.ty: |
| 1076 | if_body.append(' pPacket->%s = interpret_VkDeviceCreateInfo(pHeader, (intptr_t)pPacket->%s);' % (p.name, p.name)) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1077 | else: |
| 1078 | 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] | 1079 | # TODO : Generalize this custom code to kill dict data struct above. |
| 1080 | # 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] | 1081 | if proto.name in custom_case_dict and p.name == custom_case_dict[proto.name]['param']: |
| 1082 | if_body.append(' if (pPacket->%s != NULL)' % custom_case_dict[proto.name]['param']) |
| 1083 | if_body.append(' {') |
| 1084 | if_body.append(' %s' % " ".join(custom_case_dict[proto.name]['txt'])) |
| 1085 | if_body.append(' }') |
| 1086 | if_body.append(' return pPacket;') |
| 1087 | if_body.append('}\n') |
| 1088 | return "\n".join(if_body) |
| 1089 | |
| 1090 | def _generate_interp_funcs_ext(self, func_class='Wsi'): |
| 1091 | if_body = [] |
| 1092 | for proto in self.protos: |
| 1093 | if func_class in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1094 | if_body.append('typedef struct struct_vk%s {' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1095 | if_body.append(' glv_trace_packet_header* pHeader;') |
| 1096 | for p in proto.params: |
| 1097 | if_body.append(' %s %s;' % (p.ty, p.name)) |
| Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 1098 | if 'void' != proto.ret: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1099 | if_body.append(' %s result;' % proto.ret) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1100 | if_body.append('} struct_vk%s;\n' % proto.name) |
| 1101 | 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] | 1102 | if_body.append('{') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1103 | 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] | 1104 | if_body.append(' pPacket->pHeader = pHeader;') |
| 1105 | for p in proto.params: |
| 1106 | if '*' in p.ty: |
| 1107 | if_body.append(' pPacket->%s = (%s)glv_trace_packet_interpret_buffer_pointer(pHeader, (intptr_t)pPacket->%s);' % (p.name, p.ty, p.name)) |
| 1108 | if_body.append(' return pPacket;') |
| 1109 | if_body.append('}\n') |
| 1110 | return "\n".join(if_body) |
| 1111 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1112 | def _generate_replay_func_ptrs(self): |
| 1113 | xf_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1114 | xf_body.append('struct vkFuncs {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1115 | xf_body.append(' void init_funcs(void * libHandle);') |
| 1116 | xf_body.append(' void *m_libHandle;\n') |
| 1117 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1118 | 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] | 1119 | for p in proto.params: |
| 1120 | if '[4]' in p.ty: |
| 1121 | xf_body.append(' %s %s[4],' % (p.ty.strip('[4]'), p.name)) |
| 1122 | else: |
| 1123 | xf_body.append(' %s %s,' % (p.ty, p.name)) |
| 1124 | xf_body[-1] = xf_body[-1].replace(',', ');') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1125 | 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] | 1126 | xf_body.append('};') |
| 1127 | return "\n".join(xf_body) |
| 1128 | |
| 1129 | def _map_decl(self, type1, type2, name): |
| 1130 | return ' std::map<%s, %s> %s;' % (type1, type2, name) |
| 1131 | |
| 1132 | def _add_to_map_decl(self, type1, type2, name): |
| 1133 | txt = ' void add_to_map(%s* pTraceVal, %s* pReplayVal)\n {\n' % (type1, type2) |
| 1134 | txt += ' assert(pTraceVal != NULL);\n' |
| 1135 | txt += ' assert(pReplayVal != NULL);\n' |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1136 | txt += ' %s[*pTraceVal] = *pReplayVal;\n }\n' % name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1137 | return txt |
| 1138 | |
| 1139 | def _rm_from_map_decl(self, ty, name): |
| 1140 | txt = ' void rm_from_map(const %s& key)\n {\n' % (ty) |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1141 | txt += ' %s.erase(key);\n }\n' % name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1142 | return txt |
| 1143 | |
| 1144 | def _remap_decl(self, ty, name): |
| 1145 | txt = ' %s remap(const %s& value)\n {\n' % (ty, ty) |
| 1146 | 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] | 1147 | 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] | 1148 | return txt |
| 1149 | |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1150 | def _generate_replay_objMemory_funcs(self): |
| 1151 | rof_body = [] |
| 1152 | # Custom code for memory mapping functions for app writes into mapped memory |
| 1153 | rof_body.append('// memory mapping functions for app writes into mapped memory') |
| 1154 | rof_body.append(' bool isPendingAlloc()') |
| 1155 | rof_body.append(' {') |
| 1156 | rof_body.append(' return m_pendingAlloc;') |
| 1157 | rof_body.append(' }') |
| 1158 | rof_body.append('') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1159 | rof_body.append(' void setAllocInfo(const VkMemoryAllocInfo *info, const bool pending)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1160 | rof_body.append(' {') |
| 1161 | rof_body.append(' m_pendingAlloc = pending;') |
| 1162 | rof_body.append(' m_allocInfo = *info;') |
| 1163 | rof_body.append(' }') |
| 1164 | rof_body.append('') |
| 1165 | rof_body.append(' void setMemoryDataAddr(void *pBuf)') |
| 1166 | rof_body.append(' {') |
| 1167 | rof_body.append(' if (m_mapRange.empty())') |
| 1168 | rof_body.append(' {') |
| 1169 | rof_body.append(' glv_LogError("gpuMemory::setMemoryDataAddr() m_mapRange is empty\\n");') |
| 1170 | rof_body.append(' return;') |
| 1171 | rof_body.append(' }') |
| 1172 | rof_body.append(' MapRange mr = m_mapRange.back();') |
| 1173 | rof_body.append(' if (mr.pData != NULL)') |
| 1174 | rof_body.append(' glv_LogWarn("gpuMemory::setMemoryDataAddr() data already mapped overwrite old mapping\\n");') |
| 1175 | rof_body.append(' else if (pBuf == NULL)') |
| 1176 | rof_body.append(' glv_LogWarn("gpuMemory::setMemoryDataAddr() adding NULL pointer\\n");') |
| 1177 | rof_body.append(' mr.pData = pBuf;') |
| 1178 | rof_body.append(' }') |
| 1179 | rof_body.append('') |
| 1180 | rof_body.append(' void setMemoryMapRange(void *pBuf, const size_t size, const size_t offset, const bool pending)') |
| 1181 | rof_body.append(' {') |
| 1182 | rof_body.append(' MapRange mr;') |
| 1183 | rof_body.append(' mr.pData = pBuf;') |
| 1184 | rof_body.append(' mr.size = size;') |
| 1185 | rof_body.append(' mr.offset = offset;') |
| 1186 | rof_body.append(' mr.pending = pending;') |
| 1187 | rof_body.append(' m_mapRange.push_back(mr);') |
| 1188 | rof_body.append(' }') |
| 1189 | rof_body.append('') |
| 1190 | rof_body.append(' void copyMappingData(const void* pSrcData)') |
| 1191 | rof_body.append(' {') |
| 1192 | rof_body.append(' if (m_mapRange.empty())') |
| 1193 | rof_body.append(' {') |
| 1194 | rof_body.append(' glv_LogError("gpuMemory::copyMappingData() m_mapRange is empty\\n");') |
| 1195 | rof_body.append(' return;') |
| 1196 | rof_body.append(' }') |
| 1197 | rof_body.append(' MapRange mr = m_mapRange.back();') |
| 1198 | rof_body.append(' if (!pSrcData || !mr.pData)') |
| 1199 | rof_body.append(' {') |
| 1200 | rof_body.append(' if (!pSrcData)') |
| 1201 | rof_body.append(' glv_LogError("gpuMemory::copyMappingData() null src pointer\\n");') |
| 1202 | rof_body.append(' else') |
| 1203 | rof_body.append(' glv_LogError("gpuMemory::copyMappingData() null dest pointer size=%u\\n", m_allocInfo.allocationSize);') |
| 1204 | rof_body.append(' m_mapRange.pop_back();') |
| 1205 | rof_body.append(' return;') |
| 1206 | rof_body.append(' }') |
| 1207 | rof_body.append(' memcpy(mr.pData, pSrcData, m_allocInfo.allocationSize);') |
| 1208 | rof_body.append(' if (!mr.pending)') |
| 1209 | rof_body.append(' m_mapRange.pop_back();') |
| 1210 | rof_body.append(' }') |
| 1211 | rof_body.append('') |
| 1212 | rof_body.append(' size_t getMemoryMapSize()') |
| 1213 | rof_body.append(' {') |
| 1214 | rof_body.append(' return (!m_mapRange.empty()) ? m_mapRange.back().size : 0;') |
| 1215 | rof_body.append(' }\n') |
| 1216 | return "\n".join(rof_body) |
| 1217 | |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1218 | def _generate_replay_objmapper_class(self): |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1219 | # 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] | 1220 | obj_map_dict = {} |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1221 | for ty in vulkan.object_type_list: |
| 1222 | if ty in vulkan.object_parent_list: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1223 | continue |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1224 | mem_var = ty.replace('VK_', '').lower() |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1225 | mem_var_list = mem_var.split('_') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1226 | mem_var = 'm_%s%ss' % (mem_var_list[0], "".join([m.title() for m in mem_var_list[1:]])) |
| 1227 | obj_map_dict[mem_var] = ty |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1228 | rc_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1229 | rc_body.append('typedef struct _VKAllocInfo {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1230 | rc_body.append(' VkGpuSize size;') |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 1231 | rc_body.append(' void *pData;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1232 | rc_body.append('} VKAllocInfo;') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1233 | rc_body.append('') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1234 | rc_body.append('class objMemory {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1235 | rc_body.append('public:') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1236 | rc_body.append(' objMemory() : m_numAllocations(0), m_pMemReqs(NULL) {}') |
| 1237 | rc_body.append(' ~objMemory() { free(m_pMemReqs);}') |
| 1238 | rc_body.append(' void setCount(const uint32_t num)') |
| 1239 | rc_body.append(' {') |
| 1240 | rc_body.append(' m_numAllocations = num;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1241 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1242 | rc_body.append(' void setReqs(const VkMemoryRequirements *pReqs, const uint32_t num)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1243 | rc_body.append(' {') |
| 1244 | rc_body.append(' if (m_numAllocations != num && m_numAllocations != 0)') |
| 1245 | rc_body.append(' glv_LogError("objMemory::setReqs, internal mismatch on number of allocations");') |
| 1246 | rc_body.append(' if (m_pMemReqs == NULL && pReqs != NULL)') |
| 1247 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1248 | rc_body.append(' m_pMemReqs = (VkMemoryRequirements *) glv_malloc(num * sizeof(VkMemoryRequirements));') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1249 | rc_body.append(' if (m_pMemReqs == NULL)') |
| 1250 | rc_body.append(' {') |
| 1251 | rc_body.append(' glv_LogError("objMemory::setReqs out of memory");') |
| 1252 | rc_body.append(' return;') |
| 1253 | rc_body.append(' }') |
| 1254 | rc_body.append(' memcpy(m_pMemReqs, pReqs, num);') |
| 1255 | rc_body.append(' }') |
| 1256 | rc_body.append(' }\n') |
| 1257 | rc_body.append('private:') |
| 1258 | rc_body.append(' uint32_t m_numAllocations;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1259 | rc_body.append(' VkMemoryRequirements *m_pMemReqs;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1260 | rc_body.append('};') |
| 1261 | rc_body.append('') |
| 1262 | rc_body.append('class gpuMemory {') |
| 1263 | rc_body.append('public:') |
| 1264 | rc_body.append(' gpuMemory() : m_pendingAlloc(false) {m_allocInfo.allocationSize = 0;}') |
| 1265 | rc_body.append(' ~gpuMemory() {}') |
| 1266 | rc_body.append(self._generate_replay_objMemory_funcs()) |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1267 | rc_body.append('private:') |
| 1268 | rc_body.append(' bool m_pendingAlloc;') |
| 1269 | rc_body.append(' struct MapRange {') |
| 1270 | rc_body.append(' bool pending;') |
| 1271 | rc_body.append(' size_t size;') |
| 1272 | rc_body.append(' size_t offset;') |
| 1273 | rc_body.append(' void* pData;') |
| 1274 | rc_body.append(' };') |
| 1275 | rc_body.append(' std::vector<MapRange> m_mapRange;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1276 | rc_body.append(' VkMemoryAllocInfo m_allocInfo;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1277 | rc_body.append('};') |
| 1278 | rc_body.append('') |
| 1279 | rc_body.append('typedef struct _imageObj {') |
| 1280 | rc_body.append(' objMemory imageMem;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1281 | rc_body.append(' VkImage replayImage;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1282 | rc_body.append(' } imageObj;') |
| 1283 | rc_body.append('') |
| 1284 | rc_body.append('typedef struct _bufferObj {') |
| 1285 | rc_body.append(' objMemory bufferMem;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1286 | rc_body.append(' VkBuffer replayBuffer;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1287 | rc_body.append(' } bufferObj;') |
| 1288 | rc_body.append('') |
| 1289 | rc_body.append('typedef struct _gpuMemObj {') |
| 1290 | rc_body.append(' gpuMemory *pGpuMem;') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1291 | rc_body.append(' VkGpuMemory replayGpuMem;') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1292 | rc_body.append(' } gpuMemObj;') |
| 1293 | rc_body.append('') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1294 | rc_body.append('class vkReplayObjMapper {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1295 | rc_body.append('public:') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1296 | rc_body.append(' vkReplayObjMapper() {}') |
| 1297 | rc_body.append(' ~vkReplayObjMapper() {}') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1298 | rc_body.append('') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1299 | rc_body.append(' bool m_adjustForGPU; // true if replay adjusts behavior based on GPU') |
| 1300 | # 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^] | 1301 | rc_body.append(' void init_objMemCount(const VkBaseObject& object, const uint32_t &num)\n {') |
| 1302 | rc_body.append(' VkImage img = static_cast <VkImage> (object);') |
| 1303 | 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] | 1304 | rc_body.append(' if (it != m_images.end())') |
| 1305 | rc_body.append(' {') |
| 1306 | rc_body.append(' objMemory obj = it->second.imageMem;') |
| 1307 | rc_body.append(' obj.setCount(num);') |
| 1308 | rc_body.append(' return;') |
| 1309 | rc_body.append(' }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1310 | rc_body.append(' VkBuffer buf = static_cast <VkBuffer> (object);') |
| 1311 | 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] | 1312 | rc_body.append(' if (itb != m_buffers.end())') |
| 1313 | rc_body.append(' {') |
| 1314 | rc_body.append(' objMemory obj = itb->second.bufferMem;') |
| 1315 | rc_body.append(' obj.setCount(num);') |
| 1316 | rc_body.append(' return;') |
| 1317 | rc_body.append(' }') |
| 1318 | rc_body.append(' return;') |
| 1319 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1320 | rc_body.append(' void init_objMemReqs(const VkBaseObject& object, const VkMemoryRequirements *pMemReqs, const unsigned int num)\n {') |
| 1321 | rc_body.append(' VkImage img = static_cast <VkImage> (object);') |
| 1322 | 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] | 1323 | rc_body.append(' if (it != m_images.end())') |
| 1324 | rc_body.append(' {') |
| 1325 | rc_body.append(' objMemory obj = it->second.imageMem;') |
| 1326 | rc_body.append(' obj.setReqs(pMemReqs, num);') |
| 1327 | rc_body.append(' return;') |
| 1328 | rc_body.append(' }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1329 | rc_body.append(' VkBuffer buf = static_cast <VkBuffer> (object);') |
| 1330 | 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] | 1331 | rc_body.append(' if (itb != m_buffers.end())') |
| 1332 | rc_body.append(' {') |
| 1333 | rc_body.append(' objMemory obj = itb->second.bufferMem;') |
| 1334 | rc_body.append(' obj.setReqs(pMemReqs, num);') |
| 1335 | rc_body.append(' return;') |
| 1336 | rc_body.append(' }') |
| 1337 | rc_body.append(' return;') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1338 | rc_body.append(' }') |
| 1339 | rc_body.append('') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1340 | rc_body.append(' void clear_all_map_handles()\n {') |
| 1341 | for var in sorted(obj_map_dict): |
| 1342 | rc_body.append(' %s.clear();' % var) |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1343 | rc_body.append(' }\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1344 | for var in sorted(obj_map_dict): |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1345 | if obj_map_dict[var] == 'VkImage': |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1346 | rc_body.append(self._map_decl(obj_map_dict[var], 'imageObj', var)) |
| 1347 | 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] | 1348 | 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^] | 1349 | rc_body.append(' VkImage remap(const VkImage& value)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1350 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1351 | 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] | 1352 | 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] | 1353 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1354 | elif obj_map_dict[var] == 'VkBuffer': |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1355 | rc_body.append(self._map_decl(obj_map_dict[var], 'bufferObj', var)) |
| 1356 | 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] | 1357 | 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^] | 1358 | rc_body.append(' VkBuffer remap(const VkBuffer& value)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1359 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1360 | 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] | 1361 | 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] | 1362 | rc_body.append(' }\n') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1363 | elif obj_map_dict[var] == 'VkGpuMemory': |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1364 | rc_body.append(self._map_decl(obj_map_dict[var], 'gpuMemObj', var)) |
| 1365 | 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] | 1366 | 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^] | 1367 | rc_body.append(' VkGpuMemory remap(const VkGpuMemory& value)') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1368 | rc_body.append(' {') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1369 | rc_body.append(' std::map<VkGpuMemory, gpuMemObj>::const_iterator q = m_gpuMemorys.find(value);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1370 | 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] | 1371 | rc_body.append(' }\n') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1372 | else: |
| 1373 | rc_body.append(self._map_decl(obj_map_dict[var], obj_map_dict[var], var)) |
| 1374 | rc_body.append(self._add_to_map_decl(obj_map_dict[var], obj_map_dict[var], var)) |
| 1375 | rc_body.append(self._rm_from_map_decl(obj_map_dict[var], var)) |
| 1376 | rc_body.append(self._remap_decl(obj_map_dict[var], var)) |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1377 | # VkDynamicStateObject code |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1378 | state_obj_remap_types = vulkan.object_dynamic_state_list |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1379 | rc_body.append(' VkDynamicStateObject remap(const VkDynamicStateObject& state)\n {') |
| 1380 | rc_body.append(' VkDynamicStateObject obj;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1381 | for t in state_obj_remap_types: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1382 | 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] | 1383 | rc_body.append(' return obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1384 | rc_body.append(' return VK_NULL_HANDLE;\n }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1385 | rc_body.append(' void rm_from_map(const VkDynamicStateObject& state)\n {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1386 | for t in state_obj_remap_types: |
| 1387 | rc_body.append(' rm_from_map(static_cast <%s> (state));' % t) |
| 1388 | rc_body.append(' }') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1389 | rc_body.append('') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1390 | # OBJECT code |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1391 | rc_body.append(' VkObject remap(const VkObject& object)\n {') |
| 1392 | rc_body.append(' VkObject obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1393 | obj_remap_types = vulkan.object_list |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1394 | for var in obj_remap_types: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1395 | 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] | 1396 | rc_body.append(' return obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1397 | rc_body.append(' return VK_NULL_HANDLE;\n }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1398 | rc_body.append(' void rm_from_map(const VkObject & objKey)\n {') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1399 | for var in obj_remap_types: |
| 1400 | rc_body.append(' rm_from_map(static_cast <%s> (objKey));' % (var)) |
| 1401 | rc_body.append(' }') |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1402 | rc_body.append(' VkBaseObject remap(const VkBaseObject& object)\n {') |
| 1403 | rc_body.append(' VkBaseObject obj;') |
| 1404 | base_obj_remap_types = ['VK_DEVICE', 'VK_QUEUE', 'VkGpuMemory', 'VkObject'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1405 | for t in base_obj_remap_types: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1406 | 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] | 1407 | rc_body.append(' return obj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1408 | rc_body.append(' return VK_NULL_HANDLE;') |
| Tony Barbour | b30dcd4 | 2015-02-02 13:21:18 -0700 | [diff] [blame] | 1409 | rc_body.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1410 | rc_body.append('};') |
| 1411 | return "\n".join(rc_body) |
| 1412 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1413 | def _generate_replay_init_funcs(self): |
| 1414 | rif_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1415 | 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] | 1416 | for proto in self.protos: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1417 | 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] | 1418 | rif_body.append('}') |
| 1419 | return "\n".join(rif_body) |
| 1420 | |
| 1421 | def _get_packet_param(self, t, n): |
| 1422 | # list of types that require remapping |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1423 | remap_list = vulkan.object_type_list |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1424 | param_exclude_list = ['p1', 'p2', 'pGpus', 'pDescriptorSets'] |
| 1425 | if t.strip('*').replace('const ', '') in remap_list and n not in param_exclude_list: |
| 1426 | if '*' in t: |
| 1427 | if 'const ' not in t: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1428 | return 'm_objMapper.remap(*pPacket->%s)' % (n) |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1429 | else: # TODO : Don't remap array ptrs? |
| 1430 | return 'pPacket->%s' % (n) |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1431 | return 'm_objMapper.remap(pPacket->%s)' % (n) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1432 | return 'pPacket->%s' % (n) |
| 1433 | |
| Tobin Ehlis | 45bc7f8 | 2015-01-16 15:13:34 -0700 | [diff] [blame] | 1434 | def _gen_replay_enum_gpus(self): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1435 | ieg_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1436 | ieg_body.append(' returnValue = manually_handle_vkEnumerateGpus(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1437 | return "\n".join(ieg_body) |
| 1438 | |
| 1439 | def _gen_replay_get_gpu_info(self): |
| 1440 | ggi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1441 | ggi_body.append(' returnValue = manually_handle_vkGetGpuInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1442 | return "\n".join(ggi_body) |
| 1443 | |
| 1444 | def _gen_replay_create_device(self): |
| 1445 | cd_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1446 | cd_body.append(' returnValue = manually_handle_vkCreateDevice(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1447 | return "\n".join(cd_body) |
| 1448 | |
| 1449 | def _gen_replay_get_extension_support(self): |
| 1450 | ges_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1451 | ges_body.append(' returnValue = manually_handle_vkGetExtensionSupport(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1452 | return "\n".join(ges_body) |
| 1453 | |
| 1454 | def _gen_replay_queue_submit(self): |
| 1455 | qs_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1456 | qs_body.append(' returnValue = manually_handle_vkQueueSubmit(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1457 | return "\n".join(qs_body) |
| 1458 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1459 | def _gen_replay_get_object_info(self): |
| 1460 | goi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1461 | goi_body.append(' returnValue = manually_handle_vkGetObjectInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1462 | return "\n".join(goi_body) |
| 1463 | |
| 1464 | def _gen_replay_get_format_info(self): |
| 1465 | gfi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1466 | gfi_body.append(' returnValue = manually_handle_vkGetFormatInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1467 | return "\n".join(gfi_body) |
| 1468 | |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1469 | def _gen_replay_create_image(self): |
| 1470 | ci_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1471 | ci_body.append(' imageObj local_imageObj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1472 | ci_body.append(' replayResult = m_vkFuncs.real_vkCreateImage(m_objMapper.remap(pPacket->device), pPacket->pCreateInfo, &local_imageObj.replayImage);') |
| 1473 | ci_body.append(' if (replayResult == VK_SUCCESS)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1474 | ci_body.append(' {') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1475 | ci_body.append(' m_objMapper.add_to_map(pPacket->pImage, &local_imageObj);') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1476 | ci_body.append(' }') |
| 1477 | return "\n".join(ci_body) |
| 1478 | |
| 1479 | def _gen_replay_create_buffer(self): |
| 1480 | cb_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1481 | cb_body.append(' bufferObj local_bufferObj;') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1482 | cb_body.append(' replayResult = m_vkFuncs.real_vkCreateBuffer(m_objMapper.remap(pPacket->device), pPacket->pCreateInfo, &local_bufferObj.replayBuffer);') |
| 1483 | cb_body.append(' if (replayResult == VK_SUCCESS)') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1484 | cb_body.append(' {') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1485 | cb_body.append(' m_objMapper.add_to_map(pPacket->pBuffer, &local_bufferObj);') |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1486 | cb_body.append(' }') |
| 1487 | return "\n".join(cb_body) |
| 1488 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1489 | def _gen_replay_get_image_subresource_info(self): |
| 1490 | isi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1491 | isi_body.append(' returnValue = manually_handle_vkGetImageSubresourceInfo(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1492 | return "\n".join(isi_body) |
| 1493 | |
| Tobin Ehlis | fc04b89 | 2015-01-22 12:29:31 -0700 | [diff] [blame] | 1494 | def _gen_replay_update_descriptors(self): |
| 1495 | ud_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1496 | ud_body.append(' returnValue = manually_handle_vkUpdateDescriptors(pPacket);') |
| Tobin Ehlis | 8361b56 | 2015-02-03 14:41:26 -0700 | [diff] [blame] | 1497 | return "\n".join(ud_body) |
| Tobin Ehlis | fc04b89 | 2015-01-22 12:29:31 -0700 | [diff] [blame] | 1498 | |
| 1499 | def _gen_replay_create_descriptor_set_layout(self): |
| 1500 | cdsl_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1501 | cdsl_body.append(' returnValue = manually_handle_vkCreateDescriptorSetLayout(pPacket);') |
| Tobin Ehlis | 8361b56 | 2015-02-03 14:41:26 -0700 | [diff] [blame] | 1502 | return "\n".join(cdsl_body) |
| Tobin Ehlis | fc04b89 | 2015-01-22 12:29:31 -0700 | [diff] [blame] | 1503 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1504 | def _gen_replay_create_graphics_pipeline(self): |
| 1505 | cgp_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1506 | cgp_body.append(' returnValue = manually_handle_vkCreateGraphicsPipeline(pPacket);') |
| Courtney Goeltzenleuchter | 32876a1 | 2015-03-25 15:37:49 -0600 | [diff] [blame] | 1507 | return "\n".join(cgp_body) |
| 1508 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1509 | def _gen_replay_cmd_wait_events(self): |
| 1510 | cwe_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1511 | cwe_body.append(' returnValue = manually_handle_vkCmdWaitEvents(pPacket);') |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1512 | return "\n".join(cwe_body) |
| 1513 | |
| Jon Ashburn | c46fc50 | 2015-02-10 10:36:22 -0700 | [diff] [blame] | 1514 | def _gen_replay_cmd_pipeline_barrier(self): |
| 1515 | cpb_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1516 | cpb_body.append(' returnValue = manually_handle_vkCmdPipelineBarrier(pPacket);') |
| Jon Ashburn | c46fc50 | 2015-02-10 10:36:22 -0700 | [diff] [blame] | 1517 | return "\n".join(cpb_body) |
| 1518 | |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1519 | def _gen_replay_create_framebuffer(self): |
| 1520 | cf_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1521 | cf_body.append(' returnValue = manually_handle_vkCreateFramebuffer(pPacket);') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1522 | return "\n".join(cf_body) |
| 1523 | |
| 1524 | def _gen_replay_create_renderpass(self): |
| 1525 | cr_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1526 | cr_body.append(' returnValue = manually_handle_vkCreateRenderPass(pPacket);') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1527 | return "\n".join(cr_body) |
| 1528 | |
| 1529 | def _gen_replay_begin_command_buffer(self): |
| 1530 | bcb_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1531 | bcb_body.append(' returnValue = manually_handle_vkBeginCommandBuffer(pPacket);') |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1532 | return "\n".join(bcb_body) |
| 1533 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1534 | def _gen_replay_store_pipeline(self): |
| 1535 | sp_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1536 | sp_body.append(' returnValue = manually_handle_vkStorePipeline(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1537 | return "\n".join(sp_body) |
| 1538 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1539 | def _gen_replay_get_multi_gpu_compatibility(self): |
| 1540 | gmgc_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1541 | gmgc_body.append(' returnValue = manually_handle_vkGetMultiGpuCompatibility(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1542 | return "\n".join(gmgc_body) |
| 1543 | |
| 1544 | def _gen_replay_destroy_object(self): |
| 1545 | do_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1546 | do_body.append(' returnValue = manually_handle_vkDestroyObject(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1547 | return "\n".join(do_body) |
| 1548 | |
| 1549 | def _gen_replay_wait_for_fences(self): |
| 1550 | wf_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1551 | wf_body.append(' returnValue = manually_handle_vkWaitForFences(pPacket);') |
| Mark Lobodzinski | ebe814d | 2015-04-07 16:07:57 -0500 | [diff] [blame] | 1552 | return "\n".join(wf_body) |
| 1553 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1554 | def _gen_replay_wsi_associate_connection(self): |
| 1555 | wac_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1556 | wac_body.append(' returnValue = manually_handle_vkWsiX11AssociateConnection(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1557 | return "\n".join(wac_body) |
| 1558 | |
| 1559 | def _gen_replay_wsi_get_msc(self): |
| 1560 | wgm_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1561 | wgm_body.append(' returnValue = manually_handle_vkWsiX11GetMSC(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1562 | return "\n".join(wgm_body) |
| 1563 | |
| 1564 | def _gen_replay_wsi_create_presentable_image(self): |
| 1565 | cpi_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1566 | cpi_body.append(' returnValue = manually_handle_vkWsiX11CreatePresentableImage(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1567 | return "\n".join(cpi_body) |
| 1568 | |
| 1569 | def _gen_replay_wsi_queue_present(self): |
| 1570 | wqp_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1571 | wqp_body.append(' returnValue = manually_handle_vkWsiX11QueuePresent(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1572 | return "\n".join(wqp_body) |
| 1573 | |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1574 | def _gen_replay_alloc_memory(self): |
| 1575 | am_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1576 | am_body.append(' gpuMemObj local_mem;') |
| 1577 | am_body.append(' if (!m_objMapper.m_adjustForGPU)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1578 | am_body.append(' replayResult = m_vkFuncs.real_vkAllocMemory(m_objMapper.remap(pPacket->device), pPacket->pAllocInfo, &local_mem.replayGpuMem);') |
| 1579 | am_body.append(' if (replayResult == VK_SUCCESS || m_objMapper.m_adjustForGPU)') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1580 | am_body.append(' {') |
| Jon Ashburn | cce1cb5 | 2015-03-26 16:15:18 -0600 | [diff] [blame] | 1581 | am_body.append(' local_mem.pGpuMem = new (gpuMemory);') |
| 1582 | am_body.append(' if (local_mem.pGpuMem)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1583 | am_body.append(' local_mem.pGpuMem->setAllocInfo(pPacket->pAllocInfo, m_objMapper.m_adjustForGPU);') |
| 1584 | am_body.append(' m_objMapper.add_to_map(pPacket->pMem, &local_mem);') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1585 | am_body.append(' }') |
| 1586 | return "\n".join(am_body) |
| 1587 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1588 | def _gen_replay_free_memory(self): |
| 1589 | fm_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1590 | fm_body.append(' returnValue = manually_handle_vkFreeMemory(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1591 | return "\n".join(fm_body) |
| 1592 | |
| 1593 | def _gen_replay_map_memory(self): |
| 1594 | mm_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1595 | mm_body.append(' returnValue = manually_handle_vkMapMemory(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1596 | return "\n".join(mm_body) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1597 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1598 | def _gen_replay_unmap_memory(self): |
| 1599 | um_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1600 | um_body.append(' returnValue = manually_handle_vkUnmapMemory(pPacket);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1601 | return "\n".join(um_body) |
| 1602 | |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1603 | def _gen_replay_pin_system_memory(self): |
| 1604 | psm_body = [] |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1605 | psm_body.append(' gpuMemObj local_mem;') |
| Jon Ashburn | d4daf59 | 2015-03-27 16:23:47 -0600 | [diff] [blame] | 1606 | 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] | 1607 | psm_body.append(' replayResult = m_vkFuncs.real_vkPinSystemMemory(m_objMapper.remap(pPacket->device), pPacket->pSysMem, pPacket->memSize, &local_mem.replayGpuMem);') |
| 1608 | psm_body.append(' if (replayResult == VK_SUCCESS)') |
| Peter Lohrmann | e59ba28 | 2015-04-06 14:14:44 -0700 | [diff] [blame] | 1609 | psm_body.append(' m_objMapper.add_to_map(pPacket->pMem, &local_mem);') |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1610 | return "\n".join(psm_body) |
| 1611 | |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1612 | # 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] | 1613 | def _gen_replay_bind_dynamic_memory_view(self): |
| 1614 | bdmv_body = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1615 | bdmv_body.append(' VK_MEMORY_VIEW_ATTACH_INFO memView;') |
| 1616 | 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] | 1617 | bdmv_body.append(' memView.mem = m_objMapper.remap(pPacket->pMemView->mem);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1618 | 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] | 1619 | return "\n".join(bdmv_body) |
| 1620 | |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1621 | # 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] | 1622 | def _generate_replay(self): |
| 1623 | # map protos to custom functions if body is fully custom |
| Tobin Ehlis | 45bc7f8 | 2015-01-16 15:13:34 -0700 | [diff] [blame] | 1624 | custom_body_dict = {'EnumerateGpus': self._gen_replay_enum_gpus, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1625 | 'GetGpuInfo': self._gen_replay_get_gpu_info, |
| 1626 | 'CreateDevice': self._gen_replay_create_device, |
| 1627 | 'GetExtensionSupport': self._gen_replay_get_extension_support, |
| 1628 | 'QueueSubmit': self._gen_replay_queue_submit, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1629 | 'GetObjectInfo': self._gen_replay_get_object_info, |
| 1630 | 'GetFormatInfo': self._gen_replay_get_format_info, |
| Jon Ashburn | 7f8acc7 | 2015-03-23 09:27:33 -0600 | [diff] [blame] | 1631 | 'CreateImage': self._gen_replay_create_image, |
| 1632 | 'CreateBuffer': self._gen_replay_create_buffer, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1633 | 'GetImageSubresourceInfo': self._gen_replay_get_image_subresource_info, |
| 1634 | 'CreateGraphicsPipeline': self._gen_replay_create_graphics_pipeline, |
| Jon Ashburn | a02bc24 | 2015-01-02 18:28:26 -0700 | [diff] [blame] | 1635 | 'CreateFramebuffer': self._gen_replay_create_framebuffer, |
| 1636 | 'CreateRenderPass': self._gen_replay_create_renderpass, |
| 1637 | 'BeginCommandBuffer': self._gen_replay_begin_command_buffer, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1638 | 'StorePipeline': self._gen_replay_store_pipeline, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1639 | 'GetMultiGpuCompatibility': self._gen_replay_get_multi_gpu_compatibility, |
| 1640 | 'DestroyObject': self._gen_replay_destroy_object, |
| 1641 | 'WaitForFences': self._gen_replay_wait_for_fences, |
| 1642 | 'WsiX11AssociateConnection': self._gen_replay_wsi_associate_connection, |
| 1643 | 'WsiX11GetMSC': self._gen_replay_wsi_get_msc, |
| 1644 | 'WsiX11CreatePresentableImage': self._gen_replay_wsi_create_presentable_image, |
| 1645 | 'WsiX11QueuePresent': self._gen_replay_wsi_queue_present, |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1646 | 'AllocMemory': self._gen_replay_alloc_memory, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1647 | 'FreeMemory': self._gen_replay_free_memory, |
| 1648 | 'MapMemory': self._gen_replay_map_memory, |
| 1649 | 'UnmapMemory': self._gen_replay_unmap_memory, |
| Jon Ashburn | 16239cd | 2015-03-24 11:05:02 -0600 | [diff] [blame] | 1650 | 'PinSystemMemory': self._gen_replay_pin_system_memory, |
| Tobin Ehlis | 8361b56 | 2015-02-03 14:41:26 -0700 | [diff] [blame] | 1651 | 'CmdBindDynamicMemoryView': self._gen_replay_bind_dynamic_memory_view, |
| 1652 | 'UpdateDescriptors': self._gen_replay_update_descriptors, |
| Tobin Ehlis | 5099051 | 2015-02-05 11:29:45 -0700 | [diff] [blame] | 1653 | 'CreateDescriptorSetLayout': self._gen_replay_create_descriptor_set_layout, |
| Jon Ashburn | c46fc50 | 2015-02-10 10:36:22 -0700 | [diff] [blame] | 1654 | 'CmdWaitEvents': self._gen_replay_cmd_wait_events, |
| 1655 | 'CmdPipelineBarrier': self._gen_replay_cmd_pipeline_barrier} |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1656 | # TODO : Need to guard CreateInstance with "if (!m_display->m_initedVK)" check |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1657 | # Despite returning a value, don't check these funcs b/c custom code includes check already |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 1658 | custom_check_ret_val = ['EnumerateGpus', 'GetGpuInfo', 'CreateDevice', 'GetExtensionSupport', 'QueueSubmit', 'GetObjectInfo', |
| 1659 | 'GetFormatInfo', 'GetImageSubresourceInfo', 'CreateDescriptorSetLayout', 'CreateGraphicsPipeline', |
| 1660 | 'CreateFramebuffer', 'CreateRenderPass', 'BeginCommandBuffer', 'StorePipeline', 'GetMultiGpuCompatibility', |
| Peter Lohrmann | 95c369a | 2015-04-02 10:06:19 -0700 | [diff] [blame] | 1661 | 'DestroyObject', 'WaitForFences', 'FreeMemory', 'MapMemory', 'UnmapMemory', |
| 1662 | 'WsiX11AssociateConnection', 'WsiX11GetMSC', 'WsiX11CreatePresentableImage', 'WsiX11QueuePresent'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1663 | # multi-gpu Open funcs w/ list of local params to create |
| 1664 | custom_open_params = {'OpenSharedMemory': (-1,), |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1665 | 'OpenSharedQueueSemaphore': (-1,), |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1666 | 'OpenPeerMemory': (-1,), |
| 1667 | 'OpenPeerImage': (-1, -2,)} |
| 1668 | # Functions that create views are unique from other create functions |
| Jon Ashburn | b1b63ed | 2015-02-03 11:24:08 -0700 | [diff] [blame] | 1669 | create_view_list = ['CreateBufferView', 'CreateImageView', 'CreateColorAttachmentView', 'CreateDepthStencilView', 'CreateComputePipeline'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1670 | # Functions to treat as "Create' that don't have 'Create' in the name |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1671 | special_create_list = ['LoadPipeline', 'AllocMemory', 'GetDeviceQueue', 'PinSystemMemory', 'AllocDescriptorSets'] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1672 | # A couple funcs use do while loops |
| Tobin Ehlis | 3ef0270 | 2015-04-15 11:51:51 -0600 | [diff] [blame^] | 1673 | do_while_dict = {'GetFenceStatus': 'replayResult != pPacket->result && pPacket->result == VK_SUCCESS', 'GetEventStatus': '(pPacket->result == VkEvent_SET || pPacket->result == VkEvent_RESET) && replayResult != pPacket->result'} |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1674 | rbody = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1675 | 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] | 1676 | rbody.append('{') |
| 1677 | 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] | 1678 | rbody.append(' VkResult replayResult = VK_ERROR_UNKNOWN;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1679 | rbody.append(' switch (packet->packet_id)') |
| 1680 | rbody.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1681 | rbody.append(' case GLV_TPI_VK_vkApiVersion:') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1682 | rbody.append(' break; // nothing to replay on the version packet') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1683 | for proto in self.protos: |
| 1684 | ret_value = False |
| 1685 | create_view = False |
| 1686 | create_func = False |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1687 | # TODO : How to handle void* return of GetProcAddr? |
| 1688 | 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] | 1689 | ret_value = True |
| 1690 | if proto.name in create_view_list: |
| 1691 | create_view = True |
| 1692 | elif 'Create' in proto.name or proto.name in special_create_list: |
| 1693 | create_func = True |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1694 | rbody.append(' case GLV_TPI_VK_vk%s:' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1695 | rbody.append(' {') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1696 | 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] | 1697 | if proto.name in custom_body_dict: |
| 1698 | rbody.append(custom_body_dict[proto.name]()) |
| 1699 | else: |
| 1700 | if proto.name in custom_open_params: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1701 | rbody.append(' VK_DEVICE handle;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1702 | for pidx in custom_open_params[proto.name]: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1703 | 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] | 1704 | rbody.append(' handle = m_objMapper.remap(pPacket->device);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1705 | elif create_view: |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1706 | rbody.append(' %s createInfo;' % (proto.params[1].ty.strip('*').replace('const ', ''))) |
| 1707 | 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] | 1708 | if 'CreateComputePipeline' == proto.name: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1709 | rbody.append(' createInfo.cs.shader = m_objMapper.remap(pPacket->pCreateInfo->cs.shader);') |
| Jon Ashburn | b1b63ed | 2015-02-03 11:24:08 -0700 | [diff] [blame] | 1710 | elif 'CreateBufferView' == proto.name: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1711 | rbody.append(' createInfo.buffer = m_objMapper.remap(pPacket->pCreateInfo->buffer);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1712 | else: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1713 | rbody.append(' createInfo.image = m_objMapper.remap(pPacket->pCreateInfo->image);') |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1714 | 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] | 1715 | elif create_func: # Declare local var to store created handle into |
| Tobin Ehlis | 2012fce | 2015-01-15 17:53:54 -0700 | [diff] [blame] | 1716 | 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] | 1717 | if 'AllocDescriptorSets' == proto.name: |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1718 | rbody.append(' %s local_%s[100];' % (proto.params[-2].ty.strip('*').replace('const ', ''), proto.params[-2].name)) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1719 | rbody.append(' VK_DESCRIPTOR_SET_LAYOUT localDescSets[100];') |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1720 | rbody.append(' assert(pPacket->count <= 100);') |
| 1721 | rbody.append(' for (uint32_t i = 0; i < pPacket->count; i++)') |
| 1722 | rbody.append(' {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1723 | 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] | 1724 | rbody.append(' }') |
| 1725 | elif proto.name == 'ClearDescriptorSets': |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1726 | rbody.append(' VK_DESCRIPTOR_SET localDescSets[100];') |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1727 | rbody.append(' assert(pPacket->count <= 100);') |
| 1728 | rbody.append(' for (uint32_t i = 0; i < pPacket->count; i++)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1729 | rbody.append(' {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1730 | 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] | 1731 | rbody.append(' }') |
| 1732 | elif proto.name in do_while_dict: |
| 1733 | rbody.append(' do {') |
| Jon Ashburn | ffd5f14 | 2015-02-03 13:39:05 -0700 | [diff] [blame] | 1734 | elif proto.name == 'EnumerateLayers': |
| 1735 | rbody.append(' char **bufptr = GLV_NEW_ARRAY(char *, pPacket->maxLayerCount);') |
| 1736 | rbody.append(' char **ptrLayers = (pPacket->pOutLayers == NULL) ? bufptr : (char **) pPacket->pOutLayers;') |
| 1737 | rbody.append(' for (unsigned int i = 0; i < pPacket->maxLayerCount; i++)') |
| 1738 | rbody.append(' bufptr[i] = GLV_NEW_ARRAY(char, pPacket->maxStringSize);') |
| Jon Ashburn | d698ca2 | 2015-02-12 12:37:46 -0700 | [diff] [blame] | 1739 | elif proto.name == 'DestroyInstance': |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1740 | rbody.append(' vkDbgUnregisterMsgCallback(g_fpDbgMsgCallback);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1741 | rr_string = ' ' |
| 1742 | if ret_value: |
| 1743 | rr_string = ' replayResult = ' |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1744 | rr_string += 'm_vkFuncs.real_vk%s(' % proto.name |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1745 | for p in proto.params: |
| 1746 | # For last param of Create funcs, pass address of param |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1747 | if create_func: |
| 1748 | if p.name == proto.params[-1].name: |
| 1749 | rr_string += '&local_%s, ' % p.name |
| 1750 | elif proto.name == 'AllocDescriptorSets' and p.name == proto.params[-2].name: |
| 1751 | rr_string += 'local_%s, ' % p.name |
| 1752 | else: |
| 1753 | rr_string += '%s, ' % self._get_packet_param(p.ty, p.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1754 | else: |
| 1755 | rr_string += '%s, ' % self._get_packet_param(p.ty, p.name) |
| 1756 | rr_string = '%s);' % rr_string[:-2] |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1757 | if proto.name in custom_open_params: |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1758 | rr_list = rr_string.split(', ') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1759 | 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] | 1760 | for pidx in custom_open_params[proto.name]: |
| 1761 | rr_list[pidx] = '&local_%s' % proto.params[pidx].name |
| 1762 | rr_string = ', '.join(rr_list) |
| 1763 | rr_string += ');' |
| 1764 | elif create_view: |
| 1765 | rr_list = rr_string.split(', ') |
| 1766 | rr_list[-2] = '&createInfo' |
| 1767 | rr_list[-1] = '&local_%s);' % proto.params[-1].name |
| 1768 | rr_string = ', '.join(rr_list) |
| 1769 | # this is a sneaky shortcut to use generic create code below to add_to_map |
| 1770 | create_func = True |
| Jon Ashburn | ffd5f14 | 2015-02-03 13:39:05 -0700 | [diff] [blame] | 1771 | elif proto.name == 'EnumerateLayers': |
| 1772 | rr_string = rr_string.replace('pPacket->pOutLayers', 'ptrLayers') |
| Jon Ashburn | 200ccb5 | 2015-02-04 12:57:25 -0700 | [diff] [blame] | 1773 | elif proto.name == 'ClearDescriptorSets': |
| 1774 | rr_string = rr_string.replace('pPacket->pDescriptorSets', 'localDescSets') |
| 1775 | elif proto.name == 'AllocDescriptorSets': |
| 1776 | rr_string = rr_string.replace('pPacket->pSetLayouts', 'localDescSets') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1777 | rbody.append(rr_string) |
| 1778 | if 'DestroyDevice' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1779 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1780 | rbody.append(' {') |
| Peter Lohrmann | 53e8924 | 2015-02-27 15:35:15 -0800 | [diff] [blame] | 1781 | rbody.append(' m_pCBDump = NULL;') |
| 1782 | rbody.append(' m_pDSDump = NULL;') |
| Peter Lohrmann | caf39d5 | 2015-03-24 17:19:24 -0700 | [diff] [blame] | 1783 | rbody.append(' m_pGlvSnapshotPrint = NULL;') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1784 | rbody.append(' m_objMapper.rm_from_map(pPacket->device);') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1785 | rbody.append(' m_display->m_initedVK = false;') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1786 | rbody.append(' }') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1787 | if 'DestroyInstance' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1788 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1789 | rbody.append(' {') |
| Jon Ashburn | 6f58a16 | 2015-02-03 09:17:12 -0700 | [diff] [blame] | 1790 | rbody.append(' // TODO need to handle multiple instances and only clearing maps within an instance.') |
| 1791 | 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] | 1792 | rbody.append(' m_objMapper.clear_all_map_handles();') |
| Jon Ashburn | 6f4b303 | 2015-02-03 08:57:28 -0700 | [diff] [blame] | 1793 | rbody.append(' }') |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1794 | elif 'AllocDescriptorSets' in proto.name: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1795 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Tobin Ehlis | 377b462 | 2015-01-20 13:50:59 -0700 | [diff] [blame] | 1796 | rbody.append(' {') |
| 1797 | rbody.append(' for (uint32_t i = 0; i < local_pCount; i++) {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1798 | 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] | 1799 | rbody.append(' }') |
| 1800 | rbody.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1801 | elif create_func: # save handle mapping if create successful |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1802 | rbody.append(' if (replayResult == VK_SUCCESS)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1803 | rbody.append(' {') |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1804 | 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] | 1805 | if 'AllocMemory' == proto.name: |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 1806 | 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] | 1807 | rbody.append(' }') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1808 | elif proto.name in do_while_dict: |
| 1809 | rbody[-1] = ' %s' % rbody[-1] |
| 1810 | rbody.append(' } while (%s);' % do_while_dict[proto.name]) |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1811 | rbody.append(' if (pPacket->result != VK_NOT_READY || replayResult != VK_SUCCESS)') |
| Jon Ashburn | ffd5f14 | 2015-02-03 13:39:05 -0700 | [diff] [blame] | 1812 | elif proto.name == 'EnumerateLayers': |
| 1813 | rbody.append(' for (unsigned int i = 0; i < pPacket->maxLayerCount; i++)') |
| 1814 | rbody.append(' GLV_DELETE(bufptr[i]);') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1815 | if ret_value: |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1816 | rbody.append(' CHECK_RETURN_VALUE(vk%s);' % proto.name) |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1817 | if 'MsgCallback' in proto.name: |
| 1818 | rbody.pop() |
| 1819 | rbody.pop() |
| 1820 | rbody.pop() |
| 1821 | rbody.append(' // Just eating these calls as no way to restore dbg func ptr.') |
| 1822 | rbody.append(' break;') |
| 1823 | rbody.append(' }') |
| 1824 | rbody.append(' default:') |
| 1825 | rbody.append(' glv_LogWarn("Unrecognized packet_id %u, skipping\\n", packet->packet_id);') |
| 1826 | rbody.append(' returnValue = glv_replay::GLV_REPLAY_INVALID_ID;') |
| 1827 | rbody.append(' break;') |
| 1828 | rbody.append(' }') |
| 1829 | rbody.append(' return returnValue;') |
| 1830 | rbody.append('}') |
| 1831 | return "\n".join(rbody) |
| 1832 | |
| 1833 | class GlaveTraceHeader(Subcommand): |
| 1834 | def generate_header(self): |
| 1835 | header_txt = [] |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 1836 | header_txt.append('#include "glv_vk_vk_structs.h"') |
| 1837 | header_txt.append('#include "glv_vk_packet_id.h"\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1838 | header_txt.append('void AttachHooks();') |
| 1839 | header_txt.append('void DetachHooks();') |
| Ian Elliott | bc9ca5f | 2015-02-27 11:10:59 -0700 | [diff] [blame] | 1840 | header_txt.append('void InitTracer(void);\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1841 | return "\n".join(header_txt) |
| 1842 | |
| 1843 | def generate_body(self): |
| 1844 | body = [self._generate_trace_func_ptrs(), |
| Peter Lohrmann | 358d009 | 2015-04-03 12:03:44 -0700 | [diff] [blame] | 1845 | self._generate_trace_func_protos(), |
| 1846 | self._generate_trace_real_func_ptr_protos()] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1847 | |
| 1848 | return "\n".join(body) |
| 1849 | |
| 1850 | class GlaveTraceC(Subcommand): |
| 1851 | def generate_header(self): |
| 1852 | header_txt = [] |
| 1853 | header_txt.append('#include "glv_platform.h"') |
| 1854 | header_txt.append('#include "glv_common.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1855 | header_txt.append('#include "glvtrace_vk_helpers.h"') |
| 1856 | header_txt.append('#include "glvtrace_vk_vk.h"') |
| 1857 | header_txt.append('#include "glvtrace_vk_vkdbg.h"') |
| 1858 | header_txt.append('#include "glvtrace_vk_vkwsix11ext.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1859 | header_txt.append('#include "glv_interconnect.h"') |
| 1860 | header_txt.append('#include "glv_filelike.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1861 | header_txt.append('#include "vk_struct_size_helper.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1862 | header_txt.append('#ifdef WIN32') |
| 1863 | header_txt.append('#include "mhook/mhook-lib/mhook.h"') |
| 1864 | header_txt.append('#endif') |
| 1865 | header_txt.append('#include "glv_trace_packet_utils.h"') |
| 1866 | header_txt.append('#include <stdio.h>\n') |
| 1867 | return "\n".join(header_txt) |
| 1868 | |
| 1869 | def generate_body(self): |
| 1870 | body = [self._generate_func_ptr_assignments(), |
| 1871 | self._generate_attach_hooks(), |
| 1872 | self._generate_detach_hooks(), |
| Jon Ashburn | e224839 | 2014-12-16 18:37:04 -0700 | [diff] [blame] | 1873 | self._generate_init_funcs(), |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1874 | self._generate_trace_funcs()] |
| 1875 | |
| 1876 | return "\n".join(body) |
| 1877 | |
| 1878 | class GlavePacketID(Subcommand): |
| 1879 | def generate_header(self): |
| 1880 | header_txt = [] |
| 1881 | header_txt.append('#pragma once\n') |
| 1882 | header_txt.append('#include "glv_trace_packet_utils.h"') |
| 1883 | header_txt.append('#include "glv_trace_packet_identifiers.h"') |
| 1884 | header_txt.append('#include "glv_interconnect.h"') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 1885 | header_txt.append('#include "glv_vk_vk_structs.h"') |
| 1886 | header_txt.append('#include "glv_vk_vkdbg_structs.h"') |
| 1887 | header_txt.append('#include "glv_vk_vkwsix11ext_structs.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1888 | header_txt.append('#include "vk_enum_string_helper.h"') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 1889 | header_txt.append('#if defined(WIN32)') |
| 1890 | header_txt.append('#define snprintf _snprintf') |
| 1891 | header_txt.append('#endif') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1892 | header_txt.append('#define SEND_ENTRYPOINT_ID(entrypoint) ;') |
| 1893 | header_txt.append('//#define SEND_ENTRYPOINT_ID(entrypoint) glv_TraceInfo(#entrypoint "\\n");\n') |
| 1894 | header_txt.append('#define SEND_ENTRYPOINT_PARAMS(entrypoint, ...) ;') |
| 1895 | header_txt.append('//#define SEND_ENTRYPOINT_PARAMS(entrypoint, ...) glv_TraceInfo(entrypoint, __VA_ARGS__);\n') |
| 1896 | header_txt.append('#define CREATE_TRACE_PACKET(entrypoint, buffer_bytes_needed) \\') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1897 | 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] | 1898 | header_txt.append('#define FINISH_TRACE_PACKET() \\') |
| 1899 | header_txt.append(' glv_finalize_trace_packet(pHeader); \\') |
| 1900 | header_txt.append(' glv_write_trace_packet(pHeader, glv_trace_get_trace_file()); \\') |
| 1901 | header_txt.append(' glv_delete_trace_packet(&pHeader);') |
| 1902 | return "\n".join(header_txt) |
| 1903 | |
| 1904 | def generate_body(self): |
| 1905 | body = [self._generate_packet_id_enum(), |
| 1906 | self._generate_stringify_func(), |
| 1907 | self._generate_interp_func()] |
| 1908 | |
| 1909 | return "\n".join(body) |
| 1910 | |
| 1911 | class GlaveCoreStructs(Subcommand): |
| 1912 | def generate_header(self): |
| 1913 | header_txt = [] |
| 1914 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1915 | header_txt.append('#include "vulkan.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1916 | header_txt.append('#include "glv_trace_packet_utils.h"\n') |
| 1917 | return "\n".join(header_txt) |
| 1918 | |
| 1919 | def generate_body(self): |
| 1920 | body = [self._generate_struct_util_funcs(), |
| 1921 | self._generate_interp_funcs()] |
| 1922 | |
| 1923 | return "\n".join(body) |
| 1924 | |
| 1925 | class GlaveWsiHeader(Subcommand): |
| 1926 | def generate_header(self): |
| 1927 | header_txt = [] |
| 1928 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1929 | header_txt.append('#include "vulkan.h"') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 1930 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1931 | header_txt.append('#include "vkWsiX11Ext.h"\n') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1932 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1933 | header_txt.append('#include "vkWsiWinExt.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1934 | header_txt.append('#endif') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1935 | header_txt.append('void AttachHooks_vkwsix11ext();') |
| 1936 | header_txt.append('void DetachHooks_vkwsix11ext();') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1937 | return "\n".join(header_txt) |
| 1938 | |
| 1939 | def generate_body(self): |
| 1940 | body = [self._generate_trace_func_ptrs_ext(), |
| 1941 | self._generate_trace_func_protos_ext()] |
| 1942 | |
| 1943 | return "\n".join(body) |
| 1944 | |
| 1945 | class GlaveWsiC(Subcommand): |
| 1946 | def generate_header(self): |
| 1947 | header_txt = [] |
| 1948 | header_txt.append('#include "glv_platform.h"') |
| 1949 | header_txt.append('#include "glv_common.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1950 | header_txt.append('#include "glvtrace_vk_vkwsix11ext.h"') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 1951 | header_txt.append('#include "glv_vk_vkwsix11ext_structs.h"') |
| 1952 | header_txt.append('#include "glv_vk_packet_id.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1953 | header_txt.append('#ifdef WIN32') |
| 1954 | header_txt.append('#include "mhook/mhook-lib/mhook.h"') |
| 1955 | header_txt.append('#endif') |
| 1956 | return "\n".join(header_txt) |
| 1957 | |
| 1958 | def generate_body(self): |
| 1959 | body = [self._generate_func_ptr_assignments_ext(), |
| 1960 | self._generate_attach_hooks_ext(), |
| 1961 | self._generate_detach_hooks_ext(), |
| 1962 | self._generate_trace_funcs_ext()] |
| 1963 | |
| 1964 | return "\n".join(body) |
| 1965 | |
| 1966 | class GlaveWsiStructs(Subcommand): |
| 1967 | def generate_header(self): |
| 1968 | header_txt = [] |
| 1969 | header_txt.append('#pragma once\n') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 1970 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1971 | header_txt.append('#include "vkWsiX11Ext.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1972 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1973 | header_txt.append('#include "vkWsiWinExt.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 1974 | header_txt.append('#endif') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1975 | header_txt.append('#include "glv_trace_packet_utils.h"\n') |
| 1976 | return "\n".join(header_txt) |
| 1977 | |
| 1978 | def generate_body(self): |
| 1979 | body = [self._generate_interp_funcs_ext()] |
| 1980 | |
| 1981 | return "\n".join(body) |
| 1982 | |
| 1983 | class GlaveDbgHeader(Subcommand): |
| 1984 | def generate_header(self): |
| 1985 | header_txt = [] |
| 1986 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 1987 | header_txt.append('#include "vulkan.h"') |
| 1988 | header_txt.append('#include "vkDbg.h"\n') |
| 1989 | header_txt.append('void AttachHooks_vkdbg();') |
| 1990 | header_txt.append('void DetachHooks_vkdbg();') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 1991 | return "\n".join(header_txt) |
| 1992 | |
| 1993 | def generate_body(self): |
| 1994 | body = [self._generate_trace_func_ptrs_ext('Dbg'), |
| 1995 | self._generate_trace_func_protos_ext('Dbg')] |
| 1996 | |
| 1997 | return "\n".join(body) |
| 1998 | |
| 1999 | class GlaveDbgC(Subcommand): |
| 2000 | def generate_header(self): |
| 2001 | header_txt = [] |
| 2002 | header_txt.append('#include "glv_platform.h"') |
| 2003 | header_txt.append('#include "glv_common.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2004 | header_txt.append('#include "glvtrace_vk_vk.h"') |
| 2005 | header_txt.append('#include "glvtrace_vk_vkdbg.h"') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 2006 | header_txt.append('#include "glv_vk_vkdbg_structs.h"') |
| 2007 | header_txt.append('#include "glv_vk_packet_id.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2008 | header_txt.append('#ifdef WIN32') |
| 2009 | header_txt.append('#include "mhook/mhook-lib/mhook.h"') |
| 2010 | header_txt.append('#endif') |
| 2011 | return "\n".join(header_txt) |
| 2012 | |
| 2013 | def generate_body(self): |
| 2014 | body = [self._generate_func_ptr_assignments_ext('Dbg'), |
| 2015 | self._generate_attach_hooks_ext('Dbg'), |
| 2016 | self._generate_detach_hooks_ext('Dbg'), |
| 2017 | self._generate_trace_funcs_ext('Dbg')] |
| 2018 | |
| 2019 | return "\n".join(body) |
| 2020 | |
| 2021 | class GlaveDbgStructs(Subcommand): |
| 2022 | def generate_header(self): |
| 2023 | header_txt = [] |
| 2024 | header_txt.append('#pragma once\n') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2025 | header_txt.append('#include "vkDbg.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2026 | header_txt.append('#include "glv_trace_packet_utils.h"\n') |
| 2027 | return "\n".join(header_txt) |
| 2028 | |
| 2029 | def generate_body(self): |
| 2030 | body = [self._generate_interp_funcs_ext('Dbg')] |
| 2031 | |
| 2032 | return "\n".join(body) |
| 2033 | |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2034 | class GlaveReplayVkFuncPtrs(Subcommand): |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2035 | def generate_header(self): |
| 2036 | header_txt = [] |
| 2037 | header_txt.append('#pragma once\n') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 2038 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2039 | header_txt.append('#include <xcb/xcb.h>\n') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2040 | header_txt.append('#endif') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2041 | header_txt.append('#include "vulkan.h"') |
| 2042 | header_txt.append('#include "vkDbg.h"') |
| Piers Daniell | e2bca48 | 2015-02-24 13:58:47 -0700 | [diff] [blame] | 2043 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2044 | header_txt.append('#include "vkWsiX11Ext.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2045 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2046 | header_txt.append('#include "vkWsiWinExt.h"') |
| David Pinedo | 8e9cb3b | 2015-02-10 15:02:08 -0700 | [diff] [blame] | 2047 | header_txt.append('#endif') |
| Peter Lohrmann | af44b45 | 2015-03-30 18:29:22 -0700 | [diff] [blame] | 2048 | |
| 2049 | def generate_body(self): |
| 2050 | body = [self._generate_replay_func_ptrs()] |
| 2051 | return "\n".join(body) |
| 2052 | |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 2053 | class GlaveReplayObjMapperHeader(Subcommand): |
| Jon Ashburn | 013aa1c | 2015-02-13 11:25:53 -0700 | [diff] [blame] | 2054 | def generate_header(self): |
| Ian Elliott | 91e681e | 2015-02-18 15:35:00 -0700 | [diff] [blame] | 2055 | header_txt = [] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2056 | header_txt.append('#pragma once\n') |
| 2057 | header_txt.append('#include <set>') |
| 2058 | header_txt.append('#include <map>') |
| 2059 | header_txt.append('#include <vector>') |
| 2060 | header_txt.append('#include <string>') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2061 | header_txt.append('#include "vulkan.h"') |
| 2062 | header_txt.append('#include "vkDbg.h"') |
| Jon Ashburn | 1590877 | 2015-02-17 13:28:11 -0700 | [diff] [blame] | 2063 | header_txt.append('#if defined(PLATFORM_LINUX) || defined(XCB_NVIDIA)') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2064 | header_txt.append('#include "vkWsiX11Ext.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2065 | header_txt.append('#else') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2066 | header_txt.append('#include "vkWsiWinExt.h"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2067 | header_txt.append('#endif') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2068 | return "\n".join(header_txt) |
| 2069 | |
| 2070 | def generate_body(self): |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 2071 | body = [self._generate_replay_objmapper_class()] |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2072 | return "\n".join(body) |
| 2073 | |
| 2074 | class GlaveReplayC(Subcommand): |
| 2075 | def generate_header(self): |
| 2076 | header_txt = [] |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2077 | header_txt.append('#include "glvreplay_vk_vkreplay.h"\n') |
| 2078 | header_txt.append('#include "glvreplay_vk.h"\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2079 | header_txt.append('#include "glvreplay_main.h"\n') |
| 2080 | header_txt.append('#include <algorithm>') |
| 2081 | header_txt.append('#include <queue>') |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 2082 | header_txt.append('\n') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2083 | header_txt.append('extern "C" {') |
| Peter Lohrmann | cde614c | 2015-03-27 12:57:10 -0700 | [diff] [blame] | 2084 | header_txt.append('#include "glv_vk_vk_structs.h"') |
| 2085 | header_txt.append('#include "glv_vk_vkdbg_structs.h"') |
| 2086 | header_txt.append('#include "glv_vk_vkwsix11ext_structs.h"') |
| 2087 | header_txt.append('#include "glv_vk_packet_id.h"') |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2088 | header_txt.append('#include "vk_enum_string_helper.h"\n}\n') |
| 2089 | header_txt.append('#define APP_NAME "glvreplay_vk"') |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2090 | header_txt.append('#define IDI_ICON 101\n') |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 2091 | |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2092 | return "\n".join(header_txt) |
| 2093 | |
| 2094 | def generate_body(self): |
| Peter Lohrmann | 3f0d697 | 2015-04-01 18:12:34 -0700 | [diff] [blame] | 2095 | body = [self._generate_replay_init_funcs(), |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2096 | self._generate_replay()] |
| 2097 | |
| 2098 | return "\n".join(body) |
| 2099 | |
| 2100 | def main(): |
| 2101 | subcommands = { |
| 2102 | "glave-trace-h" : GlaveTraceHeader, |
| 2103 | "glave-trace-c" : GlaveTraceC, |
| 2104 | "glave-packet-id" : GlavePacketID, |
| 2105 | "glave-core-structs" : GlaveCoreStructs, |
| 2106 | "glave-wsi-trace-h" : GlaveWsiHeader, |
| 2107 | "glave-wsi-trace-c" : GlaveWsiC, |
| 2108 | "glave-wsi-trace-structs" : GlaveWsiStructs, |
| 2109 | "glave-dbg-trace-h" : GlaveDbgHeader, |
| 2110 | "glave-dbg-trace-c" : GlaveDbgC, |
| 2111 | "glave-dbg-trace-structs" : GlaveDbgStructs, |
| Courtney Goeltzenleuchter | 4bffc07 | 2015-04-14 16:33:28 -0600 | [diff] [blame] | 2112 | "glave-replay-vk-funcs" : GlaveReplayVkFuncPtrs, |
| Peter Lohrmann | 7572822 | 2015-04-02 11:45:31 -0700 | [diff] [blame] | 2113 | "glave-replay-obj-mapper-h" : GlaveReplayObjMapperHeader, |
| Tobin Ehlis | f5e1fc5 | 2014-12-15 18:14:12 -0700 | [diff] [blame] | 2114 | "glave-replay-c" : GlaveReplayC, |
| 2115 | } |
| 2116 | |
| 2117 | if len(sys.argv) < 2 or sys.argv[1] not in subcommands: |
| 2118 | print("Usage: %s <subcommand> [options]" % sys.argv[0]) |
| 2119 | print |
| 2120 | print("Available sucommands are: %s" % " ".join(subcommands)) |
| 2121 | exit(1) |
| 2122 | |
| 2123 | subcmd = subcommands[sys.argv[1]](sys.argv[2:]) |
| 2124 | subcmd.run() |
| 2125 | |
| 2126 | if __name__ == "__main__": |
| 2127 | main() |