Skip to content

Commit d46e463

Browse files
committed
fix calculating sampling area uv for luma metering
1 parent 7c5d3b4 commit d46e463

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

26_Autoexposure/main.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class AutoexposureApp final : public SimpleWindowedApplication, public BuiltinRe
4545
constexpr static inline MeteringMode MeterMode = MeteringMode::MEDIAN;
4646
constexpr static inline uint32_t BinCount = 1024;
4747
constexpr static inline uint32_t2 Dimensions = { 1280, 720 };
48-
constexpr static inline float32_t2 MeteringWindowScale = { 0.8f, 0.8f };
49-
constexpr static inline float32_t2 MeteringWindowOffset = { 0.1f, 0.1f };
48+
constexpr static inline float32_t2 MeteringMinUV = { 0.1f, 0.1f };
49+
constexpr static inline float32_t2 MeteringMaxUV = { 0.9f, 0.9f };
50+
constexpr static inline float32_t SamplingFactor = 2.f;
5051
constexpr static inline float32_t2 LumaRange = { 1.0f / 2048.0f, 65536.f };
5152
constexpr static inline float32_t2 PercentileRange = { 0.45f, 0.55f };
5253
constexpr static inline float32_t2 BaseExposureAdaptationFactorsLog2 = {-1.1f, -0.2f};
@@ -799,7 +800,6 @@ class AutoexposureApp final : public SimpleWindowedApplication, public BuiltinRe
799800

800801
auto pc = AutoexposurePushData
801802
{
802-
.window = hlsl::luma_meter::MeteringWindow::create(MeteringWindowScale, MeteringWindowOffset),
803803
.lumaMin = LumaRange.x,
804804
.lumaMax = LumaRange.y,
805805
.viewportSize = Dimensions,
@@ -818,11 +818,15 @@ class AutoexposureApp final : public SimpleWindowedApplication, public BuiltinRe
818818
cmdbuf->reset(IGPUCommandBuffer::RESET_FLAGS::NONE);
819819
auto ds = m_gpuImgDS.get();
820820

821-
const uint32_t2 dispatchSize = {
822-
1 + ((gpuImgExtent.width / 2) - 1) / SubgroupSize,
823-
1 + ((gpuImgExtent.height / 2) - 1) / SubgroupSize
824-
};
821+
const float32_t2 meteringUVRange = MeteringMaxUV - MeteringMinUV;
822+
823+
//const uint32_t2 dispatchSize = {
824+
// 1 + ((gpuImgExtent.width / 2) - 1) / SubgroupSize,
825+
// 1 + ((gpuImgExtent.height / 2) - 1) / SubgroupSize
826+
//};
827+
const uint32_t2 dispatchSize = uint32_t2(hlsl::ceil(float32_t2(gpuImgExtent.width, gpuImgExtent.height) * meteringUVRange / (SubgroupSize * SamplingFactor)));
825828

829+
pc.window = luma_meter::MeteringWindow::create(meteringUVRange / (float32_t2(dispatchSize) * float(SubgroupSize)), MeteringMinUV);
826830
pc.rcpFirstPassWGCount = 1.f / float(dispatchSize.x * dispatchSize.y);
827831

828832
cmdbuf->begin(IGPUCommandBuffer::USAGE::ONE_TIME_SUBMIT_BIT);

0 commit comments

Comments
 (0)