summaryrefslogtreecommitdiff
path: root/src/3d/renderer.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3d/renderer.h')
-rw-r--r--src/3d/renderer.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/3d/renderer.h b/src/3d/renderer.h
index db86b72..5c9fd38 100644
--- a/src/3d/renderer.h
+++ b/src/3d/renderer.h
@@ -8,6 +8,7 @@
#include "3d/scene.h"
#include "3d/bvh.h"
#include "gpu/gpu.h"
+#include <map>
#include <vector>
#if !defined(STRIP_ALL)
@@ -64,12 +65,30 @@ class Renderer3D {
// Set whether to use BVH acceleration
void SetBvhEnabled(bool enabled) { bvh_enabled_ = enabled; }
+ struct MeshGpuData {
+ WGPUBuffer vertex_buffer;
+ WGPUBuffer index_buffer;
+ uint32_t num_indices;
+ };
+
+ // HACK for test_mesh tool
+ void override_mesh_buffers(const MeshGpuData* data) {
+ temp_mesh_override_ = data;
+ }
+
+#if !defined(STRIP_ALL)
+ VisualDebug& GetVisualDebug() { return visual_debug_; }
+#endif
+
private:
+
void create_pipeline();
WGPURenderPipeline create_pipeline_impl(bool use_bvh);
+ void create_mesh_pipeline();
void create_skybox_pipeline();
void create_default_resources();
void update_uniforms(const Scene& scene, const Camera& camera, float time);
+ const MeshGpuData* get_or_create_mesh(AssetId asset_id);
WGPUDevice device_ = nullptr;
WGPUQueue queue_ = nullptr;
@@ -78,6 +97,7 @@ class Renderer3D {
WGPURenderPipeline pipeline_ = nullptr; // BVH enabled
WGPURenderPipeline pipeline_no_bvh_ = nullptr; // BVH disabled
WGPUBindGroup bind_group_ = nullptr;
+ WGPURenderPipeline mesh_pipeline_ = nullptr;
WGPURenderPipeline skybox_pipeline_ = nullptr;
WGPUBindGroup skybox_bind_group_ = nullptr;
WGPUBuffer global_uniform_buffer_ = nullptr;
@@ -87,6 +107,9 @@ class Renderer3D {
BVH cpu_bvh_; // Keep a CPU-side copy for building/uploading
bool bvh_enabled_ = true;
+ std::map<AssetId, MeshGpuData> mesh_cache_;
+ const MeshGpuData* temp_mesh_override_ = nullptr; // HACK for test_mesh tool
+
WGPUTextureView noise_texture_view_ = nullptr;
WGPUTextureView sky_texture_view_ = nullptr;
WGPUSampler default_sampler_ = nullptr;