Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
345ac7b
Add 26_Autoexposure
nipunG314 Jul 19, 2024
87d4794
Change 26_Autoexposure to SimpleWindowedApplication
nipunG314 Jul 19, 2024
7a5ea7c
Build a staging buffer and upload exr image
nipunG314 Jul 24, 2024
5026a64
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Jul 24, 2024
5d63d04
Init surface and create the swapchain
nipunG314 Jul 25, 2024
640e6a3
Load shaders and create the pipeline for full screen triagnle
nipunG314 Jul 25, 2024
0148f60
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Jul 25, 2024
d69a111
Set window size according to loaded image
nipunG314 Jul 25, 2024
54bf38f
Stop running if window is closed
nipunG314 Jul 25, 2024
461efd3
Acquire swapchain image and present uploaded image to it
nipunG314 Jul 26, 2024
734fea9
Set window size directly and use that for swapchain rendering
nipunG314 Jul 26, 2024
fc9b0bb
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Jul 26, 2024
4a11724
m_computeSubgroupSize
nipunG314 Aug 5, 2024
734b887
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Aug 5, 2024
7d4895a
Allocate buffer for gathered luma values
nipunG314 Aug 8, 2024
0e3e125
Create gpu resources for all passes
nipunG314 Aug 9, 2024
cef80b3
Create shaders and pipelines
nipunG314 Aug 9, 2024
15e489f
Allocate and create texture for tonemapping
nipunG314 Aug 12, 2024
c646c7d
Create separate ds for luma and present
nipunG314 Aug 12, 2024
36d7097
Record luma meter commands
nipunG314 Aug 13, 2024
3a70977
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Aug 13, 2024
6addbf1
fix layout issues with compute pipeline in 26_Autoexposure example + …
AnastaZIuk Aug 13, 2024
8434f20
Create two sets from common lumaPresentLayout correctly
nipunG314 Aug 13, 2024
bf08caa
Create compute and graphics resources separately and finish luma meter
nipunG314 Aug 13, 2024
b342c6c
Fix descriptor binding for luma_meter
nipunG314 Aug 13, 2024
817c4a7
Create separate pipeline layouts for luma and present
nipunG314 Aug 13, 2024
7f89542
Setup luma_meter.comp.hlsl
nipunG314 Aug 13, 2024
defd45e
Pass push constants
nipunG314 Aug 13, 2024
f6f8154
Record draw pass correctly
nipunG314 Aug 14, 2024
64eb610
Add a pipeline barrier to transition image layout
nipunG314 Aug 14, 2024
3d3d646
Record tonemapping pass
nipunG314 Aug 14, 2024
b4102dc
Revert "Record tonemapping pass"
nipunG314 Aug 15, 2024
8307e92
Remove separate tonemapping pass
nipunG314 Aug 15, 2024
7b5ca05
Compute final EV value on CPU
nipunG314 Aug 16, 2024
edbf8d1
Compute EV correctly and tonemap in fragment shader
nipunG314 Aug 16, 2024
dca49d2
Separate LumaMeteringWindow into a common header
nipunG314 Aug 20, 2024
9e28395
Simplify luma_meter naming
nipunG314 Aug 20, 2024
8b6675b
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Aug 20, 2024
18fae9f
Update luma examples to shared accessor api
nipunG314 Aug 20, 2024
9b31c2c
Refactor tonemapping operators
nipunG314 Aug 20, 2024
e987452
Simplify push constants and remove explicit sample counts
nipunG314 Aug 21, 2024
e135e43
Infer sample count from viewportSize and simplify userspace HLSL
nipunG314 Aug 21, 2024
57e49ae
Templatize float type and add toXYZ method to TexAccessor
nipunG314 Aug 22, 2024
f8d50e8
Refactor the example into using a 2-compute, 1-fragment architecture
nipunG314 Aug 27, 2024
d3b5765
Handle image layouts correctly
nipunG314 Aug 28, 2024
612f0f6
Simplify type
nipunG314 Sep 27, 2024
cb46d82
Wait for correct semaphore value
nipunG314 Sep 27, 2024
1996cf3
Remove unnecessary data members
nipunG314 Sep 29, 2024
36633f5
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Dec 11, 2024
bc11b4a
Use asset converter for images and descriptors
nipunG314 Dec 14, 2024
f79caed
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
nipunG314 Jan 14, 2025
3a94cd4
Rewrite descriptor set logic
nipunG314 Jan 15, 2025
462e220
Replace dot with mul
nipunG314 Jan 15, 2025
9e26a74
Replace combined image sampler with RWTexture2D
nipunG314 Jan 15, 2025
208a58a
use a single asset converter throughout, always call `convert` to mak…
Jan 21, 2025
10b6690
Transition m_tonemappedImgView to GENERAL
nipunG314 Jan 23, 2025
21995ea
Keep direct track of m_gatherBuffer
nipunG314 Jan 23, 2025
06dad8c
yay another DXC bug that was an absolute joy to debug, why on earth w…
Jan 23, 2025
dc457ca
Create a Texture2D descriptor for the fragment shader
nipunG314 Mar 13, 2025
e7c4160
Add median metering mode
nipunG314 Mar 15, 2025
3eb06b7
Use correct reinhard parameters
nipunG314 Mar 16, 2025
498ffd2
Fix autoexposure sample
nipunG314 Mar 16, 2025
2949212
merge master, fix conflicts
keptsecret Dec 3, 2025
1d82130
fixes missing shader type attribute, added check for required defines
keptsecret Dec 3, 2025
75c7530
fix shader compilation access violation
keptsecret Dec 3, 2025
68dfd1b
Merge branch 'master' into autoexposure_ex
keptsecret Jan 12, 2026
a9762cd
refactor morton usage
keptsecret Jan 12, 2026
570fc93
refactor luma_meter and tonemap ops reorganization
keptsecret Jan 12, 2026
e07df94
Merge branch 'master' into autoexposure_ex
keptsecret Jan 30, 2026
ea2b1b9
use new morton class
keptsecret Jan 30, 2026
e3f1d35
fixes (+removals) to make it work like old glsl version, use correct …
keptsecret Jan 30, 2026
7680a95
Merge branch 'master' into autoexposure_ex
keptsecret Feb 2, 2026
42ed25a
fixes to get it to compile after merge from master + old bugs in median
keptsecret Feb 2, 2026
a15508e
fixes histogram autoexposure
keptsecret Feb 3, 2026
9c330d3
clean up push constant usage, more values in push constant
keptsecret Feb 3, 2026
233db45
rename defines to all caps, refactor luma meter template names
keptsecret Feb 3, 2026
80fd063
Merge branch 'master' into autoexposure_ex
keptsecret Feb 4, 2026
de38929
fix change from master that broke
keptsecret Feb 5, 2026
ea585f5
added temporal adaptation
keptsecret Feb 5, 2026
e1d1cb1
minor fixes
keptsecret Feb 5, 2026
9f86c09
refactor to use workgroup2 stuff in cpp and average metering
keptsecret Feb 5, 2026
5e27920
merge master, fix conflicts
keptsecret Feb 6, 2026
7c5d3b4
refactor to use workgroup2 with histogram metering, some more defines…
keptsecret Feb 6, 2026
d46e463
fix calculating sampling area uv for luma metering
keptsecret Feb 6, 2026
77ec3d5
check range on tonemap output
keptsecret Feb 6, 2026
59117a8
small fix to oob bug
keptsecret Feb 6, 2026
d104945
refactor uv fix, minor bug fixes
keptsecret Feb 9, 2026
986492e
removed semantically incorrect naming of gl_WorkgroupSize()
keptsecret Feb 9, 2026
07ad5db
added in temp dithering factor, fix usage of histogram metering perce…
keptsecret Feb 9, 2026
1e012c0
ping pong buffer for last frame EV, removed tonemap output oetf becau…
keptsecret Feb 10, 2026
df7f7ed
removed sampleCount param (unused), made subgroup size member
keptsecret Feb 10, 2026
8b93ee5
implement frames in flight
keptsecret Feb 10, 2026
0804333
add eotf, removed fake dither factor
keptsecret Feb 10, 2026
f6b1b7d
use median + aces
keptsecret Feb 10, 2026
27ff451
made tonemapped image same size as input img
keptsecret Feb 11, 2026
9482f15
moved push constant out to nabla
keptsecret Feb 12, 2026
ca0e50e
refactor minor changes to luma meter
keptsecret Feb 12, 2026
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
12 changes: 0 additions & 12 deletions 23_Autoexposure/CMakeLists.txt

This file was deleted.

177 changes: 0 additions & 177 deletions 23_Autoexposure/main.cpp

This file was deleted.

33 changes: 33 additions & 0 deletions 26_Autoexposure/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

include(common RESULT_VARIABLE RES)
if(NOT RES)
message(FATAL_ERROR "common.cmake not found. Should be in {repo_root}/cmake directory")
endif()

set(NBL_INCLUDE_SERACH_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/include"
)

list(APPEND NBL_LIBRARIES
Nabla::ext::FullScreenTriangle
)

nbl_create_executable_project("" "" "${NBL_INCLUDE_SERACH_DIRECTORIES}" "${NBL_LIBRARIES}" "${NBL_EXECUTABLE_PROJECT_CREATION_PCH_TARGET}")

if(NBL_EMBED_BUILTIN_RESOURCES)
set(_BR_TARGET_ ${EXECUTABLE_NAME}_builtinResourceData)
set(RESOURCE_DIR "app_resources")

get_filename_component(_SEARCH_DIRECTORIES_ "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_SOURCE_ "${CMAKE_CURRENT_BINARY_DIR}/src" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_HEADER_ "${CMAKE_CURRENT_BINARY_DIR}/include" ABSOLUTE)

file(GLOB_RECURSE BUILTIN_RESOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}" CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}/*")
foreach(RES_FILE ${BUILTIN_RESOURCE_FILES})
LIST_BUILTIN_RESOURCE(RESOURCES_TO_EMBED "${RES_FILE}")
endforeach()

ADD_CUSTOM_BUILTIN_RESOURCES(${_BR_TARGET_} RESOURCES_TO_EMBED "${_SEARCH_DIRECTORIES_}" "${RESOURCE_DIR}" "nbl::this_example::builtin" "${_OUTPUT_DIRECTORY_HEADER_}" "${_OUTPUT_DIRECTORY_SOURCE_}")

LINK_BUILTIN_RESOURCES_TO_TARGET(${EXECUTABLE_NAME} ${_BR_TARGET_})
endif()
65 changes: 65 additions & 0 deletions 26_Autoexposure/app_resources/avg_luma_meter.comp.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Copyright (C) 2024-2024 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#include "nbl/builtin/hlsl/luma_meter/geom_mean.hlsl"
#include "nbl/builtin/hlsl/bda/bda_accessor.hlsl"
#include "nbl/builtin/hlsl/colorspace/encodeCIEXYZ.hlsl"
#include "app_resources/common.hlsl"

[[vk::combinedImageSampler]] [[vk::binding(0, 0)]] Texture2D texture;
[[vk::combinedImageSampler]] [[vk::binding(0, 0)]] SamplerState samplerState;

using namespace nbl::hlsl;
using Ptr = bda::__ptr < uint32_t >;
using PtrAccessor = BdaAccessor < uint32_t >;

[[vk::push_constant]] luma_meter::PushConstants pushData;

groupshared float32_t sdata[WORKGROUP_SIZE];
struct SharedAccessor
{
using type = float32_t;
template<typename AccessType, typename IndexType>
void get(const uint32_t ix, NBL_REF_ARG(AccessType) value)
{
value = sdata[ix];
}
template<typename AccessType, typename IndexType>
void set(const uint32_t ix, const AccessType value)
{
sdata[ix] = value;
}

void workgroupExecutionAndMemoryBarrier()
{
glsl::barrier();
}
};

struct TexAccessor
{
static float32_t toXYZ(float32_t3 srgbColor) {
return dot(colorspace::sRGBtoXYZ[1], srgbColor);
}

float32_t3 get(float32_t2 uv) {
return texture.SampleLevel(samplerState, uv, 0.f).rgb;
}
};

[numthreads(SUBGROUP_SIZE, SUBGROUP_SIZE, 1)]
[shader("compute")]
void main(uint32_t3 ID : SV_GroupThreadID, uint32_t3 GroupID : SV_GroupID)
{
const Ptr val_ptr = Ptr::create(pushData.pLumaMeterBuf);
PtrAccessor val_accessor = PtrAccessor::create(val_ptr);

SharedAccessor sdata;
TexAccessor tex;

using LumaMeter = luma_meter::geom_meter<wg_config_t, PtrAccessor, SharedAccessor, TexAccessor, device_capabilities>;
LumaMeter meter = LumaMeter::create(pushData.lumaMin, pushData.lumaMax, pushData.meanParams.rcpFirstPassWGCount);

meter.sampleLuma(pushData.window, val_accessor, tex, sdata);
}
96 changes: 96 additions & 0 deletions 26_Autoexposure/app_resources/avg_luma_tonemap.comp.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (C) 2024-2024 - DevSH Graphics Programming Sp. z O.O.
// This file is part of the "Nabla Engine".
// For conditions of distribution and use, see copyright notice in nabla.h

#include "nbl/builtin/hlsl/luma_meter/geom_mean.hlsl"
#include "nbl/builtin/hlsl/bda/bda_accessor.hlsl"
#include "nbl/builtin/hlsl/colorspace/EOTF.hlsl"
#include "nbl/builtin/hlsl/colorspace/encodeCIEXYZ.hlsl"
#include "nbl/builtin/hlsl/colorspace/decodeCIEXYZ.hlsl"
#include "nbl/builtin/hlsl/colorspace/OETF.hlsl"
#include "nbl/builtin/hlsl/tonemapper/operators/reinhard.hlsl"
#include "nbl/builtin/hlsl/tonemapper/operators/aces.hlsl"
#include "app_resources/common.hlsl"

[[vk::combinedImageSampler]] [[vk::binding(0, 0)]] Texture2D textureIn;
[[vk::combinedImageSampler]] [[vk::binding(0, 0)]] SamplerState samplerStateIn;
[[vk::binding(0, 3)]] RWTexture2D<float32_t4> textureOut;

using namespace nbl::hlsl;
using Ptr = bda::__ptr < uint32_t >;
using PtrAccessor = BdaAccessor < uint32_t >;

[[vk::push_constant]] luma_meter::PushConstants pushData;

groupshared float32_t sdata[WORKGROUP_SIZE];
struct SharedAccessor
{
using type = float32_t;
template<typename AccessType, typename IndexType>
void get(const uint32_t ix, NBL_REF_ARG(AccessType) value)
{
value = sdata[ix];
}
template<typename AccessType, typename IndexType>
void set(const uint32_t ix, const AccessType value)
{
sdata[ix] = value;
}

void workgroupExecutionAndMemoryBarrier()
{
glsl::barrier();
}
};

struct TexAccessor
{
static float32_t3 toXYZ(float32_t3 srgbColor) {
return dot(colorspace::sRGBtoXYZ[1], srgbColor);
}

float32_t3 get(float32_t2 uv) {
return textureIn.SampleLevel(samplerStateIn, uv, 0.f).rgb;
}
};

[numthreads(SUBGROUP_SIZE, SUBGROUP_SIZE, 1)]
[shader("compute")]
void main(uint32_t3 ID : SV_GroupThreadID, uint32_t3 GroupID : SV_GroupID)
{
const Ptr val_ptr = Ptr::create(pushData.pLumaMeterBuf);
PtrAccessor val_accessor = PtrAccessor::create(val_ptr);

SharedAccessor sdata;
TexAccessor tex;

using LumaMeter = luma_meter::geom_meter<wg_config_t, PtrAccessor, SharedAccessor, TexAccessor, device_capabilities>;
LumaMeter meter = LumaMeter::create(pushData.lumaMin, pushData.lumaMax, pushData.meanParams.rcpFirstPassWGCount);

float32_t EV = meter.gatherLuma(val_accessor);

const float32_t lumaDiff = vk::RawBufferLoad<float32_t>(pushData.pLastFrameEVBuf) - EV;
EV += lumaDiff * mix(pushData.exposureAdaptationFactors.x, pushData.exposureAdaptationFactors.y, lumaDiff >= 0.0);

uint32_t tid = workgroup::SubgroupContiguousIndex();
if (all(glsl::gl_WorkGroupID() == uint32_t3(0,0,0)))
if (tid == 0)
vk::RawBufferStore<float32_t>(pushData.pCurrFrameEVBuf, EV);

morton::code<false, 32, 2> mc;
mc.value = tid;
uint32_t2 coord = _static_cast<uint32_t2>(mc);

uint32_t2 pos = (glsl::gl_WorkGroupID() * SUBGROUP_SIZE).xy + coord;
if (any(pos < promote<uint32_t2>(0u)) || any(pos >= pushData.viewportSize))
return;

float32_t2 uv = float32_t2(pos) / float32_t2(pushData.viewportSize);
float32_t3 color = tex.get(uv).rgb;
float32_t3 CIEColor = mul(colorspace::sRGBtoXYZ, color);
// tonemapper::Reinhard<float32_t> reinhard = tonemapper::Reinhard<float32_t>::create(EV, 0.18f, 0.85f);
tonemapper::ACES<float32_t> aces = tonemapper::ACES<float32_t>::create(EV, 0.18f, 0.85f);
float32_t3 tonemappedColor = mul(colorspace::decode::XYZtoscRGB, aces(CIEColor));

textureOut[pos] = float32_t4(tonemappedColor, 1.0f);
}
Loading