ready for UI reconstruct

pull/2/head
ink-soul 2023-06-06 17:18:45 +08:00
parent aceb49e0be
commit f53e0ad463
11 changed files with 328 additions and 130 deletions

View File

@ -46,6 +46,7 @@ namespace vks
return std::find(formats.begin(), formats.end(), format) != std::end(formats); return std::find(formats.begin(), formats.end(), format) != std::end(formats);
} }
/** /**
* @brief Returns true if the attachment has a stencil component * @brief Returns true if the attachment has a stencil component
*/ */

View File

@ -17,7 +17,7 @@ const std::string getAssetPath()
#elif defined(VK_EXAMPLE_DATA_DIR) #elif defined(VK_EXAMPLE_DATA_DIR)
return VK_EXAMPLE_DATA_DIR; return VK_EXAMPLE_DATA_DIR;
#else #else
return "./../data/"; return "../../data";
#endif #endif
} }
#endif #endif

51
base/macros.h 100644
View File

@ -0,0 +1,51 @@
/*
* Global macros
*
* Copyright (C) 2018 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#pragma once
#include "vulkan/vulkan.h"
#if defined(__ANDROID__)
#define VK_CHECK_RESULT(f) \
{ \
VkResult res = (f); \
if (res != VK_SUCCESS) \
{ \
LOGE("Fatal : VkResult is \" %d \" in %s at line %d", res, __FILE__, __LINE__); \
assert(res == VK_SUCCESS); \
} \
}
#else
#define VK_CHECK_RESULT(f) \
{ \
VkResult res = (f); \
if (res != VK_SUCCESS) \
{ \
std::cout << "Fatal : VkResult is \"" << res << "\" in " << __FILE__ << " at line " << __LINE__ << std::endl; \
assert(res == VK_SUCCESS); \
} \
}
#endif
#define GET_INSTANCE_PROC_ADDR(inst, entrypoint) \
{ \
fp##entrypoint = reinterpret_cast<PFN_vk##entrypoint>(vkGetInstanceProcAddr(inst, "vk"#entrypoint)); \
if (fp##entrypoint == NULL) \
{ \
exit(1); \
} \
}
#define GET_DEVICE_PROC_ADDR(dev, entrypoint) \
{ \
fp##entrypoint = reinterpret_cast<PFN_vk##entrypoint>(vkGetDeviceProcAddr(dev, "vk"#entrypoint)); \
if (fp##entrypoint == NULL) \
{ \
exit(1); \
} \
}

View File

@ -299,6 +299,8 @@ void VulkanExampleBase::prepare()
void VulkanExampleBase::fileDropped(std::string filename) { } void VulkanExampleBase::fileDropped(std::string filename) { }
void VulkanExampleBase::renderFrame() void VulkanExampleBase::renderFrame()
{ {
auto tStart = std::chrono::high_resolution_clock::now(); auto tStart = std::chrono::high_resolution_clock::now();

View File

@ -30,7 +30,7 @@ function(buildHomework HOMEWORK_NAME)
# Add optional readme / tutorial # Add optional readme / tutorial
file(GLOB README_FILES "${HOMEWORK_FOLDER}/*.md") file(GLOB README_FILES "${HOMEWORK_FOLDER}/*.md")
if(WIN32) if(WIN32)
add_executable(${HOMEWORK_NAME} WIN32 ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES} "render/glTFModel.h" "render/glTFModel.cpp" "render/GUIFunction.h" "render/GUIFunction.cpp") add_executable(${HOMEWORK_NAME} WIN32 ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES} "render/glTFModel.h" "render/glTFModel.cpp" "render/GUIFunc.h" "render/GUIFunc.cpp")
target_link_libraries(${HOMEWORK_NAME} base ${Vulkan_LIBRARY} ${WINLIBS}) target_link_libraries(${HOMEWORK_NAME} base ${Vulkan_LIBRARY} ${WINLIBS})
else(WIN32) else(WIN32)
add_executable(${HOMEWORK_NAME} ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES}) add_executable(${HOMEWORK_NAME} ${MAIN_CPP} ${SOURCE} ${MAIN_HEADER} ${SHADERS_GLSL} ${SHADERS_HLSL} ${README_FILES})

View File

@ -0,0 +1,183 @@
#include "GUIFunc.h"
GUIFunc::GUIFunc(vks::VulkanDevice* vulkanDevice, VkRenderPass renderPass, VkQueue queue, VkPipelineCache pipelineCache, VkSampleCountFlagBits multiSampleCount)
{
this->device = vulkanDevice->logicalDevice;
ImGui::CreateContext();
/*
Font texture loading
*/
ImGuiIO& io = ImGui::GetIO();
unsigned char* fontData;
int texWidth, texHeight;
io.Fonts->AddFontFromFileTTF("./../data/Roboto-Medium.ttf", 16.0f);
io.Fonts->GetTexDataAsRGBA32(&fontData, &texWidth, &texHeight);
fontTexture.loadFromBuffer(fontData, texWidth * texHeight * 4 * sizeof(char), VK_FORMAT_R8G8B8A8_UNORM, texWidth, texHeight, vulkanDevice, queue);
/*
Setup
*/
ImGuiStyle& style = ImGui::GetStyle();
style.FrameBorderSize = 0.0f;
style.WindowBorderSize = 0.0f;
/*
Descriptor pool
*/
std::vector<VkDescriptorPoolSize> poolSizes = {
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1 }
};
VkDescriptorPoolCreateInfo descriptorPoolCI{};
descriptorPoolCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
descriptorPoolCI.poolSizeCount = 1;
descriptorPoolCI.pPoolSizes = poolSizes.data();
descriptorPoolCI.maxSets = 1;
VK_CHECK_RESULT(vkCreateDescriptorPool(device, &descriptorPoolCI, nullptr, &descriptorPool));
/*
Descriptor set layout
*/
VkDescriptorSetLayoutBinding setLayoutBinding{ 0, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1, VK_SHADER_STAGE_FRAGMENT_BIT, nullptr };
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCI{};
descriptorSetLayoutCI.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
descriptorSetLayoutCI.pBindings = &setLayoutBinding;
descriptorSetLayoutCI.bindingCount = 1;
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(device, &descriptorSetLayoutCI, nullptr, &descriptorSetLayout));
/*
Descriptor set
*/
VkDescriptorSetAllocateInfo descriptorSetAllocInfo{};
descriptorSetAllocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
descriptorSetAllocInfo.descriptorPool = descriptorPool;
descriptorSetAllocInfo.pSetLayouts = &descriptorSetLayout;
descriptorSetAllocInfo.descriptorSetCount = 1;
VK_CHECK_RESULT(vkAllocateDescriptorSets(device, &descriptorSetAllocInfo, &descriptorSet));
VkWriteDescriptorSet writeDescriptorSet{};
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
writeDescriptorSet.descriptorCount = 1;
writeDescriptorSet.dstSet = descriptorSet;
writeDescriptorSet.dstBinding = 0;
writeDescriptorSet.pImageInfo = &fontTexture.descriptor;
vkUpdateDescriptorSets(device, 1, &writeDescriptorSet, 0, nullptr);
/*
Pipeline layout
*/
VkPushConstantRange pushConstantRange{ VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(PushConstBlock) };
VkPipelineLayoutCreateInfo pipelineLayoutCI{};
pipelineLayoutCI.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutCI.pushConstantRangeCount = 1;
pipelineLayoutCI.pPushConstantRanges = &pushConstantRange;
pipelineLayoutCI.setLayoutCount = 1;
pipelineLayoutCI.pSetLayouts = &descriptorSetLayout;
pipelineLayoutCI.pushConstantRangeCount = 1;
pipelineLayoutCI.pPushConstantRanges = &pushConstantRange;
VK_CHECK_RESULT(vkCreatePipelineLayout(device, &pipelineLayoutCI, nullptr, &pipelineLayout));
/*
Pipeline
*/
VkPipelineInputAssemblyStateCreateInfo inputAssemblyStateCI{};
inputAssemblyStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
inputAssemblyStateCI.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
VkPipelineRasterizationStateCreateInfo rasterizationStateCI{};
rasterizationStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
rasterizationStateCI.polygonMode = VK_POLYGON_MODE_FILL;
rasterizationStateCI.cullMode = VK_CULL_MODE_NONE;
rasterizationStateCI.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
rasterizationStateCI.lineWidth = 1.0f;
VkPipelineColorBlendAttachmentState blendAttachmentState{};
blendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
blendAttachmentState.blendEnable = VK_TRUE;
blendAttachmentState.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
blendAttachmentState.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
blendAttachmentState.colorBlendOp = VK_BLEND_OP_ADD;
blendAttachmentState.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
blendAttachmentState.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
blendAttachmentState.alphaBlendOp = VK_BLEND_OP_ADD;
VkPipelineColorBlendStateCreateInfo colorBlendStateCI{};
colorBlendStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
colorBlendStateCI.attachmentCount = 1;
colorBlendStateCI.pAttachments = &blendAttachmentState;
VkPipelineDepthStencilStateCreateInfo depthStencilStateCI{};
depthStencilStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
depthStencilStateCI.depthTestEnable = VK_FALSE;
depthStencilStateCI.depthWriteEnable = VK_FALSE;
depthStencilStateCI.depthCompareOp = VK_COMPARE_OP_LESS_OR_EQUAL;
depthStencilStateCI.front = depthStencilStateCI.back;
depthStencilStateCI.back.compareOp = VK_COMPARE_OP_ALWAYS;
VkPipelineViewportStateCreateInfo viewportStateCI{};
viewportStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
viewportStateCI.viewportCount = 1;
viewportStateCI.scissorCount = 1;
VkPipelineMultisampleStateCreateInfo multisampleStateCI{};
multisampleStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
if (multiSampleCount > VK_SAMPLE_COUNT_1_BIT) {
multisampleStateCI.rasterizationSamples = multiSampleCount;
}
std::vector<VkDynamicState> dynamicStateEnables = {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR
};
VkPipelineDynamicStateCreateInfo dynamicStateCI{};
dynamicStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
dynamicStateCI.pDynamicStates = dynamicStateEnables.data();
dynamicStateCI.dynamicStateCount = static_cast<uint32_t>(dynamicStateEnables.size());
VkVertexInputBindingDescription vertexInputBinding = { 0, 20, VK_VERTEX_INPUT_RATE_VERTEX };
std::vector<VkVertexInputAttributeDescription> vertexInputAttributes = {
{ 0, 0, VK_FORMAT_R32G32_SFLOAT, 0 },
{ 1, 0, VK_FORMAT_R32G32_SFLOAT, sizeof(float) * 2 },
{ 2, 0, VK_FORMAT_R8G8B8A8_UNORM, sizeof(float) * 4 },
};
VkPipelineVertexInputStateCreateInfo vertexInputStateCI{};
vertexInputStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputStateCI.vertexBindingDescriptionCount = 1;
vertexInputStateCI.pVertexBindingDescriptions = &vertexInputBinding;
vertexInputStateCI.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertexInputAttributes.size());
vertexInputStateCI.pVertexAttributeDescriptions = vertexInputAttributes.data();
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
VkGraphicsPipelineCreateInfo pipelineCI{};
pipelineCI.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
pipelineCI.layout = pipelineLayout;
pipelineCI.renderPass = renderPass;
pipelineCI.pInputAssemblyState = &inputAssemblyStateCI;
pipelineCI.pVertexInputState = &vertexInputStateCI;
pipelineCI.pRasterizationState = &rasterizationStateCI;
pipelineCI.pColorBlendState = &colorBlendStateCI;
pipelineCI.pMultisampleState = &multisampleStateCI;
pipelineCI.pViewportState = &viewportStateCI;
pipelineCI.pDepthStencilState = &depthStencilStateCI;
pipelineCI.pDynamicState = &dynamicStateCI;
pipelineCI.stageCount = static_cast<uint32_t>(shaderStages.size());
pipelineCI.pStages = shaderStages.data();
pipelineCI.layout = pipelineLayout;
shaderStages = {
loadShader(device, "ui.vert.spv", VK_SHADER_STAGE_VERTEX_BIT),
loadShader(device, "ui.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT)
};
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
for (auto shaderStage : shaderStages) {
vkDestroyShaderModule(device, shaderStage.module, nullptr);
}
}

View File

@ -0,0 +1,48 @@
#pragma once
#include <vector>
#include <array>
#include <map>
#include "vulkan/vulkan.h"
#include "imgui/imgui.h"
#include "VulkanDevice.hpp"
#include "VulkanUtils.hpp"
#include "VulkanTexture.h"
#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
class GUIFunc
{
private:
VkDevice device;
public:
Buffer vertexBuffer, indexBuffer;
vks::Texture2D fontTexture;
VkPipelineLayout pipelineLayout;
VkPipeline pipeline;
VkDescriptorPool descriptorPool;
VkDescriptorSetLayout descriptorSetLayout;
VkDescriptorSet descriptorSet;
struct PushConstBlock {
glm::vec2 scale;
glm::vec2 translate;
} pushConstBlock;
};

View File

@ -1,78 +0,0 @@
#include "GUIFunction.h"
// win32 api IFileOpenDialog
std::string GUIFunction::openFileFolderDialog()
{
//initialize COM lib
std::string strFilePath = GUIFunction::strFilePath;
HRESULT hResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
if (SUCCEEDED(hResult))
{
IFileOpenDialog* pFileOpen = nullptr;
hResult = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_ALL, IID_IFileOpenDialog, reinterpret_cast<void**>(&pFileOpen));
DWORD fileFormatFlag;
hResult = pFileOpen->GetOptions(&fileFormatFlag);
hResult = pFileOpen->SetOptions(fileFormatFlag | FOS_FORCEFILESYSTEM);
COMDLG_FILTERSPEC fileType[] =
{
{L"all files",L"*.*"},
{L"compiled shader",L"*.spv*"},
{L"gltf model files",L"*.gltf*"},
{L"gltf model files",L"*.GLTF*"},
};
hResult = pFileOpen->SetFileTypes(ARRAYSIZE(fileType), fileType);
hResult = pFileOpen->SetFileTypeIndex(0);
if (SUCCEEDED(hResult))
{
// Show the Open dialog box.
hResult = pFileOpen->Show(NULL);
// Get the file name from the dialog box.
if (SUCCEEDED(hResult))
{
IShellItem* pItem;
hResult = pFileOpen->GetResult(&pItem);
if (SUCCEEDED(hResult))
{
PWSTR pszFilePath;
std::wstring wstrFilePath;
hResult = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath);
// Display the file name to the user.
if (SUCCEEDED(hResult))
{
wstrFilePath = pszFilePath;
CoTaskMemFree(pszFilePath);
using convert_type = std::codecvt_utf8<wchar_t>;
std::wstring_convert<convert_type, wchar_t> converter;
strFilePath = converter.to_bytes(wstrFilePath);
}
pItem->Release();
}
}
pFileOpen->Release();
}
CoUninitialize();
}
return strFilePath;
};

View File

@ -1,28 +0,0 @@
#pragma once
#include <cstdio>
#include <string>
#include <locale>
#include <codecvt>
#include <shobjidl.h>
#include <windows.h>
#include <vulkanexamplebase.h>
class GUIFunction
{
public:
PWSTR glTFFilePath ;
std::string strFilePath = getAssetPath() + "buster_drone/busterDrone.gltf";
bool newModelFile;
std::string openFileFolderDialog();
private:
};

View File

@ -30,24 +30,19 @@
#include "render.h" #include "render.h"
#include "GUIFunction.h" #include "GUIFunc.h"
#include "assetLoader.h" #include "assetLoader.h"
#include <VulkanTools.h>
#include <VulkanTexture.h>
PlumageRender::PlumageRender():
VulkanExampleBase(ENABLE_VALIDATION) PlumageRender::PlumageRender():PlumageRender()
{ {
title = "plumage render"; title = "plumage render";
} }
void PlumageRender::getEnabledFeatures()
{
// Fill mode non solid is required for wireframe display
if (deviceFeatures.fillModeNonSolid) {
enabledFeatures.fillModeNonSolid = VK_TRUE;
};
}
void PlumageRender::renderNode(glTFModel::Node* node, uint32_t cbIndex, glTFModel::Material::AlphaMode alphaMode) { void PlumageRender::renderNode(glTFModel::Node* node, uint32_t cbIndex, glTFModel::Material::AlphaMode alphaMode) {
if (node->mesh) { if (node->mesh) {
@ -644,8 +639,8 @@ PlumageRender::PlumageRender():
// Skybox pipeline (background cube) // Skybox pipeline (background cube)
shaderStages = { shaderStages = {
loadShader(filePath.skyboxVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT), loadShader(device,filePath.skyboxVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
loadShader(filePath.skyboxFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT) loadShader(device,filePath.skyboxFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT)
}; };
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.skybox)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipelines.skybox));
for (auto shaderStage : shaderStages) { for (auto shaderStage : shaderStages) {
@ -654,8 +649,8 @@ PlumageRender::PlumageRender():
// PBR pipeline // PBR pipeline
shaderStages = { shaderStages = {
loadShader(filePath.pbrVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT), loadShader(device,filePath.pbrVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
loadShader(filePath.pbrFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT) loadShader(device,filePath.pbrFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT)
}; };
depthStencilStateCI.depthWriteEnable = VK_TRUE; depthStencilStateCI.depthWriteEnable = VK_TRUE;
depthStencilStateCI.depthTestEnable = VK_TRUE; depthStencilStateCI.depthTestEnable = VK_TRUE;
@ -702,8 +697,8 @@ PlumageRender::PlumageRender():
const std::string fragPath = ToneMapping ? filePath.tonemappingEnableFragShaderPath : filePath.tonemappingDisableFragShaderPath; const std::string fragPath = ToneMapping ? filePath.tonemappingEnableFragShaderPath : filePath.tonemappingDisableFragShaderPath;
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = { std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages = {
loadShader(filePath.tonemappingVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT), loadShader(device,filePath.tonemappingVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
loadShader(fragPath, VK_SHADER_STAGE_FRAGMENT_BIT) loadShader(device,fragPath, VK_SHADER_STAGE_FRAGMENT_BIT)
}; };
VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayouts.tonemappingLayout, renderPass, 0); VkGraphicsPipelineCreateInfo pipelineCI = vks::initializers::pipelineCreateInfo(pipelineLayouts.tonemappingLayout, renderPass, 0);
@ -1050,13 +1045,13 @@ PlumageRender::PlumageRender():
pipelineCI.pStages = shaderStages.data(); pipelineCI.pStages = shaderStages.data();
pipelineCI.renderPass = renderpass; pipelineCI.renderPass = renderpass;
shaderStages[0] = loadShader(filePath.filterVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT); shaderStages[0] = loadShader(device,filePath.filterVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT);
switch (target) { switch (target) {
case IRRADIANCE: case IRRADIANCE:
shaderStages[1] = loadShader(filePath.irradianceFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT); shaderStages[1] = loadShader(device,filePath.irradianceFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
break; break;
case PREFILTEREDENV: case PREFILTEREDENV:
shaderStages[1] = loadShader(filePath.prefilterEnvmapFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT); shaderStages[1] = loadShader(device,filePath.prefilterEnvmapFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT);
break; break;
}; };
VkPipeline pipeline; VkPipeline pipeline;
@ -1460,8 +1455,8 @@ PlumageRender::PlumageRender():
// Look-up-table (from BRDF) pipeline // Look-up-table (from BRDF) pipeline
shaderStages = { shaderStages = {
loadShader(filePath.brdfVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT), loadShader(device,filePath.brdfVertShaderPath, VK_SHADER_STAGE_VERTEX_BIT),
loadShader(filePath.brdfFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT) loadShader(device,filePath.brdfFragShaderPath, VK_SHADER_STAGE_FRAGMENT_BIT)
}; };
VkPipeline pipeline; VkPipeline pipeline;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCI, nullptr, &pipeline));
@ -1774,4 +1769,27 @@ PlumageRender::PlumageRender():
} }
PLUMAGE_RENDER_MAIN()
PlumageRender* plumageRender;
// OS specific macros for the example main entry points
#if defined(_WIN32)
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (plumageRender != NULL)
{
plumageRender->handleMessages(hWnd, uMsg, wParam, lParam);
}
return (DefWindowProc(hWnd, uMsg, wParam, lParam));
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
for (int32_t i = 0; i < __argc; i++) { PlumageRender::args.push_back(__argv[i]); };
plumageRender = new PlumageRender();
plumageRender->initVulkan();
plumageRender->setupWindow(hInstance, WndProc);
plumageRender->prepare();
plumageRender->renderLoop();
delete(plumageRender);
return 0;
}
#endif

View File

@ -15,6 +15,7 @@
#include "VulkanExampleBase.h" #include "VulkanExampleBase.h"
#include "glTFModel.h" #include "glTFModel.h"
#include "VulkanUtils.hpp" #include "VulkanUtils.hpp"
#include <VulkanTexture.h>
//#include "VulkanDevice.hpp" //#include "VulkanDevice.hpp"