205 lines
3.8 KiB
Plaintext
205 lines
3.8 KiB
Plaintext
// #define V_ParticlesCap Kibi(128)
|
|
// #define V_ParticlesCap Mebi(1)
|
|
#define V_ParticlesCap Mebi(2)
|
|
// #define V_ParticlesCap Mebi(16)
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Constant types
|
|
|
|
Enum(V_GpuFlag)
|
|
{
|
|
V_GpuFlag_None = 0,
|
|
V_GpuFlag_DebugDraw = (1 << 0),
|
|
};
|
|
|
|
G_DeclConstant(V_GpuFlag, V_ShaderConst_GpuFlags, 0);
|
|
G_DeclConstant(G_RWStructuredBufferRef, V_ShaderConst_State, 1);
|
|
G_DeclConstant(G_StructuredBufferRef, V_ShaderConst_Params, 2);
|
|
G_DeclConstant(G_Texture3DRef, V_ShaderConst_NoiseTex, 3);
|
|
|
|
Enum(V_SelectionMode)
|
|
{
|
|
V_SelectionMode_None,
|
|
V_SelectionMode_Tile,
|
|
};
|
|
|
|
Struct(V_Affines)
|
|
{
|
|
// World <-> screen
|
|
Affine world_to_screen;
|
|
Affine screen_to_world;
|
|
|
|
// World <-> shade
|
|
Affine world_to_shade;
|
|
Affine shade_to_world;
|
|
|
|
// Shade <-> screen
|
|
Affine shade_to_screen;
|
|
Affine screen_to_shade;
|
|
|
|
// World <-> cell
|
|
Affine world_to_cell;
|
|
Affine cell_to_world;
|
|
|
|
// World <-> tile
|
|
Affine world_to_tile;
|
|
Affine tile_to_world;
|
|
};
|
|
|
|
Struct(V_TileDesc)
|
|
{
|
|
G_Texture2DRef tex;
|
|
};
|
|
|
|
Struct(V_GpuState)
|
|
{
|
|
// u32 particle_seq; // Atomic monotonically increasing allocation counter sequence for particle ring buffer
|
|
i32 _;
|
|
};
|
|
|
|
Struct(V_GpuParams)
|
|
{
|
|
// TODO: Use simulation dt
|
|
f32 dt;
|
|
u64 tick;
|
|
u64 seed;
|
|
V_Affines af;
|
|
|
|
V_SelectionMode selection_mode;
|
|
P_TileKind equipped_tile;
|
|
|
|
b32 has_mouse_focus;
|
|
b32 has_keyboard_focus;
|
|
Vec2 screen_cursor;
|
|
Vec2 shade_cursor;
|
|
Vec2 world_cursor;
|
|
Rng2 screen_selection;
|
|
Rng2 shade_selection;
|
|
Rng2 world_selection;
|
|
|
|
Vec2 camera_pos;
|
|
f32 camera_zoom;
|
|
|
|
G_SamplerStateRef pt_clamp_sampler;
|
|
G_SamplerStateRef pt_wrap_sampler;
|
|
|
|
Vec2 screen_dims;
|
|
|
|
Vec2 shade_dims;
|
|
G_Texture2DRef shade_ro;
|
|
G_RWTexture2DRef shade_rw;
|
|
G_Texture2DRef albedo_ro;
|
|
G_RWTexture2DRef albedo_rw;
|
|
|
|
G_Texture2DRef tiles;
|
|
G_StructuredBufferRef quads;
|
|
G_StructuredBufferRef shape_verts;
|
|
|
|
u32 emitters_count;
|
|
G_StructuredBufferRef emitters;
|
|
|
|
G_RWStructuredBufferRef particles;
|
|
|
|
b32 should_clear_stains;
|
|
G_RWTexture2DRef cells;
|
|
G_RWTexture2DRef stains;
|
|
G_RWTexture2DRef drynesses;
|
|
|
|
V_TileDesc tile_descs[P_TileKind_COUNT];
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Particle types
|
|
|
|
Enum(V_ParticleFlag)
|
|
{
|
|
V_ParticleFlag_None = 0,
|
|
V_ParticleFlag_PruneWhenStill = (1 << 0),
|
|
V_ParticleFlag_StainOnPrune = (1 << 1),
|
|
V_ParticleFlag_StainTrail = (1 << 2),
|
|
};
|
|
|
|
Struct(V_Emitter)
|
|
{
|
|
V_ParticleFlag flags;
|
|
|
|
u32 first_particle_seq;
|
|
u32 count;
|
|
|
|
Vec2 start;
|
|
Vec2 end;
|
|
|
|
f32 lifetime;
|
|
f32 lifetime_spread;
|
|
|
|
f32 speed;
|
|
f32 speed_spread;
|
|
|
|
f32 angle;
|
|
f32 angle_spread;
|
|
|
|
f32 velocity_falloff;
|
|
f32 velocity_falloff_spread;
|
|
|
|
Vec4 color_lin;
|
|
Vec4 color_spread;
|
|
};
|
|
|
|
// TODO: Pack this efficiently
|
|
Struct(V_Particle)
|
|
{
|
|
u32 emitter_init_num; // if != 0, then initialize using emitter at index [emitter_init_num - 1]
|
|
u32 seq;
|
|
|
|
V_ParticleFlag flags;
|
|
|
|
Vec2 pos;
|
|
Vec2 velocity;
|
|
|
|
f32 exists;
|
|
f32 lifetime;
|
|
|
|
f32 velocity_falloff;
|
|
Vec4 color;
|
|
};
|
|
|
|
#if IsLanguageC
|
|
Struct(V_EmitterNode)
|
|
{
|
|
V_EmitterNode *next;
|
|
V_Emitter emitter;
|
|
};
|
|
#endif
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Quad types
|
|
|
|
Enum(V_QuadFlag)
|
|
{
|
|
V_QuadFlag_None = 0,
|
|
};
|
|
|
|
Struct(V_Quad)
|
|
{
|
|
V_QuadFlag flags;
|
|
Affine to_shade_af;
|
|
G_Texture2DRef tex;
|
|
Rng2 uv_rect;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Debug vert types
|
|
|
|
Struct(V_DVert)
|
|
{
|
|
Vec2 pos;
|
|
Vec4 color_lin;
|
|
};
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
//~ Helpers
|
|
|
|
#define V_ThreadGroupSizeFromBufferSize(buffer_size) VEC3I32((((buffer_size) + 63) / 64), 1, 1)
|
|
#define V_ThreadGroupSizeFromTexSize(tex_size) VEC3I32(((tex_size).x + 7) / 8, ((tex_size).y + 7) / 8, 1)
|