Archived
1
Fork 0

Fix merge

This commit is contained in:
Joshua Goins 2018-12-14 21:10:38 -05:00
commit 23f84a0906
5 changed files with 52 additions and 25 deletions

View file

@ -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

View file

@ -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;
}; };

View file

@ -290,13 +290,15 @@ 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);
VkSurfaceKHR surface = nullptr; VkSurfaceKHR surface = nullptr;
@ -325,8 +327,10 @@ 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);
} }
} }
@ -412,6 +416,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;
@ -433,6 +438,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)

View file

@ -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");
} }
delete[] availableLayers;
#endif #endif
delete[] availableLayers; 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());

View file

@ -29,19 +29,6 @@ ShadowPass::~ShadowPass() {
} }
void ShadowPass::render(VkCommandBuffer commandBuffer, World& world) { void ShadowPass::render(VkCommandBuffer commandBuffer, World& world) {
VkViewport viewport = {};
viewport.width = renderer_.getConfig().shadowResolution;
viewport.height = renderer_.getConfig().shadowResolution;
viewport.maxDepth = 1.0f;
vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
VkRect2D scissor = {};
scissor.extent.width = renderer_.getConfig().shadowResolution;
scissor.extent.height = renderer_.getConfig().shadowResolution;
vkCmdSetScissor(commandBuffer, 0, 1, &scissor);
VkClearValue clearColor = {}; VkClearValue clearColor = {};
clearColor.depthStencil.depth = 1.0f; clearColor.depthStencil.depth = 1.0f;
@ -196,11 +183,22 @@ void ShadowPass::createPipeline() {
VkPipelineInputAssemblyStateCreateInfo inputAssembly = {}; VkPipelineInputAssemblyStateCreateInfo inputAssembly = {};
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
VkViewport viewport = {};
viewport.width = renderer_.getConfig().shadowResolution;
viewport.height = renderer_.getConfig().shadowResolution;
viewport.maxDepth = 1.0f;
VkRect2D scissor = {};
scissor.extent.width = renderer_.getConfig().shadowResolution;
scissor.extent.height = renderer_.getConfig().shadowResolution;
VkPipelineViewportStateCreateInfo viewportState = {}; VkPipelineViewportStateCreateInfo viewportState = {};
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportState.viewportCount = 1; viewportState.viewportCount = 1;
viewportState.pViewports = &viewport;
viewportState.scissorCount = 1; viewportState.scissorCount = 1;
viewportState.pScissors = &scissor;
VkPipelineRasterizationStateCreateInfo rasterizer = {}; VkPipelineRasterizationStateCreateInfo rasterizer = {};
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;