add particle_oriented_animated_quad_vbuf_pixel_shader (partially working)
This commit is contained in:
parent
57a62859f3
commit
a4c6f29cb4
@ -98,3 +98,65 @@ int drm_radeon_cs(int fd,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drm_radeon_cs2(int fd,
|
||||
int * handles,
|
||||
int handles_length,
|
||||
int ib_dwords)
|
||||
{
|
||||
struct drm_radeon_cs_reloc relocs[handles_length];
|
||||
|
||||
for (int i = 0; i < handles_length; i++) {
|
||||
relocs[i] = (struct drm_radeon_cs_reloc){
|
||||
.handle = handles[i],
|
||||
.read_domains = 4, // RADEON_GEM_DOMAIN_VRAM
|
||||
.write_domain = 4, // RADEON_GEM_DOMAIN_VRAM
|
||||
.flags = 8,
|
||||
};
|
||||
}
|
||||
|
||||
const uint32_t flags[2] = {
|
||||
5, // RADEON_CS_KEEP_TILING_FLAGS | RADEON_CS_END_OF_FRAME
|
||||
0, // RADEON_CS_RING_GFX
|
||||
};
|
||||
|
||||
struct drm_radeon_cs_chunk chunks[3] = {
|
||||
{
|
||||
.chunk_id = RADEON_CHUNK_ID_IB,
|
||||
.length_dw = ib_dwords,
|
||||
.chunk_data = (uint64_t)(uintptr_t)ib,
|
||||
},
|
||||
{
|
||||
.chunk_id = RADEON_CHUNK_ID_RELOCS,
|
||||
.length_dw = (sizeof (relocs)) / (sizeof (uint32_t)),
|
||||
.chunk_data = (uint64_t)(uintptr_t)relocs,
|
||||
},
|
||||
{
|
||||
.chunk_id = RADEON_CHUNK_ID_FLAGS,
|
||||
.length_dw = (sizeof (flags)) / (sizeof (uint32_t)),
|
||||
.chunk_data = (uint64_t)(uintptr_t)&flags,
|
||||
},
|
||||
};
|
||||
|
||||
uint64_t chunks_array[3] = {
|
||||
(uint64_t)(uintptr_t)&chunks[0],
|
||||
(uint64_t)(uintptr_t)&chunks[1],
|
||||
(uint64_t)(uintptr_t)&chunks[2],
|
||||
};
|
||||
|
||||
struct drm_radeon_cs cs = {
|
||||
.num_chunks = 3,
|
||||
.cs_id = 0,
|
||||
.chunks = (uint64_t)(uintptr_t)chunks_array,
|
||||
.gart_limit = 0,
|
||||
.vram_limit = 0,
|
||||
};
|
||||
|
||||
int ret = drmCommandWriteRead(fd, DRM_RADEON_CS, &cs, (sizeof (struct drm_radeon_cs)));
|
||||
if (ret != 0) {
|
||||
perror("drmCommandWriteRead(DRM_RADEON_CS)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -18,6 +18,11 @@ int drm_radeon_cs(int fd,
|
||||
int texturebuffer_handles_length,
|
||||
int ib_dwords);
|
||||
|
||||
int drm_radeon_cs2(int fd,
|
||||
int * handles,
|
||||
int handles_length,
|
||||
int ib_dwords);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
1190
src/particle_oriented_animated_quad_vbuf_pixel_shader.cpp
Normal file
1190
src/particle_oriented_animated_quad_vbuf_pixel_shader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
77
src/particle_physics.fs.asm
Normal file
77
src/particle_physics.fs.asm
Normal file
@ -0,0 +1,77 @@
|
||||
-- temp[0].rgb : position
|
||||
-- temp[0].a : age
|
||||
-- temp[1].rgb : velocity
|
||||
-- temp[1].a : delta
|
||||
|
||||
-- temp[2].rgb : reset__position
|
||||
-- temp[2].a : reset__age
|
||||
-- temp[3].rgb : reset__velocity
|
||||
-- temp[3].a : reset__delta
|
||||
|
||||
-- temp[4].rgb : update__position
|
||||
-- temp[4].a : update__age
|
||||
-- temp[5].rgb : update__velocity
|
||||
-- temp[5].a : update__delta
|
||||
|
||||
-- temp[6].rgb : temp
|
||||
|
||||
-- velocity_scale.rgb = vec3(0.003 , 0.01, 0.003)
|
||||
-- delta_age = 0.01
|
||||
-- const[0] = { velocity_scale.rgb, delta_age }
|
||||
-- gravity = -0.05
|
||||
-- velocity_attenuation = -0.7
|
||||
-- const[1] = { velocity_attenuation, gravity, 0, 0 }
|
||||
|
||||
-- out[0].rgb : position
|
||||
-- out[0].a : age
|
||||
|
||||
TEX
|
||||
temp[0].rgba = LD tex[0].rgba temp[0].rgaa ;
|
||||
|
||||
TEX TEX_SEM_WAIT TEX_SEM_ACQUIRE
|
||||
temp[1].rgba = LD tex[1].rgba temp[0].rgaa ;
|
||||
|
||||
-- update_particle (position)
|
||||
TEX_SEM_WAIT
|
||||
src0.a = temp[0] , -- age
|
||||
src0.rgb = temp[0] , -- position
|
||||
src1.a = const[0] , -- delta_age
|
||||
src1.rgb = const[0] , -- scale
|
||||
src2.rgb = temp[1] : -- velocity
|
||||
temp[4].a = MAD src0.a src0.1 src1.a , -- update__age = (age * 1) - delta_age
|
||||
temp[4].rgb = MAD src2.rgb src1.rgb src0.rgb ; -- update__position = (velocity * scale) + position
|
||||
|
||||
-- update_particle (velocity gravity)
|
||||
-- p.velocity.y += -0.05;
|
||||
src0.rgb = temp[1] , -- velocity
|
||||
src1.rgb = const[1] : -- gravity (g)
|
||||
temp[5].rgb = MAD src0.rgb src1.111 src1.0g0 ;
|
||||
|
||||
-- update_particle (velocity bounce)
|
||||
-- p.velocity.y *= -0.7;
|
||||
src0.rgb = temp[5] , -- velocity <gravity>
|
||||
src1.rgb = const[1] : -- velocity_attenuation (r)
|
||||
temp[6].rgb = MAD src0.rgb src1.1r1 src1.000 ;
|
||||
|
||||
-- update_particle (velocity bounce)
|
||||
-- p.velocity = (p.position.y >= 0) ? temp[5] : temp[6]
|
||||
src0.rgb = temp[5] , -- velocity <gravity>
|
||||
src1.rgb = temp[6] , -- velocity <bounce>
|
||||
src2.rgb = temp[4] : -- position
|
||||
temp[5].rgb = CMP src0.rgb src1.rgb src2.ggg ;
|
||||
|
||||
-- position.y = abs(position.y)
|
||||
src0.rgb = temp[4] :
|
||||
temp[4].g = MAX |src0.0g0| |src0.0g0| ;
|
||||
|
||||
OUT
|
||||
src0.a = temp[4] , -- update__age
|
||||
src0.rgb = temp[4] : -- update__position
|
||||
out[0].a = MAX src0.a src0.a ,
|
||||
out[0].rgb = MAX src0.rgb src0.rgb ;
|
||||
|
||||
OUT TEX_SEM_WAIT
|
||||
src0.a = temp[1] , -- delta
|
||||
src0.rgb = temp[5] : -- update__velocity
|
||||
out[1].a = MAX src0.a src0.a ,
|
||||
out[1].rgb = MAX src0.rgb src0.rgb ;
|
||||
BIN
src/particle_physics.fs.bin
Normal file
BIN
src/particle_physics.fs.bin
Normal file
Binary file not shown.
2
src/particle_physics.vs.asm
Normal file
2
src/particle_physics.vs.asm
Normal file
@ -0,0 +1,2 @@
|
||||
out[0].xyzw = VE_ADD input[0].xyzw input[0].0000 ;
|
||||
out[1].xyzw = VE_ADD input[0].xy00 const[0].xy00 ;
|
||||
BIN
src/particle_physics.vs.bin
Normal file
BIN
src/particle_physics.vs.bin
Normal file
Binary file not shown.
@ -272,7 +272,8 @@ void ib_generic_initialization()
|
||||
);
|
||||
}
|
||||
|
||||
void ib_colorbuffer(int reloc_index, int pitch, int macrotile, int microtile)
|
||||
void ib_colorbuffer(int reloc_index, int pitch,
|
||||
int macrotile, int microtile)
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -297,6 +298,38 @@ void ib_colorbuffer(int reloc_index, int pitch, int macrotile, int microtile)
|
||||
TU(reloc_index * 4); // index into relocs array
|
||||
}
|
||||
|
||||
void ib_colorbuffer2(int buffer_index,
|
||||
int reloc_index,
|
||||
int pitch,
|
||||
int macrotile, int microtile,
|
||||
int colorformat)
|
||||
{
|
||||
assert(buffer_index >= 0 && buffer_index <= 3);
|
||||
|
||||
int reg_offset = buffer_index * 4;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// CB
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
T0V(RB3D_COLOROFFSET0 + reg_offset
|
||||
, 0x00000000 // value replaced by kernel from relocs
|
||||
);
|
||||
T3(_NOP, 0);
|
||||
TU(reloc_index * 4); // index into relocs array
|
||||
|
||||
T0V(RB3D_COLORPITCH0 + reg_offset
|
||||
, RB3D_COLORPITCH__COLORPITCH(pitch >> 1)
|
||||
| RB3D_COLORPITCH__COLORTILE(macrotile)
|
||||
| RB3D_COLORPITCH__COLORMICROTILE(microtile)
|
||||
| RB3D_COLORPITCH__COLORFORMAT(colorformat)
|
||||
);
|
||||
// The COLORPITCH NOP is ignored/not applied due to
|
||||
// RADEON_CS_KEEP_TILING_FLAGS, but is still required.
|
||||
T3(_NOP, 0);
|
||||
TU(reloc_index * 4); // index into relocs array
|
||||
}
|
||||
|
||||
void ib_viewport(int width, int height)
|
||||
{
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -586,6 +619,7 @@ void ib_texture__1_float32(int reloc_index,
|
||||
| TX_FILTER0__CLAMP_T(clamp)
|
||||
| TX_FILTER0__MAG_FILTER__POINT
|
||||
| TX_FILTER0__MIN_FILTER__POINT
|
||||
| TX_FILTER0__ID(0)
|
||||
);
|
||||
T0V(TX_FILTER1_0
|
||||
, TX_FILTER1__LOD_BIAS(1)
|
||||
@ -616,6 +650,57 @@ void ib_texture__1_float32(int reloc_index,
|
||||
TU(reloc_index * 4); // index into relocs array
|
||||
}
|
||||
|
||||
void ib_texture2(int texture_index,
|
||||
int reloc_index,
|
||||
int width, int height,
|
||||
int macrotile, int microtile,
|
||||
int clamp,
|
||||
int txformat)
|
||||
{
|
||||
assert(texture_index >= 0 && texture_index <= 15);
|
||||
|
||||
int texture_offset = texture_index * 4;
|
||||
|
||||
T0V(TX_FILTER0_0 + texture_offset
|
||||
, TX_FILTER0__CLAMP_S(clamp)
|
||||
| TX_FILTER0__CLAMP_T(clamp)
|
||||
| TX_FILTER0__MAG_FILTER__POINT
|
||||
| TX_FILTER0__MIN_FILTER__POINT
|
||||
| TX_FILTER0__ID(texture_index)
|
||||
);
|
||||
T0V(TX_FILTER1_0 + texture_offset
|
||||
, TX_FILTER1__LOD_BIAS(1)
|
||||
| TX_FILTER1__BORDER_FIX(0)
|
||||
);
|
||||
T0V(TX_BORDER_COLOR_0 + texture_offset
|
||||
, 0
|
||||
);
|
||||
T0V(TX_FORMAT0_0 + texture_offset
|
||||
, TX_FORMAT0__TXWIDTH(width - 1)
|
||||
| TX_FORMAT0__TXHEIGHT(height - 1)
|
||||
);
|
||||
|
||||
T0V(TX_FORMAT1_0 + texture_offset
|
||||
, TX_FORMAT1__TXFORMAT(txformat)
|
||||
| TX_FORMAT1__SEL_ALPHA(3)
|
||||
| TX_FORMAT1__SEL_RED(0)
|
||||
| TX_FORMAT1__SEL_GREEN(1)
|
||||
| TX_FORMAT1__SEL_BLUE(2)
|
||||
| TX_FORMAT1__TEX_COORD_TYPE__2D
|
||||
);
|
||||
T0V(TX_FORMAT2_0 + texture_offset
|
||||
, 0
|
||||
);
|
||||
|
||||
T0V(TX_OFFSET_0 + texture_offset
|
||||
, TX_OFFSET__MACRO_TILE(macrotile)
|
||||
| TX_OFFSET__MICRO_TILE(microtile)
|
||||
);
|
||||
|
||||
T3(_NOP, 0);
|
||||
TU(reloc_index * 4); // index into relocs array
|
||||
}
|
||||
|
||||
void ib_vap_pvs(struct shader_offset * offset)
|
||||
{
|
||||
const int instruction_size = 4 * 4; // bytes
|
||||
|
||||
@ -7,23 +7,23 @@
|
||||
|
||||
#define T0(address, count) \
|
||||
do { \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_BASE_INDEX(address >> 2); \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_BASE_INDEX((address) >> 2); \
|
||||
} while (0);
|
||||
|
||||
#define T0_ONE_REG(address, count) \
|
||||
do { \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_ONE_REG | TYPE_0_BASE_INDEX(address >> 2); \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(count) | TYPE_0_ONE_REG | TYPE_0_BASE_INDEX((address) >> 2); \
|
||||
} while (0);
|
||||
|
||||
#define T0V(address, value) \
|
||||
do { \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX(address >> 2); \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX((address) >> 2); \
|
||||
ib[ib_ix++].u32 = value; \
|
||||
} while (0);
|
||||
|
||||
#define T0Vf(address, value) \
|
||||
do { \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX(address >> 2); \
|
||||
ib[ib_ix++].u32 = TYPE_0_COUNT(0) | TYPE_0_BASE_INDEX((address) >> 2); \
|
||||
ib[ib_ix++].f32 = value; \
|
||||
} while (0);
|
||||
|
||||
@ -57,6 +57,11 @@ extern volatile int ib_ix;
|
||||
void ib_generic_initialization();
|
||||
void ib_viewport(int width, int height);
|
||||
void ib_colorbuffer(int reloc_index, int pitch, int macrotile, int microtile);
|
||||
void ib_colorbuffer2(int buffer_index,
|
||||
int reloc_index,
|
||||
int pitch,
|
||||
int macrotile, int microtile,
|
||||
int colorformat);
|
||||
void ib_zbuffer(int reloc_index, int pitch, int zfunc);
|
||||
void ib_rs_instructions(int count);
|
||||
void ib_texture__0();
|
||||
@ -68,6 +73,12 @@ void ib_texture__1_float32(int reloc_index,
|
||||
int width, int height,
|
||||
int macrotile, int microtile,
|
||||
int clamp);
|
||||
void ib_texture2(int texture_index,
|
||||
int reloc_index,
|
||||
int width, int height,
|
||||
int macrotile, int microtile,
|
||||
int clamp,
|
||||
int txformat);
|
||||
void ib_vap_pvs(struct shader_offset * offset);
|
||||
void ib_ga_us(struct shader_offset * offset);
|
||||
void ib_vap_pvs_const_cntl(const float * consts, int size);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user