Skip to content

Hlsl path tracer #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 325 commits into
base: bxdf_unit_tests
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
325 commits
Select commit Hold shift + click to select a range
6517442
Fix merge bug.
Mar 12, 2025
6465312
Fix demo to use the new traceRayIndirect
Mar 12, 2025
6abb635
fixed nan and accumulation going black problem
keptsecret Mar 13, 2025
1eee3ca
fixed triangle light, rectangle needs checking
keptsecret Mar 13, 2025
011fbfb
simplified material data
keptsecret Mar 13, 2025
4d1dca4
Small fixes on ray trace pipeline demo.
Mar 13, 2025
cc84091
Optimize ray tracing demo occlusion tracing
Mar 13, 2025
63b64e3
made scene a static global var
keptsecret Mar 14, 2025
7bd69e9
fixed most of rectangle light issues, still red pixels
keptsecret Mar 14, 2025
38d8285
Use unused shader instead of stub shader for occlusion ray miss shader.
Mar 14, 2025
ab0aa12
fix for nan samples
keptsecret Mar 17, 2025
96c7497
revert to intial scene settings
keptsecret Mar 17, 2025
b5194ef
Merge branch 'master' into hlsl_path_tracer
keptsecret Mar 17, 2025
f96dfcc
Use nbl::hlsl::_static_cast for converting MaterialPacked to Material…
Mar 17, 2025
88b3275
Fix create shader binding table to use the new span api
Mar 17, 2025
cca8f72
Some optimization on ray tracing demo
Mar 18, 2025
b483aa6
better hlsl dispatch
keptsecret Mar 19, 2025
773733d
refactor NEE to use templated light types and sampling
keptsecret Mar 19, 2025
b889b60
use 1D workgroup dispatch
keptsecret Mar 19, 2025
79ee9da
removed obsolete commented sections
keptsecret Mar 19, 2025
ca8f2ec
some minor corrections
keptsecret Mar 19, 2025
c904134
Return materialId instead of materialPacked from rchit
Mar 20, 2025
6b3ae54
Add ray tracing no null flags
Mar 20, 2025
b2abf00
Add setRayTracingStackSize in the demo
Mar 20, 2025
e95f09d
changed workgroup size to 512
keptsecret Mar 21, 2025
56994a9
workgroup size 512 for sure this time
keptsecret Mar 21, 2025
3cdfb4b
use morton and virtual indexing
keptsecret Mar 24, 2025
5f93cec
reverted virtual index, fix hlsl colors
keptsecret Mar 24, 2025
78de4f5
fixed some bugs for cpp compat
keptsecret Mar 25, 2025
8090a2d
initial benchmark example copy
keptsecret Mar 27, 2025
f823771
use dropdown, more options
keptsecret Mar 28, 2025
1535561
added persistent workgroup toggle
keptsecret Mar 28, 2025
3a2ff14
test subgroup2 funcs correct
keptsecret Mar 31, 2025
dd021a0
fix test
keptsecret Mar 31, 2025
6074c7c
Merge pull request #173 from kevyuu/raytracing_pipeline_demo
devshgraphicsprogramming Mar 31, 2025
6766420
make RT pipeline example work when `NBL_EMED_RESOURCES=OFF`
Mar 31, 2025
0905053
Correct Alpha handling in RT Pipeline example, also work around https…
Mar 31, 2025
699f263
clean up the code a bit more, address comments in https://github.com/…
Mar 31, 2025
bb2fd06
do shadows without any closest hit shaders, one miss shader instead
Mar 31, 2025
ca21941
benchmarking shader + pipeline working
keptsecret Apr 1, 2025
0bb41db
begin adding fake frames for nsight profiler
keptsecret Apr 2, 2025
3400a2a
Merge branch 'master' into hlsl_path_tracer
keptsecret Apr 3, 2025
391c3ac
fix ray query geometry to use IShader
Apr 3, 2025
24a93bb
merge master, fix conflicts
keptsecret Apr 7, 2025
17dda8e
re-numbered example to avoid duplicate
keptsecret Apr 7, 2025
3d4e0f2
fake frames for nsight
keptsecret Apr 8, 2025
0192999
use correct shader, spirv line dbinfo for nsight
keptsecret Apr 8, 2025
8c9d55e
support for 1 item per invoc
keptsecret Apr 8, 2025
07d6980
handle when items per invoc =1
keptsecret Apr 9, 2025
be756d5
minor fixes
keptsecret Apr 10, 2025
1963b51
changes in Param, Config usage
keptsecret Apr 10, 2025
21af190
Merge branch 'master' into stageless_shaders
Apr 15, 2025
08b2442
make example 07 run again after slight updates to API
Apr 18, 2025
32ec0af
FFT examples now fully deprecate the old, and move Clustered Renderin…
Apr 19, 2025
24f952d
count path depth properly, bug from unremoved testing code caused MIS…
Apr 19, 2025
3253b6f
fix NEE_ONLY setting
Apr 19, 2025
c699bd0
Remove legacy deprecated/reimplemented examples
Apr 19, 2025
f4cc4cd
const correctness of BLAS geometry spans
Apr 19, 2025
ff1d092
make example use new enum without KHR suffix
Apr 20, 2025
99cf5d8
coalesced load/store data
keptsecret Apr 21, 2025
1d5e433
Merge branch 'master' into scan_perf_bench
keptsecret Apr 21, 2025
a3bb526
fixed some bugs
keptsecret Apr 21, 2025
355c605
disable test by default
keptsecret Apr 21, 2025
21f424f
Fix merge conflict
Apr 22, 2025
2878d03
Fix Hello Compute to use IShader
Apr 22, 2025
2ea6304
Fix example 03 to use IShader
Apr 22, 2025
78990f8
Fix example 05 to use IShader
Apr 22, 2025
01df790
Fix example 07 to use IShader
Apr 22, 2025
f46522c
Fix example 70 to use IShader
Apr 22, 2025
b0b6f64
Fix example 30 to use IShader
Apr 22, 2025
a675cdb
Fix example 10 to use IShader
Apr 22, 2025
4104de5
Fix example 11 to use IShader
Apr 22, 2025
1d6fde6
Fix example 22 to use IShader
Apr 22, 2025
32c4974
Fix example 23 to use IShader
Apr 22, 2025
8255a3e
Fix example 24 to use IShader
Apr 22, 2025
847927c
Fix example 25 to use IShader
Apr 22, 2025
20cd09a
Fix example 26 to use IShader
Apr 22, 2025
fabe1db
Fix example 27 to use IShader
Apr 22, 2025
d7f9f18
Fix example 28 to use IShader
Apr 22, 2025
ad5054d
Fix example 71 to use IShader
Apr 22, 2025
3698fb4
Fix geometry scene creator to use IShader
Apr 22, 2025
6b57674
refactor to load data as vectors, consecutive uints
keptsecret Apr 25, 2025
7da1bec
initial wg scan test
keptsecret Apr 28, 2025
750b3d2
working? test for workgroup2 reduce
keptsecret Apr 28, 2025
f11b3df
fixes to test
keptsecret Apr 29, 2025
9f690ee
tests with multiple items per invoc
keptsecret Apr 29, 2025
755f89a
inclusive scan test
keptsecret Apr 29, 2025
b8415ad
exclusive scan test, remove comments
keptsecret Apr 30, 2025
474281d
benchmark shader, new common header
keptsecret May 1, 2025
7d06332
test smaller workgroup sizes
keptsecret May 2, 2025
874557c
expanded scratch proxy funcs
keptsecret May 2, 2025
28ea75f
simplify scratch,proxy to just scalar types
keptsecret May 5, 2025
8c76367
update the Acceleration Structure Position fetch code in one example …
May 6, 2025
e8c2831
move all tests into new example
keptsecret May 7, 2025
93b4d0b
Merge branch 'master' into new_wg_scan_test
keptsecret May 7, 2025
2ba2b82
workgroup scan benchmark, renamed examples
keptsecret May 7, 2025
d567e71
removed obsolete files
keptsecret May 7, 2025
54acf2a
replaced old ex 23 unit test with new tests
keptsecret May 7, 2025
030d622
minor fixes
keptsecret May 7, 2025
ca71a39
minor fixes to workgroup benchmark
keptsecret May 8, 2025
6018e9a
more minor fixes
keptsecret May 8, 2025
3a9758c
some fixes to using config vars
keptsecret May 9, 2025
e496e98
fixes to test mem errors
keptsecret May 12, 2025
20011f5
config struct changes
keptsecret May 12, 2025
55a9e13
block to test tlas/blas asset converter
keptsecret May 14, 2025
4a951b3
more test case coverage
keptsecret May 14, 2025
16b7349
some fixes + log debug
keptsecret May 14, 2025
825c73d
update media submodule
AnastaZIuk May 14, 2025
052148f
disable more old code, use two queues for BLAS & TLAS convert and mul…
May 14, 2025
a42a742
Merge branch 'master' into new_wg_scan_test
keptsecret May 15, 2025
908abd1
refactor name changes
keptsecret May 15, 2025
81238ad
minor refactor
keptsecret May 15, 2025
749658f
manage workgroup in example
keptsecret May 15, 2025
1de31dd
moved benchmark to ex 29
keptsecret May 15, 2025
e828dc4
fit accessors to concept
keptsecret May 16, 2025
06bf814
Merge branch 'master' into asset_conv_ray_query_geom
keptsecret May 16, 2025
c41617b
moved stuff around, check inputs in imgui
keptsecret May 16, 2025
b498e9c
triangles and aabbs into icpubuffers
keptsecret May 16, 2025
b4c5ff2
use asset converter to build tlas
keptsecret May 19, 2025
086c21e
use bda in unit test
keptsecret May 20, 2025
f4af3ed
benchmarks use bda
keptsecret May 20, 2025
a394f22
use data accessor with preload data in reg
keptsecret May 20, 2025
44c34a8
use store with data type because it works now
keptsecret May 20, 2025
52f5485
make old code compile with new API and work with renderdoc
May 20, 2025
5eb919d
Merge branch 'asset_conv_ray_query_geom' of github.com:Devsh-Graphics…
May 20, 2025
010a9e5
add missing ownership acquire and clean up the code a bit
May 20, 2025
0ccd26f
save reduction returns to storage
keptsecret May 21, 2025
f71b1d3
do the ownership acquires properly
May 21, 2025
f5302ec
Do the QFOT Acquires properly, fix a bug due to missing BDA on sideba…
May 21, 2025
0bd7fba
ReBAR AS-conversion codepath tested and enabled by default now
May 21, 2025
ff962da
typo and no point announcing ass-conv failures if the ass-conv will d…
May 21, 2025
09f0d32
stuff was crashing cause IGPUBuffers backing BDA were going out of scope
May 21, 2025
cac9ea1
typo
May 21, 2025
2a991a9
combined headers between subgroup, workgroup stuff, restored spirv ca…
keptsecret May 22, 2025
e4735a4
simplified test,benchmark function template params
keptsecret May 22, 2025
13ae89f
revert test to default params
keptsecret May 22, 2025
a8774db
use preloaded data in benchmark
keptsecret May 22, 2025
8b729d5
test compaction of BLASes
May 22, 2025
4352122
test TLAS compaction
May 22, 2025
20fed8c
test Descriptor Set conversion with TLAS rewrites
May 23, 2025
c2023df
name variables correctly
May 23, 2025
69ba991
Merge pull request #193 from Devsh-Graphics-Programming/asset_conv_ra…
devshgraphicsprogramming May 23, 2025
a7f52a7
Merge remote-tracking branch 'remotes/origin/asset_conv_ray_tracing'
May 25, 2025
fae6490
get old Acceleration Structure code workin in ex 71 after API change
May 25, 2025
bb3a901
Merge branch 'master' into new_wg_scan_test
keptsecret May 26, 2025
c8d4b60
the multi-queue was badly implemented, just use Graphics & Compute th…
May 26, 2025
e30938c
test that we're not overflown submitted when providing correct max si…
May 26, 2025
2a85f4e
refactor config member name
keptsecret May 27, 2025
99f6dfe
fit new accessor concepts
keptsecret May 27, 2025
0ed8dc4
Lets remake the STL/PLY loaders
May 27, 2025
3d89894
fix template accessors
keptsecret May 27, 2025
3d63ed7
add accessor index template type
keptsecret May 27, 2025
1100876
limit workgroup count
keptsecret May 28, 2025
f202ef5
utility func to get items per wg
keptsecret May 29, 2025
93b7810
added check for vk spec requirement
keptsecret May 30, 2025
3a3aaa9
removed maxComputeWorkgroupSubgroups*subgroupsize check
keptsecret Jun 2, 2025
6581ed4
Merge branch 'master' into new_wg_scan_test
keptsecret Jun 2, 2025
fef1cd5
first outline
Jun 3, 2025
157bd8f
outline how I want stuff reorganised
Jun 4, 2025
8370719
temporarily disable some things that I couldn't figure out withour Ar…
Jun 4, 2025
83443a7
factored out the `CSwapchainFramebuffersAndDepth` into `nbl/examples/…
Jun 4, 2025
90ba926
various minor adjustments to unit tests
keptsecret Jun 5, 2025
19d7fe0
simplified data accessors
keptsecret Jun 5, 2025
fdace31
tests for native and emulated subgroup op
keptsecret Jun 5, 2025
d6680f2
removed redundant stuff
keptsecret Jun 5, 2025
bafad3e
bind swapchain image directly, explicit surface format swapchain
keptsecret Jun 6, 2025
32dc78f
shared data accessor header between test and bench, same shader adjus…
keptsecret Jun 6, 2025
2aef6d3
generate benchmark inputs with xoroshiro
keptsecret Jun 6, 2025
149a237
only have to benchmark plus op
keptsecret Jun 6, 2025
00ed9be
benchmark all reduce/scan in one run (lots of shaders)
keptsecret Jun 6, 2025
a5a21fd
minor changes to passing subgroup size and items per wg
keptsecret Jun 9, 2025
1710b69
push constant stores array of output addresses directly because stati…
keptsecret Jun 9, 2025
6c78e29
rework PCH for examples, save work and test with 01 - successfully
AnastaZIuk Jun 11, 2025
fdae6f9
actually some example headers I removed can be used in PCH with small…
AnastaZIuk Jun 11, 2025
ed51dee
remove old header references from 29_MeshLoaders/main.cpp which are i…
AnastaZIuk Jun 11, 2025
971ee34
wipe all EXCLUDE_FROM_ALL except common directory, group all examples…
AnastaZIuk Jun 11, 2025
c9f610f
use NBL_ADJUST_FOLDERS with examples namespace
AnastaZIuk Jun 11, 2025
b9f3f13
Fix example to use reworked shader spec itnerface
Jun 13, 2025
60319f4
Fix picking the wrong diff when merging with master
Jun 13, 2025
bb0e4fd
Fix merge by using master code
Jun 14, 2025
04e32ad
Fix example 64,67,70,71
Jun 14, 2025
4c10dc1
use config header file for workgroup sizes
keptsecret Jun 16, 2025
6c6c645
simplified some cpp code, write all benchmark descriptors at beginning
keptsecret Jun 16, 2025
d33791e
Merge branch 'master' into stageless_shaders
Jun 16, 2025
638846e
Fix ray tracing pipeline demo alpha
Jun 16, 2025
6c251d1
Remove test code in ray query geometry shaders
Jun 16, 2025
95d8f78
Merge branch 'stageless_shaders' into rework_pipeline_shader_spec_info
Jun 16, 2025
2076b66
simplified data accessor template + usage
keptsecret Jun 16, 2025
d1a8113
prep the push constants a little and move onto scene conversion
Jun 16, 2025
629a0ac
correct small typos, get stuff to compile
Jun 16, 2025
37330ab
add more test geometries
Jun 16, 2025
5200ea1
fire up the converter and handle ownership between queues
Jun 16, 2025
a89ffbe
make accessor template nicer to read
keptsecret Jun 17, 2025
272a269
use Asset Converter for ICPUPolygonGeometry, and split into Scene and…
Jun 17, 2025
3a487ac
make example 30 run again
Jun 17, 2025
8fd7f5d
fix ex 11 fft
keptsecret Jun 18, 2025
e5d4a35
Fix fft bloom example to use the reworked shader spec info interface
Jun 18, 2025
c06b97e
Merge branch 'master' into rework_pipeline_shader_spec_info
Jun 18, 2025
8ae32e1
removed redundant barrier
keptsecret Jun 18, 2025
7121e8b
Fix example 05
Jun 18, 2025
683aa87
use builtin bda accessor
keptsecret Jun 18, 2025
1c56eb0
reduce workgroup macro definitions, use config string
keptsecret Jun 18, 2025
3e910b5
similar config string thing but for subgroups
keptsecret Jun 18, 2025
c446d7e
prep for the final stretch in ex 09 (shaders)
Jun 18, 2025
e76bfcc
move ex09 renderer to its own include
Jun 18, 2025
0ba8eed
apply reduced macro definitions to benchmark ex
keptsecret Jun 18, 2025
e06c9af
Merge pull request #192 from Devsh-Graphics-Programming/new_wg_scan_test
devshgraphicsprogramming Jun 18, 2025
c3786df
prep for shader loading
Jun 18, 2025
18bb325
Merge branch 'master' into rework_pipeline_shader_spec_info
Jun 18, 2025
173a3c9
Fix compile error for example 23 and 29
Jun 18, 2025
643b8d8
Merge pull request #195 from Devsh-Graphics-Programming/rework_pipeli…
devshgraphicsprogramming Jun 18, 2025
d03f31b
kill a CMakeLists.txt not used in the example PCH branch
Jun 18, 2025
f6aebbf
commit shaders somewhere for now
Jun 18, 2025
00be524
Merge remote-tracking branch 'remotes/origin/master' into mesh_loaders
Jun 18, 2025
8965fb3
get ex 09 in line with Stageless Shaders
Jun 18, 2025
a860c43
fix up examples before the PCH PR
Jun 18, 2025
2dc2682
prep example 71 for @kevinyu
Jun 18, 2025
be46ec3
prep example 67 for further work
Jun 18, 2025
9aa7483
@AnastaZIuk I need your help for getting the mounting of `common/incl…
Jun 18, 2025
846d2fd
prep UI example for further work
Jun 18, 2025
a347562
note down embedding TODOs for arek
Jun 19, 2025
cf4e279
remove unused shaders
Jun 19, 2025
08c28ef
get the example to find shaders and create pipelines, but nothing on …
Jun 19, 2025
17b0579
scene was empty, no wonder nothing drew
Jun 19, 2025
62f1a26
index type was not being set
Jun 19, 2025
fcae0b4
Initial commit for example 71 to use ICPUPolygonGeometry
Jun 19, 2025
312ca61
pull Matt and resolve conflicts
AnastaZIuk Jun 19, 2025
e419580
docs docs docs, adjust to comments and test on 01 after updates
AnastaZIuk Jun 19, 2025
cfd609c
matrix math in linalg was fine, I made a typo
Jun 20, 2025
6242357
fix a caption bug
Jun 20, 2025
19df6e1
Merge remote-tracking branch 'remotes/origin/mlBuildUpdates' into mes…
Jun 21, 2025
19167c5
leave pointers on how to port example 62_CAD, also `EXCLUDE_FROM_ALL`…
Jun 21, 2025
a0622f3
kill old meshloaders example that didn't work since forever
Jun 21, 2025
f494d85
yes `NBL_EMBED_BUILTIN_RESOURCES` should control both Nable and examp…
Jun 21, 2025
ce268fb
Adjust all examples after splitting `MonoAssetManagerAndBuiltinResour…
Jun 21, 2025
20a5438
correct namespace ambiguities affecting example 23 and 29
Jun 21, 2025
21a88ff
aaah the `BuiltinResourcesApplication.hpp` header needs some special …
Jun 22, 2025
1b3c19c
make the `BuiltinResourcesApplication` work for examples without buil…
Jun 23, 2025
7ec6846
make CSwapchainFramebuffersAndDepth support runtime depth buffer resi…
Jun 23, 2025
64e7b26
remake example 61, not thoroughly tested, some TODOs remain for @Anas…
Jun 23, 2025
2872604
fix bugs in ex 61:
Jun 23, 2025
20cc57e
Push Mesh Loader example
Jun 24, 2025
86cc7dd
decouple `CSimpleDebugRenderer` from `CGeometryCreatorScene`
Jun 25, 2025
e790c84
more improvements to make the Simple Debug Renderer more runtime frie…
Jun 25, 2025
eaa1320
prep the conversion
Jun 25, 2025
5929be1
just some todo markup
Jun 26, 2025
52c1aa5
ready changes for mesh_loaders merge, requires examples.hpp from mesh…
keptsecret Jun 27, 2025
d596f75
merge mesh_loaders, fix conflict
keptsecret Jun 27, 2025
c43c93b
cpp fixes so it compiles at least
keptsecret Jun 27, 2025
8b31859
a bazillion fixes since last time bxdf usages changed
keptsecret Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 01_HelloCoreSystemAsset/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

// always include nabla first before std:: headers
#include "nabla.h"
// <nabla.h> public interface and common examples API, always include first before std:: headers
#include "nbl/examples/examples.hpp"

#include "nbl/system/IApplicationFramework.h"

Expand Down
6 changes: 3 additions & 3 deletions 02_HelloCompute/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class HelloComputeApp final : public nbl::application_templates::MonoSystemMonoL
// The convention is that an `ICPU` object represents a potentially Mutable (and in the past, Serializable) recipe for creating an `IGPU` object, and later examples will show automated systems for doing that.
// The Assets always form a Directed Acyclic Graph and our type system enforces that property at compile time (i.e. an `IBuffer` cannot reference an `IImageView` even indirectly).
// Another reason for the 1:1 pairing of types is that one can use a CPU-to-GPU associative cache (asset manager has a default one) and use the pointers to the CPU objects as UUIDs.
// The ICPUShader is just a mutable container for source code (can be high level like HLSL needing compilation to SPIR-V or SPIR-V itself) held in an `nbl::asset::ICPUBuffer`.
// The IShader is just a mutable container for source code (can be high level like HLSL needing compilation to SPIR-V or SPIR-V itself) held in an `nbl::asset::ICPUBuffer`.
// They can be created: from buffers of code, by compilation from some other source code, or loaded from files (next example will do that).
smart_refctd_ptr<nbl::asset::ICPUShader> cpuShader;
smart_refctd_ptr<nbl::asset::IShader> cpuShader;
{
// Normally we'd use the ISystem and the IAssetManager to load shaders flexibly from (virtual) files for ease of development (syntax highlighting and Intellisense),
// but I want to show the full process of assembling a shader from raw source code at least once.
Expand Down Expand Up @@ -138,7 +138,7 @@ class HelloComputeApp final : public nbl::application_templates::MonoSystemMonoL
}

// Note how each ILogicalDevice method takes a smart-pointer r-value, so that the GPU objects refcount their dependencies
smart_refctd_ptr<nbl::video::IGPUShader> shader = device->createShader(cpuShader.get());
smart_refctd_ptr<IShader> shader = device->compileShader({.source = cpuShader.get()});
if (!shader)
return logFail("Failed to create a GPU Shader, seems the Driver doesn't like the SPIR-V we're feeding it!\n");

Expand Down
26 changes: 14 additions & 12 deletions 03_DeviceSelectionAndSharedSources/Testers.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#ifndef _NBL_TESTERS_H_INCLUDED_
#define _NBL_TESTERS_H_INCLUDED_

#include "nbl/application_templates/MonoDeviceApplication.hpp"
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
#include "nbl/examples/examples.hpp"

using namespace nbl;

Expand All @@ -24,7 +23,7 @@ class IntrospectionTesterBase
const std::string m_functionToTestName = "";

protected:
static std::pair<smart_refctd_ptr<ICPUShader>, smart_refctd_ptr<const CSPIRVIntrospector::CStageIntrospectionData>> compileHLSLShaderAndTestIntrospection(
static std::pair<smart_refctd_ptr<IShader>, smart_refctd_ptr<const CSPIRVIntrospector::CStageIntrospectionData>> compileHLSLShaderAndTestIntrospection(
video::IPhysicalDevice* physicalDevice, video::ILogicalDevice* device, system::ILogger* logger, asset::IAssetManager* assetMgr, const std::string& shaderPath, CSPIRVIntrospector& introspector)
{
IAssetLoader::SAssetLoadParams lp = {};
Expand All @@ -33,15 +32,18 @@ class IntrospectionTesterBase
// this time we load a shader directly from a file
auto assetBundle = assetMgr->getAsset(shaderPath, lp);
const auto assets = assetBundle.getContents();
if (assets.empty())
const auto* metadata = assetBundle.getMetadata();
if (assets.empty() || assetBundle.getAssetType() != IAsset::ET_SHADER)
{
logFail(logger, "Could not load shader!");
assert(0);
}
const auto hlslMetadata = static_cast<const CHLSLMetadata*>(metadata);
const auto shaderStage = hlslMetadata->shaderStages->front();

// It would be super weird if loading a shader from a file produced more than 1 asset
assert(assets.size() == 1);
smart_refctd_ptr<ICPUShader> source = IAsset::castDown<ICPUShader>(assets[0]);
smart_refctd_ptr<IShader> source = IAsset::castDown<IShader>(assets[0]);

smart_refctd_ptr<const CSPIRVIntrospector::CStageIntrospectionData> introspection;
{
Expand All @@ -53,7 +55,7 @@ class IntrospectionTesterBase
// The Shader Asset Loaders deduce the stage from the file extension,
// if the extension is generic (.glsl or .hlsl) the stage is unknown.
// But it can still be overriden from within the source with a `#pragma shader_stage`
options.stage = source->getStage() == IShader::E_SHADER_STAGE::ESS_COMPUTE ? source->getStage() : IShader::E_SHADER_STAGE::ESS_VERTEX; // TODO: do smth with it
options.stage = shaderStage == IShader::E_SHADER_STAGE::ESS_COMPUTE ? shaderStage : IShader::E_SHADER_STAGE::ESS_VERTEX; // TODO: do smth with it
options.targetSpirvVersion = device->getPhysicalDevice()->getLimits().spirvVersion;
// we need to perform an unoptimized compilation with source debug info or we'll lose names of variable sin the introspection
options.spirvOptimizer = nullptr;
Expand Down Expand Up @@ -186,7 +188,7 @@ class PredefinedLayoutTester final : public IntrospectionTesterBase
constexpr uint32_t MERGE_TEST_SHADERS_CNT = mergeTestShadersPaths.size();

CSPIRVIntrospector introspector[MERGE_TEST_SHADERS_CNT];
smart_refctd_ptr<ICPUShader> sources[MERGE_TEST_SHADERS_CNT];
smart_refctd_ptr<IShader> sources[MERGE_TEST_SHADERS_CNT];

for (uint32_t i = 0u; i < MERGE_TEST_SHADERS_CNT; ++i)
{
Expand All @@ -201,7 +203,7 @@ class PredefinedLayoutTester final : public IntrospectionTesterBase
.binding = 0,
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
.createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
.stageFlags = ICPUShader::E_SHADER_STAGE::ESS_COMPUTE,
.stageFlags = IShader::E_SHADER_STAGE::ESS_COMPUTE,
.count = 1,
.immutableSamplers = nullptr
}
Expand All @@ -213,15 +215,15 @@ class PredefinedLayoutTester final : public IntrospectionTesterBase
.binding = 0,
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
.createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
.stageFlags = ICPUShader::E_SHADER_STAGE::ESS_COMPUTE,
.stageFlags = IShader::E_SHADER_STAGE::ESS_COMPUTE,
.count = 1,
.immutableSamplers = nullptr
},
{
.binding = 1,
.type = nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
.createFlags = ICPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE,
.stageFlags = ICPUShader::E_SHADER_STAGE::ESS_COMPUTE,
.stageFlags = IShader::E_SHADER_STAGE::ESS_COMPUTE,
.count = 2,
.immutableSamplers = nullptr
}
Expand Down Expand Up @@ -251,9 +253,9 @@ class PredefinedLayoutTester final : public IntrospectionTesterBase
bool pplnCreationSuccess[MERGE_TEST_SHADERS_CNT];
for (uint32_t i = 0u; i < MERGE_TEST_SHADERS_CNT; ++i)
{
ICPUShader::SSpecInfo specInfo;
ICPUPipelineBase::SShaderSpecInfo specInfo;
specInfo.entryPoint = "main";
specInfo.shader = sources[i].get();
specInfo.shader = sources[i];
pplnCreationSuccess[i] = static_cast<bool>(introspector[i].createApproximateComputePipelineFromIntrospection(specInfo, core::smart_refctd_ptr<ICPUPipelineLayout>(predefinedPplnLayout)));
}

Expand Down
41 changes: 25 additions & 16 deletions 03_DeviceSelectionAndSharedSources/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#include "nbl/application_templates/MonoDeviceApplication.hpp"
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
#include "CommonPCH/PCH.hpp"

#include "nbl/examples/examples.hpp"
// TODO: why isn't this in `nabla.h` ?
#include "nbl/asset/metadata/CHLSLMetadata.h"


using namespace nbl;
using namespace core;
using namespace system;
using namespace asset;
using namespace video;
using namespace nbl::core;
using namespace nbl::hlsl;
using namespace nbl::system;
using namespace nbl::asset;
using namespace nbl::ui;
using namespace nbl::video;
using namespace nbl::examples;

// TODO[Przemek]: update comments

Expand All @@ -21,10 +26,10 @@ using namespace video;
constexpr bool ENABLE_TESTS = false;

// This time we create the device in the base class and also use a base class to give us an Asset Manager and an already mounted built-in resource archive
class DeviceSelectionAndSharedSourcesApp final : public application_templates::MonoDeviceApplication, public application_templates::MonoAssetManagerAndBuiltinResourceApplication
class DeviceSelectionAndSharedSourcesApp final : public application_templates::MonoDeviceApplication, public BuiltinResourcesApplication
{
using device_base_t = application_templates::MonoDeviceApplication;
using asset_base_t = application_templates::MonoAssetManagerAndBuiltinResourceApplication;
using asset_base_t = BuiltinResourcesApplication;
public:
// Yay thanks to multiple inheritance we cannot forward ctors anymore
DeviceSelectionAndSharedSourcesApp(const path& _localInputCWD, const path& _localOutputCWD, const path& _sharedInputCWD, const path& _sharedOutputCWD) :
Expand Down Expand Up @@ -60,9 +65,9 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
//shaderIntrospection->debugPrint(m_logger.get());

// We've now skipped the manual creation of a descriptor set layout, pipeline layout
ICPUShader::SSpecInfo specInfo;
ICPUPipelineBase::SShaderSpecInfo specInfo;
specInfo.entryPoint = "main";
specInfo.shader = source.get();
specInfo.shader = source;

smart_refctd_ptr<nbl::asset::ICPUComputePipeline> cpuPipeline = introspector.createApproximateComputePipelineFromIntrospection(specInfo);

Expand Down Expand Up @@ -236,7 +241,7 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
// Whether to keep invoking the above. In this example because its headless GPU compute, we do all the work in the app initialization.
bool keepRunning() override { return false; }

std::pair<smart_refctd_ptr<ICPUShader>, smart_refctd_ptr<const CSPIRVIntrospector::CStageIntrospectionData>> compileShaderAndTestIntrospection(
std::pair<smart_refctd_ptr<IShader>, smart_refctd_ptr<const CSPIRVIntrospector::CStageIntrospectionData>> compileShaderAndTestIntrospection(
const std::string& shaderPath, CSPIRVIntrospector& introspector)
{
IAssetLoader::SAssetLoadParams lp = {};
Expand All @@ -245,15 +250,19 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
// this time we load a shader directly from a file
auto assetBundle = m_assetMgr->getAsset(shaderPath, lp);
const auto assets = assetBundle.getContents();
if (assets.empty())
if (assets.empty() || assetBundle.getAssetType() != IAsset::ET_SHADER)
{
logFail("Could not load shader!");
assert(0);
}

const auto* metadata = assetBundle.getMetadata();
const auto hlslMetadata = static_cast<const CHLSLMetadata*>(metadata);
const auto shaderStage = hlslMetadata->shaderStages->front();

// It would be super weird if loading a shader from a file produced more than 1 asset
assert(assets.size() == 1);
smart_refctd_ptr<ICPUShader> source = IAsset::castDown<ICPUShader>(assets[0]);
smart_refctd_ptr<IShader> source = IAsset::castDown<IShader>(assets[0]);

smart_refctd_ptr<const CSPIRVIntrospector::CStageIntrospectionData> introspection;
{
Expand All @@ -265,7 +274,7 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
// The Shader Asset Loaders deduce the stage from the file extension,
// if the extension is generic (.glsl or .hlsl) the stage is unknown.
// But it can still be overriden from within the source with a `#pragma shader_stage`
options.stage = source->getStage() == IShader::E_SHADER_STAGE::ESS_COMPUTE ? source->getStage() : IShader::E_SHADER_STAGE::ESS_VERTEX; // TODO: do smth with it
options.stage = shaderStage == IShader::E_SHADER_STAGE::ESS_COMPUTE ? shaderStage : IShader::E_SHADER_STAGE::ESS_VERTEX; // TODO: do smth with it
options.targetSpirvVersion = m_device->getPhysicalDevice()->getLimits().spirvVersion;
// we need to perform an unoptimized compilation with source debug info or we'll lose names of variable sin the introspection
options.spirvOptimizer = nullptr;
Expand All @@ -277,7 +286,7 @@ class DeviceSelectionAndSharedSourcesApp final : public application_templates::M
options.preprocessorOptions.includeFinder = compilerSet->getShaderCompiler(source->getContentType())->getDefaultIncludeFinder();

auto spirvUnspecialized = compilerSet->compileToSPIRV(source.get(), options);
const CSPIRVIntrospector::CStageIntrospectionData::SParams inspctParams = { .entryPoint = "main", .shader = spirvUnspecialized };
const CSPIRVIntrospector::CStageIntrospectionData::SParams inspctParams = { .entryPoint = "main", .shader = spirvUnspecialized, .stage = shaderStage };

introspection = introspector.introspect(inspctParams);
introspection->debugPrint(m_logger.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ template<typename capability_traits=nbl::hlsl::jit::device_capabilities_traits>
void dummyTraitTest() {}

[numthreads(WorkgroupSize,1,1)]
[shader("compute")]
void main(uint32_t3 ID : SV_DispatchThreadID)
{
dummyTraitTest();
Expand Down
19 changes: 8 additions & 11 deletions 05_StreamingAndBufferDeviceAddressApp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// I've moved out a tiny part of this example into a shared header for reuse, please open and read it.
#include "nbl/application_templates/MonoDeviceApplication.hpp"
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
#include "nbl/examples/common/BuiltinResourcesApplication.hpp"


using namespace nbl;
Expand All @@ -20,10 +20,10 @@ using namespace video;


// In this application we'll cover buffer streaming, Buffer Device Address (BDA) and push constants
class StreamingAndBufferDeviceAddressApp final : public application_templates::MonoDeviceApplication, public application_templates::MonoAssetManagerAndBuiltinResourceApplication
class StreamingAndBufferDeviceAddressApp final : public application_templates::MonoDeviceApplication, public examples::BuiltinResourcesApplication
{
using device_base_t = application_templates::MonoDeviceApplication;
using asset_base_t = application_templates::MonoAssetManagerAndBuiltinResourceApplication;
using asset_base_t = examples::BuiltinResourcesApplication;

// This is the first example that submits multiple workloads in-flight.
// What the shader does is it computes the minimum distance of each point against K other random input points.
Expand Down Expand Up @@ -91,7 +91,7 @@ class StreamingAndBufferDeviceAddressApp final : public application_templates::M
return false;

// this time we load a shader directly from a file
smart_refctd_ptr<IGPUShader> shader;
smart_refctd_ptr<IShader> shader;
{
IAssetLoader::SAssetLoadParams lp = {};
lp.logger = m_logger.get();
Expand All @@ -102,14 +102,10 @@ class StreamingAndBufferDeviceAddressApp final : public application_templates::M
return logFail("Could not load shader!");

// lets go straight from ICPUSpecializedShader to IGPUSpecializedShader
auto source = IAsset::castDown<ICPUShader>(assets[0]);
const auto shaderSource = IAsset::castDown<IShader>(assets[0]);
shader = m_device->compileShader({shaderSource.get()});
// The down-cast should not fail!
assert(source);

// this time we skip the use of the asset converter since the ICPUShader->IGPUShader path is quick and simple
shader = m_device->createShader(source.get());
if (!shader)
return logFail("Creation of a GPU Shader to from CPU Shader source failed!");
assert(shader);
}

// The StreamingTransientDataBuffers are actually composed on top of another useful utility called `CAsyncSingleBufferSubAllocator`
Expand Down Expand Up @@ -139,6 +135,7 @@ class StreamingAndBufferDeviceAddressApp final : public application_templates::M
IGPUComputePipeline::SCreationParams params = {};
params.layout = layout.get();
params.shader.shader = shader.get();
params.shader.entryPoint = "main";
if (!m_device->createComputePipelines(nullptr,{&params,1},&m_pipeline))
return logFail("Failed to create compute pipeline!\n");
}
Expand Down
20 changes: 11 additions & 9 deletions 06_HelloGraphicsQueue/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
// For conditions of distribution and use, see copyright notice in nabla.h


// I've moved out a tiny part of this example into a shared header for reuse, please open and read it.
#include "nbl/application_templates/MonoDeviceApplication.hpp"
#include "nbl/application_templates/MonoAssetManagerAndBuiltinResourceApplication.hpp"
#include "nbl/examples/examples.hpp"

#include "nbl/ext/ScreenShot/ScreenShot.h"


using namespace nbl;
using namespace core;
using namespace system;
using namespace asset;
using namespace video;
using namespace nbl::core;
using namespace nbl::hlsl;
using namespace nbl::system;
using namespace nbl::asset;
using namespace nbl::ui;
using namespace nbl::video;
using namespace nbl::examples;


// Here we showcase the use of Graphics Queue only
// Steps we take in this example:
Expand All @@ -26,10 +28,10 @@ using namespace video;
// - save the smallImg to disk
//
// all without using IUtilities.
class HelloGraphicsQueueApp final : public application_templates::MonoDeviceApplication, public application_templates::MonoAssetManagerAndBuiltinResourceApplication
class HelloGraphicsQueueApp final : public application_templates::MonoDeviceApplication, public BuiltinResourcesApplication
{
using device_base_t = application_templates::MonoDeviceApplication;
using asset_base_t = application_templates::MonoAssetManagerAndBuiltinResourceApplication;
using asset_base_t = BuiltinResourcesApplication;

public:
// Yay thanks to multiple inheritance we cannot forward ctors anymore.
Expand Down
6 changes: 0 additions & 6 deletions 06_MeshLoaders/CMakeLists.txt

This file was deleted.

Loading