优化引用,避免重复引用导致link阶段出错
parent
f04da30909
commit
d25e494926
|
@ -0,0 +1,39 @@
|
|||
避免重复引入
|
||||
|
||||
``` C++
|
||||
#ifndef _GLTFMODEL_H
|
||||
#include "glTFModel.h"
|
||||
#define _GLTFMODEL_H
|
||||
#endif // !GLTFMODEL_H
|
||||
|
||||
#ifndef _RENDERSETTER_H
|
||||
#include "renderSetter.h"
|
||||
#define _RENDERSETTER_H
|
||||
#endif // !RENDERSETTER_H
|
||||
|
||||
#ifndef _VULKANFOUNDATION_H
|
||||
#include "vulkanFoundation.h"
|
||||
#define _VULKANFOUNDATION_H
|
||||
#endif // !VULKANFOUNDATION_H
|
||||
|
||||
#ifndef _UI_HPP
|
||||
#include "ui.hpp"
|
||||
#define _UI_HPP
|
||||
#endif // !UI_HPP
|
||||
|
||||
#ifndef _PBR_H
|
||||
#include "PBR.h"
|
||||
#define _PBR_H
|
||||
#endif // !PBR_H
|
||||
|
||||
#ifndef _RENDER_H
|
||||
#include "render.h"
|
||||
#define _RENDER_H
|
||||
#endif // !RENDER_H
|
||||
|
||||
#ifndef _RENDERIO_H
|
||||
#include "renderIO.h"
|
||||
#define _RENDERIO_H
|
||||
#endif // !RENDERIO_H
|
||||
|
||||
```
|
|
@ -33,9 +33,19 @@ function(buildHomework HOMEWORK_NAME)
|
|||
add_executable(${HOMEWORK_NAME} WIN32 ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES}
|
||||
"render/glTFModel.h"
|
||||
"render/glTFModel.cpp"
|
||||
|
||||
"render/vulkanFoundation.h" "render/vulkanFoundation.cpp" "render/renderSetter.h" "render/renderSetter.cpp" "render/PBR.h" "render/PBR.cpp" "render/renderUI.h" "render/renderUI.cpp" "render/renderIO.h" "render/renderIO.cpp")
|
||||
target_link_libraries(${HOMEWORK_NAME} base ${Vulkan_LIBRARY} ${WINLIBS})
|
||||
"render/vulkanFoundation.h"
|
||||
"render/vulkanFoundation.cpp"
|
||||
"render/renderSetter.h"
|
||||
"render/renderSetter.cpp"
|
||||
"render/PBR.h"
|
||||
"render/PBR.cpp"
|
||||
"render/renderUI.h"
|
||||
"render/renderUI.cpp"
|
||||
"render/renderIO.h"
|
||||
"render/renderIO.cpp"
|
||||
"render/render.h"
|
||||
"render/render.cpp")
|
||||
target_link_libraries(${HOMEWORK_NAME} base ${Vulkan_LIBRARY})
|
||||
else(WIN32)
|
||||
add_executable(${HOMEWORK_NAME} ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES})
|
||||
target_link_libraries(${HOMEWORK_NAME} base )
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "PBR.h"
|
||||
|
||||
void PBR::Material::generateCubemap()
|
||||
void PBR::Material::generateCubemap(VulkanBackend::VulkanFoundation vkFoundation,PlumageRender::Setter setter,PlumageRender::renderMain mainRender)
|
||||
{
|
||||
enum Target { IRRADIANCE = 0, PREFILTEREDENV = 1 };
|
||||
|
||||
|
@ -42,15 +42,15 @@ void PBR::Material::generateCubemap()
|
|||
imageCI.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imageCI.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
imageCI.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
|
||||
VK_CHECK_RESULT(vkCreateImage(VulkanBackend::VulkanFoundation::device, &imageCI, nullptr, &cubemap.image));
|
||||
VK_CHECK_RESULT(vkCreateImage(vkFoundation.device, &imageCI, nullptr, &cubemap.image));
|
||||
VkMemoryRequirements memReqs;
|
||||
vkGetImageMemoryRequirements(VulkanBackend::VulkanFoundation::device, cubemap.image, &memReqs);
|
||||
vkGetImageMemoryRequirements(vkFoundation.device, cubemap.image, &memReqs);
|
||||
VkMemoryAllocateInfo memAllocInfo{};
|
||||
memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
memAllocInfo.allocationSize = memReqs.size;
|
||||
memAllocInfo.memoryTypeIndex = VulkanBackend::VulkanFoundation::vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK_RESULT(vkAllocateMemory(VulkanBackend::VulkanFoundation::device, &memAllocInfo, nullptr, &cubemap.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(VulkanBackend::VulkanFoundation::device, cubemap.image, cubemap.deviceMemory, 0));
|
||||
memAllocInfo.memoryTypeIndex = vkFoundation.vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK_RESULT(vkAllocateMemory(vkFoundation.device, &memAllocInfo, nullptr, &cubemap.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(vkFoundation.device, cubemap.image, cubemap.deviceMemory, 0));
|
||||
|
||||
// View
|
||||
VkImageViewCreateInfo viewCI{};
|
||||
|
@ -62,7 +62,7 @@ void PBR::Material::generateCubemap()
|
|||
viewCI.subresourceRange.levelCount = numMips;
|
||||
viewCI.subresourceRange.layerCount = 6;
|
||||
viewCI.image = cubemap.image;
|
||||
VK_CHECK_RESULT(vkCreateImageView(VulkanBackend::VulkanFoundation::device, &viewCI, nullptr, &cubemap.view));
|
||||
VK_CHECK_RESULT(vkCreateImageView(vkFoundation.device, &viewCI, nullptr, &cubemap.view));
|
||||
|
||||
// Sampler
|
||||
VkSamplerCreateInfo samplerCI{};
|
||||
|
@ -77,7 +77,7 @@ void PBR::Material::generateCubemap()
|
|||
samplerCI.maxLod = static_cast<float>(numMips);
|
||||
samplerCI.maxAnisotropy = 1.0f;
|
||||
samplerCI.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
|
||||
VK_CHECK_RESULT(vkCreateSampler(VulkanBackend::VulkanFoundation::device, &samplerCI, nullptr, &cubemap.sampler));
|
||||
VK_CHECK_RESULT(vkCreateSampler(vkFoundation.device, &samplerCI, nullptr, &cubemap.sampler));
|
||||
}
|
||||
|
||||
// FB, Att, RP, Pipe, etc.
|
||||
|
@ -125,7 +125,7 @@ void PBR::Material::generateCubemap()
|
|||
renderPassCI.dependencyCount = 2;
|
||||
renderPassCI.pDependencies = dependencies.data();
|
||||
VkRenderPass renderpass;
|
||||
VK_CHECK_RESULT(vkCreateRenderPass(VulkanBackend::VulkanFoundation::device, &renderPassCI, nullptr, &renderpass));
|
||||
VK_CHECK_RESULT(vkCreateRenderPass(vkFoundation.device, &renderPassCI, nullptr, &renderpass));
|
||||
|
||||
|
||||
// Create offscreen framebuffer
|
||||
|
@ -145,15 +145,15 @@ void PBR::Material::generateCubemap()
|
|||
imageCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
imageCI.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
imageCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
VK_CHECK_RESULT(vkCreateImage(VulkanBackend::VulkanFoundation::device, &imageCI, nullptr, &offscreen.image));
|
||||
VK_CHECK_RESULT(vkCreateImage(vkFoundation.device, &imageCI, nullptr, &offscreen.image));
|
||||
VkMemoryRequirements memReqs;
|
||||
vkGetImageMemoryRequirements(VulkanBackend::VulkanFoundation::device, offscreen.image, &memReqs);
|
||||
vkGetImageMemoryRequirements(vkFoundation.device, offscreen.image, &memReqs);
|
||||
VkMemoryAllocateInfo memAllocInfo{};
|
||||
memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
memAllocInfo.allocationSize = memReqs.size;
|
||||
memAllocInfo.memoryTypeIndex = VulkanBackend::VulkanFoundation::vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK_RESULT(vkAllocateMemory(VulkanBackend::VulkanFoundation::device, &memAllocInfo, nullptr, &offscreen.memory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(VulkanBackend::VulkanFoundation::device, offscreen.image, offscreen.memory, 0));
|
||||
memAllocInfo.memoryTypeIndex = vkFoundation.vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK_RESULT(vkAllocateMemory(vkFoundation.device, &memAllocInfo, nullptr, &offscreen.memory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(vkFoundation.device, offscreen.image, offscreen.memory, 0));
|
||||
|
||||
// View
|
||||
VkImageViewCreateInfo viewCI{};
|
||||
|
@ -168,7 +168,7 @@ void PBR::Material::generateCubemap()
|
|||
viewCI.subresourceRange.baseArrayLayer = 0;
|
||||
viewCI.subresourceRange.layerCount = 1;
|
||||
viewCI.image = offscreen.image;
|
||||
VK_CHECK_RESULT(vkCreateImageView(VulkanBackend::VulkanFoundation::device, &viewCI, nullptr, &offscreen.view));
|
||||
VK_CHECK_RESULT(vkCreateImageView(vkFoundation.device, &viewCI, nullptr, &offscreen.view));
|
||||
|
||||
// Framebuffer
|
||||
VkFramebufferCreateInfo framebufferCI{};
|
||||
|
@ -179,9 +179,9 @@ void PBR::Material::generateCubemap()
|
|||
framebufferCI.width = dim;
|
||||
framebufferCI.height = dim;
|
||||
framebufferCI.layers = 1;
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(VulkanBackend::VulkanFoundation::device, &framebufferCI, nullptr, &offscreen.framebuffer));
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(vkFoundation.device, &framebufferCI, nullptr, &offscreen.framebuffer));
|
||||
|
||||
VkCommandBuffer layoutCmd = VulkanBackend::VulkanFoundation::vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer layoutCmd = vkFoundation.vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkImageMemoryBarrier imageMemoryBarrier{};
|
||||
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
imageMemoryBarrier.image = offscreen.image;
|
||||
|
@ -191,7 +191,7 @@ void PBR::Material::generateCubemap()
|
|||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
imageMemoryBarrier.subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
|
||||
vkCmdPipelineBarrier(layoutCmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->flushCommandBuffer(layoutCmd, VulkanBackend::VulkanFoundation::graphicQueue, true);
|
||||
vkFoundation.vulkanDevice->flushCommandBuffer(layoutCmd, vkFoundation.graphicQueue, true);
|
||||
}
|
||||
|
||||
// Descriptors
|
||||
|
@ -201,7 +201,7 @@ void PBR::Material::generateCubemap()
|
|||
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
descriptorSetLayoutCI.pBindings = &setLayoutBinding;
|
||||
descriptorSetLayoutCI.bindingCount = 1;
|
||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(VulkanBackend::VulkanFoundation::device, &descriptorSetLayoutCI, nullptr, &descriptorsetlayout));
|
||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(vkFoundation.device, &descriptorSetLayoutCI, nullptr, &descriptorsetlayout));
|
||||
|
||||
// Descriptor Pool
|
||||
VkDescriptorPoolSize poolSize = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 };
|
||||
|
@ -211,7 +211,7 @@ void PBR::Material::generateCubemap()
|
|||
descriptorPoolCI.pPoolSizes = &poolSize;
|
||||
descriptorPoolCI.maxSets = 2;
|
||||
VkDescriptorPool descriptorpool;
|
||||
VK_CHECK_RESULT(vkCreateDescriptorPool(VulkanBackend::VulkanFoundation::device, &descriptorPoolCI, nullptr, &descriptorpool));
|
||||
VK_CHECK_RESULT(vkCreateDescriptorPool(vkFoundation.device, &descriptorPoolCI, nullptr, &descriptorpool));
|
||||
|
||||
// Descriptor sets
|
||||
VkDescriptorSet descriptorset;
|
||||
|
@ -220,7 +220,7 @@ void PBR::Material::generateCubemap()
|
|||
descriptorSetAllocInfo.descriptorPool = descriptorpool;
|
||||
descriptorSetAllocInfo.pSetLayouts = &descriptorsetlayout;
|
||||
descriptorSetAllocInfo.descriptorSetCount = 1;
|
||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(VulkanBackend::VulkanFoundation::device, &descriptorSetAllocInfo, &descriptorset));
|
||||
VK_CHECK_RESULT(vkAllocateDescriptorSets(vkFoundation.device, &descriptorSetAllocInfo, &descriptorset));
|
||||
VkWriteDescriptorSet writeDescriptorSet{};
|
||||
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||
writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
|
@ -228,7 +228,7 @@ void PBR::Material::generateCubemap()
|
|||
writeDescriptorSet.dstSet = descriptorset;
|
||||
writeDescriptorSet.dstBinding = 0;
|
||||
writeDescriptorSet.pImageInfo = &textures.environmentCube.descriptor;
|
||||
vkUpdateDescriptorSets(VulkanBackend::VulkanFoundation::device, 1, &writeDescriptorSet, 0, nullptr);
|
||||
vkUpdateDescriptorSets(vkFoundation.device, 1, &writeDescriptorSet, 0, nullptr);
|
||||
|
||||
// Pipeline layout
|
||||
VkPipelineLayout pipelinelayout;
|
||||
|
@ -250,7 +250,7 @@ void PBR::Material::generateCubemap()
|
|||
pipelineLayoutCI.pSetLayouts = &descriptorsetlayout;
|
||||
pipelineLayoutCI.pushConstantRangeCount = 1;
|
||||
pipelineLayoutCI.pPushConstantRanges = &pushConstantRange;
|
||||
VK_CHECK_RESULT(vkCreatePipelineLayout(VulkanBackend::VulkanFoundation::device, &pipelineLayoutCI, nullptr, &pipelinelayout));
|
||||
VK_CHECK_RESULT(vkCreatePipelineLayout(vkFoundation.device, &pipelineLayoutCI, nullptr, &pipelinelayout));
|
||||
|
||||
// Pipeline
|
||||
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI{};
|
||||
|
@ -325,19 +325,19 @@ void PBR::Material::generateCubemap()
|
|||
pipelineCI.pStages = shaderStages.data();
|
||||
pipelineCI.renderPass = renderpass;
|
||||
|
||||
shaderStages[0] = loadShader(VulkanBackend::VulkanFoundation::device, PlumageRender::Setter::filePath.filterVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[0] = loadShader(vkFoundation.device, setter.filePath.filterVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT);
|
||||
switch (target) {
|
||||
case IRRADIANCE:
|
||||
shaderStages[1] = loadShader(VulkanBackend::VulkanFoundation::device, PlumageRender::Setter::filePath.irradianceFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[1] = loadShader(vkFoundation.device, setter.filePath.irradianceFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
break;
|
||||
case PREFILTEREDENV:
|
||||
shaderStages[1] = loadShader(VulkanBackend::VulkanFoundation::device, PlumageRender::Setter::filePath.prefilterEnvmapFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
shaderStages[1] = loadShader(vkFoundation.device, setter.filePath.prefilterEnvmapFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
break;
|
||||
};
|
||||
VkPipeline pipeline;
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(VulkanBackend::VulkanFoundation::device, VulkanBackend::VulkanFoundation::pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(vkFoundation.device, vkFoundation.pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
|
||||
for (auto shaderStage : shaderStages) {
|
||||
vkDestroyShaderModule(VulkanBackend::VulkanFoundation::device, shaderStage.module, nullptr);
|
||||
vkDestroyShaderModule(vkFoundation.device, shaderStage.module, nullptr);
|
||||
}
|
||||
|
||||
// Render cubemap
|
||||
|
@ -362,7 +362,7 @@ void PBR::Material::generateCubemap()
|
|||
glm::rotate(glm::mat4(1.0f), glm::radians(180.0f), glm::vec3(0.0f, 0.0f, 1.0f)),
|
||||
};
|
||||
|
||||
VkCommandBuffer cmdBuf = VulkanBackend::VulkanFoundation::vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
VkCommandBuffer cmdBuf = vkFoundation.vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, false);
|
||||
|
||||
VkViewport viewport{};
|
||||
viewport.width = (float)dim;
|
||||
|
@ -382,7 +382,7 @@ void PBR::Material::generateCubemap()
|
|||
|
||||
// Change image layout for all cubemap faces to transfer destination
|
||||
{
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->beginCommandBuffer(cmdBuf);
|
||||
vkFoundation.vulkanDevice->beginCommandBuffer(cmdBuf);
|
||||
VkImageMemoryBarrier imageMemoryBarrier{};
|
||||
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
imageMemoryBarrier.image = cubemap.image;
|
||||
|
@ -392,13 +392,13 @@ void PBR::Material::generateCubemap()
|
|||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
imageMemoryBarrier.subresourceRange = subresourceRange;
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->flushCommandBuffer(cmdBuf, VulkanBackend::VulkanFoundation::graphicQueue, false);
|
||||
vkFoundation.vulkanDevice->flushCommandBuffer(cmdBuf, vkFoundation.graphicQueue, false);
|
||||
}
|
||||
|
||||
for (uint32_t m = 0; m < numMips; m++) {
|
||||
for (uint32_t f = 0; f < 6; f++) {
|
||||
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->beginCommandBuffer(cmdBuf);
|
||||
vkFoundation.vulkanDevice->beginCommandBuffer(cmdBuf);
|
||||
|
||||
viewport.width = static_cast<float>(dim * std::pow(0.5f, m));
|
||||
viewport.height = static_cast<float>(dim * std::pow(0.5f, m));
|
||||
|
@ -426,7 +426,7 @@ void PBR::Material::generateCubemap()
|
|||
|
||||
VkDeviceSize offsets[1] = { 0 };
|
||||
|
||||
PlumageRender::renderMain::models.skybox.draw(cmdBuf);
|
||||
mainRender.models.skybox.draw(cmdBuf);
|
||||
|
||||
vkCmdEndRenderPass(cmdBuf);
|
||||
|
||||
|
@ -488,12 +488,12 @@ void PBR::Material::generateCubemap()
|
|||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
|
||||
}
|
||||
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->flushCommandBuffer(cmdBuf, VulkanBackend::VulkanFoundation::graphicQueue, false);
|
||||
vkFoundation.vulkanDevice->flushCommandBuffer(cmdBuf, vkFoundation.graphicQueue, false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->beginCommandBuffer(cmdBuf);
|
||||
vkFoundation.vulkanDevice->beginCommandBuffer(cmdBuf);
|
||||
VkImageMemoryBarrier imageMemoryBarrier{};
|
||||
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
imageMemoryBarrier.image = cubemap.image;
|
||||
|
@ -503,24 +503,24 @@ void PBR::Material::generateCubemap()
|
|||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
imageMemoryBarrier.subresourceRange = subresourceRange;
|
||||
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->flushCommandBuffer(cmdBuf, VulkanBackend::VulkanFoundation::graphicQueue, false);
|
||||
vkFoundation.vulkanDevice->flushCommandBuffer(cmdBuf, vkFoundation.graphicQueue, false);
|
||||
}
|
||||
|
||||
|
||||
vkDestroyRenderPass(VulkanBackend::VulkanFoundation::device, renderpass, nullptr);
|
||||
vkDestroyFramebuffer(VulkanBackend::VulkanFoundation::device, offscreen.framebuffer, nullptr);
|
||||
vkFreeMemory(VulkanBackend::VulkanFoundation::device, offscreen.memory, nullptr);
|
||||
vkDestroyImageView(VulkanBackend::VulkanFoundation::device, offscreen.view, nullptr);
|
||||
vkDestroyImage(VulkanBackend::VulkanFoundation::device, offscreen.image, nullptr);
|
||||
vkDestroyDescriptorPool(VulkanBackend::VulkanFoundation::device, descriptorpool, nullptr);
|
||||
vkDestroyDescriptorSetLayout(VulkanBackend::VulkanFoundation::device, descriptorsetlayout, nullptr);
|
||||
vkDestroyPipeline(VulkanBackend::VulkanFoundation::device, pipeline, nullptr);
|
||||
vkDestroyPipelineLayout(VulkanBackend::VulkanFoundation::device, pipelinelayout, nullptr);
|
||||
vkDestroyRenderPass(vkFoundation.device, renderpass, nullptr);
|
||||
vkDestroyFramebuffer(vkFoundation.device, offscreen.framebuffer, nullptr);
|
||||
vkFreeMemory(vkFoundation.device, offscreen.memory, nullptr);
|
||||
vkDestroyImageView(vkFoundation.device, offscreen.view, nullptr);
|
||||
vkDestroyImage(vkFoundation.device, offscreen.image, nullptr);
|
||||
vkDestroyDescriptorPool(vkFoundation.device, descriptorpool, nullptr);
|
||||
vkDestroyDescriptorSetLayout(vkFoundation.device, descriptorsetlayout, nullptr);
|
||||
vkDestroyPipeline(vkFoundation.device, pipeline, nullptr);
|
||||
vkDestroyPipelineLayout(vkFoundation.device, pipelinelayout, nullptr);
|
||||
|
||||
cubemap.descriptor.imageView = cubemap.view;
|
||||
cubemap.descriptor.sampler = cubemap.sampler;
|
||||
cubemap.descriptor.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
cubemap.device = VulkanBackend::VulkanFoundation::vulkanDevice;
|
||||
cubemap.device = vkFoundation.vulkanDevice;
|
||||
|
||||
switch (target) {
|
||||
case IRRADIANCE:
|
||||
|
@ -538,7 +538,7 @@ void PBR::Material::generateCubemap()
|
|||
}
|
||||
}
|
||||
|
||||
void PBR::Material::generateBRDFLUT()
|
||||
void PBR::Material::generateBRDFLUT(VulkanBackend::VulkanFoundation vkFoundation, PlumageRender::Setter setter)
|
||||
{
|
||||
auto tStart = std::chrono::high_resolution_clock::now();
|
||||
|
||||
|
@ -558,15 +558,15 @@ void PBR::Material::generateBRDFLUT()
|
|||
imageCI.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||
imageCI.tiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imageCI.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
VK_CHECK_RESULT(vkCreateImage(VulkanBackend::VulkanFoundation::device, &imageCI, nullptr, &textures.lutBrdf.image));
|
||||
VK_CHECK_RESULT(vkCreateImage(vkFoundation.device, &imageCI, nullptr, &textures.lutBrdf.image));
|
||||
VkMemoryRequirements memReqs;
|
||||
vkGetImageMemoryRequirements(VulkanBackend::VulkanFoundation::device, textures.lutBrdf.image, &memReqs);
|
||||
vkGetImageMemoryRequirements(vkFoundation.device, textures.lutBrdf.image, &memReqs);
|
||||
VkMemoryAllocateInfo memAllocInfo{};
|
||||
memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
||||
memAllocInfo.allocationSize = memReqs.size;
|
||||
memAllocInfo.memoryTypeIndex = VulkanBackend::VulkanFoundation::vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK_RESULT(vkAllocateMemory(VulkanBackend::VulkanFoundation::device, &memAllocInfo, nullptr, &textures.lutBrdf.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(VulkanBackend::VulkanFoundation::device, textures.lutBrdf.image, textures.lutBrdf.deviceMemory, 0));
|
||||
memAllocInfo.memoryTypeIndex = vkFoundation.vulkanDevice->getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||
VK_CHECK_RESULT(vkAllocateMemory(vkFoundation.device, &memAllocInfo, nullptr, &textures.lutBrdf.deviceMemory));
|
||||
VK_CHECK_RESULT(vkBindImageMemory(vkFoundation.device, textures.lutBrdf.image, textures.lutBrdf.deviceMemory, 0));
|
||||
|
||||
// View
|
||||
VkImageViewCreateInfo viewCI{};
|
||||
|
@ -578,7 +578,7 @@ void PBR::Material::generateBRDFLUT()
|
|||
viewCI.subresourceRange.levelCount = 1;
|
||||
viewCI.subresourceRange.layerCount = 1;
|
||||
viewCI.image = textures.lutBrdf.image;
|
||||
VK_CHECK_RESULT(vkCreateImageView(VulkanBackend::VulkanFoundation::device, &viewCI, nullptr, &textures.lutBrdf.view));
|
||||
VK_CHECK_RESULT(vkCreateImageView(vkFoundation.device, &viewCI, nullptr, &textures.lutBrdf.view));
|
||||
|
||||
// Sampler
|
||||
VkSamplerCreateInfo samplerCI{};
|
||||
|
@ -593,7 +593,7 @@ void PBR::Material::generateBRDFLUT()
|
|||
samplerCI.maxLod = 1.0f;
|
||||
samplerCI.maxAnisotropy = 1.0f;
|
||||
samplerCI.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE;
|
||||
VK_CHECK_RESULT(vkCreateSampler(VulkanBackend::VulkanFoundation::device, &samplerCI, nullptr, &textures.lutBrdf.sampler));
|
||||
VK_CHECK_RESULT(vkCreateSampler(vkFoundation.device, &samplerCI, nullptr, &textures.lutBrdf.sampler));
|
||||
|
||||
// FB, Att, RP, Pipe, etc.
|
||||
VkAttachmentDescription attDesc{};
|
||||
|
@ -641,7 +641,7 @@ void PBR::Material::generateBRDFLUT()
|
|||
renderPassCI.pDependencies = dependencies.data();
|
||||
|
||||
VkRenderPass renderpass;
|
||||
VK_CHECK_RESULT(vkCreateRenderPass(VulkanBackend::VulkanFoundation::device, &renderPassCI, nullptr, &renderpass));
|
||||
VK_CHECK_RESULT(vkCreateRenderPass(vkFoundation.device, &renderPassCI, nullptr, &renderpass));
|
||||
|
||||
VkFramebufferCreateInfo framebufferCI{};
|
||||
framebufferCI.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||
|
@ -653,13 +653,13 @@ void PBR::Material::generateBRDFLUT()
|
|||
framebufferCI.layers = 1;
|
||||
|
||||
VkFramebuffer framebuffer;
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(VulkanBackend::VulkanFoundation::device, &framebufferCI, nullptr, &framebuffer));
|
||||
VK_CHECK_RESULT(vkCreateFramebuffer(vkFoundation.device, &framebufferCI, nullptr, &framebuffer));
|
||||
|
||||
// Desriptors
|
||||
VkDescriptorSetLayout descriptorsetlayout;
|
||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCI{};
|
||||
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(VulkanBackend::VulkanFoundation::device, &descriptorSetLayoutCI, nullptr, &descriptorsetlayout));
|
||||
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(vkFoundation.device, &descriptorSetLayoutCI, nullptr, &descriptorsetlayout));
|
||||
|
||||
// Pipeline layout
|
||||
VkPipelineLayout pipelinelayout;
|
||||
|
@ -667,7 +667,7 @@ void PBR::Material::generateBRDFLUT()
|
|||
pipelineLayoutCI.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||
pipelineLayoutCI.setLayoutCount = 1;
|
||||
pipelineLayoutCI.pSetLayouts = &descriptorsetlayout;
|
||||
VK_CHECK_RESULT(vkCreatePipelineLayout(VulkanBackend::VulkanFoundation::device, &pipelineLayoutCI, nullptr, &pipelinelayout));
|
||||
VK_CHECK_RESULT(vkCreatePipelineLayout(vkFoundation.device, &pipelineLayoutCI, nullptr, &pipelinelayout));
|
||||
|
||||
// Pipeline
|
||||
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI{};
|
||||
|
@ -735,13 +735,13 @@ void PBR::Material::generateBRDFLUT()
|
|||
|
||||
// Look-up-table (from BRDF) pipeline
|
||||
shaderStages = {
|
||||
loadShader(VulkanBackend::VulkanFoundation::device,PlumageRender::Setter::filePath.brdfVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
|
||||
loadShader(VulkanBackend::VulkanFoundation::device,PlumageRender::Setter::filePath.brdfFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT)
|
||||
loadShader(vkFoundation.device,setter.filePath.brdfVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
|
||||
loadShader(vkFoundation.device,setter.filePath.brdfFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT)
|
||||
};
|
||||
VkPipeline pipeline;
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(VulkanBackend::VulkanFoundation::device, VulkanBackend::VulkanFoundation::pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(vkFoundation.device, vkFoundation.pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
|
||||
for (auto shaderStage : shaderStages) {
|
||||
vkDestroyShaderModule(VulkanBackend::VulkanFoundation::device, shaderStage.module, nullptr);
|
||||
vkDestroyShaderModule(vkFoundation.device, shaderStage.module, nullptr);
|
||||
}
|
||||
|
||||
// Render
|
||||
|
@ -757,7 +757,7 @@ void PBR::Material::generateBRDFLUT()
|
|||
renderPassBeginInfo.pClearValues = clearValues;
|
||||
renderPassBeginInfo.framebuffer = framebuffer;
|
||||
|
||||
VkCommandBuffer cmdBuf = VulkanBackend::VulkanFoundation::vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
VkCommandBuffer cmdBuf = vkFoundation.vulkanDevice->createCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY, true);
|
||||
vkCmdBeginRenderPass(cmdBuf, &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||
|
||||
VkViewport viewport{};
|
||||
|
@ -775,20 +775,20 @@ void PBR::Material::generateBRDFLUT()
|
|||
vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
|
||||
vkCmdDraw(cmdBuf, 3, 1, 0, 0);
|
||||
vkCmdEndRenderPass(cmdBuf);
|
||||
VulkanBackend::VulkanFoundation::vulkanDevice->flushCommandBuffer(cmdBuf, VulkanBackend::VulkanFoundation::graphicQueue);
|
||||
vkFoundation.vulkanDevice->flushCommandBuffer(cmdBuf, vkFoundation.graphicQueue);
|
||||
|
||||
vkQueueWaitIdle(VulkanBackend::VulkanFoundation::graphicQueue);
|
||||
vkQueueWaitIdle(vkFoundation.graphicQueue);
|
||||
|
||||
vkDestroyPipeline(VulkanBackend::VulkanFoundation::device, pipeline, nullptr);
|
||||
vkDestroyPipelineLayout(VulkanBackend::VulkanFoundation::device, pipelinelayout, nullptr);
|
||||
vkDestroyRenderPass(VulkanBackend::VulkanFoundation::device, renderpass, nullptr);
|
||||
vkDestroyFramebuffer(VulkanBackend::VulkanFoundation::device, framebuffer, nullptr);
|
||||
vkDestroyDescriptorSetLayout(VulkanBackend::VulkanFoundation::device, descriptorsetlayout, nullptr);
|
||||
vkDestroyPipeline(vkFoundation.device, pipeline, nullptr);
|
||||
vkDestroyPipelineLayout(vkFoundation.device, pipelinelayout, nullptr);
|
||||
vkDestroyRenderPass(vkFoundation.device, renderpass, nullptr);
|
||||
vkDestroyFramebuffer(vkFoundation.device, framebuffer, nullptr);
|
||||
vkDestroyDescriptorSetLayout(vkFoundation.device, descriptorsetlayout, nullptr);
|
||||
|
||||
textures.lutBrdf.descriptor.imageView = textures.lutBrdf.view;
|
||||
textures.lutBrdf.descriptor.sampler = textures.lutBrdf.sampler;
|
||||
textures.lutBrdf.descriptor.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
textures.lutBrdf.device = VulkanBackend::VulkanFoundation::vulkanDevice;
|
||||
textures.lutBrdf.device = vkFoundation.vulkanDevice;
|
||||
|
||||
auto tEnd = std::chrono::high_resolution_clock::now();
|
||||
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef _RENDER_H
|
||||
#include "render.h"
|
||||
#define _RENDER_H
|
||||
#endif // !RENDER_H
|
||||
|
||||
#ifndef _VULKANFOUNDATION_H
|
||||
#include "vulkanFoundation.h"
|
||||
#define _VULKANFOUNDATION_H
|
||||
#endif // !VULKANFOUNDATION_H
|
||||
|
||||
|
||||
#include "glm/glm.hpp"
|
||||
#include <VulkanTexture.hpp>
|
||||
#include "vulkanFoundation.h"
|
||||
|
||||
|
||||
|
||||
namespace PBR
|
||||
|
@ -56,10 +68,10 @@ namespace PBR
|
|||
// generate two cube maps
|
||||
// irradiance cube map
|
||||
// prefileter environment cube map
|
||||
void generateCubemap();
|
||||
void generateCubemap(VulkanBackend::VulkanFoundation vkFoundation, PlumageRender::Setter setter, PlumageRender::renderMain mainRender);
|
||||
|
||||
// generate BRDF integration map for roughness/NdotV
|
||||
void generateBRDFLUT();
|
||||
void generateBRDFLUT(VulkanBackend::VulkanFoundation vkFoundation, PlumageRender::Setter setter);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -35,7 +35,11 @@
|
|||
#include "VulkanDevice.hpp"
|
||||
//#include "VulkanUtils.hpp"
|
||||
#include "vulkan/vulkan.h"
|
||||
|
||||
#ifndef _VULKANFOUNDATION_H
|
||||
#include "vulkanFoundation.h"
|
||||
#define _VULKANFOUNDATION_H
|
||||
#endif // !VULKANFOUNDATION_H
|
||||
|
||||
#define ENABLE_VALIDATION false
|
||||
#define MAX_NUM_JOINTS 128u
|
||||
|
|
|
@ -210,6 +210,8 @@ int main()
|
|||
PlumageRender::Setter setter;
|
||||
PlumageRender::renderMain plumageRender;
|
||||
VulkanBackend::VulkanFoundation vkFoundation;
|
||||
UI* gui = new UI(vkFoundation.vulkanDevice, vkFoundation.renderPass, vkFoundation.graphicQueue, vkFoundation.pipelineCache, setter.settings.sampleCount);
|
||||
|
||||
vkFoundation.initVulkan();
|
||||
if (!setter.settings.headless)
|
||||
{
|
||||
|
|
|
@ -1,36 +1,57 @@
|
|||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <vector>
|
||||
#include <chrono>
|
||||
#include <map>
|
||||
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include "algorithm"
|
||||
#include <iostream>
|
||||
#include <sys/stat.h>
|
||||
#include <codecvt>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <locale>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "glTFModel.h"
|
||||
#include "GLFW/glfw3.h"
|
||||
#include <VulkanTexture.hpp>
|
||||
#include "VulkanDevice.hpp"
|
||||
#include "ui.hpp"
|
||||
#include <VulkanUtils.hpp>
|
||||
|
||||
|
||||
#ifndef _GLTFMODEL_H
|
||||
#include "glTFModel.h"
|
||||
#define _GLTFMODEL_H
|
||||
#endif // !GLTFMODEL_H
|
||||
|
||||
#ifndef _RENDERSETTER_H
|
||||
#include "renderSetter.h"
|
||||
#define _RENDERSETTER_H
|
||||
#endif // !RENDERSETTER_H
|
||||
|
||||
#ifndef _VULKANFOUNDATION_H
|
||||
#include "vulkanFoundation.h"
|
||||
#define _VULKANFOUNDATION_H
|
||||
#endif // !VULKANFOUNDATION_H
|
||||
|
||||
#ifndef _UI_HPP
|
||||
#include "ui.hpp"
|
||||
#define _UI_HPP
|
||||
#endif // !UI_HPP
|
||||
|
||||
|
||||
|
||||
#include "VulkanDevice.hpp"
|
||||
|
||||
#include <camera.hpp>
|
||||
#include <VulkanTexture.hpp>
|
||||
#include <VulkanUtils.hpp>
|
||||
|
||||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
#include "vulkanFoundation.h"
|
||||
|
||||
|
||||
#define ENABLE_VALIDATION false
|
||||
|
||||
|
@ -68,9 +89,9 @@ namespace PlumageRender
|
|||
static uint32_t currentBuffer;
|
||||
|
||||
|
||||
UI* gui;
|
||||
|
||||
|
||||
uint64_t savedFrameCounter = PlumageRender::Setter::settings.startFrameCount;
|
||||
uint64_t savedFrameCounter = 1;
|
||||
|
||||
|
||||
|
||||
|
@ -117,7 +138,7 @@ namespace PlumageRender
|
|||
models.skybox.destroy(VulkanBackend::VulkanFoundation::device);
|
||||
|
||||
|
||||
delete gui;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
#include "renderIO.h"
|
||||
|
||||
void PlumageRender::RenderInput::loadScene(std::string fileName)
|
||||
void PlumageRender::RenderInput::loadScene(std::string fileName,renderMain &mainRender, VulkanBackend::VulkanFoundation vkFoundation)
|
||||
{
|
||||
|
||||
std::cout << "Loading scene from " << fileName << std::endl;
|
||||
PlumageRender::renderMain::models.scene.destroy(VulkanBackend::VulkanFoundation::device);
|
||||
animationIndex = 0;
|
||||
animationTimer = 0.0f;
|
||||
mainRender.models.scene.destroy(vkFoundation.device);
|
||||
mainRender.animationIndex = 0;
|
||||
mainRender.animationTimer = 0.0f;
|
||||
auto tStart = std::chrono::high_resolution_clock::now();
|
||||
PlumageRender::renderMain::models.scene.loadFromFile(fileName, VulkanBackend::VulkanFoundation::vulkanDevice, VulkanBackend::VulkanFoundation::graphicQueue);
|
||||
mainRender.models.scene.loadFromFile(fileName, vkFoundation.vulkanDevice, vkFoundation.graphicQueue);
|
||||
auto tFileLoad = std::chrono::duration<double, std::milli>(std::chrono::high_resolution_clock::now() - tStart).count();
|
||||
std::cout << "Loading took " << tFileLoad << " ms" << std::endl;
|
||||
PlumageRender::renderMain::camera.setPosition({ 0.0f, 0.0f, -1.0f });
|
||||
PlumageRender::renderMain::camera.setRotation({ 0.0f, 0.0f, 0.0f });
|
||||
mainRender.camera.setPosition({ 0.0f, 0.0f, -1.0f });
|
||||
mainRender.camera.setRotation({ 0.0f, 0.0f, 0.0f });
|
||||
}
|
||||
|
||||
void PlumageRender::RenderInput::loadEnvironment(std::string fileName)
|
||||
void PlumageRender::RenderInput::loadEnvironment(std::string fileName,PBR::Material pbrMaterial,Setter setter ,VulkanBackend::VulkanFoundation vkFoundation, renderMain& mainRender)
|
||||
{
|
||||
std::cout << "Loading environment from " << fileName << std::endl;
|
||||
if (PBR::Material::textures.environmentCube.image) {
|
||||
PBR::Material::textures.environmentCube.destroy();
|
||||
PBR::Material::textures.irradianceCube.destroy();
|
||||
PBR::Material::textures.prefilteredCube.destroy();
|
||||
if (pbrMaterial.textures.environmentCube.image) {
|
||||
pbrMaterial.textures.environmentCube.destroy();
|
||||
pbrMaterial.textures.irradianceCube.destroy();
|
||||
pbrMaterial.textures.prefilteredCube.destroy();
|
||||
}
|
||||
PBR::Material::textures.environmentCube.loadFromFile(fileName, VK_FORMAT_R16G16B16A16_SFLOAT, VulkanBackend::VulkanFoundation::vulkanDevice, VulkanBackend::VulkanFoundation::graphicQueue);
|
||||
PBR::Material material;
|
||||
material.generateCubemap();
|
||||
pbrMaterial.textures.environmentCube.loadFromFile(fileName, VK_FORMAT_R16G16B16A16_SFLOAT, vkFoundation.vulkanDevice, vkFoundation.graphicQueue);
|
||||
pbrMaterial.generateCubemap(vkFoundation,setter,mainRender);
|
||||
}
|
||||
|
||||
void PlumageRender::RenderInput::loadAssets()
|
||||
|
|
|
@ -3,7 +3,17 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#ifndef _PBR_H
|
||||
#include "PBR.h"
|
||||
#define _PBR_H
|
||||
#endif // !PBR_H
|
||||
|
||||
#ifndef _RENDER_H
|
||||
#include "render.h"
|
||||
#define _RENDER_H
|
||||
#endif // !RENDER_H
|
||||
|
||||
|
||||
|
||||
namespace PlumageRender
|
||||
{
|
||||
|
@ -20,7 +30,7 @@ namespace PlumageRender
|
|||
std::map<std::string, std::string> scenes;
|
||||
std::string selectedScene = "DamagedHelmet";
|
||||
|
||||
void loadScene(std::string fileName);
|
||||
void loadScene(std::string fileName, renderMain& mainRender, VulkanBackend::VulkanFoundation vkFoundation);
|
||||
|
||||
void loadEnvironment(std::string fileName);
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace PlumageRender
|
|||
VkSampleCountFlagBits sampleCount = VK_SAMPLE_COUNT_4_BIT; // 多重采样倍率
|
||||
}settings;
|
||||
|
||||
Settings getSettings();
|
||||
|
||||
struct FilePath
|
||||
{
|
||||
|
@ -103,7 +102,7 @@ namespace PlumageRender
|
|||
std::string image2videoShFilePath = getAssetPath() + "script/image2video.sh";
|
||||
|
||||
}filePath;
|
||||
FilePath getFilePath();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -2,15 +2,15 @@
|
|||
#include <codecvt>
|
||||
|
||||
|
||||
void PlumageRender::PlumageGUI::updateUIOverlay(Setter setter)
|
||||
void PlumageRender::PlumageGUI::updateUIOverlay(UI* gui,Setter& setter,renderMain mainRender,VulkanBackend::VulkanFoundation vkFoundation,RenderInput renderInput,RenderOutput& renderOutput)
|
||||
{
|
||||
Setter::Settings settings = setter.getSettings();
|
||||
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
ImVec2 lastDisplaySize = io.DisplaySize;
|
||||
io.DisplaySize = ImVec2((float)PlumageRender::Setter::settings.width, (float)PlumageRender::Setter::settings.height);
|
||||
io.DeltaTime = PlumageRender::renderMain::frameTimer;
|
||||
io.DisplaySize = ImVec2((float)setter.settings.width, (float)setter.settings.height);
|
||||
io.DeltaTime = mainRender.frameTimer;
|
||||
|
||||
io.MousePos = ImVec2(mousePos.x, mousePos.y);
|
||||
io.MouseDown[0] = mouseButtons.left;
|
||||
|
@ -56,7 +56,7 @@ void PlumageRender::PlumageGUI::updateUIOverlay(Setter setter)
|
|||
}
|
||||
|
||||
if (!filename.empty()) {
|
||||
vkDeviceWaitIdle(VulkanBackend::VulkanFoundation::device);
|
||||
vkDeviceWaitIdle(vkFoundation.device);
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
|
||||
std::string stringFilename = converter.to_bytes(filename);
|
||||
|
||||
|
@ -84,7 +84,7 @@ void PlumageRender::PlumageGUI::updateUIOverlay(Setter setter)
|
|||
vkFoundation.createDescriptorSets();
|
||||
updateCBs = true;
|
||||
}
|
||||
if (gui->checkbox(chineseUI.environmentBackGround, &PlumageRender::Setter::settings.displayBackground)) {
|
||||
if (gui->checkbox(chineseUI.environmentBackGround, &setter.settings.displayBackground)) {
|
||||
updateShaderParams = true;
|
||||
}
|
||||
if (gui->slider("Exposure", &PBR::Material::shaderData.exposure, 0.1f, 10.0f)) {
|
||||
|
@ -127,7 +127,7 @@ void PlumageRender::PlumageGUI::updateUIOverlay(Setter setter)
|
|||
|
||||
if (gui->beginMenu(chineseUI.menuDebugFrameRate))
|
||||
{
|
||||
gui->text("%.1d fps (%.2f ms)", renderMain.lastFPS, (1000.0f / renderMain.lastFPS));
|
||||
gui->text("%.1d fps (%.2f ms)", mainRender.lastFPS, (1000.0f / mainRender.lastFPS));
|
||||
gui->endMenu();
|
||||
}
|
||||
gui->endMenu();
|
||||
|
@ -138,16 +138,16 @@ void PlumageRender::PlumageGUI::updateUIOverlay(Setter setter)
|
|||
{
|
||||
if (gui->beginMenu(chineseUI.menuAnimationActivation))
|
||||
{
|
||||
gui->checkbox(chineseUI.pauseAnimation, &PlumageRender::Setter::settings.animate);
|
||||
gui->checkbox(chineseUI.pauseAnimation, &setter.settings.animate);
|
||||
gui->endMenu();
|
||||
}
|
||||
if (gui->beginMenu(chineseUI.menuAnimationAnimationSequence))
|
||||
{
|
||||
std::vector<std::string> animationNames;
|
||||
for (auto animation : PlumageRender::renderMain::models.scene.animations) {
|
||||
for (auto animation : mainRender.models.scene.animations) {
|
||||
animationNames.push_back(animation.name);
|
||||
}
|
||||
gui->combo(chineseUI.animationSeq, &renderMain.animationIndex, animationNames);
|
||||
gui->combo(chineseUI.animationSeq, &mainRender.animationIndex, animationNames);
|
||||
gui->endMenu();
|
||||
}
|
||||
}
|
||||
|
@ -176,16 +176,16 @@ void PlumageRender::PlumageGUI::updateUIOverlay(Setter setter)
|
|||
bool updateBuffers = (gui->vertexBuffer.buffer == VK_NULL_HANDLE) || (gui->vertexBuffer.count != imDrawData->TotalVtxCount) || (gui->indexBuffer.buffer == VK_NULL_HANDLE) || (gui->indexBuffer.count != imDrawData->TotalIdxCount);
|
||||
|
||||
if (updateBuffers) {
|
||||
vkDeviceWaitIdle(VulkanBackend::VulkanFoundation::device);
|
||||
vkDeviceWaitIdle(vkFoundation.device);
|
||||
if (gui->vertexBuffer.buffer) {
|
||||
gui->vertexBuffer.destroy();
|
||||
}
|
||||
gui->vertexBuffer.create(VulkanBackend::VulkanFoundation::vulkanDevice, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, vertexBufferSize);
|
||||
gui->vertexBuffer.create(vkFoundation.vulkanDevice, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, vertexBufferSize);
|
||||
gui->vertexBuffer.count = imDrawData->TotalVtxCount;
|
||||
if (gui->indexBuffer.buffer) {
|
||||
gui->indexBuffer.destroy();
|
||||
}
|
||||
gui->indexBuffer.create(VulkanBackend::VulkanFoundation::vulkanDevice, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, indexBufferSize);
|
||||
gui->indexBuffer.create(vkFoundation.vulkanDevice, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, indexBufferSize);
|
||||
gui->indexBuffer.count = imDrawData->TotalIdxCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "ui.hpp"
|
||||
#include "VulkanDevice.hpp"
|
||||
#include "vulkanFoundation.h"
|
||||
#include "renderSetter.h"
|
||||
#include "renderIO.h"
|
||||
#ifndef _RENDER_H
|
||||
#include "render.h"
|
||||
#define _RENDER_H
|
||||
#endif // !RENDER_H
|
||||
|
||||
#ifndef _VULKANFOUNDATION_H
|
||||
#include "vulkanFoundation.h"
|
||||
#define _VULKANFOUNDATION_H
|
||||
#endif // !VULKANFOUNDATION_H
|
||||
|
||||
#ifndef _RENDERSETTER_H
|
||||
#include "renderSetter.h"
|
||||
#define _RENDERSETTER_H
|
||||
#endif // !RENDERSETTER_H
|
||||
|
||||
#ifndef _RENDERIO_H
|
||||
#include "renderIO.h"
|
||||
#define _RENDERIO_H
|
||||
#endif // !RENDERIO_H
|
||||
|
||||
#ifndef _UI_HPP
|
||||
#include "ui.hpp"
|
||||
#define _UI_HPP
|
||||
#endif // !UI_HPP
|
||||
|
||||
|
||||
namespace PlumageRender
|
||||
{
|
||||
class PlumageGUI
|
||||
|
@ -15,9 +34,9 @@ namespace PlumageRender
|
|||
PlumageGUI();
|
||||
~PlumageGUI();
|
||||
|
||||
UI* gui = new UI(VulkanBackend::VulkanFoundation::vulkanDevice, VulkanBackend::VulkanFoundation::renderPass, VulkanBackend::VulkanFoundation::graphicQueue, VulkanBackend::VulkanFoundation::pipelineCache, PlumageRender::Setter::settings.sampleCount);
|
||||
|
||||
|
||||
void updateUIOverlay();
|
||||
void updateUIOverlay(UI* gui,Setter& setter,renderMain mainRender, VulkanBackend::VulkanFoundation vkFoundation, RenderInput renderInput, RenderOutput& renderOutput);
|
||||
|
||||
struct DebugView
|
||||
{
|
||||
|
@ -67,8 +86,6 @@ namespace PlumageRender
|
|||
|
||||
const char* menuAnimationActivation = "开关";
|
||||
const char* menuAnimationAnimationSequence = "动画序列";
|
||||
|
||||
|
||||
}chineseUI;
|
||||
|
||||
};
|
||||
|
|
|
@ -1,19 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
#include "GLFW/glfw3.h"
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
#include "renderSetter.h"
|
||||
#include <VulkanSwapChain.hpp>
|
||||
#ifndef _GLTFMODEL_H
|
||||
#include "glTFModel.h"
|
||||
#define _GLTFMODEL_H
|
||||
#endif // !GLTFMODEL_H
|
||||
|
||||
#ifndef _RENDERSETTER_H
|
||||
#include "renderSetter.h"
|
||||
#define _RENDERSETTER_H
|
||||
#endif // !RENDERSETTER_H
|
||||
|
||||
|
||||
|
||||
#include "VulkanUtils.hpp"
|
||||
#include "PBR.h"
|
||||
#include <VulkanSwapChain.hpp>
|
||||
|
||||
#include "VulkanDevice.hpp"
|
||||
#include "renderUI.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -165,7 +175,7 @@ namespace VulkanBackend
|
|||
|
||||
private:
|
||||
|
||||
PlumageRender::PlumageGUI plumageGui;
|
||||
|
||||
|
||||
VkInstance instance;
|
||||
|
||||
|
|
Loading…
Reference in New Issue