Quake II RTX doxygen
1.0 dev
|
|
#include "shared/shared.h"
#include "vkpt.h"
#include "vk_util.h"
Go to the source code of this file.
|
static void | create_buffers () |
|
static void | create_blas () |
|
static void | allocate_and_bind_memory_to_blas () |
|
static qboolean | allocate_and_bind_memory_to_buffers () |
|
static void | create_buffer_views () |
|
static void | fill_index_buffer () |
|
static void | write_particle_geometry (const float *view_matrix, const particle_t *particles, int particle_num) |
|
static void | write_beam_geometry (const float *view_matrix, const entity_t *entities, int entity_num) |
|
static void | write_sprite_geometry (const float *view_matrix, const entity_t *entities, int entity_num) |
|
static void | upload_geometry (VkCommandBuffer command_buffer) |
|
static void | update_particle_blas (VkCommandBuffer command_buffer) |
|
static void | update_beam_blas (VkCommandBuffer command_buffer) |
|
static void | update_sprite_blas (VkCommandBuffer command_buffer) |
|
void | cast_u32_to_f32_color (int color_index, const color_t *pcolor, float *color_f32, float hdr_factor) |
|
qboolean | initialize_transparency () |
|
void | destroy_transparency () |
|
void | update_transparency (VkCommandBuffer command_buffer, const float *view_matrix, const particle_t *particles, int particle_num, const entity_t *entities, int entity_num) |
|
void | build_transparency_blas (VkCommandBuffer cmd_buf) |
|
VkAccelerationStructureNV | get_transparency_particle_blas () |
|
VkAccelerationStructureNV | get_transparency_beam_blas () |
|
VkAccelerationStructureNV | get_transparency_sprite_blas () |
|
VkBufferView | get_transparency_particle_color_buffer_view () |
|
VkBufferView | get_transparency_beam_color_buffer_view () |
|
VkBufferView | get_transparency_sprite_info_buffer_view () |
|
void | get_transparency_counts (int *particle_num, int *beam_num, int *sprite_num) |
|
static int | compare_beams (const void *_a, const void *_b) |
|
qboolean | vkpt_build_cylinder_light (light_poly_t *light_list, int *num_lights, int max_lights, bsp_t *bsp, vec3_t begin, vec3_t end, vec3_t color, float radius) |
|
void | vkpt_build_beam_lights (light_poly_t *light_list, int *num_lights, int max_lights, bsp_t *bsp, entity_t *entities, int num_entites, float adapted_luminance) |
|
static size_t | calculate_scratch_buffer_size (VkAccelerationStructureNV blas) |
|
◆ MAX_BEAMS
◆ TR_BEAM_MAX_NUM
#define TR_BEAM_MAX_NUM MAX_ENTITIES |
◆ TR_BLAS_BUILD_FLAGS
#define TR_BLAS_BUILD_FLAGS |
Value: VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV | \
VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV
Definition at line 32 of file transparency.c.
◆ TR_COLOR_SIZE
#define TR_COLOR_SIZE 4 * sizeof(float) |
◆ TR_INDEX_MAX_NUM
◆ TR_PARTICLE_MAX_NUM
#define TR_PARTICLE_MAX_NUM MAX_PARTICLES |
◆ TR_POSITION_SIZE
#define TR_POSITION_SIZE 3 * sizeof(float) |
◆ TR_SPRITE_INFO_SIZE
#define TR_SPRITE_INFO_SIZE 2 * sizeof(float) |
◆ TR_SPRITE_MAX_NUM
#define TR_SPRITE_MAX_NUM MAX_ENTITIES |
◆ TR_VERTEX_MAX_NUM
◆ allocate_and_bind_memory_to_blas()
static void allocate_and_bind_memory_to_blas |
( |
| ) |
|
|
static |
Definition at line 1075 of file transparency.c.
1077 const VkAccelerationStructureMemoryRequirementsInfoNV blas_requirements_info = {
1078 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV,
1079 .type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV,
1083 VkMemoryRequirements2 blas_memory_requirements = { 0 };
1084 blas_memory_requirements.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
1085 qvkGetAccelerationStructureMemoryRequirementsNV(
qvk.
device, &blas_requirements_info,
1086 &blas_memory_requirements);
1088 VkMemoryRequirements mem_req = blas_memory_requirements.memoryRequirements;
1089 size_t beam_memory_offset =
align(mem_req.size, mem_req.alignment);
1090 mem_req.size += beam_memory_offset;
1092 size_t sprite_memory_offset =
align(mem_req.size, mem_req.alignment);
1093 mem_req.size += sprite_memory_offset;
1097 VkBindAccelerationStructureMemoryInfoNV bindings[3] = { 0 };
1099 bindings[0].sType = VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV;
1100 bindings[0].accelerationStructure =
transparency.particle_blas;
1102 bindings[1].sType = VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV;
1103 bindings[1].accelerationStructure =
transparency.beam_blas;
1105 bindings[1].memoryOffset = beam_memory_offset;
1106 bindings[2].sType = VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV;
1107 bindings[2].accelerationStructure =
transparency.sprite_blas;
1109 bindings[2].memoryOffset = sprite_memory_offset;
Referenced by initialize_transparency().
◆ allocate_and_bind_memory_to_buffers()
static qboolean allocate_and_bind_memory_to_buffers |
( |
| ) |
|
|
static |
Definition at line 932 of file transparency.c.
936 VkMemoryRequirements host_buffer_requirements;
939 const VkMemoryPropertyFlags host_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT |
940 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
942 const uint32_t host_memory_type =
get_memory_type(host_buffer_requirements.memoryTypeBits, host_flags);
944 const VkMemoryAllocateInfo host_memory_allocate_info = {
945 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
946 .allocationSize = host_buffer_requirements.size,
947 .memoryTypeIndex = host_memory_type
954 const VkBuffer device_buffers[] = {
963 const VkMemoryPropertyFlags device_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
964 uint32_t memory_types[
LENGTH(device_buffers)];
965 VkMemoryRequirements requirements[
LENGTH(device_buffers)];
967 VkMemoryAllocateInfo memory_allocate_info = { .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO };
969 for (
size_t i = 0; i <
LENGTH(device_buffers); i++)
971 vkGetBufferMemoryRequirements(
qvk.
device, device_buffers[i], &requirements[i]);
972 memory_types[i] =
get_memory_type(requirements[i].memoryTypeBits, device_flags);
973 memory_allocate_info.allocationSize += requirements[i].size + ((i == 0) ? 0 : requirements[i].alignment);
977 for (
size_t i = 1; i <
LENGTH(device_buffers); i++)
979 if (memory_types[i] != memory_types[0])
983 memory_allocate_info.memoryTypeIndex = memory_types[0];
986 #ifdef VKPT_DEVICE_GROUPS
987 VkMemoryAllocateFlagsInfoKHR mem_alloc_flags = {
988 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHR,
989 .flags = VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHR,
994 memory_allocate_info.pNext = &mem_alloc_flags;
1001 VkBindBufferMemoryInfo bindings[
LENGTH(device_buffers) + 1] = { 0 };
1003 bindings[0].sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO;
1006 bindings[0].memoryOffset = 0;
1009 for (
size_t i = 0; i <
LENGTH(device_buffers); i++)
1011 VkBindBufferMemoryInfo* binding = bindings + i + 1;
1013 binding->sType = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO;
1014 binding->buffer = device_buffers[i];
1017 offset =
align(offset, requirements[i].alignment);
1018 binding->memoryOffset = offset;
1019 offset += requirements[i].size;
Referenced by initialize_transparency().
◆ build_transparency_blas()
void build_transparency_blas |
( |
VkCommandBuffer |
cmd_buf | ) |
|
◆ calculate_scratch_buffer_size()
static size_t calculate_scratch_buffer_size |
( |
VkAccelerationStructureNV |
blas | ) |
|
|
static |
Definition at line 846 of file transparency.c.
848 VkAccelerationStructureMemoryRequirementsInfoNV scratch_requirements_info = {
849 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV,
850 .type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV,
851 .accelerationStructure = blas
854 VkMemoryRequirements2 build_memory_requirements = { 0 };
855 build_memory_requirements.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
856 qvkGetAccelerationStructureMemoryRequirementsNV(
qvk.
device, &scratch_requirements_info,
857 &build_memory_requirements);
859 scratch_requirements_info.type = VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV;
861 VkMemoryRequirements2 update_memory_requirements = { 0 };
862 update_memory_requirements.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
863 qvkGetAccelerationStructureMemoryRequirementsNV(
qvk.
device, &scratch_requirements_info,
864 &update_memory_requirements);
866 const uint64_t build_size = build_memory_requirements.memoryRequirements.size;
867 const uint64_t update_size = update_memory_requirements.memoryRequirements.size;
869 return max(build_size, update_size);
Referenced by create_buffers().
◆ cast_u32_to_f32_color()
void cast_u32_to_f32_color |
( |
int |
color_index, |
|
|
const color_t * |
pcolor, |
|
|
float * |
color_f32, |
|
|
float |
hdr_factor |
|
) |
| |
◆ compare_beams()
static int compare_beams |
( |
const void * |
_a, |
|
|
const void * |
_b |
|
) |
| |
|
static |
Definition at line 388 of file transparency.c.
390 const entity_t* a = *(
void**)_a;
391 const entity_t* b = *(
void**)_b;
393 if (a->origin[0] < b->origin[0])
return -1;
394 if (a->origin[0] > b->origin[0])
return 1;
395 if (a->origin[1] < b->origin[1])
return -1;
396 if (a->origin[1] > b->origin[1])
return 1;
397 if (a->origin[2] < b->origin[2])
return -1;
398 if (a->origin[2] > b->origin[2])
return 1;
399 if (a->oldorigin[0] < b->oldorigin[0])
return -1;
400 if (a->oldorigin[0] > b->oldorigin[0])
return 1;
401 if (a->oldorigin[1] < b->oldorigin[1])
return -1;
402 if (a->oldorigin[1] > b->oldorigin[1])
return 1;
403 if (a->oldorigin[2] < b->oldorigin[2])
return -1;
404 if (a->oldorigin[2] > b->oldorigin[2])
return 1;
Referenced by vkpt_build_beam_lights().
◆ create_blas()
static void create_blas |
( |
| ) |
|
|
static |
Definition at line 1032 of file transparency.c.
1034 const VkGeometryTrianglesNV geometry_triangles = {
1035 .sType = VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV,
1037 .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT,
1039 .indexType = VK_INDEX_TYPE_UINT16
1042 const VkGeometryAABBNV geometry_aabbs = {
1043 .sType = VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV
1046 const VkGeometryDataNV geometry_data = {
1047 .triangles = geometry_triangles,
1048 .aabbs = geometry_aabbs
1051 const VkGeometryNV geometry = {
1052 .sType = VK_STRUCTURE_TYPE_GEOMETRY_NV,
1053 .geometryType = VK_GEOMETRY_TYPE_TRIANGLES_NV,
1054 .geometry = geometry_data
1057 const VkAccelerationStructureInfoNV info = {
1058 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
1059 .type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV,
1062 .pGeometries = &geometry
1065 const VkAccelerationStructureCreateInfoNV blas_info = {
1066 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_NV,
Referenced by initialize_transparency().
◆ create_buffer_views()
static void create_buffer_views |
( |
| ) |
|
|
static |
Definition at line 1114 of file transparency.c.
1116 const VkBufferViewCreateInfo particle_color_view_info = {
1117 .sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
1119 .format = VK_FORMAT_R32G32B32A32_SFLOAT,
1123 const VkBufferViewCreateInfo beam_color_view_info = {
1124 .sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
1126 .format = VK_FORMAT_R32G32B32A32_SFLOAT,
1130 const VkBufferViewCreateInfo sprite_info_view_info = {
1131 .sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
1133 .format = VK_FORMAT_R32G32_UINT,
1137 _VK(vkCreateBufferView(
qvk.
device, &particle_color_view_info, NULL,
1140 _VK(vkCreateBufferView(
qvk.
device, &beam_color_view_info, NULL,
1143 _VK(vkCreateBufferView(
qvk.
device, &sprite_info_view_info, NULL,
Referenced by initialize_transparency().
◆ create_buffers()
static void create_buffers |
( |
| ) |
|
|
static |
Definition at line 872 of file transparency.c.
878 transparency.beam_scratch_device_offset = particle_scratch_size;
881 const VkBufferCreateInfo host_buffer_info = {
882 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
884 .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT
887 const VkBufferCreateInfo scratch_buffer_info = {
888 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
889 .size = particle_scratch_size + beam_scratch_size + sprite_scratch_size,
890 .usage = VK_BUFFER_USAGE_RAY_TRACING_BIT_NV
893 const VkBufferCreateInfo buffer_info = {
894 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
896 .usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
899 const VkBufferCreateInfo index_buffer_info = {
900 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
902 .usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
905 const VkBufferCreateInfo particle_color_buffer_info = {
906 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
908 .usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
911 const VkBufferCreateInfo beam_color_buffer_info = {
912 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
914 .usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
917 const VkBufferCreateInfo sprite_info_buffer_info = {
918 .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
920 .usage = VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT
Referenced by initialize_transparency().
◆ destroy_transparency()
void destroy_transparency |
( |
| ) |
|
◆ fill_index_buffer()
static void fill_index_buffer |
( |
| ) |
|
|
static |
Definition at line 1147 of file transparency.c.
1149 uint16_t* indices = (uint16_t*)
transparency.mapped_host_buffer;
1153 uint16_t* quad = indices + i * 6;
1155 const uint16_t base_vertex = i * 4;
1156 quad[0] = base_vertex + 0;
1157 quad[1] = base_vertex + 1;
1158 quad[2] = base_vertex + 2;
1159 quad[3] = base_vertex + 2;
1160 quad[4] = base_vertex + 3;
1161 quad[5] = base_vertex + 0;
1166 const VkBufferMemoryBarrier pre_barrier = {
1167 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
1169 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
1170 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
1171 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
1173 .size = VK_WHOLE_SIZE
1176 vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
1177 0, 0, NULL, 1, &pre_barrier, 0, NULL);
1179 const VkBufferCopy region = {
1185 const VkBufferMemoryBarrier post_barrier = {
1186 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
1187 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
1188 .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT,
1189 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
1190 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
1192 .size = VK_WHOLE_SIZE
1195 vkCmdPipelineBarrier(cmd_buf, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
1196 0, 0, NULL, 1, &post_barrier, 0, NULL);
Referenced by initialize_transparency().
◆ get_transparency_beam_blas()
VkAccelerationStructureNV get_transparency_beam_blas |
( |
| ) |
|
◆ get_transparency_beam_color_buffer_view()
VkBufferView get_transparency_beam_color_buffer_view |
( |
| ) |
|
◆ get_transparency_counts()
void get_transparency_counts |
( |
int * |
particle_num, |
|
|
int * |
beam_num, |
|
|
int * |
sprite_num |
|
) |
| |
◆ get_transparency_particle_blas()
VkAccelerationStructureNV get_transparency_particle_blas |
( |
| ) |
|
◆ get_transparency_particle_color_buffer_view()
VkBufferView get_transparency_particle_color_buffer_view |
( |
| ) |
|
◆ get_transparency_sprite_blas()
VkAccelerationStructureNV get_transparency_sprite_blas |
( |
| ) |
|
◆ get_transparency_sprite_info_buffer_view()
VkBufferView get_transparency_sprite_info_buffer_view |
( |
| ) |
|
◆ initialize_transparency()
qboolean initialize_transparency |
( |
| ) |
|
Definition at line 114 of file transparency.c.
124 const size_t particle_data_size = particle_vertex_position_max_size + particle_color_size;
128 const size_t beam_data_size = beam_vertex_position_max_size + beam_color_size;
132 const size_t sprite_data_size = sprite_vertex_position_max_size + sprite_info_size;
135 transparency.host_frame_size = particle_data_size + beam_data_size + sprite_data_size;
Referenced by vkpt_initialize_all().
◆ update_beam_blas()
static void update_beam_blas |
( |
VkCommandBuffer |
command_buffer | ) |
|
|
static |
Definition at line 747 of file transparency.c.
752 const VkGeometryTrianglesNV triangles = {
753 .sType = VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV,
757 .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT,
761 .indexType = VK_INDEX_TYPE_UINT16
764 const VkGeometryAABBNV aabbs = {
765 .sType = VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV
768 const VkGeometryDataNV geometry_data = {
769 .triangles = triangles,
773 const VkGeometryNV geometry = {
774 .sType = VK_STRUCTURE_TYPE_GEOMETRY_NV,
775 .geometryType = VK_GEOMETRY_TYPE_TRIANGLES_NV,
776 .geometry = geometry_data
779 const VkAccelerationStructureInfoNV info = {
780 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
781 .type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV,
785 .pGeometries = &geometry
792 qvkCmdBuildAccelerationStructureNV(command_buffer, &info, VK_NULL_HANDLE, 0, update,
Referenced by build_transparency_blas().
◆ update_particle_blas()
static void update_particle_blas |
( |
VkCommandBuffer |
command_buffer | ) |
|
|
static |
Definition at line 697 of file transparency.c.
702 vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
705 const VkGeometryTrianglesNV triangles = {
706 .sType = VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV,
710 .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT,
713 .indexType = VK_INDEX_TYPE_UINT16
716 const VkGeometryAABBNV aabbs = {
717 .sType = VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV
720 const VkGeometryDataNV geometry_data = {
721 .triangles = triangles,
725 const VkGeometryNV geometry = {
726 .sType = VK_STRUCTURE_TYPE_GEOMETRY_NV,
727 .geometryType = VK_GEOMETRY_TYPE_TRIANGLES_NV,
728 .geometry = geometry_data
731 const VkAccelerationStructureInfoNV info = {
732 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
733 .type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV,
737 .pGeometries = &geometry
743 qvkCmdBuildAccelerationStructureNV(command_buffer, &info, VK_NULL_HANDLE, 0, update,
Referenced by build_transparency_blas().
◆ update_sprite_blas()
static void update_sprite_blas |
( |
VkCommandBuffer |
command_buffer | ) |
|
|
static |
Definition at line 797 of file transparency.c.
802 const VkGeometryTrianglesNV triangles = {
803 .sType = VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV,
807 .vertexFormat = VK_FORMAT_R32G32B32_SFLOAT,
808 .vertexOffset =
transparency.sprite_vertex_device_offset,
811 .indexType = VK_INDEX_TYPE_UINT16
814 const VkGeometryAABBNV aabbs = {
815 .sType = VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV
818 const VkGeometryDataNV geometry_data = {
819 .triangles = triangles,
823 const VkGeometryNV geometry = {
824 .sType = VK_STRUCTURE_TYPE_GEOMETRY_NV,
825 .geometryType = VK_GEOMETRY_TYPE_TRIANGLES_NV,
826 .geometry = geometry_data
829 const VkAccelerationStructureInfoNV info = {
830 .sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV,
831 .type = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV,
835 .pGeometries = &geometry
841 qvkCmdBuildAccelerationStructureNV(command_buffer, &info, VK_NULL_HANDLE, 0, update,
Referenced by build_transparency_blas().
◆ update_transparency()
void update_transparency |
( |
VkCommandBuffer |
command_buffer, |
|
|
const float * |
view_matrix, |
|
|
const particle_t * |
particles, |
|
|
int |
particle_num, |
|
|
const entity_t * |
entities, |
|
|
int |
entity_num |
|
) |
| |
Definition at line 171 of file transparency.c.
179 for (
int i = 0; i < entity_num; i++)
181 if (entities[i].flags & RF_BEAM)
183 else if ((entities[i].model & 0x80000000) == 0)
186 if (model && model->type == MOD_SPRITE)
203 transparency.vertex_position_host_offset = host_buffer_offset;
204 transparency.particle_color_host_offset = host_buffer_offset + particle_vertices_size + beam_vertices_size + sprite_vertices_size;
Referenced by R_RenderFrame_RTX().
◆ upload_geometry()
static void upload_geometry |
( |
VkCommandBuffer |
command_buffer | ) |
|
|
static |
Definition at line 635 of file transparency.c.
642 const VkBufferCopy vertices = {
648 const VkBufferCopy paritcle_colors = {
654 const VkBufferCopy beam_colors = {
660 const VkBufferCopy sprite_infos = {
670 1, &paritcle_colors);
680 transparency.transfer_barriers[i].sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
681 transparency.transfer_barriers[i].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
682 transparency.transfer_barriers[i].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
683 transparency.transfer_barriers[i].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
684 transparency.transfer_barriers[i].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
690 transparency.transfer_barriers[1].size = paritcle_colors.size;
692 transparency.transfer_barriers[2].size = beam_colors.size;
694 transparency.transfer_barriers[3].size = sprite_infos.size;
Referenced by update_transparency().
◆ vkpt_build_beam_lights()
void vkpt_build_beam_lights |
( |
light_poly_t * |
light_list, |
|
|
int * |
num_lights, |
|
|
int |
max_lights, |
|
|
bsp_t * |
bsp, |
|
|
entity_t * |
entities, |
|
|
int |
num_entites, |
|
|
float |
adapted_luminance |
|
) |
| |
Definition at line 492 of file transparency.c.
497 if (hdr_factor <= 0.f)
504 for (
int i = 0; i < num_entites; i++)
509 if ((entities[i].flags & RF_BEAM) != 0)
510 beams[num_beams++] = entities + i;
518 for (
int i = 0; i < num_beams; i++)
520 if (*num_lights >= max_lights)
523 const entity_t* beam = beams[i];
527 VectorCopy(beam->oldorigin, begin);
528 VectorCopy(beam->origin, end);
531 VectorSubtract(end, begin, to_end);
534 VectorCopy(to_end, norm_dir);
536 VectorMA(begin, -5.f, norm_dir, begin);
537 VectorMA(end, 5.f, norm_dir, end);
Referenced by R_RenderFrame_RTX().
◆ vkpt_build_cylinder_light()
qboolean vkpt_build_cylinder_light |
( |
light_poly_t * |
light_list, |
|
|
int * |
num_lights, |
|
|
int |
max_lights, |
|
|
bsp_t * |
bsp, |
|
|
vec3_t |
begin, |
|
|
vec3_t |
end, |
|
|
vec3_t |
color, |
|
|
float |
radius |
|
) |
| |
Definition at line 408 of file transparency.c.
410 vec3_t dir, norm_dir;
411 VectorSubtract(end, begin, dir);
412 VectorCopy(dir, norm_dir);
415 vec3_t
up = { 0.f, 0.f, 1.f };
416 vec3_t left = { 1.f, 0.f, 0.f };
417 if (fabsf(norm_dir[2]) < 0.9f)
419 CrossProduct(
up, norm_dir, left);
421 CrossProduct(norm_dir, left,
up);
426 CrossProduct(norm_dir, left,
up);
428 CrossProduct(
up, norm_dir, left);
433 vec3_t vertices[6] = {
435 { 0.866f, -0.5f, 0.f },
436 { -0.866f, -0.5f, 0.f },
438 { -0.866f, 0.5f, 1.f },
439 { 0.866f, 0.5f, 1.f },
442 const int indices[18] = {
451 for (
int vert = 0; vert < 6; vert++)
454 VectorCopy(begin, transformed);
455 VectorMA(transformed, vertices[vert][0] * radius,
up, transformed);
456 VectorMA(transformed, vertices[vert][1] * radius, left, transformed);
457 VectorMA(transformed, vertices[vert][2], dir, transformed);
458 VectorCopy(transformed, vertices[vert]);
461 for (
int tri = 0; tri < 6; tri++)
463 if (*num_lights >= max_lights)
466 int i0 = indices[tri * 3 + 0];
467 int i1 = indices[tri * 3 + 1];
468 int i2 = indices[tri * 3 + 2];
472 VectorCopy(vertices[i0], light->
positions + 0);
473 VectorCopy(vertices[i1], light->
positions + 3);
474 VectorCopy(vertices[i2], light->
positions + 6);
Referenced by process_regular_entity(), and vkpt_build_beam_lights().
◆ write_beam_geometry()
static void write_beam_geometry |
( |
const float * |
view_matrix, |
|
|
const entity_t * |
entities, |
|
|
int |
entity_num |
|
) |
| |
|
static |
Definition at line 325 of file transparency.c.
330 const vec3_t view_y = { view_matrix[1], view_matrix[5], view_matrix[9] };
339 const size_t beam_vertex_offset =
transparency.vertex_position_host_offset + particle_vertex_data_size;
342 vec3_t* vertex_positions = (vec3_t*)(
transparency.mapped_host_buffer + beam_vertex_offset);
345 for (
int i = 0; i < entity_num; i++)
347 if ((entities[i].flags & RF_BEAM) == 0)
350 const entity_t* beam = entities + i;
353 beam_colors[3] = beam->alpha;
354 beam_colors = beam_colors + 4;
358 VectorCopy(beam->oldorigin, begin);
359 VectorCopy(beam->origin, end);
362 VectorSubtract(end, begin, to_end);
365 VectorCopy(to_end, norm_dir);
367 VectorMA(begin, -5.f, norm_dir, begin);
368 VectorMA(end, 5.f, norm_dir, end);
371 VectorSubtract(view_origin, begin, to_view);
374 CrossProduct(to_end, to_view, x_axis);
376 VectorScale(x_axis, beam_width, x_axis);
378 VectorSubtract(end, x_axis, vertex_positions[0]);
379 VectorAdd(end, x_axis, vertex_positions[1]);
380 VectorAdd(begin, x_axis, vertex_positions[2]);
381 VectorSubtract(begin, x_axis, vertex_positions[3]);
382 vertex_positions += 4;
Referenced by update_transparency().
◆ write_particle_geometry()
static void write_particle_geometry |
( |
const float * |
view_matrix, |
|
|
const particle_t * |
particles, |
|
|
int |
particle_num |
|
) |
| |
|
static |
Definition at line 263 of file transparency.c.
267 const vec3_t view_y = { view_matrix[1], view_matrix[5], view_matrix[9] };
278 const particle_t* particle =
particles + i;
281 particle_colors[3] = particle->alpha;
282 particle_colors = particle_colors + 4;
285 VectorCopy(particle->origin,
origin);
288 VectorSubtract(view_origin,
origin, z_axis);
293 CrossProduct(z_axis, view_y, x_axis);
294 CrossProduct(x_axis, z_axis, y_axis);
296 const float size_factor = pow(particle->alpha, 0.05f);
297 if (particle->radius == 0.f)
299 VectorScale(y_axis, particle_size * size_factor, y_axis);
300 VectorScale(x_axis, particle_size * size_factor, x_axis);
304 VectorScale(y_axis, particle->radius, y_axis);
305 VectorScale(x_axis, particle->radius, x_axis);
309 VectorSubtract(
origin, x_axis, temp);
310 VectorAdd(temp, y_axis, vertex_positions[0]);
312 VectorAdd(
origin, x_axis, temp);
313 VectorAdd(temp, y_axis, vertex_positions[1]);
315 VectorAdd(
origin, x_axis, temp);
316 VectorSubtract(temp, y_axis, vertex_positions[2]);
318 VectorSubtract(
origin, x_axis, temp);
319 VectorSubtract(temp, y_axis, vertex_positions[3]);
321 vertex_positions += 4;
Referenced by update_transparency().
◆ write_sprite_geometry()
static void write_sprite_geometry |
( |
const float * |
view_matrix, |
|
|
const entity_t * |
entities, |
|
|
int |
entity_num |
|
) |
| |
|
static |
Definition at line 546 of file transparency.c.
551 const vec3_t view_x = { view_matrix[0], view_matrix[4], view_matrix[8] };
552 const vec3_t view_y = { view_matrix[1], view_matrix[5], view_matrix[9] };
553 const vec3_t world_y = { 0.f, 0.f, 1.f };
560 const size_t sprite_vertex_offset =
transparency.vertex_position_host_offset + particle_vertex_data_size + beam_vertex_data_size;
563 vec3_t* vertex_positions = (vec3_t*)(
transparency.mapped_host_buffer + sprite_vertex_offset);
566 int sprite_count = 0;
567 for (
int i = 0; i < entity_num; i++)
569 const entity_t *e = entities + i;
571 if (e->model & 0x80000000)
575 if (!model || model->type != MOD_SPRITE)
578 mspriteframe_t *frame = &model->spriteframes[e->frame % model->numframes];
582 sprite_info[1] = *(uint32_t*)&e->alpha;
593 VectorSubtract(view_origin, e->origin, to_camera);
596 CrossProduct(world_y, to_camera, cyl_x);
599 VectorScale(cyl_x, frame->origin_x, left);
600 VectorScale(cyl_x, frame->origin_x - frame->width,
right);
602 VectorScale(world_y, -frame->origin_y, down);
603 VectorScale(world_y, frame->height - frame->origin_y,
up);
607 VectorScale(view_x, frame->origin_x, left);
608 VectorScale(view_x, frame->origin_x - frame->width,
right);
610 if (model->sprite_vertical)
612 VectorScale(world_y, -frame->origin_y, down);
613 VectorScale(world_y, frame->height - frame->origin_y,
up);
617 VectorScale(view_y, -frame->origin_y, down);
618 VectorScale(view_y, frame->height - frame->origin_y,
up);
622 VectorAdd3(e->origin, down, left, vertex_positions[0]);
623 VectorAdd3(e->origin,
up, left, vertex_positions[1]);
624 VectorAdd3(e->origin,
up,
right, vertex_positions[2]);
625 VectorAdd3(e->origin, down,
right, vertex_positions[3]);
627 vertex_positions += 4;
Referenced by update_transparency().
◆ beam_blas
VkAccelerationStructureNV beam_blas |
◆ beam_color_buffer
VkBuffer beam_color_buffer |
◆ beam_color_buffer_view
VkBufferView beam_color_buffer_view |
◆ beam_color_host_offset
size_t beam_color_host_offset |
◆ beam_num
◆ beam_scratch_device_offset
size_t beam_scratch_device_offset |
◆ beam_vertex_device_offset
size_t beam_vertex_device_offset |
◆ blas_beam_num
unsigned int blas_beam_num |
◆ blas_particle_num
unsigned int blas_particle_num |
◆ blas_sprite_num
unsigned int blas_sprite_num |
◆ cvar_pt_beam_lights
cvar_t* cvar_pt_beam_lights = NULL |
◆ cvar_pt_beam_width
cvar_t* cvar_pt_beam_width = NULL |
◆ cvar_pt_enable_particles
cvar_t* cvar_pt_enable_particles |
◆ cvar_pt_particle_emissive
cvar_t* cvar_pt_particle_emissive |
Definition at line 835 of file effects.c.
Referenced by CL_BFGExplosionParticles(), CL_BfgParticles(), CL_BlasterParticles(), CL_BlasterTrail(), CL_ExplosionParticles(), CL_OldRailTrail(), CL_ParticleEffect(), CL_QuadTrail(), CL_RocketTrail(), FX_Init(), and write_beam_geometry().
◆ cvar_pt_particle_size
cvar_t* cvar_pt_particle_size = NULL |
◆ cvar_pt_projection
cvar_t* cvar_pt_projection |
◆ device_blas_memory
VkDeviceMemory device_blas_memory |
◆ device_buffer_memory
VkDeviceMemory device_buffer_memory |
◆ host_buffer
◆ host_buffer_memory
VkDeviceMemory host_buffer_memory |
◆ host_buffer_size
◆ host_buffered_frame_num
unsigned int host_buffered_frame_num |
◆ host_frame_index
unsigned int host_frame_index |
◆ host_frame_size
◆ index_buffer
◆ mapped_host_buffer
◆ particle_blas
VkAccelerationStructureNV particle_blas |
◆ particle_color_buffer
VkBuffer particle_color_buffer |
◆ particle_color_buffer_view
VkBufferView particle_color_buffer_view |
◆ particle_color_host_offset
size_t particle_color_host_offset |
◆ particle_num
unsigned int particle_num |
◆ scratch_buffer
◆ sprite_blas
VkAccelerationStructureNV sprite_blas |
◆ sprite_info_buffer
VkBuffer sprite_info_buffer |
◆ sprite_info_buffer_view
VkBufferView sprite_info_buffer_view |
◆ sprite_info_host_offset
size_t sprite_info_host_offset |
◆ sprite_num
◆ sprite_scratch_device_offset
size_t sprite_scratch_device_offset |
◆ sprite_vertex_device_offset
size_t sprite_vertex_device_offset |
◆ transfer_barriers
VkBufferMemoryBarrier transfer_barriers[4] |
◆ transparency
struct { ... } transparency |
Referenced by allocate_and_bind_memory_to_blas(), allocate_and_bind_memory_to_buffers(), create_blas(), create_buffer_views(), create_buffers(), destroy_transparency(), fill_index_buffer(), get_transparency_beam_blas(), get_transparency_beam_color_buffer_view(), get_transparency_counts(), get_transparency_particle_blas(), get_transparency_particle_color_buffer_view(), get_transparency_sprite_blas(), get_transparency_sprite_info_buffer_view(), initialize_transparency(), update_beam_blas(), update_particle_blas(), update_sprite_blas(), update_transparency(), upload_geometry(), write_beam_geometry(), write_particle_geometry(), and write_sprite_geometry().
◆ vertex_buffer
◆ vertex_position_host_offset
size_t vertex_position_host_offset |
static void update_sprite_blas(VkCommandBuffer command_buffer)
static void update_particle_blas(VkCommandBuffer command_buffer)
#define MAX_FRAMES_IN_FLIGHT
VkResult allocate_gpu_memory(VkMemoryRequirements mem_req, VkDeviceMemory *pMemory)
cvar_t * cvar_pt_projection
static qboolean allocate_and_bind_memory_to_buffers()
model_t * MOD_ForHandle(qhandle_t h)
cvar_t * cvar_pt_particle_emissive
static size_t align(size_t x, size_t alignment)
vkpt_refdef_t vkpt_refdef
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
static cparticle_t particles[MAX_PARTICLES]
cmd_buf_group_t cmd_buffers_transfer
void cast_u32_to_f32_color(int color_index, const color_t *pcolor, float *color_f32, float hdr_factor)
struct pbr_material_s * material
cvar_t * cvar_pt_particle_size
qboolean vkpt_build_cylinder_light(light_poly_t *light_list, int *num_lights, int max_lights, bsp_t *bsp, vec3_t begin, vec3_t end, vec3_t color, float radius)
static void write_particle_geometry(const float *view_matrix, const particle_t *particles, int particle_num)
uint32_t d_8to24table[256]
#define TR_BLAS_BUILD_FLAGS
#define TR_SPRITE_MAX_NUM
static void write_beam_geometry(const float *view_matrix, const entity_t *entities, int entity_num)
static size_t calculate_scratch_buffer_size(VkAccelerationStructureNV blas)
static void create_buffer_views()
static int compare_beams(const void *_a, const void *_b)
mleaf_t * BSP_PointLeaf(mnode_t *node, vec3_t p)
#define TR_VERTEX_MAX_NUM
uint32_t get_memory_type(uint32_t mem_req_type_bits, VkMemoryPropertyFlags mem_prop)
#define TR_SPRITE_INFO_SIZE
cvar_t * cvar_pt_beam_width
qboolean get_triangle_off_center(const float *positions, float *center, float *anti_center)
image_t r_images[MAX_RIMAGES]
cvar_t * cvar_pt_beam_lights
void vkpt_wait_idle(VkQueue queue, cmd_buf_group_t *group)
static void write_sprite_geometry(const float *view_matrix, const entity_t *entities, int entity_num)
static void fill_index_buffer()
unsigned int particle_num
static void create_blas()
static void create_buffers()
#define TR_PARTICLE_MAX_NUM
void vkpt_submit_command_buffer_simple(VkCommandBuffer cmd_buf, VkQueue queue, qboolean all_gpus)
static void update_beam_blas(VkCommandBuffer command_buffer)
static void upload_geometry(VkCommandBuffer command_buffer)
VkCommandBuffer vkpt_begin_command_buffer(cmd_buf_group_t *group)
CONST PIXELFORMATDESCRIPTOR int
vec_t VectorNormalize(vec3_t v)
static void allocate_and_bind_memory_to_blas()