Fix merge
This commit is contained in:
commit
23f84a0906
5 changed files with 52 additions and 25 deletions
|
@ -44,16 +44,25 @@ IMPORTED_LOCATION ${ASSIMP_IMPORTED_PATH})
|
|||
INTERFACE_INCLUDE_DIRECTORIES ${ASSIMP_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
add_executable(Graph
|
||||
set(GRAPH_SRC
|
||||
src/main.cpp
|
||||
src/renderer.cpp
|
||||
src/worldpass.cpp
|
||||
src/postpass.cpp
|
||||
src/dofpass.cpp
|
||||
src/imguipass.cpp
|
||||
src/skypass.cpp
|
||||
src/shadowpass.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
|
||||
PUBLIC
|
||||
-fno-exceptions
|
||||
|
@ -64,8 +73,13 @@ target_link_libraries(Graph
|
|||
Vulkan::Vulkan
|
||||
assimp::assimp
|
||||
nlohmann::json
|
||||
stb::stb
|
||||
stb::stb)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
target_link_libraries(Graph
|
||||
PUBLIC
|
||||
imgui::imgui)
|
||||
endif()
|
||||
|
||||
target_include_directories(Graph
|
||||
PUBLIC
|
||||
|
|
|
@ -188,7 +188,9 @@ private:
|
|||
WorldPass* worldPass_ = nullptr;
|
||||
PostPass* postPass_ = nullptr;
|
||||
DoFPass* dofPass_ = nullptr;
|
||||
#ifdef DEBUG
|
||||
ImGuiPass* imguiPass_ = nullptr;
|
||||
#endif
|
||||
SkyPass* skyPass_ = nullptr;
|
||||
ShadowPass* shadowPass_ = nullptr;
|
||||
};
|
||||
|
|
|
@ -290,12 +290,14 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
SDL_SetWindowFullscreen(window, windowFullscreen == 1 ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
ImGui::CreateContext();
|
||||
|
||||
auto& io = ImGui::GetIO();
|
||||
io.DisplaySize = ImVec2(windowWidth, windowHeight);
|
||||
|
||||
ImGui::StyleColorsDark();
|
||||
#endif
|
||||
|
||||
renderer = new Renderer(graphicsConfig);
|
||||
|
||||
|
@ -325,7 +327,9 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
if(event.type == SDL_WINDOWEVENT) {
|
||||
if(event.window.event == SDL_WINDOWEVENT_RESIZED) {
|
||||
#ifdef DEBUG
|
||||
io.DisplaySize = ImVec2(event.window.data1, event.window.data2);
|
||||
#endif
|
||||
|
||||
target = renderer->createSurfaceRenderTarget(surface, target);
|
||||
}
|
||||
|
@ -412,6 +416,7 @@ int main(int argc, char* argv[]) {
|
|||
const float deltaTime = currentTime - lastTime;
|
||||
lastTime = currentTime;
|
||||
|
||||
#ifdef DEBUG
|
||||
ImGui::NewFrame();
|
||||
|
||||
io.DeltaTime = deltaTime;
|
||||
|
@ -433,6 +438,8 @@ int main(int argc, char* argv[]) {
|
|||
ImGui::Text("dpack[2] = %f", (100 - camera.focusDistance) / 100.0f);
|
||||
|
||||
ImGui::Render();
|
||||
#endif
|
||||
|
||||
renderer->render(*world, camera, target);
|
||||
|
||||
if(cinematicMode)
|
||||
|
|
|
@ -30,7 +30,9 @@ Renderer::Renderer(GraphicsConfig config) : config_(config) {
|
|||
worldPass_ = new WorldPass(*this);
|
||||
postPass_ = new PostPass(*this);
|
||||
dofPass_ = new DoFPass(*this);
|
||||
#ifdef DEBUG
|
||||
imguiPass_ = new ImGuiPass(*this);
|
||||
#endif
|
||||
skyPass_ = new SkyPass(*this);
|
||||
}
|
||||
|
||||
|
@ -38,7 +40,9 @@ Renderer::~Renderer() {
|
|||
vkDeviceWaitIdle(device_);
|
||||
|
||||
delete skyPass_;
|
||||
#ifdef DEBUG
|
||||
delete imguiPass_;
|
||||
#endif
|
||||
delete dofPass_;
|
||||
delete postPass_;
|
||||
delete worldPass_;
|
||||
|
@ -127,7 +131,9 @@ void Renderer::render(World& world, Camera& camera, RenderTarget* target) {
|
|||
vkCmdBeginRenderPass(commandBuffer, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
postPass_->render(commandBuffer, target);
|
||||
#ifdef DEBUG
|
||||
imguiPass_->render(commandBuffer, target);
|
||||
#endif
|
||||
|
||||
vkCmdEndRenderPass(commandBuffer);
|
||||
|
||||
|
@ -1155,39 +1161,39 @@ void Renderer::destroyMeshBuffers(Mesh* mesh) {
|
|||
}
|
||||
|
||||
void Renderer::createInstance() {
|
||||
std::vector<const char*> enabledLayers;
|
||||
#ifdef DEBUG
|
||||
uint32_t layerCount = 0;
|
||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||
|
||||
auto availableLayers = new VkLayerProperties[layerCount];
|
||||
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers);
|
||||
|
||||
std::vector<const char*> enabledLayers;
|
||||
#ifdef DEBUG
|
||||
for(uint32_t i = 0; i < layerCount; i++) {
|
||||
if(strcmp(availableLayers[i].layerName, "VK_LAYER_LUNARG_standard_validation") == 0)
|
||||
enabledLayers.push_back("VK_LAYER_LUNARG_standard_validation");
|
||||
}
|
||||
#endif
|
||||
|
||||
delete[] availableLayers;
|
||||
#endif
|
||||
|
||||
std::vector<const char*> enabledExtensions;
|
||||
#ifdef DEBUG
|
||||
uint32_t extensionCount = 0;
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
||||
|
||||
auto availableExtensions = new VkExtensionProperties[extensionCount];
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, availableExtensions);
|
||||
|
||||
std::vector<const char*> enabledExtensions;
|
||||
#ifdef DEBUG
|
||||
for(uint32_t i = 0; i < extensionCount; i++) {
|
||||
if(strcmp(availableExtensions[i].extensionName, "VK_EXT_debug_utils") == 0) {
|
||||
enabledExtensions.push_back("VK_EXT_debug_utils");
|
||||
enableDebug = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
delete[] availableExtensions;
|
||||
#endif
|
||||
|
||||
auto requiredExtensions = platform::getRequiredExtensions();
|
||||
enabledExtensions.insert(enabledExtensions.end(), requiredExtensions.begin(), requiredExtensions.end());
|
||||
|
|
|
@ -29,19 +29,6 @@ ShadowPass::~ShadowPass() {
|
|||
}
|
||||
|
||||
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 = {};
|
||||
clearColor.depthStencil.depth = 1.0f;
|
||||
|
||||
|
@ -197,10 +184,21 @@ void ShadowPass::createPipeline() {
|
|||
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
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 = {};
|
||||
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
||||
viewportState.viewportCount = 1;
|
||||
viewportState.pViewports = &viewport;
|
||||
viewportState.scissorCount = 1;
|
||||
viewportState.pScissors = &scissor;
|
||||
|
||||
VkPipelineRasterizationStateCreateInfo rasterizer = {};
|
||||
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
||||
|
|
Reference in a new issue