drm: add shadertoy_sin.fs.asm

This commit is contained in:
Zack Buhman 2025-10-21 11:41:54 -05:00
parent f6105c66b3
commit 3213edda43
6 changed files with 175 additions and 7 deletions

View File

@ -452,7 +452,7 @@ int indirect_buffer()
// fragment code // fragment code
const uint32_t fragment_shader[] = { const uint32_t fragment_shader[] = {
#include "shadertoy_circle.fs.inc" #include "shadertoy_sin.fs.inc"
}; };
const int fragment_shader_length = (sizeof (fragment_shader)) / (sizeof (fragment_shader[0])); const int fragment_shader_length = (sizeof (fragment_shader)) / (sizeof (fragment_shader[0]));
assert(fragment_shader_length % 6 == 0); assert(fragment_shader_length % 6 == 0);

22
drm/shadertoy_sin.fs.asm Normal file
View File

@ -0,0 +1,22 @@
# d = length(uv)
src0.rgb = temp[0] :
temp[0].r = DP3 src0.rg0 src0.rg0 ;
src0.rgb = temp[0] :
temp[0].a = RSQ |src0.r| ;
src0.a = temp[0] :
temp[0].a = RCP src0.a ;
# d = d * 1.625 + 0
src0.a = temp[0],
src1.a = float(61) : # 1.625
temp[0].a = MAD src0.a src1.a src0.0 ;
# d = frc(d)
src0.a = temp[0] :
temp[0].a = FRC src0.a ;
# d = cos(d * 2π)
OUT TEX_SEM_WAIT
src0.a = temp[0] :
COS src0.a ,
out[0].rgb = SOP ;

42
drm/shadertoy_sin.fs.inc Normal file
View File

@ -0,0 +1,42 @@
0x00000800,
0x08020000,
0x08020080,
0x00840420,
0x00000000,
0x00000001,
0x00004000,
0x08020000,
0x08020080,
0x00000000,
0x0004000b,
0x00000000,
0x00004000,
0x08020080,
0x08020000,
0x00000000,
0x0000c00a,
0x00000000,
0x00004000,
0x08020080,
0x0802f400,
0x00000000,
0x0068c000,
0x20000000,
0x00004000,
0x08020080,
0x08020000,
0x00000000,
0x0000c007,
0x00000000,
0x00038005,
0x08020080,
0x08020000,
0x00000000,
0x0000c00d,
0x0000000a,

View File

@ -228,10 +228,6 @@ def assert_zeros(code):
assert nop == 0 assert nop == 0
alu_wait = US_CMN_INST.ALU_WAIT(code) alu_wait = US_CMN_INST.ALU_WAIT(code)
assert alu_wait == 0 assert alu_wait == 0
rgb_clamp = US_CMN_INST.RGB_CLAMP(code)
assert rgb_clamp == 0
alpha_clamp = US_CMN_INST.ALPHA_CLAMP(code)
assert alpha_clamp == 0
alu_result_sel = US_CMN_INST.ALU_RESULT_SEL(code) alu_result_sel = US_CMN_INST.ALU_RESULT_SEL(code)
assert alu_result_sel == 0 assert alu_result_sel == 0
alpha_pred_inv = US_CMN_INST.ALPHA_PRED_INV(code) alpha_pred_inv = US_CMN_INST.ALPHA_PRED_INV(code)
@ -334,12 +330,17 @@ def disassemble_alu(code, is_output):
a_addr_strs = [s for i, s in enumerate(a_addr_strs) if i in a_sources] a_addr_strs = [s for i, s in enumerate(a_addr_strs) if i in a_sources]
rgb_addr_strs = [s for i, s in enumerate(rgb_addr_strs) if i in rgb_sources] rgb_addr_strs = [s for i, s in enumerate(rgb_addr_strs) if i in rgb_sources]
rgb_clamp = US_CMN_INST.RGB_CLAMP(code)
alpha_clamp = US_CMN_INST.ALPHA_CLAMP(code)
rgb_clamp_str = ".CLAMP" if rgb_clamp != 0 else ""
a_clamp_str = ".CLAMP" if alpha_clamp != 0 else ""
print(", ".join([*a_addr_strs, *rgb_addr_strs]), ":") print(", ".join([*a_addr_strs, *rgb_addr_strs]), ":")
#print(", ".join(a_addr_strs), ":") #print(", ".join(a_addr_strs), ":")
print(f" {a_out_str} = {a_temp_str} = {a_op.removeprefix('OP_').ljust(3)} {' '.join(a_swizzle_sel)}", ",") print(f" {a_out_str} = {a_temp_str} = {a_op.removeprefix('OP_').ljust(3)}{a_clamp_str} {' '.join(a_swizzle_sel)}", ",")
#print(", ".join(rgb_addr_strs), ":") #print(", ".join(rgb_addr_strs), ":")
print(f" {rgb_out_str} = {rgb_temp_str} = {rgb_op.removeprefix('OP_').ljust(3)} {' '.join(rgb_swizzle_sel)}", ";") print(f" {rgb_out_str} = {rgb_temp_str} = {rgb_op.removeprefix('OP_').ljust(3)}{rgb_clamp_str} {' '.join(rgb_swizzle_sel)}", ";")
def disassemble(code): def disassemble(code):
assert len(code) == 6, len(code) assert len(code) == 6, len(code)

View File

@ -0,0 +1,48 @@
0x00000800,
0x08020000,
0x08020080,
0x00840420,
0x00000000,
0x00000001,
0x00004000,
0x08020000,
0x08020080,
0x00000000,
0x0004000b,
0x00000000,
0x00004000,
0x08020080,
0x08020000,
0x00000000,
0x0000c00a,
0x00000000,
0x00000800,
0x08020100,
0x08020000,
0x00918480,
0x00000000,
0x00490000,
0x00000800,
0x08020000,
0x08020080,
0x00000480,
0x00000000,
0x00000009,
0x00008001,
0x08020000,
0x08020080,
0x00000000,
0x0000000d,
0x0000000a,
0x00070005,
0x08020080,
0x08020080,
0x1c920490,
0x1cc18003,
0x00000005,

View File

@ -0,0 +1,55 @@
0x00000800,
0x08020000,
0x08020080,
0x00840420,
0x00000000,
0x00000001,
0x00004000,
0x08020000,
0x08020080,
0x00000000,
0x0004000b,
0x00000000,
0x00004000,
0x08020080,
0x08020000,
0x00000000,
0x0000c00a,
0x00000000,
0x00000800,
0x08020080,
0x08020000,
0x0093048c,
0x00000000,
0x00c94000,
0x00080800,
0x08020000,
0x080200d2,
0x00919480,
0x00000000,
0x00490000,
0x00001000,
0x08020000,
0x080310c0,
0x00820c70,
0x00000000,
0x00471000,
0x00001000,
0x08000000,
0x08020080,
0x00862410,
0x00000000,
0x00490000,
0x00078005,
0x08000000,
0x08020080,
0x0024a000,
0x1cc18003,
0x00490000,