mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-24 21:55:09 +00:00
feat(materialx): Add constexpr check for hwAiryFresnelIterations and improve logging
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
@@ -126,6 +127,11 @@ std::string JoinTokens(const std::vector<std::string>& tokens, size_t limit) {
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr bool HasHwAiryFresnelIterations = requires(const T& options) {
|
||||
options.hwAiryFresnelIterations;
|
||||
};
|
||||
|
||||
void ApplyTokenSubstitutions(const mx::ShaderGenerator& generator,
|
||||
std::string& source,
|
||||
const std::string& stageLabel,
|
||||
@@ -171,9 +177,14 @@ unsigned int ResolveAiryFresnelIterations(const mx::GenContext& context,
|
||||
constexpr unsigned int kDefaultAiryFresnelIterations = 4;
|
||||
unsigned int iterations = kDefaultAiryFresnelIterations;
|
||||
bool fromOptions = false;
|
||||
if constexpr (requires { context.getOptions().hwAiryFresnelIterations; }) {
|
||||
using OptionsType = std::remove_reference_t<decltype(context.getOptions())>;
|
||||
constexpr bool kHasHwAiryFresnelIterations = HasHwAiryFresnelIterations<OptionsType>;
|
||||
if constexpr (kHasHwAiryFresnelIterations) {
|
||||
iterations = context.getOptions().hwAiryFresnelIterations;
|
||||
fromOptions = true;
|
||||
} else if (logger) {
|
||||
logger->Trace("MaterialXShaderGenerator", "Generate",
|
||||
"airyFresnelIterationsOption=unavailable");
|
||||
}
|
||||
if (logger) {
|
||||
logger->Trace("MaterialXShaderGenerator", "Generate",
|
||||
|
||||
Reference in New Issue
Block a user