[Mesa-dev] [PATCH 1/8] genxml: Add pitch bitfield sizes to gen*_pack.h
Chad Versace
chadversary at chromium.org
Tue Mar 21 23:02:33 UTC 2017
For each structure or instruction member in gen*_pack.h whose name
matches /.*Surface(Q?)Pitch$", add a macro that defines the member's
bitfield size.
isl will use these macros to validate requested pitches.
Example: Changes to RENDER_SURFACE_STATE in gen9_pack.h:
#define GEN9_RENDER_SURFACE_STATE_length 16
+#define GEN9_RENDER_SURFACE_STATE_SurfaceQPitch_bits 15
+#define GEN9_RENDER_SURFACE_STATE_SurfacePitch_bits 18
+#define GEN9_RENDER_SURFACE_STATE_AuxiliarySurfaceQPitch_bits 15
+#define GEN9_RENDER_SURFACE_STATE_AuxiliarySurfacePitch_bits 9
struct GEN9_RENDER_SURFACE_STATE {
uint32_t SurfaceType;
Example: Changes to 3DSTATE_DEPTH_BUFFER in gen9_pack.h:
#define GEN9_3DSTATE_DEPTH_BUFFER_length 8
#define GEN9_3DSTATE_DEPTH_BUFFER_length_bias 2
#define GEN9_3DSTATE_DEPTH_BUFFER_header \
.CommandType = 3, \
.CommandSubType = 3, \
._3DCommandOpcode = 0, \
._3DCommandSubOpcode = 5, \
.DWordLength = 6
+#define GEN9_3DSTATE_DEPTH_BUFFER_SurfacePitch_bits 18
+#define GEN9_3DSTATE_DEPTH_BUFFER_SurfaceQPitch_bits 15
---
src/intel/genxml/gen_pack_header.py | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/intel/genxml/gen_pack_header.py b/src/intel/genxml/gen_pack_header.py
index 2a709454af3..71b22f77403 100644
--- a/src/intel/genxml/gen_pack_header.py
+++ b/src/intel/genxml/gen_pack_header.py
@@ -216,6 +216,7 @@ def num_from_str(num_str):
class Field(object):
ufixed_pattern = re.compile(r"u(\d+)\.(\d+)")
sfixed_pattern = re.compile(r"s(\d+)\.(\d+)")
+ surface_pitch_pattern = re.compile(r"\w*Surface(Q?)Pitch\w*")
def __init__(self, parser, attrs):
self.parser = parser
@@ -225,6 +226,15 @@ class Field(object):
self.end = int(attrs["end"])
self.type = attrs["type"]
+ if parser.instruction:
+ self.container_name = parser.instruction
+ elif parser.struct:
+ self.container_name = parser.struct
+ elif parser.register:
+ self.container_name = parser.register
+ else:
+ assert False
+
if "prefix" in attrs:
self.prefix = attrs["prefix"]
else:
@@ -601,10 +611,9 @@ class Parser(object):
if default_fields:
print('#define %-40s\\' % (self.gen_prefix(name + '_header')))
print(", \\\n".join(default_fields))
- print('')
+ self.emit_field_sizes(self.instruction, self.group)
self.emit_template_struct(self.instruction, self.group)
-
self.emit_pack_function(self.instruction, self.group)
def emit_register(self):
@@ -626,6 +635,7 @@ class Parser(object):
print('#define %-33s %6d' %
(self.gen_prefix(name + "_length"), self.length))
+ self.emit_field_sizes(self.struct, self.group)
self.emit_template_struct(self.struct, self.group)
self.emit_pack_function(self.struct, self.group)
@@ -639,6 +649,20 @@ class Parser(object):
print(' %-36s = %6d,' % (name.upper(), value.value))
print('};\n')
+ def emit_field_sizes(self, container_name, group):
+ for field in group.fields:
+ if type(field) is not Field:
+ continue
+ if not hasattr(field, 'name'):
+ continue
+ if not Field.surface_pitch_pattern.match(field.name):
+ continue
+ name = self.gen_prefix('%s_%s_bits' %
+ (container_name, field.name))
+ bits = 1 + field.end - field.start
+ print('#define %-56s %2d' % (name, bits))
+ print('')
+
def parse(self, filename):
file = open(filename, "rb")
self.parser.ParseFile(file)
--
2.12.0
More information about the mesa-dev
mailing list