gpu refactor progress
This commit is contained in:
parent
82c81a6280
commit
cf7ae04abb
@ -6,7 +6,7 @@ pushd build
|
||||
|
||||
for %%a in (%*) do set "%%a=1"
|
||||
set program_build_cmd=meta.exe %*
|
||||
set meta_build_cmd=cl.exe ../src/meta/meta.c /Od /Z7 /nologo /diagnostics:column /WX /link /DEBUG:FULL /INCREMENTAL:NO
|
||||
set meta_build_cmd=cl.exe ../src/meta/meta.c -Od -Z7 -nologo -diagnostics:column -WX -link -DEBUG:FULL -INCREMENTAL:NO
|
||||
set meta_rebuild_code=1317212284
|
||||
|
||||
::- Meta build
|
||||
@ -16,6 +16,7 @@ if not exist meta.exe (
|
||||
%meta_build_cmd%
|
||||
set "rc=!errorlevel!"
|
||||
if !rc! NEQ 0 (
|
||||
if exist meta.exe del meta.exe
|
||||
exit /b !rc!
|
||||
)
|
||||
)
|
||||
@ -26,8 +27,8 @@ if not "%nobuild%"=="1" (
|
||||
%program_build_cmd%
|
||||
set "rc=!errorlevel!"
|
||||
if !rc! NEQ 0 (
|
||||
del meta.exe
|
||||
if !rc! EQU %meta_rebuild_code% (
|
||||
del meta.exe
|
||||
goto meta_build
|
||||
)
|
||||
exit /b !rc!
|
||||
|
||||
@ -140,10 +140,10 @@ void BB_WriteAlignToNextByte(BB_Writer *bw)
|
||||
bw->cur_bit += (8 - (bw->cur_bit & 7)) & 7;
|
||||
}
|
||||
|
||||
void BB_WriteAlignByte(BB_Writer *bw, u64 align)
|
||||
void BB_WriteAlignBytes(BB_Writer *bw, u64 align)
|
||||
{
|
||||
BB_WriteAlignToNextByte(bw);
|
||||
BB_WriteDebugMagic(bw, BB_DebugMagicKind_AlignByte, align);
|
||||
BB_WriteDebugMagic(bw, BB_DebugMagicKind_AlignBytes, align);
|
||||
if (align > 0)
|
||||
{
|
||||
u64 new_pos = (bw->cur_bit >> 3);
|
||||
@ -471,10 +471,10 @@ void BB_ReadAlignToNextByte(BB_Reader *br)
|
||||
br->cur_bit += (8 - (br->cur_bit & 7)) & 7;
|
||||
}
|
||||
|
||||
void BB_ReadAlignByte(BB_Reader *br, u64 align)
|
||||
void BB_ReadAlignBytes(BB_Reader *br, u64 align)
|
||||
{
|
||||
BB_ReadAlignToNextByte(br);
|
||||
BB_ReadDebugMagic(br, BB_DebugMagicKind_AlignByte, align);
|
||||
BB_ReadDebugMagic(br, BB_DebugMagicKind_AlignBytes, align);
|
||||
if (align > 0)
|
||||
{
|
||||
u64 new_pos = (br->cur_bit >> 3);
|
||||
|
||||
@ -47,7 +47,7 @@ Struct(BB_Reader)
|
||||
/* Magic numbers inserted to verify read/write type & length */
|
||||
Enum(BB_DebugMagicKind)
|
||||
{
|
||||
BB_DebugMagicKind_AlignByte = 0x20A4,
|
||||
BB_DebugMagicKind_AlignBytes = 0x20A4,
|
||||
BB_DebugMagicKind_AlignToNextByte = 0x379A,
|
||||
BB_DebugMagicKind_UBits = 0xCB4A,
|
||||
BB_DebugMagicKind_IBits = 0xB30D,
|
||||
@ -90,7 +90,7 @@ b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits);
|
||||
|
||||
//- Align
|
||||
void BB_WriteAlignToNextByte(BB_Writer *bw);
|
||||
void BB_WriteAlignByte(BB_Writer *bw, u64 align);
|
||||
void BB_WriteAlignBytes(BB_Writer *bw, u64 align);
|
||||
|
||||
//- Bits
|
||||
void BB_WriteUBitsNoMagic(BB_Writer *bw, u64 value, u8 num_bits);
|
||||
@ -144,7 +144,7 @@ b32 BB_CheckReaderOverflowBits(BB_Reader *br, u64 num_bits);
|
||||
|
||||
//- Align
|
||||
void BB_ReadAlignToNextByte(BB_Reader *br);
|
||||
void BB_ReadAlignByte(BB_Reader *br, u64 align);
|
||||
void BB_ReadAlignBytes(BB_Reader *br, u64 align);
|
||||
|
||||
//- Bits
|
||||
u64 BB_ReadUBitsNoMagic(BB_Reader *br, u8 num_bits);
|
||||
|
||||
@ -163,6 +163,8 @@ Enum(GPU_Format)
|
||||
////////////////////////////////
|
||||
//~ Resource types
|
||||
|
||||
#define GPU_MaxRenderTargets 8
|
||||
|
||||
Enum(GPU_ResourceKind)
|
||||
{
|
||||
GPU_ResourceKind_Unknown,
|
||||
@ -219,12 +221,12 @@ Struct(GPU_ResourceDesc)
|
||||
////////////////////////////////
|
||||
//~ Shader types
|
||||
|
||||
Struct(GPU_ShaderDesc)
|
||||
Struct(GPU_Shader)
|
||||
{
|
||||
char *shader_id;
|
||||
char *shader_resource_name;
|
||||
};
|
||||
|
||||
#define GPU_ShaderDecl(name) static GPU_ShaderDesc name = { .shader_id = #name }
|
||||
#define GPU_ShaderDecl(name) static GPU_Shader name = { .shader_resource_name = #name }
|
||||
|
||||
////////////////////////////////
|
||||
//~ Rasterizer types
|
||||
@ -232,17 +234,29 @@ Struct(GPU_ShaderDesc)
|
||||
Enum(GPU_RasterizeMode)
|
||||
{
|
||||
GPU_RasterizeMode_None,
|
||||
GPU_RasterizeMode_TriangleList
|
||||
GPU_RasterizeMode_PointList,
|
||||
GPU_RasterizeMode_LineList,
|
||||
GPU_RasterizeMode_LineStrip,
|
||||
GPU_RasterizeMode_TriangleList,
|
||||
GPU_RasterizeMode_TriangleStrip,
|
||||
};
|
||||
|
||||
Struct(GPU_Viewport)
|
||||
{
|
||||
i32 _;
|
||||
f32 top_left_x;
|
||||
f32 top_left_y;
|
||||
f32 width;
|
||||
f32 height;
|
||||
f32 min_depth;
|
||||
f32 max_depth;
|
||||
};
|
||||
|
||||
Struct(GPU_Scissor)
|
||||
{
|
||||
i32 _;
|
||||
f32 left;
|
||||
f32 top;
|
||||
f32 right;
|
||||
f32 bottom;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@ -263,23 +277,23 @@ Struct(GPU_MemoryInfo)
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Startup
|
||||
//~ @hookdecl Startup
|
||||
|
||||
void GPU_Startup(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Rasterizer helpers
|
||||
//~ @hookdecl Rasterizer helpers
|
||||
|
||||
GPU_Viewport GPU_ViewportFromRect(Rect rect);
|
||||
GPU_Scissor GPU_ScissorFromRect(Rect rect);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Fence operations
|
||||
//~ @hookdecl Fence operations
|
||||
|
||||
GPU_Fence GPU_GetGlobalFence(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Resource operations
|
||||
//~ @hookdecl Resource operations
|
||||
|
||||
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc);
|
||||
void GPU_ReleaseResource(GPU_Resource *resource, GPU_Fence fence, GPU_ReleaseFlag flags);
|
||||
@ -288,18 +302,18 @@ u32 GPU_GetResourceId(GPU_Resource *resource);
|
||||
Vec2I32 GPU_GetTextureSize(GPU_Resource *resource);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Command list operations
|
||||
//~ @hookdecl Command list operations
|
||||
|
||||
GPU_CommandList *GPU_BeginCommandList(void);
|
||||
GPU_Fence GPU_EndCommandList(GPU_CommandList *cl);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Profiling helpers
|
||||
//~ @hookdecl Profiling helpers
|
||||
|
||||
void GPU_ProfN(GPU_CommandList *cl, String name);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Resource transition operations
|
||||
//~ @hookdecl Resource transition operations
|
||||
|
||||
void GPU_TransitionToSrv(GPU_CommandList *cl, GPU_Resource *resource);
|
||||
void GPU_TransitionToUav(GPU_CommandList *cl, GPU_Resource *resource);
|
||||
@ -307,39 +321,44 @@ void GPU_TransitionToRtv(GPU_CommandList *cl, GPU_Resource *resource);
|
||||
void GPU_FlushUav(GPU_CommandList *cl, GPU_Resource *resource);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Dispatch operations
|
||||
//~ @hookdecl Dispatch operations
|
||||
|
||||
void GPU_DispatchClear(GPU_CommandList *cl, GPU_Resource *resource);
|
||||
void GPU_ClearResource(GPU_CommandList *cl, GPU_Resource *resource);
|
||||
|
||||
void GPU_DispatchRasterize(GPU_CommandList *cl,
|
||||
GPU_ShaderDesc vs,
|
||||
GPU_ShaderDesc ps,
|
||||
void GPU_Rasterize(GPU_CommandList *gpu_cl,
|
||||
u32 sig_size,
|
||||
void *sig,
|
||||
GPU_Shader vs,
|
||||
GPU_Shader ps,
|
||||
u32 rts_count,
|
||||
GPU_Resource **rts,
|
||||
u32 viewports_count,
|
||||
GPU_Viewport *viewports,
|
||||
u32 scissors_count,
|
||||
GPU_Scissor *scissors,
|
||||
GPU_Viewport viewport,
|
||||
GPU_Scissor scissor,
|
||||
u32 instances_count,
|
||||
GPU_Resource *index_buffer,
|
||||
GPU_RasterizeMode mode);
|
||||
|
||||
void GPU_DispatchCompute(GPU_CommandList *cl, GPU_ShaderDesc cs, void *sig, u32 num_threads_x, u32 num_threads_y, u32 num_threads_z);
|
||||
void GPU_Compute(GPU_CommandList *cl,
|
||||
u32 sig_size,
|
||||
void *sig,
|
||||
GPU_Shader cs,
|
||||
u32 num_threads_x,
|
||||
u32 num_threads_y,
|
||||
u32 num_threads_z);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Resource copy operations
|
||||
//~ @hookdecl Resource copy operations
|
||||
|
||||
void GPU_PushResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src);
|
||||
void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Memory info operations
|
||||
//~ @hookdecl Memory info operations
|
||||
|
||||
GPU_MemoryInfo GPU_QueryMemoryInfo(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Swapchain operations
|
||||
//~ @hookdecl Swapchain operations
|
||||
|
||||
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, Vec2I32 size);
|
||||
void GPU_ReleaseSwapchain(GPU_Swapchain *swapchain);
|
||||
|
||||
@ -1,5 +1,33 @@
|
||||
GPU_D12_SharedState GPU_D12_shared_state = ZI;
|
||||
|
||||
////////////////////////////////
|
||||
//~ Raw fiber state
|
||||
|
||||
GPU_D12_FiberState *GPU_D12_FiberStateFromId(i16 fiber_id)
|
||||
{
|
||||
LocalPersist GPU_D12_FiberState *fiber_states[MaxFibers] = ZI;
|
||||
GPU_D12_FiberState *result = fiber_states[fiber_id];
|
||||
if (!result)
|
||||
{
|
||||
Arena *perm = PermArena();
|
||||
fiber_states[fiber_id] = PushStruct(perm, GPU_D12_FiberState);
|
||||
result = fiber_states[fiber_id];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Raw command list
|
||||
|
||||
GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ @hookdef Startup hook
|
||||
|
||||
@ -12,13 +40,13 @@ void GPU_Startup(void)
|
||||
|
||||
GPU_Viewport GPU_ViewportFromRect(Rect rect)
|
||||
{
|
||||
LAX rect;
|
||||
/* TODO */
|
||||
return (GPU_Viewport) ZI;
|
||||
}
|
||||
|
||||
GPU_Scissor GPU_ScissorFromRect(Rect rect)
|
||||
{
|
||||
LAX rect;
|
||||
/* TODO */
|
||||
return (GPU_Scissor) ZI;
|
||||
}
|
||||
|
||||
@ -35,26 +63,24 @@ GPU_Fence GPU_GetGlobalFence(void)
|
||||
|
||||
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc)
|
||||
{
|
||||
LAX desc;
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GPU_ReleaseResource(GPU_Resource *resource, GPU_Fence fence, GPU_ReleaseFlag flags)
|
||||
{
|
||||
LAX resource;
|
||||
LAX fence;
|
||||
LAX flags;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
u32 GPU_GetResourceId(GPU_Resource *resource)
|
||||
{
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vec2I32 GPU_GetTextureSize(GPU_Resource *resource)
|
||||
{
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
return VEC2I32(0, 0);
|
||||
}
|
||||
|
||||
@ -63,12 +89,145 @@ Vec2I32 GPU_GetTextureSize(GPU_Resource *resource)
|
||||
|
||||
GPU_CommandList *GPU_BeginCommandList(void)
|
||||
{
|
||||
return 0;
|
||||
GPU_D12_FiberState *f = GPU_D12_FiberStateFromId(FiberId());
|
||||
Arena *perm = PermArena();
|
||||
GPU_D12_CommandList *cl = f->first_free_command_list;
|
||||
StackPop(f->first_free_command_list);
|
||||
if (!cl)
|
||||
{
|
||||
cl = PushStruct(perm, GPU_D12_CommandList);
|
||||
}
|
||||
return (GPU_CommandList *)cl;
|
||||
}
|
||||
|
||||
GPU_Fence GPU_EndCommandList(GPU_CommandList *cl)
|
||||
GPU_Fence GPU_EndCommandList(GPU_CommandList *gpu_cl)
|
||||
{
|
||||
LAX cl;
|
||||
GPU_D12_FiberState *f = GPU_D12_FiberStateFromId(FiberId());
|
||||
GPU_D12_CommandList *cl = gpu_cl;
|
||||
|
||||
/* Determine queue kind */
|
||||
GPU_QueueKind queue_kind = GPU_QueueKind_BackgroundCopy;
|
||||
for (GPU_D12_Command *cmd = cl->first; cmd; cmd = cmd->next)
|
||||
{
|
||||
}
|
||||
|
||||
/* Begin dx12 command list */
|
||||
GPU_D12_RawCommandList *dx12_cl = GPU_D12_BeginRawCommandList(queue_kind);
|
||||
ID3D12GraphicsCommandList *rcl = dx12_cl->cl;
|
||||
|
||||
/* Process gpu commands into dx12 commands */
|
||||
{
|
||||
|
||||
for (GPU_D12_Command *cmd = cl->first; cmd; cmd = cmd->next)
|
||||
{
|
||||
GPU_D12_CommandKind kind = cmd->kind;
|
||||
switch (kind)
|
||||
{
|
||||
default: break;
|
||||
|
||||
//- Dispatch Vs/Ps shader
|
||||
case GPU_D12_CommandKind_Rasterize:
|
||||
{
|
||||
GPU_D12_RawPipeline *pipeline = 0;
|
||||
{
|
||||
GPU_D12_RawPipelineDesc pipeline_desc = ZI;
|
||||
pipeline_desc.vs = cmd->rasterise.vs;
|
||||
pipeline_desc.ps = cmd->rasterise.ps;
|
||||
pipeline_desc.render_targets_count = rts_count;
|
||||
for (u32 i = 0; i < rts_count && i < GPU_MaxRenderTargets; ++i)
|
||||
{
|
||||
pipeline_desc.render_target_formats[i] = rts[i]->format;
|
||||
}
|
||||
pipeline = GPU_D12_RawPipelineFromDesc(pipeline_desc);
|
||||
}
|
||||
|
||||
if (pipeline)
|
||||
{
|
||||
|
||||
/* Bind pipeline */
|
||||
ID3D12GraphicsCommandList_SetPipelineState(rc, pipeline->raw);
|
||||
|
||||
/* Fill signature */
|
||||
{
|
||||
u32 sig_size = cmd->rasterize.sig_size;
|
||||
void *sig = cmd->rasterize.sig;
|
||||
u32 num32bit = sig_size / 4;
|
||||
ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(rcl, 0, num32bit, sig, 0);
|
||||
}
|
||||
|
||||
/* Set rasterizer state */
|
||||
{
|
||||
D3D12_RECT scissor = GPU_D12_ScissorRectFromRect(ui_viewport);
|
||||
scissor.left = cmd->rasterize.scissor.left;
|
||||
scissor.top = cmd->rasterize.scissor.top;
|
||||
scissor.right = cmd->rasterize.scissor.right;
|
||||
scissor.bottom = cmd->rasterize.scissor.bottom;
|
||||
D3D12_VIEWPORT viewport = ZI;
|
||||
viewport.TopLeftX = cmd->rasterize.viewport.top_left_x;
|
||||
viewport.TopLeftY = cmd->rasterize.viewport.top_left_y;
|
||||
viewport.Width = cmd->rasterize.viewport.width;
|
||||
viewport.Height = cmd->rasterize.viewport.height;
|
||||
viewport.MinDepth = cmd->rasterize.viewport.min_depth;
|
||||
viewport.MaxDepth = cmd->rasterize.viewport.max_depth;
|
||||
ID3D12GraphicsCommandList_RSSetScissorRects(rcl, 1, &scissor);
|
||||
ID3D12GraphicsCommandList_RSSetViewports(rcl, 1, &viewport);
|
||||
}
|
||||
|
||||
/* Set topology */
|
||||
{
|
||||
D3D_PRIMITIVE_TOPOLOGY topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||
switch (cmd->rasterize.mode)
|
||||
{
|
||||
default: Assert(0); break;
|
||||
case GPU_RasterizeMode_PointList: topology = D3D_PRIMITIVE_TOPOLOGY_POINTLIST; break;
|
||||
case GPU_RasterizeMode_LineList: topology = D3D_PRIMITIVE_TOPOLOGY_LINELIST; break;
|
||||
case GPU_RasterizeMode_LineStrip: topology = D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; break;
|
||||
case GPU_RasterizeMode_TriangleList: topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; break;
|
||||
case GPU_RasterizeMode_TriangleStrip: topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; break;
|
||||
}
|
||||
ID3D12GraphicsCommandList_IASetPrimitiveTopology(rcl, topology);
|
||||
}
|
||||
|
||||
/* Set index buffer */
|
||||
u32 indices_count = 0;
|
||||
{
|
||||
GPU_D12_Resource *indices = cmd->rasterizer.index_buffer;
|
||||
if (indices)
|
||||
{
|
||||
D3D12_INDEX_BUFFER_VIEW ibv = ZI;
|
||||
ibv.buffer_location = indices->gpu_address;
|
||||
ibv.format = indices->format;
|
||||
ibv.SizeInBytes = indices->size;
|
||||
indices_count = indices->count;
|
||||
}
|
||||
}
|
||||
|
||||
/* Dispatch */
|
||||
ID3D12GraphicsCommandList_DrawIndexedInstanced(rcl, cmd->rasterize.instance_count, indices_count, 0, 0, 0);
|
||||
}
|
||||
} break;
|
||||
|
||||
//- Dispatch compute shader
|
||||
case GPU_D12_CommandKind_Compute:
|
||||
{
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End dx12 command list */
|
||||
GPU_D12_EndRawCommandList(rcl);
|
||||
|
||||
/* Free commands */
|
||||
if (cl->last)
|
||||
{
|
||||
cl->last->next = f->first_free_command;
|
||||
f->first_free_command = cl->first;
|
||||
}
|
||||
|
||||
/* Free command list */
|
||||
StackPush(f->first_free_command_list, cl);
|
||||
|
||||
return (GPU_Fence) ZI;
|
||||
}
|
||||
|
||||
@ -77,8 +236,7 @@ GPU_Fence GPU_EndCommandList(GPU_CommandList *cl)
|
||||
|
||||
void GPU_ProfN(GPU_CommandList *cl, String name)
|
||||
{
|
||||
LAX cl;
|
||||
LAX name;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@ -86,74 +244,57 @@ void GPU_ProfN(GPU_CommandList *cl, String name)
|
||||
|
||||
void GPU_TransitionToSrv(GPU_CommandList *cl, GPU_Resource *resource)
|
||||
{
|
||||
LAX cl;
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_TransitionToUav(GPU_CommandList *cl, GPU_Resource *resource)
|
||||
{
|
||||
LAX cl;
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_TransitionToRtv(GPU_CommandList *cl, GPU_Resource *resource)
|
||||
{
|
||||
LAX cl;
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_FlushUav(GPU_CommandList *cl, GPU_Resource *resource)
|
||||
{
|
||||
LAX cl;
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ @hookdef Dispatch hooks
|
||||
|
||||
void GPU_DispatchClear(GPU_CommandList *cl, GPU_Resource *resource)
|
||||
void GPU_ClearResource(GPU_CommandList *cl, GPU_Resource *resource)
|
||||
{
|
||||
LAX cl;
|
||||
LAX resource;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_DispatchRasterize(GPU_CommandList *cl,
|
||||
GPU_ShaderDesc vs,
|
||||
GPU_ShaderDesc ps,
|
||||
void GPU_Rasterize(GPU_CommandList *gpu_cl,
|
||||
GPU_Shader vs,
|
||||
GPU_Shader ps,
|
||||
u32 sig_size,
|
||||
void *sig,
|
||||
u32 rts_count,
|
||||
GPU_Resource **rts,
|
||||
u32 viewports_count,
|
||||
GPU_Viewport *viewports,
|
||||
u32 scissors_count,
|
||||
GPU_Scissor *scissors,
|
||||
GPU_Viewport viewport,
|
||||
GPU_Scissor scissor,
|
||||
u32 instances_count,
|
||||
GPU_Resource *index_buffer,
|
||||
GPU_RasterizeMode mode)
|
||||
{
|
||||
LAX cl;
|
||||
LAX vs;
|
||||
LAX ps;
|
||||
LAX sig;
|
||||
LAX rts_count;
|
||||
LAX rts;
|
||||
LAX viewports_count;
|
||||
LAX *viewports;
|
||||
LAX scissors_count;
|
||||
LAX scissors;
|
||||
LAX instances_count;
|
||||
LAX index_buffer;
|
||||
LAX mode;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_DispatchCompute(GPU_CommandList *cl, GPU_ShaderDesc cs, void *sig, u32 num_threads_x, u32 num_threads_y, u32 num_threads_z)
|
||||
void GPU_Compute(GPU_CommandList *cl,
|
||||
GPU_Shader cs,
|
||||
u32 sig_size,
|
||||
void *sig,
|
||||
u32 num_threads_x,
|
||||
u32 num_threads_y,
|
||||
u32 num_threads_z)
|
||||
{
|
||||
LAX cl;
|
||||
LAX cs;
|
||||
LAX sig;
|
||||
LAX num_threads_x;
|
||||
LAX num_threads_y;
|
||||
LAX num_threads_z;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@ -161,16 +302,12 @@ void GPU_DispatchCompute(GPU_CommandList *cl, GPU_ShaderDesc cs, void *sig, u32
|
||||
|
||||
void GPU_PushResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src)
|
||||
{
|
||||
LAX cl;
|
||||
LAX dst;
|
||||
LAX src;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src)
|
||||
{
|
||||
LAX cl;
|
||||
LAX dst;
|
||||
LAX src;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@ -178,6 +315,7 @@ void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src)
|
||||
|
||||
GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
||||
{
|
||||
/* TODO */
|
||||
return (GPU_MemoryInfo) ZI;
|
||||
}
|
||||
|
||||
@ -186,26 +324,21 @@ GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
||||
|
||||
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, Vec2I32 size)
|
||||
{
|
||||
LAX window;
|
||||
LAX size;
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GPU_ReleaseSwapchain(GPU_Swapchain *swapchain)
|
||||
{
|
||||
LAX swapchain;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_WaitOnSwapchain(GPU_Swapchain *swapchain)
|
||||
{
|
||||
LAX swapchain;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void GPU_PresentSwapchain(GPU_Swapchain *swapchain, Vec2I32 backbuffer_resolution, GPU_Resource *texture, Xform texture_xf, i32 vsync)
|
||||
{
|
||||
LAX swapchain;
|
||||
LAX backbuffer_resolution;
|
||||
LAX texture;
|
||||
LAX texture_xf;
|
||||
LAX vsync;
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
@ -1,3 +1,69 @@
|
||||
////////////////////////////////
|
||||
//~ Raw command list types
|
||||
|
||||
Struct(GPU_D12_RawCommandList)
|
||||
{
|
||||
struct ID3D12CommandAllocator *ca;
|
||||
struct ID3D12GraphicsCommandList *cl;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Command types
|
||||
|
||||
Enum(GPU_D12_CommandKind)
|
||||
{
|
||||
GPU_D12_CommandKind_None,
|
||||
GPU_D12_CommandKind_Rasterize,
|
||||
GPU_D12_CommandKind_Compute,
|
||||
};
|
||||
|
||||
Struct(GPU_D12_Command)
|
||||
{
|
||||
GPU_D12_Command *next;
|
||||
GPU_D12_CommandKind kind;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
GPU_Shader vs;
|
||||
GPU_Shader ps;
|
||||
u32 sig_size;
|
||||
void *sig;
|
||||
u32 rts_count;
|
||||
GPU_Resource **rts;
|
||||
u32 viewports_count;
|
||||
GPU_Viewport *viewports;
|
||||
u32 scissors_count;
|
||||
GPU_Scissor *scissors;
|
||||
u32 instances_count;
|
||||
GPU_Resource *index_buffer;
|
||||
GPU_RasterizeMode mode;
|
||||
} rasterize;
|
||||
struct
|
||||
{
|
||||
i32 _;
|
||||
} compute;
|
||||
};
|
||||
};
|
||||
|
||||
Struct(GPU_D12_CommandList)
|
||||
{
|
||||
GPU_D12_CommandList *next;
|
||||
GPU_D12_Command *first;
|
||||
GPU_D12_Command *last;
|
||||
u64 count;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Fiber state
|
||||
|
||||
Struct(GPU_D12_FiberState)
|
||||
{
|
||||
GPU_D12_CommandList *first_free_command_list;
|
||||
GPU_D12_Command *first_free_command;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ Shared state
|
||||
|
||||
@ -7,3 +73,14 @@ Struct(GPU_D12_SharedState)
|
||||
};
|
||||
|
||||
extern GPU_D12_SharedState GPU_D12_shared_state;
|
||||
|
||||
////////////////////////////////
|
||||
//~ Fiber state operations
|
||||
|
||||
GPU_D12_FiberState *GPU_D12_FiberStateFromId(i16 fiber_id);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Raw command list operations
|
||||
|
||||
GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind);
|
||||
void GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl);
|
||||
|
||||
@ -556,13 +556,13 @@ void StartupMeta(void)
|
||||
String file_data = F_DataFromFile(arena, en->file_name);
|
||||
|
||||
/* Write name */
|
||||
BB_WriteAlignByte(&bw, 64);
|
||||
BB_WriteAlignBytes(&bw, 64);
|
||||
u64 name_start = BB_GetNumBytesWritten(&bw) + 1;
|
||||
BB_WriteString(&bw, en->entry_name);
|
||||
u64 name_len = BB_GetNumBytesWritten(&bw) - name_start;
|
||||
|
||||
/* Write data */
|
||||
BB_WriteAlignByte(&bw, 64);
|
||||
BB_WriteAlignBytes(&bw, 64);
|
||||
/* FIXME: Why no +1 here? */
|
||||
u64 data_start = BB_GetNumBytesWritten(&bw);
|
||||
BB_WriteBytes(&bw, file_data);
|
||||
|
||||
@ -433,7 +433,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList
|
||||
while (stack)
|
||||
{
|
||||
StackNode *stack_node = stack;
|
||||
IterState *state = stack->state;
|
||||
IterState *state = stack_node->state;
|
||||
M_Layer *layer = state->layer;
|
||||
StackPop(stack);
|
||||
|
||||
|
||||
36
src/pp/pp.c
36
src/pp/pp.c
@ -2209,8 +2209,8 @@ void UpdateUser(P_Window *window)
|
||||
GPU_ProfN(cl, Lit("Clear gbuffers"));
|
||||
GPU_TransitionToRtv(cl, g->albedo);
|
||||
GPU_TransitionToRtv(cl, g->emittance);
|
||||
GPU_DispatchClear(cl, g->albedo);
|
||||
GPU_DispatchClear(cl, g->emittance);
|
||||
GPU_ClearResource(cl, g->albedo);
|
||||
GPU_ClearResource(cl, g->emittance);
|
||||
}
|
||||
|
||||
//- Material pass
|
||||
@ -2229,12 +2229,12 @@ void UpdateUser(P_Window *window)
|
||||
sig.projection = world_to_render_vp_matrix;
|
||||
sig.instances_urid = GPU_GetResourceId(material_instance_buffer);
|
||||
sig.grids_urid = GPU_GetResourceId(grids_buffer);
|
||||
GPU_DispatchRasterize(cl,
|
||||
GPU_Rasterize(cl,
|
||||
MaterialVS, MaterialPS,
|
||||
&sig,
|
||||
countof(rts), rts,
|
||||
1, &viewport,
|
||||
1, &scissor,
|
||||
viewport,
|
||||
scissor,
|
||||
g->material_instances_count,
|
||||
quad_index_buffer,
|
||||
GPU_RasterizeMode_TriangleList);
|
||||
@ -2272,7 +2272,7 @@ void UpdateUser(P_Window *window)
|
||||
sig.target_flood_tex_urid = GPU_GetResourceId(g->emittance_flood_target);
|
||||
sig.tex_width = g->render_size.x;
|
||||
sig.tex_height = g->render_size.y;
|
||||
GPU_DispatchCompute(cl, FloodCS, &sig, (g->render_size.x + 7) / 8, (g->render_size.y + 7) / 8, 1);
|
||||
GPU_Compute(cl, FloodCS, &sig, (g->render_size.x + 7) / 8, (g->render_size.y + 7) / 8, 1);
|
||||
|
||||
/* Swap buffers */
|
||||
GPU_Resource *swp = g->emittance_flood_read;
|
||||
@ -2301,7 +2301,7 @@ void UpdateUser(P_Window *window)
|
||||
GPU_TransitionToUav(cl, g->shade_target);
|
||||
GPU_FlushUav(cl, g->emittance_flood_read);
|
||||
GPU_FlushUav(cl, g->shade_read);
|
||||
GPU_DispatchClear(cl, g->shade_target);
|
||||
GPU_ClearResource(cl, g->shade_target);
|
||||
}
|
||||
|
||||
//- Shade pass
|
||||
@ -2329,7 +2329,7 @@ void UpdateUser(P_Window *window)
|
||||
sig.emittance_flood_tex_urid = GPU_GetResourceId(g->emittance_flood_read);
|
||||
sig.read_tex_urid = GPU_GetResourceId(g->shade_read);
|
||||
sig.target_tex_urid = GPU_GetResourceId(g->shade_target);
|
||||
GPU_DispatchCompute(cl, ShadeCS, &sig, (g->render_size.x + 7) / 8, (g->render_size.y + 7) / 8, 1);
|
||||
GPU_Compute(cl, ShadeCS, &sig, (g->render_size.x + 7) / 8, (g->render_size.y + 7) / 8, 1);
|
||||
|
||||
/* Swap */
|
||||
GPU_Resource *swp = g->shade_read;
|
||||
@ -2343,7 +2343,7 @@ void UpdateUser(P_Window *window)
|
||||
GPU_ProfN(cl, Lit("Clear ui target"));
|
||||
GPU_TransitionToRtv(cl, g->ui_target);
|
||||
GPU_FlushUav(cl, g->shade_read);
|
||||
GPU_DispatchClear(cl, g->ui_target);
|
||||
GPU_ClearResource(cl, g->ui_target);
|
||||
}
|
||||
|
||||
//- Ui blit pass
|
||||
@ -2360,12 +2360,12 @@ void UpdateUser(P_Window *window)
|
||||
sig.exposure = 2.0;
|
||||
sig.gamma = (f32)2.2;
|
||||
sig.tex_urid = GPU_GetResourceId(g->shade_read);
|
||||
GPU_DispatchRasterize(cl,
|
||||
GPU_Rasterize(cl,
|
||||
UiBlitVS, UiBlitPS,
|
||||
&sig,
|
||||
1, &g->ui_target,
|
||||
1, &viewport,
|
||||
1, &scissor,
|
||||
viewport,
|
||||
scissor,
|
||||
1,
|
||||
quad_index_buffer,
|
||||
GPU_RasterizeMode_TriangleList);
|
||||
@ -2382,12 +2382,12 @@ void UpdateUser(P_Window *window)
|
||||
UiRectSig sig = ZI;
|
||||
sig.projection = ui_vp_matrix;
|
||||
sig.instances_urid = GPU_GetResourceId(ui_rect_instance_buffer);
|
||||
GPU_DispatchRasterize(cl,
|
||||
GPU_Rasterize(cl,
|
||||
UiRectVS, UiRectPS,
|
||||
&sig,
|
||||
1, &g->ui_target,
|
||||
1, &viewport,
|
||||
1, &scissor,
|
||||
viewport,
|
||||
scissor,
|
||||
g->ui_rect_instances_count,
|
||||
quad_index_buffer,
|
||||
GPU_RasterizeMode_TriangleList);
|
||||
@ -2404,12 +2404,12 @@ void UpdateUser(P_Window *window)
|
||||
UiShapeSig sig = ZI;
|
||||
sig.projection = ui_vp_matrix;
|
||||
sig.verts_urid = GPU_GetResourceId(ui_shape_verts_buffer);
|
||||
GPU_DispatchRasterize(cl,
|
||||
GPU_Rasterize(cl,
|
||||
UiShapeVS, UiShapePS,
|
||||
&sig,
|
||||
1, &g->ui_target,
|
||||
1, &viewport,
|
||||
1, &scissor,
|
||||
viewport,
|
||||
scissor,
|
||||
1,
|
||||
ui_shape_indices_buffer,
|
||||
GPU_RasterizeMode_TriangleList);
|
||||
|
||||
@ -2,13 +2,6 @@ Readonly S_Texture S_NilTexture = ZI;
|
||||
Readonly S_Sheet S_NilSheet = ZI;
|
||||
S_SharedState S_shared_state = ZI;
|
||||
|
||||
////////////////////////////////
|
||||
//~ Startup
|
||||
|
||||
void S_Startup(void)
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ Load jobs
|
||||
|
||||
|
||||
@ -132,11 +132,6 @@ Struct(S_SharedState)
|
||||
|
||||
extern S_SharedState S_shared_state;
|
||||
|
||||
////////////////////////////////
|
||||
//~ Startup
|
||||
|
||||
void S_Startup(void);
|
||||
|
||||
////////////////////////////////
|
||||
//~ Load jobs
|
||||
|
||||
|
||||
@ -9,6 +9,3 @@
|
||||
|
||||
//- Impl
|
||||
@IncludeC sprite.c
|
||||
|
||||
//- Startup
|
||||
@Startup S_Startup
|
||||
|
||||
Loading…
Reference in New Issue
Block a user