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