-
Notifications
You must be signed in to change notification settings - Fork 4
02 Quick Start & Configuration
Afer you have successfully integrated LinaGX into your project, include the header:
#include "LinaGX/LinaGX.hpp"
Before everything else, setup the LinaGX configuration once:
LinaGX::Config.api = BackendAPI::Vulkan;
LinaGX::Config.gpu = PreferredGPUType::Discrete;
LinaGX::Config.framesInFlight = FRAMES_IN_FLIGHT;
LinaGX::Config.backbufferCount = BACK_BUFFER;
LinaGX::Config.gpuLimits = {};
LinaGX::Config.logLevel = LogLevel::Verbose;
LinaGX::Config.errorCallback = LogError;
LinaGX::Config.infoCallback = LogInfo;
LinaGX::Config structure allows you to customize runtime behaviour and define the initial state.
Configuration also allows you to setup GPU limits, and backend specific features. Check out the source code (CommonGfx.hpp) for more details.
LinaGX::Config.dx12Config.serializeShaderDebugSymbols = false;
LinaGX::Config.dx12Config.enableDebugLayers = true;
LinaGX::Config.vulkanConfig.enableVulkanFeatures = VulkanFeatureFlags::VKF_SamplerAnisotropy;
After you are done with the configuration, create a LinaGX instance:
LinaGX::Instance* m_lgx = new LinaGX::Instance();
m_lgx->Initialize();
Do not modify anything from the configuration after you have created a LinaGX instance.
Additionally, after you have created the instance, before initializing LinaGX you can query backend specific feature support:
m_lgx = new LinaGX::Instance();
// You can check supported features from the supported flag.
uint32 supported = m_lgx->VKQueryFeatureSupport(PreferredGPUType::Discrete);
const bool success = m_lgx->Initialize();
if (!success)
{
LOGA(false, "Current GPU does not support one of the features required by this example!");
}
Similarly, you can query e.g. format support:
std::vector<LinaGX::Format> formatSupport = {
Format::R32G32B32A32_SFLOAT,
Format::R16G16B16A16_SFLOAT,
Format::R16G16B16A16_UNORM,
Format::R8G8B8A8_SRGB,
Format::R8G8B8A8_UNORM,
Format::B8G8R8A8_UNORM,
};
for (auto fmt : formatSupport)
{
const LinaGX::FormatSupportInfo fsi = m_lgx->GetFormatSupport(fmt);
if (fsi.format == LinaGX::Format::UNDEFINED)
LOGE("Current GPU does not support the formats required by this example!");
}
Check out Instance.hpp for all documented functionalities!
Now all you need in order to start rendering is done, use the instance to perform graphics operations, and deallocate it before terminating your application.
delete m_lgx;