drm/shadertoy: add shadertoy_circle.fs.asm
This commit is contained in:
parent
2fd094bbc2
commit
59390a9ea2
@ -357,6 +357,8 @@ int indirect_buffer()
|
||||
// VAP_PVS
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// vertex constants
|
||||
|
||||
T0V(VAP_PVS_CONST_CNTL
|
||||
, VAP_PVS_CONST_CNTL__PVS_CONST_BASE_OFFSET(0)
|
||||
| VAP_PVS_CONST_CNTL__PVS_MAX_CONST_ADDR(1)
|
||||
@ -366,13 +368,15 @@ int indirect_buffer()
|
||||
, VAP_PVS_VECTOR_INDX_REG__OCTWORD_OFFSET(1024)
|
||||
);
|
||||
|
||||
const float consts[] = {
|
||||
const float vertex_consts[] = {
|
||||
4.0f / 3.0f, 0.0f, 0.0f, 0.0f,
|
||||
};
|
||||
int consts_length = (sizeof (consts)) / (sizeof (consts[0]));
|
||||
T0_ONE_REG(VAP_PVS_VECTOR_DATA_REG_128, (consts_length - 1));
|
||||
for (int i = 0; i < consts_length; i++)
|
||||
ib[ix++].f32 = consts[i];
|
||||
int vertex_consts_length = (sizeof (vertex_consts)) / (sizeof (vertex_consts[0]));
|
||||
T0_ONE_REG(VAP_PVS_VECTOR_DATA_REG_128, (vertex_consts_length - 1));
|
||||
for (int i = 0; i < vertex_consts_length; i++)
|
||||
ib[ix++].f32 = vertex_consts[i];
|
||||
|
||||
// vertex code
|
||||
|
||||
T0V(VAP_PVS_CODE_CNTL_0
|
||||
, VAP_PVS_CODE_CNTL_0__PVS_FIRST_INST(0)
|
||||
@ -430,8 +434,25 @@ int indirect_buffer()
|
||||
// GA_US
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// fragment constants
|
||||
|
||||
const float fragment_consts[] = {
|
||||
-0.1f, 0, 0, 0,
|
||||
};
|
||||
int fragment_consts_length = (sizeof (fragment_consts)) / (sizeof (fragment_consts[0]));
|
||||
|
||||
T0V(GA_US_VECTOR_INDEX
|
||||
, GA_US_VECTOR_INDEX__INDEX(0)
|
||||
| GA_US_VECTOR_INDEX__TYPE(1)
|
||||
);
|
||||
T0_ONE_REG(GA_US_VECTOR_DATA, (fragment_consts_length - 1));
|
||||
for (int i = 0; i < fragment_consts_length; i++)
|
||||
ib[ix++].f32 = fragment_consts[i];
|
||||
|
||||
// fragment code
|
||||
|
||||
const uint32_t fragment_shader[] = {
|
||||
#include "shadertoy.fs.inc"
|
||||
#include "shadertoy_circle.fs.inc"
|
||||
};
|
||||
const int fragment_shader_length = (sizeof (fragment_shader)) / (sizeof (fragment_shader[0]));
|
||||
assert(fragment_shader_length % 6 == 0);
|
||||
@ -455,7 +476,10 @@ int indirect_buffer()
|
||||
| US_CODE_ADDR__END_ADDR(fragment_shader_instructions - 1)
|
||||
);
|
||||
|
||||
T0V(GA_US_VECTOR_INDEX, 0x00000000);
|
||||
T0V(GA_US_VECTOR_INDEX
|
||||
, GA_US_VECTOR_INDEX__INDEX(0)
|
||||
| GA_US_VECTOR_INDEX__TYPE(0)
|
||||
);
|
||||
T0_ONE_REG(GA_US_VECTOR_DATA, fragment_shader_length - 1);
|
||||
for (int i = 0; i < fragment_shader_length; i++) {
|
||||
ib[ix++].u32 = fragment_shader[i];
|
||||
|
||||
29
drm/shadertoy_circle.fs.asm
Normal file
29
drm/shadertoy_circle.fs.asm
Normal file
@ -0,0 +1,29 @@
|
||||
# CONSTS[0] = (-0.1, 0, 0, 0)
|
||||
|
||||
# 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 -= 0.5
|
||||
src0.a = temp[0] :
|
||||
temp[0].r = MAD src0.a00 src0.100 -src0.h00 ;
|
||||
|
||||
# d = abs(d) * 1 + -0.1
|
||||
src0.rgb = temp[0] , src1.rgb = const[0] :
|
||||
temp[0].r = MAD |src0.r00| src0.100 src1.r00 ;
|
||||
|
||||
# out.r = (d >= 0.0) ? 1.0 : 0.0
|
||||
OUT
|
||||
src0.rgb = temp[0] :
|
||||
out[0].r = CMP src0.100 src0.000 src0.r00 ;
|
||||
|
||||
# out.a = 1
|
||||
# out.gb = vec2(0, 0)
|
||||
OUT TEX_SEM_WAIT
|
||||
:
|
||||
out[0].a = MAX src0.1 src0.1 ,
|
||||
out[0].gb = MAX src0.000 src0.000 ;
|
||||
49
drm/shadertoy_circle.fs.inc
Normal file
49
drm/shadertoy_circle.fs.inc
Normal file
@ -0,0 +1,49 @@
|
||||
0x00000800,
|
||||
0x08020000,
|
||||
0x08020080,
|
||||
0x00840420,
|
||||
0x00000000,
|
||||
0x00000001,
|
||||
|
||||
0x00004000,
|
||||
0x08020000,
|
||||
0x08020080,
|
||||
0x00000000,
|
||||
0x0004000b,
|
||||
0x00000000,
|
||||
|
||||
0x00004000,
|
||||
0x08020080,
|
||||
0x08020000,
|
||||
0x00000000,
|
||||
0x0000c00a,
|
||||
0x00000000,
|
||||
|
||||
0x00000800,
|
||||
0x08020080,
|
||||
0x08020000,
|
||||
0x0093048c,
|
||||
0x00000000,
|
||||
0x00c94000,
|
||||
|
||||
0x00000800,
|
||||
0x08040000,
|
||||
0x08020080,
|
||||
0x00931480,
|
||||
0x00000000,
|
||||
0x00481000,
|
||||
|
||||
0x00008001,
|
||||
0x08020000,
|
||||
0x08020080,
|
||||
0x00920498,
|
||||
0x00000000,
|
||||
0x00480008,
|
||||
|
||||
0x00070005,
|
||||
0x08020080,
|
||||
0x08020080,
|
||||
0x00920490,
|
||||
0x00c18003,
|
||||
0x00000005,
|
||||
|
||||
48
shader_examples/mesa/shadertoy_circle.fs.txt
Normal file
48
shader_examples/mesa/shadertoy_circle.fs.txt
Normal file
@ -0,0 +1,48 @@
|
||||
0x00000800,
|
||||
0x08020000,
|
||||
0x08020080,
|
||||
0x00840420,
|
||||
0x00000000,
|
||||
0x00000001,
|
||||
|
||||
0x00004000,
|
||||
0x08020000,
|
||||
0x08020080,
|
||||
0x00000000,
|
||||
0x0004000b,
|
||||
0x00000000,
|
||||
|
||||
0x00004000,
|
||||
0x08020080,
|
||||
0x08020000,
|
||||
0x00000000,
|
||||
0x0000c00a,
|
||||
0x00000000,
|
||||
|
||||
0x00000800,
|
||||
0x08020080,
|
||||
0x08020000,
|
||||
0x0093048c,
|
||||
0x00000000,
|
||||
0x00c94000,
|
||||
|
||||
0x00000800,
|
||||
0x08040000,
|
||||
0x08020080,
|
||||
0x00931480,
|
||||
0x00000000,
|
||||
0x00481000,
|
||||
|
||||
0x00008001,
|
||||
0x08020000,
|
||||
0x08020080,
|
||||
0x1c920498,
|
||||
0x00000000,
|
||||
0x00480008,
|
||||
|
||||
0x00070005,
|
||||
0x08020080,
|
||||
0x08020080,
|
||||
0x1c920490,
|
||||
0x1cc18003,
|
||||
0x00000005,
|
||||
Loading…
x
Reference in New Issue
Block a user