tests/1.vsh
author Ethan Lee <flibitijibibo@flibitijibibo.com>
Tue, 07 Jul 2020 17:44:32 -0400
changeset 1278 be0f548f321f
parent 23 8a6ac66b0761
permissions -rw-r--r--
spirv: Fix bogus detection of PSIZE0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     1
vs_3_sw
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     2
    def c3056, 1, 2, 3, 4
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     3
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     4
dcl_position v0
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     5
dcl_normal v1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     6
dcl_normal1 v3
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     7
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     8
dcl_color4     o3.x  
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
     9
dcl_texcoord3  o3.yz 
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    10
dcl_fog        o3.w 
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    11
dcl_tangent    o4.xyz
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    12
dcl_position   o7.xyzw
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    13
dcl_psize      o6
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    14
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    15
#define oPos o7
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    16
#define oD0 o3
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    17
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    18
def c76, -10.0e5, 2.0e4, 3.3e2, 4.4
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    19
def c15, 1, 2, 3, 4
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    20
defi i1, 1, 2, 3,0
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    21
defb b11, true
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    22
defb b12, false
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    23
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    24
if_le v0.x, v1.y
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    25
nop
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    26
else
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    27
nop
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    28
endif
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    29
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    30
mova a0.yw, v0.argb
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    31
loop aL, i1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    32
nop
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    33
break_le v1.x, r0.y
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    34
breakp !p0.y
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    35
nop
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    36
endloop
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    37
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    38
; Decompress position
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    39
mov r0.x, v0.x
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    40
mov r0.y, c4.w       ; 1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    41
mov r0.z, v0.y
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    42
mov r0.w, c4.w       ; 1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    43
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    44
setp_ge p0.yz, v1, v1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    45
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    46
callnz l1, b11
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    47
callnz l1, !p0.w
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    48
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    49
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    50
if !p0.z
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    51
m3x2   r0.xy, r1, c0   ;which will be expanded to:
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    52
else
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    53
nop
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    54
endif
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    55
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    56
call l1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    57
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    58
; Debug code [start]
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    59
ret
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    60
label l1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    61
m3x2   r0.xy, r1, c0   ;which will be expanded to:
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    62
mov r0, r0.xz     
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    63
; Debug code [end]
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    64
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    65
; Compute theta from distance and time
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    66
mov r4.xz, r0        ; xz
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    67
mov r4.y, c4.y       ; y = 0
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    68
dp3 r4.x, r4, r4     ; d2
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    69
rsq r4.x, r4.x
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    70
rcp r4.x, r4.x       ; d
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    71
mul r4.xyz, r4, c4.x     ; scale by time
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    72
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    73
; Clamp theta to -pi..pi
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    74
add r4.x, r4.x, c7.x
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    75
mul r4.x, r4.x, c7.y
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    76
frc r4.xy, r4.x
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    77
mul r4.x, r4.x, c7.z
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    78
add r4.x, r4.x,-c7.x
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    79
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    80
; Compute first 4 values in sin and cos series
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    81
mov r5.x, c4.w       ; d^0
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    82
mov r4.x, r4.x       ; d^1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    83
mul r5.y, r4.x, r4.x ; d^2
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    84
mul r4.y, r4.x, r5.y ; d^3
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    85
mul r5.z, r5.y, r5.y ; d^4
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    86
mul r4.z, r4.x, r5.z ; d^5
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    87
mul r5.w, r5.y, r5.z ; d^6
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    88
mul r4.w, r4.x, r5.w ; d^7
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    89
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    90
mul r4, r4, c10      ; sin
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    91
dp4 r4.x, r4, c4.w
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    92
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    93
mul r5, r5, c11      ; cos
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    94
dp4 r5.x, r5, c4.w
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    95
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    96
; Set color
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    97
add r5.x, -r5.x, c4.w ; + 1.0
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    98
mul oD0, r5.x, c4.z   ; * 0.5
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
    99
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   100
; Scale height
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   101
mul r0.y, r4.x, c7.w
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   102
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   103
; Transform position
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   104
dp4 oPos.x, r0, c0
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   105
dp4 oPos.y, r0, c1
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   106
dp4 oPos.z, r0, c2
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   107
dp4 oPos.w, r0, c3
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   108
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   109
ret
8a6ac66b0761 [svn] Endline fixes for test shader assembly code.
icculus
parents: 3
diff changeset
   110