Ejemplo n.º 1
0
def main():

    # auto_script parameters.
    if len(sys.argv) > 1:
        inputs = [
            'angle_format.py', 'angle_format_data.json',
            'angle_format_map.json'
        ]
        outputs = ['Format_table_autogen.cpp', 'FormatID_autogen.h']

        if sys.argv[1] == 'inputs':
            print ','.join(inputs)
        elif sys.argv[1] == 'outputs':
            print ','.join(outputs)
        else:
            print('Invalid script parameters')
            return 1
        return 0

    gl_to_angle = angle_format.load_forward_table('angle_format_map.json')
    angle_to_gl = angle_format.load_inverse_table('angle_format_map.json')
    data_source_name = 'angle_format_data.json'
    json_data = angle_format.load_json(data_source_name)
    all_angle = angle_to_gl.keys()

    angle_format_cases = parse_angle_format_table(all_angle, json_data,
                                                  angle_to_gl)
    switch_data = gen_map_switch_string(gl_to_angle)
    output_cpp = template_autogen_inl.format(
        script_name=sys.argv[0],
        copyright_year=date.today().year,
        angle_format_info_cases=angle_format_cases,
        angle_format_switch=switch_data,
        data_source_name=data_source_name)
    with open('Format_table_autogen.cpp', 'wt') as out_file:
        out_file.write(output_cpp)
        out_file.close()

    enum_data = gen_enum_string(all_angle)
    num_angle_formats = len(all_angle)
    output_h = template_autogen_h.format(script_name=sys.argv[0],
                                         copyright_year=date.today().year,
                                         angle_format_enum=enum_data,
                                         data_source_name=data_source_name,
                                         num_angle_formats=num_angle_formats)
    with open('FormatID_autogen.h', 'wt') as out_file:
        out_file.write(output_h)
        out_file.close()

    return 0
Ejemplo n.º 2
0
def main():

    # auto_script parameters.
    if len(sys.argv) > 1:
        inputs = ['angle_format.py', 'angle_format_data.json', 'angle_format_map.json']
        outputs = ['Format_table_autogen.cpp', 'FormatID_autogen.h']

        if sys.argv[1] == 'inputs':
            print ','.join(inputs)
        elif sys.argv[1] == 'outputs':
            print ','.join(outputs)
        else:
            print('Invalid script parameters')
            return 1
        return 0

    gl_to_angle = angle_format.load_forward_table('angle_format_map.json')
    angle_to_gl = angle_format.load_inverse_table('angle_format_map.json')
    data_source_name = 'angle_format_data.json'
    json_data = angle_format.load_json(data_source_name)
    all_angle = angle_to_gl.keys()

    angle_format_cases = parse_angle_format_table(all_angle, json_data, angle_to_gl)
    switch_data = gen_map_switch_string(gl_to_angle)
    output_cpp = template_autogen_inl.format(
        script_name=sys.argv[0],
        copyright_year=date.today().year,
        angle_format_info_cases=angle_format_cases,
        angle_format_switch=switch_data,
        data_source_name=data_source_name)
    with open('Format_table_autogen.cpp', 'wt') as out_file:
        out_file.write(output_cpp)
        out_file.close()

    enum_data = gen_enum_string(all_angle)
    num_angle_formats = len(all_angle)
    output_h = template_autogen_h.format(
        script_name=sys.argv[0],
        copyright_year=date.today().year,
        angle_format_enum=enum_data,
        data_source_name=data_source_name,
        num_angle_formats=num_angle_formats)
    with open('FormatID_autogen.h', 'wt') as out_file:
        out_file.write(output_h)
        out_file.close()

    return 0
Ejemplo n.º 3
0
def main():

    input_file_name = 'vk_format_map.json'
    out_file_name = 'vk_format_table_autogen.cpp'

    # auto_script parameters.
    if len(sys.argv) > 1:
        inputs = [
            '../angle_format.py', '../angle_format_map.json', input_file_name
        ]
        outputs = [out_file_name]

        if sys.argv[1] == 'inputs':
            print ','.join(inputs)
        elif sys.argv[1] == 'outputs':
            print ','.join(outputs)
        else:
            print('Invalid script parameters')
            return 1
        return 0

    angle_to_gl = angle_format.load_inverse_table(
        os.path.join('..', 'angle_format_map.json'))
    vk_json_data = angle_format.load_json(input_file_name)
    vk_cases = [
        gen_format_case(angle, gl, vk_json_data)
        for angle, gl in sorted(angle_to_gl.iteritems())
    ]

    output_cpp = template_table_autogen_cpp.format(
        copyright_year=date.today().year,
        format_case_data="\n".join(vk_cases),
        script_name=__file__,
        out_file_name=out_file_name,
        input_file_name=input_file_name)

    with open(out_file_name, 'wt') as out_file:
        out_file.write(output_cpp)
        out_file.close()
    return 0
Ejemplo n.º 4
0
def main():

    input_file_name = 'vk_format_map.json'
    out_file_name = 'vk_format_table_autogen.cpp'

    # auto_script parameters.
    if len(sys.argv) > 1:
        inputs = ['../angle_format.py', '../angle_format_map.json', input_file_name]
        outputs = [out_file_name]

        if sys.argv[1] == 'inputs':
            print ','.join(inputs)
        elif sys.argv[1] == 'outputs':
            print ','.join(outputs)
        else:
            print('Invalid script parameters')
            return 1
        return 0

    angle_to_gl = angle_format.load_inverse_table(os.path.join('..', 'angle_format_map.json'))
    vk_json_data = angle_format.load_json(input_file_name)
    vk_cases = [
        gen_format_case(angle, gl, vk_json_data) for angle, gl in sorted(angle_to_gl.iteritems())
    ]

    output_cpp = template_table_autogen_cpp.format(
        copyright_year=date.today().year,
        format_case_data="\n".join(vk_cases),
        script_name=__file__,
        out_file_name=out_file_name,
        input_file_name=input_file_name)

    with open(out_file_name, 'wt') as out_file:
        out_file.write(output_cpp)
        out_file.close()
    return 0
format_cases = ""

input_data = 'dxgi_format_data.json'

dxgi_map = angle_format.load_json(input_data)

types = {
    'SNORM': 'GL_SIGNED_NORMALIZED',
    'UNORM': 'GL_UNSIGNED_NORMALIZED',
    'SINT': 'GL_INT',
    'UINT': 'GL_UNSIGNED_INT',
    'FLOAT': 'GL_FLOAT',
    'SHAREDEXP': 'GL_FLOAT'
}

angle_to_gl = angle_format.load_inverse_table('../../angle_format_map.json')
all_angle = angle_to_gl.keys()

for dxgi_format, angle_format in sorted(dxgi_map.iteritems()):

    found = [ctype in dxgi_format for ctype in types.keys()]
    count = reduce((lambda a, b: int(a) + int(b)), found)

    component_type = 'GL_NONE'

    if count == 1:
        gltype = next(gltype for ctype, gltype in types.iteritems() if ctype in dxgi_format)
        component_cases += format_case(dxgi_format, gltype)
    else:
        component_cases += undefined_case(dxgi_format)
Ejemplo n.º 6
0
  if len(buffers) == 1:
    args.update(buffer_template=buffer_basic_template)
    args.update(buffer_args(buffers[0]))
  elif len(buffers) > 1:
    args.update(
        buffer_template=buffer_fallback_template,
        buffer_list=", ".join(
            buffer_struct_template.format(**buffer_args(i)) for i in buffers))

  return format_entry_template.format(**args).format(**args)


input_file_name = 'vk_format_map.json'
out_file_name = 'vk_format_table'

angle_to_gl = angle_format.load_inverse_table(os.path.join('..', 'angle_format_map.json'))
vk_json_data = angle_format.load_json(input_file_name)
vk_cases = [gen_format_case(angle, gl, vk_json_data)
             for angle, gl in sorted(angle_to_gl.iteritems())]

output_cpp = template_table_autogen_cpp.format(
    copyright_year = date.today().year,
    format_case_data = "\n".join(vk_cases),
    script_name = __file__,
    out_file_name = out_file_name,
    input_file_name = input_file_name)

with open(out_file_name + '_autogen.cpp', 'wt') as out_file:
  out_file.write(output_cpp)
  out_file.close()