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 40fd8e60..e2e67af9 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: @@ -414,7 +416,6 @@ public: VkDeviceSize copyShaderIdentifier(uint8_t* data, const uint8_t* shaderHandleStorage, uint32_t groupIndex) { const uint32_t shaderGroupHandleSize = rayTracingProperties.shaderGroupHandleSize; memcpy(data, shaderHandleStorage + groupIndex * shaderGroupHandleSize, shaderGroupHandleSize); - data += shaderGroupHandleSize; return shaderGroupHandleSize; } @@ -423,7 +424,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, @@ -433,10 +434,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); @@ -542,7 +542,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 a5f56cad..35407d9a 100644 --- a/examples/nv_ray_tracing_reflections/nv_ray_tracing_reflections.cpp +++ b/examples/nv_ray_tracing_reflections/nv_ray_tracing_reflections.cpp @@ -403,7 +403,6 @@ public: VkDeviceSize copyShaderIdentifier(uint8_t* data, const uint8_t* shaderHandleStorage, uint32_t groupIndex) { const uint32_t shaderGroupHandleSize = rayTracingProperties.shaderGroupHandleSize; memcpy(data, shaderHandleStorage + groupIndex * shaderGroupHandleSize, shaderGroupHandleSize); - data += shaderGroupHandleSize; return shaderGroupHandleSize; } @@ -425,7 +424,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 dcb5c379..c3f4731d 100644 --- a/examples/nv_ray_tracing_shadows/nv_ray_tracing_shadows.cpp +++ b/examples/nv_ray_tracing_shadows/nv_ray_tracing_shadows.cpp @@ -412,7 +412,6 @@ public: VkDeviceSize copyShaderIdentifier(uint8_t* data, const uint8_t* shaderHandleStorage, uint32_t groupIndex) { const uint32_t shaderGroupHandleSize = rayTracingProperties.shaderGroupHandleSize; memcpy(data, shaderHandleStorage + groupIndex * shaderGroupHandleSize, shaderGroupHandleSize); - data += shaderGroupHandleSize; return shaderGroupHandleSize; } @@ -434,7 +433,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);