diff --git a/projects/rt_ambient_occlusion/resources/Sponza/Sponza.bin b/projects/rt_ambient_occlusion/assets/Sponza/Sponza.bin similarity index 100% rename from projects/rt_ambient_occlusion/resources/Sponza/Sponza.bin rename to projects/rt_ambient_occlusion/assets/Sponza/Sponza.bin diff --git a/projects/rt_ambient_occlusion/resources/Sponza/Sponza.gltf b/projects/rt_ambient_occlusion/assets/Sponza/Sponza.gltf similarity index 100% rename from projects/rt_ambient_occlusion/resources/Sponza/Sponza.gltf rename to projects/rt_ambient_occlusion/assets/Sponza/Sponza.gltf diff --git a/projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rchit b/projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rchit similarity index 100% rename from projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rchit rename to projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rchit diff --git a/projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rgen b/projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rgen similarity index 99% rename from projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rgen rename to projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rgen index cecbfcc9aaff3dea184112c9e8988a290dbb9518..ad3c18ad213779be5578a298049283a0f62061d9 100644 --- a/projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rgen +++ b/projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rgen @@ -114,7 +114,7 @@ vec3 sampleCosineDistribution(vec2 xi) { sqrt(xi.x) * cos(phi), sqrt(1 - xi.x), sqrt(xi.x) * sin(phi) - ); + ); } struct Basis{ diff --git a/projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rmiss b/projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rmiss similarity index 100% rename from projects/rt_ambient_occlusion/resources/shaders/ambientOcclusion.rmiss rename to projects/rt_ambient_occlusion/assets/shaders/ambientOcclusion.rmiss diff --git a/projects/rt_ambient_occlusion/src/main.cpp b/projects/rt_ambient_occlusion/src/main.cpp index 49d6156405af2149c0fe0ec38c72635554af690e..2194ac1481c3f0e5e44909aa3a2f78c4bf6da911 100644 --- a/projects/rt_ambient_occlusion/src/main.cpp +++ b/projects/rt_ambient_occlusion/src/main.cpp @@ -70,7 +70,7 @@ int main(int argc, const char** argv) { vkcv::scene::Scene scene = vkcv::scene::Scene::load( core, - "resources/Sponza/Sponza.gltf", + "assets/Sponza/Sponza.gltf", { vkcv::asset::PrimitiveType::POSITION } @@ -86,17 +86,17 @@ int main(int argc, const char** argv) { vkcv::shader::GLSLCompiler compiler (vkcv::shader::GLSLCompileTarget::RAY_TRACING); vkcv::ShaderProgram shaderProgram; - compiler.compile(vkcv::ShaderStage::RAY_GEN, std::filesystem::path("resources/shaders/ambientOcclusion.rgen"), + compiler.compile(vkcv::ShaderStage::RAY_GEN, std::filesystem::path("assets/shaders/ambientOcclusion.rgen"), [&shaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { shaderProgram.addShader(shaderStage, path); }); - compiler.compile(vkcv::ShaderStage::RAY_CLOSEST_HIT, std::filesystem::path("resources/shaders/ambientOcclusion.rchit"), + compiler.compile(vkcv::ShaderStage::RAY_CLOSEST_HIT, std::filesystem::path("assets/shaders/ambientOcclusion.rchit"), [&shaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { shaderProgram.addShader(shaderStage, path); }); - compiler.compile(vkcv::ShaderStage::RAY_MISS, std::filesystem::path("resources/shaders/ambientOcclusion.rmiss"), + compiler.compile(vkcv::ShaderStage::RAY_MISS, std::filesystem::path("assets/shaders/ambientOcclusion.rmiss"), [&shaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) { shaderProgram.addShader(shaderStage, path); }); diff --git a/src/vkcv/RayTracingPipelineManager.cpp b/src/vkcv/RayTracingPipelineManager.cpp index aae73acf3ef0012bf72ea027674487fc9c280dfc..28acac9d22597d34d1a9824aff10ec255102d46f 100644 --- a/src/vkcv/RayTracingPipelineManager.cpp +++ b/src/vkcv/RayTracingPipelineManager.cpp @@ -3,6 +3,9 @@ #include "vkcv/Core.hpp" #include "vkcv/Logger.hpp" +#include <cstring> +#include <iostream> +#include <iterator> namespace vkcv { @@ -184,7 +187,7 @@ namespace vkcv { size_t missShaderGroupIndex = genShaderGroupIndex; size_t hitShaderGroupIndex = genShaderGroupIndex; size_t callShaderGroupIndex = genShaderGroupIndex; - + if (existsRayGenShader) { vk::PipelineShaderStageCreateInfo createInfo; const bool success = createPipelineShaderStageCreateInfo( @@ -311,7 +314,7 @@ namespace vkcv { nullptr ); } - + Vector<vk::DescriptorSetLayout> descriptorSetLayouts; descriptorSetLayouts.reserve(config.getDescriptorSetLayouts().size()); for (const auto &handle : config.getDescriptorSetLayouts()) { @@ -456,7 +459,7 @@ namespace vkcv { rayMissAddress = vk::StridedDeviceAddressRegionKHR( bufferBaseAddress + missShaderGroupIndex * tableSizeAlignment, shaderBindingTableSize, - shaderBindingTableSize + tableSizeAlignment ); } @@ -464,7 +467,7 @@ namespace vkcv { rayHitAddress = vk::StridedDeviceAddressRegionKHR( bufferBaseAddress + hitShaderGroupIndex * tableSizeAlignment, shaderBindingTableSize, - shaderBindingTableSize + tableSizeAlignment ); } @@ -472,10 +475,10 @@ namespace vkcv { rayCallAddress = vk::StridedDeviceAddressRegionKHR( bufferBaseAddress + callShaderGroupIndex * tableSizeAlignment, shaderBindingTableSize, - shaderBindingTableSize + tableSizeAlignment ); } - + return add({ pipeline, pipelineLayout, @@ -501,35 +504,39 @@ namespace vkcv { const RayTracingPipelineConfig & RayTracingPipelineManager::getPipelineConfig(const RayTracingPipelineHandle &handle) const { - auto &pipeline = (*this) [handle]; + const auto &pipeline = (*this) [handle]; return pipeline.m_config; } const vk::StridedDeviceAddressRegionKHR * RayTracingPipelineManager::getRayGenShaderBindingTableAddress( const vkcv::RayTracingPipelineHandle &handle) const { - auto &pipeline = (*this) [handle]; + const auto &pipeline = (*this) [handle]; + if (pipeline.m_rayGenAddress.size == 0) return nullptr; return &(pipeline.m_rayGenAddress); } const vk::StridedDeviceAddressRegionKHR * RayTracingPipelineManager::getMissShaderBindingTableAddress( const vkcv::RayTracingPipelineHandle &handle) const { - auto &pipeline = (*this) [handle]; + const auto &pipeline = (*this) [handle]; + if (pipeline.m_rayMissAddress.size == 0) return nullptr; return &(pipeline.m_rayMissAddress); } const vk::StridedDeviceAddressRegionKHR * RayTracingPipelineManager::getHitShaderBindingTableAddress( const vkcv::RayTracingPipelineHandle &handle) const { - auto &pipeline = (*this) [handle]; + const auto &pipeline = (*this) [handle]; + if (pipeline.m_rayHitAddress.size == 0) return nullptr; return &(pipeline.m_rayHitAddress); } const vk::StridedDeviceAddressRegionKHR * RayTracingPipelineManager::getCallShaderBindingTableAddress( const vkcv::RayTracingPipelineHandle &handle) const { - auto &pipeline = (*this) [handle]; + const auto &pipeline = (*this) [handle]; + //if (pipeline.m_rayCallAddress.size == 0) return nullptr; return &(pipeline.m_rayCallAddress); }