start implementing async system
This commit is contained in:
parent
e9e8dcc04d
commit
ac8a4cf6c2
22
src/base/base_async.c
Normal file
22
src/base/base_async.c
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Bootstrap
|
||||||
|
|
||||||
|
void BootstrapAsync(void)
|
||||||
|
{
|
||||||
|
/* TODO: Dynamic lane counts */
|
||||||
|
DispatchWave(Lit("Async"), 4, AsyncEntryPoint, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Async ops
|
||||||
|
|
||||||
|
void OnAsyncTick(AsyncFunc *func)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Async worker
|
||||||
|
|
||||||
|
void AsyncEntryPoint(WaveLaneCtx *lane)
|
||||||
|
{
|
||||||
|
}
|
||||||
19
src/base/base_async.h
Normal file
19
src/base/base_async.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Async types
|
||||||
|
|
||||||
|
typedef void AsyncFunc(WaveLaneCtx *lane);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Bootstrap
|
||||||
|
|
||||||
|
void BootstrapAsync(void);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Async ops
|
||||||
|
|
||||||
|
void OnAsyncTick(AsyncFunc *func);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Async worker
|
||||||
|
|
||||||
|
void AsyncEntryPoint(WaveLaneCtx *lane);
|
||||||
@ -25,6 +25,7 @@
|
|||||||
# include "base_bitbuff.h"
|
# include "base_bitbuff.h"
|
||||||
# include "base_resource.h"
|
# include "base_resource.h"
|
||||||
# include "base_controller.h"
|
# include "base_controller.h"
|
||||||
|
# include "base_async.h"
|
||||||
#elif IsLanguageG
|
#elif IsLanguageG
|
||||||
# include "base_shader.gh"
|
# include "base_shader.gh"
|
||||||
#endif
|
#endif
|
||||||
@ -46,6 +47,7 @@
|
|||||||
# include "base_bitbuff.c"
|
# include "base_bitbuff.c"
|
||||||
# include "base_resource.c"
|
# include "base_resource.c"
|
||||||
# include "base_controller.c"
|
# include "base_controller.c"
|
||||||
|
# include "base_async.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//- Include base_win32
|
//- Include base_win32
|
||||||
|
|||||||
@ -320,6 +320,9 @@ i32 W32_Main(void)
|
|||||||
BootstrapResources(ctx.embedded_strings_count, ctx.embedded_strings);
|
BootstrapResources(ctx.embedded_strings_count, ctx.embedded_strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Bootstrap async */
|
||||||
|
BootstrapAsync();
|
||||||
|
|
||||||
/* Bootstrap layers */
|
/* Bootstrap layers */
|
||||||
if (!Atomic32Fetch(&g->panicking))
|
if (!Atomic32Fetch(&g->panicking))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@ GC_State GC = ZI;
|
|||||||
|
|
||||||
void GC_BootStrap(void)
|
void GC_BootStrap(void)
|
||||||
{
|
{
|
||||||
// OnAsync(GC_AsyncTick);
|
OnAsyncTick(GC_AsyncTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
@ -79,6 +79,10 @@ GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uncached_codepoints.len > 0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
f32 baseline_pos = 0;
|
f32 baseline_pos = 0;
|
||||||
result.rects = PushStructs(arena, GC_RunRect, ready_glyphs_count);
|
result.rects = PushStructs(arena, GC_RunRect, ready_glyphs_count);
|
||||||
result.rects_count = ready_glyphs_count;
|
result.rects_count = ready_glyphs_count;
|
||||||
@ -130,6 +134,22 @@ GC_Run GC_RunFromString(Arena *arena, String str, GC_FontKey font, f32 font_size
|
|||||||
|
|
||||||
void GC_AsyncTick(WaveLaneCtx *lane)
|
void GC_AsyncTick(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
|
TempArena scratch = BeginScratchNoConflict();
|
||||||
|
GC_WorkerState *w = &GC.worker_state;
|
||||||
|
|
||||||
|
/* Flatten cmds */
|
||||||
|
// if (lane->idx == 0)
|
||||||
|
// {
|
||||||
|
// Lock lock = LockE();
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// Unlock(&lock);
|
||||||
|
// }
|
||||||
|
|
||||||
|
WaveSync(lane);
|
||||||
|
|
||||||
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,13 +9,6 @@ Struct(GC_FontKey)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Glyph types
|
//~ Glyph types
|
||||||
|
|
||||||
Struct(GC_GlyphDesc)
|
|
||||||
{
|
|
||||||
GC_FontKey font;
|
|
||||||
f32 font_size;
|
|
||||||
u32 codepoint;
|
|
||||||
};
|
|
||||||
|
|
||||||
Struct(GC_Glyph)
|
Struct(GC_Glyph)
|
||||||
{
|
{
|
||||||
GC_Glyph *next;
|
GC_Glyph *next;
|
||||||
@ -42,6 +35,20 @@ Struct(GC_GlyphBin)
|
|||||||
GC_Glyph *first;
|
GC_Glyph *first;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Struct(GC_GlyphDesc)
|
||||||
|
{
|
||||||
|
GC_FontKey font;
|
||||||
|
f32 font_size;
|
||||||
|
u32 codepoint;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Struct(GC_GlyphDescChunk)
|
||||||
|
// {
|
||||||
|
// GC_GlyphDescChunk *next;
|
||||||
|
// u64 descs_count;
|
||||||
|
// GC_GlyphDesc *descs;
|
||||||
|
// };
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Run types
|
//~ Run types
|
||||||
|
|
||||||
@ -73,13 +80,48 @@ Struct(GC_Run)
|
|||||||
b32 ready;
|
b32 ready;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
//~ Cmd types
|
||||||
|
|
||||||
|
// Enum(GC_CmdKind)
|
||||||
|
// {
|
||||||
|
// GC_CmdKind_None,
|
||||||
|
// GC_CmdKind_LoadGlyphs
|
||||||
|
// };
|
||||||
|
|
||||||
|
Struct(GC_Cmd)
|
||||||
|
{
|
||||||
|
GC_Glyph *glyph;
|
||||||
|
};
|
||||||
|
|
||||||
|
Struct(GC_CmdChunk)
|
||||||
|
{
|
||||||
|
GC_CmdChunk *next;
|
||||||
|
|
||||||
|
u64 cmds_count;
|
||||||
|
GC_Cmd *cmds;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ State
|
//~ State
|
||||||
|
|
||||||
|
Struct(GC_WorkerState)
|
||||||
|
{
|
||||||
|
u64 cmds_count;
|
||||||
|
GC_Cmd *cmds;
|
||||||
|
};
|
||||||
|
|
||||||
Struct(GC_State)
|
Struct(GC_State)
|
||||||
{
|
{
|
||||||
Mutex glyphs_mutex;
|
Mutex glyphs_mutex;
|
||||||
GC_GlyphBin glyph_bins[16384];
|
GC_GlyphBin glyph_bins[16384];
|
||||||
|
|
||||||
|
Mutex submitted_cmds_mutex;
|
||||||
|
u64 submitted_cmds_count;
|
||||||
|
GC_CmdChunk *first_submitted_cmd_chunk;
|
||||||
|
GC_CmdChunk *last_submitted_cmd_chunk;
|
||||||
|
|
||||||
|
GC_WorkerState worker_state;
|
||||||
} extern GC;
|
} extern GC;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@ -332,7 +332,7 @@ void G_Bootstrap(void)
|
|||||||
// DispatchWave(name, 1, G_D12_WorkerEntry, (void *)(u64)kind);
|
// DispatchWave(name, 1, G_D12_WorkerEntry, (void *)(u64)kind);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
DispatchWave(Lit("Gpu collection worker"), 1, G_D12_CollectionWorkerEntry, 0);
|
DispatchWave(Lit("Gpu collection worker"), 1, G_D12_CollectionWorkerEntryPoint, 0);
|
||||||
|
|
||||||
EndScratch(scratch);
|
EndScratch(scratch);
|
||||||
}
|
}
|
||||||
@ -1067,9 +1067,11 @@ G_ResourceHandle G_PushTextureEx(G_ArenaHandle arena_handle, G_TextureResourceDe
|
|||||||
d3d_desc.MipLevels = MaxI32(desc.mip_levels, 1);
|
d3d_desc.MipLevels = MaxI32(desc.mip_levels, 1);
|
||||||
d3d_desc.SampleDesc.Count = 1;
|
d3d_desc.SampleDesc.Count = 1;
|
||||||
d3d_desc.SampleDesc.Quality = 0;
|
d3d_desc.SampleDesc.Quality = 0;
|
||||||
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS * AnyBit(desc.flags, G_ResourceFlag_AllowShaderReadWrite);
|
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS * AnyBit(desc.flags, G_ResourceFlag_AllowShaderReadWrite);
|
||||||
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET * AnyBit(desc.flags, G_ResourceFlag_AllowRenderTarget);
|
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET * AnyBit(desc.flags, G_ResourceFlag_AllowRenderTarget);
|
||||||
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL * AnyBit(desc.flags, G_ResourceFlag_AllowDepthStencil);
|
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL * AnyBit(desc.flags, G_ResourceFlag_AllowDepthStencil);
|
||||||
|
d3d_desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS * (desc.initial_layout == G_Layout_Simultaneous);
|
||||||
|
|
||||||
|
|
||||||
u64 alloc_size = 0;
|
u64 alloc_size = 0;
|
||||||
u64 alloc_align = 0;
|
u64 alloc_align = 0;
|
||||||
@ -2842,7 +2844,7 @@ void G_CommitBackbuffer(G_ResourceHandle backbuffer_handle, i32 vsync)
|
|||||||
|
|
||||||
/* TODO: Move this to common */
|
/* TODO: Move this to common */
|
||||||
|
|
||||||
void G_D12_CollectionWorkerEntry(WaveLaneCtx *lane)
|
void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane)
|
||||||
{
|
{
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -472,4 +472,4 @@ G_D12_StagingRegionNode *G_D12_PushStagingRegion(G_D12_CmdList *cl, u64 size);
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
//~ Collection worker
|
//~ Collection worker
|
||||||
|
|
||||||
void G_D12_CollectionWorkerEntry(WaveLaneCtx *lane);
|
void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user