Compare commits
2 Commits
1dc62d90ee
...
836ecefac4
| Author | SHA1 | Date | |
|---|---|---|---|
| 836ecefac4 | |||
| 8e6e6e9750 |
1293
drm/matrix_cubesphere_specular.cpp
Normal file
1293
drm/matrix_cubesphere_specular.cpp
Normal file
File diff suppressed because it is too large
Load Diff
102
drm/matrix_cubesphere_specular.fs.asm
Normal file
102
drm/matrix_cubesphere_specular.fs.asm
Normal file
@ -0,0 +1,102 @@
|
||||
-- temp[0] -- position (world space)
|
||||
-- temp[1] -- normal
|
||||
-- temp[2] -- light pos (world space)
|
||||
-- temp[3] -- view pos (world space)
|
||||
-- temp[4] -- texture
|
||||
|
||||
-- PIXSIZE 4
|
||||
|
||||
TEX TEX_SEM_WAIT TEX_SEM_ACQUIRE
|
||||
temp[4].rgba = LD tex[0].rgba temp[4].rgaa ;
|
||||
|
||||
-- normal = normalize(normal)
|
||||
-- normal = (1.0 / sqrt(dot(normal, normal))) * normal
|
||||
src0.rgb = temp[1] :
|
||||
DP3 src0.rgb src0.rgb ,
|
||||
temp[1].a = DP ;
|
||||
src0.a = temp[1] :
|
||||
temp[1].a = RSQ |src0.a| ;
|
||||
src0.a = temp[1], src0.rgb = temp[1] :
|
||||
temp[1].rgb = MAD src0.rgb src0.aaa src0.000 ;
|
||||
|
||||
-- light_dir = normalize((f_light_pos - f_world_pos))
|
||||
src1.rgb = temp[2] , -- f_light_pos
|
||||
src0.rgb = temp[0] , -- f_world_pos
|
||||
srcp.rgb = neg : -- (f_light_pos - f_world_pos)
|
||||
DP3 srcp.rgb srcp.rgb ,
|
||||
temp[2].a = DP ;
|
||||
src0.a = temp[2] :
|
||||
temp[2].a = RSQ |src0.a| ;
|
||||
src0.a = temp[2], src0.rgb = temp[2] :
|
||||
temp[2].rgb = MAD src0.rgb src0.aaa src0.000 ;
|
||||
|
||||
-- diff = dot(normal, light_dir)
|
||||
src0.rgb = temp[2] ,
|
||||
src1.rgb = temp[1] :
|
||||
DP3 src0.rgb src1.rgb ,
|
||||
temp[5].a = DP ;
|
||||
|
||||
-- diff = max(diff, 0)
|
||||
src0.a = temp[5] :
|
||||
temp[5].a = MAX src0.a src0.0 ;
|
||||
|
||||
-- intensity = diff + 0.125
|
||||
src0.a = temp[5] ,
|
||||
src1.a = float(32) : -- 0.125
|
||||
temp[5].a = MAD src0.a src0.1 src1.a ;
|
||||
|
||||
--
|
||||
-- specular
|
||||
--
|
||||
-- temp[3] -- view pos (world space)
|
||||
-- view_dir = normalize(f_view_pos - f_world_pos)
|
||||
src1.rgb = temp[3] , -- f_light_pos
|
||||
src0.rgb = temp[0] , -- f_world_pos
|
||||
srcp.rgb = neg : -- (f_light_pos - f_world_pos)
|
||||
DP3 srcp.rgb srcp.rgb ,
|
||||
temp[3].a = DP ;
|
||||
src0.a = temp[3] :
|
||||
temp[3].a = RSQ |src0.a| ;
|
||||
src0.a = temp[3], src0.rgb = temp[3] :
|
||||
temp[3].rgb = MAD src0.rgb src0.aaa src0.000 ;
|
||||
|
||||
-- reflect(I, N)
|
||||
-- I - 2.0 * dot(N, I) * N
|
||||
-- reflect_dir = reflect(-light_dir, norm)
|
||||
-- reflect_dir = reflect(-temp[2], temp[1])
|
||||
-- I - 2.0 * dot(N, I) * N
|
||||
-- - (2.0 * dot(N, I)) * temp[1] + -temp[2]
|
||||
src0.rgb = temp[1] , -- N=normal
|
||||
src1.rgb = temp[2] : -- I=light_dir dot(N, -I)
|
||||
temp[6].r = DP3 src0.rgb -src1.rgb ;
|
||||
src0.rgb = temp[6] ,
|
||||
src1.rgb = float(64) : -- 2.0
|
||||
temp[6].r = MAD src0.r00 src1.r00 src0.000 ;
|
||||
src0.rgb = temp[6] ,
|
||||
src1.rgb = temp[1] , -- N
|
||||
src2.rgb = temp[2] : -- I
|
||||
temp[6].rgb = MAD -src0.rrr src1.rgb -src2.rgb ;
|
||||
|
||||
-- spec = max(dot(view_dir, reflect_dir), 0.0)
|
||||
src0.rgb = temp[6] , -- reflect_dir
|
||||
src1.rgb = temp[3] : -- view_dir
|
||||
temp[6].r = DP3 src0.rgb src1.rgb ;
|
||||
src0.rgb = temp[6] :
|
||||
temp[6].a = MAX src0.r src0.0 ;
|
||||
|
||||
-- spec = pow(spec, 32)
|
||||
src0.a = temp[6] :
|
||||
temp[6].a = LN2 src0.a ;
|
||||
src0.a = temp[6] ,
|
||||
src1.a = float(72) : -- 32
|
||||
temp[6].a = MAD src0.a src1.a src1.0 ;
|
||||
src0.a = temp[6] :
|
||||
temp[6].a = EX2 src0.a ;
|
||||
|
||||
OUT TEX_SEM_WAIT
|
||||
src0.a = temp[4],
|
||||
src0.rgb = temp[4] ,
|
||||
src1.a = temp[6] ,
|
||||
src1.rgb = temp[6] :
|
||||
out[0].a = MAX src0.a src0.a ,
|
||||
out[0].rgb = MAD src0.111 src1.aaa src1.000 ;
|
||||
48
drm/matrix_cubesphere_specular.vs.asm
Normal file
48
drm/matrix_cubesphere_specular.vs.asm
Normal file
@ -0,0 +1,48 @@
|
||||
--
|
||||
-- dot(m[0], v), dot(m[1], v), dot(m[2], v), dot(m[3], v)
|
||||
--
|
||||
|
||||
-- input[0] -- position
|
||||
-- input[1] -- texture
|
||||
-- input[2] -- normal
|
||||
|
||||
-- consts[0] -- trans
|
||||
-- consts[4] -- world_trans
|
||||
-- consts[8] -- normal_trans
|
||||
|
||||
-- out[0] -- position clip space
|
||||
-- out[1] -- object position world space
|
||||
-- out[2] -- normal
|
||||
-- out[3] -- light position world space
|
||||
-- out[4] -- view position world space
|
||||
-- out[5] -- texture
|
||||
|
||||
-- position clip space
|
||||
temp[1].x = VE_DOT const[0].xyzw input[0].xyzw ;
|
||||
temp[1].y = VE_DOT const[1].xyzw input[0].xyzw ;
|
||||
temp[1].z = VE_DOT const[2].xyzw input[0].xyzw ;
|
||||
temp[1].w = VE_DOT const[3].xyzw input[0].xyzw ;
|
||||
|
||||
-- position world space
|
||||
temp[2].x = VE_DOT const[4].xyzw input[0].xyzw ;
|
||||
temp[2].y = VE_DOT const[5].xyzw input[0].xyzw ;
|
||||
temp[2].z = VE_DOT const[6].xyzw input[0].xyzw ;
|
||||
temp[2].w = VE_DOT const[7].xyzw input[0].xyzw ;
|
||||
|
||||
-- normal world space
|
||||
temp[3].x = VE_DOT const[4].xyz0 input[2].xyz0 ;
|
||||
temp[3].y = VE_DOT const[5].xyz0 input[2].xyz0 ;
|
||||
temp[3].z = VE_DOT const[6].xyz0 input[2].xyz0 ;
|
||||
|
||||
-- position (clip space)
|
||||
out[0].xyzw = VE_ADD temp[1].xyzw const[0].0000 ;
|
||||
-- position (world space)
|
||||
out[1].xyzw = VE_ADD temp[2].xyzw const[0].0000 ;
|
||||
-- normal
|
||||
out[2].xyzw = VE_ADD temp[3].xyz0 const[0].0000 ;
|
||||
-- light pos (world space)
|
||||
out[3].xyzw = VE_ADD const[8].xyzw const[8].0000 ;
|
||||
-- view pos (world space)
|
||||
out[4].xyzw = VE_ADD const[9].xyzw const[9].0000 ;
|
||||
-- texture
|
||||
out[5].xyzw = VE_ADD input[1].xy00 const[0].0000 ;
|
||||
@ -174,23 +174,24 @@ def disassemble_a_swizzle_sel(code):
|
||||
return [mod_str(f"src{alu_sel_strs[sel]}.{swiz}", mod)
|
||||
for swiz, sel, mod in zip(a_swiz, a_sels, a_mods)], a_sels
|
||||
|
||||
def omod_str(s, mod):
|
||||
if s == 0: # * 1
|
||||
return s
|
||||
elif s == 1: # * 1
|
||||
return f"({s}) * 1"
|
||||
elif s == 2: # * 2
|
||||
return f"({s}) * 2"
|
||||
elif s == 3: # * 4
|
||||
return f"({s}) * 4"
|
||||
elif s == 4: # * 8
|
||||
return f"({s}) * 8"
|
||||
elif s == 5: # / 2
|
||||
return f"({s}) / 2"
|
||||
elif s == 6: # / 4
|
||||
return f"({s}) / 4"
|
||||
elif s == 7: # DISABLE OMOD
|
||||
return s
|
||||
def omod_str(mod):
|
||||
if mod == 0: # * 1
|
||||
#return f"1.0 * "
|
||||
return ""
|
||||
elif mod == 1: # * 2
|
||||
return f"2.0 * "
|
||||
elif mod == 2: # * 4
|
||||
return f"4.0 * "
|
||||
elif mod == 3: # * 8
|
||||
return f"8.0 * "
|
||||
elif mod == 4: # / 2
|
||||
return f"0.5 * "
|
||||
elif mod == 5: # / 4
|
||||
return f"0.25 * "
|
||||
elif mod == 6:
|
||||
return f"0.125 * "
|
||||
elif mod == 7: # DISABLE OMOD
|
||||
return "(DISABLE OMOD) "
|
||||
|
||||
def disassemble_alu_dest(code):
|
||||
a_addrd = US_ALU_ALPHA_INST.ALPHA_ADDRD(code)
|
||||
@ -250,14 +251,9 @@ def assert_zeros_common(code):
|
||||
assert stat_we == 0
|
||||
|
||||
def assert_zeros_alu(code):
|
||||
rgb_omod = US_ALU_RGB_INST.OMOD(code)
|
||||
alu_wmask = US_ALU_RGB_INST.ALU_WMASK(code)
|
||||
assert rgb_omod in {0, 7}
|
||||
assert alu_wmask == 0
|
||||
|
||||
a_omod = US_ALU_ALPHA_INST.OMOD(code)
|
||||
w_omask = US_ALU_ALPHA_INST.W_OMASK(code)
|
||||
assert a_omod in {0, 7}
|
||||
assert w_omask == 0
|
||||
|
||||
def assert_zeros_tex(code):
|
||||
@ -325,6 +321,7 @@ _a_op_operands = {
|
||||
"OP_CMP": 3,
|
||||
"OP_FRC": 1,
|
||||
"OP_EX2": 1,
|
||||
"OP_LN2": 1,
|
||||
"OP_RCP": 1,
|
||||
"OP_RSQ": 1,
|
||||
"OP_SIN": 1,
|
||||
@ -387,12 +384,17 @@ def disassemble_alu(code, is_output):
|
||||
rgb_clamp_str = ".SAT" if rgb_clamp != 0 else ""
|
||||
a_clamp_str = ".SAT" if alpha_clamp != 0 else ""
|
||||
|
||||
rgb_omod = US_ALU_RGB_INST.OMOD(code)
|
||||
a_omod = US_ALU_ALPHA_INST.OMOD(code)
|
||||
rgb_omod_str = omod_str(rgb_omod)
|
||||
a_omod_str = omod_str(a_omod)
|
||||
|
||||
print(", ".join([*a_addr_strs, *rgb_addr_strs]), ":")
|
||||
#print(", ".join(a_addr_strs), ":")
|
||||
print(f" {a_out_str}{a_temp_str}{a_op.removeprefix('OP_').ljust(3)}{a_clamp_str} {' '.join(a_swizzle_sel)}", ",")
|
||||
print(f" {a_out_str}{a_temp_str}{a_omod_str}{a_op.removeprefix('OP_').ljust(3)}{a_clamp_str} {' '.join(a_swizzle_sel)}", ",")
|
||||
|
||||
#print(", ".join(rgb_addr_strs), ":")
|
||||
print(f" {rgb_out_str}{rgb_temp_str}{rgb_op.removeprefix('OP_').ljust(3)}{rgb_clamp_str} {' '.join(rgb_swizzle_sel)}", ";")
|
||||
print(f" {rgb_out_str}{rgb_temp_str}{rgb_omod_str}{rgb_op.removeprefix('OP_').ljust(3)}{rgb_clamp_str} {' '.join(rgb_swizzle_sel)}", ";")
|
||||
|
||||
def disassemble_tex_swizzle_str(code):
|
||||
tex_swiz_strs = ["r", "g", "b", "a"]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user