Skip to content

Commit

Permalink
Pull code out into FinalizeOccupancyMasksFromNoiseValues
Browse files Browse the repository at this point in the history
  • Loading branch information
scallyw4g committed Oct 18, 2024
1 parent ed64aca commit a126cff
Show file tree
Hide file tree
Showing 35 changed files with 242 additions and 182 deletions.
2 changes: 1 addition & 1 deletion generated/asyncify_render_function_c_DrawLod.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/work_queue.h:307:0
// src/engine/work_queue.h:313:0

link_internal void
DrawLod_Async(work_queue *Queue,engine_resources *Engine ,shader *Shader ,lod_element_buffer *Meshes ,r32 DistanceSquared ,v3 Basis ,Quaternion Rotation ,v3 Scale )
Expand Down
2 changes: 1 addition & 1 deletion generated/asyncify_render_function_c_RenderToTexture.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/work_queue.h:304:0
// src/engine/work_queue.h:310:0

link_internal void
RenderToTexture_Async(work_queue *Queue,engine_resources *Engine ,asset_thumbnail *Thumb ,lod_element_buffer *Meshes ,v3 Offset ,camera *Camera )
Expand Down
2 changes: 1 addition & 1 deletion generated/asyncify_render_function_h_DrawLod.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/work_queue.h:163:0
// src/engine/work_queue.h:168:0

struct draw_lod_async_params poof(@async_function_params)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/asyncify_render_function_h_RenderToTexture.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/work_queue.h:160:0
// src/engine/work_queue.h:165:0

struct render_to_texture_async_params poof(@async_function_params)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/render_command.h:160:0
// src/engine/render_command.h:168:0


link_internal work_queue_entry__bonsai_render_command
Expand Down Expand Up @@ -166,6 +166,19 @@ WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_draw_all_entities A )



};
return Result;
}

link_internal work_queue_entry__bonsai_render_command
WorkQueueEntryBonsaiRenderCommand( bonsai_render_command_initialize_noise_buffer A )
{
work_queue_entry__bonsai_render_command Result = {
.Type = type_bonsai_render_command_initialize_noise_buffer,
.bonsai_render_command_initialize_noise_buffer = A,



};
return Result;
}
Expand Down Expand Up @@ -387,6 +400,19 @@ BonsaiRenderCommandDrawAllEntities( shader* Shader )
return Reuslt;
}

link_internal bonsai_render_command_initialize_noise_buffer
BonsaiRenderCommandInitializeNoiseBuffer( v3 ChunkSize , f32* NoiseData )
{
bonsai_render_command_initialize_noise_buffer Reuslt = {
.ChunkSize = ChunkSize
,
.NoiseData = NoiseData
};


return Reuslt;
}

link_internal bonsai_render_command_gl_timer_init
BonsaiRenderCommandGlTimerInit( u32* GlTimerObject )
{
Expand Down
4 changes: 3 additions & 1 deletion generated/d_union_bonsai_render_command.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/render_command.h:128:0
// src/engine/render_command.h:134:0

enum work_queue_entry__bonsai_render_command_type
{
Expand All @@ -16,6 +16,7 @@ enum work_queue_entry__bonsai_render_command_type
type_bonsai_render_command_set_shader_uniform,
type_bonsai_render_command_draw_world_chunk_draw_list,
type_bonsai_render_command_draw_all_entities,
type_bonsai_render_command_initialize_noise_buffer,
type_bonsai_render_command_gl_timer_init,
type_bonsai_render_command_gl_timer_start,
type_bonsai_render_command_gl_timer_end,
Expand All @@ -41,6 +42,7 @@ struct work_queue_entry__bonsai_render_command
struct bonsai_render_command_set_shader_uniform bonsai_render_command_set_shader_uniform;
struct bonsai_render_command_draw_world_chunk_draw_list bonsai_render_command_draw_world_chunk_draw_list;
struct bonsai_render_command_draw_all_entities bonsai_render_command_draw_all_entities;
struct bonsai_render_command_initialize_noise_buffer bonsai_render_command_initialize_noise_buffer;
struct bonsai_render_command_gl_timer_init bonsai_render_command_gl_timer_init;
struct bonsai_render_command_gl_timer_start bonsai_render_command_gl_timer_start;
struct bonsai_render_command_gl_timer_end bonsai_render_command_gl_timer_end;
Expand Down
15 changes: 14 additions & 1 deletion generated/d_union_constructors_work_queue_entry.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/work_queue.h:248:0
// src/engine/work_queue.h:254:0


link_internal work_queue_entry
Expand All @@ -10,6 +10,19 @@ WorkQueueEntry( work_queue_entry_init_world_chunk A )



};
return Result;
}

link_internal work_queue_entry
WorkQueueEntry( work_queue_entry_build_chunk_mesh A )
{
work_queue_entry Result = {
.Type = type_work_queue_entry_build_chunk_mesh,
.work_queue_entry_build_chunk_mesh = A,



};
return Result;
}
Expand Down
4 changes: 3 additions & 1 deletion generated/d_union_work_queue_entry.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// src/engine/work_queue.h:220:0
// src/engine/work_queue.h:225:0

enum work_queue_entry_type
{
type_work_queue_entry_noop,
type_work_queue_entry_init_world_chunk,
type_work_queue_entry_build_chunk_mesh,
type_work_queue_entry_copy_buffer_set,
type_work_queue_entry_copy_buffer_ref,
type_work_queue_entry_init_asset,
Expand All @@ -22,6 +23,7 @@ struct work_queue_entry
union
{
struct work_queue_entry_init_world_chunk work_queue_entry_init_world_chunk;
struct work_queue_entry_build_chunk_mesh work_queue_entry_build_chunk_mesh;
struct work_queue_entry_copy_buffer_set work_queue_entry_copy_buffer_set;
struct work_queue_entry_copy_buffer_ref work_queue_entry_copy_buffer_ref;
struct work_queue_entry_init_asset work_queue_entry_init_asset;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:568:0
// src/engine/world_update.cpp:569:0

random_series ColorEntropy = {4654376543246};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:823:0
// src/engine/world_update.cpp:824:0

random_series ColorEntropy = {4654376543246};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:805:0
// src/engine/world_update.cpp:806:0

random_series ColorEntropy = {4654376543246};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:678:0
// src/engine/world_update.cpp:679:0

random_series ColorEntropy = {4654376543246};

Expand Down
4 changes: 3 additions & 1 deletion generated/for_datatypes_0XxWqGSZ.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// src/engine/work_queue.h:280:0
// src/engine/work_queue.h:286:0




Expand Down Expand Up @@ -657,6 +658,7 @@ WorkQueueEntryAsyncFunction( render_to_texture_async_params *Params )






struct draw_lod_async_params;
Expand Down
4 changes: 3 additions & 1 deletion generated/for_datatypes_fkubhsYl.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// src/engine/work_queue.h:203:0
// src/engine/work_queue.h:208:0




Expand Down Expand Up @@ -647,6 +648,7 @@ render_to_texture_async_params render_to_texture_async_params;






draw_lod_async_params draw_lod_async_params;
Expand Down
4 changes: 3 additions & 1 deletion generated/for_datatypes_kv3WBTai.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// src/engine/work_queue.h:184:0
// src/engine/work_queue.h:189:0




Expand Down Expand Up @@ -647,6 +648,7 @@ type_render_to_texture_async_params,






type_draw_lod_async_params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ PushBonsaiRenderCommandDrawAllEntities(
PushWorkQueueEntry(RenderQueue, &Work);
}
link_internal void
PushBonsaiRenderCommandInitializeNoiseBuffer(
work_queue *RenderQueue
, v3 ChunkSize , f32* NoiseData
)
{
work_queue_entry Work = WorkQueueEntry(
WorkQueueEntryBonsaiRenderCommand( BonsaiRenderCommandInitializeNoiseBuffer( ChunkSize , NoiseData )));

PushWorkQueueEntry(RenderQueue, &Work);
}
link_internal void
PushBonsaiRenderCommandGlTimerInit(
work_queue *RenderQueue
, u32* GlTimerObject
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_398799212.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:526:0
// src/engine/world_update.cpp:527:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_416827956.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:709:0
// src/engine/world_update.cpp:710:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_428632106.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:868:0
// src/engine/world_update.cpp:869:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_530902269.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:652:0
// src/engine/world_update.cpp:653:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_583358156.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:841:0
// src/engine/world_update.cpp:842:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_631222419.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:751:0
// src/engine/world_update.cpp:752:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_643608995.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:631:0
// src/engine/world_update.cpp:632:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_812652930.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:603:0
// src/engine/world_update.cpp:604:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_920026661.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:547:0
// src/engine/world_update.cpp:548:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_992879728.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:773:0
// src/engine/world_update.cpp:774:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
2 changes: 1 addition & 1 deletion generated/rectalinear_iteration_pattern_99934950.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// src/engine/world_update.cpp:717:0
// src/engine/world_update.cpp:718:0

DimIterator(x, y, z, UpdateDim)
{
Expand Down
4 changes: 4 additions & 0 deletions src/engine/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ WorkerThread_ApplicationDefaultImplementation(BONSAI_API_WORKER_THREAD_CALLBACK_
SimulateParticleSystem(Job);
} break;

case type_work_queue_entry_build_chunk_mesh:
{
} break;

case type_work_queue_entry_rebuild_mesh:
{
work_queue_entry_rebuild_mesh *Job = SafeAccess(work_queue_entry_rebuild_mesh, Entry);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ poof( @vert_source_file("external/bonsai_stdlib/shaders/Passthrough.vertexshader
shader_uniform Uniforms[1];
texture ChunkData;

v3 ChunkSize; poof(@uniform)
v3 ChunkSize; poof(@uniform)
};

poof(shader_magic(gradient_noise_shader))
Expand Down
8 changes: 8 additions & 0 deletions src/engine/render_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ struct bonsai_render_command_do_stuff
u32 Ignored = 0;
};

struct bonsai_render_command_initialize_noise_buffer
{
v3 ChunkSize; // TODO(Jesse): Make this v3i
f32 *NoiseData;
};

struct bonsai_render_command_gl_timer_init
{
u32 *GlTimerObject;
Expand Down Expand Up @@ -149,6 +155,8 @@ poof(
bonsai_render_command_draw_world_chunk_draw_list
bonsai_render_command_draw_all_entities

bonsai_render_command_initialize_noise_buffer

bonsai_render_command_gl_timer_init
bonsai_render_command_gl_timer_start
bonsai_render_command_gl_timer_end
Expand Down
26 changes: 19 additions & 7 deletions src/engine/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ RenderLoop(thread_startup_params *ThreadParams, engine_resources *Engine)
case type_work_queue_entry_init_asset:
case type_work_queue_entry_update_world_region:
case type_work_queue_entry_rebuild_mesh:
case type_work_queue_entry_build_chunk_mesh:
case type_work_queue_entry_sim_particle_system:
case type_work_queue_entry__align_to_cache_line_helper:
{
Expand Down Expand Up @@ -221,6 +222,24 @@ RenderLoop(thread_startup_params *ThreadParams, engine_resources *Engine)
} break;


{ tmatch(bonsai_render_command_initialize_noise_buffer, RC, Command)

auto *Shader = &Graphics->GpuNoise.GradientShader;
Assert(Command->ChunkSize == Shader->ChunkSize);

GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->GpuNoise.FBO.ID);

v2i ViewportSize = V2i(s32(Command->ChunkSize.x), s32(Command->ChunkSize.y*Command->ChunkSize.z));
SetViewport(ViewportSize);
UseShader(Shader);
RenderQuad();

GL.GetTexImage(GL_TEXTURE_2D, 0, GL_RED, GL_FLOAT, Command->NoiseData);

auto E = WorkQueueEntry(WorkQueueEntryBuildChunkMesh(Command->ChunkSize, Command->NoiseData));
PushWorkQueueEntry(&Plat->LowPriority, &E);
} break;


{ tmatch(bonsai_render_command_do_stuff, RC, Command)

Expand Down Expand Up @@ -297,13 +316,6 @@ RenderLoop(thread_startup_params *ThreadParams, engine_resources *Engine)

UiFrameEnd(&Engine->Ui);

{
GL.BindFramebuffer(GL_FRAMEBUFFER, Graphics->GpuNoise.FBO.ID);
SetViewport(V2i(64, 4096));
UseShader( &Graphics->GpuNoise.GradientShader );
RenderQuad();
}


BonsaiSwapBuffers(&Engine->Stdlib.Os);

Expand Down
Loading

0 comments on commit a126cff

Please sign in to comment.