work improving world draw perf
This commit is contained in:
parent
94bbdb8427
commit
d00885a73b
@ -646,14 +646,15 @@ create_level_editor_preview_tasks :: () {
|
|||||||
name, orientation, found := get_trile_at(*curworld.world, xx px, xx py, xx pz);
|
name, orientation, found := get_trile_at(*curworld.world, xx px, xx py, xx pz);
|
||||||
cursor_trile := ifx found then name else (ifx editor_current_trile then editor_current_trile.name else "");
|
cursor_trile := ifx found then name else (ifx editor_current_trile then editor_current_trile.name else "");
|
||||||
if cursor_trile != "" {
|
if cursor_trile != "" {
|
||||||
positions: [..]Vector4;
|
positions: [..]Trile_Instance;
|
||||||
positions.allocator = temp;
|
positions.allocator = temp;
|
||||||
array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, cast(float)orientation});
|
array_add(*positions, Trile_Instance.{xx (px % 32), xx (py % 32), xx (pz % 32), xx orientation});
|
||||||
task: Rendering_Task_Trile;
|
task: Rendering_Task_Trile;
|
||||||
task.trile = cursor_trile;
|
task.trile = cursor_trile;
|
||||||
task.positions = positions;
|
task.positions = positions;
|
||||||
task.worldConf = *curworld.world.conf;
|
task.worldConf = *curworld.world.conf;
|
||||||
task.preview_mode = 1;
|
task.preview_mode = 1;
|
||||||
|
task.chunk_key = world_to_chunk_coord(xx px, xx py, xx pz);
|
||||||
add_rendering_task(task);
|
add_rendering_task(task);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -688,7 +689,7 @@ create_level_editor_preview_tasks :: () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, ori});
|
// array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, ori});
|
||||||
}
|
}
|
||||||
} else if current_tool_mode == .LINE {
|
} else if current_tool_mode == .LINE {
|
||||||
if line_active {
|
if line_active {
|
||||||
@ -710,7 +711,7 @@ create_level_editor_preview_tasks :: () {
|
|||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, ori});
|
// array_add(*positions, .{cast(float)px, cast(float)py, cast(float)pz, ori});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +722,7 @@ create_level_editor_preview_tasks :: () {
|
|||||||
|
|
||||||
task: Rendering_Task_Trile;
|
task: Rendering_Task_Trile;
|
||||||
task.trile = editor_current_trile.name;
|
task.trile = editor_current_trile.name;
|
||||||
task.positions = positions;
|
// task.positions = positions;
|
||||||
task.worldConf = *curworld.world.conf;
|
task.worldConf = *curworld.world.conf;
|
||||||
task.preview_mode = ifx is_delete then cast(s32)2 else cast(s32)1;
|
task.preview_mode = ifx is_delete then cast(s32)2 else cast(s32)1;
|
||||||
add_rendering_task(task);
|
add_rendering_task(task);
|
||||||
|
|||||||
@ -47,7 +47,8 @@ Render_Command_Set_Light :: struct {
|
|||||||
Render_Command_Add_Trile_Positions :: struct {
|
Render_Command_Add_Trile_Positions :: struct {
|
||||||
#as using c : Render_Command;
|
#as using c : Render_Command;
|
||||||
c.type = .ADD_TRILE_POSITIONS;
|
c.type = .ADD_TRILE_POSITIONS;
|
||||||
positions : []Vector4;
|
positions : []Trile_Instance;
|
||||||
|
chunk : Chunk_Key;
|
||||||
}
|
}
|
||||||
|
|
||||||
Render_Command_Draw_Trile_Positions :: struct {
|
Render_Command_Draw_Trile_Positions :: struct {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ backend_handle_command :: (cmd: *Render_Command) {
|
|||||||
if cmd.type == {
|
if cmd.type == {
|
||||||
case .ADD_TRILE_POSITIONS;
|
case .ADD_TRILE_POSITIONS;
|
||||||
add_command := cast(*Render_Command_Add_Trile_Positions)cmd;
|
add_command := cast(*Render_Command_Add_Trile_Positions)cmd;
|
||||||
backend_add_trile_positions(add_command.positions);
|
backend_add_trile_positions(add_command.positions, add_command.chunk);
|
||||||
case .DRAW_TRILE_POSITIONS;
|
case .DRAW_TRILE_POSITIONS;
|
||||||
draw_command := cast(*Render_Command_Draw_Trile_Positions)cmd;
|
draw_command := cast(*Render_Command_Draw_Trile_Positions)cmd;
|
||||||
backend_draw_trile_positions(draw_command.trile, draw_command.amount, draw_command.conf, draw_command.chunk_key, draw_command.preview_mode, draw_command.offset_index, draw_command.lod_index);
|
backend_draw_trile_positions(draw_command.trile, draw_command.amount, draw_command.conf, draw_command.chunk_key, draw_command.preview_mode, draw_command.offset_index, draw_command.lod_index);
|
||||||
@ -133,10 +133,26 @@ backend_draw_trixels :: (cmd: Render_Command_Draw_Trixels) {
|
|||||||
sg_draw(0, 36, count);
|
sg_draw(0, 36, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
backend_add_trile_positions :: (positions : []Vector4) {
|
// @Note: We store these as Trile_Instances in the loaded world,
|
||||||
|
// and we need to transform them to Vector4 at some point, and
|
||||||
|
// this seems like the most convinient place to do that without
|
||||||
|
// having to constantly allocate.
|
||||||
|
trile_position_staging : [..]Vector4;
|
||||||
|
|
||||||
|
backend_add_trile_positions :: (positions : []Trile_Instance, chunk: Chunk_Key) {
|
||||||
|
array_reset_keeping_memory(*trile_position_staging);
|
||||||
|
for position : positions {
|
||||||
|
array_add(*trile_position_staging, Vector4.{
|
||||||
|
cast(float)(position.x + chunk.x),
|
||||||
|
cast(float)(position.y + chunk.y),
|
||||||
|
cast(float)(position.z + chunk.z),
|
||||||
|
cast(float)(position.orientation)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
offset := sg_append_buffer(gPipelines.trile.bind.vertex_buffers[3], *(sg_range.{
|
offset := sg_append_buffer(gPipelines.trile.bind.vertex_buffers[3], *(sg_range.{
|
||||||
ptr = positions.data,
|
ptr = trile_position_staging.data,
|
||||||
size = size_of(Vector4) * cast(u64)positions.count,
|
size = size_of(Vector4) * cast(u64)trile_position_staging.count,
|
||||||
}));
|
}));
|
||||||
array_add(*trile_offsets, offset);
|
array_add(*trile_offsets, offset);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,14 +105,14 @@ create_world_rendering_tasks :: (world: *World, camera: Camera, plane_height: fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for group : chunk.group {
|
for group : chunk.groups {
|
||||||
task := Rendering_Task_Trile.{
|
task := Rendering_Task_Trile.{
|
||||||
trile = group.trile_name,
|
trile = group.trile_name,
|
||||||
chunk_key = chunk.coord,
|
chunk_key = chunk.coord,
|
||||||
positions = group.instances,
|
positions = group.instances,
|
||||||
worldConf = world.conf
|
worldConf = *world.conf
|
||||||
};
|
};
|
||||||
add_rendering_task(*task);
|
add_rendering_task(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,6 +152,7 @@ tasks_to_commands :: () {
|
|||||||
trileTask := (cast(*Rendering_Task_Trile)it);
|
trileTask := (cast(*Rendering_Task_Trile)it);
|
||||||
addPositionsCmd := New(Render_Command_Add_Trile_Positions,, temp);
|
addPositionsCmd := New(Render_Command_Add_Trile_Positions,, temp);
|
||||||
addPositionsCmd.positions = trileTask.positions;
|
addPositionsCmd.positions = trileTask.positions;
|
||||||
|
addPositionsCmd.chunk = trileTask.chunk_key;
|
||||||
array_add(*render_command_buckets.setup, addPositionsCmd);
|
array_add(*render_command_buckets.setup, addPositionsCmd);
|
||||||
drawPositionsCmd := New(Render_Command_Draw_Trile_Positions,, temp);
|
drawPositionsCmd := New(Render_Command_Draw_Trile_Positions,, temp);
|
||||||
drawPositionsCmd.trile = trileTask.trile;
|
drawPositionsCmd.trile = trileTask.trile;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user