diff options
Diffstat (limited to 'src/3d/renderer.h')
| -rw-r--r-- | src/3d/renderer.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/3d/renderer.h b/src/3d/renderer.h index 8068bdc..db86b72 100644 --- a/src/3d/renderer.h +++ b/src/3d/renderer.h @@ -6,6 +6,7 @@ #include "3d/camera.h" #include "3d/scene.h" +#include "3d/bvh.h" #include "gpu/gpu.h" #include <vector> @@ -43,19 +44,12 @@ class Renderer3D { #endif // Renders the scene to the given texture view (Convenience: creates a pass) - void render(const Scene& scene, const Camera& camera, float time, - WGPUTextureView target_view, WGPUTextureView depth_view_opt = nullptr); // Records draw commands to an existing pass. - // Assumes the pass has a compatible pipeline (or we set it here). - - // Note: Caller must ensure depth/color attachments are set up correctly in - // the pass. - void draw(WGPURenderPassEncoder pass, const Scene& scene, const Camera& camera, float time); @@ -67,8 +61,12 @@ class Renderer3D { // Resize handler (if needed for internal buffers) void resize(int width, int height); + // Set whether to use BVH acceleration + void SetBvhEnabled(bool enabled) { bvh_enabled_ = enabled; } + private: void create_pipeline(); + WGPURenderPipeline create_pipeline_impl(bool use_bvh); void create_skybox_pipeline(); void create_default_resources(); void update_uniforms(const Scene& scene, const Camera& camera, float time); @@ -77,12 +75,17 @@ class Renderer3D { WGPUQueue queue_ = nullptr; WGPUTextureFormat format_ = WGPUTextureFormat_Undefined; - WGPURenderPipeline pipeline_ = nullptr; + WGPURenderPipeline pipeline_ = nullptr; // BVH enabled + WGPURenderPipeline pipeline_no_bvh_ = nullptr; // BVH disabled WGPUBindGroup bind_group_ = nullptr; WGPURenderPipeline skybox_pipeline_ = nullptr; WGPUBindGroup skybox_bind_group_ = nullptr; WGPUBuffer global_uniform_buffer_ = nullptr; WGPUBuffer object_storage_buffer_ = nullptr; + WGPUBuffer bvh_storage_buffer_ = nullptr; + + BVH cpu_bvh_; // Keep a CPU-side copy for building/uploading + bool bvh_enabled_ = true; WGPUTextureView noise_texture_view_ = nullptr; WGPUTextureView sky_texture_view_ = nullptr; @@ -101,4 +104,4 @@ class Renderer3D { VisualDebug visual_debug_; static bool s_debug_enabled_; #endif -}; +};
\ No newline at end of file |
