diff --git a/examples/nv_ray_tracing_basic/nv_ray_tracing_basic.cpp b/examples/nv_ray_tracing_basic/nv_ray_tracing_basic.cpp index ab8b07b6..6a350a3f 100644 --- a/examples/nv_ray_tracing_basic/nv_ray_tracing_basic.cpp +++ b/examples/nv_ray_tracing_basic/nv_ray_tracing_basic.cpp @@ -44,6 +44,8 @@ struct GeometryInstance { #define INDEX_MISS 1 #define INDEX_CLOSEST_HIT 2 +#define NUM_SHADER_GROUPS 3 + class VulkanExample : public VulkanExampleBase { public: @@ -421,7 +423,7 @@ public: */ void createShaderBindingTable() { // Create buffer for the shader binding table - const uint32_t sbtSize = rayTracingProperties.shaderGroupHandleSize * 3; + const uint32_t sbtSize = rayTracingProperties.shaderGroupHandleSize * NUM_SHADER_GROUPS; VK_CHECK_RESULT(vulkanDevice->createBuffer( VK_BUFFER_USAGE_RAY_TRACING_BIT_NV, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, @@ -431,10 +433,9 @@ public: auto shaderHandleStorage = new uint8_t[sbtSize]; // Get shader identifiers - VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, 3, sbtSize, shaderHandleStorage)); + VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, NUM_SHADER_GROUPS, sbtSize, shaderHandleStorage)); auto* data = static_cast(shaderBindingTable.mapped); // Copy the shader identifiers to the shader binding table - VkDeviceSize offset = 0; data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_RAYGEN); data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_MISS); data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_CLOSEST_HIT); @@ -540,7 +541,7 @@ public: /* Setup ray tracing shader groups */ - std::array groups{}; + std::array groups{}; for (auto& group : groups) { // Init all groups with some default values group.sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV; diff --git a/examples/nv_ray_tracing_reflections/nv_ray_tracing_reflections.cpp b/examples/nv_ray_tracing_reflections/nv_ray_tracing_reflections.cpp index 020477eb..40ef233b 100644 --- a/examples/nv_ray_tracing_reflections/nv_ray_tracing_reflections.cpp +++ b/examples/nv_ray_tracing_reflections/nv_ray_tracing_reflections.cpp @@ -423,7 +423,6 @@ public: VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, NUM_SHADER_GROUPS, sbtSize, shaderHandleStorage)); auto* data = static_cast(shaderBindingTable.mapped); // Copy the shader identifiers to the shader binding table - VkDeviceSize offset = 0; data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_RAYGEN); data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_MISS); data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_CLOSEST_HIT); diff --git a/examples/nv_ray_tracing_shadows/nv_ray_tracing_shadows.cpp b/examples/nv_ray_tracing_shadows/nv_ray_tracing_shadows.cpp index 676284e8..7065566f 100644 --- a/examples/nv_ray_tracing_shadows/nv_ray_tracing_shadows.cpp +++ b/examples/nv_ray_tracing_shadows/nv_ray_tracing_shadows.cpp @@ -432,7 +432,6 @@ public: VK_CHECK_RESULT(vkGetRayTracingShaderGroupHandlesNV(device, pipeline, 0, NUM_SHADER_GROUPS, sbtSize, shaderHandleStorage)); auto* data = static_cast(shaderBindingTable.mapped); // Copy the shader identifiers to the shader binding table - VkDeviceSize offset = 0; data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_RAYGEN); data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_MISS); data += copyShaderIdentifier(data, shaderHandleStorage, INDEX_SHADOW_MISS);