Commit b0e1917d authored by Connor Abbott's avatar Connor Abbott

make ClauseType handling a little more complete

parent 46303864
......@@ -95,6 +95,13 @@ class SrcOpParserBase(OpParserBase):
opcode >>= (src_cnt - 1) * 3
super().__init__(name, opcode, src_cnt)
class ClauseType(IntEnum):
NONE = 0
UBO_LOAD = 2
SSBO_LOAD = 5
SSBO_STORE = 6
BLEND = 9
ALPHA_TEST = 13
class fma:
NAME = 'FMA'
......@@ -305,10 +312,17 @@ class add:
class OpParser(OpParserBase):
bitlen = 20
def __init__(self, name, opcode, src_cnt=None, has_data_reg=False):
def __init__(self, name, opcode, src_cnt=None, has_data_reg=False, clause_type=None):
self.has_data_reg = has_data_reg
self.clause_type = clause_type
super().__init__(name, opcode, src_cnt)
def parse_op(self, clause, reg_file, srcs):
if self.clause_type:
clause.clause_type = self.clause_type
return super().parse_op(clause, reg_file, srcs)
class SrcOpParser(OpParser, SrcOpParserBase):
pass
......@@ -329,13 +343,15 @@ class add:
class ATestOpParser(SrcOpParser):
def parse_op(self, clause, reg_file, srcs):
clause.clause_type = Clause.ClauseType.ALPHA_TEST
clause.clause_type = ClauseType.ALPHA_TEST
reg_file.const_port = Bits(length=8, uint=5)
return super().parse_op(clause, reg_file, srcs)
class LoadAttrOpParser(OpParser):
pass
def parse_op(self, clause, reg_file, srcs):
clause.clause_type = ClauseType.UBO_LOAD
return super().parse_op(clause, reg_file, srcs)
class VaryingInterpOpParser(OpParser):
pass
......@@ -344,13 +360,16 @@ class add:
pass
class VaryingAddressOpParser(OpParser):
pass
def parse_op(self, clause, reg_file, srcs):
clause.clause_type = ClauseType.UBO_LOAD
return super().parse_op(clause, reg_file, srcs)
class BlendingOpParser(SrcOpParser):
name = "BLEND"
opcode = 0x1952c
src_cnt = 1
has_data_reg = True
clause_type = ClauseType.BLEND
class BlendDescriptor:
def encode_const_field(self):
......@@ -369,7 +388,7 @@ class add:
raise ParsingException("Invalid src '%s' (must be loc_token)" % loc_token)
reg_file.disable_port(1)
clause.clause_type = Clause.ClauseType.BLEND
clause.clause_type = ClauseType.BLEND
try:
reg_file.const_port = self.BlendDescriptor(int(loc_token[1]))
......@@ -459,20 +478,20 @@ class add:
"LD_ATTR.v4u32" : LoadAttrOpParser("LD_ATTR.v4u32", 0x08f00, True),
"LD_VAR.32" : VaryingInterpOpParser("LD_VAR.32", 0x0a000, True),
"TEX" : TexCompactOpParser("TEX", 0x0b000, True),
"LOAD.i32" : SrcOpParser("LOAD.i32", 0x0c188, 2, True),
"LD_UBO.i32" : SrcOpParser("LD_UBO.i32", 0x0c1a0, 2, True),
"LOAD.v2i32" : SrcOpParser("LOAD.v2i32", 0x0c1c8, 2, True),
"LD_UBO.v2i32" : SrcOpParser("LD_UBO.v2i32", 0x0c1e0, 2, True),
"LOAD.v4i32" : SrcOpParser("LOAD.v4i32", 0x0c208, 2, True),
"LOAD.i32" : SrcOpParser("LOAD.i32", 0x0c188, 2, True, ClauseType.SSBO_LOAD),
"LD_UBO.i32" : SrcOpParser("LD_UBO.i32", 0x0c1a0, 2, True, ClauseType.UBO_LOAD),
"LOAD.v2i32" : SrcOpParser("LOAD.v2i32", 0x0c1c8, 2, True, ClauseType.SSBO_LOAD),
"LD_UBO.v2i32" : SrcOpParser("LD_UBO.v2i32", 0x0c1e0, 2, True, ClauseType.UBO_LOAD),
"LOAD.v4i32" : SrcOpParser("LOAD.v4i32", 0x0c208, 2, True, ClauseType.SSBO_LOAD),
# src0 = offset, src1 = binding
"LD_UBO.v4i32" : SrcOpParser("LD_UBO.v4i32", 0x0c220, 2, True),
"STORE.v4i32" : SrcOpParser("STORE.v4i32", 0x0c248, 2, True),
"STORE.i32" : SrcOpParser("STORE.i32", 0x0c588, 2, True),
"STORE.v2i32" : SrcOpParser("STORE.v2i32", 0x0c5c8, 2, True),
"LOAD.u16" : SrcOpParser("LOAD.u16", 0x0c648, 2, True), # zero-extends
"LOAD.v3i32" : SrcOpParser("LOAD.v3i32", 0x0ca88, 2, True),
"LD_UBO.v3i32" : SrcOpParser("LD_UBO.v3i32", 0x0caa0, 2, True),
"STORE.v3i32" : SrcOpParser("STORE.v3i32", 0x0cb88, 2, True),
"LD_UBO.v4i32" : SrcOpParser("LD_UBO.v4i32", 0x0c220, 2, True, ClauseType.UBO_LOAD),
"STORE.v4i32" : SrcOpParser("STORE.v4i32", 0x0c248, 2, True, ClauseType.SSBO_STORE),
"STORE.i32" : SrcOpParser("STORE.i32", 0x0c588, 2, True, ClauseType.SSBO_STORE),
"STORE.v2i32" : SrcOpParser("STORE.v2i32", 0x0c5c8, 2, True, ClauseType.SSBO_STORE),
"LOAD.u16" : SrcOpParser("LOAD.u16", 0x0c648, 2, True, ClauseType.UBO_LOAD), # zero-extends
"LOAD.v3i32" : SrcOpParser("LOAD.v3i32", 0x0ca88, 2, True, ClauseType.SSBO_LOAD),
"LD_UBO.v3i32" : SrcOpParser("LD_UBO.v3i32", 0x0caa0, 2, True, ClauseType.UBO_LOAD),
"STORE.v3i32" : SrcOpParser("STORE.v3i32", 0x0cb88, 2, True, ClauseType.SSBO_STORE),
# Does not exist on G71 (added to G51, G72, and everything after)
"FRCP_FAST.f32" : SrcOpParser("FRCP_FAST.f32", 0x0cc00, 1),
# Produce appropriate scale
......@@ -531,10 +550,10 @@ class add:
"ATEST.X.f16" : ATestOpParser("ATEST.X.f16", 0x191f0, 2, True),
"ATEST.Y.f16" : ATestOpParser("ATEST.Y.f16", 0x191f8, 2, True),
# store a varying given the address and datatype from LD_VAR_ADDR
"ST_VAR.v1" : SrcOpParser("ST_VAR.v1", 0x19300, 3, True),
"ST_VAR.v2" : SrcOpParser("ST_VAR.v2", 0x19340, 3, True),
"ST_VAR.v3" : SrcOpParser("ST_VAR.v3", 0x19380, 3, True),
"ST_VAR.v4" : SrcOpParser("ST_VAR.v4", 0x193c0, 3, True),
"ST_VAR.v1" : SrcOpParser("ST_VAR.v1", 0x19300, 3, True, ClauseType.SSBO_STORE),
"ST_VAR.v2" : SrcOpParser("ST_VAR.v2", 0x19340, 3, True, ClauseType.SSBO_STORE),
"ST_VAR.v3" : SrcOpParser("ST_VAR.v3", 0x19380, 3, True, ClauseType.SSBO_STORE),
"ST_VAR.v4" : SrcOpParser("ST_VAR.v4", 0x193c0, 3, True, ClauseType.SSBO_STORE),
# This takes the sample coverage mask (computed by ATEST above) as a
# regular argument, in addition to the vec4 color in the special register.
"BLEND" : BlendingOpParser(),
......@@ -1101,13 +1120,6 @@ class Instruction:
+ self.reg_file.encode(self))
class Clause:
class ClauseType(IntEnum):
# XXX This isn't going to be used just yet
NONE = 0
SSBO_LOAD = 5
SSBO_STORE = 6
BLEND = 9
ALPHA_TEST = 13
MAX_CONSTS_ALLOWED = 5 # FIXME: maybe make this 6 later?
......@@ -1339,9 +1351,9 @@ class Clause:
@clause_type.setter
def clause_type(self, value):
assert isinstance(self.__clause_type, self.ClauseType)
assert isinstance(self.__clause_type, ClauseType)
if (self.__clause_type is not self.ClauseType.NONE and
if (self.__clause_type is not ClauseType.NONE and
self.__clause_type != value):
raise ParsingException(
("Would need the clause's instruction type to be %s, but the"
......@@ -1810,8 +1822,8 @@ class Clause:
self.__data_reg = None
self.scoreboard_deps = []
self.scoreboard_entry = None
self.__clause_type = self.ClauseType.NONE
self.next_clause_type = self.ClauseType.NONE
self.__clause_type = ClauseType.NONE
self.next_clause_type = ClauseType.NONE
self.unk0 = False
self.unk1 = False
self.unk3 = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment