i965g: Dumper for i965 structures.

This commit is contained in:
José Fonseca 2009-11-05 12:22:01 +00:00
parent 6ac38232ee
commit 9069c791d0
5 changed files with 2073 additions and 0 deletions

View file

@ -43,6 +43,7 @@ C_SOURCES = \
brw_state_cache.c \
brw_state_dump.c \
brw_state_upload.c \
brw_structs_dump.c \
brw_swtnl.c \
brw_urb.c \
brw_util.c \

View file

@ -43,6 +43,7 @@ i965 = env.ConvenienceLibrary(
'brw_screen_surface.c',
'brw_screen_tex_layout.c',
'brw_screen_texture.c',
'brw_structs_dump.c',
'brw_sf.c',
'brw_sf_emit.c',
'brw_sf_state.c',

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,276 @@
/**************************************************************************
*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
/**
* @file
* Dump i965 data structures.
*
* Generated automatically from brw_structs.h by brw_structs_dump.py.
*/
#ifndef BRW_STRUCTS_DUMP_H
#define BRW_STRUCTS_DUMP_H
struct brw_3d_control;
struct brw_3d_primitive;
struct brw_aa_line_parameters;
struct brw_binding_table_pointers;
struct brw_blend_constant_color;
struct brw_cc0;
struct brw_cc1;
struct brw_cc2;
struct brw_cc3;
struct brw_cc4;
struct brw_cc5;
struct brw_cc6;
struct brw_cc7;
struct brw_cc_unit_state;
struct brw_cc_viewport;
struct brw_clip_unit_state;
struct brw_clipper_viewport;
struct brw_constant_buffer;
struct brw_cs_urb_state;
struct brw_depthbuffer;
struct brw_depthbuffer_g4x;
struct brw_drawrect;
struct brw_global_depth_offset_clamp;
struct brw_gs_unit_state;
struct brw_indexbuffer;
struct brw_line_stipple;
struct brw_mi_flush;
struct brw_pipe_control;
struct brw_pipeline_select;
struct brw_pipelined_state_pointers;
struct brw_polygon_stipple;
struct brw_polygon_stipple_offset;
struct brw_sampler_default_color;
struct brw_sampler_state;
struct brw_sf_unit_state;
struct brw_sf_viewport;
struct brw_ss0;
struct brw_ss1;
struct brw_ss2;
struct brw_ss3;
struct brw_state_base_address;
struct brw_state_prefetch;
struct brw_surf_ss0;
struct brw_surf_ss1;
struct brw_surf_ss2;
struct brw_surf_ss3;
struct brw_surf_ss4;
struct brw_surf_ss5;
struct brw_surface_state;
struct brw_system_instruction_pointer;
struct brw_urb_fence;
struct brw_urb_immediate;
struct brw_vb_array_state;
struct brw_vertex_buffer_state;
struct brw_vertex_element_packet;
struct brw_vertex_element_state;
struct brw_vf_statistics;
struct brw_vs_unit_state;
struct brw_wm_unit_state;
void
brw_dump_3d_control(const struct brw_3d_control *ptr);
void
brw_dump_3d_primitive(const struct brw_3d_primitive *ptr);
void
brw_dump_aa_line_parameters(const struct brw_aa_line_parameters *ptr);
void
brw_dump_binding_table_pointers(const struct brw_binding_table_pointers *ptr);
void
brw_dump_blend_constant_color(const struct brw_blend_constant_color *ptr);
void
brw_dump_cc0(const struct brw_cc0 *ptr);
void
brw_dump_cc1(const struct brw_cc1 *ptr);
void
brw_dump_cc2(const struct brw_cc2 *ptr);
void
brw_dump_cc3(const struct brw_cc3 *ptr);
void
brw_dump_cc4(const struct brw_cc4 *ptr);
void
brw_dump_cc5(const struct brw_cc5 *ptr);
void
brw_dump_cc6(const struct brw_cc6 *ptr);
void
brw_dump_cc7(const struct brw_cc7 *ptr);
void
brw_dump_cc_unit_state(const struct brw_cc_unit_state *ptr);
void
brw_dump_cc_viewport(const struct brw_cc_viewport *ptr);
void
brw_dump_clip_unit_state(const struct brw_clip_unit_state *ptr);
void
brw_dump_clipper_viewport(const struct brw_clipper_viewport *ptr);
void
brw_dump_constant_buffer(const struct brw_constant_buffer *ptr);
void
brw_dump_cs_urb_state(const struct brw_cs_urb_state *ptr);
void
brw_dump_depthbuffer(const struct brw_depthbuffer *ptr);
void
brw_dump_depthbuffer_g4x(const struct brw_depthbuffer_g4x *ptr);
void
brw_dump_drawrect(const struct brw_drawrect *ptr);
void
brw_dump_global_depth_offset_clamp(const struct brw_global_depth_offset_clamp *ptr);
void
brw_dump_gs_unit_state(const struct brw_gs_unit_state *ptr);
void
brw_dump_indexbuffer(const struct brw_indexbuffer *ptr);
void
brw_dump_line_stipple(const struct brw_line_stipple *ptr);
void
brw_dump_mi_flush(const struct brw_mi_flush *ptr);
void
brw_dump_pipe_control(const struct brw_pipe_control *ptr);
void
brw_dump_pipeline_select(const struct brw_pipeline_select *ptr);
void
brw_dump_pipelined_state_pointers(const struct brw_pipelined_state_pointers *ptr);
void
brw_dump_polygon_stipple(const struct brw_polygon_stipple *ptr);
void
brw_dump_polygon_stipple_offset(const struct brw_polygon_stipple_offset *ptr);
void
brw_dump_sampler_default_color(const struct brw_sampler_default_color *ptr);
void
brw_dump_sampler_state(const struct brw_sampler_state *ptr);
void
brw_dump_sf_unit_state(const struct brw_sf_unit_state *ptr);
void
brw_dump_sf_viewport(const struct brw_sf_viewport *ptr);
void
brw_dump_ss0(const struct brw_ss0 *ptr);
void
brw_dump_ss1(const struct brw_ss1 *ptr);
void
brw_dump_ss2(const struct brw_ss2 *ptr);
void
brw_dump_ss3(const struct brw_ss3 *ptr);
void
brw_dump_state_base_address(const struct brw_state_base_address *ptr);
void
brw_dump_state_prefetch(const struct brw_state_prefetch *ptr);
void
brw_dump_surf_ss0(const struct brw_surf_ss0 *ptr);
void
brw_dump_surf_ss1(const struct brw_surf_ss1 *ptr);
void
brw_dump_surf_ss2(const struct brw_surf_ss2 *ptr);
void
brw_dump_surf_ss3(const struct brw_surf_ss3 *ptr);
void
brw_dump_surf_ss4(const struct brw_surf_ss4 *ptr);
void
brw_dump_surf_ss5(const struct brw_surf_ss5 *ptr);
void
brw_dump_surface_state(const struct brw_surface_state *ptr);
void
brw_dump_system_instruction_pointer(const struct brw_system_instruction_pointer *ptr);
void
brw_dump_urb_fence(const struct brw_urb_fence *ptr);
void
brw_dump_urb_immediate(const struct brw_urb_immediate *ptr);
void
brw_dump_vb_array_state(const struct brw_vb_array_state *ptr);
void
brw_dump_vertex_buffer_state(const struct brw_vertex_buffer_state *ptr);
void
brw_dump_vertex_element_packet(const struct brw_vertex_element_packet *ptr);
void
brw_dump_vertex_element_state(const struct brw_vertex_element_state *ptr);
void
brw_dump_vf_statistics(const struct brw_vf_statistics *ptr);
void
brw_dump_vs_unit_state(const struct brw_vs_unit_state *ptr);
void
brw_dump_wm_unit_state(const struct brw_wm_unit_state *ptr);
#endif /* BRW_STRUCTS_DUMP_H */

View file

@ -0,0 +1,284 @@
#!/usr/bin/env python
'''
Generates dumpers for the i965 state strucutures using pygccxml.
Run as
PYTHONPATH=/path/to/pygccxml-1.0.0 python brw_structs_dump.py
Jose Fonseca <jfonseca@vmware.com>
'''
copyright = '''
/**************************************************************************
*
* Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
**************************************************************************/
'''
import os
import sys
from pygccxml import parser
from pygccxml import declarations
from pygccxml.declarations import algorithm
from pygccxml.declarations import decl_visitor
from pygccxml.declarations import type_traits
from pygccxml.declarations import type_visitor
enums = True
class decl_dumper_t(decl_visitor.decl_visitor_t):
def __init__(self, stream, instance = '', decl = None):
decl_visitor.decl_visitor_t.__init__(self)
self.stream = stream
self._instance = instance
self.decl = decl
def clone(self):
return decl_dumper_t(self.stream, self._instance, self.decl)
def visit_class(self):
class_ = self.decl
assert self.decl.class_type in ('struct', 'union')
for variable in class_.variables(recursive = False):
dump_type(self.stream, self._instance + '.' + variable.name, variable.type)
def visit_enumeration(self):
if enums:
self.stream.write(' switch(%s) {\n' % ("(*ptr)" + self._instance,))
for name, value in self.decl.values:
self.stream.write(' case %s:\n' % (name,))
self.stream.write(' debug_printf("\\t\\t%s = %s\\n");\n' % (self._instance, name))
self.stream.write(' break;\n')
self.stream.write(' default:\n')
self.stream.write(' debug_printf("\\t\\t%s = %%i\\n", %s);\n' % (self._instance, "(*ptr)" + self._instance))
self.stream.write(' break;\n')
self.stream.write(' }\n')
else:
self.stream.write(' debug_printf("\\t\\t%s = %%i\\n", %s);\n' % (self._instance, "(*ptr)" + self._instance))
def dump_decl(stream, instance, decl):
dumper = decl_dumper_t(stream, instance, decl)
algorithm.apply_visitor(dumper, decl)
class type_dumper_t(type_visitor.type_visitor_t):
def __init__(self, stream, instance, type_):
type_visitor.type_visitor_t.__init__(self)
self.stream = stream
self.instance = instance
self.type = type_
def clone(self):
return type_dumper_t(self.instance, self.type)
def visit_bool(self):
self.print_instance('%i')
def visit_char(self):
#self.print_instance('%i')
self.print_instance('0x%x')
def visit_unsigned_char(self):
#self.print_instance('%u')
self.print_instance('0x%x')
def visit_signed_char(self):
#self.print_instance('%i')
self.print_instance('0x%x')
def visit_wchar(self):
self.print_instance('0x%x')
def visit_short_int(self):
#self.print_instance('%i')
self.print_instance('0x%x')
def visit_short_unsigned_int(self):
#self.print_instance('%u')
self.print_instance('0x%x')
def visit_int(self):
#self.print_instance('%i')
self.print_instance('0x%x')
def visit_unsigned_int(self):
#self.print_instance('%u')
self.print_instance('0x%x')
def visit_long_int(self):
#self.print_instance('%li')
self.print_instance('0x%lx')
def visit_long_unsigned_int(self):
#self.print_instance('%lu')
self.print_instance('%0xlx')
def visit_long_long_int(self):
#self.print_instance('%lli')
self.print_instance('%0xllx')
def visit_long_long_unsigned_int(self):
#self.print_instance('%llu')
self.print_instance('0x%llx')
def visit_float(self):
self.print_instance('%f')
def visit_double(self):
self.print_instance('%f')
def visit_array(self):
for i in range(type_traits.array_size(self.type)):
dump_type(self.stream, self.instance + '[%i]' % i, type_traits.base_type(self.type))
def visit_pointer(self):
self.print_instance('%p')
def visit_declarated(self):
#stream.write('decl = %r\n' % self.type.decl_string)
decl = type_traits.remove_declarated(self.type)
dump_decl(self.stream, self.instance, decl)
def print_instance(self, format):
self.stream.write(' debug_printf("\\t\\t%s = %s\\n", %s);\n' % (self.instance, format, "(*ptr)" + self.instance))
def dump_type(stream, instance, type_):
type_ = type_traits.remove_alias(type_)
visitor = type_dumper_t(stream, instance, type_)
algorithm.apply_visitor(visitor, type_)
def dump_struct_interface(stream, class_, suffix = ';'):
name = class_.name
assert name.startswith('brw_');
name = name[:4] + 'dump_' + name[4:]
stream.write('void\n')
stream.write('%s(const struct %s *ptr)%s\n' % (name, class_.name, suffix))
def dump_struct_implementation(stream, decls, class_):
dump_struct_interface(stream, class_, suffix = '')
stream.write('{\n')
dump_decl(stream, '', class_)
stream.write('}\n')
stream.write('\n')
def dump_header(stream):
stream.write(copyright.strip() + '\n')
stream.write('\n')
stream.write('/**\n')
stream.write(' * @file\n')
stream.write(' * Dump i965 data structures.\n')
stream.write(' *\n')
stream.write(' * Generated automatically from brw_structs.h by brw_structs_dump.py.\n')
stream.write(' */\n')
stream.write('\n')
def dump_interfaces(decls, global_ns, names):
stream = open('brw_structs_dump.h', 'wt')
dump_header(stream)
stream.write('#ifndef BRW_STRUCTS_DUMP_H\n')
stream.write('#define BRW_STRUCTS_DUMP_H\n')
stream.write('\n')
for name in names:
stream.write('struct %s;\n' % (name,))
stream.write('\n')
for name in names:
(class_,) = global_ns.classes(name = name)
dump_struct_interface(stream, class_)
stream.write('\n')
stream.write('\n')
stream.write('#endif /* BRW_STRUCTS_DUMP_H */\n')
def dump_implementations(decls, global_ns, names):
stream = open('brw_structs_dump.c', 'wt')
dump_header(stream)
stream.write('#include "util/u_debug.h"\n')
stream.write('\n')
stream.write('#include "brw_types.h"\n')
stream.write('#include "brw_structs.h"\n')
stream.write('#include "brw_structs_dump.h"\n')
stream.write('\n')
for name in names:
(class_,) = global_ns.classes(name = name)
dump_struct_implementation(stream, decls, class_)
def decl_filter(decl):
'''Filter the declarations we're interested in'''
name = decl.name
return name.startswith('brw_') and name not in ('brw_instruction',)
def main():
config = parser.config_t(
include_paths = [
'../../include',
],
compiler = 'gcc',
)
headers = [
'brw_types.h',
'brw_structs.h',
]
decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)
global_ns = declarations.get_global_namespace(decls)
names = []
for class_ in global_ns.classes(decl_filter):
names.append(class_.name)
names.sort()
dump_interfaces(decls, global_ns, names)
dump_implementations(decls, global_ns, names)
if __name__ == '__main__':
main()