Only use imgui in debug builds
This commit is contained in:
parent
c92a62db3e
commit
91f66ef952
4 changed files with 41 additions and 12 deletions
|
@ -44,16 +44,25 @@ IMPORTED_LOCATION ${ASSIMP_IMPORTED_PATH})
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${ASSIMP_INCLUDE_DIRS})
|
INTERFACE_INCLUDE_DIRECTORIES ${ASSIMP_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(Graph
|
set(GRAPH_SRC
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
src/renderer.cpp
|
src/renderer.cpp
|
||||||
src/worldpass.cpp
|
src/worldpass.cpp
|
||||||
src/postpass.cpp
|
src/postpass.cpp
|
||||||
src/dofpass.cpp
|
src/dofpass.cpp
|
||||||
src/imguipass.cpp
|
|
||||||
src/skypass.cpp
|
src/skypass.cpp
|
||||||
src/shadowpass.cpp
|
src/shadowpass.cpp
|
||||||
src/config.cpp)
|
src/config.cpp)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(GRAPH_SRC
|
||||||
|
${GRAPH_SRC}
|
||||||
|
src/imguipass.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_executable(Graph
|
||||||
|
${GRAPH_SRC})
|
||||||
|
|
||||||
target_compile_options(Graph
|
target_compile_options(Graph
|
||||||
PUBLIC
|
PUBLIC
|
||||||
-fno-exceptions
|
-fno-exceptions
|
||||||
|
@ -64,8 +73,13 @@ target_link_libraries(Graph
|
||||||
Vulkan::Vulkan
|
Vulkan::Vulkan
|
||||||
assimp::assimp
|
assimp::assimp
|
||||||
nlohmann::json
|
nlohmann::json
|
||||||
stb::stb
|
stb::stb)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
target_link_libraries(Graph
|
||||||
|
PUBLIC
|
||||||
imgui::imgui)
|
imgui::imgui)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(Graph
|
target_include_directories(Graph
|
||||||
PUBLIC
|
PUBLIC
|
||||||
|
|
|
@ -188,7 +188,9 @@ private:
|
||||||
WorldPass* worldPass_ = nullptr;
|
WorldPass* worldPass_ = nullptr;
|
||||||
PostPass* postPass_ = nullptr;
|
PostPass* postPass_ = nullptr;
|
||||||
DoFPass* dofPass_ = nullptr;
|
DoFPass* dofPass_ = nullptr;
|
||||||
|
#ifdef DEBUG
|
||||||
ImGuiPass* imguiPass_ = nullptr;
|
ImGuiPass* imguiPass_ = nullptr;
|
||||||
|
#endif
|
||||||
SkyPass* skyPass_ = nullptr;
|
SkyPass* skyPass_ = nullptr;
|
||||||
ShadowPass* shadowPass_ = nullptr;
|
ShadowPass* shadowPass_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -221,12 +221,14 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
SDL_SetWindowFullscreen(window, windowFullscreen == 1 ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
SDL_SetWindowFullscreen(window, windowFullscreen == 1 ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
|
|
||||||
auto& io = ImGui::GetIO();
|
auto& io = ImGui::GetIO();
|
||||||
io.DisplaySize = ImVec2(windowWidth, windowHeight);
|
io.DisplaySize = ImVec2(windowWidth, windowHeight);
|
||||||
|
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
|
#endif
|
||||||
|
|
||||||
renderer = new Renderer(graphicsConfig);
|
renderer = new Renderer(graphicsConfig);
|
||||||
|
|
||||||
|
@ -272,7 +274,9 @@ int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
if(event.type == SDL_WINDOWEVENT) {
|
if(event.type == SDL_WINDOWEVENT) {
|
||||||
if(event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
if(event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||||
|
#ifdef DEBUG
|
||||||
io.DisplaySize = ImVec2(event.window.data1, event.window.data2);
|
io.DisplaySize = ImVec2(event.window.data1, event.window.data2);
|
||||||
|
#endif
|
||||||
|
|
||||||
target = renderer->createSurfaceRenderTarget(surface, target);
|
target = renderer->createSurfaceRenderTarget(surface, target);
|
||||||
}
|
}
|
||||||
|
@ -349,6 +353,7 @@ int main(int argc, char* argv[]) {
|
||||||
const float deltaTime = currentTime - lastTime;
|
const float deltaTime = currentTime - lastTime;
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
|
|
||||||
io.DeltaTime = deltaTime;
|
io.DeltaTime = deltaTime;
|
||||||
|
@ -370,6 +375,8 @@ int main(int argc, char* argv[]) {
|
||||||
ImGui::Text("dpack[2] = %f", (100 - camera.focusDistance) / 100.0f);
|
ImGui::Text("dpack[2] = %f", (100 - camera.focusDistance) / 100.0f);
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
|
#endif
|
||||||
|
|
||||||
renderer->render(world, camera, target);
|
renderer->render(world, camera, target);
|
||||||
|
|
||||||
if(cinematicMode) {
|
if(cinematicMode) {
|
||||||
|
|
|
@ -30,7 +30,9 @@ Renderer::Renderer(GraphicsConfig config) : config_(config) {
|
||||||
worldPass_ = new WorldPass(*this);
|
worldPass_ = new WorldPass(*this);
|
||||||
postPass_ = new PostPass(*this);
|
postPass_ = new PostPass(*this);
|
||||||
dofPass_ = new DoFPass(*this);
|
dofPass_ = new DoFPass(*this);
|
||||||
|
#ifdef DEBUG
|
||||||
imguiPass_ = new ImGuiPass(*this);
|
imguiPass_ = new ImGuiPass(*this);
|
||||||
|
#endif
|
||||||
skyPass_ = new SkyPass(*this);
|
skyPass_ = new SkyPass(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +40,9 @@ Renderer::~Renderer() {
|
||||||
vkDeviceWaitIdle(device_);
|
vkDeviceWaitIdle(device_);
|
||||||
|
|
||||||
delete skyPass_;
|
delete skyPass_;
|
||||||
|
#ifdef DEBUG
|
||||||
delete imguiPass_;
|
delete imguiPass_;
|
||||||
|
#endif
|
||||||
delete dofPass_;
|
delete dofPass_;
|
||||||
delete postPass_;
|
delete postPass_;
|
||||||
delete worldPass_;
|
delete worldPass_;
|
||||||
|
@ -127,7 +131,9 @@ void Renderer::render(World& world, Camera& camera, RenderTarget* target) {
|
||||||
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
postPass_->render(commandBuffer, target);
|
postPass_->render(commandBuffer, target);
|
||||||
|
#ifdef DEBUG
|
||||||
imguiPass_->render(commandBuffer, target);
|
imguiPass_->render(commandBuffer, target);
|
||||||
|
#endif
|
||||||
|
|
||||||
vkCmdEndRenderPass(commandBuffer);
|
vkCmdEndRenderPass(commandBuffer);
|
||||||
|
|
||||||
|
@ -1155,39 +1161,39 @@ void Renderer::destroyMeshBuffers(Mesh* mesh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::createInstance() {
|
void Renderer::createInstance() {
|
||||||
|
std::vector<const char*> enabledLayers;
|
||||||
|
#ifdef DEBUG
|
||||||
uint32_t layerCount = 0;
|
uint32_t layerCount = 0;
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||||
|
|
||||||
auto availableLayers = new VkLayerProperties[layerCount];
|
auto availableLayers = new VkLayerProperties[layerCount];
|
||||||
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers);
|
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers);
|
||||||
|
|
||||||
std::vector<const char*> enabledLayers;
|
|
||||||
#ifdef DEBUG
|
|
||||||
for(uint32_t i = 0; i < layerCount; i++) {
|
for(uint32_t i = 0; i < layerCount; i++) {
|
||||||
if(strcmp(availableLayers[i].layerName, "VK_LAYER_LUNARG_standard_validation") == 0)
|
if(strcmp(availableLayers[i].layerName, "VK_LAYER_LUNARG_standard_validation") == 0)
|
||||||
enabledLayers.push_back("VK_LAYER_LUNARG_standard_validation");
|
enabledLayers.push_back("VK_LAYER_LUNARG_standard_validation");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
delete[] availableLayers;
|
delete[] availableLayers;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::vector<const char*> enabledExtensions;
|
||||||
|
#ifdef DEBUG
|
||||||
uint32_t extensionCount = 0;
|
uint32_t extensionCount = 0;
|
||||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
||||||
|
|
||||||
auto availableExtensions = new VkExtensionProperties[extensionCount];
|
auto availableExtensions = new VkExtensionProperties[extensionCount];
|
||||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, availableExtensions);
|
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, availableExtensions);
|
||||||
|
|
||||||
std::vector<const char*> enabledExtensions;
|
|
||||||
#ifdef DEBUG
|
|
||||||
for(uint32_t i = 0; i < extensionCount; i++) {
|
for(uint32_t i = 0; i < extensionCount; i++) {
|
||||||
if(strcmp(availableExtensions[i].extensionName, "VK_EXT_debug_utils") == 0) {
|
if(strcmp(availableExtensions[i].extensionName, "VK_EXT_debug_utils") == 0) {
|
||||||
enabledExtensions.push_back("VK_EXT_debug_utils");
|
enabledExtensions.push_back("VK_EXT_debug_utils");
|
||||||
enableDebug = true;
|
enableDebug = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
delete[] availableExtensions;
|
delete[] availableExtensions;
|
||||||
|
#endif
|
||||||
|
|
||||||
auto requiredExtensions = platform::getRequiredExtensions();
|
auto requiredExtensions = platform::getRequiredExtensions();
|
||||||
enabledExtensions.insert(enabledExtensions.end(), requiredExtensions.begin(), requiredExtensions.end());
|
enabledExtensions.insert(enabledExtensions.end(), requiredExtensions.begin(), requiredExtensions.end());
|
||||||
|
|
Reference in a new issue