def beginFile(self, gen_opts): """Method override.""" BaseGenerator.beginFile(self, gen_opts) class_name = 'VulkanReferencedResourceConsumer' write('#include "decode/vulkan_referenced_resource_consumer_base.h"', file=self.outFile) write('#include "util/defines.h"', file=self.outFile) self.newline() self.includeVulkanHeaders(gen_opts) self.newline() write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile) write('GFXRECON_BEGIN_NAMESPACE(decode)', file=self.outFile) self.newline() write('class {name} : public {name}Base'.format(name=class_name), file=self.outFile) write('{', file=self.outFile) write(' public:', file=self.outFile) write(' {}() {{ }}\n'.format(class_name), file=self.outFile) write(' virtual ~{}() override {{ }}'.format(class_name), file=self.outFile)
def beginFile(self, gen_opts): """Method override.""" BaseGenerator.beginFile(self, gen_opts) write('#include "format/platform_types.h"', file=self.outFile) write('#include "util/defines.h"', file=self.outFile) write('#include "util/logging.h"', file=self.outFile) self.newline() write('#include "vulkan/vk_layer.h"', file=self.outFile) self.includeVulkanHeaders(gen_opts) self.newline() write('#ifdef WIN32', file=self.outFile) write('#ifdef CreateEvent', file=self.outFile) write('#undef CreateEvent', file=self.outFile) write('#endif', file=self.outFile) write('#ifdef CreateSemaphore', file=self.outFile) write('#undef CreateSemaphore', file=self.outFile) write('#endif', file=self.outFile) write('#endif', file=self.outFile) self.newline() write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile) write('GFXRECON_BEGIN_NAMESPACE(encode)', file=self.outFile)
def beginFile(self, gen_opts): """Method override.""" BaseGenerator.beginFile(self, gen_opts) if gen_opts.replay_overrides: self.__load_replay_overrides(gen_opts.replay_overrides) write('#include "generated/generated_vulkan_replay_consumer.h"', file=self.outFile) self.newline() write('#include "decode/custom_vulkan_struct_handle_mappers.h"', file=self.outFile) write('#include "decode/vulkan_handle_mapping_util.h"', file=self.outFile) write('#include "generated/generated_vulkan_dispatch_table.h"', file=self.outFile) write('#include "generated/generated_vulkan_struct_handle_mappers.h"', file=self.outFile) write('#include "util/defines.h"', file=self.outFile) self.newline() write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile) write('GFXRECON_BEGIN_NAMESPACE(decode)', file=self.outFile)
def beginFile(self, gen_opts): """Method override.""" BaseGenerator.beginFile(self, gen_opts) write('#include "generated/generated_vulkan_struct_encoders.h"', file=self.outFile) self.newline() write('#include "encode/parameter_encoder.h"', file=self.outFile) write('#include "encode/struct_pointer_encoder.h"', file=self.outFile) write('#include "encode/vulkan_capture_manager.h"', file=self.outFile) write('#include "util/defines.h"', file=self.outFile) self.newline() self.includeVulkanHeaders(gen_opts) self.newline() write('#include <cassert>', file=self.outFile) write('#include <cstdio>', file=self.outFile) write('#include <memory>', file=self.outFile) self.newline() write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile) write('GFXRECON_BEGIN_NAMESPACE(encode)', file=self.outFile) self.newline() write( 'void EncodePNextStruct(ParameterEncoder* encoder, const void* value)', file=self.outFile) write('{', file=self.outFile) write(' assert(encoder != nullptr);', file=self.outFile) self.newline() write( ' auto base = reinterpret_cast<const VkBaseInStructure*>(value);', file=self.outFile) self.newline() write( ' // Ignore the structures added to the pnext chain by the loader.', file=self.outFile) write( ' while ((base != nullptr) && ((base->sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO) ||', file=self.outFile) write( ' (base->sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO)))', file=self.outFile) write(' {', file=self.outFile) write(' base = base->pNext;', file=self.outFile) write(' }', file=self.outFile) self.newline() write(' if (base != nullptr)', file=self.outFile) write(' {', file=self.outFile) write(' switch (base->sType)', file=self.outFile) write(' {', file=self.outFile) write(' default:', file=self.outFile) write(' {', file=self.outFile) write( ' // pNext is unrecognized. Write warning message to indicate it will be omitted from the capture and check to see if it points to a recognized value.', file=self.outFile) write( ' int32_t message_size = std::snprintf(nullptr, 0, "A pNext value with unrecognized VkStructureType = %d was omitted from the capture file, which may cause replay to fail.", base->sType);', file=self.outFile) write( ' std::unique_ptr<char[]> message = std::make_unique<char[]>(message_size + 1); // Add 1 for null-terminator.', file=self.outFile) write( ' std::snprintf(message.get(), (message_size + 1), "A pNext value with unrecognized VkStructureType = %d was omitted from the capture file, which may cause replay to fail.", base->sType);', file=self.outFile) write( ' VulkanCaptureManager::Get()->WriteDisplayMessageCmd(message.get());', file=self.outFile) write(' GFXRECON_LOG_WARNING("%s", message.get());', file=self.outFile) write(' EncodePNextStruct(encoder, base->pNext);', file=self.outFile) write(' }', file=self.outFile) write(' break;', file=self.outFile)
def beginFile(self, gen_opts): """Method override.""" BaseGenerator.beginFile(self, gen_opts) write('#include "decode/custom_vulkan_struct_decoders.h"', file=self.outFile) write('#include "decode/decode_allocator.h"', file=self.outFile) write('#include "decode/pnext_node.h"', file=self.outFile) write('#include "decode/pnext_typed_node.h"', file=self.outFile) write('#include "generated/generated_vulkan_struct_decoders.h"', file=self.outFile) write('#include "util/logging.h"', file=self.outFile) self.newline() write('#include <cassert>', file=self.outFile) self.newline() write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile) write('GFXRECON_BEGIN_NAMESPACE(decode)', file=self.outFile) self.newline() write( 'size_t DecodePNextStruct(const uint8_t* parameter_buffer, size_t buffer_size, PNextNode** pNext)', file=self.outFile) write('{', file=self.outFile) write(' assert(pNext != nullptr);', file=self.outFile) self.newline() write(' size_t bytes_read = 0;', file=self.outFile) write(' uint32_t attrib = 0;', file=self.outFile) self.newline() write( ' if ((parameter_buffer != nullptr) && (buffer_size >= sizeof(attrib)))', file=self.outFile) write(' {', file=self.outFile) write(' size_t stype_offset = 0;', file=self.outFile) self.newline() write( ' // Peek at the pointer attribute mask to make sure we have a non-NULL value that can be decoded.', file=self.outFile) write( ' attrib = *(reinterpret_cast<const uint32_t*>(parameter_buffer));', file=self.outFile) self.newline() write( ' if ((attrib & format::PointerAttributes::kIsNull) != format::PointerAttributes::kIsNull)', file=self.outFile) write(' {', file=self.outFile) write( ' // Offset to VkStructureType, after the pointer encoding preamble.', file=self.outFile) write(' stype_offset = sizeof(attrib);', file=self.outFile) self.newline() write( ' if ((attrib & format::PointerAttributes::kHasAddress) == format::PointerAttributes::kHasAddress)', file=self.outFile) write(' {', file=self.outFile) write( ' stype_offset += sizeof(format::AddressEncodeType);', file=self.outFile) write(' }', file=self.outFile) write(' }', file=self.outFile) self.newline() write( ' if ((stype_offset != 0) && ((buffer_size - stype_offset) >= sizeof(VkStructureType)))', file=self.outFile) write(' {', file=self.outFile) write( ' const VkStructureType* sType = reinterpret_cast<const VkStructureType*>(parameter_buffer + stype_offset);', file=self.outFile) self.newline() write(' switch (*sType)', file=self.outFile) write(' {', file=self.outFile) write(' default:', file=self.outFile) write(' // TODO: This may need to be a fatal error', file=self.outFile) write( ' GFXRECON_LOG_ERROR("Failed to decode pNext value with unrecognized VkStructurType = %d", (*sType));', file=self.outFile) write(' break;', file=self.outFile)