diff --git a/src/base/integrator.cpp b/src/base/integrator.cpp index 3894fdab..1df4262e 100644 --- a/src/base/integrator.cpp +++ b/src/base/integrator.cpp @@ -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( @@ -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; diff --git a/src/base/pipeline.cpp b/src/base/pipeline.cpp index e39c764c..be2c2e82 100644 --- a/src/base/pipeline.cpp +++ b/src/base/pipeline.cpp @@ -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(device, 16_M)}, - _printer{luisa::make_unique(device)} {} + _general_buffer_arena{luisa::make_unique(device, 16_M)} {} Pipeline::~Pipeline() noexcept = default; @@ -46,7 +45,6 @@ luisa::unique_ptr Pipeline::create(Device &device, Stream &stream, con auto pipeline = luisa::make_unique(device); pipeline->_transform_matrices.resize(transform_matrix_buffer_size); pipeline->_transform_matrix_buffer = device.create_buffer(transform_matrix_buffer_size); - stream << pipeline->printer().reset(); auto initial_time = std::numeric_limits::max(); for (auto c : scene.cameras()) { if (c->shutter_span().x < initial_time) { diff --git a/src/base/pipeline.h b/src/base/pipeline.h index c1459b3c..bef34ad9 100644 --- a/src/base/pipeline.h +++ b/src/base/pipeline.h @@ -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; @@ -94,7 +93,6 @@ class Pipeline { Buffer _transform_matrix_buffer; luisa::unordered_map _named_ids; // other things - luisa::unique_ptr _printer; float _initial_time{}; bool _any_dynamic_transform{false}; bool _any_non_opaque_surface{false}; @@ -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 [[nodiscard]] auto buffer(I &&i) const noexcept { return _bindless_array->buffer(std::forward(i)); } diff --git a/src/compute b/src/compute index 1b31b9a2..56408d53 160000 --- a/src/compute +++ b/src/compute @@ -1 +1 @@ -Subproject commit 1b31b9a24b8ed7f3618b03faa07efa523e19a2d0 +Subproject commit 56408d53b641b998e372eca15a14c1b9c06e292e diff --git a/src/integrators/mega_vpt.cpp b/src/integrators/mega_vpt.cpp index eca385f1..ad941dfa 100644 --- a/src/integrators/mega_vpt.cpp +++ b/src/integrators/mega_vpt.cpp @@ -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); @@ -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()->rr_depth(); - auto medium_tracker = MediumTracker(pipeline().printer()); + MediumTracker medium_tracker; // functions auto le_zero = [](auto b) noexcept { return b <= 0.f; }; @@ -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(); @@ -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); @@ -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()) { @@ -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; @@ -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); }; @@ -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]; @@ -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]; @@ -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); @@ -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); } diff --git a/src/integrators/mega_vpt_naive.cpp b/src/integrators/mega_vpt_naive.cpp index 77feb73f..c8c17d45 100644 --- a/src/integrators/mega_vpt_naive.cpp +++ b/src/integrators/mega_vpt_naive.cpp @@ -2,6 +2,7 @@ // Created by ChenXin on 2023/3/30. // +#include #include #include #include @@ -159,7 +160,7 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra ray = it->spawn_ray_to(light_p); - pipeline().printer().verbose_with_location( + device_log( "transmittance: f=({}, {}, {}), pdf={}", transmittance.f[0u], transmittance.f[1u], transmittance.f[2u], transmittance.pdf); }; @@ -178,7 +179,7 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra SampledSpectrum beta{swl.dimension(), camera_weight}; SampledSpectrum Li{swl.dimension(), 0.f}; auto rr_depth = node()->rr_depth(); - auto medium_tracker = MediumTracker(pipeline().printer()); + MediumTracker medium_tracker; // Initialize RNG for sampling the majorant transmittance PCG32 rng(U64(as(sampler()->generate_2d()))); @@ -197,7 +198,7 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra auto it = pipeline().geometry()->intersect(ray); $if(!it->valid()) { $break; }; - pipeline().printer().verbose_with_location("depth={}", depth_track); + device_log("depth={}", depth_track); $if(it->shape().has_medium()) { auto surface_tag = it->shape().surface_tag(); @@ -212,40 +213,39 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra // 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()); + 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()); pipeline().printer().verbose(""); ray = it->spawn_ray(ray->direction()); depth_track += 1u; }; #endif - 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); @@ -261,14 +261,14 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra auto has_medium = it->shape().has_medium(); auto t_max = ite(it->valid(), length(it->p() - ray->origin()), Interaction::default_t_max); - pipeline().printer().verbose_with_location("depth={}", depth); - pipeline().printer().verbose_with_location("before: medium tracker size={}, priority={}, tag={}", + device_log("depth={}", depth); + 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( + device_log( "ray=({}, {}, {}) + t * ({}, {}, {})", ray->origin().x, ray->origin().y, ray->origin().z, ray->direction().x, ray->direction().y, ray->direction().z); - 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); auto medium_sample = Medium::Sample::zero(swl.dimension()); // sample the participating medium @@ -325,7 +325,7 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra $if(it->shape().has_light()) { auto eval = light_sampler()->evaluate_hit(*it, ray->origin(), swl, time); Li += beta * eval.L * balance_heuristic(pdf_bsdf, eval.pdf); - pipeline().printer().verbose_with_location( + device_log( "hit light: " "pdf_bsdf={}," "eval.pdf={}, " @@ -368,7 +368,7 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra auto closure = medium->closure(ray, swl, time); medium_priority = medium->priority(); eta_next = closure->eta(); - pipeline().printer().verbose_with_location("eta_next={}", eta_next); + device_log("eta_next={}", eta_next); }); }; auto medium_info = make_medium_info(medium_priority, medium_tag); @@ -409,7 +409,7 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra auto w = 1.f / (light_sample.eval.pdf + eval.pdf); Li += w * beta * eval.f * light_sample.eval.L; #endif - pipeline().printer().verbose_with_location( + device_log( "direct lighting: " "eval.f=({}, {}, {}), " "eval.pdf={}, " @@ -456,13 +456,13 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra }; }; - pipeline().printer().verbose_with_location( + device_log( "surface event={}, priority={}, tag={}", surface_event, medium_priority, medium_tag); }); }; - pipeline().printer().verbose_with_location( + device_log( "medium event={}, beta=({}, {}, {}), pdf_bsdf={}, Li=({}, {}, {})", medium_sample.medium_event, beta[0u], beta[1u], beta[2u], pdf_bsdf, Li[0u], Li[1u], Li[2u]); @@ -476,10 +476,9 @@ class MegakernelVolumePathTracingNaiveInstance final : public ProgressiveIntegra beta *= ite(q < rr_threshold, 1.0f / q, 1.f); }; - pipeline().printer().verbose_with_location("beta=({}, {}, {})", beta[0u], beta[1u], beta[2u]); - pipeline().printer().verbose_with_location("after: medium tracker size={}, priority={}, tag={}", + device_log("beta=({}, {}, {})", beta[0u], beta[1u], beta[2u]); + 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); } diff --git a/src/integrators/megapm.cpp b/src/integrators/megapm.cpp index 08821129..bd7df358 100644 --- a/src/integrators/megapm.cpp +++ b/src/integrators/megapm.cpp @@ -393,7 +393,6 @@ class MegakernelPhotonMappingInstance final : public ProgressiveIntegrator::Inst //TODO: use sampler right uint add_x = (photon_per_iter + resolution.y - 1) / resolution.y; sampler()->reset(command_buffer, make_uint2(resolution.x + add_x, resolution.y), pixel_count + add_x * resolution.y, spp); - command_buffer << pipeline().printer().reset(); command_buffer << compute::synchronize(); LUISA_INFO( "Rendering to '{}' of resolution {}x{} at {}spp.", @@ -533,13 +532,11 @@ class MegakernelPhotonMappingInstance final : public ProgressiveIntegrator::Inst command_buffer << [&progress, p] { progress.update(p); }; } } - command_buffer << pipeline().printer().retrieve(); } LUISA_INFO("total spp:{}", runtime_spp); //tot_photon is photon_per_iter not photon_per_iter*spp because of unnormalized samples command_buffer << indirect_draw(node()->photon_per_iter(), runtime_spp).dispatch(resolution); command_buffer << synchronize(); - command_buffer << pipeline().printer().retrieve(); progress.done(); diff --git a/src/integrators/megawave.cpp b/src/integrators/megawave.cpp index a0eb64c5..e07de707 100644 --- a/src/integrators/megawave.cpp +++ b/src/integrators/megawave.cpp @@ -773,12 +773,14 @@ void MegakernelWaveFrontInstance::_render_one_camera( }; sync_block(); }; +#ifndef NDEBUG $if(count == count_limit) { - pipeline().printer().info("block_id{},thread_id {}, loop not break! local:{}, global:{}",block_x(),thread_x(), rem_local[0], rem_global[0]); + device_log("block_id{},thread_id {}, loop not break! local:{}, global:{}",block_x(),thread_x(), rem_local[0], rem_global[0]); $if(thread_x() < (uint)KERNEL_COUNT){ - pipeline().printer().info("work rem: id {}, size {}", thread_x(), work_counter[thread_x()]); + device_log("work rem: id {}, size {}", thread_x(), work_counter[thread_x()]); }; }; +#endif }); auto clear_global_shader = compile_async<1>(device, [&]() noexcept { auto dispatch_id = dispatch_x(); @@ -815,7 +817,6 @@ void MegakernelWaveFrontInstance::_render_one_camera( << commit(); LUISA_ASSERT(launch_size % render_shader.get().block_size().x == 0u, ""); command_buffer << render_shader.get()(sample_count, host_sample_count, shutter_spp, time, s.point.weight).dispatch(launch_size); - command_buffer << pipeline().printer().retrieve(); command_buffer << synchronize(); shutter_spp += s.spp; } diff --git a/src/media/homogeneous.cpp b/src/media/homogeneous.cpp index c9e9326d..d17f882c 100644 --- a/src/media/homogeneous.cpp +++ b/src/media/homogeneous.cpp @@ -55,7 +55,6 @@ class HomogeneousMedium : public Medium { auto channel = sample_discrete(pdf_channels, rng.uniform_float()); auto u = rng.uniform_float(); auto t = -log(max(1.f - u, std::numeric_limits::min())) / sigma_t()[channel]; - instance()->pipeline().printer().verbose_with_location("HomogeneousMediumClosure::sample: u={}, t={}", u, t); // hit surface $if(t > t_max) { @@ -95,7 +94,7 @@ class HomogeneousMedium : public Medium { sample_ans.eval.f = Tr * sigma_s(); sample_ans.eval.pdf = pdf.sum(); - instance()->pipeline().printer().verbose_with_location( + compute::device_log( "HomogeneousMediumClosure::sample::scatter\n" "t={}, Tr=({}, {}, {}), \n" "pdf_channels=({}, {}, {}), \n" diff --git a/src/util/medium_tracker.cpp b/src/util/medium_tracker.cpp index ca544d5f..d54106df 100644 --- a/src/util/medium_tracker.cpp +++ b/src/util/medium_tracker.cpp @@ -9,7 +9,11 @@ namespace luisa::render { using namespace luisa::compute; -MediumTracker::MediumTracker(Printer &printer) noexcept : _size{0u}, _printer{printer} { +Bool equal(Expr a, Expr b) noexcept { + return a.medium_tag == b.medium_tag; +} + +MediumTracker::MediumTracker() noexcept : _size{0u} { for (auto i = 0u; i < capacity; i++) { _priority_list[i] = Medium::VACUUM_PRIORITY; _medium_list[i] = make_medium_info(Medium::VACUUM_PRIORITY, Medium::INVALID_TAG); @@ -22,8 +26,8 @@ Bool MediumTracker::true_hit(Expr priority) const noexcept { void MediumTracker::enter(Expr priority, Expr value) noexcept { $if(_size == capacity) { - printer().error_with_location( - "Medium stack overflow when trying to enter priority={}, medium_tag={}", + device_log( + "[error] Medium stack overflow when trying to enter priority={}, medium_tag={}", priority, value.medium_tag); } $else { @@ -46,7 +50,7 @@ void MediumTracker::exit(Expr priority, Expr value) noexcept { auto remove_num = def(0u); for (auto i = 0u; i < capacity - 1u; i++) { auto p = _priority_list[i]; - auto should_remove = (p == priority) & _medium_list[i]->equal(value) & (remove_num == 0u); + auto should_remove = (p == priority) & equal(_medium_list[i], value) & (remove_num == 0u); remove_num += ite(should_remove, 1u, 0u); _priority_list[i] = _priority_list[i + remove_num]; _medium_list[i] = _medium_list[i + remove_num]; @@ -57,8 +61,8 @@ void MediumTracker::exit(Expr priority, Expr value) noexcept { _medium_list[_size] = make_medium_info(Medium::VACUUM_PRIORITY, Medium::INVALID_TAG); } $else { - printer().error_with_location( - "Medium stack trying to exit nonexistent priority={}, medium_tag={}", + device_log( + "[error] Medium stack trying to exit nonexistent priority={}, medium_tag={}", priority, value.medium_tag); }; } @@ -67,7 +71,7 @@ Bool MediumTracker::exist(Expr priority, Expr value) noexcept auto exist = def(false); for (auto i = 0u; i < capacity - 1u; i++) { auto p = _priority_list[i]; - exist |= (p == priority) & _medium_list[i]->equal(value); + exist |= (p == priority) & equal(_medium_list[i], value); } return exist; } diff --git a/src/util/medium_tracker.h b/src/util/medium_tracker.h index fd401591..4e5a5630 100644 --- a/src/util/medium_tracker.h +++ b/src/util/medium_tracker.h @@ -15,7 +15,6 @@ using compute::ArrayVar; using compute::Bool; using compute::Expr; using compute::Float4; -using compute::Printer; using compute::UInt; using compute::Var; @@ -35,16 +34,11 @@ class MediumTracker { ArrayVar _priority_list; ArrayVar _medium_list; UInt _size; - Printer &_printer; public: - explicit MediumTracker(Printer &printer) noexcept; + explicit MediumTracker() noexcept; MediumTracker(const MediumTracker &) = default; -protected: - [[nodiscard]] auto &printer() noexcept { return _printer; } - [[nodiscard]] const auto &printer() const noexcept { return _printer; } - public: [[nodiscard]] Var current() const noexcept; [[nodiscard]] Bool vacuum() const noexcept;