コード例 #1
0
 def _before_generating(self):
     BaseGenerator._before_generating(self)
     self._comment = '//'
     self._base_class_name = 'BaseMessage'
     self._get_id_method_name = 'getID'
     self._send_stream_creator_name = 'initSendStream'
     self._receive_stream_creator_name = 'initReceiveStream'
コード例 #2
0
    def endFile(self):
        """Method override."""
        for cmd, info in self.command_info.items():
            params = info[2]
            if params and params[0].base_type == 'VkCommandBuffer':
                # Check for parameters with handle types, ignoring the first VkCommandBuffer parameter.
                handles = self.get_param_list_handles(params[1:])

                if (handles):
                    # Generate a function to build a list of handle types and values.
                    cmddef = '\n'
                    cmddef += 'void Track{}Handles(CommandBufferWrapper* wrapper, {})\n'.format(
                        cmd[2:], self.get_arg_list(handles))
                    cmddef += '{\n'
                    indent = self.INDENT_SIZE * ' '
                    cmddef += indent + 'assert(wrapper != nullptr);\n'
                    cmddef += '\n'
                    for index, handle in enumerate(handles):
                        cmddef += self.insert_command_handle(index,
                                                             handle,
                                                             indent=indent)
                    cmddef += '}'

                    write(cmddef, file=self.outFile)

        self.newline()
        write('GFXRECON_END_NAMESPACE(encode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #3
0
    def endFile(self):
        """Method override."""
        for cmd, info in self.command_info.items():
            return_type = info[0]
            params = info[2]
            if params and params[0].base_type == 'VkCommandBuffer':
                # Check for parameters with resource handle types.
                handles = self.get_param_list_handles(params[1:])

                if (handles):
                    # Generate a function to build a list of handle types and values.
                    cmddef = '\n'

                    # Temporarily remove resource only matching restriction from is_handle() when generating the function signature.
                    self.restrict_handles = False
                    decl = self.make_consumer_func_decl(
                        return_type, 'Process_' + cmd, params)
                    cmddef += self.indent('virtual ' + decl + ' override;',
                                          self.INDENT_SIZE)
                    self.restrict_handles = True

                    write(cmddef, file=self.outFile)

        write('};', file=self.outFile)
        self.newline()
        write('GFXRECON_END_NAMESPACE(decode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #4
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write(
            '#include "decode/custom_vulkan_struct_decoders_forward.h"',
            file=self.outFile
        )
        write('#include "decode/handle_pointer_decoder.h"', file=self.outFile)
        write('#include "decode/pnext_node.h"', file=self.outFile)
        write('#include "decode/pointer_decoder.h"', file=self.outFile)
        write('#include "decode/string_array_decoder.h"', file=self.outFile)
        write('#include "decode/string_decoder.h"', file=self.outFile)
        write('#include "decode/struct_pointer_decoder.h"', file=self.outFile)
        write('#include "format/format.h"', file=self.outFile)
        write('#include "format/platform_types.h"', file=self.outFile)
        write(
            '#include "generated/generated_vulkan_struct_decoders_forward.h"',
            file=self.outFile
        )
        write('#include "util/defines.h"', file=self.outFile)
        self.newline()
        self.includeVulkanHeaders(gen_opts)
        self.newline()
        write('#include <memory>', file=self.outFile)
        self.newline()
        write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile)
        write('GFXRECON_BEGIN_NAMESPACE(decode)', file=self.outFile)
コード例 #5
0
    def genStruct(self, typeinfo, typename, alias):
        """Method override."""
        BaseGenerator.genStruct(self, typeinfo, typename, alias)

        if not alias:
            self.check_struct_member_handles(typename,
                                             self.structs_with_handles)
コード例 #6
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write(
            '#include "generated/generated_vulkan_struct_handle_mappers.h"',
            file=self.outFile
        )
        self.newline()
        write(
            '#include "decode/custom_vulkan_struct_decoders.h"',
            file=self.outFile
        )
        write('#include "decode/handle_pointer_decoder.h"', file=self.outFile)
        write(
            '#include "decode/vulkan_handle_mapping_util.h"',
            file=self.outFile
        )
        write(
            '#include "generated/generated_vulkan_struct_decoders.h"',
            file=self.outFile
        )
        self.newline()
        write('#include <algorithm>', file=self.outFile)
        write('#include <cassert>', file=self.outFile)
        self.newline()
        write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile)
        write('GFXRECON_BEGIN_NAMESPACE(decode)', file=self.outFile)
コード例 #7
0
    def __init__(
        self, err_file=sys.stderr, warn_file=sys.stderr, diag_file=sys.stdout
    ):
        BaseGenerator.__init__(
            self,
            process_cmds=True,
            process_structs=False,
            feature_break=False,
            err_file=err_file,
            warn_file=warn_file,
            diag_file=diag_file
        )
        # Map of return types to default return values for no-op functions
        self.RETURN_DEFAULTS = {
            'VkResult': 'VK_SUCCESS',
            'VkBool32': 'VK_TRUE',
            'PFN_vkVoidFunction': 'nullptr',
            'VkDeviceAddress': '0',
            'VkDeviceSize': '0',
            'uint32_t': '0',
            'uint64_t': '0'
        }

        self.instance_cmd_names = dict(
        )  # Map of API call names to no-op function declarations
        self.device_cmd_names = dict(
        )  # Map of API call names to no-op function declarations
コード例 #8
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        if gen_opts.capture_overrides:
            self.__load_capture_overrides(gen_opts.capture_overrides)

        write('#include "generated/generated_vulkan_api_call_encoders.h"',
              file=self.outFile)
        self.newline()
        write('#include "encode/custom_vulkan_encoder_commands.h"',
              file=self.outFile)
        write('#include "encode/custom_vulkan_array_size_2d.h"',
              file=self.outFile)
        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 "encode/vulkan_handle_wrapper_util.h"',
              file=self.outFile)
        write('#include "encode/vulkan_handle_wrappers.h"', file=self.outFile)
        write('#include "format/api_call_id.h"', file=self.outFile)
        write('#include "generated/generated_vulkan_command_buffer_util.h"',
              file=self.outFile)
        write('#include "generated/generated_vulkan_struct_handle_wrappers.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(encode)', file=self.outFile)
コード例 #9
0
    def endFile(self):
        """Method override."""
        write('            }', file=self.outFile)
        write('        }', file=self.outFile)
        write('    }', file=self.outFile)
        self.newline()
        write('    if ((bytes_read == 0) && (attrib != 0))', file=self.outFile)
        write('    {', file=self.outFile)
        write(
            '        // The encoded pointer attribute mask included kIsNull, or the sType was unrecognized.',
            file=self.outFile)
        write(
            '        // We will report that we read the attribute mask, but nothing else was decoded.',
            file=self.outFile)
        write('        bytes_read = sizeof(attrib);', file=self.outFile)
        write('    }', file=self.outFile)
        self.newline()
        write('    return bytes_read;', file=self.outFile)
        write('}', file=self.outFile)
        self.newline()
        write('GFXRECON_END_NAMESPACE(decode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #10
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write('#include "decode/vulkan_decoder_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 VulkanDecoder : public VulkanDecoderBase',
              file=self.outFile)
        write('{', file=self.outFile)
        write('  public:', file=self.outFile)
        write('    VulkanDecoder() { }\n', file=self.outFile)
        write('    virtual ~VulkanDecoder() override { }\n', file=self.outFile)
        write(
            '    virtual void DecodeFunctionCall(format::ApiCallId             call_id,',
            file=self.outFile)
        write(
            '                                    const ApiCallInfo&            call_info,',
            file=self.outFile)
        write(
            '                                    const uint8_t*                parameter_buffer,',
            file=self.outFile)
        write(
            '                                    size_t                        buffer_size) override;\n',
            file=self.outFile)
        write('  private:', end='', file=self.outFile)
コード例 #11
0
ファイル: cs_generator.py プロジェクト: andi2/ld32-6
 def _before_generating(self):
     BaseGenerator._before_generating(self)
     self._comment = "//"
     self._base_class_name = "BaseMessage"
     self._get_id_method_name = "getID"
     self._send_stream_creator_name = "initSendStream"
     self._receive_stream_creator_name = "initReceiveStream"
コード例 #12
0
    def endFile(self):
        """Method override."""
        self.newline()
        write('GFXRECON_END_NAMESPACE(encode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #13
0
    def endFile(self):
        """Method override."""
        body = inspect.cleandoc('''
            GFXRECON_END_NAMESPACE(decode)
            GFXRECON_END_NAMESPACE(gfxrecon)
            ''')
        write(body, file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #14
0
    def endFile(self):
        """Method override."""
        self.newline()
        # Generate the VulkanDecoder::DecodeFunctionCall method for all of the commands processed by the generator.
        self.generate_decode_cases()
        self.newline()
        write('GFXRECON_END_NAMESPACE(decode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #15
0
    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)
        self.newline()
        self.includeVulkanHeaders(gen_opts)
        self.newline()
        write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile)
        write('GFXRECON_BEGIN_NAMESPACE(encode)', file=self.outFile)
コード例 #16
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write('#include "decode/vulkan_feature_util.h"', file=self.outFile)
        self.newline()
        write('#include "util/logging.h"', file=self.outFile)
        self.newline()
        write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile)
        write('GFXRECON_BEGIN_NAMESPACE(decode)', file=self.outFile)
        write('GFXRECON_BEGIN_NAMESPACE(feature_util)', file=self.outFile)
コード例 #17
0
 def __init__(self,
              err_file=sys.stderr,
              warn_file=sys.stderr,
              diag_file=sys.stdout):
     BaseGenerator.__init__(self,
                            process_cmds=False,
                            process_structs=True,
                            feature_break=True,
                            err_file=err_file,
                            warn_file=warn_file,
                            diag_file=diag_file)
コード例 #18
0
    def endFile(self):
        """Method override."""
        self.newline()
        write(self.make_feature_helper(), file=self.outFile)
        self.newline()
        write('GFXRECON_END_NAMESPACE(feature_util)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(decode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #19
0
    def genStruct(self, typeinfo, typename, alias):
        """Method override."""
        BaseGenerator.genStruct(self, typeinfo, typename, alias)

        if not alias:
            self.check_struct_member_handles(typename,
                                             self.structs_with_handles,
                                             self.structs_with_handle_ptrs)

            stype = self.make_structure_type_enum(typeinfo, typename)
            if stype:
                self.stype_values[typename] = stype
コード例 #20
0
ファイル: cs_generator.py プロジェクト: andi2/ld32-6
    def _generate_enum(self, enum_descriptor):
        BaseGenerator._generate_enum(self, enum_descriptor)

        f = self._file
        cls_name = util.format_to_pascal(enum_descriptor["cls"])
        f.write("%spublic enum %s\n" % (TAB, cls_name))
        f.write("%s{\n" % TAB)

        for enum_field in enum_descriptor["fields"]:
            f.write("%s%s,\n" % (TAB2, enum_field.upper()))

        f.write("%s}\n\n" % TAB)
コード例 #21
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write(
            '#include "generated/generated_vulkan_referenced_resource_consumer.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)
コード例 #22
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write('#include "generated/generated_vulkan_command_buffer_util.h"',
              file=self.outFile)
        self.newline()
        write('#include "encode/vulkan_handle_wrapper_util.h"',
              file=self.outFile)
        write('#include "encode/vulkan_state_info.h"', 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)

        write(
            '#include "generated/generated_vulkan_struct_handle_wrappers.h"',
            file=self.outFile
        )
        self.newline()
        write('#include "vulkan/vk_layer.h"', file=self.outFile)
        self.newline()
        write('GFXRECON_BEGIN_NAMESPACE(gfxrecon)', file=self.outFile)
        write('GFXRECON_BEGIN_NAMESPACE(encode)', file=self.outFile)
コード例 #24
0
    def __init__(self,
                 err_file=sys.stderr,
                 warn_file=sys.stderr,
                 diag_file=sys.stdout):
        BaseGenerator.__init__(self,
                               process_cmds=False,
                               process_structs=False,
                               feature_break=False,
                               err_file=err_file,
                               warn_file=warn_file,
                               diag_file=diag_file)

        # Map to store VkStructureType enum values.
        self.stype_values = dict()
コード例 #25
0
    def endFile(self):
        """Method override."""
        for cmd, info in self.command_info.items():
            return_type = info[0]
            params = info[2]
            if params and params[0].base_type == 'VkCommandBuffer':
                # Check for parameters with resource handle types.
                handles = self.get_param_list_handles(params[1:])

                if (handles):
                    # Generate a function to add handles to the command buffer's referenced handle list.
                    cmddef = '\n'

                    # Temporarily remove resource only matching restriction from is_handle() when generating the function signature.
                    self.restrict_handles = False
                    cmddef += self.make_consumer_func_decl(
                        return_type,
                        'VulkanReferencedResourceConsumer::Process_' + cmd,
                        params
                    ) + '\n'
                    self.restrict_handles = True

                    cmddef += '{\n'
                    indent = self.INDENT_SIZE * ' '

                    # Add unreferenced parameter macros.
                    unref_count = 0
                    for param in params[1:]:
                        if param not in handles:
                            cmddef += indent + 'GFXRECON_UNREFERENCED_PARAMETER({});\n'.format(
                                param.name
                            )
                            unref_count += 1
                    if unref_count > 0:
                        cmddef += '\n'

                    for index, handle in enumerate(handles):
                        cmddef += self.track_command_handle(
                            index, params[0].name, handle, indent=indent
                        )
                    cmddef += '}'

                    write(cmddef, file=self.outFile)

        self.newline()
        write('GFXRECON_END_NAMESPACE(decode)', file=self.outFile)
        write('GFXRECON_END_NAMESPACE(gfxrecon)', file=self.outFile)

        # Finish processing in superclass
        BaseGenerator.endFile(self)
コード例 #26
0
    def genStruct(self, typeinfo, typename, alias):
        """Method override."""
        BaseGenerator.genStruct(self, typeinfo, typename, alias)

        if not alias:
            self.check_struct_member_handles(typename,
                                             self.structs_with_handles)

            # Track this struct if it can be present in a pNext chain.
            parent_structs = typeinfo.elem.get('structextends')
            if parent_structs:
                stype = self.make_structure_type_enum(typeinfo, typename)
                if stype:
                    self.pnext_structs[typename] = stype
コード例 #27
0
    def __init__(
        self, err_file=sys.stderr, warn_file=sys.stderr, diag_file=sys.stdout
    ):
        BaseGenerator.__init__(
            self,
            process_cmds=True,
            process_structs=False,
            feature_break=True,
            err_file=err_file,
            warn_file=warn_file,
            diag_file=diag_file
        )

        # Names of all Vulkan commands processed by the generator.
        self.cmd_names = []
コード例 #28
0
    def __init__(self,
                 err_file=sys.stderr,
                 warn_file=sys.stderr,
                 diag_file=sys.stdout):
        BaseGenerator.__init__(self,
                               process_cmds=False,
                               process_structs=True,
                               feature_break=True,
                               err_file=err_file,
                               warn_file=warn_file,
                               diag_file=diag_file)

        self.physical_device_features2_stypes = dict()
        # List of 1.0 features
        self.physical_device_features = []
    def genCmd(self, cmdinfo, name, alias):
        """Method override."""
        BaseGenerator.genCmd(self, cmdinfo, name, alias)

        # Look for output structs that contain handles and add to list
        if not alias:
            for value_info in self.feature_cmd_params[name][2]:
                if self.is_output_parameter(value_info) and (
                        value_info.base_type
                        in self.get_filtered_struct_names()) and (
                            value_info.base_type in self.structs_with_handles
                        ) and (value_info.base_type
                               not in self.output_structs_with_handles):
                    self.output_structs_with_handles.append(
                        value_info.base_type)
コード例 #30
0
    def __init__(self,
                 err_file=sys.stderr,
                 warn_file=sys.stderr,
                 diag_file=sys.stdout):
        BaseGenerator.__init__(self,
                               process_cmds=True,
                               process_structs=True,
                               feature_break=True,
                               err_file=err_file,
                               warn_file=warn_file,
                               diag_file=diag_file)

        # Map of Vulkan structs containing handles to a list values for handle members or struct members
        # that contain handles (eg. VkGraphicsPipelineCreateInfo contains a VkPipelineShaderStageCreateInfo
        # member that contains handles).
        self.structs_with_handles = dict()
コード例 #31
0
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write(
            '#include "decode/{}"'.format(gen_opts.base_class_header),
            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 {class_name} : public {class_name}Base'.format(
                class_name=gen_opts.class_name
            ),
            file=self.outFile
        )
        write('{', file=self.outFile)
        write('  public:', file=self.outFile)
        if gen_opts.constructor_args:
            arg_list = ', '.join(
                [
                    arg.split(' ')[-1]
                    for arg in gen_opts.constructor_args.split(',')
                ]
            )
            write(
                '    {class_name}({}) : {class_name}Base({}) {{ }}\n'.format(
                    gen_opts.constructor_args,
                    arg_list,
                    class_name=gen_opts.class_name
                ),
                file=self.outFile
            )
        else:
            write(
                '    {}() {{ }}\n'.format(gen_opts.class_name),
                file=self.outFile
            )
        write(
            '    virtual ~{}() override {{ }}'.format(gen_opts.class_name),
            file=self.outFile
        )
    def beginFile(self, gen_opts):
        """Method override."""
        BaseGenerator.beginFile(self, gen_opts)

        write('#include "decode/pnext_node.h"', file=self.outFile)
        write('#include "decode/vulkan_object_info_table.h"',
              file=self.outFile)
        write('#include "format/platform_types.h"', file=self.outFile)
        write(
            '#include "generated/generated_vulkan_struct_decoders_forward.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)
コード例 #33
0
ファイル: py_generator.py プロジェクト: andi2/ld32-6
    def _generate_base_class(self):
        BaseGenerator._generate_base_class(self)

        f = self._file

        f.write('class %s():\n' % self._base_class_name)
        f.write('%s@property\n' % TAB)
        f.write('%sdef %s(self):\n' % (TAB, self._get_id_method_name, ))
        f.write('%sraise NotImplementedError()\n' % TAB2)

        f.write('\n')

        f.write('%sdef __init__(self):\n' % TAB)
        f.write('%sself._length = -1\n' % TAB2)
        f.write('%sself._real_id = 255\n' % TAB2)
        f.write('\n')
        f.write('%sself._format = "<i b"\n' % TAB2)
        f.write('%sself._struct = None\n' % TAB2)
コード例 #34
0
ファイル: py_generator.py プロジェクト: andi2/ld32-6
    def _generate_enum(self, enum_descriptor):
        BaseGenerator._generate_enum(self, enum_descriptor)

        f = self._file
        cls_name = util.format_to_pascal(enum_descriptor['cls'])

        f.write('# noinspection PyClassHasNoInit\n')
        f.write('class %s():\n' % cls_name)
        f.write('%s' % TAB)

        fields = enum_descriptor['fields']
        l = len(fields)
        for i in xrange(l):
            if i == l - 1:
                f.write('%s = range(%i)\n' % (fields[i].upper(), l))
            else:
                f.write('%s, ' % fields[i].upper())
        f.write('\n')
        f.write('\n')