Skip to content

Commit

Permalink
remove the deprecated printer
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Apr 19, 2024
1 parent 814693d commit a919ecb
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 87 deletions.
4 changes: 0 additions & 4 deletions src/base/integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void ProgressiveIntegrator::Instance::_render_one_camera(

auto pixel_count = resolution.x * resolution.y;
sampler()->reset(command_buffer, resolution, pixel_count, spp);
command_buffer << pipeline().printer().reset();
command_buffer << compute::synchronize();

LUISA_INFO(
Expand Down Expand Up @@ -92,9 +91,6 @@ void ProgressiveIntegrator::Instance::_render_one_camera(
for (auto i = 0u; i < s.spp; i++) {
command_buffer << render(sample_id++, s.point.time, s.point.weight)
.dispatch(resolution);
if (auto &&p = pipeline().printer(); !p.empty()) {
command_buffer << p.retrieve();
}
dispatch_count++;
if (camera->film()->show(command_buffer)) { dispatch_count = 0u; }
auto dispatches_per_commit = 4u;
Expand Down
4 changes: 1 addition & 3 deletions src/base/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ namespace luisa::render {
inline Pipeline::Pipeline(Device &device) noexcept
: _device{device},
_bindless_array{device.create_bindless_array(bindless_array_capacity)},
_general_buffer_arena{luisa::make_unique<BufferArena>(device, 16_M)},
_printer{luisa::make_unique<compute::Printer>(device)} {}
_general_buffer_arena{luisa::make_unique<BufferArena>(device, 16_M)} {}

Pipeline::~Pipeline() noexcept = default;

Expand Down Expand Up @@ -46,7 +45,6 @@ luisa::unique_ptr<Pipeline> Pipeline::create(Device &device, Stream &stream, con
auto pipeline = luisa::make_unique<Pipeline>(device);
pipeline->_transform_matrices.resize(transform_matrix_buffer_size);
pipeline->_transform_matrix_buffer = device.create_buffer<float4x4>(transform_matrix_buffer_size);
stream << pipeline->printer().reset();
auto initial_time = std::numeric_limits<float>::max();
for (auto c : scene.cameras()) {
if (c->shutter_span().x < initial_time) {
Expand Down
4 changes: 0 additions & 4 deletions src/base/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ using compute::Image;
using compute::Mesh;
using compute::PixelStorage;
using compute::Polymorphic;
using compute::Printer;
using compute::Ray;
using compute::Resource;
using compute::Triangle;
Expand Down Expand Up @@ -94,7 +93,6 @@ class Pipeline {
Buffer<float4x4> _transform_matrix_buffer;
luisa::unordered_map<luisa::string, uint> _named_ids;
// other things
luisa::unique_ptr<Printer> _printer;
float _initial_time{};
bool _any_dynamic_transform{false};
bool _any_non_opaque_surface{false};
Expand Down Expand Up @@ -214,8 +212,6 @@ class Pipeline {
[[nodiscard]] const PhaseFunction::Instance *build_phasefunction(CommandBuffer &command_buffer, const PhaseFunction *phasefunction) noexcept;
bool update(CommandBuffer &command_buffer, float time) noexcept;
void render(Stream &stream) noexcept;
[[nodiscard]] auto &printer() noexcept { return *_printer; }
[[nodiscard]] auto &printer() const noexcept { return *_printer; }
[[nodiscard]] uint named_id(luisa::string_view name) const noexcept;
template<typename T, typename I>
[[nodiscard]] auto buffer(I &&i) const noexcept { return _bindless_array->buffer<T>(std::forward<I>(i)); }
Expand Down
51 changes: 24 additions & 27 deletions src/integrators/mega_vpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
wo_local = shading.world_to_local(wo);
wi_local = shading.world_to_local(wi);
};
pipeline().printer().verbose_with_location(
device_log(
"wo_local: ({}, {}, {}), wi_local: ({}, {}, {})",
wo_local.x, wo_local.y, wo_local.z,
wi_local.x, wi_local.y, wi_local.z);
Expand All @@ -96,7 +96,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
SampledSpectrum Li{swl.dimension(), 0.f};
SampledSpectrum r_u{swl.dimension(), 1.f}, r_l{swl.dimension(), 1.f};
auto rr_depth = node<MegakernelVolumePathTracing>()->rr_depth();
auto medium_tracker = MediumTracker(pipeline().printer());
MediumTracker medium_tracker;

// functions
auto le_zero = [](auto b) noexcept { return b <= 0.f; };
Expand All @@ -113,7 +113,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
auto it = pipeline().geometry()->intersect(ray);
$if(!it->valid()) { $break; };

pipeline().printer().verbose_with_location("depth={}", depth_track + 1u);
device_log("depth={}", depth_track + 1u);

$if(it->shape().has_medium()) {
auto surface_tag = it->shape().surface_tag();
Expand All @@ -128,39 +128,37 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
// deal with medium tracker
auto surface_event = event(swl, it, time, -ray->direction(), ray->direction());
pipeline().surfaces().dispatch(surface_tag, [&](auto surface) {
pipeline().printer().verbose_with_location("surface event={}", surface_event);
device_log("surface event={}", surface_event);
// update medium tracker
$switch(surface_event) {
$case(Surface::event_enter) {
medium_tracker.enter(medium_priority, medium_info);
pipeline().printer().verbose_with_location("enter: priority={}, medium_tag={}", medium_priority, medium_tag);
device_log("enter: priority={}, medium_tag={}", medium_priority, medium_tag);
};
$case(Surface::event_exit) {
$if(medium_tracker.exist(medium_priority, medium_info)) {
medium_tracker.exit(medium_priority, medium_info);
pipeline().printer().verbose_with_location("exit exist: priority={}, medium_tag={}", medium_priority, medium_tag);
device_log("exit exist: priority={}, medium_tag={}", medium_priority, medium_tag);
}
$else {
medium_tracker.enter(medium_priority, medium_info);
pipeline().printer().verbose_with_location("exit nonexistent: priority={}, medium_tag={}", medium_priority, medium_tag);
device_log("exit nonexistent: priority={}, medium_tag={}", medium_priority, medium_tag);
};
};
};
});
};
pipeline().printer().verbose_with_location("medium tracker size={}", medium_tracker.size());
device_log("medium tracker size={}", medium_tracker.size());
auto dir = ray->direction();
auto origin = ray->origin();
pipeline().printer().verbose_with_location("ray->origin()=({}, {}, {})", origin.x, origin.y, origin.z);
pipeline().printer().verbose_with_location("ray->direction()=({}, {}, {})", dir.x, dir.y, dir.z);
pipeline().printer().verbose_with_location("it->p()=({}, {}, {})", it->p().x, it->p().y, it->p().z);
pipeline().printer().verbose_with_location("it->shape().has_medium()={}", it->shape().has_medium());
pipeline().printer().verbose("");
device_log("ray->origin()=({}, {}, {})", origin.x, origin.y, origin.z);
device_log("ray->direction()=({}, {}, {})", dir.x, dir.y, dir.z);
device_log("it->p()=({}, {}, {})", it->p().x, it->p().y, it->p().z);
device_log("it->shape().has_medium()={}", it->shape().has_medium());
ray = it->spawn_ray(ray->direction());
depth_track += 1u;
};
pipeline().printer().verbose_with_location("Final medium tracker size={}", medium_tracker.size());
pipeline().printer().verbose("");
device_log("Final medium tracker size={}", medium_tracker.size());

ray = camera_ray;
auto pdf_bsdf = def(1e16f);
Expand All @@ -177,10 +175,10 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
auto it = pipeline().geometry()->intersect(ray);
auto has_medium = it->shape().has_medium();

pipeline().printer().verbose_with_location("depth={}", depth + 1u);
pipeline().printer().verbose_with_location("before: medium tracker size={}, priority={}, tag={}",
device_log("depth={}", depth + 1u);
device_log("before: medium tracker size={}, priority={}, tag={}",
medium_tracker.size(), medium_tracker.current().priority, medium_tracker.current().medium_tag);
pipeline().printer().verbose_with_location("it->p(): ({}, {}, {})", it->p().x, it->p().y, it->p().z);
device_log("it->p(): ({}, {}, {})", it->p().x, it->p().y, it->p().z);

// sample the participating medium
$if(!medium_tracker.vacuum()) {
Expand Down Expand Up @@ -239,13 +237,13 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
UInt medium_event = Medium::sample_event(pAbsorb, pScatter, pNull, um);
// don't use switch-case here, because of local variable definition
$if(medium_event == Medium::event_absorb) {
pipeline().printer().verbose_with_location("Absorb");
device_log("Absorb");
// Handle absorption along ray path
terminated = true;
ans = false;
}
$elif(medium_event == Medium::event_scatter) {
pipeline().printer().verbose_with_location("Scatter");
device_log("Scatter");
// Handle scattering along ray path
// Stop path sampling if maximum depth has been reached
depth += 1u;
Expand Down Expand Up @@ -351,7 +349,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
scattered = true;
auto p = closure_p->ray()->origin();
ray = make_ray(p, ps.wi);
pipeline().printer().verbose_with_location(
device_log(
"Medium scattering event at depth={}, p=({}, {}, {})",
depth, p.x, p.y, p.z);
};
Expand All @@ -360,7 +358,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
};
}
$elif(medium_event == Medium::event_null) {
pipeline().printer().verbose_with_location("Null");
device_log("Null");
// Handle null scattering along ray path
SampledSpectrum sigma_n = max(sigma_maj - closure_p->sigma_a() - closure_p->sigma_s(), 0.f);
Float pdf = T_maj[0u] * sigma_n[0u];
Expand All @@ -385,7 +383,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
$continue;
};

pipeline().printer().verbose_with_location(
device_log(
"T_maj=({}, {}, {})", T_maj[0u], T_maj[1u], T_maj[2u]);

beta *= T_maj / T_maj[0u];
Expand Down Expand Up @@ -457,7 +455,7 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
pipeline().media().dispatch(medium_tag, [&](auto medium) {
medium_priority = medium->priority();
auto closure = medium->closure(ray, swl, time);
pipeline().printer().verbose_with_location("eta={}", closure->eta());
device_log("eta={}", closure->eta());
});
};
auto medium_info = make_medium_info(medium_priority, medium_tag);
Expand Down Expand Up @@ -539,12 +537,11 @@ class MegakernelVolumePathTracingInstance final : public ProgressiveIntegrator::
};
depth += 1u;

pipeline().printer().verbose_with_location(
device_log(
"scattered={}, beta=({}, {}, {}), pdf_bsdf={}, Li: ({}, {}, {})",
scattered, beta[0u], beta[1u], beta[2u], pdf_bsdf, Li[0u], Li[1u], Li[2u]);
pipeline().printer().verbose_with_location("after: medium tracker size={}, priority={}, tag={}",
device_log("after: medium tracker size={}, priority={}, tag={}",
medium_tracker.size(), medium_tracker.current().priority, medium_tracker.current().medium_tag);
pipeline().printer().verbose("");
};
return spectrum->srgb(swl, Li);
}
Expand Down
Loading

0 comments on commit a919ecb

Please sign in to comment.