use standard indentation style for multi-line function parameters

This commit is contained in:
jacob 2025-12-18 16:48:41 -06:00
parent 83f7c48369
commit c1b768282f
14 changed files with 195 additions and 143 deletions

View File

@ -275,13 +275,15 @@ void W32_BootstrapLogs(String logfile_path)
TempArena scratch = BeginScratchNoConflict();
{
wchar_t *path_wstr = WstrFromString(scratch.arena, logfile_path);
W32.logfile = CreateFileW(path_wstr,
FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0);
W32.logfile = CreateFileW(
path_wstr,
FILE_APPEND_DATA,
FILE_SHARE_READ | FILE_SHARE_WRITE,
0,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
0
);
}
EndScratch(scratch);
}

View File

@ -63,7 +63,7 @@ Struct(G_QueueBarrierDesc)
/* NOTE: Matches DirectX DXGI_FORMAT */
Enum(G_Format)
{
G_Format_Unknown = 0,
G_Format_Unknown = 0,
G_Format_R32G32B32A32_Typeless = 1,
G_Format_R32G32B32A32_Float = 2,
G_Format_R32G32B32A32_Uint = 3,
@ -742,12 +742,14 @@ void G_Compute(G_CommandListHandle cl, ComputeShader cs, Vec3I32 groups);
//- Rasterize
void G_Rasterize(G_CommandListHandle cl,
VertexShader vs, PixelShader ps,
u32 instances_count, G_IndexBufferDesc index_buffer,
u32 render_targets_count, G_ResourceHandle *render_targets,
Rng3 viewport, Rng2 scissor,
G_RasterMode mode);
void G_Rasterize(
G_CommandListHandle cl,
VertexShader vs, PixelShader ps,
u32 instances_count, G_IndexBufferDesc index_buffer,
u32 render_targets_count, G_ResourceHandle *render_targets,
Rng3 viewport, Rng2 scissor,
G_RasterMode mode
);
//- Clear

View File

@ -106,9 +106,11 @@ void G_Bootstrap(void)
{
if (first_gpu_name.len > 0)
{
error = StringF(scratch.arena,
"Could not initialize device '%F' with D3D_FEATURE_LEVEL_12_0. Ensure that the device is capable and drivers are up to date.",
FmtString(first_gpu_name));
error = StringF(
scratch.arena,
"Could not initialize device '%F' with D3D_FEATURE_LEVEL_12_0. Ensure that the device is capable and drivers are up to date.",
FmtString(first_gpu_name)
);
}
Panic(error);
}
@ -2563,9 +2565,11 @@ void G_CopyBufferToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_h
void G_CopyTextureToTexture(G_CommandListHandle cl_handle, G_ResourceHandle dst_handle, Vec3I32 dst_offset, G_ResourceHandle src_handle, Rng3I32 src_copy_range)
{
if (src_copy_range.p1.x > src_copy_range.p0.x &&
if (
src_copy_range.p1.x > src_copy_range.p0.x &&
src_copy_range.p1.y > src_copy_range.p0.y &&
src_copy_range.p1.z > src_copy_range.p0.z)
src_copy_range.p1.z > src_copy_range.p0.z
)
{
G_D12_SharedState *g = &G_D12_shared_state;
G_D12_CmdList *cl = G_D12_CmdListFromHandle(cl_handle);
@ -2638,12 +2642,14 @@ void G_Compute(G_CommandListHandle cl_handle, ComputeShader cs, Vec3I32 groups)
//- Rasterize
void G_Rasterize(G_CommandListHandle cl_handle,
VertexShader vs, PixelShader ps,
u32 instances_count, G_IndexBufferDesc index_buffer,
u32 render_targets_count, G_ResourceHandle *render_targets,
Rng3 viewport, Rng2 scissor,
G_RasterMode mode)
void G_Rasterize(
G_CommandListHandle cl_handle,
VertexShader vs, PixelShader ps,
u32 instances_count, G_IndexBufferDesc index_buffer,
u32 render_targets_count, G_ResourceHandle *render_targets,
Rng3 viewport, Rng2 scissor,
G_RasterMode mode
)
{
G_D12_CmdList *cl = G_D12_CmdListFromHandle(cl_handle);
G_D12_Cmd *cmd = G_D12_PushCmd(cl);
@ -3059,7 +3065,8 @@ void G_D12_CollectionWorkerEntryPoint(WaveLaneCtx *lane)
/* Copy print buffer to readback buffer */
G_CopyBufferToBuffer(cl, queue->print_readback_buffer, 0, queue->print_buffer, RNGU64(0, queue->print_buffer_size));
/* Reset counters to 0 */
G_MemorySync(cl, queue->print_buffer,
G_MemorySync(
cl, queue->print_buffer,
G_Stage_Copy, G_Access_CopyRead,
G_Stage_Copy, G_Access_CopyWrite
);

View File

@ -81,12 +81,14 @@ String StringFromMetaErrors(Arena *arena, M_ErrorList errors)
{
line_col = LineColFromPos(token_file_data, token_pos);
}
String formatted = StringF(scratch.arena,
"%F:%F:%F: error: %F",
FmtString(token_file),
FmtSint(line_col.line),
FmtSint(line_col.col),
FmtString(e->msg));
String formatted = StringF(
scratch.arena,
"%F:%F:%F: error: %F",
FmtString(token_file),
FmtSint(line_col.line),
FmtSint(line_col.col),
FmtString(e->msg)
);
PushStringToList(scratch.arena, &error_strings, formatted);
}
else
@ -824,14 +826,16 @@ void BuildEntryPoint(WaveLaneCtx *lane)
if (lane->idx == WaveLaneIdxFromTaskIdx(lane, task_idx++) && GetBuildStatus() == 0)
{
Build.c_obj.obj_file = StringF(perm, "%F_gen_c.obj", FmtString(cmdline.leaf_layer_name));
String cmd = StringF(perm,
"cl.exe /c %F -Fo:%F %F %F %F %F",
FmtString(c_out_file),
FmtString(Build.c_obj.obj_file),
FmtString(StringFromList(perm, cp.flags_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.compiler_only_flags_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.warnings_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.defs, Lit(" "))));
String cmd = StringF(
perm,
"cl.exe /c %F -Fo:%F %F %F %F %F",
FmtString(c_out_file),
FmtString(Build.c_obj.obj_file),
FmtString(StringFromList(perm, cp.flags_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.compiler_only_flags_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.warnings_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.defs, Lit(" ")))
);
OS_CommandResult cmd_result = OS_RunCommand(perm, cmd);
String cmd_output = TrimWhitespace(cmd_result.output);
Build.c_obj.output = cmd_output;
@ -861,14 +865,16 @@ void BuildEntryPoint(WaveLaneCtx *lane)
: e->kind == ShaderEntryKind_PS ? Lit("ps_6_6")
: e->kind == ShaderEntryKind_CS ? Lit("cs_6_6")
: Lit("vs_6_6");
String compile_cmd = StringF(perm,
"dxc.exe -T %F -E %F -Fo %F %F %F %F",
FmtString(target),
FmtString(e->name),
FmtString(out_file),
FmtString(gpu_out_file),
FmtString(StringFromList(perm, cp.defs, Lit(" "))),
FmtString(StringFromList(perm, cp.flags_dxc, Lit(" "))));
String compile_cmd = StringF(
perm,
"dxc.exe -T %F -E %F -Fo %F %F %F %F",
FmtString(target),
FmtString(e->name),
FmtString(out_file),
FmtString(gpu_out_file),
FmtString(StringFromList(perm, cp.defs, Lit(" "))),
FmtString(StringFromList(perm, cp.flags_dxc, Lit(" ")))
);
OS_CommandResult cmd_result = OS_RunCommand(perm, compile_cmd);
gpu_obj->output = cmd_result.output;
@ -937,12 +943,14 @@ void BuildEntryPoint(WaveLaneCtx *lane)
obj_files_str = StringFromList(perm, obj_files, Lit(" "));
}
String cmd = StringF(perm,
"link.exe %F /OUT:%F %F %F",
FmtString(obj_files_str),
FmtString(exe_file),
FmtString(StringFromList(perm, cp.flags_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.linker_only_flags_msvc, Lit(" "))));
String cmd = StringF(
perm,
"link.exe %F /OUT:%F %F %F",
FmtString(obj_files_str),
FmtString(exe_file),
FmtString(StringFromList(perm, cp.flags_msvc, Lit(" "))),
FmtString(StringFromList(perm, cp.linker_only_flags_msvc, Lit(" ")))
);
OS_CommandResult result = OS_RunCommand(perm, cmd);
Build.link.output = TrimWhitespace(result.output);
Build.link.return_code = result.code;

View File

@ -12,7 +12,8 @@ String W32_StringFromError(Arena *arena, DWORD err)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&msg_cstr,
0,
0);
0
);
if (len > 0)
{
result = PushString(arena, TrimWhitespace(StringFromCstr(msg_cstr, len)));

View File

@ -289,10 +289,12 @@ void P_MkDir(String path)
}
if (err.len > 0)
{
String msg = StringF(scratch.arena,
"Failed to create directory \"%F\": %F",
FmtString(path),
FmtString(err));
String msg = StringF(
scratch.arena,
"Failed to create directory \"%F\": %F",
FmtString(path),
FmtString(err)
);
Panic(msg);
}
EndScratch(scratch);

View File

@ -1072,7 +1072,8 @@ void V_TickForever(WaveLaneCtx *lane)
FmtUint(datetime.minute, .z = 2),
FmtUint(datetime.second, .z = 2),
FmtUint(datetime.milliseconds, .z = 3),
FmtString(text));
FmtString(text)
);
}
UI_PushCP(UI_NilKey);
{

View File

@ -1440,15 +1440,17 @@ void PP_UpdateUser(void)
"normal: (%F, %F)\n"
"num contacts: %F"
);
String text = StringF(temp.arena, fmt,
FmtUint(e0->key.idx),
FmtUint(e1->key.idx),
FmtHex(point.key),
FmtFloat(point.normal_impulse),
FmtFloat(point.tangent_impulse),
FmtFloatP(point.starting_separation, 6),
FmtFloatP(data->normal.x, 6), FmtFloatP(data->normal.y, 6),
FmtUint(data->num_points));
String text = StringF(
temp.arena, fmt,
FmtUint(e0->key.idx),
FmtUint(e1->key.idx),
FmtHex(point.key),
FmtFloat(point.normal_impulse),
FmtFloat(point.tangent_impulse),
FmtFloatP(point.starting_separation, 6),
FmtFloatP(data->normal.x, 6), FmtFloatP(data->normal.y, 6),
FmtUint(data->num_points)
);
draw_text(g->render_sig, disp_font, AddVec2(RoundVec2(MulXformV2(g->world_to_ui_xf, dbg_pt)), VEC2(0, offset_px)), text);
}
@ -1557,11 +1559,13 @@ void PP_UpdateUser(void)
"e1 pos: (%F, %F)\n"
"e1 rot: %F\n"
);
String text = StringF(temp.arena, fmt,
FmtFloatP(e0_xf.og.x, 24), FmtFloatP(e0_xf.og.y, 24),
FmtFloatP(RotationFromXform(e0_xf), 24),
FmtFloatP(e1_xf.og.x, 24), FmtFloatP(e1_xf.og.y, 24),
FmtFloatP(RotationFromXform(e1_xf), 24));
String text = StringF(
temp.arena, fmt,
FmtFloatP(e0_xf.og.x, 24), FmtFloatP(e0_xf.og.y, 24),
FmtFloatP(RotationFromXform(e0_xf), 24),
FmtFloatP(e1_xf.og.x, 24), FmtFloatP(e1_xf.og.y, 24),
FmtFloatP(RotationFromXform(e1_xf), 24)
);
draw_text(g->render_sig, disp_font, AddVec2(RoundVec2(MulXformV2(g->world_to_ui_xf, VEC2(0, 0))), VEC2(0, offset_px)), text);
}
@ -2261,15 +2265,17 @@ void PP_UpdateUser(void)
sig.sampler = GPU_SamplerStateRidFromResource(GPU_GetCommonPointSampler());
sig.instances = GPU_StructuredBufferRidFromResource(material_instances_buffer);
sig.grids = GPU_StructuredBufferRidFromResource(grids_buffer);
GPU_Rasterize(cl,
&sig,
PP_MaterialVS, PP_MaterialPS,
2,
viewport,
scissor,
material_instances_count,
GPU_GetCommonQuadIndices(),
GPU_RasterizeMode_TriangleList);
GPU_Rasterize(
cl,
&sig,
PP_MaterialVS, PP_MaterialPS,
2,
viewport,
scissor,
material_instances_count,
GPU_GetCommonQuadIndices(),
GPU_RasterizeMode_TriangleList
);
}
//- Prep flood pass
@ -2352,10 +2358,12 @@ void PP_UpdateUser(void)
sig.tex_width = g->render_size.x;
sig.tex_height = g->render_size.y;
sig.exposure = 2.0;
sig.frame_seed = VEC4U32((u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF),
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF),
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF),
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF));
sig.frame_seed = VEC4U32(
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF),
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF),
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF),
(u32)(RandU64FromState(&g->frame_rand) & 0xFFFFFFFF)
);
sig.frame_index = g->frame_index;
sig.camera_offset = g->world_to_render_xf.og;
sig.noise = GPU_Texture3DRidFromResource(GPU_GetCommonNoise());

View File

@ -103,7 +103,8 @@ UI_Box *PP_BuildDebugConsole(b32 minimized)
FmtUintZ(datetime.minute, 2),
FmtUintZ(datetime.second, 2),
FmtUintZ(datetime.milliseconds, 3),
FmtString(text));
FmtString(text)
);
}
UI_PushCP(0);
{

View File

@ -21,11 +21,13 @@ void PT_RunForever(WaveLaneCtx *lane)
{
/* Push resources */
Vec2I32 final_target_size = window_frame.draw_size;
G_ResourceHandle final_target = G_PushTexture2D(gpu_frame_arena,
G_Format_R16G16B16A16_Float,
final_target_size,
G_Layout_DirectQueue_ShaderReadWrite,
.flags = G_ResourceFlag_AllowShaderReadWrite);
G_ResourceHandle final_target = G_PushTexture2D(
gpu_frame_arena,
G_Format_R16G16B16A16_Float,
final_target_size,
G_Layout_DirectQueue_ShaderReadWrite,
.flags = G_ResourceFlag_AllowShaderReadWrite
);
/* Push resource handles */
G_Texture2DRef final_target_rhandle = G_PushTexture2DRef(gpu_frame_arena, final_target);
@ -54,12 +56,14 @@ void PT_RunForever(WaveLaneCtx *lane)
/* Blit pass */
{
G_Rasterize(cl,
PT_BlitVS, PT_BlitPS,
1, G_GetSharedQuadIndices(),
1, &window_frame.backbuffer,
G_ViewportFromTexture(window_frame.backbuffer), G_ScissorFromTexture(window_frame.backbuffer),
G_RasterMode_TriangleList);
G_Rasterize(
cl,
PT_BlitVS, PT_BlitPS,
1, G_GetSharedQuadIndices(),
1, &window_frame.backbuffer,
G_ViewportFromTexture(window_frame.backbuffer), G_ScissorFromTexture(window_frame.backbuffer),
G_RasterMode_TriangleList
);
}
/* Finalize backbuffer layout */

View File

@ -25,15 +25,17 @@ String SETTINGS_StringFromWindowSettings(Arena *arena, const P_WindowSettings *s
"}\n"
);
String formatted = FormatString(arena,
fmt,
FmtString(minimized),
FmtString(maximized),
FmtString(fullscreen),
FmtSint(x),
FmtSint(y),
FmtSint(width),
FmtSint(height));
String formatted = FormatString(
,
fmt,
FmtString(minimized),
FmtString(maximized),
FmtString(fullscreen),
FmtSint(x),
FmtSint(y),
FmtSint(width),
FmtSint(height)
);
return formatted;
}
@ -162,11 +164,13 @@ abort:
{
if (json_error.msg.len > 0)
{
*error_out = StringF(arena,
Lit("%F\n(%F:%F)"),
FmtString(json_error.msg),
FmtUint(json_error.start),
FmtUint(json_error.end));
*error_out = StringF(
arena,
Lit("%F\n(%F:%F)"),
FmtString(json_error.msg),
FmtUint(json_error.start),
FmtUint(json_error.end)
);
}
else
{

View File

@ -85,10 +85,12 @@ AC_Asset *SND_LoadAsset(ResourceKey resource, SND_SoundFlag flags, b32 wait)
/* Generate and append sound flags to name key */
String name = NameFromResource(resource);
String key = StringF(scratch.arena,
"%F%F_sound",
FmtString(name),
FmtUint((u64)flags));
String key = StringF(
scratch.arena,
"%F%F_sound",
FmtString(name),
FmtUint((u64)flags)
);
u64 hash = AC_HashFromKey(key);
b32 is_first_touch;
AC_Asset *asset = AC_TouchCache(key, hash, &is_first_touch);

View File

@ -24,20 +24,24 @@ JobImpl(SPR_LoadTexture, sig, _)
if (ok)
{
GPU_ArenaHandle gpu_perm = GPU_PermArena();
GPU_ResourceHandle gpu_resource = GPU_PushTexture2D(gpu_perm,
GPU_Format_R8G8B8A8_Unorm_Srgb,
VEC2I32(decoded.width, decoded.height),
GPU_Layout_AnyQueue_ShaderRead_CopyRead_CopyWrite_Present);
GPU_ResourceHandle gpu_resource = GPU_PushTexture2D(
gpu_perm,
GPU_Format_R8G8B8A8_Unorm_Srgb,
VEC2I32(decoded.width, decoded.height),
GPU_Layout_AnyQueue_ShaderRead_CopyRead_CopyWrite_Present
);
// texture->texture = gpu_tex;
texture->width = decoded.width;
texture->height = decoded.height;
GPU_CommandListHandle cl = GPU_PrepareCommandList();
{
GPU_ReadTexelsFromCpu(cl,
gpu_resource, VEC3I32(0,0,0),
decoded.pixels, VEC3I32(decoded.width, decoded.height, 1),
RNG3I32(VEC3I32(0,0,0), VEC3I32(decoded.width, decoded.height, 1)));
GPU_ReadTexelsFromCpu(
cl,
gpu_resource, VEC3I32(0,0,0),
decoded.pixels, VEC3I32(decoded.width, decoded.height, 1),
RNG3I32(VEC3I32(0,0,0), VEC3I32(decoded.width, decoded.height, 1))
);
}
GPU_CommitCommandList(cl, GPU_QueueKind_AsyncCopy);
}

View File

@ -1411,23 +1411,27 @@ void UI_EndFrame(UI_Frame *frame)
if (rects_count > 0)
{
/* Render rects */
G_Rasterize(frame->cl,
UI_DRectVS, UI_DRectPS,
rects_count, G_QuadIndices(),
1, &draw_target,
draw_viewport, draw_scissor,
G_RasterMode_TriangleList);
G_Rasterize(
frame->cl,
UI_DRectVS, UI_DRectPS,
rects_count, G_QuadIndices(),
1, &draw_target,
draw_viewport, draw_scissor,
G_RasterMode_TriangleList
);
/* Render rect wireframes */
if (AnyBit(frame->frame_flags, UI_FrameFlag_Debug))
{
G_SetConstant(frame->cl, UI_ShaderConst_DebugDraw, 1);
G_Rasterize(frame->cl,
UI_DRectVS, UI_DRectPS,
rects_count, G_QuadIndices(),
1, &draw_target,
draw_viewport, draw_scissor,
G_RasterMode_WireTriangleList);
G_Rasterize(
frame->cl,
UI_DRectVS, UI_DRectPS,
rects_count, G_QuadIndices(),
1, &draw_target,
draw_viewport, draw_scissor,
G_RasterMode_WireTriangleList
);
}
}
@ -1437,12 +1441,14 @@ void UI_EndFrame(UI_Frame *frame)
G_DumbMemoryLayoutSync(frame->cl, backbuffer, G_Layout_DirectQueue_RenderTargetWrite);
{
G_Rasterize(frame->cl,
UI_BlitVS, UI_BlitPS,
1, G_QuadIndices(),
1, &backbuffer,
monitor_viewport, monitor_scissor,
G_RasterMode_TriangleList);
G_Rasterize(
frame->cl,
UI_BlitVS, UI_BlitPS,
1, G_QuadIndices(),
1, &backbuffer,
monitor_viewport, monitor_scissor,
G_RasterMode_TriangleList
);
}
G_DumbMemoryLayoutSync(frame->cl, backbuffer, G_Layout_AnyQueue_ShaderRead_CopyRead_CopyWrite_Present);