Skip to content

Commit be46ec3

Browse files
author
devsh
committed
prep example 67 for further work
1 parent 2dc2682 commit be46ec3

File tree

2 files changed

+23
-112
lines changed

2 files changed

+23
-112
lines changed
Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,18 @@
1-
#ifndef __NBL_THIS_EXAMPLE_COMMON_H_INCLUDED__
2-
#define __NBL_THIS_EXAMPLE_COMMON_H_INCLUDED__
1+
#ifndef _NBL_THIS_EXAMPLE_COMMON_H_INCLUDED_
2+
#define _NBL_THIS_EXAMPLE_COMMON_H_INCLUDED_
33

4-
#include <nabla.h>
5-
#include "nbl/asset/utils/CGeometryCreator.h"
6-
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
7-
8-
#include "SimpleWindowedApplication.hpp"
9-
10-
#include "InputSystem.hpp"
11-
#include "CEventCallback.hpp"
12-
13-
#include "CCamera.hpp"
14-
15-
#include <nbl/builtin/hlsl/cpp_compat.hlsl>
16-
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>
4+
#include "nbl/examples/examples.hpp"
175

186
using namespace nbl;
19-
using namespace core;
20-
using namespace hlsl;
21-
using namespace system;
22-
using namespace asset;
23-
using namespace ui;
24-
using namespace video;
25-
using namespace scene;
7+
using namespace nbl::core;
8+
using namespace nbl::hlsl;
9+
using namespace nbl::system;
10+
using namespace nbl::asset;
11+
using namespace nbl::ui;
12+
using namespace nbl::video;
13+
using namespace nbl::application_templates;
14+
using namespace nbl::examples;
2615

2716
#include "app_resources/common.hlsl"
2817

29-
namespace nbl::scene
30-
{
31-
enum ObjectType : uint8_t
32-
{
33-
OT_CUBE,
34-
OT_SPHERE,
35-
OT_CYLINDER,
36-
OT_RECTANGLE,
37-
OT_DISK,
38-
OT_ARROW,
39-
OT_CONE,
40-
OT_ICOSPHERE,
41-
42-
OT_COUNT,
43-
OT_UNKNOWN = std::numeric_limits<uint8_t>::max()
44-
};
45-
46-
struct ObjectMeta
47-
{
48-
ObjectType type = OT_UNKNOWN;
49-
std::string_view name = "Unknown";
50-
};
51-
52-
struct ObjectDrawHookCpu
53-
{
54-
nbl::core::matrix3x4SIMD model;
55-
nbl::asset::SBasicViewParameters viewParameters;
56-
ObjectMeta meta;
57-
};
58-
59-
enum GeometryShader
60-
{
61-
GP_BASIC = 0,
62-
GP_CONE,
63-
GP_ICO,
64-
65-
GP_COUNT
66-
};
67-
68-
struct ReferenceObjectCpu
69-
{
70-
ObjectMeta meta;
71-
GeometryShader shadersType;
72-
nbl::asset::CGeometryCreator::return_type data;
73-
};
74-
75-
struct ReferenceObjectGpu
76-
{
77-
struct Bindings
78-
{
79-
nbl::asset::SBufferBinding<IGPUBuffer> vertex, index;
80-
};
81-
82-
ObjectMeta meta;
83-
Bindings bindings;
84-
uint32_t vertexStride;
85-
nbl::asset::E_INDEX_TYPE indexType = nbl::asset::E_INDEX_TYPE::EIT_UNKNOWN;
86-
uint32_t indexCount = {};
87-
88-
const bool useIndex() const
89-
{
90-
return bindings.index.buffer && (indexType != E_INDEX_TYPE::EIT_UNKNOWN);
91-
}
92-
};
93-
}
94-
95-
#endif // __NBL_THIS_EXAMPLE_COMMON_H_INCLUDED__
18+
#endif // _NBL_THIS_EXAMPLE_COMMON_H_INCLUDED_

67_RayQueryGeometry/main.cpp

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// For conditions of distribution and use, see copyright notice in nabla.h
44
#include "common.hpp"
55

6-
class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, public application_templates::MonoAssetManagerAndBuiltinResourceApplication
6+
class RayQueryGeometryApp final : public SimpleWindowedApplication, public MonoAssetManagerAndBuiltinResourceApplication
77
{
8-
using device_base_t = examples::SimpleWindowedApplication;
9-
using asset_base_t = application_templates::MonoAssetManagerAndBuiltinResourceApplication;
8+
using device_base_t = SimpleWindowedApplication;
9+
using asset_base_t = MonoAssetManagerAndBuiltinResourceApplication;
1010
using clock_t = std::chrono::steady_clock;
1111

1212
constexpr static inline uint32_t WIN_W = 1280, WIN_H = 720;
@@ -121,7 +121,6 @@ class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, pu
121121
return logFail("Could not create HDR Image");
122122

123123
auto assetManager = make_smart_refctd_ptr<nbl::asset::IAssetManager>(smart_refctd_ptr(system));
124-
auto* geometryCreator = assetManager->getGeometryCreator();
125124

126125
auto cQueue = getComputeQueue();
127126

@@ -138,9 +137,9 @@ class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, pu
138137
std::this_thread::yield();
139138
}
140139
// Nsight is special and can't capture anything not on the queue that performs the swapchain acquire/release
141-
createAccelerationStructureDS(gQueue,geometryCreator);
140+
createAccelerationStructureDS(gQueue);
142141
#else
143-
createAccelerationStructureDS(cQueue,geometryCreator);
142+
createAccelerationStructureDS(cQueue);
144143
#endif
145144
if (!renderDs)
146145
return logFail("Could not create acceleration structures and descriptor set");
@@ -258,11 +257,9 @@ class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, pu
258257
cmdbuf->beginDebugMarker("RayQueryGeometryApp Frame");
259258
{
260259
camera.beginInputProcessing(nextPresentationTimestamp);
261-
mouse.consumeEvents([&](const IMouseEventChannel::range_t& events) -> void { camera.mouseProcess(events); mouseProcess(events); }, m_logger.get());
260+
mouse.consumeEvents([&](const IMouseEventChannel::range_t& events) -> void { camera.mouseProcess(events); }, m_logger.get());
262261
keyboard.consumeEvents([&](const IKeyboardEventChannel::range_t& events) -> void { camera.keyboardProcess(events); }, m_logger.get());
263262
camera.endInputProcessing(nextPresentationTimestamp);
264-
265-
const auto type = static_cast<ObjectType>(gcIndex);
266263
}
267264

268265
const auto viewMatrix = camera.getViewMatrix();
@@ -487,9 +484,12 @@ class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, pu
487484
return (dim + size - 1) / size;
488485
}
489486

490-
smart_refctd_ptr<IGPUDescriptorSet> createAccelerationStructureDS(video::CThreadSafeQueueAdapter* queue, const IGeometryCreator* gc)
487+
smart_refctd_ptr<IGPUDescriptorSet> createAccelerationStructureDS(video::CThreadSafeQueueAdapter* queue)
491488
{
492489
// get geometries in ICPUBuffers
490+
#if 1
491+
return nullptr;
492+
#else
493493
std::array<ReferenceObjectCpu, OT_COUNT> objectsCpu;
494494
objectsCpu[OT_CUBE] = ReferenceObjectCpu{ .meta = {.type = OT_CUBE, .name = "Cube Mesh" }, .shadersType = GP_BASIC, .data = gc->createCubeMesh(nbl::core::vector3df(1.f, 1.f, 1.f)) };
495495
objectsCpu[OT_SPHERE] = ReferenceObjectCpu{ .meta = {.type = OT_SPHERE, .name = "Sphere Mesh" }, .shadersType = GP_BASIC, .data = gc->createSphereMesh(2, 16, 16) };
@@ -892,6 +892,7 @@ class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, pu
892892
m_api->endCapture();
893893
894894
return reservation.getGPUObjects<ICPUDescriptorSet>().front().value;
895+
#endif
895896
}
896897

897898

@@ -915,19 +916,6 @@ class RayQueryGeometryApp final : public examples::SimpleWindowedApplication, pu
915916

916917
smart_refctd_ptr<IGPUComputePipeline> renderPipeline;
917918
smart_refctd_ptr<IGPUDescriptorSet> renderDs;
918-
919-
uint16_t gcIndex = {};
920-
921-
void mouseProcess(const nbl::ui::IMouseEventChannel::range_t& events)
922-
{
923-
for (auto eventIt = events.begin(); eventIt != events.end(); eventIt++)
924-
{
925-
auto ev = *eventIt;
926-
927-
if (ev.type == nbl::ui::SMouseEvent::EET_SCROLL)
928-
gcIndex = std::clamp<uint16_t>(int16_t(gcIndex) + int16_t(core::sign(ev.scrollEvent.verticalScroll)), int64_t(0), int64_t(OT_COUNT - (uint8_t)1u));
929-
}
930-
}
931919
};
932920

933921
NBL_MAIN_FUNC(RayQueryGeometryApp)

0 commit comments

Comments
 (0)