Commit 0d411eb0 authored by Lukas Tietze's avatar Lukas Tietze

Makros beim Kompilieren

parent a437e104
...@@ -80,6 +80,33 @@ namespace lib ...@@ -80,6 +80,33 @@ namespace lib
None, None,
}; };
/**
* @brief Makrodefinition f眉r den Compiler. Es k枚nnen Name und Wert angegeben werden.
*/
struct CompilerMacro
{
/**
* @brief Initialisiert eine neue Instanz der Compiler Macro Klasse.
*
* @param name Der Name.
* @param value Der Wert (optional)
*/
inline CompilerMacro(std::string name, std::string value = "")
: name(name),
value(value)
{}
/**
* @brief Der Name des Makros, also der zu ersetzende Text.
*/
std::string name;
/**
* @brief Der Wert des Makros.
*/
std::string value;
};
/** /**
* @brief Enth盲lt Optionen f眉r die Kompilierung eines Shaders. * @brief Enth盲lt Optionen f眉r die Kompilierung eines Shaders.
*/ */
...@@ -89,6 +116,11 @@ namespace lib ...@@ -89,6 +116,11 @@ namespace lib
* @brief Optimierungslevel. * @brief Optimierungslevel.
*/ */
ShaderOptimizationLevel optimizationLevel = lib::IsDebug ? ShaderOptimizationLevel::Debug : ShaderOptimizationLevel::Performance; ShaderOptimizationLevel optimizationLevel = lib::IsDebug ? ShaderOptimizationLevel::Debug : ShaderOptimizationLevel::Performance;
/**
* @brief Eine Auflistung von Makros, die beim Kompilieren definiert sein sollen.
*/
std::vector<CompilerMacro> macros;
}; };
/** /**
......
...@@ -289,8 +289,7 @@ void lib::CgContext::CreateRasterizationFrameBuffers() ...@@ -289,8 +289,7 @@ void lib::CgContext::CreateRasterizationFrameBuffers()
}, },
this->swapChainImageFormat, this->swapChainImageFormat,
vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eSampled |
vk::ImageUsageFlagBits::eStorage | vk::ImageUsageFlagBits::eStorage,
vk::ImageUsageFlagBits::eColorAttachment,
vk::ImageLayout::eGeneral}; vk::ImageLayout::eGeneral};
auto newTexture = new lib::Texture{this, auto newTexture = new lib::Texture{this,
......
...@@ -11,9 +11,8 @@ ...@@ -11,9 +11,8 @@
#include "Util/Logging.hpp" #include "Util/Logging.hpp"
#include "Util/Io.hpp" #include "Util/Io.hpp"
using lib::log::Info;
using lib::log::Error; using lib::log::Error;
using lib::log::Info;
using lib::log::Warning; using lib::log::Warning;
namespace namespace
...@@ -134,6 +133,11 @@ bool lib::CompileShader(const std::string &glsl, const lib::ShaderInfo &info, li ...@@ -134,6 +133,11 @@ bool lib::CompileShader(const std::string &glsl, const lib::ShaderInfo &info, li
options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1); options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1);
options.SetSourceLanguage(shaderc_source_language_glsl); options.SetSourceLanguage(shaderc_source_language_glsl);
for (const auto &macro : info.compileOptions.macros)
{
options.AddMacroDefinition(macro.name, macro.value);
}
switch (info.compileOptions.optimizationLevel) switch (info.compileOptions.optimizationLevel)
{ {
case lib::ShaderOptimizationLevel::Debug: case lib::ShaderOptimizationLevel::Debug:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment