Skip to content

Commit 3387da3

Browse files
committed
Unify vkb::sg::Scene and vkb::scene_graph::HPPScene into vkb::scene_graph::Scene<bindingType>
1 parent 8f7fcb0 commit 3387da3

File tree

32 files changed

+353
-403
lines changed

32 files changed

+353
-403
lines changed

framework/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,8 @@ set(SCENE_GRAPH_FILES
131131
scene_graph/node.h
132132
scene_graph/scene.h
133133
scene_graph/script.h
134-
scene_graph/hpp_scene.h
135134
# Source Files
136135
scene_graph/component.cpp
137-
scene_graph/scene.cpp
138136
scene_graph/script.cpp)
139137

140138
set(SCENE_GRAPH_COMPONENT_FILES

framework/common/hpp_utils.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2021-2025, NVIDIA CORPORATION. All rights reserved.
1+
/* Copyright (c) 2021-2026, NVIDIA CORPORATION. All rights reserved.
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -18,7 +18,6 @@
1818
#pragma once
1919

2020
#include "common/utils.h"
21-
#include "scene_graph/hpp_scene.h"
2221

2322
/**
2423
* @brief facade helper functions around the functions in common/utils.h, providing a vulkan.hpp-based interface
@@ -27,10 +26,10 @@ namespace vkb
2726
{
2827
namespace common
2928
{
30-
inline vkb::scene_graph::NodeCpp &add_free_camera(vkb::scene_graph::HPPScene &scene, const std::string &node_name, vk::Extent2D const &extent)
29+
inline vkb::scene_graph::NodeCpp &add_free_camera(vkb::scene_graph::SceneCpp &scene, const std::string &node_name, vk::Extent2D const &extent)
3130
{
3231
return reinterpret_cast<vkb::scene_graph::NodeCpp &>(
33-
vkb::add_free_camera(reinterpret_cast<vkb::sg::Scene &>(scene), node_name, static_cast<VkExtent2D>(extent)));
32+
vkb::add_free_camera(reinterpret_cast<vkb::scene_graph::SceneC &>(scene), node_name, static_cast<VkExtent2D>(extent)));
3433
}
3534

3635
inline void screenshot(vkb::rendering::RenderContextCpp &render_context, const std::string &filename)

framework/common/utils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018-2025, Arm Limited and Contributors
1+
/* Copyright (c) 2018-2026, Arm Limited and Contributors
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -215,7 +215,7 @@ std::string to_snake_case(const std::string &text)
215215
return result.str();
216216
}
217217

218-
sg::Light &add_light(sg::Scene &scene,
218+
sg::Light &add_light(vkb::scene_graph::SceneC &scene,
219219
sg::LightType type,
220220
const glm::vec3 &position,
221221
const glm::quat &rotation,
@@ -249,22 +249,22 @@ sg::Light &add_light(sg::Scene &scene,
249249
return light;
250250
}
251251

252-
sg::Light &add_point_light(sg::Scene &scene, const glm::vec3 &position, const sg::LightProperties &props, vkb::scene_graph::NodeC *parent_node)
252+
sg::Light &add_point_light(vkb::scene_graph::SceneC &scene, const glm::vec3 &position, const sg::LightProperties &props, vkb::scene_graph::NodeC *parent_node)
253253
{
254254
return add_light(scene, sg::LightType::Point, position, {}, props, parent_node);
255255
}
256256

257-
sg::Light &add_directional_light(sg::Scene &scene, const glm::quat &rotation, const sg::LightProperties &props, vkb::scene_graph::NodeC *parent_node)
257+
sg::Light &add_directional_light(vkb::scene_graph::SceneC &scene, const glm::quat &rotation, const sg::LightProperties &props, vkb::scene_graph::NodeC *parent_node)
258258
{
259259
return add_light(scene, sg::LightType::Directional, {}, rotation, props, parent_node);
260260
}
261261

262-
sg::Light &add_spot_light(sg::Scene &scene, const glm::vec3 &position, const glm::quat &rotation, const sg::LightProperties &props, vkb::scene_graph::NodeC *parent_node)
262+
sg::Light &add_spot_light(vkb::scene_graph::SceneC &scene, const glm::vec3 &position, const glm::quat &rotation, const sg::LightProperties &props, vkb::scene_graph::NodeC *parent_node)
263263
{
264264
return add_light(scene, sg::LightType::Spot, position, rotation, props, parent_node);
265265
}
266266

267-
vkb::scene_graph::NodeC &add_free_camera(sg::Scene &scene, const std::string &node_name, VkExtent2D extent)
267+
vkb::scene_graph::NodeC &add_free_camera(vkb::scene_graph::SceneC &scene, const std::string &node_name, VkExtent2D extent)
268268
{
269269
auto camera_node = scene.find_node(node_name);
270270

framework/common/utils.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2018-2025, Arm Limited and Contributors
1+
/* Copyright (c) 2018-2026, Arm Limited and Contributors
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -25,6 +25,7 @@
2525
#include "filesystem/legacy.h"
2626
#include "rendering/pipeline_state.h"
2727
#include "rendering/render_context.h"
28+
#include "scene_graph/components/light.h"
2829
#include "scene_graph/components/sub_mesh.h"
2930
#include "scene_graph/scene.h"
3031

@@ -66,7 +67,7 @@ void screenshot(vkb::rendering::RenderContextC &render_context, const std::strin
6667
* @param parent_node The parent node for the line, defaults to root
6768
* @return The newly created light component
6869
*/
69-
sg::Light &add_light(sg::Scene &scene,
70+
sg::Light &add_light(vkb::scene_graph::SceneC &scene,
7071
sg::LightType type,
7172
const glm::vec3 &position,
7273
const glm::quat &rotation = {},
@@ -82,7 +83,7 @@ sg::Light &add_light(sg::Scene &scene,
8283
* @return The newly created light component
8384
*/
8485
sg::Light &
85-
add_point_light(sg::Scene &scene, const glm::vec3 &position, const sg::LightProperties &props = {}, vkb::scene_graph::NodeC *parent_node = nullptr);
86+
add_point_light(vkb::scene_graph::SceneC &scene, const glm::vec3 &position, const sg::LightProperties &props = {}, vkb::scene_graph::NodeC *parent_node = nullptr);
8687

8788
/**
8889
* @brief Adds a directional light to the scene with the specified parameters
@@ -92,7 +93,7 @@ sg::Light &
9293
* @param parent_node The parent node for the line, defaults to root
9394
* @return The newly created light component
9495
*/
95-
sg::Light &add_directional_light(sg::Scene &scene,
96+
sg::Light &add_directional_light(vkb::scene_graph::SceneC &scene,
9697
const glm::quat &rotation,
9798
const sg::LightProperties &props = {},
9899
vkb::scene_graph::NodeC *parent_node = nullptr);
@@ -106,7 +107,7 @@ sg::Light &add_directional_light(sg::Scene &scene,
106107
* @param parent_node The parent node for the line, defaults to root
107108
* @return The newly created light component
108109
*/
109-
sg::Light &add_spot_light(sg::Scene &scene,
110+
sg::Light &add_spot_light(vkb::scene_graph::SceneC &scene,
110111
const glm::vec3 &position,
111112
const glm::quat &rotation,
112113
const sg::LightProperties &props = {},
@@ -120,6 +121,6 @@ sg::Light &add_spot_light(sg::Scene &scene,
120121
* @param extent The initial resolution of the camera
121122
* @return Node where the script was attached as component
122123
*/
123-
vkb::scene_graph::NodeC &add_free_camera(sg::Scene &scene, const std::string &node_name, VkExtent2D extent);
124+
vkb::scene_graph::NodeC &add_free_camera(vkb::scene_graph::SceneC &scene, const std::string &node_name, VkExtent2D extent);
124125

125126
} // namespace vkb

framework/gltf_loader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2018-2025, Arm Limited and Contributors
2-
* Copyright (c) 2019-2025, Sascha Willems
1+
/* Copyright (c) 2018-2026, Arm Limited and Contributors
2+
* Copyright (c) 2019-2026, Sascha Willems
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -407,7 +407,7 @@ GLTFLoader::GLTFLoader(vkb::core::DeviceC &device) :
407407
{
408408
}
409409

410-
std::unique_ptr<sg::Scene> GLTFLoader::read_scene_from_file(const std::string &file_name, int scene_index, VkBufferUsageFlags additional_buffer_usage_flags)
410+
std::unique_ptr<vkb::scene_graph::SceneC> GLTFLoader::read_scene_from_file(const std::string &file_name, int scene_index, VkBufferUsageFlags additional_buffer_usage_flags)
411411
{
412412
PROFILE_SCOPE("Load GLTF Scene");
413413

@@ -447,7 +447,7 @@ std::unique_ptr<sg::Scene> GLTFLoader::read_scene_from_file(const std::string &f
447447
model_path.clear();
448448
}
449449

450-
return std::make_unique<sg::Scene>(load_scene(scene_index, additional_buffer_usage_flags));
450+
return std::make_unique<vkb::scene_graph::SceneC>(load_scene(scene_index, additional_buffer_usage_flags));
451451
}
452452

453453
std::unique_ptr<sg::SubMesh> GLTFLoader::read_model_from_file(const std::string &file_name, uint32_t index, bool storage_buffer, VkBufferUsageFlags additional_buffer_usage_flags)
@@ -494,11 +494,11 @@ std::unique_ptr<sg::SubMesh> GLTFLoader::read_model_from_file(const std::string
494494
return std::move(load_model(index, storage_buffer, additional_buffer_usage_flags));
495495
}
496496

497-
sg::Scene GLTFLoader::load_scene(int scene_index, VkBufferUsageFlags additional_buffer_usage_flags)
497+
vkb::scene_graph::SceneC GLTFLoader::load_scene(int scene_index, VkBufferUsageFlags additional_buffer_usage_flags)
498498
{
499499
PROFILE_SCOPE("Process Scene");
500500

501-
auto scene = sg::Scene();
501+
auto scene = vkb::scene_graph::SceneC();
502502

503503
scene.set_name("gltf_scene");
504504

framework/gltf_loader.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Copyright (c) 2018-2025, Arm Limited and Contributors
2-
* Copyright (c) 2019-2025, Sascha Willems
1+
/* Copyright (c) 2018-2026, Arm Limited and Contributors
2+
* Copyright (c) 2019-2026, Sascha Willems
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -29,6 +29,7 @@
2929

3030
#include "scene_graph/components/sampler.h"
3131
#include "scene_graph/node.h"
32+
#include "scene_graph/scene.h"
3233
#include "timer.h"
3334

3435
#include "vulkan/vulkan.h"
@@ -54,7 +55,6 @@ class Mesh;
5455
class Node;
5556
class PBRMaterial;
5657
class Sampler;
57-
class Scene;
5858
class SubMesh;
5959
class Texture;
6060
} // namespace sg
@@ -84,7 +84,7 @@ class GLTFLoader
8484

8585
virtual ~GLTFLoader() = default;
8686

87-
std::unique_ptr<sg::Scene> read_scene_from_file(const std::string &file_name, int scene_index = -1, VkBufferUsageFlags additional_buffer_usage_flags = 0);
87+
std::unique_ptr<vkb::scene_graph::SceneC> read_scene_from_file(const std::string &file_name, int scene_index = -1, VkBufferUsageFlags additional_buffer_usage_flags = 0);
8888

8989
/**
9090
* @brief Loads the first model from a GLTF file for use in simpler samples
@@ -143,7 +143,7 @@ class GLTFLoader
143143
static std::unordered_map<std::string, bool> supported_extensions;
144144

145145
private:
146-
sg::Scene load_scene(int scene_index = -1, VkBufferUsageFlags additional_buffer_usage_flags = 0);
146+
vkb::scene_graph::SceneC load_scene(int scene_index = -1, VkBufferUsageFlags additional_buffer_usage_flags = 0);
147147

148148
std::unique_ptr<sg::SubMesh> load_model(uint32_t index, bool storage_buffer = false, VkBufferUsageFlags additional_buffer_usage_flags = 0);
149149
};

framework/hpp_gltf_loader.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2021-2025, NVIDIA CORPORATION. All rights reserved.
1+
/* Copyright (c) 2021-2026, NVIDIA CORPORATION. All rights reserved.
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -20,7 +20,6 @@
2020
#include <gltf_loader.h>
2121

2222
#include <scene_graph/components/hpp_sub_mesh.h>
23-
#include <scene_graph/hpp_scene.h>
2423

2524
namespace vkb
2625
{
@@ -43,9 +42,9 @@ class HPPGLTFLoader : private vkb::GLTFLoader
4342
vkb::GLTFLoader::read_model_from_file(file_name, index, storage_buffer, static_cast<VkBufferUsageFlags>(additional_buffer_usage_flags)).release()));
4443
}
4544

46-
std::unique_ptr<vkb::scene_graph::HPPScene> read_scene_from_file(const std::string &file_name, int scene_index = -1)
45+
std::unique_ptr<vkb::scene_graph::SceneCpp> read_scene_from_file(const std::string &file_name, int scene_index = -1)
4746
{
48-
return std::unique_ptr<vkb::scene_graph::HPPScene>(reinterpret_cast<vkb::scene_graph::HPPScene *>(vkb::GLTFLoader::read_scene_from_file(file_name, scene_index).release()));
47+
return std::unique_ptr<vkb::scene_graph::SceneCpp>(reinterpret_cast<vkb::scene_graph::SceneCpp *>(vkb::GLTFLoader::read_scene_from_file(file_name, scene_index).release()));
4948
}
5049
};
5150
} // namespace vkb

framework/rendering/subpasses/forward_subpass.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ template <vkb::BindingType bindingType>
5454
class ForwardSubpass : public vkb::rendering::subpasses::GeometrySubpass<bindingType>
5555
{
5656
public:
57-
using SceneType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::scene_graph::HPPScene, vkb::sg::Scene>::type;
5857
using ShaderSourceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPShaderSource, vkb::ShaderSource>::type;
5958

6059
public:
@@ -69,7 +68,7 @@ class ForwardSubpass : public vkb::rendering::subpasses::GeometrySubpass<binding
6968
ForwardSubpass(vkb::rendering::RenderContext<bindingType> &render_context,
7069
ShaderSourceType &&vertex_shader,
7170
ShaderSourceType &&fragment_shader,
72-
SceneType &scene,
71+
vkb::scene_graph::Scene<bindingType> &scene,
7372
sg::Camera &camera);
7473

7574
virtual ~ForwardSubpass() = default;
@@ -88,7 +87,7 @@ template <vkb::BindingType bindingType>
8887
inline ForwardSubpass<bindingType>::ForwardSubpass(vkb::rendering::RenderContext<bindingType> &render_context,
8988
ShaderSourceType &&vertex_source,
9089
ShaderSourceType &&fragment_source,
91-
SceneType &scene_,
90+
vkb::scene_graph::Scene<bindingType> &scene_,
9291
sg::Camera &camera) :
9392
GeometrySubpass<bindingType>{render_context, std::move(vertex_source), std::move(fragment_source), scene_, camera}
9493
{}

framework/rendering/subpasses/geometry_subpass.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "scene_graph/components/image.h"
2727
#include "scene_graph/components/pbr_material.h"
2828
#include "scene_graph/components/sub_mesh.h"
29-
#include "scene_graph/hpp_scene.h"
3029
#include "scene_graph/scene.h"
3130

3231
namespace vkb
@@ -91,7 +90,6 @@ class GeometrySubpass : public vkb::rendering::Subpass<bindingType>
9190
using MeshType = typename std::conditional<bindingType == BindingType::Cpp, vkb::scene_graph::components::HPPMesh, vkb::sg::Mesh>::type;
9291
using PipelineLayoutType = typename std::conditional<bindingType == BindingType::Cpp, vkb::core::HPPPipelineLayout, vkb::PipelineLayout>::type;
9392
using RasterizationStateType = typename std::conditional<bindingType == BindingType::Cpp, vkb::rendering::HPPRasterizationState, vkb::RasterizationState>::type;
94-
using SceneType = typename std::conditional<bindingType == BindingType::Cpp, vkb::scene_graph::HPPScene, vkb::sg::Scene>::type;
9593
using ShaderModuleType = typename std::conditional<bindingType == BindingType::Cpp, vkb::core::HPPShaderModule, vkb::ShaderModule>::type;
9694
using ShaderSourceType = typename std::conditional<bindingType == BindingType::Cpp, vkb::core::HPPShaderSource, vkb::ShaderSource>::type;
9795
using SubMeshType = typename std::conditional<bindingType == BindingType::Cpp, vkb::scene_graph::components::HPPSubMesh, vkb::sg::SubMesh>::type;
@@ -108,7 +106,7 @@ class GeometrySubpass : public vkb::rendering::Subpass<bindingType>
108106
GeometrySubpass(vkb::rendering::RenderContext<bindingType> &render_context,
109107
ShaderSourceType &&vertex_shader,
110108
ShaderSourceType &&fragment_shader,
111-
SceneType &scene,
109+
vkb::scene_graph::Scene<bindingType> &scene,
112110
sg::Camera &camera);
113111

114112
virtual ~GeometrySubpass() = default;
@@ -127,12 +125,12 @@ class GeometrySubpass : public vkb::rendering::Subpass<bindingType>
127125
void set_thread_index(uint32_t index);
128126

129127
protected:
130-
void draw_submesh(vkb::core::CommandBuffer<bindingType> &command_buffer, SubMeshType &sub_mesh, FrontFaceType front_face = DefaultFrontFaceTypeValue<FrontFaceType>::value);
131-
virtual void draw_submesh_command(vkb::core::CommandBuffer<bindingType> &command_buffer, SubMeshType &sub_mesh);
132-
vkb::sg::Camera const &get_camera() const;
133-
std::vector<MeshType *> const &get_meshes() const;
134-
RasterizationStateType const &get_rasterization_state() const;
135-
SceneType const &get_scene() const;
128+
void draw_submesh(vkb::core::CommandBuffer<bindingType> &command_buffer, SubMeshType &sub_mesh, FrontFaceType front_face = DefaultFrontFaceTypeValue<FrontFaceType>::value);
129+
virtual void draw_submesh_command(vkb::core::CommandBuffer<bindingType> &command_buffer, SubMeshType &sub_mesh);
130+
vkb::sg::Camera const &get_camera() const;
131+
std::vector<MeshType *> const &get_meshes() const;
132+
RasterizationStateType const &get_rasterization_state() const;
133+
vkb::scene_graph::Scene<bindingType> const &get_scene() const;
136134

137135
/**
138136
* @brief Sorts objects based on distance from camera and classifies them
@@ -168,7 +166,7 @@ class GeometrySubpass : public vkb::rendering::Subpass<bindingType>
168166
vkb::rendering::HPPRasterizationState base_rasterization_state;
169167
vkb::sg::Camera &camera;
170168
std::vector<vkb::scene_graph::components::HPPMesh *> meshes;
171-
vkb::scene_graph::HPPScene *scene;
169+
vkb::scene_graph::SceneCpp *scene;
172170
uint32_t thread_index = 0;
173171
};
174172

@@ -181,7 +179,7 @@ template <vkb::BindingType bindingType>
181179
inline GeometrySubpass<bindingType>::GeometrySubpass(vkb::rendering::RenderContext<bindingType> &render_context,
182180
ShaderSourceType &&vertex_source,
183181
ShaderSourceType &&fragment_source,
184-
SceneType &scene_,
182+
vkb::scene_graph::Scene<bindingType> &scene_,
185183
sg::Camera &camera) :
186184
Subpass<bindingType>{render_context, std::move(vertex_source), std::move(fragment_source)}, camera{camera}
187185
{
@@ -191,7 +189,7 @@ inline GeometrySubpass<bindingType>::GeometrySubpass(vkb::rendering::RenderConte
191189
}
192190
else
193191
{
194-
scene = reinterpret_cast<vkb::scene_graph::HPPScene *>(&scene_);
192+
scene = reinterpret_cast<vkb::scene_graph::SceneCpp *>(&scene_);
195193
}
196194
meshes = scene->get_components<vkb::scene_graph::components::HPPMesh>();
197195
}
@@ -369,15 +367,15 @@ inline typename GeometrySubpass<bindingType>::RasterizationStateType const &Geom
369367
}
370368

371369
template <vkb::BindingType bindingType>
372-
inline typename GeometrySubpass<bindingType>::SceneType const &GeometrySubpass<bindingType>::get_scene() const
370+
inline vkb::scene_graph::Scene<bindingType> const &GeometrySubpass<bindingType>::get_scene() const
373371
{
374372
if constexpr (bindingType == BindingType::Cpp)
375373
{
376374
return *scene;
377375
}
378376
else
379377
{
380-
return *reinterpret_cast<vkb::sg::Scene const *>(scene);
378+
return *reinterpret_cast<vkb::scene_graph::SceneC const *>(scene);
381379
}
382380
}
383381

framework/rendering/subpasses/lighting_subpass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2019-2025, Arm Limited and Contributors
1+
/* Copyright (c) 2019-2026, Arm Limited and Contributors
22
*
33
* SPDX-License-Identifier: Apache-2.0
44
*
@@ -27,7 +27,7 @@
2727
namespace vkb
2828
{
2929
LightingSubpass::LightingSubpass(
30-
vkb::rendering::RenderContextC &render_context, ShaderSource &&vertex_shader, ShaderSource &&fragment_shader, sg::Camera &cam, sg::Scene &scene_) :
30+
vkb::rendering::RenderContextC &render_context, ShaderSource &&vertex_shader, ShaderSource &&fragment_shader, sg::Camera &cam, vkb::scene_graph::SceneC &scene_) :
3131
Subpass{render_context, std::move(vertex_shader), std::move(fragment_shader)}, camera{cam}, scene{scene_}
3232
{
3333
}

0 commit comments

Comments
 (0)