// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Config.h" #if COMPILE_WITH_SHADER_COMPILER namespace ShaderProcessing { struct ParserMacros { const Array* Data; ParserMacros(const Array& data) { Data = &data; } Token GetValue(Token& token) const { for (int32 i = 0; i < Data->Count(); i++) { if (token == Data->At(i).Name) { // Use macro value return Token(Data->At(i).Definition); } } // Fallback to token return token; } }; /// /// Interface describing shader source code parser /// class IShaderParser { public: /// /// Virtual destructor /// virtual ~IShaderParser() { } public: /// /// Gets the parser feature level of the target platform graphics backend. /// /// The graphics feature level virtual FeatureLevel GetFeatureLevel() const = 0; /// /// Gets the parser macros. /// /// The macros virtual ParserMacros GetMacros() const = 0; /// /// Gets value indicating that shader processing operation failed /// /// True if shader processing failed, otherwise false virtual bool Failed() const = 0; /// /// Gets source code reader /// /// Source code reader virtual Reader& GetReader() = 0; /// /// Event send to the parser on reading shader source code error /// /// Message to send virtual void OnError(const String& message) = 0; /// /// Event send to the parser on reading shader source code warning /// /// Message to send virtual void OnWarning(const String& message) = 0; }; } #endif