assembler/vs/validator: only count temp addresses for macro operations
This commit is contained in:
parent
44dd480549
commit
4777be84d4
@ -9,8 +9,8 @@ LDFLAGS += $(shell pkg-config --libs libdrm) -lm
|
||||
%: %.c
|
||||
$(CC) $(ARCH) $(CFLAGS) $(LDFLAGS) $(OPT) $< -o $@
|
||||
|
||||
%.inc: %.asm
|
||||
PYTHONPATH=../regs/ python -m assembler $< > $@
|
||||
%.vs.inc: %.vs.asm
|
||||
PYTHONPATH=../regs/ python -m assembler.vs $< > $@
|
||||
|
||||
clean:
|
||||
find . -type f ! -name "*.*" -delete
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
; CONST[0] = {0.159155, 0.5, 6.283185, -3.141593}
|
||||
; CONST[1] = {rotate, _, _, _}
|
||||
# CONST[0] = {0.159155, 0.5, 6.283185, -3.141593}
|
||||
# CONST[1] = {rotate, _, _, _}
|
||||
|
||||
; each instruction is only allowed to use a single unique `const` address
|
||||
;
|
||||
; instructions may use multiple `temp` addresses, so const[1] is moved to
|
||||
; temp[0]:
|
||||
;
|
||||
# each instruction is only allowed to use a single unique `const` address
|
||||
#
|
||||
# instructions may use multiple `temp` addresses, so const[1] is moved to
|
||||
# temp[0]:
|
||||
#
|
||||
temp[0].x = VE_ADD const[1].x___ const[1].0___
|
||||
|
||||
|
||||
; ME_SIN and ME_COS are clamped to the range -π to +π prior to the sin/cos
|
||||
; calculation.
|
||||
;
|
||||
; This 3-instruction sequence linearly remaps the range [-∞,+∞] to [-π,+π]
|
||||
# ME_SIN and ME_COS are clamped to the range -π to +π prior to the sin/cos
|
||||
# calculation.
|
||||
#
|
||||
# This 3-instruction sequence linearly remaps the range [-∞,+∞] to [-π,+π]
|
||||
temp[1].x = VE_MAD temp[0].x___ const[0].x___ const[0].y___
|
||||
temp[2].x = VE_FRC temp[1].x___
|
||||
temp[3].x = VE_MAD temp[2].x___ const[0].z___ const[0].w___
|
||||
@ -20,11 +20,11 @@ temp[3].x = VE_MAD temp[2].x___ const[0].z___ const[0].w___
|
||||
temp[4].x = ME_SIN temp[3].___x
|
||||
temp[4].y = ME_COS temp[3].___x
|
||||
|
||||
; with sin and cos calculated, this now ordinary two-dimensional rotation:
|
||||
;
|
||||
; x = position.x * cost - position.y * sint
|
||||
; y = position.x * sint + position.y * cost
|
||||
; z = 0
|
||||
; w = 1
|
||||
# with sin and cos calculated, this now ordinary two-dimensional rotation:
|
||||
#
|
||||
# x = position.x * cost - position.y * sint
|
||||
# y = position.x * sint + position.y * cost
|
||||
# z = 0
|
||||
# w = 1
|
||||
temp[5].xy = VE_MUL input[0].yy__ temp[4].xy__
|
||||
out[0].xyzw = VE_MAD input[0].xx01 temp[4].yx01 temp[5].-xy00
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
from assembler.vs.keywords import ME, VE, macro_vector_operations
|
||||
from assembler.vs.keywords import KW, ME, VE, macro_vector_operations
|
||||
|
||||
class ValidatorError(Exception):
|
||||
pass
|
||||
|
||||
def validate_instruction(ins):
|
||||
addresses = len(set(
|
||||
temp_addresses = len(set(
|
||||
source.offset
|
||||
for source in [ins.source0, ins.source1, ins.source2]
|
||||
if source is not None
|
||||
if (source is not None and source.type == KW.temporary)
|
||||
))
|
||||
if addresses > 2:
|
||||
if temp_addresses > 2:
|
||||
if type(ins.destination_op.opcode) is not VE:
|
||||
raise ValidatorError("too many addresses for non-VE instruction", ins)
|
||||
if ins.destination_op.opcode.name not in {b"VE_MULTIPLYX2_ADD", b"VE_MULTIPLY_ADD"}:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user