renouveau: nv30/nv40 unification
cover renouveau: nv30/nv40 unification
This patchset applies some minor fixes to renouveau.xml and then unifies the nv30 and nv40 register definitions.
nv30 and nv40 are very similar and have the same offsets for the registers they share.
The major differences are:
1. Texture setup is different due to full NPOT support on nv40
2. More advanced blending/render targets on nv40
3. NV30 has fixed function registers, which NV40 lacks
The vertex shader instruction format also differs, but this does not affect renouveau.xml.
This is in preparation for unifying the Gallium drivers.
Unification is carried out by creating a new artificial "NVFXTCL" object.
This results in most of the old NV34TCL_ and NV40TCL_ definitions being replaced by NVFXTCL_. A sed script is provided to fix the Gallium driver and DDX.
This provides the following advantages:
1. Registers are defined only once in renouveau.xml
2. grep NV34TCL_ yields all usages of NV30-only functionality
3. grep NV40TCL_ yields all usages of NV40-only functionality
The "FX" name comes from CineFX, which nVidia uses to refers to, and only to, nv30 and nv40 hardware.
There are some mentions on the web of CineFX referring to nv50 too, but I could not find any official uses of it from nVidia.
This approach has been criticized due to the fact that other registers are either named for the first card having them, or duplicated for every card.
However, I believe the additional clarity of the NVFXTCL_ approach is worthwhile.
If consensus develops against this notion, it is easy to change the Python script that generated the unification patch and rerun it.
Luca Barbieri (5):
renouveau: completely describe POINT_SPRITE on nv30 and nv40 renouveau/nv40: describe CLEAR_VALUE_COLOR bitfields renouveau/nv40: set NV40TCL_LINE_STIPPLE_PATTERN to hexa like nv30 renouveau/nv30: remove clip planes #6 and #7
renouveau: unify nv30 and nv40 as NVFXTCL
nvfx.py | 207 +++++++++++++ nvfx.sed | 340 ++++++++++++++++++++++ renouveau.xml | 891 ++++++++++++++++++++++----------------------------------- 3 files changed, 889 insertions(+), 549 deletions(-) create mode 100755 nvfx.py create mode 100644 nvfx.sed
A message that is not in the archive (sent off-list or not yet received): 1267191504-24575-1-git-send-email-luca-Ukmtq+NC3rhBHFWNQifrYwC/[email protected]
PATCH 1/5 renouveau: completely describe POINT_SPRITE on nv30 and nv40
This matches the behavior of the Gallium drivers.
On nv20, only texture unit 3 is accelerated (according to the NV_point_sprite spec, and that is probably why only bitfield 11 was defined on nv30).
--- renouveau.xml | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-)
renouveau.xml +22 -4
@@ -3884,9 +3884,16 @@ <reg32 offset="0x1ee0" name="POINT_SIZE" type="float"/> <reg32 offset="0x1ee4" name="POINT_PARAMETERS_ENABLE" type="boolean"/> <reg32 offset="0x1ee8" name="POINT_SPRITE" type="bitfield"> - <bitfield name="ENABLE" high="0" low="0" type="boolean"/> - <bitfield name="R_MODE" high="2" low="1" type="enum" enum_name="nv20_point_sprite_r_mode"/> - <bitfield name="COORD_REPLACE" high="11" low="11" type="boolean"/> + <bitfield high="0" low="0" name="ENABLE" type="boolean" /> + <bitfield enum_name="nv20_point_sprite_r_mode" high="2" low="1" name="R_MODE" type="enum" /> + <bitfield high="8" low="8" name="COORD_REPLACE_0" type="boolean" /> + <bitfield high="9" low="9" name="COORD_REPLACE_1" type="boolean" /> + <bitfield high="10" low="10" name="COORD_REPLACE_2" type="boolean" /> + <bitfield high="11" low="11" name="COORD_REPLACE_3" type="boolean" /> + <bitfield high="12" low="12" name="COORD_REPLACE_4" type="boolean" /> + <bitfield high="13" low="13" name="COORD_REPLACE_5" type="boolean" /> + <bitfield high="14" low="14" name="COORD_REPLACE_6" type="boolean" /> + <bitfield high="15" low="15" name="COORD_REPLACE_7" type="boolean" /> </reg32> <reg32 offset="0x1efc" name="VP_UPLOAD_CONST_ID" type="hexa"/> <reg32 offset="0x1f00" name="VP_UPLOAD_CONST_X" size="4" stride="16" type="float"/>
@@ -4270,7 +4277,18 @@ <reg32 offset="0x1ea8"/> <reg32 offset="0x1eac"/> <reg32 offset="0x1ee0" name="POINT_SIZE" type="float"/> - <reg32 offset="0x1ee8" name="POINT_SPRITE"/> + <reg32 offset="0x1ee8" name="POINT_SPRITE" type="bitfield"> + <bitfield high="0" low="0" name="ENABLE" type="boolean" /> + <bitfield enum_name="nv20_point_sprite_r_mode" high="2" low="1" name="R_MODE" type="enum" /> + <bitfield high="8" low="8" name="COORD_REPLACE_0" type="boolean" /> + <bitfield high="9" low="9" name="COORD_REPLACE_1" type="boolean" /> + <bitfield high="10" low="10" name="COORD_REPLACE_2" type="boolean" /> + <bitfield high="11" low="11" name="COORD_REPLACE_3" type="boolean" /> + <bitfield high="12" low="12" name="COORD_REPLACE_4" type="boolean" /> + <bitfield high="13" low="13" name="COORD_REPLACE_5" type="boolean" /> + <bitfield high="14" low="14" name="COORD_REPLACE_6" type="boolean" /> + <bitfield high="15" low="15" name="COORD_REPLACE_7" type="boolean" /> + </reg32> <reg32 offset="0x1ef8"/> <reg32 offset="0x1efc" name="VP_UPLOAD_CONST_ID" type="hexa"/> <reg32 offset="0x1f00" name="VP_UPLOAD_CONST_X" size="4" stride="16" type="float"/>
Signature · 1 line
1.6.6.1.476.g01ddb
PATCH 2/5 renouveau/nv40: describe CLEAR_VALUE_COLOR bitfields
In reply to a message not in the archive--- renouveau.xml | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
renouveau.xml +6 -1
@@ -4253,7 +4253,12 @@ <reg32 offset="0x1d84"/> <reg32 offset="0x1d88"/> <reg32 offset="0x1d8c" name="CLEAR_VALUE_DEPTH"/> - <reg32 offset="0x1d90" name="CLEAR_VALUE_COLOR"/> + <reg32 offset="0x1d90" name="CLEAR_VALUE_COLOR" type="bitfield"> + <bitfield name="B" high="7" low="0" type="int" /> + <bitfield name="G" high="15" low="8" type="int" /> + <bitfield name="R" high="23" low="16" type="int" /> + <bitfield name="A" high="31" low="24" type="int" /> + </reg32> <reg32 offset="0x1d94" name="CLEAR_BUFFERS" type="bitfield"> <bitfield name="COLOR_A" high="7" low="7" type="boolean"/> <bitfield name="COLOR_B" high="6" low="6" type="boolean"/>
Signature · 1 line
1.6.6.1.476.g01ddb
PATCH 3/5 renouveau/nv40: set NV40TCL_LINE_STIPPLE_PATTERN to hexa like nv30
In reply to a message not in the archive--- renouveau.xml | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
renouveau.xml +1 -1
@@ -4271,7 +4271,7 @@ <reg32 offset="0x1db4" name="LINE_STIPPLE_ENABLE" type="boolean"/> <reg32 offset="0x1db8" name="LINE_STIPPLE_PATTERN" type="bitfield"> <bitfield name="FACTOR" high="15" low="0" type="int"/> - <bitfield name="PATTERN" high="31" low="16" type="int"/> + <bitfield name="PATTERN" high="31" low="16" type="hexa"/> </reg32> <reg32 offset="0x1e40" name="VTX_ATTR_1F" size="16" type="float"/> <reg32 offset="0x1e94"/>
Signature · 1 line
1.6.6.1.476.g01ddb
PATCH 4/5 renouveau/nv30: remove clip planes #6 and #7
In reply to a message not in the archiveThese are defined for nv30 and not nv40, and they probably don't exist in the hardware.
Both DirectX and OpenGL nVidia drivers support only 6 clip planes on pre-nv50 hardware.
Neither the DDX nor the Gallium driver support user clip planes at all on nv30.
This makes the definition the same as nv40, so they can be unified.
--- renouveau.xml | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
renouveau.xml +0 -2
@@ -3681,8 +3681,6 @@ <bitfield name="PLANE3" high="13" low="13" type="boolean"/> <bitfield name="PLANE4" high="17" low="17" type="boolean"/> <bitfield name="PLANE5" high="21" low="21" type="boolean"/> - <bitfield name="PLANE6" high="25" low="25" type="boolean"/> - <bitfield name="PLANE7" high="29" low="29" type="boolean"/> </reg32> <reg32 offset="0x147c" name="POLYGON_STIPPLE_ENABLE" type="boolean"/> <reg32 offset="0x1480" name="POLYGON_STIPPLE_PATTERN" size="32" type="hexa"/>
Signature · 1 line
1.6.6.1.476.g01ddb
PATCH 5/5 renouveau: unify nv30 and nv40 as NVFXTCL
In reply to a message not in the archiveThis patch unifies all the registers that are the same between nv30 and nv40.
nv30 and nv40 are mostly identical, except for the following areas:
- Texture sampler definition
- Separate blend equation
- MRT
- FP_CONTROL
- Miscellaneous unused registers that may be wrong
A new "NVFXTCL" is created and contains all the common registers.
A sed script (use sed -r or perl -p for it) is also committed, that can be used to fix the constants in the Gallium driver and DDX.
This change was automatically generated with a Python script, which is committed as well.
--- nvfx.py | 207 +++++++++++++ nvfx.sed | 340 +++++++++++++++++++++ renouveau.xml | 912 +++++++++++++++++++++----------------------------------- 3 files changed, 889 insertions(+), 570 deletions(-) create mode 100755 nvfx.py create mode 100644 nvfx.sed
nvfx.py new file +207 -0
@@ -0,0 +1,207 @@ +#!/usr/bin/python +#use diff -w -u to ignore whitespace due to difference between attr="" /> and attr=""/> +import sys +# don't use ElementTree/cElementTree because they don't preserve attribute order +from lxml import etree as ET +xml = sys.argv[1] if 1 in sys.argv else "renouveau.xml" +tree = ET.parse(xml) +root = tree.getroot(); +nv30tcl = None +tclnames = ("NV34TCL", "NV40TCL") +unitclname = "NVFXTCL" +unitclid = "0xfa1e3040" +tcls = [None for i in tclnames] +for obj in root: + if obj.tag != "object": + continue + for i in xrange(len(tclnames)): + if obj.get("name") == tclnames[i]: + if obj.get("parent"): + print "ERROR:", tclnames[i], "has a parent" + sys.exit(1) + tcls[i] = obj + if obj.attrib["name"] == "NV30TCL": + nv30tcl = obj + +def get_regs(tcl): + regs = {} + for i in tcl.iterchildren(tag=ET.Element): + assert i.tag == "reg32" + regs[i.get("offset")] = i + return regs + +def fix_field_name(fname): + return fname.replace("MAGNIFY", "MAG").replace("MINIFY", "MIN") + +def get_fields(reg32): + fields = {} + for i in reg32.iterchildren(tag=ET.Element): + assert i.tag == "bitfield" + fields[fix_field_name(i.get("name"))] = i + return fields + +def get_field_list(reg32): + fields = [] + for i in reg32.iterchildren(tag=ET.Element): + assert i.tag == "bitfield" + fields.append((int(i.get("low")), i)) + fields.sort() + return [reg for low, reg in fields] + +dicts = [get_regs(tcl) for tcl in tcls] + +nvfx_sed = open("nvfx.sed", "w") +diffs = open("diffs", "w") + +common = ET.Element("object") +common.set("name", unitclname) +common.set("id", unitclid) +common.text = "\n " + +for tcl in tcls: + for reg32 in tcl: + if reg32.tail: + reg32.tail = "\n " + +for reg32 in tcls[0].iterchildren(tag=ET.Element): + offset = reg32.attrib["offset"] + regs = [d.get(offset) for d in dicts] + missing = 0 + for i in xrange(len(regs)): + if regs[i] == None: + missing += 1 + if missing: + continue + + names = [r.get("name") for r in regs] + candnames = [n for n in names if n] + name = None + if candnames: + name = candnames[-1] + +# these must not be unified + if name == "MRT_COLOR_MASK" or name == "TEX_SIZE1" or name == "UNK0400" or name == "ZETA_PITCH": + continue + + diff = 0 + +# these have bitfields defined on nv30 but not nv40 + use_nv30 = False + if name == "VIEWPORT_CLIP_HORIZ" or name == "VIEWPORT_CLIP_VERT": + use_nv30 = True + +# these are the same but have bitfield definition lines in opposite order: use ascending nv30 order + if name == "RT_HORIZ" or name == "RT_VERT" or name == "VIEWPORT_HORIZ" or name == "VIEWPORT_VERT" or name == "VB_ELEMENT_U16" or name == "VB_VERTEX_BATCH" or name == "FP_ADDRESS": + use_nv30 = True + +# this is not described on nv40, presumably it's the same as nv30 + if name == "MULTISAMPLE_CONTROL": + use_nv30 = True + + deep = False + # these have different contents, but we want the register to exist in NVFX + if name == "FP_CONTROL" or name == "COLOR_MASK" or name == "COLOR0_PITCH": + deep = True + + # texture fields, we want the registers to exist in NVFX but not the contents + if int(offset, 16) >= 0x1a00 and int(offset, 16) < 0x1a20: + deep = True + + ext_nv40 = False +# nv40 also has rt2 and rt3 + if name == "RT_ENABLE": + ext_nv40 = True + + if not deep: + if not use_nv30 and not ext_nv40: + s = None + for i in xrange(len(regs)): + r = ET.fromstring(ET.tostring(regs[i])) + r.attrib["name"] = "" + if s == None: + s = ET.tostring(r).strip() + elif ET.tostring(r).strip() != s: + diff += 1 + if diff: + print >> diffs, "DIFF:", name + print >> diffs, ET.tostring(regs[0]) + print >> diffs, ET.tostring(regs[1]) + continue + else: + fields = [get_fields(reg) for reg in regs] + field_list = get_field_list(regs[0]) + creg = ET.Element("reg32") + creg.set("offset", offset) + creg.set("name", name) + if regs[0].attrib["type"] == regs[1].attrib["type"]: + creg.set("type", regs[0].attrib["type"]) + else: + creg.set("type", "hexa") + if "size" in regs[0].attrib or "size" in regs[1].attrib: + size0 = int(regs[0].attrib["size"]) if "size" in regs[0].attrib else 0 + size1 = int(regs[1].attrib["size"]) if "size" in regs[1].attrib else 0 + creg.attrib["size"] = str(size1 if size1 > size0 else size0) + if "stride" in regs[0].attrib or "stride" in regs[1].attrib: + assert regs[0].attrib["stride"] == regs[1].attrib["stride"] + creg.attrib["stride"] = regs[0].attrib["stride"] + creg.tail = "\n " + prev = None + perfect = len(fields[0]) == len(fields[1]) + cfields = [] + for field0 in field_list: + fname = fix_field_name(field0.attrib["name"]) + if fname in fields[0] and fname in fields[1]: + s0 = fix_field_name(ET.tostring(fields[0][fname]).strip()) + s1 = fix_field_name(ET.tostring(fields[1][fname]).strip()) + if "nv04_tx_wrap" in s0: + s0 = s0.replace("nv04_tx_wrap", "nv40_texture_wrap") + s0 = s0.replace("high=\"7\"", "high=\"3\"") + if s0 == s1: + if prev == None: + creg.text = "\n " + else: + prev.tail = "\n " + cfield = ET.fromstring(ET.tostring(fields[1][fname])) + cfield.attrib["name"] = fname + cfield.tail = "\n " + creg.append(cfield) + prev = cfield + cfields.append(cfield) + else: + perfect = False + else: + perfect = False + + if not perfect: + for i in xrange(len(tcls)): + for cfield in cfields: + r = regs[i] + fname = cfield.attrib["name"] + print >> nvfx_sed, "s/" + tclnames[i] + "_" + r.attrib["name"] + "_" + fields[i][fname].attrib["name"] + "/" + unitclname + "_" + name + "_" + fname + "/g;" + print >> nvfx_sed, "s/" + tclnames[i] + "_" + r.attrib["name"] + "([^_])/" + unitclname + "_" + name + "\\1/g;" + common.append(creg) + continue + + if name: + for i in xrange(len(tcls)): + if ext_nv40 and i == 1: + continue + r = regs[i] + if "name" in r.attrib: + print >> nvfx_sed, "s/" + tclnames[i] + "_" + r.attrib["name"] + "/" + unitclname + "_" + name + "/g;" + r.attrib["name"] = name + + tcls[0].remove(regs[0]) + if not ext_nv40: + tcls[1].remove(regs[1]) + + regs[0].tail = "\n " + common.append(regs[0]) +# print name + +common.tail = "\n\n " +root.insert(root.index(nv30tcl), common) + +print "<?xml version=\"1.0\"?>" +print +print ET.tostring(root)
nvfx.sed new file +340 -0
340 lines not on this page · raw message
renouveau.xml +342 -570
1,191 lines not on this page · raw message
Signature · 1 line
1.6.6.1.476.g01ddb