From f0abfeb2f36ba78961eb312333d9b60a6c44d615 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 19:09:30 +0000 Subject: [PATCH 1/4] Initial plan From 127ca258bd1671c5d5195f41299b7d984d30c240 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 19:18:32 +0000 Subject: [PATCH 2/4] Fix serious logic errors in path-tracer-core and path-tracer-preprocessor Fixes: 1. Master resolution off-by-one: Added +1 to resolution calculation 2. Master bounds in preprocessor: Fixed max_x/max_y to use X-1/Y-1 3. ACCUMULATE stage routing: Changed from map_ray_stage_to_queue to m_batch_sender.enqueue_ray for master 4. Direct lighting results routing: Added proper owner check before routing (similar to object intersection results) 5. Batch sender flush: Removed early break to ensure final flush 6. Global resolution for NDC: Added image_width/image_height fields and global_resolution member for correct ray generation 7. Ray initialization: Added proper initialization for all cloud_ray fields Co-authored-by: vmanam0451 <25410102+vmanam0451@users.noreply.github.com> --- path-tracer-core/src/cloud/batch_sender.cpp | 5 ----- path-tracer-core/src/models/work_info.hpp | 5 ++++- path-tracer-core/src/processors/master/master.cpp | 2 +- .../src/processors/worker/intersection_worker.cpp | 10 +++++++++- .../src/processors/worker/shading_worker.cpp | 8 ++++---- path-tracer-core/src/processors/worker/worker.cpp | 10 ++++++++-- path-tracer-core/src/processors/worker/worker.hpp | 1 + path-tracer-preprocessor/preprocessor-function/app.py | 10 +++++++--- 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/path-tracer-core/src/cloud/batch_sender.cpp b/path-tracer-core/src/cloud/batch_sender.cpp index 8d39026..48ff19c 100644 --- a/path-tracer-core/src/cloud/batch_sender.cpp +++ b/path-tracer-core/src/cloud/batch_sender.cpp @@ -25,11 +25,6 @@ void batch_sender::flush_loop() std::unique_lock lock(m_mutex); m_cv.wait_for(lock, m_flush_interval, [this]() { return m_terminate.load(); }); - if (m_terminate) - { - break; - } - std::vector>> batches_to_send; for (auto &pair : m_pending_rays) { diff --git a/path-tracer-core/src/models/work_info.hpp b/path-tracer-core/src/models/work_info.hpp index e3fb024..9ac7e0b 100644 --- a/path-tracer-core/src/models/work_info.hpp +++ b/path-tracer-core/src/models/work_info.hpp @@ -32,8 +32,11 @@ struct worker_info float min_y; float max_x; float max_y; + int image_width; + int image_height; NLOHMANN_DEFINE_TYPE_INTRUSIVE(worker_info, scene_info, scene_bucket, scene_root, worker_id, sqs_queue_url, - sns_topic_arn, num_workers, samples, bounces, min_x, min_y, max_x, max_y) + sns_topic_arn, num_workers, samples, bounces, min_x, min_y, max_x, max_y, + image_width, image_height) }; } // namespace models \ No newline at end of file diff --git a/path-tracer-core/src/processors/master/master.cpp b/path-tracer-core/src/processors/master/master.cpp index 673cc1b..c7c47e0 100644 --- a/path-tracer-core/src/processors/master/master.cpp +++ b/path-tracer-core/src/processors/master/master.cpp @@ -20,7 +20,7 @@ master::~master() void master::run() { this->resolution = - math::uvec2((m_worker_info.max_x - m_worker_info.min_x), (m_worker_info.max_y - m_worker_info.min_y)); + math::uvec2((m_worker_info.max_x - m_worker_info.min_x) + 1, (m_worker_info.max_y - m_worker_info.min_y) + 1); this->sample_count = m_worker_info.samples; this->m_should_terminate = false; this->m_completed_rays = 0; diff --git a/path-tracer-core/src/processors/worker/intersection_worker.cpp b/path-tracer-core/src/processors/worker/intersection_worker.cpp index a31de37..365b369 100644 --- a/path-tracer-core/src/processors/worker/intersection_worker.cpp +++ b/path-tracer-core/src/processors/worker/intersection_worker.cpp @@ -219,7 +219,15 @@ void worker::process_direct_lighting_intersection_results() auto best_ray = results.second; best_ray.stage = models::ray_stage::SHADING; - map_ray_stage_to_queue(best_ray); + if (best_ray.worker_id == m_worker_info.worker_id) + { + map_ray_stage_to_queue(best_ray); + } + else + { + best_ray.type = models::ray_type::OWN; + m_batch_sender.enqueue_ray(best_ray, best_ray.worker_id); + } } } } diff --git a/path-tracer-core/src/processors/worker/shading_worker.cpp b/path-tracer-core/src/processors/worker/shading_worker.cpp index 03bf026..0229539 100644 --- a/path-tracer-core/src/processors/worker/shading_worker.cpp +++ b/path-tracer-core/src/processors/worker/shading_worker.cpp @@ -48,7 +48,7 @@ void worker::process_shading() alpha = transparent_background ? 0.0f : 1.0f; ray.stage = models::ray_stage::ACCUMULATE; - map_ray_stage_to_queue(ray); + m_batch_sender.enqueue_ray(ray, models::MASTER_ID); continue; } @@ -78,7 +78,7 @@ void worker::process_shading() if (math::dot(normal, outcoming) <= 0) { ray.stage = models::ray_stage::ACCUMULATE; - map_ray_stage_to_queue(ray); + m_batch_sender.enqueue_ray(ray, models::MASTER_ID); continue; } @@ -105,7 +105,7 @@ void worker::process_shading() ray.color = fvec3::zero; ray.alpha = 1; ray.stage = models::ray_stage::ACCUMULATE; - map_ray_stage_to_queue(ray); + m_batch_sender.enqueue_ray(ray, models::MASTER_ID); continue; } else @@ -199,7 +199,7 @@ void worker::process_shading() if (core::rand() > p) { ray.stage = models::ray_stage::ACCUMULATE; - map_ray_stage_to_queue(ray); + m_batch_sender.enqueue_ray(ray, models::MASTER_ID); continue; } throughput /= p; // Compensate for termination diff --git a/path-tracer-core/src/processors/worker/worker.cpp b/path-tracer-core/src/processors/worker/worker.cpp index 0d87de1..3700768 100644 --- a/path-tracer-core/src/processors/worker/worker.cpp +++ b/path-tracer-core/src/processors/worker/worker.cpp @@ -1,6 +1,7 @@ #include "worker.hpp" #include +#include #include #include #include @@ -39,6 +40,7 @@ void worker::run() m_should_terminate = false; this->resolution = fvec2((info.max_x - info.min_x) + 1, (info.max_y - info.min_y) + 1); + this->global_resolution = fvec2(info.image_width, info.image_height); this->sample_count = info.samples; this->bounce_count = info.bounces; @@ -131,9 +133,9 @@ void worker::generate_rays() aa_offset = fvec2(core::rand(), core::rand()); } - fvec2 ndc = ((fvec2(pixel) + aa_offset) / resolution) * 2 - fvec2::one; + fvec2 ndc = ((fvec2(pixel) + aa_offset) / fvec2(global_resolution)) * 2 - fvec2::one; ndc.y = -ndc.y; - float ratio = static_cast(resolution.x) / resolution.y; + float ratio = static_cast(global_resolution.x) / global_resolution.y; geometry::ray ray = m_scene.m_camera->get_component()->get_ray(ndc, ratio); @@ -145,6 +147,10 @@ void worker::generate_rays() cloud_ray.bounce = bounce_count; cloud_ray.stage = models::ray_stage::INTERSECT; cloud_ray.worker_id = m_worker_info.worker_id; + cloud_ray.object_intersect_distance = std::numeric_limits::max(); + cloud_ray.direct_light_intersect_result = false; + cloud_ray.alpha = 0.0f; + cloud_ray.type = models::ray_type::CALCULATE; map_ray_stage_to_queue(cloud_ray); } diff --git a/path-tracer-core/src/processors/worker/worker.hpp b/path-tracer-core/src/processors/worker/worker.hpp index 5a243de..7ffe907 100644 --- a/path-tracer-core/src/processors/worker/worker.hpp +++ b/path-tracer-core/src/processors/worker/worker.hpp @@ -25,6 +25,7 @@ class worker : public application public: math::uvec2 resolution = math::fvec2(640, 480); + math::uvec2 global_resolution = math::fvec2(640, 480); uint32_t sample_count = 50; math::fvec3 environment_factor = math::fvec3::one; bool transparent_background = false; diff --git a/path-tracer-preprocessor/preprocessor-function/app.py b/path-tracer-preprocessor/preprocessor-function/app.py index 465f4d4..3717d3c 100644 --- a/path-tracer-preprocessor/preprocessor-function/app.py +++ b/path-tracer-preprocessor/preprocessor-function/app.py @@ -218,7 +218,9 @@ def lambda_handler(event, context): "min_x": sub_grid[worker_id]["minX"], "max_x": sub_grid[worker_id]["maxX"], "min_y": sub_grid[worker_id]["minY"], - "max_y": sub_grid[worker_id]["maxY"] + "max_y": sub_grid[worker_id]["maxY"], + "image_width": X, + "image_height": Y } worker_infos[worker_id] = worker_info @@ -237,9 +239,11 @@ def lambda_handler(event, context): "samples": samples, "bounces": bounces, "min_x": 0, - "max_x": X, + "max_x": X - 1, "min_y": 0, - "max_y": Y + "max_y": Y - 1, + "image_width": X, + "image_height": Y } for worker_id, worker_info in worker_infos.items(): From 27e35f1af25bf988c5d39f1126c93bf59d3a9aac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 19:20:43 +0000 Subject: [PATCH 3/4] Fix type mismatch in uvec2 initialization (uvec2 should use uvec2, not fvec2) Co-authored-by: vmanam0451 <25410102+vmanam0451@users.noreply.github.com> --- _codeql_detected_source_root | 1 + path-tracer-core/src/processors/master/master.hpp | 2 +- path-tracer-core/src/processors/worker/worker.hpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000..5a1e124 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +./path-tracer-core \ No newline at end of file diff --git a/path-tracer-core/src/processors/master/master.hpp b/path-tracer-core/src/processors/master/master.hpp index 2a00eb9..c32544e 100644 --- a/path-tracer-core/src/processors/master/master.hpp +++ b/path-tracer-core/src/processors/master/master.hpp @@ -32,7 +32,7 @@ class master : public application private: models::worker_info m_worker_info; std::vector> pixels; - math::uvec2 resolution = math::fvec2(640, 480); + math::uvec2 resolution = math::uvec2(640, 480); bool transparent_background = false; uint32_t sample_count = 50; diff --git a/path-tracer-core/src/processors/worker/worker.hpp b/path-tracer-core/src/processors/worker/worker.hpp index 7ffe907..8f696ee 100644 --- a/path-tracer-core/src/processors/worker/worker.hpp +++ b/path-tracer-core/src/processors/worker/worker.hpp @@ -24,8 +24,8 @@ class worker : public application ~worker() override; public: - math::uvec2 resolution = math::fvec2(640, 480); - math::uvec2 global_resolution = math::fvec2(640, 480); + math::uvec2 resolution = math::uvec2(640, 480); + math::uvec2 global_resolution = math::uvec2(640, 480); uint32_t sample_count = 50; math::fvec3 environment_factor = math::fvec3::one; bool transparent_background = false; From 90024eb87501d66f00935923bda2b13ddb56e143 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 14 Jan 2026 19:21:06 +0000 Subject: [PATCH 4/4] Remove accidentally committed codeql symlink and add to gitignore Co-authored-by: vmanam0451 <25410102+vmanam0451@users.noreply.github.com> --- .gitignore | 2 +- _codeql_detected_source_root | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 120000 _codeql_detected_source_root diff --git a/.gitignore b/.gitignore index b7a882f..aa6ecba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ .aws-sam/ -.DS_Store \ No newline at end of file +.DS_Store_codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index 5a1e124..0000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -./path-tracer-core \ No newline at end of file