diff options
author | quou <quou@disroot.org> | 2025-02-22 23:11:15 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-02-22 23:25:45 +1100 |
commit | ed5d6dfa2ed08c5a9185f3eb4ffb4deb898ed2af (patch) | |
tree | 29a6dc82b3ccd528c80978dbc5bd6ef8c925f231 /c2.cpp | |
parent | ab9ed1ccadbd2c1b971bfbfb5ee651aa03a4a63e (diff) |
move shadows to a fullscreen buffer
Diffstat (limited to 'c2.cpp')
-rw-r--r-- | c2.cpp | 71 |
1 files changed, 7 insertions, 64 deletions
@@ -162,61 +162,6 @@ struct Orbit_Cam { } }; -struct Fullscreen_Quad { - Buffer_Id vb; - - void init(Device* d) { - float verts[] = { - -1.0f, -1.0f, 0.0f, 0.0f, - -1.0f, 3.0f, 0.0f, 2.0f, - 3.0f, -1.0f, 2.0f, 0.0f - }; - Buffer_Id stage; - void* mem; - stage = d->create_buffer( - "sky vb stage", - sizeof verts, - Buffer_Flags::cpu_readwrite | - Buffer_Flags::copy_src - ); - mem = d->map_buffer(stage, 0, sizeof verts); - memcpy(mem, verts, sizeof verts); - d->unmap_buffer(stage); - vb = d->create_buffer( - "fullscreen quad", - sizeof verts, - Buffer_Flags::copy_dst | - Buffer_Flags::vertex_buffer - ); - Context& ctx = d->acquire(); - ctx.copy(vb, stage); - d->submit(ctx); - d->destroy_bufferi(stage); - } - - void destroy(Device* d) { - d->destroy_buffer(vb); - } - - void render( - Context& ctx, - Pipeline& pip, - Render_Pass& pass, - int bind - ) { - Vertex_Buffer_Binding vbb[] = {{ - .id = vb, - .offset = 0, - .target = bind - }, {}}; - Draw draw{}; - draw.verts = vbb; - draw.vertex_count = 3; - draw.instance_count = 1; - ctx.submit(draw, pip, pass); - } -}; - struct Sky { Staged_Buffer config; Texture_Id texture; @@ -647,7 +592,6 @@ struct C2 : public App { Lighting lighting; Camera_Id camera; Orbit_Cam orbit_cam; - Fullscreen_Quad quad; Sky sky; Env_Probe eprobe; Tonemap tonemap; @@ -703,7 +647,6 @@ struct C2 : public App { ui_shader = (Shader*)assets.load("ui.csh"); texture = (Texture*)assets.load("22.tex"); texture2 = (Texture*)assets.load("kita.tex"); - quad.init(dev); cbuf = dev->create_buffer( "config buffer", sizeof(Config_Buffer), @@ -715,7 +658,7 @@ struct C2 : public App { per_frame_memory_size ); clamped_linear = create_clamped_linear(dev); - renderer.init(arena, dev); + renderer.init(arena, dev, assets); world = (World*)arena_alloc(arena, sizeof *world); world->init(arena); ui = UI::create(this, &ui_arena); @@ -726,7 +669,7 @@ struct C2 : public App { ui->layout(w, h); fps_label = ui->create_element<UI::Label>(ui->root, ""); scene.init(&scene_arena, 32, clamped_linear); - lighting.init(dev); + lighting.init(dev, w, h); sky.init(dev, &assets); eprobe.init(dev, &assets, 256); tonemap.init(dev, &assets); @@ -884,7 +827,7 @@ struct C2 : public App { Render_Pass& tonemap_pass = pb.build_rp(); ctx.debug_push("environment cube"); - eprobe.render(dev, &frame_arena, quad, sky); + eprobe.render(dev, &frame_arena, renderer.quad, sky); ctx.debug_pop(); renderer.env_cubemap = eprobe.get_cubemap(); @@ -911,7 +854,7 @@ struct C2 : public App { sky.render( dev, &frame_arena, - quad, + renderer.quad, sky_pass, clamped_linear, pcam, @@ -925,7 +868,7 @@ struct C2 : public App { tonemap.render( dev, &frame_arena, - quad, + renderer.quad, tonemap_pass, hdr_target, clamped_linear @@ -959,7 +902,7 @@ struct C2 : public App { clamped_linear ); Pipeline& ui_pip = pb.build(); - quad.render( + renderer.quad.render( ctx, ui_pip, ui_pass, @@ -1001,7 +944,6 @@ struct C2 : public App { } void on_destroy() override { - quad.destroy(dev); scene.destroy(dev); sky.destroy(dev); lighting.destroy(dev, renderer); @@ -1030,6 +972,7 @@ struct C2 : public App { dev->destroy_buffer(ui_buffer); make_hdr_target(); make_ui_texture(); + lighting.recreate(dev, w, h); } void make_hdr_target() { |