|
11 | 11 | #include "nbl/ext/FullScreenTriangle/FullScreenTriangle.h" |
12 | 12 |
|
13 | 13 | #include "nbl/builtin/hlsl/luma_meter/common.hlsl" |
| 14 | +#include "nbl/builtin/hlsl/workgroup2/arithmetic_config.hlsl" |
14 | 15 | #include "app_resources/common.hlsl" |
15 | 16 |
|
16 | 17 | using namespace nbl; |
@@ -317,18 +318,26 @@ class AutoexposureApp final : public SimpleWindowedApplication, public BuiltinRe |
317 | 318 | const uint32_t workgroupSize = m_physicalDevice->getLimits().maxComputeWorkGroupInvocations; |
318 | 319 | const uint32_t subgroupSize = m_physicalDevice->getLimits().maxSubgroupSize; |
319 | 320 |
|
| 321 | + const uint32_t configItemsPerInvoc = MeterMode == MeteringMode::AVERAGE ? 1 : workgroupSize / BinCount; |
| 322 | + workgroup2::SArithmeticConfiguration wgConfig; |
| 323 | + wgConfig.init(hlsl::findMSB(workgroupSize), hlsl::log2(float(subgroupSize)), configItemsPerInvoc); |
| 324 | + |
320 | 325 | struct MacroDefines |
321 | 326 | { |
322 | 327 | std::string identifier; |
323 | 328 | std::string definition; |
324 | 329 | }; |
325 | | - const MacroDefines definesBuf[2] = { |
| 330 | + constexpr uint32_t NumDefines = 4; |
| 331 | + const MacroDefines definesBuf[NumDefines] = { |
326 | 332 | { "WORKGROUP_SIZE", std::to_string(workgroupSize) }, |
327 | | - { "SUBGROUP_SIZE", std::to_string(subgroupSize) } |
| 333 | + { "SUBGROUP_SIZE", std::to_string(subgroupSize) }, |
| 334 | + {"WG_CONFIG_T", wgConfig.getConfigTemplateStructString()}, |
| 335 | + {"NATIVE_SUBGROUP_ARITHMETIC", "1"} |
328 | 336 | }; |
329 | 337 |
|
| 338 | + const uint32_t defineCount = m_physicalDevice->getLimits().shaderSubgroupArithmetic ? NumDefines : NumDefines - 1; |
330 | 339 | std::vector<IShaderCompiler::SMacroDefinition> defines; |
331 | | - for (uint32_t i = 0; i < 2; i++) |
| 340 | + for (uint32_t i = 0; i < defineCount; i++) |
332 | 341 | defines.emplace_back(definesBuf[i].identifier, definesBuf[i].definition); |
333 | 342 | options.preprocessorOptions.extraDefines = defines; |
334 | 343 |
|
|
0 commit comments