This commit is contained in:
Zack Buhman 2025-11-11 08:27:15 -06:00
parent 399cd6aaf9
commit db0574345b
3 changed files with 252 additions and 8 deletions

View File

@ -409,7 +409,7 @@ int indirect_buffer(float time)
}; };
const int vertex_shader_length = (sizeof (vertex_shader)) / (sizeof (vertex_shader[0])); const int vertex_shader_length = (sizeof (vertex_shader)) / (sizeof (vertex_shader[0]));
assert(vertex_shader_length % 4 == 0); assert(vertex_shader_length % 4 == 0);
printf("vs length %d\n", vertex_shader_length); //printf("vs length %d\n", vertex_shader_length);
T0_ONE_REG(VAP_PVS_VECTOR_DATA_REG_128, vertex_shader_length - 1); T0_ONE_REG(VAP_PVS_VECTOR_DATA_REG_128, vertex_shader_length - 1);
for (int i = 0; i < vertex_shader_length; i++) { for (int i = 0; i < vertex_shader_length; i++) {
@ -449,10 +449,17 @@ int indirect_buffer(float time)
// fragment constants // fragment constants
#define PI (3.14159274101257324219f)
#define PI_2 (PI * 2.0f)
#define I_PI_2 (1.0f / (PI_2))
const float fragment_consts[] = { const float fragment_consts[] = {
time, 0, 0, 0, time, 1.2, 0.01, 0.4,
PI_2, I_PI_2, 0, 0,
0.25, 0.40625, 0.5625, 0,
}; };
int fragment_consts_length = (sizeof (fragment_consts)) / (sizeof (fragment_consts[0])); int fragment_consts_length = (sizeof (fragment_consts)) / (sizeof (fragment_consts[0]));
assert(fragment_consts_length % 4 == 0);
T0V(GA_US_VECTOR_INDEX T0V(GA_US_VECTOR_INDEX
, GA_US_VECTOR_INDEX__INDEX(0) , GA_US_VECTOR_INDEX__INDEX(0)
@ -465,16 +472,16 @@ int indirect_buffer(float time)
// fragment code // fragment code
const uint32_t fragment_shader[] = { const uint32_t fragment_shader[] = {
#include "shadertoy_palette.fs.inc" #include "shadertoy_palette_fractal.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);
printf("fs length %d\n", fragment_shader_length); //printf("fs length %d\n", fragment_shader_length);
const int fragment_shader_instructions = fragment_shader_length / 6; const int fragment_shader_instructions = fragment_shader_length / 6;
printf("fs instructions %d\n", fragment_shader_instructions); //printf("fs instructions %d\n", fragment_shader_instructions);
T0V(US_PIXSIZE T0V(US_PIXSIZE
, US_PIXSIZE__PIX_SIZE(2) // pixel shader stack frame size , US_PIXSIZE__PIX_SIZE(3) // pixel shader stack frame size
); );
T0V(US_CODE_RANGE T0V(US_CODE_RANGE
@ -513,7 +520,7 @@ int indirect_buffer(float time)
-1.0f, 1.0f, 0.0f -1.0f, 1.0f, 0.0f
}; };
const int vertices_length = (sizeof (vertices)) / (sizeof (vertices[0])); const int vertices_length = (sizeof (vertices)) / (sizeof (vertices[0]));
printf("vtx length %d\n", vertices_length); //printf("vtx length %d\n", vertices_length);
T3(_3D_DRAW_IMMD_2, (1 + vertices_length) - 1); T3(_3D_DRAW_IMMD_2, (1 + vertices_length) - 1);
ib[ix++].u32 ib[ix++].u32
= VAP_VF_CNTL__PRIM_TYPE(4) = VAP_VF_CNTL__PRIM_TYPE(4)
@ -708,7 +715,7 @@ int main()
#define D1GRPH_UPDATE__D1GRPH_SURFACE_UPDATE_PENDING (1 << 2) #define D1GRPH_UPDATE__D1GRPH_SURFACE_UPDATE_PENDING (1 << 2)
uint32_t d1crtc_double_buffer_control = rreg(rmmio, D1CRTC_DOUBLE_BUFFER_CONTROL); uint32_t d1crtc_double_buffer_control = rreg(rmmio, D1CRTC_DOUBLE_BUFFER_CONTROL);
printf("D1CRTC_DOUBLE_BUFFER_CONTROL: %08x\n", d1crtc_double_buffer_control); //printf("D1CRTC_DOUBLE_BUFFER_CONTROL: %08x\n", d1crtc_double_buffer_control);
assert(d1crtc_double_buffer_control == (1 << 8)); assert(d1crtc_double_buffer_control == (1 << 8));
// addresses were retrieved from /sys/kernel/debug/radeon_vram_mm // addresses were retrieved from /sys/kernel/debug/radeon_vram_mm

View File

@ -0,0 +1,104 @@
-- CONST[0] = { time, 1.2, 0.01, 0.4 }
-- CONST[1] = { PI_2, I_PI_2, 0, 0 },
-- CONST[2] = { 0.25, 0.40625, 0.5625, 0 },
-- temp[0] : { uv0.xy , _, l }
-- temp[1] : { uv.xy , _, d }
-- temp[2] : final_color.xyzw
-- temp[3] : {col.xyz , i }
-- vec2 uv = uv0; // temp[1]
src0.rgb = temp[0] : -- uv0
temp[1].rg = MAX src0.rg_ src0.rg_ ;
-- vec4 final_color = vec4(0, 0, 0, 1);
:
temp[2].a = MAX src0.1 src0.1 ,
temp[2].rgb = MAX src0.000 src0.000 ;
-- i = 0;
:
temp[3].a = MAX src0.0 src0.0 ;
--------------------------------------------------------------------------------
-- loop start
--------------------------------------------------------------------------------
-- uv = uv * 1.5;
src0.rgb = temp[1] , -- uv
src0.a = float(60) : -- 1.5
temp[1].rg = MAD src0.rg_ src0.aa_ src0.00_ ;
-- uv = fract(uv);
src0.rgb = temp[1] : -- uv
temp[1].rg = FRC src0.rg_ ;
-- uv = uv - 0.5;
src0.a = float(48) : -- 0.5
temp[1].rg = MAD src0.rg_ src0.11_ src0.aa_ ;
-- l = length(uv0);
src0.rgb = temp[0] : -- uv0
DP3 src0.rg0 src0.rg0 ,
temp[0].a = DP ;
src0.a = temp[0] :
temp[0].a = RSQ |src0.a| ;
src0.a = temp[0] :
temp[0].a = RCP src0.a ;
-- d = i * 0.4 + l;
src0.a = const[0] , -- 0.4
src1.a = temp[0] , -- l
src2.a = temp[3] : -- i
temp[1].a = MAD src2.a src0.a src1.a ;
-- d = time * 0.4 + d;
src0.a = const[0] , -- 0.4
src1.a = temp[1] , -- d
src0.rgb = const[0] : -- time (r)
temp[1].a = MAD src0.r src0.a src1.a ;
-- palette
-- v = d + (vec3(0.25, 0.40625, 0.5625) + 0.5)
src0.a = temp[1] , -- d
src0.rgb = const[2] , -- vec3(0.25, 0.40625, 0.5625)
src1.rgb = float(48) , -- 0.5
srcp.rgb = add : -- (vec3(0.25, 0.40625, 0.5625) + 0.5)
temp[3].rgb = MAD src0.111 src0.aaa srcp.rgb ;
-- v = frac(v)
src0.rgb = temp[3] : -- v
temp[3].rgb = FRC src0.rgb ;
src0.rgb = temp[3] , -- v
src1.rgb = float(48) : -- 0.5
temp[3].rgb = MAD src0.111 src0.rgb -src1.rgb ;
-- v = cos(v)
src0.rgb = temp[3] : -- v
COS src0.r ,
temp[3].r = SOP ;
src0.rgb = temp[3] : -- v
COS src0.g ,
temp[3].g = SOP ;
src0.rgb = temp[3] : -- v
COS src0.b ,
temp[3].b = SOP ;
-- col = vec3(0.5, 0.5, 0.5) * v + vec3(0.5, 0.5, 0.5)
src0.rgb = temp[3] , -- v
src1.rgb = float(48) : -- 0.5
temp[3].rgb = MAD src1.rgb src0.rgb src1.rgb;
-- end of 'palette' function
-----
-----
-----
OUT TEX_SEM_WAIT
src0.a = temp[0] ,
src0.rgb = temp[0] ,
src1.rgb = temp[3] :
out[0].a = MAX src0.1 src0.1 ,
out[0].rgb = MAX src1.rgb src1.rgb ;

View File

@ -0,0 +1,133 @@
0x00001800,
0x08020000,
0x08020080,
0x00e40720,
0x00000000,
0x00000015,
0x00007800,
0x08020080,
0x08020080,
0x00920490,
0x00c18023,
0x00000025,
0x00004000,
0x08020080,
0x08020080,
0x00000000,
0x00810033,
0x00000000,
0x00001800,
0x08020001,
0x080200bc,
0x00ed8720,
0x00000000,
0x00790010,
0x00001800,
0x08020001,
0x08020080,
0x00000720,
0x00000000,
0x00000019,
0x00001800,
0x08020080,
0x080200b0,
0x00fb0720,
0x00000000,
0x0076c010,
0x00004000,
0x08020000,
0x08020080,
0x00840420,
0x00000001,
0x00000001,
0x00004000,
0x08020080,
0x08020000,
0x00000000,
0x0004c00b,
0x00000000,
0x00004000,
0x08020080,
0x08020000,
0x00000000,
0x0000c00a,
0x00000000,
0x00004000,
0x08020080,
0x00300100,
0x00000000,
0x0060e010,
0x1a000000,
0x00004000,
0x08020100,
0x08000500,
0x00000000,
0x00600010,
0x1a000000,
0x00003800,
0x8802c102,
0x08020001,
0x006d86d8,
0x00000000,
0x00223030,
0x00003800,
0x08020003,
0x08020080,
0x00000220,
0x00000000,
0x00000039,
0x00003800,
0x0802c003,
0x08020080,
0x004406d8,
0x00000000,
0x00a21030,
0x00000800,
0x08020003,
0x08020080,
0x00000000,
0x0000000d,
0x0000003a,
0x00001000,
0x08020003,
0x08020080,
0x00000000,
0x0000400d,
0x0000003a,
0x00002000,
0x08020003,
0x08020080,
0x00000000,
0x0000800d,
0x0000003a,
0x00003800,
0x0802c003,
0x08020080,
0x00440221,
0x00000000,
0x00221030,
0x00078005,
0x08000c00,
0x08020000,
0x00442221,
0x00c18003,
0x00000005,