20 #include "shared/shared.h"
24 #include "../../client/client.h"
28 #define RAY_GEN_ACCEL_STRUCTURE_BINDING_IDX 0
29 #define RAY_GEN_PARTICLE_COLOR_BUFFER_BINDING_IDX 1
30 #define RAY_GEN_BEAM_COLOR_BUFFER_BINDING_IDX 2
31 #define RAY_GEN_SPRITE_INFO_BUFFER_BINDING_IDX 3
33 #define SIZE_SCRATCH_BUFFER (1 << 24)
35 #define INSTANCE_MAX_NUM 12
38 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV,
40 .maxRecursionDepth = 0,
41 .shaderGroupHandleSize = 0
118 #define MEM_BARRIER_BUILD_ACCEL(cmd_buf, ...) \
120 VkMemoryBarrier mem_barrier = { \
121 .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER, \
122 .srcAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV \
123 | VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV, \
124 .dstAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV, \
128 vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV, \
129 VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV, 0, 1, \
130 &mem_barrier, 0, 0, 0, 0); \
136 VkPhysicalDeviceProperties2 dev_props2 = {
137 .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2,
143 Com_Printf(
"Maximum recursion depth: %d\n",
rt_properties.maxRecursionDepth);
144 Com_Printf(
"Shader group handle size: %d\n",
rt_properties.shaderGroupHandleSize);
147 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
151 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
155 VkDescriptorSetLayoutBinding bindings[] = {
158 .descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV,
159 .descriptorCount = 1,
160 .stageFlags = VK_SHADER_STAGE_RAYGEN_BIT_NV,
164 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
165 .descriptorCount = 1,
166 .stageFlags = VK_SHADER_STAGE_ANY_HIT_BIT_NV,
170 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
171 .descriptorCount = 1,
172 .stageFlags = VK_SHADER_STAGE_ANY_HIT_BIT_NV,
176 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
177 .descriptorCount = 1,
178 .stageFlags = VK_SHADER_STAGE_ANY_HIT_BIT_NV,
182 VkDescriptorSetLayoutCreateInfo layout_info = {
183 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
184 .bindingCount =
LENGTH(bindings),
185 .pBindings = bindings
191 VkDescriptorSetLayout desc_set_layouts[] = {
199 VkPushConstantRange push_constant_range = {
200 .stageFlags = VK_SHADER_STAGE_RAYGEN_BIT_NV,
202 .size =
sizeof(
int) * 2,
205 VkPipelineLayoutCreateInfo pipeline_layout_create_info = {
206 .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
207 .setLayoutCount =
LENGTH(desc_set_layouts),
208 .pSetLayouts = desc_set_layouts,
209 .pushConstantRangeCount = 1,
210 .pPushConstantRanges = &push_constant_range,
216 VkDescriptorPoolSize pool_sizes[] = {
221 VkDescriptorPoolCreateInfo pool_create_info = {
222 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
224 .poolSizeCount =
LENGTH(pool_sizes),
225 .pPoolSizes = pool_sizes
231 VkDescriptorSetAllocateInfo descriptor_set_alloc_info = {
232 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
234 .descriptorSetCount = 1,
254 VkWriteDescriptorSetAccelerationStructureNV desc_accel_struct_info = {
255 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV,
256 .accelerationStructureCount = 1,
257 .pAccelerationStructures =
accel_top + idx
264 VkWriteDescriptorSet writes[] = {
266 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
267 .pNext = &desc_accel_struct_info,
270 .descriptorCount = 1,
271 .descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV
274 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
277 .descriptorCount = 1,
278 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
282 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
285 .descriptorCount = 1,
286 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
290 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
293 .descriptorCount = 1,
294 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
308 VkAccelerationStructureMemoryRequirementsInfoNV mem_req_info = {
309 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV,
310 .accelerationStructure =
ac,
311 .type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV
314 VkMemoryRequirements2 mem_req = { 0 };
315 mem_req.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
316 qvkGetAccelerationStructureMemoryRequirementsNV(
qvk.
device, &mem_req_info, &mem_req);
318 return mem_req.memoryRequirements.size;
321 static inline VkGeometryNV
324 size_t size_per_vertex =
sizeof(float) * 3;
325 VkGeometryNV geometry = {
326 .sType = VK_STRUCTURE_TYPE_GEOMETRY_NV,
329 .sType = VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV,
330 .vertexData = buffer,
331 .vertexOffset = offset,
332 .vertexCount = num_vertices,
333 .vertexStride = size_per_vertex,
334 .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT,
335 .indexType = VK_INDEX_TYPE_NONE_NV,
336 .indexCount = num_vertices,
338 .aabbs = { .sType = VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV }
453 VkGeometryNV *geometry) {
454 return match->
flags == geometry->flags &&
455 match->
vertexCount >= geometry->geometry.triangles.vertexCount &&
456 match->
indexCount >= geometry->geometry.triangles.indexCount;
461 #define DYNAMIC_GEOMETRY_BLOAT_FACTOR 2
466 size_t buffer_offset,
468 VkAccelerationStructureNV *accel,
470 VkDeviceMemory *mem_accel,
471 VkCommandBuffer cmd_buf,
483 if (!match || !
accel_matches(match, &geometry) || *accel == VK_NULL_HANDLE) {
485 doFree = (*accel != VK_NULL_HANDLE);
490 vkFreeMemory(
qvk.
device, *mem_accel, NULL);
491 *mem_accel = VK_NULL_HANDLE;
494 qvkDestroyAccelerationStructureNV(
qvk.
device, *accel, NULL);
495 *accel = VK_NULL_HANDLE;
500 VkGeometryNV allocGeometry = geometry;
508 VkAccelerationStructureCreateInfoNV accel_create_info = {
509 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_NV,
511 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
514 .pGeometries = &allocGeometry,
515 .type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV,
516 .flags = fast_build ? VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV : VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV
520 qvkCreateAccelerationStructureNV(
qvk.
device, &accel_create_info, NULL, accel);
522 VkAccelerationStructureMemoryRequirementsInfoNV mem_req_info = {
523 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV,
524 .accelerationStructure = *accel,
525 .type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV
527 VkMemoryRequirements2 mem_req = { 0 };
528 mem_req.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
529 qvkGetAccelerationStructureMemoryRequirementsNV(
qvk.
device, &mem_req_info, &mem_req);
533 VkBindAccelerationStructureMemoryInfoNV bind_info = {
534 .sType = VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV,
535 .accelerationStructure = *accel,
536 .memory = *mem_accel,
539 _VK(qvkBindAccelerationStructureMemoryNV(
qvk.
device, 1, &bind_info));
542 match->
flags = allocGeometry.flags;
543 match->
vertexCount = allocGeometry.geometry.triangles.vertexCount;
544 match->
indexCount = allocGeometry.geometry.triangles.indexCount;
551 VkAccelerationStructureInfoNV as_info = {
552 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
553 .type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV,
555 .pGeometries = &geometry,
556 .flags = fast_build ? VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV : VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV
559 qvkCmdBuildAccelerationStructureNV(cmd_buf, &as_info,
576 size_t buffer_offset,
578 int num_vertices_transparent,
579 int num_vertices_sky,
580 int num_vertices_custom_sky
602 buffer_offset + num_vertices *
sizeof(
float) * 3,
603 num_vertices_transparent,
615 buffer_offset + (num_vertices + num_vertices_transparent) *
sizeof(
float) * 3,
628 buffer_offset + (num_vertices + num_vertices_transparent + num_vertices_sky) *
sizeof(
float) * 3,
629 num_vertices_custom_sky,
651 VkCommandBuffer cmd_buf,
654 size_t buffer_offset,
671 VkCommandBuffer cmd_buf,
674 size_t buffer_offset,
681 if (num_vertices > 0)
687 buffer_offset + vertex_offset * 3 *
sizeof(
float),
704 VkCommandBuffer cmd_buf,
707 size_t buffer_offset,
716 buffer_offset + vertex_offset * 3 *
sizeof(
float),
727 VkCommandBuffer cmd_buf,
730 size_t buffer_offset,
739 buffer_offset + vertex_offset * 3 *
sizeof(
float),
750 VkCommandBuffer cmd_buf,
753 size_t buffer_offset,
758 if (num_vertices > 0)
765 buffer_offset + vertex_offset * 3 *
sizeof(
float),
782 VkCommandBuffer cmd_buf,
833 1.0f, 0.0f, 0.0f, 0.0f,
834 0.0f, 1.0f, 0.0f, 0.0f,
835 0.0f, 0.0f, 1.0f, 0.0f,
837 .instance_id = instance_id,
839 .instance_offset = sbt_offset,
841 .acceleration_structure_handle = 1337,
847 memcpy(instances + *num_instances, &instance,
sizeof(instance));
855 int num_instances = 0;
904 instance_data = NULL;
906 VkAccelerationStructureCreateInfoNV accel_create_info = {
907 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_NV,
909 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
910 .instanceCount = num_instances,
913 .type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV
920 qvkCreateAccelerationStructureNV(
qvk.
device, &accel_create_info, NULL,
accel_top + idx);
923 VkAccelerationStructureMemoryRequirementsInfoNV mem_req_info = {
924 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV,
926 .type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV
928 VkMemoryRequirements2 mem_req = { 0 };
929 mem_req.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
930 qvkGetAccelerationStructureMemoryRequirementsNV(
qvk.
device, &mem_req_info, &mem_req);
934 VkBindAccelerationStructureMemoryInfoNV bind_info = {
935 .sType = VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV,
940 _VK(qvkBindAccelerationStructureMemoryNV(
qvk.
device, 1, &bind_info));
947 VkAccelerationStructureInfoNV as_info = {
948 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
949 .type = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV,
952 .instanceCount = num_instances,
955 qvkCmdBuildAccelerationStructureNV(
971 #define BARRIER_COMPUTE(cmd_buf, img) \
973 VkImageSubresourceRange subresource_range = { \
974 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, \
977 .baseArrayLayer = 0, \
980 IMAGE_BARRIER(cmd_buf, \
982 .subresourceRange = subresource_range, \
983 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, \
984 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT, \
985 .oldLayout = VK_IMAGE_LAYOUT_GENERAL, \
986 .newLayout = VK_IMAGE_LAYOUT_GENERAL, \
992 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
995 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
999 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
1002 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
1005 vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV,
rt_pipeline);
1014 .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
1015 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
1018 .size = VK_WHOLE_SIZE,
1030 vkCmdPushConstants(cmd_buf,
rt_pipeline_layout, VK_SHADER_STAGE_RAYGEN_BIT_NV, 0,
sizeof(
int), &idx);
1032 qvkCmdTraceRaysNV(cmd_buf,
1036 VK_NULL_HANDLE, 0, 0,
1074 vkCmdPushConstants(cmd_buf,
rt_pipeline_layout, VK_SHADER_STAGE_RAYGEN_BIT_NV, 0,
sizeof(
int), &idx);
1075 vkCmdPushConstants(cmd_buf,
rt_pipeline_layout, VK_SHADER_STAGE_RAYGEN_BIT_NV,
sizeof(
int),
sizeof(
int), &bounce);
1079 qvkCmdTraceRaysNV(cmd_buf,
1083 VK_NULL_HANDLE, 0, 0,
1118 vkCmdPushConstants(cmd_buf,
rt_pipeline_layout, VK_SHADER_STAGE_RAYGEN_BIT_NV, 0,
sizeof(
int), &idx);
1124 qvkCmdTraceRaysNV(cmd_buf,
1128 VK_NULL_HANDLE, 0, 0,
1142 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
1143 .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
1146 .size = VK_WHOLE_SIZE,
1151 if (num_bounce_rays > 0)
1158 vkCmdPushConstants(cmd_buf,
rt_pipeline_layout, VK_SHADER_STAGE_RAYGEN_BIT_NV, 0,
sizeof(idx), &idx);
1160 for (
int bounce_ray = 0; bounce_ray < (
int)ceilf(num_bounce_rays); bounce_ray++)
1163 if (num_bounce_rays == 0.5f)
1168 int rgen_index = (bounce_ray == 0)
1172 qvkCmdTraceRaysNV(cmd_buf,
1176 VK_NULL_HANDLE, 0, 0,
1218 VkSpecializationMapEntry specEntry = {
1221 .size =
sizeof(uint32_t),
1224 uint32_t numbers[2] = { 0, 1 };
1226 VkSpecializationInfo specInfo[2] = {
1229 .pMapEntries = &specEntry,
1230 .dataSize =
sizeof(uint32_t),
1231 .pData = &numbers[0],
1235 .pMapEntries = &specEntry,
1236 .dataSize =
sizeof(uint32_t),
1237 .pData = &numbers[1],
1241 VkPipelineShaderStageCreateInfo shader_stages[] = {
1242 SHADER_STAGE(QVK_MOD_PRIMARY_RAYS_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV),
1243 SHADER_STAGE_SPEC(QVK_MOD_REFLECT_REFRACT_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV, &specInfo[0]),
1244 SHADER_STAGE_SPEC(QVK_MOD_REFLECT_REFRACT_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV, &specInfo[1]),
1245 SHADER_STAGE_SPEC(QVK_MOD_DIRECT_LIGHTING_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV, &specInfo[0]),
1246 SHADER_STAGE_SPEC(QVK_MOD_DIRECT_LIGHTING_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV, &specInfo[1]),
1247 SHADER_STAGE_SPEC(QVK_MOD_INDIRECT_LIGHTING_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV, &specInfo[0]),
1248 SHADER_STAGE_SPEC(QVK_MOD_INDIRECT_LIGHTING_RGEN, VK_SHADER_STAGE_RAYGEN_BIT_NV, &specInfo[1]),
1249 SHADER_STAGE(QVK_MOD_PATH_TRACER_RMISS, VK_SHADER_STAGE_MISS_BIT_NV),
1250 SHADER_STAGE(QVK_MOD_PATH_TRACER_SHADOW_RMISS, VK_SHADER_STAGE_MISS_BIT_NV),
1251 SHADER_STAGE(QVK_MOD_PATH_TRACER_RCHIT, VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV),
1252 SHADER_STAGE(QVK_MOD_PATH_TRACER_PARTICLE_RAHIT, VK_SHADER_STAGE_ANY_HIT_BIT_NV),
1253 SHADER_STAGE(QVK_MOD_PATH_TRACER_BEAM_RAHIT, VK_SHADER_STAGE_ANY_HIT_BIT_NV),
1254 SHADER_STAGE(QVK_MOD_PATH_TRACER_EXPLOSION_RAHIT, VK_SHADER_STAGE_ANY_HIT_BIT_NV),
1255 SHADER_STAGE(QVK_MOD_PATH_TRACER_SPRITE_RAHIT, VK_SHADER_STAGE_ANY_HIT_BIT_NV),
1258 VkRayTracingShaderGroupCreateInfoNV rt_shader_group_info[] = {
1260 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1261 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1263 .closestHitShader = VK_SHADER_UNUSED_NV,
1264 .anyHitShader = VK_SHADER_UNUSED_NV,
1265 .intersectionShader = VK_SHADER_UNUSED_NV
1268 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1269 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1271 .closestHitShader = VK_SHADER_UNUSED_NV,
1272 .anyHitShader = VK_SHADER_UNUSED_NV,
1273 .intersectionShader = VK_SHADER_UNUSED_NV
1276 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1277 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1279 .closestHitShader = VK_SHADER_UNUSED_NV,
1280 .anyHitShader = VK_SHADER_UNUSED_NV,
1281 .intersectionShader = VK_SHADER_UNUSED_NV
1284 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1285 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1287 .closestHitShader = VK_SHADER_UNUSED_NV,
1288 .anyHitShader = VK_SHADER_UNUSED_NV,
1289 .intersectionShader = VK_SHADER_UNUSED_NV
1292 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1293 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1295 .closestHitShader = VK_SHADER_UNUSED_NV,
1296 .anyHitShader = VK_SHADER_UNUSED_NV,
1297 .intersectionShader = VK_SHADER_UNUSED_NV
1300 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1301 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1303 .closestHitShader = VK_SHADER_UNUSED_NV,
1304 .anyHitShader = VK_SHADER_UNUSED_NV,
1305 .intersectionShader = VK_SHADER_UNUSED_NV
1308 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1309 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1311 .closestHitShader = VK_SHADER_UNUSED_NV,
1312 .anyHitShader = VK_SHADER_UNUSED_NV,
1313 .intersectionShader = VK_SHADER_UNUSED_NV
1316 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1317 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1319 .closestHitShader = VK_SHADER_UNUSED_NV,
1320 .anyHitShader = VK_SHADER_UNUSED_NV,
1321 .intersectionShader = VK_SHADER_UNUSED_NV
1324 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1325 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV,
1327 .closestHitShader = VK_SHADER_UNUSED_NV,
1328 .anyHitShader = VK_SHADER_UNUSED_NV,
1329 .intersectionShader = VK_SHADER_UNUSED_NV
1332 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1333 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV,
1334 .generalShader = VK_SHADER_UNUSED_NV,
1335 .closestHitShader = 9,
1336 .anyHitShader = VK_SHADER_UNUSED_NV,
1337 .intersectionShader = VK_SHADER_UNUSED_NV
1340 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1341 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV,
1342 .generalShader = VK_SHADER_UNUSED_NV,
1343 .closestHitShader = VK_SHADER_UNUSED_NV,
1345 .intersectionShader = VK_SHADER_UNUSED_NV
1348 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1349 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV,
1350 .generalShader = VK_SHADER_UNUSED_NV,
1351 .closestHitShader = VK_SHADER_UNUSED_NV,
1353 .intersectionShader = VK_SHADER_UNUSED_NV
1356 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1357 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV,
1358 .generalShader = VK_SHADER_UNUSED_NV,
1359 .closestHitShader = VK_SHADER_UNUSED_NV,
1361 .intersectionShader = VK_SHADER_UNUSED_NV
1364 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1365 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV,
1366 .generalShader = VK_SHADER_UNUSED_NV,
1367 .closestHitShader = VK_SHADER_UNUSED_NV,
1369 .intersectionShader = VK_SHADER_UNUSED_NV
1372 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV,
1373 .type = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV,
1374 .generalShader = VK_SHADER_UNUSED_NV,
1375 .closestHitShader = VK_SHADER_UNUSED_NV,
1376 .anyHitShader = VK_SHADER_UNUSED_NV,
1377 .intersectionShader = VK_SHADER_UNUSED_NV
1381 VkRayTracingPipelineCreateInfoNV rt_pipeline_info = {
1382 .sType = VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_CREATE_INFO_NV,
1383 .stageCount =
LENGTH(shader_stages),
1384 .pStages = shader_stages,
1385 .groupCount =
LENGTH(rt_shader_group_info),
1386 .pGroups = rt_shader_group_info,
1388 .maxRecursionDepth = 1,
1393 uint32_t num_groups =
LENGTH(rt_shader_group_info);
1394 uint32_t shader_binding_table_size =
rt_properties.shaderGroupHandleSize * num_groups;
1398 VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT));
1402 shader_binding_table_size, shader_binding_table));
1404 shader_binding_table = NULL;