1 /**************************************************************************** 2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 * 23 * @file ${filename} 24 * 25 * @brief Definitions for events. auto-generated file 26 * 27 * DO NOT EDIT 28 * 29 * Generation Command Line: 30 * ${'\n * '.join(cmdline)} 31 * 32 ******************************************************************************/ 33 // clang-format off 34 #pragma once 35 36 #include "common/os.h" 37 #include "core/state.h" 38 39 <% 40 always_enabled_knob_groups = ['Framework', 'SWTagFramework', 'ApiSwr'] 41 group_knob_remap_table = { 42 "ShaderStats": "KNOB_AR_ENABLE_SHADER_STATS", 43 "PipelineStats" : "KNOB_AR_ENABLE_PIPELINE_STATS", 44 "SWTagData" : "KNOB_AR_ENABLE_SWTAG_DATA", 45 } 46 %> 47 namespace ArchRast 48 { 49 <% sorted_enums = sorted(protos['enums']['defs']) %> 50 % for name in sorted_enums: 51 enum ${name} 52 {<% names = protos['enums']['defs'][name]['names'] %> 53 % for i in range(len(names)): 54 ${names[i].lstrip()} 55 % endfor 56 }; 57 % endfor 58 59 // Forward decl 60 class EventHandler; 61 62 ////////////////////////////////////////////////////////////////////////// 63 /// Event - interface for handling events. 64 ////////////////////////////////////////////////////////////////////////// 65 struct Event 66 { 67 const uint32_t eventId = {0xFFFFFFFF}; EventEvent68 Event() {} ~EventEvent69 virtual ~Event() {} 70 IsEnabledEvent71 virtual bool IsEnabled() const { return true; }; 72 virtual const uint32_t GetEventId() const = 0; 73 virtual void Accept(EventHandler* pHandler) const = 0; 74 }; 75 76 <% sorted_groups = sorted(protos['events']['groups']) %> 77 % for group in sorted_groups: 78 % for event_key in protos['events']['groups'][group]: 79 <% 80 event = protos['events']['defs'][event_key] 81 %> 82 ////////////////////////////////////////////////////////////////////////// 83 /// ${event_key}Data 84 ////////////////////////////////////////////////////////////////////////// 85 #pragma pack(push, 1) 86 struct ${event['name']}Data 87 {<% 88 fields = event['fields'] %> 89 // Fields 90 % for i in range(len(fields)): 91 % if fields[i]['size'] > 1: 92 ${fields[i]['type']} ${fields[i]['name']}[${fields[i]['size']}]; 93 % else: 94 ${fields[i]['type']} ${fields[i]['name']}; 95 % endif 96 % endfor 97 }; 98 #pragma pack(pop) 99 100 ////////////////////////////////////////////////////////////////////////// 101 /// ${event_key} 102 ////////////////////////////////////////////////////////////////////////// 103 struct ${event['name']} : Event 104 {<% 105 fields = event['fields'] %> 106 const uint32_t eventId = {${ event['id'] }}; 107 ${event['name']}Data data; 108 109 // Constructor 110 ${event['name']}( 111 % for i in range(len(fields)): 112 % if i < len(fields)-1: 113 % if fields[i]['size'] > 1: 114 ${fields[i]['type']}* ${fields[i]['name']}, 115 uint32_t ${fields[i]['name']}_size, 116 % else: 117 ${fields[i]['type']} ${fields[i]['name']}, 118 % endif 119 % endif 120 % if i == len(fields)-1: 121 % if fields[i]['size'] > 1: 122 ${fields[i]['type']}* ${fields[i]['name']}, 123 uint32_t ${fields[i]['name']}_size 124 % else: 125 ${fields[i]['type']} ${fields[i]['name']} 126 % endif 127 % endif 128 % endfor 129 ) 130 { 131 % for i in range(len(fields)): 132 % if fields[i]['size'] > 1: 133 % if fields[i]['type'] == 'char': 134 // Copy size of string (null-terminated) followed by string into entire buffer 135 SWR_ASSERT(${fields[i]['name']}_size + 1 < ${fields[i]['size']} - sizeof(uint32_t), "String length must be less than size of char buffer - size(uint32_t)!"); 136 memcpy(data.${fields[i]['name']}, &${fields[i]['name']}_size, sizeof(uint32_t)); 137 strcpy_s(data.${fields[i]['name']} + sizeof(uint32_t), ${fields[i]['name']}_size + 1, ${fields[i]['name']}); 138 % else: 139 memcpy(data.${fields[i]['name']}, ${fields[i]['name']}, ${fields[i]['name']}_size); 140 % endif 141 % else: 142 data.${fields[i]['name']} = ${fields[i]['name']}; 143 % endif 144 % endfor 145 } 146 147 virtual void Accept(EventHandler* pHandler) const; 148 inline const uint32_t GetEventId() const { return eventId; } 149 % if group not in always_enabled_knob_groups: 150 <% 151 if group in group_knob_remap_table: 152 group_knob_define = group_knob_remap_table[group] 153 else: 154 group_knob_define = 'KNOB_AR_ENABLE_' + group.upper() + '_EVENTS' 155 %> 156 bool IsEnabled() const 157 { 158 static const bool IsEventEnabled = true; // TODO: Replace with knob for each event 159 return ${group_knob_define} && IsEventEnabled; 160 } 161 % endif 162 }; 163 164 % endfor 165 166 % endfor 167 } // namespace ArchRast 168 // clang-format on 169