Skip to content
Snippets Groups Projects
Verified Commit 4858ab01 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

Solve validtion issues with size and stride in shader groups

parent 2d20497b
No related branches found
No related tags found
No related merge requests found
...@@ -114,7 +114,7 @@ vec3 sampleCosineDistribution(vec2 xi) { ...@@ -114,7 +114,7 @@ vec3 sampleCosineDistribution(vec2 xi) {
sqrt(xi.x) * cos(phi), sqrt(xi.x) * cos(phi),
sqrt(1 - xi.x), sqrt(1 - xi.x),
sqrt(xi.x) * sin(phi) sqrt(xi.x) * sin(phi)
); );
} }
struct Basis{ struct Basis{
......
...@@ -70,7 +70,7 @@ int main(int argc, const char** argv) { ...@@ -70,7 +70,7 @@ int main(int argc, const char** argv) {
vkcv::scene::Scene scene = vkcv::scene::Scene::load( vkcv::scene::Scene scene = vkcv::scene::Scene::load(
core, core,
"resources/Sponza/Sponza.gltf", "assets/Sponza/Sponza.gltf",
{ {
vkcv::asset::PrimitiveType::POSITION vkcv::asset::PrimitiveType::POSITION
} }
...@@ -86,17 +86,17 @@ int main(int argc, const char** argv) { ...@@ -86,17 +86,17 @@ int main(int argc, const char** argv) {
vkcv::shader::GLSLCompiler compiler (vkcv::shader::GLSLCompileTarget::RAY_TRACING); vkcv::shader::GLSLCompiler compiler (vkcv::shader::GLSLCompileTarget::RAY_TRACING);
vkcv::ShaderProgram shaderProgram; 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](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
shaderProgram.addShader(shaderStage, 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](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
shaderProgram.addShader(shaderStage, 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](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
shaderProgram.addShader(shaderStage, path); shaderProgram.addShader(shaderStage, path);
}); });
......
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
#include "vkcv/Core.hpp" #include "vkcv/Core.hpp"
#include "vkcv/Logger.hpp" #include "vkcv/Logger.hpp"
#include <cstring>
#include <iostream>
#include <iterator>
namespace vkcv { namespace vkcv {
...@@ -184,7 +187,7 @@ namespace vkcv { ...@@ -184,7 +187,7 @@ namespace vkcv {
size_t missShaderGroupIndex = genShaderGroupIndex; size_t missShaderGroupIndex = genShaderGroupIndex;
size_t hitShaderGroupIndex = genShaderGroupIndex; size_t hitShaderGroupIndex = genShaderGroupIndex;
size_t callShaderGroupIndex = genShaderGroupIndex; size_t callShaderGroupIndex = genShaderGroupIndex;
if (existsRayGenShader) { if (existsRayGenShader) {
vk::PipelineShaderStageCreateInfo createInfo; vk::PipelineShaderStageCreateInfo createInfo;
const bool success = createPipelineShaderStageCreateInfo( const bool success = createPipelineShaderStageCreateInfo(
...@@ -311,7 +314,7 @@ namespace vkcv { ...@@ -311,7 +314,7 @@ namespace vkcv {
nullptr nullptr
); );
} }
Vector<vk::DescriptorSetLayout> descriptorSetLayouts; Vector<vk::DescriptorSetLayout> descriptorSetLayouts;
descriptorSetLayouts.reserve(config.getDescriptorSetLayouts().size()); descriptorSetLayouts.reserve(config.getDescriptorSetLayouts().size());
for (const auto &handle : config.getDescriptorSetLayouts()) { for (const auto &handle : config.getDescriptorSetLayouts()) {
...@@ -456,7 +459,7 @@ namespace vkcv { ...@@ -456,7 +459,7 @@ namespace vkcv {
rayMissAddress = vk::StridedDeviceAddressRegionKHR( rayMissAddress = vk::StridedDeviceAddressRegionKHR(
bufferBaseAddress + missShaderGroupIndex * tableSizeAlignment, bufferBaseAddress + missShaderGroupIndex * tableSizeAlignment,
shaderBindingTableSize, shaderBindingTableSize,
shaderBindingTableSize tableSizeAlignment
); );
} }
...@@ -464,7 +467,7 @@ namespace vkcv { ...@@ -464,7 +467,7 @@ namespace vkcv {
rayHitAddress = vk::StridedDeviceAddressRegionKHR( rayHitAddress = vk::StridedDeviceAddressRegionKHR(
bufferBaseAddress + hitShaderGroupIndex * tableSizeAlignment, bufferBaseAddress + hitShaderGroupIndex * tableSizeAlignment,
shaderBindingTableSize, shaderBindingTableSize,
shaderBindingTableSize tableSizeAlignment
); );
} }
...@@ -472,10 +475,10 @@ namespace vkcv { ...@@ -472,10 +475,10 @@ namespace vkcv {
rayCallAddress = vk::StridedDeviceAddressRegionKHR( rayCallAddress = vk::StridedDeviceAddressRegionKHR(
bufferBaseAddress + callShaderGroupIndex * tableSizeAlignment, bufferBaseAddress + callShaderGroupIndex * tableSizeAlignment,
shaderBindingTableSize, shaderBindingTableSize,
shaderBindingTableSize tableSizeAlignment
); );
} }
return add({ return add({
pipeline, pipeline,
pipelineLayout, pipelineLayout,
...@@ -501,35 +504,39 @@ namespace vkcv { ...@@ -501,35 +504,39 @@ namespace vkcv {
const RayTracingPipelineConfig & const RayTracingPipelineConfig &
RayTracingPipelineManager::getPipelineConfig(const RayTracingPipelineHandle &handle) const { RayTracingPipelineManager::getPipelineConfig(const RayTracingPipelineHandle &handle) const {
auto &pipeline = (*this) [handle]; const auto &pipeline = (*this) [handle];
return pipeline.m_config; return pipeline.m_config;
} }
const vk::StridedDeviceAddressRegionKHR * const vk::StridedDeviceAddressRegionKHR *
RayTracingPipelineManager::getRayGenShaderBindingTableAddress( RayTracingPipelineManager::getRayGenShaderBindingTableAddress(
const vkcv::RayTracingPipelineHandle &handle) const { 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); return &(pipeline.m_rayGenAddress);
} }
const vk::StridedDeviceAddressRegionKHR * const vk::StridedDeviceAddressRegionKHR *
RayTracingPipelineManager::getMissShaderBindingTableAddress( RayTracingPipelineManager::getMissShaderBindingTableAddress(
const vkcv::RayTracingPipelineHandle &handle) const { 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); return &(pipeline.m_rayMissAddress);
} }
const vk::StridedDeviceAddressRegionKHR * const vk::StridedDeviceAddressRegionKHR *
RayTracingPipelineManager::getHitShaderBindingTableAddress( RayTracingPipelineManager::getHitShaderBindingTableAddress(
const vkcv::RayTracingPipelineHandle &handle) const { 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); return &(pipeline.m_rayHitAddress);
} }
const vk::StridedDeviceAddressRegionKHR * const vk::StridedDeviceAddressRegionKHR *
RayTracingPipelineManager::getCallShaderBindingTableAddress( RayTracingPipelineManager::getCallShaderBindingTableAddress(
const vkcv::RayTracingPipelineHandle &handle) const { 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); return &(pipeline.m_rayCallAddress);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment