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"
|
for %%a in (%*) do set "%%a=1"
|
||||||
set program_build_cmd=meta.exe %*
|
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
|
set meta_rebuild_code=1317212284
|
||||||
|
|
||||||
::- Meta build
|
::- Meta build
|
||||||
@ -16,6 +16,7 @@ if not exist meta.exe (
|
|||||||
%meta_build_cmd%
|
%meta_build_cmd%
|
||||||
set "rc=!errorlevel!"
|
set "rc=!errorlevel!"
|
||||||
if !rc! NEQ 0 (
|
if !rc! NEQ 0 (
|
||||||
|
if exist meta.exe del meta.exe
|
||||||
exit /b !rc!
|
exit /b !rc!
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -26,8 +27,8 @@ if not "%nobuild%"=="1" (
|
|||||||
%program_build_cmd%
|
%program_build_cmd%
|
||||||
set "rc=!errorlevel!"
|
set "rc=!errorlevel!"
|
||||||
if !rc! NEQ 0 (
|
if !rc! NEQ 0 (
|
||||||
del meta.exe
|
|
||||||
if !rc! EQU %meta_rebuild_code% (
|
if !rc! EQU %meta_rebuild_code% (
|
||||||
|
del meta.exe
|
||||||
goto meta_build
|
goto meta_build
|
||||||
)
|
)
|
||||||
exit /b !rc!
|
exit /b !rc!
|
||||||
|
|||||||
@ -286,15 +286,15 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
|
|
||||||
//- Singly linked list queue (first, last, & next pointers)
|
//- Singly linked list queue (first, last, & next pointers)
|
||||||
|
|
||||||
#define QueuePushNZ(nil,f,l,n,next) (CheckNil(nil,f) ? \
|
#define QueuePushNZ(nil,f,l,n,next) (CheckNil(nil,f) ? \
|
||||||
((f)=(l)=(n),SetNil(nil,(n)->next)) : \
|
((f)=(l)=(n),SetNil(nil,(n)->next)) : \
|
||||||
((l)->next=(n),(l)=(n),SetNil(nil,(n)->next)))
|
((l)->next=(n),(l)=(n),SetNil(nil,(n)->next)))
|
||||||
|
|
||||||
#define QueuePushFrontNZ(nil,f,l,n,next) (CheckNil(nil,f) ? \
|
#define QueuePushFrontNZ(nil,f,l,n,next) (CheckNil(nil,f) ? \
|
||||||
((f)=(l)=(n),SetNil(nil,(n)->next)) : \
|
((f)=(l)=(n),SetNil(nil,(n)->next)) : \
|
||||||
((n)->next=(f),(f)=(n)))
|
((n)->next=(f),(f)=(n)))
|
||||||
|
|
||||||
#define QueuePopNZ(nil,f,l,next) ((f)==(l) ? \
|
#define QueuePopNZ(nil,f,l,next) ((f)==(l) ? \
|
||||||
(SetNil(nil,f),SetNil(nil,l)) : \
|
(SetNil(nil,f),SetNil(nil,l)) : \
|
||||||
((f)=(f)->next))
|
((f)=(f)->next))
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
|
|
||||||
//- Doubly linked list (first, last, next, & prev pointers)
|
//- Doubly linked list (first, last, next, & prev pointers)
|
||||||
|
|
||||||
#define DllInsertNPZ(nil,f,l,p,n,next,prev) (CheckNil(nil,f) ? \
|
#define DllInsertNPZ(nil,f,l,p,n,next,prev) (CheckNil(nil,f) ? \
|
||||||
((f) = (l) = (n), SetNil(nil,(n)->next), SetNil(nil,(n)->prev)) : \
|
((f) = (l) = (n), SetNil(nil,(n)->next), SetNil(nil,(n)->prev)) : \
|
||||||
CheckNil(nil,p) ? \
|
CheckNil(nil,p) ? \
|
||||||
((n)->next = (f), (f)->prev = (n), (f) = (n), SetNil(nil,(n)->prev)) : \
|
((n)->next = (f), (f)->prev = (n), (f) = (n), SetNil(nil,(n)->prev)) : \
|
||||||
@ -315,7 +315,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
|
|||||||
((l)->next = (n), (n)->prev = (l), (l) = (n), SetNil(nil, (n)->next)) : \
|
((l)->next = (n), (n)->prev = (l), (l) = (n), SetNil(nil, (n)->next)) : \
|
||||||
(((!CheckNil(nil,p) && CheckNil(nil,(p)->next)) ? (0) : ((p)->next->prev = (n))), ((n)->next = (p)->next), ((p)->next = (n)), ((n)->prev = (p))))
|
(((!CheckNil(nil,p) && CheckNil(nil,(p)->next)) ? (0) : ((p)->next->prev = (n))), ((n)->next = (p)->next), ((p)->next = (n)), ((n)->prev = (p))))
|
||||||
|
|
||||||
#define DllRemoveNPZ(nil,f,l,n,next,prev) (((n) == (f) ? (f) = (n)->next : (0)), \
|
#define DllRemoveNPZ(nil,f,l,n,next,prev) (((n) == (f) ? (f) = (n)->next : (0)), \
|
||||||
((n) == (l) ? (l) = (l)->prev : (0)), \
|
((n) == (l) ? (l) = (l)->prev : (0)), \
|
||||||
(CheckNil(nil,(n)->prev) ? (0) : \
|
(CheckNil(nil,(n)->prev) ? (0) : \
|
||||||
((n)->prev->next = (n)->next)), \
|
((n)->prev->next = (n)->next)), \
|
||||||
|
|||||||
@ -140,10 +140,10 @@ void BB_WriteAlignToNextByte(BB_Writer *bw)
|
|||||||
bw->cur_bit += (8 - (bw->cur_bit & 7)) & 7;
|
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_WriteAlignToNextByte(bw);
|
||||||
BB_WriteDebugMagic(bw, BB_DebugMagicKind_AlignByte, align);
|
BB_WriteDebugMagic(bw, BB_DebugMagicKind_AlignBytes, align);
|
||||||
if (align > 0)
|
if (align > 0)
|
||||||
{
|
{
|
||||||
u64 new_pos = (bw->cur_bit >> 3);
|
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;
|
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_ReadAlignToNextByte(br);
|
||||||
BB_ReadDebugMagic(br, BB_DebugMagicKind_AlignByte, align);
|
BB_ReadDebugMagic(br, BB_DebugMagicKind_AlignBytes, align);
|
||||||
if (align > 0)
|
if (align > 0)
|
||||||
{
|
{
|
||||||
u64 new_pos = (br->cur_bit >> 3);
|
u64 new_pos = (br->cur_bit >> 3);
|
||||||
|
|||||||
@ -47,7 +47,7 @@ Struct(BB_Reader)
|
|||||||
/* Magic numbers inserted to verify read/write type & length */
|
/* Magic numbers inserted to verify read/write type & length */
|
||||||
Enum(BB_DebugMagicKind)
|
Enum(BB_DebugMagicKind)
|
||||||
{
|
{
|
||||||
BB_DebugMagicKind_AlignByte = 0x20A4,
|
BB_DebugMagicKind_AlignBytes = 0x20A4,
|
||||||
BB_DebugMagicKind_AlignToNextByte = 0x379A,
|
BB_DebugMagicKind_AlignToNextByte = 0x379A,
|
||||||
BB_DebugMagicKind_UBits = 0xCB4A,
|
BB_DebugMagicKind_UBits = 0xCB4A,
|
||||||
BB_DebugMagicKind_IBits = 0xB30D,
|
BB_DebugMagicKind_IBits = 0xB30D,
|
||||||
@ -90,7 +90,7 @@ b32 BB_CheckWriterOverflowBits(BB_Writer *bw, u64 num_bits);
|
|||||||
|
|
||||||
//- Align
|
//- Align
|
||||||
void BB_WriteAlignToNextByte(BB_Writer *bw);
|
void BB_WriteAlignToNextByte(BB_Writer *bw);
|
||||||
void BB_WriteAlignByte(BB_Writer *bw, u64 align);
|
void BB_WriteAlignBytes(BB_Writer *bw, u64 align);
|
||||||
|
|
||||||
//- Bits
|
//- Bits
|
||||||
void BB_WriteUBitsNoMagic(BB_Writer *bw, u64 value, u8 num_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
|
//- Align
|
||||||
void BB_ReadAlignToNextByte(BB_Reader *br);
|
void BB_ReadAlignToNextByte(BB_Reader *br);
|
||||||
void BB_ReadAlignByte(BB_Reader *br, u64 align);
|
void BB_ReadAlignBytes(BB_Reader *br, u64 align);
|
||||||
|
|
||||||
//- Bits
|
//- Bits
|
||||||
u64 BB_ReadUBitsNoMagic(BB_Reader *br, u8 num_bits);
|
u64 BB_ReadUBitsNoMagic(BB_Reader *br, u8 num_bits);
|
||||||
|
|||||||
@ -163,6 +163,8 @@ Enum(GPU_Format)
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Resource types
|
//~ Resource types
|
||||||
|
|
||||||
|
#define GPU_MaxRenderTargets 8
|
||||||
|
|
||||||
Enum(GPU_ResourceKind)
|
Enum(GPU_ResourceKind)
|
||||||
{
|
{
|
||||||
GPU_ResourceKind_Unknown,
|
GPU_ResourceKind_Unknown,
|
||||||
@ -219,12 +221,12 @@ Struct(GPU_ResourceDesc)
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Shader types
|
//~ 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
|
//~ Rasterizer types
|
||||||
@ -232,17 +234,29 @@ Struct(GPU_ShaderDesc)
|
|||||||
Enum(GPU_RasterizeMode)
|
Enum(GPU_RasterizeMode)
|
||||||
{
|
{
|
||||||
GPU_RasterizeMode_None,
|
GPU_RasterizeMode_None,
|
||||||
GPU_RasterizeMode_TriangleList
|
GPU_RasterizeMode_PointList,
|
||||||
|
GPU_RasterizeMode_LineList,
|
||||||
|
GPU_RasterizeMode_LineStrip,
|
||||||
|
GPU_RasterizeMode_TriangleList,
|
||||||
|
GPU_RasterizeMode_TriangleStrip,
|
||||||
};
|
};
|
||||||
|
|
||||||
Struct(GPU_Viewport)
|
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)
|
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);
|
void GPU_Startup(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Rasterizer helpers
|
//~ @hookdecl Rasterizer helpers
|
||||||
|
|
||||||
GPU_Viewport GPU_ViewportFromRect(Rect rect);
|
GPU_Viewport GPU_ViewportFromRect(Rect rect);
|
||||||
GPU_Scissor GPU_ScissorFromRect(Rect rect);
|
GPU_Scissor GPU_ScissorFromRect(Rect rect);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Fence operations
|
//~ @hookdecl Fence operations
|
||||||
|
|
||||||
GPU_Fence GPU_GetGlobalFence(void);
|
GPU_Fence GPU_GetGlobalFence(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Resource operations
|
//~ @hookdecl Resource operations
|
||||||
|
|
||||||
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc);
|
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc);
|
||||||
void GPU_ReleaseResource(GPU_Resource *resource, GPU_Fence fence, GPU_ReleaseFlag flags);
|
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);
|
Vec2I32 GPU_GetTextureSize(GPU_Resource *resource);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Command list operations
|
//~ @hookdecl Command list operations
|
||||||
|
|
||||||
GPU_CommandList *GPU_BeginCommandList(void);
|
GPU_CommandList *GPU_BeginCommandList(void);
|
||||||
GPU_Fence GPU_EndCommandList(GPU_CommandList *cl);
|
GPU_Fence GPU_EndCommandList(GPU_CommandList *cl);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Profiling helpers
|
//~ @hookdecl Profiling helpers
|
||||||
|
|
||||||
void GPU_ProfN(GPU_CommandList *cl, String name);
|
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_TransitionToSrv(GPU_CommandList *cl, GPU_Resource *resource);
|
||||||
void GPU_TransitionToUav(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);
|
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,
|
void GPU_Rasterize(GPU_CommandList *gpu_cl,
|
||||||
GPU_ShaderDesc vs,
|
u32 sig_size,
|
||||||
GPU_ShaderDesc ps,
|
void *sig,
|
||||||
void *sig,
|
GPU_Shader vs,
|
||||||
u32 rts_count,
|
GPU_Shader ps,
|
||||||
GPU_Resource **rts,
|
u32 rts_count,
|
||||||
u32 viewports_count,
|
GPU_Resource **rts,
|
||||||
GPU_Viewport *viewports,
|
GPU_Viewport viewport,
|
||||||
u32 scissors_count,
|
GPU_Scissor scissor,
|
||||||
GPU_Scissor *scissors,
|
u32 instances_count,
|
||||||
u32 instances_count,
|
GPU_Resource *index_buffer,
|
||||||
GPU_Resource *index_buffer,
|
GPU_RasterizeMode mode);
|
||||||
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_PushResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src);
|
||||||
void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src);
|
void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Memory info operations
|
//~ @hookdecl Memory info operations
|
||||||
|
|
||||||
GPU_MemoryInfo GPU_QueryMemoryInfo(void);
|
GPU_MemoryInfo GPU_QueryMemoryInfo(void);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Swapchain operations
|
//~ @hookdecl Swapchain operations
|
||||||
|
|
||||||
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, Vec2I32 size);
|
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, Vec2I32 size);
|
||||||
void GPU_ReleaseSwapchain(GPU_Swapchain *swapchain);
|
void GPU_ReleaseSwapchain(GPU_Swapchain *swapchain);
|
||||||
|
|||||||
@ -1,5 +1,33 @@
|
|||||||
GPU_D12_SharedState GPU_D12_shared_state = ZI;
|
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
|
//~ @hookdef Startup hook
|
||||||
|
|
||||||
@ -12,13 +40,13 @@ void GPU_Startup(void)
|
|||||||
|
|
||||||
GPU_Viewport GPU_ViewportFromRect(Rect rect)
|
GPU_Viewport GPU_ViewportFromRect(Rect rect)
|
||||||
{
|
{
|
||||||
LAX rect;
|
/* TODO */
|
||||||
return (GPU_Viewport) ZI;
|
return (GPU_Viewport) ZI;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPU_Scissor GPU_ScissorFromRect(Rect rect)
|
GPU_Scissor GPU_ScissorFromRect(Rect rect)
|
||||||
{
|
{
|
||||||
LAX rect;
|
/* TODO */
|
||||||
return (GPU_Scissor) ZI;
|
return (GPU_Scissor) ZI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,26 +63,24 @@ GPU_Fence GPU_GetGlobalFence(void)
|
|||||||
|
|
||||||
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc)
|
GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc)
|
||||||
{
|
{
|
||||||
LAX desc;
|
/* TODO */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_ReleaseResource(GPU_Resource *resource, GPU_Fence fence, GPU_ReleaseFlag flags)
|
void GPU_ReleaseResource(GPU_Resource *resource, GPU_Fence fence, GPU_ReleaseFlag flags)
|
||||||
{
|
{
|
||||||
LAX resource;
|
/* TODO */
|
||||||
LAX fence;
|
|
||||||
LAX flags;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GPU_GetResourceId(GPU_Resource *resource)
|
u32 GPU_GetResourceId(GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX resource;
|
/* TODO */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2I32 GPU_GetTextureSize(GPU_Resource *resource)
|
Vec2I32 GPU_GetTextureSize(GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX resource;
|
/* TODO */
|
||||||
return VEC2I32(0, 0);
|
return VEC2I32(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,12 +89,145 @@ Vec2I32 GPU_GetTextureSize(GPU_Resource *resource)
|
|||||||
|
|
||||||
GPU_CommandList *GPU_BeginCommandList(void)
|
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;
|
return (GPU_Fence) ZI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +236,7 @@ GPU_Fence GPU_EndCommandList(GPU_CommandList *cl)
|
|||||||
|
|
||||||
void GPU_ProfN(GPU_CommandList *cl, String name)
|
void GPU_ProfN(GPU_CommandList *cl, String name)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@ -86,74 +244,57 @@ void GPU_ProfN(GPU_CommandList *cl, String name)
|
|||||||
|
|
||||||
void GPU_TransitionToSrv(GPU_CommandList *cl, GPU_Resource *resource)
|
void GPU_TransitionToSrv(GPU_CommandList *cl, GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_TransitionToUav(GPU_CommandList *cl, GPU_Resource *resource)
|
void GPU_TransitionToUav(GPU_CommandList *cl, GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_TransitionToRtv(GPU_CommandList *cl, GPU_Resource *resource)
|
void GPU_TransitionToRtv(GPU_CommandList *cl, GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_FlushUav(GPU_CommandList *cl, GPU_Resource *resource)
|
void GPU_FlushUav(GPU_CommandList *cl, GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ @hookdef Dispatch hooks
|
//~ @hookdef Dispatch hooks
|
||||||
|
|
||||||
void GPU_DispatchClear(GPU_CommandList *cl, GPU_Resource *resource)
|
void GPU_ClearResource(GPU_CommandList *cl, GPU_Resource *resource)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX resource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_DispatchRasterize(GPU_CommandList *cl,
|
void GPU_Rasterize(GPU_CommandList *gpu_cl,
|
||||||
GPU_ShaderDesc vs,
|
GPU_Shader vs,
|
||||||
GPU_ShaderDesc ps,
|
GPU_Shader ps,
|
||||||
void *sig,
|
u32 sig_size,
|
||||||
u32 rts_count,
|
void *sig,
|
||||||
GPU_Resource **rts,
|
u32 rts_count,
|
||||||
u32 viewports_count,
|
GPU_Resource **rts,
|
||||||
GPU_Viewport *viewports,
|
GPU_Viewport viewport,
|
||||||
u32 scissors_count,
|
GPU_Scissor scissor,
|
||||||
GPU_Scissor *scissors,
|
u32 instances_count,
|
||||||
u32 instances_count,
|
GPU_Resource *index_buffer,
|
||||||
GPU_Resource *index_buffer,
|
GPU_RasterizeMode mode)
|
||||||
GPU_RasterizeMode mode)
|
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
/* TODO */
|
||||||
LAX cs;
|
|
||||||
LAX sig;
|
|
||||||
LAX num_threads_x;
|
|
||||||
LAX num_threads_y;
|
|
||||||
LAX num_threads_z;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@ -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)
|
void GPU_PushResource(GPU_CommandList *cl, GPU_Resource *dst, GPU_Resource *src)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX dst;
|
|
||||||
LAX src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src)
|
void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src)
|
||||||
{
|
{
|
||||||
LAX cl;
|
/* TODO */
|
||||||
LAX dst;
|
|
||||||
LAX src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@ -178,6 +315,7 @@ void GPU_PushString(GPU_CommandList *cl, GPU_Resource *dst, String src)
|
|||||||
|
|
||||||
GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
||||||
{
|
{
|
||||||
|
/* TODO */
|
||||||
return (GPU_MemoryInfo) ZI;
|
return (GPU_MemoryInfo) ZI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,26 +324,21 @@ GPU_MemoryInfo GPU_QueryMemoryInfo(void)
|
|||||||
|
|
||||||
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, Vec2I32 size)
|
GPU_Swapchain *GPU_AcquireSwapchain(P_Window *window, Vec2I32 size)
|
||||||
{
|
{
|
||||||
LAX window;
|
/* TODO */
|
||||||
LAX size;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_ReleaseSwapchain(GPU_Swapchain *swapchain)
|
void GPU_ReleaseSwapchain(GPU_Swapchain *swapchain)
|
||||||
{
|
{
|
||||||
LAX swapchain;
|
/* TODO */
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU_WaitOnSwapchain(GPU_Swapchain *swapchain)
|
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)
|
void GPU_PresentSwapchain(GPU_Swapchain *swapchain, Vec2I32 backbuffer_resolution, GPU_Resource *texture, Xform texture_xf, i32 vsync)
|
||||||
{
|
{
|
||||||
LAX swapchain;
|
/* TODO */
|
||||||
LAX backbuffer_resolution;
|
|
||||||
LAX texture;
|
|
||||||
LAX texture_xf;
|
|
||||||
LAX vsync;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
//~ Shared state
|
||||||
|
|
||||||
@ -7,3 +73,14 @@ Struct(GPU_D12_SharedState)
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern GPU_D12_SharedState GPU_D12_shared_state;
|
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);
|
||||||
|
|||||||
@ -289,7 +289,7 @@ void StartupMeta(void)
|
|||||||
M_Token *entry_tok = entry->name_token;
|
M_Token *entry_tok = entry->name_token;
|
||||||
M_Token *arg0_tok = entry->arg_tokens[0];
|
M_Token *arg0_tok = entry->arg_tokens[0];
|
||||||
M_Token *arg1_tok = entry->arg_tokens[1];
|
M_Token *arg1_tok = entry->arg_tokens[1];
|
||||||
switch(kind)
|
switch (kind)
|
||||||
{
|
{
|
||||||
case M_EntryKind_Unknown:
|
case M_EntryKind_Unknown:
|
||||||
{
|
{
|
||||||
@ -556,13 +556,13 @@ void StartupMeta(void)
|
|||||||
String file_data = F_DataFromFile(arena, en->file_name);
|
String file_data = F_DataFromFile(arena, en->file_name);
|
||||||
|
|
||||||
/* Write name */
|
/* Write name */
|
||||||
BB_WriteAlignByte(&bw, 64);
|
BB_WriteAlignBytes(&bw, 64);
|
||||||
u64 name_start = BB_GetNumBytesWritten(&bw) + 1;
|
u64 name_start = BB_GetNumBytesWritten(&bw) + 1;
|
||||||
BB_WriteString(&bw, en->entry_name);
|
BB_WriteString(&bw, en->entry_name);
|
||||||
u64 name_len = BB_GetNumBytesWritten(&bw) - name_start;
|
u64 name_len = BB_GetNumBytesWritten(&bw) - name_start;
|
||||||
|
|
||||||
/* Write data */
|
/* Write data */
|
||||||
BB_WriteAlignByte(&bw, 64);
|
BB_WriteAlignBytes(&bw, 64);
|
||||||
/* FIXME: Why no +1 here? */
|
/* FIXME: Why no +1 here? */
|
||||||
u64 data_start = BB_GetNumBytesWritten(&bw);
|
u64 data_start = BB_GetNumBytesWritten(&bw);
|
||||||
BB_WriteBytes(&bw, file_data);
|
BB_WriteBytes(&bw, file_data);
|
||||||
|
|||||||
@ -433,7 +433,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList
|
|||||||
while (stack)
|
while (stack)
|
||||||
{
|
{
|
||||||
StackNode *stack_node = stack;
|
StackNode *stack_node = stack;
|
||||||
IterState *state = stack->state;
|
IterState *state = stack_node->state;
|
||||||
M_Layer *layer = state->layer;
|
M_Layer *layer = state->layer;
|
||||||
StackPop(stack);
|
StackPop(stack);
|
||||||
|
|
||||||
|
|||||||
84
src/pp/pp.c
84
src/pp/pp.c
@ -2209,8 +2209,8 @@ void UpdateUser(P_Window *window)
|
|||||||
GPU_ProfN(cl, Lit("Clear gbuffers"));
|
GPU_ProfN(cl, Lit("Clear gbuffers"));
|
||||||
GPU_TransitionToRtv(cl, g->albedo);
|
GPU_TransitionToRtv(cl, g->albedo);
|
||||||
GPU_TransitionToRtv(cl, g->emittance);
|
GPU_TransitionToRtv(cl, g->emittance);
|
||||||
GPU_DispatchClear(cl, g->albedo);
|
GPU_ClearResource(cl, g->albedo);
|
||||||
GPU_DispatchClear(cl, g->emittance);
|
GPU_ClearResource(cl, g->emittance);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Material pass
|
//- Material pass
|
||||||
@ -2229,15 +2229,15 @@ void UpdateUser(P_Window *window)
|
|||||||
sig.projection = world_to_render_vp_matrix;
|
sig.projection = world_to_render_vp_matrix;
|
||||||
sig.instances_urid = GPU_GetResourceId(material_instance_buffer);
|
sig.instances_urid = GPU_GetResourceId(material_instance_buffer);
|
||||||
sig.grids_urid = GPU_GetResourceId(grids_buffer);
|
sig.grids_urid = GPU_GetResourceId(grids_buffer);
|
||||||
GPU_DispatchRasterize(cl,
|
GPU_Rasterize(cl,
|
||||||
MaterialVS, MaterialPS,
|
MaterialVS, MaterialPS,
|
||||||
&sig,
|
&sig,
|
||||||
countof(rts), rts,
|
countof(rts), rts,
|
||||||
1, &viewport,
|
viewport,
|
||||||
1, &scissor,
|
scissor,
|
||||||
g->material_instances_count,
|
g->material_instances_count,
|
||||||
quad_index_buffer,
|
quad_index_buffer,
|
||||||
GPU_RasterizeMode_TriangleList);
|
GPU_RasterizeMode_TriangleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Prep flood pass
|
//- Prep flood pass
|
||||||
@ -2272,7 +2272,7 @@ void UpdateUser(P_Window *window)
|
|||||||
sig.target_flood_tex_urid = GPU_GetResourceId(g->emittance_flood_target);
|
sig.target_flood_tex_urid = GPU_GetResourceId(g->emittance_flood_target);
|
||||||
sig.tex_width = g->render_size.x;
|
sig.tex_width = g->render_size.x;
|
||||||
sig.tex_height = g->render_size.y;
|
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 */
|
/* Swap buffers */
|
||||||
GPU_Resource *swp = g->emittance_flood_read;
|
GPU_Resource *swp = g->emittance_flood_read;
|
||||||
@ -2301,7 +2301,7 @@ void UpdateUser(P_Window *window)
|
|||||||
GPU_TransitionToUav(cl, g->shade_target);
|
GPU_TransitionToUav(cl, g->shade_target);
|
||||||
GPU_FlushUav(cl, g->emittance_flood_read);
|
GPU_FlushUav(cl, g->emittance_flood_read);
|
||||||
GPU_FlushUav(cl, g->shade_read);
|
GPU_FlushUav(cl, g->shade_read);
|
||||||
GPU_DispatchClear(cl, g->shade_target);
|
GPU_ClearResource(cl, g->shade_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Shade pass
|
//- Shade pass
|
||||||
@ -2329,7 +2329,7 @@ void UpdateUser(P_Window *window)
|
|||||||
sig.emittance_flood_tex_urid = GPU_GetResourceId(g->emittance_flood_read);
|
sig.emittance_flood_tex_urid = GPU_GetResourceId(g->emittance_flood_read);
|
||||||
sig.read_tex_urid = GPU_GetResourceId(g->shade_read);
|
sig.read_tex_urid = GPU_GetResourceId(g->shade_read);
|
||||||
sig.target_tex_urid = GPU_GetResourceId(g->shade_target);
|
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 */
|
/* Swap */
|
||||||
GPU_Resource *swp = g->shade_read;
|
GPU_Resource *swp = g->shade_read;
|
||||||
@ -2343,7 +2343,7 @@ void UpdateUser(P_Window *window)
|
|||||||
GPU_ProfN(cl, Lit("Clear ui target"));
|
GPU_ProfN(cl, Lit("Clear ui target"));
|
||||||
GPU_TransitionToRtv(cl, g->ui_target);
|
GPU_TransitionToRtv(cl, g->ui_target);
|
||||||
GPU_FlushUav(cl, g->shade_read);
|
GPU_FlushUav(cl, g->shade_read);
|
||||||
GPU_DispatchClear(cl, g->ui_target);
|
GPU_ClearResource(cl, g->ui_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Ui blit pass
|
//- Ui blit pass
|
||||||
@ -2360,15 +2360,15 @@ void UpdateUser(P_Window *window)
|
|||||||
sig.exposure = 2.0;
|
sig.exposure = 2.0;
|
||||||
sig.gamma = (f32)2.2;
|
sig.gamma = (f32)2.2;
|
||||||
sig.tex_urid = GPU_GetResourceId(g->shade_read);
|
sig.tex_urid = GPU_GetResourceId(g->shade_read);
|
||||||
GPU_DispatchRasterize(cl,
|
GPU_Rasterize(cl,
|
||||||
UiBlitVS, UiBlitPS,
|
UiBlitVS, UiBlitPS,
|
||||||
&sig,
|
&sig,
|
||||||
1, &g->ui_target,
|
1, &g->ui_target,
|
||||||
1, &viewport,
|
viewport,
|
||||||
1, &scissor,
|
scissor,
|
||||||
1,
|
1,
|
||||||
quad_index_buffer,
|
quad_index_buffer,
|
||||||
GPU_RasterizeMode_TriangleList);
|
GPU_RasterizeMode_TriangleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Ui rect pass
|
//- Ui rect pass
|
||||||
@ -2382,15 +2382,15 @@ void UpdateUser(P_Window *window)
|
|||||||
UiRectSig sig = ZI;
|
UiRectSig sig = ZI;
|
||||||
sig.projection = ui_vp_matrix;
|
sig.projection = ui_vp_matrix;
|
||||||
sig.instances_urid = GPU_GetResourceId(ui_rect_instance_buffer);
|
sig.instances_urid = GPU_GetResourceId(ui_rect_instance_buffer);
|
||||||
GPU_DispatchRasterize(cl,
|
GPU_Rasterize(cl,
|
||||||
UiRectVS, UiRectPS,
|
UiRectVS, UiRectPS,
|
||||||
&sig,
|
&sig,
|
||||||
1, &g->ui_target,
|
1, &g->ui_target,
|
||||||
1, &viewport,
|
viewport,
|
||||||
1, &scissor,
|
scissor,
|
||||||
g->ui_rect_instances_count,
|
g->ui_rect_instances_count,
|
||||||
quad_index_buffer,
|
quad_index_buffer,
|
||||||
GPU_RasterizeMode_TriangleList);
|
GPU_RasterizeMode_TriangleList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Ui shape pass
|
//- Ui shape pass
|
||||||
@ -2404,15 +2404,15 @@ void UpdateUser(P_Window *window)
|
|||||||
UiShapeSig sig = ZI;
|
UiShapeSig sig = ZI;
|
||||||
sig.projection = ui_vp_matrix;
|
sig.projection = ui_vp_matrix;
|
||||||
sig.verts_urid = GPU_GetResourceId(ui_shape_verts_buffer);
|
sig.verts_urid = GPU_GetResourceId(ui_shape_verts_buffer);
|
||||||
GPU_DispatchRasterize(cl,
|
GPU_Rasterize(cl,
|
||||||
UiShapeVS, UiShapePS,
|
UiShapeVS, UiShapePS,
|
||||||
&sig,
|
&sig,
|
||||||
1, &g->ui_target,
|
1, &g->ui_target,
|
||||||
1, &viewport,
|
viewport,
|
||||||
1, &scissor,
|
scissor,
|
||||||
1,
|
1,
|
||||||
ui_shape_indices_buffer,
|
ui_shape_indices_buffer,
|
||||||
GPU_RasterizeMode_TriangleList);
|
GPU_RasterizeMode_TriangleList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g->render_fence = GPU_EndCommandList(cl);
|
g->render_fence = GPU_EndCommandList(cl);
|
||||||
|
|||||||
@ -2,13 +2,6 @@ Readonly S_Texture S_NilTexture = ZI;
|
|||||||
Readonly S_Sheet S_NilSheet = ZI;
|
Readonly S_Sheet S_NilSheet = ZI;
|
||||||
S_SharedState S_shared_state = ZI;
|
S_SharedState S_shared_state = ZI;
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ Startup
|
|
||||||
|
|
||||||
void S_Startup(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Load jobs
|
//~ Load jobs
|
||||||
|
|
||||||
|
|||||||
@ -132,11 +132,6 @@ Struct(S_SharedState)
|
|||||||
|
|
||||||
extern S_SharedState S_shared_state;
|
extern S_SharedState S_shared_state;
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ Startup
|
|
||||||
|
|
||||||
void S_Startup(void);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Load jobs
|
//~ Load jobs
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,3 @@
|
|||||||
|
|
||||||
//- Impl
|
//- Impl
|
||||||
@IncludeC sprite.c
|
@IncludeC sprite.c
|
||||||
|
|
||||||
//- Startup
|
|
||||||
@Startup S_Startup
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user