Bulk update NvPro-Samples 05/21/21

This commit is contained in:
Mathias Heyer 2021-05-21 16:15:58 -07:00
parent 3b0c3536e0
commit b3e6d84807
53 changed files with 359 additions and 366 deletions

View file

@ -118,11 +118,11 @@ void HelloVulkan::updateUniformBuffer(const vk::CommandBuffer& cmdBuf)
//
void HelloVulkan::createDescriptorSetLayout()
{
using vkDS = vk::DescriptorSetLayoutBinding;
using vkDT = vk::DescriptorType;
using vkSS = vk::ShaderStageFlagBits;
uint32_t nbTxt = static_cast<uint32_t>(m_textures.size());
uint32_t nbObj = static_cast<uint32_t>(m_objModel.size());
using vkDS = vk::DescriptorSetLayoutBinding;
using vkDT = vk::DescriptorType;
using vkSS = vk::ShaderStageFlagBits;
auto nbTxt = static_cast<uint32_t>(m_textures.size());
auto nbObj = static_cast<uint32_t>(m_objModel.size());
// Camera matrices (binding = 0)
m_descSetLayoutBind.addBinding(
@ -230,11 +230,12 @@ void HelloVulkan::createGraphicsPipeline()
gpb.addShader(nvh::loadFile("spv/vert_shader.vert.spv", true, paths, true), vkSS::eVertex);
gpb.addShader(nvh::loadFile("spv/frag_shader.frag.spv", true, paths, true), vkSS::eFragment);
gpb.addBindingDescription({0, sizeof(VertexObj)});
gpb.addAttributeDescriptions(std::vector<vk::VertexInputAttributeDescription>{
{0, 0, vk::Format::eR32G32B32Sfloat, offsetof(VertexObj, pos)},
{1, 0, vk::Format::eR32G32B32Sfloat, offsetof(VertexObj, nrm)},
{2, 0, vk::Format::eR32G32B32Sfloat, offsetof(VertexObj, color)},
{3, 0, vk::Format::eR32G32Sfloat, offsetof(VertexObj, texCoord)}});
gpb.addAttributeDescriptions({
{0, 0, vk::Format::eR32G32B32Sfloat, static_cast<uint32_t>(offsetof(VertexObj, pos))},
{1, 0, vk::Format::eR32G32B32Sfloat, static_cast<uint32_t>(offsetof(VertexObj, nrm))},
{2, 0, vk::Format::eR32G32B32Sfloat, static_cast<uint32_t>(offsetof(VertexObj, color))},
{3, 0, vk::Format::eR32G32Sfloat, static_cast<uint32_t>(offsetof(VertexObj, texCoord))},
});
m_graphicsPipeline = gpb.createPipeline();
m_debug.setObjectName(m_graphicsPipeline, "Graphics");

View file

@ -56,8 +56,7 @@ static void onErrorCallback(int error, const char* description)
// Extra UI
void renderUI(HelloVulkan& helloVk)
{
static int item = 1;
bool changed = false;
bool changed = false;
changed |= ImGuiH::CameraWidget();
if(ImGui::CollapsingHeader("Light"))
@ -315,7 +314,7 @@ int main(int argc, char** argv)
helloVk.updateUniformBuffer(cmdBuf);
// Clearing screen
vk::ClearValue clearValues[2];
std::array<vk::ClearValue, 2> clearValues;
clearValues[0].setColor(
std::array<float, 4>({clearColor[0], clearColor[1], clearColor[2], clearColor[3]}));
clearValues[1].setDepthStencil({1.0f, 0});
@ -324,7 +323,7 @@ int main(int argc, char** argv)
{
vk::RenderPassBeginInfo offscreenRenderPassBeginInfo;
offscreenRenderPassBeginInfo.setClearValueCount(2);
offscreenRenderPassBeginInfo.setPClearValues(clearValues);
offscreenRenderPassBeginInfo.setPClearValues(clearValues.data());
offscreenRenderPassBeginInfo.setRenderPass(offscreen.renderPass());
offscreenRenderPassBeginInfo.setFramebuffer(offscreen.frameBuffer());
offscreenRenderPassBeginInfo.setRenderArea({{}, helloVk.getSize()});
@ -346,7 +345,7 @@ int main(int argc, char** argv)
{
vk::RenderPassBeginInfo postRenderPassBeginInfo;
postRenderPassBeginInfo.setClearValueCount(2);
postRenderPassBeginInfo.setPClearValues(clearValues);
postRenderPassBeginInfo.setPClearValues(clearValues.data());
postRenderPassBeginInfo.setRenderPass(helloVk.getRenderPass());
postRenderPassBeginInfo.setFramebuffer(helloVk.getFramebuffers()[curFrame]);
postRenderPassBeginInfo.setRenderArea({{}, helloVk.getSize()});

View file

@ -75,6 +75,6 @@ struct ImplInst
std::vector<MaterialObj> implMat; // All materials used by implicit obj
nvvk::Buffer implBuf; // Buffer of objects
nvvk::Buffer implMatBuf; // Buffer of material
int blasId;
int blasId{0};
nvmath::mat4f transform{1};
};

View file

@ -62,7 +62,7 @@ private:
nvvk::Texture m_colorTexture;
vk::Format m_colorFormat{vk::Format::eR32G32B32A32Sfloat};
nvvk::Texture m_depthTexture;
vk::Format m_depthFormat;
vk::Format m_depthFormat{vk::Format::eX8D24UnormPack32};
nvvk::ResourceAllocator* m_alloc{
nullptr}; // Allocator for buffer, images, acceleration structures

View file

@ -360,9 +360,8 @@ void Raytracer::createRtPipeline(vk::DescriptorSetLayout& sceneDescLayout)
rayPipelineInfo.setMaxPipelineRayRecursionDepth(2); // Ray depth
rayPipelineInfo.setLayout(m_rtPipelineLayout);
m_rtPipeline = static_cast<const vk::Pipeline&>(
m_device.createRayTracingPipelineKHR({}, {}, rayPipelineInfo));
m_rtPipeline = m_device.createRayTracingPipelineKHR({}, {}, rayPipelineInfo).value;
m_sbtWrapper.create(m_rtPipeline, rayPipelineInfo);

View file

@ -72,7 +72,7 @@ private:
{
nvmath::vec4f clearColor;
nvmath::vec3f lightPosition;
float lightIntensity;
float lightIntensity{100.0f};
nvmath::vec3f lightDirection{-1, -1, -1};
float lightSpotCutoff{deg2rad(12.5f)};
float lightSpotOuterCutoff{deg2rad(17.5f)};