Skip to content

Commit

Permalink
Library updates and PGI Misc
Browse files Browse the repository at this point in the history
- added a compute pass to shade pgi hits
- moved to new vcpkg
- moved to new fastgltf
- moved to new daxa
- moved to new meshoptimizer
- new meshoptimizer must be used via master so its no longer a vcpkg but a submodule
- moved alpha test for cutout geo to much lower threshold
  • Loading branch information
Ipotrick committed Jan 27, 2025
1 parent f923133 commit 1683280
Show file tree
Hide file tree
Showing 16 changed files with 481 additions and 121 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "deps/daxa"]
path = deps/daxa
url = https://github.com/Ipotrick/Daxa.git
[submodule "deps/meshoptimizer"]
path = deps/meshoptimizer
url = https://github.com/zeux/meshoptimizer.git
22 changes: 18 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/deps/daxa/CMakeLists.txt")
COMMAND_ERROR_IS_FATAL ANY)
endif()

if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/deps/meshoptimizer/CMakeLists.txt")
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}"
COMMAND_ERROR_IS_FATAL ANY)
endif()

project(TimberDoodle)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin")
Expand All @@ -24,6 +31,9 @@ else()
COMMAND_ERROR_IS_FATAL ANY)
endif()

# include_directories(${PROJECT_SOURCE_DIR}/deps/meshoptimizer)
add_subdirectory(${PROJECT_SOURCE_DIR}/deps/meshoptimizer)

add_executable(${PROJECT_NAME}
"src/main.cpp"
"src/window.cpp"
Expand All @@ -45,15 +55,19 @@ find_package(fmt CONFIG REQUIRED)
find_package(daxa CONFIG REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
find_package(fastgltf CONFIG REQUIRED)
find_package(meshoptimizer CONFIG REQUIRED)
# find_package(meshoptimizer CONFIG REQUIRED)
find_package(freeimage CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(implot CONFIG REQUIRED)

# NOTE(grundlett): Really hacky. It appears there's no way to create plugin dll dependencies...
# see https://gitlab.kitware.com/cmake/cmake/-/issues/22993
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:slang::glslang> $<TARGET_FILE_DIR:${PROJECT_NAME}>

find_program(SLANG_DLL slang.dll)
find_program(SLANG_GLSLANG_DLL slang-glslang.dll)
add_custom_command(TARGET TimberDoodle POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SLANG_DLL} $<TARGET_FILE_DIR:TimberDoodle>
COMMAND ${CMAKE_COMMAND} -E copy ${SLANG_GLSLANG_DLL} $<TARGET_FILE_DIR:TimberDoodle>
)

# FreeImage links OpenEXR, which adds /EHsc for its targets, even if we're using Clang
Expand Down Expand Up @@ -86,7 +100,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
fmt::fmt
daxa::daxa
glfw
meshoptimizer::meshoptimizer
meshoptimizer
fastgltf::fastgltf
KTX::ktx
freeimage::FreeImage
Expand Down
2 changes: 1 addition & 1 deletion deps/daxa
Submodule daxa updated 41 files
+19 −11 CMakeLists.txt
+0 −6 cmake/packaging.cmake
+0 −187 cmake/vcpkg-overlay-ports/shader-slang/portfile.cmake
+0 −8 cmake/vcpkg-overlay-ports/shader-slang/vcpkg.json
+33 −33 include/daxa/c/device.h
+4 −4 include/daxa/command_recorder.hpp
+7 −6 include/daxa/device.hpp
+1 −0 include/daxa/gpu_resources.hpp
+2 −2 include/daxa/sync.hpp
+29 −6 include/daxa/types.hpp
+14 −12 include/daxa/utils/task_graph_types.hpp
+13 −10 src/cpp_wrapper.cpp
+0 −1 src/cpp_wrapper.hpp
+5 −3 src/impl_command_recorder.hpp
+7 −5 src/impl_core.cpp
+2 −1 src/impl_core.hpp
+37 −38 src/impl_device.cpp
+3 −3 src/impl_device.hpp
+19 −0 src/impl_features.cpp
+3 −2 src/impl_features.hpp
+3 −3 src/impl_gpu_resources.cpp
+5 −5 src/impl_gpu_resources.hpp
+3 −2 src/impl_instance.cpp
+11 −2 src/impl_pipeline.cpp
+7 −6 src/impl_swapchain.cpp
+4 −0 src/impl_timeline_query.cpp
+10 −10 src/utils/impl_imgui.cpp
+1 −1 src/utils/impl_pipeline_manager.cpp
+2 −0 src/utils/impl_pipeline_manager.hpp
+105 −90 src/utils/impl_task_graph.cpp
+22 −21 src/utils/impl_task_graph.hpp
+19 −13 src/utils/impl_task_graph_debug.hpp
+1 −0 tests/0_common/base_app.hpp
+0 −1 tests/2_daxa_api/3_command_recorder/main.cpp
+2 −2 tests/3_samples/1_mandelbrot/main.cpp
+10 −2 tests/3_samples/1_mandelbrot/shaders/shared.inl
+1 −0 tests/3_samples/2_mpm_mls/camera.h
+1 −1 tests/3_samples/3_hello_triangle_compute/shaders/compute.hlsl
+22 −22 tests/3_samples/5_boids/main.cpp
+15 −11 tests/CMakeLists.txt
+2 −4 vcpkg.json
1 change: 1 addition & 0 deletions deps/meshoptimizer
Submodule meshoptimizer added at 331f1c
46 changes: 46 additions & 0 deletions src/rendering/pgi/pgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,17 @@ auto pgi_trace_probe_lighting_pipeline_compile_info() -> daxa::RayTracingPipelin
};
}

auto pgi_shade_rays_pipeline_compile_info() -> daxa::ComputePipelineCompileInfo2
{
return daxa::ComputePipelineCompileInfo2{
.source = daxa::ShaderFile{"./src/rendering/pgi/pgi_trace_probe_lighting.hlsl"},
.entry_point = "entry_shade_rays",
.language = daxa::ShaderLanguage::SLANG,
.push_constant_size = s_cast<u32>(sizeof(PGIShadeRaysPush)),
.name = std::string{"entry_shade_rays"},
};
}

daxa::RasterPipelineCompileInfo pgi_draw_debug_probes_compile_info()
{
auto ret = daxa::RasterPipelineCompileInfo{};
Expand Down Expand Up @@ -1800,6 +1811,7 @@ void PGITraceProbeRaysTask::callback(daxa::TaskInterface ti)
ti.recorder.push_constant(push);

render_context->render_times.start_gpu_timer(ti.recorder, RenderTimes::PGI_TRACE_SHADE_RAYS);
// TODO(pahrens): remove non indirect version!
if (render_data.pgi_settings.enable_indirect_sparse)
{
ti.recorder.trace_rays_indirect({
Expand All @@ -1817,6 +1829,23 @@ void PGITraceProbeRaysTask::callback(daxa::TaskInterface ti)
render_context->render_times.end_gpu_timer(ti.recorder, RenderTimes::PGI_TRACE_SHADE_RAYS);
}

void PGIShadeRaysTask::callback(daxa::TaskInterface ti)
{
auto & gpu_context = render_context->gpu_context;
auto & render_data = render_context->render_data;
ti.recorder.set_pipeline(*gpu_context->compute_pipelines.at(pgi_shade_rays_pipeline_compile_info().name));

PGIShadeRaysPush push = {};
push.attach = ti.attachment_shader_blob;
push.scene = render_data.scene;
ti.recorder.push_constant(push);

ti.recorder.dispatch_indirect({
.indirect_buffer = ti.get(AT.probe_indirections).ids[0],
.offset = offsetof(PGIIndirections, probe_shade_rays_dispatch),
});
}

void PGIEvalScreenIrradianceTask::callback(daxa::TaskInterface ti)
{
auto & gpu_context = render_context->gpu_context;
Expand Down Expand Up @@ -2227,6 +2256,23 @@ auto task_pgi_all(TaskPGIAllInfo const & info) -> TaskPGIAllOut
},
.render_context = info.render_context,
.pgi_state = &info.pgi_state,
});
info.tg.add_task(PGIShadeRaysTask{
.views = std::array{
PGIShadeRaysTask::AT.globals | info.render_context->tgpu_render_data,
PGIShadeRaysTask::AT.probe_indirections | pgi_indirections,
PGIShadeRaysTask::AT.probe_radiance | info.pgi_state.probe_radiance_view,
PGIShadeRaysTask::AT.probe_visibility | info.pgi_state.probe_visibility_view,
PGIShadeRaysTask::AT.probe_info | info.pgi_state.probe_info_view,
PGIShadeRaysTask::AT.probe_requests | info.pgi_state.cell_requests_view,
PGIShadeRaysTask::AT.sky_transmittance | info.sky_transmittance,
PGIShadeRaysTask::AT.sky | info.sky,
PGIShadeRaysTask::AT.trace_result | pgi_trace_result,
PGIShadeRaysTask::AT.trace_gbuffer | trace_gbuffer,
PGIShadeRaysTask::AT.mesh_instances | info.mesh_instances,
},
.render_context = info.render_context,
.pgi_state = &info.pgi_state,
});
//info.tg.copy_image_to_image({info.pgi_state.probe_info_view, probe_info_copy, "copy over probe info prev frame"});
info.tg.add_task(PGIUpdateProbesTask{
Expand Down
12 changes: 10 additions & 2 deletions src/rendering/pgi/pgi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ auto pgi_update_probes_compile_info() -> daxa::ComputePipelineCompileInfo2;

auto pgi_trace_probe_lighting_pipeline_compile_info() -> daxa::RayTracingPipelineCompileInfo;

auto pgi_shade_rays_pipeline_compile_info() -> daxa::ComputePipelineCompileInfo2;

auto pgi_pre_update_probes_compute_compile_info() -> daxa::ComputePipelineCompileInfo2;

auto pgi_eval_screen_irradiance_compute_compile_info() -> daxa::ComputePipelineCompileInfo2;
Expand Down Expand Up @@ -75,8 +77,6 @@ struct PGIUpdateProbesTask : PGIUpdateProbesH::Task
void callback(daxa::TaskInterface ti);
};

// Traces one ray per probe texel.
// Results (color, depth) are written to the trace result texture.
struct PGITraceProbeRaysTask : PGITraceProbeLightingH::Task
{
AttachmentViews views = {};
Expand All @@ -85,6 +85,14 @@ struct PGITraceProbeRaysTask : PGITraceProbeLightingH::Task
void callback(daxa::TaskInterface ti);
};

struct PGIShadeRaysTask : PGIShadeRaysH::Task
{
AttachmentViews views = {};
RenderContext* render_context = {};
PGIState* pgi_state = {};
void callback(daxa::TaskInterface ti);
};

struct PGIPreUpdateProbesTask : PGIPreUpdateProbesH::Task
{
AttachmentViews views = {};
Expand Down
Loading

0 comments on commit 1683280

Please sign in to comment.