Quake II RTX doxygen
1.0 dev
|
|
#include <vulkan/vulkan.h>
#include <SDL.h>
#include <SDL_vulkan.h>
#include "vk_util.h"
#include "shared/shared.h"
#include "common/bsp.h"
#include "common/cmd.h"
#include "common/common.h"
#include "common/cvar.h"
#include "common/files.h"
#include "common/math.h"
#include "client/video.h"
#include "client/client.h"
#include "refresh/refresh.h"
#include "refresh/images.h"
#include "refresh/models.h"
#include "system/hunk.h"
#include "shader/global_ubo.h"
#include "shader/global_textures.h"
#include "shader/vertex_buffer.h"
Go to the source code of this file.
|
#define | HAVE_M_PI |
|
#define | LENGTH(a) ((sizeof (a)) / (sizeof(*(a)))) |
|
#define | MIN(a, b) ((a) < (b) ? (a) : (b)) |
|
#define | MAX(a, b) ((a) > (b) ? (a) : (b)) |
|
#define | LOG_FUNC_(f) do {} while(0) |
|
#define | LOG_FUNC() LOG_FUNC_(__func__) |
|
#define | _VK(...) do { __VA_ARGS__; } while(0) |
|
#define | LIST_SHADER_MODULES |
|
#define | VKPT_SHADER_DIR "shader_vkpt" |
|
#define | SHADER_PATH_TEMPLATE VKPT_SHADER_DIR "/%s.spv" |
|
#define | SHADER_STAGE(_module, _stage) |
|
#define | SHADER_STAGE_SPEC(_module, _stage, _spec) |
|
#define | SHADER_MODULE_DO(a) a, |
|
#define | MAX_FRAMES_IN_FLIGHT 2 |
|
#define | MAX_SWAPCHAIN_IMAGES 4 |
|
#define | _VK_INST_EXTENSION_LIST |
|
#define | _VK_INST_EXTENSION_DO(a) extern PFN_##a q##a; |
|
#define | _VK_EXTENSION_LIST |
|
#define | _VK_EXTENSION_DO(a) extern PFN_##a q##a; |
|
#define | MAX_SKY_CLUSTERS 1024 |
|
#define | PROFILER_LIST |
|
#define | PROFILER_DO(a, ...) a, |
|
#define | NUM_PROFILER_QUERIES_PER_FRAME (NUM_PROFILER_ENTRIES * 2) |
|
#define | ALL_GPUS (-1) |
|
#define | TESS_MAX_VERTICES 16384 |
|
#define | TESS_MAX_INDICES (3 * TESS_MAX_VERTICES) |
|
#define | QGL_INDEX_TYPE GLuint |
|
#define | BEGIN_PERF_MARKER(command_buffer, name) begin_perf_marker(command_buffer, name, #name) |
|
#define | END_PERF_MARKER(command_buffer, name) end_perf_marker(command_buffer, name) |
|
|
void | bsp_mesh_create_from_bsp (bsp_mesh_t *wm, bsp_t *bsp, const char *map_name) |
|
void | bsp_mesh_destroy (bsp_mesh_t *wm) |
|
void | bsp_mesh_register_textures (bsp_t *bsp) |
|
void | mult_matrix_matrix (float *p, const float *a, const float *b) |
|
void | mult_matrix_vector (float *p, const float *a, const float *b) |
|
void | create_entity_matrix (float matrix[16], entity_t *e, qboolean enable_left_hand) |
|
void | create_projection_matrix (float matrix[16], float znear, float zfar, float fov_x, float fov_y) |
|
void | create_view_matrix (float matrix[16], refdef_t *fd) |
|
void | inverse (const float *m, float *inv) |
|
void | create_orthographic_matrix (float matrix[16], float xmin, float xmax, float ymin, float ymax, float znear, float zfar) |
|
VkDescriptorSet | qvk_get_current_desc_set_textures () |
|
VkResult | vkpt_profiler_initialize () |
|
VkResult | vkpt_profiler_destroy () |
|
VkResult | vkpt_profiler_query (VkCommandBuffer cmd_buf, int idx, VKPTProfilerAction action) |
|
VkResult | vkpt_profiler_next_frame (VkCommandBuffer cmd_buf) |
|
void | draw_profiler (int enable_asvgf) |
|
double | vkpt_get_profiler_result (int idx) |
|
VkResult | vkpt_readback (struct ReadbackBuffer *dst) |
|
VkResult | vkpt_textures_initialize () |
|
VkResult | vkpt_textures_destroy () |
|
VkResult | vkpt_textures_end_registration () |
|
VkResult | vkpt_textures_upload_envmap (int w, int h, byte *data) |
|
void | vkpt_textures_destroy_unused () |
|
void | vkpt_textures_update_descriptor_set () |
|
void | vkpt_normalize_normal_map (image_t *image) |
|
void | vkpt_extract_emissive_texture_info (image_t *image) |
|
void | vkpt_textures_prefetch () |
|
void | vkpt_init_light_textures () |
|
VkCommandBuffer | vkpt_begin_command_buffer (cmd_buf_group_t *group) |
|
void | vkpt_free_command_buffers (cmd_buf_group_t *group) |
|
void | vkpt_reset_command_buffers (cmd_buf_group_t *group) |
|
void | vkpt_wait_idle (VkQueue queue, cmd_buf_group_t *group) |
|
void | vkpt_submit_command_buffer (VkCommandBuffer cmd_buf, VkQueue queue, uint32_t execute_device_mask, int wait_semaphore_count, VkSemaphore *wait_semaphores, VkPipelineStageFlags *wait_stages, uint32_t *wait_device_indices, int signal_semaphore_count, VkSemaphore *signal_semaphores, uint32_t *signal_device_indices, VkFence fence) |
|
void | vkpt_submit_command_buffer_simple (VkCommandBuffer cmd_buf, VkQueue queue, qboolean all_gpus) |
|
void | set_current_gpu (VkCommandBuffer cmd_buf, int gpu_index) |
|
VkResult | allocate_gpu_memory (VkMemoryRequirements mem_req, VkDeviceMemory *pMemory) |
|
void | vkpt_image_copy (VkCommandBuffer cmd_buf, int src_image_index, int dst_image_index, VkOffset2D src_offset, VkOffset2D dst_offset, VkExtent2D size) |
|
VkResult | vkpt_draw_initialize () |
|
VkResult | vkpt_draw_destroy () |
|
VkResult | vkpt_draw_destroy_pipelines () |
|
VkResult | vkpt_draw_create_pipelines () |
|
VkResult | vkpt_draw_submit_stretch_pics (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_final_blit_simple (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_final_blit_filtered (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_draw_clear_stretch_pics () |
|
VkResult | vkpt_uniform_buffer_create () |
|
VkResult | vkpt_uniform_buffer_destroy () |
|
VkResult | vkpt_uniform_buffer_update (VkCommandBuffer command_buffer) |
|
VkResult | vkpt_vertex_buffer_create () |
|
VkResult | vkpt_vertex_buffer_destroy () |
|
VkResult | vkpt_vertex_buffer_upload_bsp_mesh_to_staging (bsp_mesh_t *bsp_mesh) |
|
VkResult | vkpt_vertex_buffer_create_pipelines () |
|
VkResult | vkpt_vertex_buffer_destroy_pipelines () |
|
VkResult | vkpt_vertex_buffer_create_instance (VkCommandBuffer cmd_buf, uint32_t num_instances, qboolean update_world_animations) |
|
VkResult | vkpt_vertex_buffer_upload_models_to_staging () |
|
VkResult | vkpt_vertex_buffer_upload_staging () |
|
void | vkpt_light_buffer_reset_counts () |
|
VkResult | vkpt_light_buffer_upload_to_staging (qboolean render_world, bsp_mesh_t *bsp_mesh, bsp_t *bsp, int num_model_lights, light_poly_t *transformed_model_lights, const float *sky_radiance) |
|
VkResult | vkpt_light_buffer_upload_staging (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_light_stats_create (bsp_mesh_t *bsp_mesh) |
|
VkResult | vkpt_light_stats_destroy () |
|
VkResult | vkpt_load_shader_modules () |
|
VkResult | vkpt_destroy_shader_modules () |
|
VkResult | vkpt_create_images () |
|
VkResult | vkpt_destroy_images () |
|
VkResult | vkpt_pt_init () |
|
VkResult | vkpt_pt_destroy () |
|
VkResult | vkpt_pt_create_pipelines () |
|
VkResult | vkpt_pt_destroy_pipelines () |
|
VkResult | vkpt_pt_create_toplevel (VkCommandBuffer cmd_buf, int idx, qboolean include_world, qboolean weapon_left_handed) |
|
VkResult | vkpt_pt_create_static (VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices, int num_vertices_transparent, int num_vertices_sky, int num_vertices_custom_sky) |
|
VkResult | vkpt_pt_destroy_static () |
|
VkResult | vkpt_pt_trace_primary_rays (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_pt_trace_reflections (VkCommandBuffer cmd_buf, int bounce) |
|
VkResult | vkpt_pt_trace_lighting (VkCommandBuffer cmd_buf, float num_bounce_rays) |
|
VkResult | vkpt_pt_update_descripter_set_bindings (int idx) |
|
VkResult | vkpt_pt_create_all_dynamic (VkCommandBuffer cmd_buf, int idx, VkBuffer vertex_buffer, const EntityUploadInfo *upload_info) |
|
VkResult | vkpt_asvgf_initialize () |
|
VkResult | vkpt_asvgf_destroy () |
|
VkResult | vkpt_asvgf_create_pipelines () |
|
VkResult | vkpt_asvgf_destroy_pipelines () |
|
VkResult | vkpt_asvgf_filter (VkCommandBuffer cmd_buf, qboolean enable_lf) |
|
VkResult | vkpt_compositing (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_interleave (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_taa (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_asvgf_create_gradient_samples (VkCommandBuffer cmd_buf, uint32_t frame_num, int do_gradient_samples) |
|
VkResult | vkpt_bloom_initialize () |
|
VkResult | vkpt_bloom_destroy () |
|
VkResult | vkpt_bloom_create_pipelines () |
|
VkResult | vkpt_bloom_destroy_pipelines () |
|
void | vkpt_bloom_reset () |
|
void | vkpt_bloom_update (QVKUniformBuffer_t *ubo, float frame_time, qboolean under_water, qboolean menu_mode) |
|
VkResult | vkpt_bloom_record_cmd_buffer (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_tone_mapping_initialize () |
|
VkResult | vkpt_tone_mapping_destroy () |
|
VkResult | vkpt_tone_mapping_create_pipelines () |
|
VkResult | vkpt_tone_mapping_reset (VkCommandBuffer cmd_buf) |
|
VkResult | vkpt_tone_mapping_destroy_pipelines () |
|
VkResult | vkpt_tone_mapping_record_cmd_buffer (VkCommandBuffer cmd_buf, float frame_time) |
|
void | vkpt_tone_mapping_request_reset () |
|
VkResult | vkpt_shadow_map_initialize () |
|
VkResult | vkpt_shadow_map_destroy () |
|
VkResult | vkpt_shadow_map_create_pipelines () |
|
VkResult | vkpt_shadow_map_destroy_pipelines () |
|
VkResult | vkpt_shadow_map_render (VkCommandBuffer cmd_buf, float *view_projection_matrix, int num_static_verts, int num_dynamic_verts, int transparent_offset, int num_transparent_verts) |
|
VkImageView | vkpt_shadow_map_get_view () |
|
void | vkpt_shadow_map_setup (const sun_light_t *light, const float *bbox_min, const float *bbox_max, float *VP, float *depth_scale, qboolean random_sampling) |
|
qerror_t | load_img (const char *name, image_t *image) |
|
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) |
|
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) |
|
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) |
|
qboolean | get_triangle_off_center (const float *positions, float *center, float *anti_center) |
|
VkResult | vkpt_initialize_god_rays () |
|
VkResult | vkpt_destroy_god_rays () |
|
VkResult | vkpt_god_rays_create_pipelines () |
|
VkResult | vkpt_god_rays_destroy_pipelines () |
|
VkResult | vkpt_god_rays_update_images () |
|
VkResult | vkpt_god_rays_noop () |
|
qboolean | vkpt_god_rays_enabled (const sun_light_t *sun_light) |
|
void | vkpt_record_god_rays_trace_command_buffer (VkCommandBuffer command_buffer, int pass) |
|
void | vkpt_record_god_rays_filter_command_buffer (VkCommandBuffer command_buffer) |
|
void | vkpt_god_rays_prepare_ubo (QVKUniformBuffer_t *ubo, const aabb_t *world_aabb, const float *proj, const float *view, const float *shadowmap_viewproj, float shadowmap_depth_scale) |
|
void | vkpt_freecam_reset () |
|
void | vkpt_freecam_update (float frame_time) |
|
void | vkpt_reset_accumulation () |
|
static void | begin_perf_marker (VkCommandBuffer command_buffer, int index, const char *name) |
|
static void | end_perf_marker (VkCommandBuffer command_buffer, int index) |
|
void | R_SetClipRect_RTX (const clipRect_t *clip) |
|
void | R_ClearColor_RTX (void) |
|
void | R_SetAlpha_RTX (float alpha) |
|
void | R_SetAlphaScale_RTX (float alpha) |
|
void | R_SetColor_RTX (uint32_t color) |
|
void | R_LightPoint_RTX (vec3_t origin, vec3_t light) |
|
void | R_SetScale_RTX (float scale) |
|
void | R_DrawStretchPic_RTX (int x, int y, int w, int h, qhandle_t pic) |
|
void | R_DrawPic_RTX (int x, int y, qhandle_t pic) |
|
void | R_TileClear_RTX (int x, int y, int w, int h, qhandle_t pic) |
|
void | R_DrawFill8_RTX (int x, int y, int w, int h, int c) |
|
void | R_DrawFill32_RTX (int x, int y, int w, int h, uint32_t color) |
|
void | R_DrawChar_RTX (int x, int y, int flags, int c, qhandle_t font) |
|
int | R_DrawString_RTX (int x, int y, int flags, size_t maxlen, const char *s, qhandle_t font) |
|
qboolean | R_InterceptKey_RTX (unsigned key, qboolean down) |
|
void | IMG_Load_RTX (image_t *image, byte *pic) |
|
void | IMG_Unload_RTX (image_t *image) |
|
byte * | IMG_ReadPixels_RTX (int *width, int *height, int *rowbytes) |
|
qerror_t | MOD_LoadMD2_RTX (model_t *model, const void *rawdata, size_t length) |
|
qerror_t | MOD_LoadMD3_RTX (model_t *model, const void *rawdata, size_t length) |
|
void | MOD_Reference_RTX (model_t *model) |
|
◆ _VK
#define _VK |
( |
|
... | ) |
do { __VA_ARGS__; } while(0) |
◆ _VK_EXTENSION_DO
#define _VK_EXTENSION_DO |
( |
|
a | ) |
extern PFN_##a q##a; |
◆ _VK_EXTENSION_LIST
#define _VK_EXTENSION_LIST |
Value:
_VK_EXTENSION_DO(vkCreateAccelerationStructureNV) \
_VK_EXTENSION_DO(vkDestroyAccelerationStructureNV) \
_VK_EXTENSION_DO(vkGetAccelerationStructureMemoryRequirementsNV) \
_VK_EXTENSION_DO(vkBindAccelerationStructureMemoryNV) \
_VK_EXTENSION_DO(vkCmdBuildAccelerationStructureNV) \
_VK_EXTENSION_DO(vkCmdCopyAccelerationStructureNV) \
_VK_EXTENSION_DO(vkCmdTraceRaysNV) \
_VK_EXTENSION_DO(vkCreateRayTracingPipelinesNV) \
_VK_EXTENSION_DO(vkGetRayTracingShaderGroupHandlesNV) \
_VK_EXTENSION_DO(vkGetAccelerationStructureHandleNV) \
_VK_EXTENSION_DO(vkCmdWriteAccelerationStructuresPropertiesNV) \
_VK_EXTENSION_DO(vkCompileDeferredNV) \
_VK_EXTENSION_DO(vkDebugMarkerSetObjectNameEXT) \
_VK_EXTENSION_DO(vkGetDeviceGroupPeerMemoryFeaturesKHR) \
_VK_EXTENSION_DO(vkCmdSetDeviceMaskKHR) \
_VK_EXTENSION_DO(vkCmdDispatchBaseKHR) \
_VK_EXTENSION_DO(vkGetDeviceGroupPresentCapabilitiesKHR) \
_VK_EXTENSION_DO(vkGetDeviceGroupSurfacePresentModesKHR) \
_VK_EXTENSION_DO(vkGetPhysicalDevicePresentRectanglesKHR) \
_VK_EXTENSION_DO(vkAcquireNextImage2KHR) \
_VK_EXTENSION_DO(vkBindImageMemory2KHR)
Definition at line 284 of file vkpt.h.
◆ _VK_INST_EXTENSION_DO
#define _VK_INST_EXTENSION_DO |
( |
|
a | ) |
extern PFN_##a q##a; |
◆ _VK_INST_EXTENSION_LIST
#define _VK_INST_EXTENSION_LIST |
Value:
_VK_INST_EXTENSION_DO(vkCmdEndDebugUtilsLabelEXT) \
_VK_INST_EXTENSION_DO(vkEnumeratePhysicalDeviceGroupsKHR)
Definition at line 275 of file vkpt.h.
◆ ALL_GPUS
◆ BEGIN_PERF_MARKER
#define BEGIN_PERF_MARKER |
( |
|
command_buffer, |
|
|
|
name |
|
) |
| begin_perf_marker(command_buffer, name, #name) |
◆ END_PERF_MARKER
#define END_PERF_MARKER |
( |
|
command_buffer, |
|
|
|
name |
|
) |
| end_perf_marker(command_buffer, name) |
◆ HAVE_M_PI
◆ LENGTH
#define LENGTH |
( |
|
a | ) |
((sizeof (a)) / (sizeof(*(a)))) |
◆ LIST_SHADER_MODULES
#define LIST_SHADER_MODULES |
◆ LOG_FUNC
◆ LOG_FUNC_
#define LOG_FUNC_ |
( |
|
f | ) |
do {} while(0) |
◆ MAX
#define MAX |
( |
|
a, |
|
|
|
b |
|
) |
| ((a) > (b) ? (a) : (b)) |
◆ MAX_FRAMES_IN_FLIGHT
#define MAX_FRAMES_IN_FLIGHT 2 |
◆ MAX_SKY_CLUSTERS
#define MAX_SKY_CLUSTERS 1024 |
◆ MAX_SWAPCHAIN_IMAGES
#define MAX_SWAPCHAIN_IMAGES 4 |
◆ MIN
#define MIN |
( |
|
a, |
|
|
|
b |
|
) |
| ((a) < (b) ? (a) : (b)) |
◆ NUM_PROFILER_QUERIES_PER_FRAME
◆ PROFILER_DO
#define PROFILER_DO |
( |
|
a, |
|
|
|
... |
|
) |
| a, |
◆ PROFILER_LIST
Value:
PROFILER_DO(PROFILER_INSTANCE_GEOMETRY, 1) \
PROFILER_DO(PROFILER_BVH_UPDATE, 1) \
PROFILER_DO(PROFILER_ASVGF_GRADIENT_SAMPLES, 1) \
PROFILER_DO(PROFILER_ASVGF_DO_GRADIENT_SAMPLES, 2) \
PROFILER_DO(PROFILER_PRIMARY_RAYS, 1) \
PROFILER_DO(PROFILER_REFLECT_REFRACT_1, 1) \
PROFILER_DO(PROFILER_REFLECT_REFRACT_2, 1) \
PROFILER_DO(PROFILER_DIRECT_LIGHTING, 1) \
PROFILER_DO(PROFILER_INDIRECT_LIGHTING, 1) \
PROFILER_DO(PROFILER_ASVGF_FULL, 1) \
PROFILER_DO(PROFILER_ASVGF_RECONSTRUCT_GRADIENT, 2) \
PROFILER_DO(PROFILER_ASVGF_TEMPORAL, 2) \
PROFILER_DO(PROFILER_ASVGF_ATROUS, 2) \
PROFILER_DO(PROFILER_MGPU_TRANSFERS, 1) \
PROFILER_DO(PROFILER_INTERLEAVE, 1) \
PROFILER_DO(PROFILER_ASVGF_TAA, 2) \
PROFILER_DO(PROFILER_BLOOM, 1) \
PROFILER_DO(PROFILER_TONE_MAPPING, 1) \
PROFILER_DO(PROFILER_UPDATE_ENVIRONMENT, 1) \
PROFILER_DO(PROFILER_GOD_RAYS, 1) \
PROFILER_DO(PROFILER_GOD_RAYS_REFLECT_REFRACT, 1) \
PROFILER_DO(PROFILER_GOD_RAYS_FILTER, 1) \
PROFILER_DO(PROFILER_SHADOW_MAP, 1) \
PROFILER_DO(PROFILER_COMPOSITING, 1) \
Definition at line 432 of file vkpt.h.
◆ QGL_INDEX_TYPE
#define QGL_INDEX_TYPE GLuint |
◆ SHADER_MODULE_DO
#define SHADER_MODULE_DO |
( |
|
a | ) |
a, |
◆ SHADER_PATH_TEMPLATE
◆ SHADER_STAGE
#define SHADER_STAGE |
( |
|
_module, |
|
|
|
_stage |
|
) |
| |
Value: { \
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, \
.stage = _stage, \
.pName = "main" \
}
Definition at line 116 of file vkpt.h.
◆ SHADER_STAGE_SPEC
#define SHADER_STAGE_SPEC |
( |
|
_module, |
|
|
|
_stage, |
|
|
|
_spec |
|
) |
| |
Value: { \
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, \
.stage = _stage, \
.pName = "main", \
.pSpecializationInfo = _spec, \
}
Definition at line 124 of file vkpt.h.
◆ TESS_MAX_INDICES
◆ TESS_MAX_VERTICES
#define TESS_MAX_VERTICES 16384 |
◆ VKPT_SHADER_DIR
#define VKPT_SHADER_DIR "shader_vkpt" |
◆ aabb_t
◆ bsp_mesh_t
◆ bsp_model_t
◆ cmd_buf_group_t
◆ EntityUploadInfo
◆ light_poly_t
◆ maliasframe_t
◆ maliasmesh_t
◆ QVK_t
◆ semaphore_group_t
◆ sun_light_t
◆ vkpt_refdef_t
◆ anonymous enum
Enumerator |
---|
NUM_PROFILER_ENTRIES | |
Definition at line 459 of file vkpt.h.
460 #define PROFILER_DO(a, ...) a,
◆ QVK_SHADER_MODULES
Enumerator |
---|
NUM_QVK_SHADER_MODULES | |
Definition at line 133 of file vkpt.h.
134 #define SHADER_MODULE_DO(a) a,
136 #undef SHADER_MODULE_DO
◆ VKPTProfilerAction
Enumerator |
---|
PROFILER_START | |
PROFILER_STOP | |
Definition at line 468 of file vkpt.h.
◆ allocate_gpu_memory()
VkResult allocate_gpu_memory |
( |
VkMemoryRequirements |
mem_req, |
|
|
VkDeviceMemory * |
pMemory |
|
) |
| |
Definition at line 402 of file vk_util.c.
404 VkMemoryAllocateInfo mem_alloc_info = {
405 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
406 .allocationSize = mem_req.size,
407 .memoryTypeIndex =
get_memory_type(mem_req.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
410 #ifdef VKPT_DEVICE_GROUPS
411 VkMemoryAllocateFlagsInfoKHR mem_alloc_flags = {
412 .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHR,
413 .flags = VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHR,
418 mem_alloc_info.pNext = &mem_alloc_flags;
422 return vkAllocateMemory(
qvk.
device, &mem_alloc_info, NULL, pMemory);
Referenced by allocate_and_bind_memory_to_blas(), initializeEnvTexture(), load_blue_noise(), vkpt_create_images(), vkpt_pt_create_accel_bottom(), vkpt_pt_create_toplevel(), vkpt_shadow_map_initialize(), and vkpt_textures_upload_envmap().
◆ begin_perf_marker()
static void begin_perf_marker |
( |
VkCommandBuffer |
command_buffer, |
|
|
int |
index, |
|
|
const char * |
name |
|
) |
| |
|
inlinestatic |
Definition at line 721 of file vkpt.h.
725 const VkDebugUtilsLabelEXT label = {
726 .sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT,
730 if (qvkCmdBeginDebugUtilsLabelEXT != NULL)
731 qvkCmdBeginDebugUtilsLabelEXT(command_buffer, &label);
◆ bsp_mesh_create_from_bsp()
void bsp_mesh_create_from_bsp |
( |
bsp_mesh_t * |
wm, |
|
|
bsp_t * |
bsp, |
|
|
const char * |
map_name |
|
) |
| |
Definition at line 1623 of file bsp_mesh.c.
1625 const char* full_game_map_name = map_name;
1626 if (strcmp(map_name,
"demo1") == 0)
1627 full_game_map_name =
"base1";
1628 else if (strcmp(map_name,
"demo2") == 0)
1629 full_game_map_name =
"base2";
1630 else if (strcmp(map_name,
"demo3") == 0)
1631 full_game_map_name =
"base3";
1661 #if DUMP_WORLD_MESH_TO_OBJ
1663 char filename[MAX_QPATH];
1664 Q_snprintf(filename,
sizeof(filename),
"C:\\temp\\%s.obj", map_name);
1665 obj_dump_file = fopen(filename,
"w");
1685 for (
int k = 0; k < bsp->nummodels; k++) {
1692 #if DUMP_WORLD_MESH_TO_OBJ
1693 fclose(obj_dump_file);
1694 obj_dump_file = NULL;
1697 if (!bsp->pvs_patched)
1703 Com_EPrintf(
"Couldn't save patched PVS for %s.\n", bsp->name);
1710 wm->
indices = Z_Malloc(idx_ctr *
sizeof(
int));
1732 vec3_t margin = { 1.f, 1.f, 1.f };
1741 for (
int k = 0; k < bsp->nummodels; k++)
Referenced by R_BeginRegistration_RTX().
◆ bsp_mesh_destroy()
◆ bsp_mesh_register_textures()
void bsp_mesh_register_textures |
( |
bsp_t * |
bsp | ) |
|
Definition at line 1781 of file bsp_mesh.c.
1783 for (
int i = 0; i < bsp->numtexinfo; i++) {
1784 mtexinfo_t *info = bsp->texinfo + i;
1786 if (info->c.flags & SURF_WARP)
1787 flags = IF_TURBULENT;
1791 char buffer[MAX_QPATH];
1792 Q_concat(buffer,
sizeof(buffer),
"textures/", info->name,
".wal", NULL);
1797 Com_EPrintf(
"error finding material '%s'\n", buffer);
1800 image_t* image_normals = NULL;
1801 image_t* image_emissive = NULL;
1803 if (image_diffuse != R_NOTEXTURE)
1806 Q_concat(buffer,
sizeof(buffer),
"textures/", info->name,
"_n.tga", NULL);
1808 image_normals =
IMG_Find(buffer, IT_WALL, flags);
1809 if (image_normals == R_NOTEXTURE) image_normals = NULL;
1811 if (image_normals && !image_normals->processing_complete)
1817 Q_concat(buffer,
sizeof(buffer),
"textures/", info->name,
"_light.tga", NULL);
1819 image_emissive =
IMG_Find(buffer, IT_WALL, flags | IF_SRGB);
1820 if (image_emissive == R_NOTEXTURE) image_emissive = NULL;
1831 info->material = mat;
1835 for (
int i = 0; i < bsp->numtexinfo; i++)
1837 mtexinfo_t *texinfo = bsp->texinfo + i;
1840 if (texinfo->numframes > 1)
1842 assert(texinfo->next);
1843 assert(texinfo->next->material);
Referenced by R_BeginRegistration_RTX().
◆ build_transparency_blas()
void build_transparency_blas |
( |
VkCommandBuffer |
cmd_buf | ) |
|
◆ create_entity_matrix()
void create_entity_matrix |
( |
float |
matrix[16], |
|
|
entity_t * |
e, |
|
|
qboolean |
enable_left_hand |
|
) |
| |
Definition at line 23 of file matrix.c.
27 origin[0] = (1.f-e->backlerp) * e->origin[0] + e->backlerp * e->oldorigin[0];
28 origin[1] = (1.f-e->backlerp) * e->origin[1] + e->backlerp * e->oldorigin[1];
29 origin[2] = (1.f-e->backlerp) * e->origin[2] + e->backlerp * e->oldorigin[2];
31 AnglesToAxis(e->angles, axis);
33 float scale = (e->scale > 0.f) ? e->scale : 1.f;
35 vec3_t scales = { scale, scale, scale };
36 if ((e->flags & RF_LEFTHAND) && enable_left_hand)
41 matrix[0] = axis[0][0] * scales[0];
42 matrix[4] = axis[1][0] * scales[1];
43 matrix[8] = axis[2][0] * scales[2];
46 matrix[1] = axis[0][1] * scales[0];
47 matrix[5] = axis[1][1] * scales[1];
48 matrix[9] = axis[2][1] * scales[2];
51 matrix[2] = axis[0][2] * scales[0];
52 matrix[6] = axis[1][2] * scales[1];
53 matrix[10] = axis[2][2] * scales[2];
Referenced by process_bsp_entity(), and process_regular_entity().
◆ create_orthographic_matrix()
void create_orthographic_matrix |
( |
float |
matrix[16], |
|
|
float |
xmin, |
|
|
float |
xmax, |
|
|
float |
ymin, |
|
|
float |
ymax, |
|
|
float |
znear, |
|
|
float |
zfar |
|
) |
| |
Definition at line 100 of file matrix.c.
107 depth = zfar - znear;
109 matrix[0] = 2 /
width;
112 matrix[12] = -(xmax + xmin) /
width;
117 matrix[13] = -(ymax + ymin) /
height;
121 matrix[10] = 1 / depth;
122 matrix[14] = -znear / depth;
Referenced by vkpt_shadow_map_setup().
◆ create_projection_matrix()
void create_projection_matrix |
( |
float |
matrix[16], |
|
|
float |
znear, |
|
|
float |
zfar, |
|
|
float |
fov_x, |
|
|
float |
fov_y |
|
) |
| |
Definition at line 63 of file matrix.c.
65 float xmin, xmax, ymin, ymax;
68 ymax = znear * tan(fov_y * M_PI / 360.0);
71 xmax = znear * tan(fov_x * M_PI / 360.0);
78 matrix[0] = 2 * znear /
width;
80 matrix[8] = (xmax + xmin) /
width;
84 matrix[5] = -2 * znear /
height;
85 matrix[9] = (ymax + ymin) /
height;
90 matrix[10] = (zfar + znear) / depth;
91 matrix[14] = 2 * zfar * znear / depth;
Referenced by prepare_ubo().
◆ create_view_matrix()
void create_view_matrix |
( |
float |
matrix[16], |
|
|
refdef_t * |
fd |
|
) |
| |
Definition at line 131 of file matrix.c.
134 AnglesToAxis(fd->viewangles, viewaxis);
136 matrix[0] = -viewaxis[1][0];
137 matrix[4] = -viewaxis[1][1];
138 matrix[8] = -viewaxis[1][2];
139 matrix[12] = DotProduct(viewaxis[1], fd->vieworg);
141 matrix[1] = viewaxis[2][0];
142 matrix[5] = viewaxis[2][1];
143 matrix[9] = viewaxis[2][2];
144 matrix[13] = -DotProduct(viewaxis[2], fd->vieworg);
146 matrix[2] = viewaxis[0][0];
147 matrix[6] = viewaxis[0][1];
148 matrix[10] = viewaxis[0][2];
149 matrix[14] = -DotProduct(viewaxis[0], fd->vieworg);
Referenced by prepare_ubo().
◆ destroy_transparency()
void destroy_transparency |
( |
| ) |
|
◆ draw_profiler()
void draw_profiler |
( |
int |
enable_asvgf | ) |
|
Definition at line 134 of file profiler.c.
140 font = R_RegisterFont(
"conchars");
144 #define PROFILER_DO(name, indent) \
145 draw_query(x, y, font, #name + 9, name); y += 10;
153 PROFILER_DO(PROFILER_ASVGF_DO_GRADIENT_SAMPLES, 2);
165 PROFILER_DO(PROFILER_ASVGF_RECONSTRUCT_GRADIENT, 2);
Referenced by R_EndFrame_RTX().
◆ end_perf_marker()
static void end_perf_marker |
( |
VkCommandBuffer |
command_buffer, |
|
|
int |
index |
|
) |
| |
|
inlinestatic |
Definition at line 734 of file vkpt.h.
736 if (qvkCmdEndDebugUtilsLabelEXT != NULL)
737 qvkCmdEndDebugUtilsLabelEXT(command_buffer);
◆ 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 |
( |
| ) |
|
◆ get_triangle_off_center()
qboolean get_triangle_off_center |
( |
const float * |
positions, |
|
|
float * |
center, |
|
|
float * |
anti_center |
|
) |
| |
Definition at line 282 of file bsp_mesh.c.
284 const float* v0 = positions + 0;
285 const float* v1 = positions + 3;
286 const float* v2 = positions + 6;
290 VectorCopy(v0, center);
291 VectorAdd(center, v1, center);
292 VectorAdd(center, v2, center);
293 VectorScale(center, 1.f / 3.f, center);
297 vec3_t e1, e2, normal;
298 VectorSubtract(v1, v0, e1);
299 VectorSubtract(v2, v0, e2);
300 CrossProduct(e1, e2, normal);
306 VectorAdd(center, normal, center);
310 VectorMA(center, -2.f, normal, anti_center);
313 return (length > 0.f);
Referenced by bsp_mesh_load_custom_sky(), collect_ligth_polys(), collect_sky_and_lava_ligth_polys(), collect_surfaces(), and vkpt_build_cylinder_light().
◆ IMG_Load_RTX()
◆ IMG_ReadPixels_RTX()
byte* IMG_ReadPixels_RTX |
( |
int * |
width, |
|
|
int * |
height, |
|
|
int * |
rowbytes |
|
) |
| |
Definition at line 3028 of file main.c.
3033 Com_EPrintf(
"IMG_ReadPixels: unsupported swap chain format (%d)!\n",
qvk.
surf_format.format);
3041 VkImageSubresourceRange subresource_range = {
3042 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
3045 .baseArrayLayer = 0,
3050 .image = swap_chain_image,
3051 .subresourceRange = subresource_range,
3053 .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
3054 .oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
3055 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
3060 .subresourceRange = subresource_range,
3061 .srcAccessMask = VK_ACCESS_HOST_READ_BIT,
3062 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
3063 .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
3064 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
3067 VkImageCopy img_copy_region = {
3068 .srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 },
3069 .dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 },
3073 vkCmdCopyImage(cmd_buf,
3074 swap_chain_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
3076 1, &img_copy_region);
3079 .image = swap_chain_image,
3080 .subresourceRange = subresource_range,
3081 .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
3083 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
3084 .newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
3089 .subresourceRange = subresource_range,
3090 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
3091 .dstAccessMask = VK_ACCESS_HOST_READ_BIT,
3092 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
3093 .newLayout = VK_IMAGE_LAYOUT_GENERAL
3099 VkImageSubresource subresource = {
3100 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
3105 VkSubresourceLayout subresource_layout;
3116 byte* src_row = (
byte*)device_data + subresource_layout.rowPitch * row;
3123 dst_row[0] = src_row[2];
3124 dst_row[1] = src_row[1];
3125 dst_row[2] = src_row[0];
3135 dst_row[0] = src_row[0];
3136 dst_row[1] = src_row[1];
3137 dst_row[2] = src_row[2];
Referenced by R_RegisterFunctionsRTX().
◆ IMG_Unload_RTX()
◆ 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().
◆ inverse()
void inverse |
( |
const float * |
m, |
|
|
float * |
inv |
|
) |
| |
Definition at line 158 of file matrix.c.
160 inv[0] =
m[5] *
m[10] *
m[15] -
161 m[5] *
m[11] *
m[14] -
162 m[9] *
m[6] *
m[15] +
163 m[9] *
m[7] *
m[14] +
164 m[13] *
m[6] *
m[11] -
165 m[13] *
m[7] *
m[10];
167 inv[1] = -
m[1] *
m[10] *
m[15] +
168 m[1] *
m[11] *
m[14] +
169 m[9] *
m[2] *
m[15] -
170 m[9] *
m[3] *
m[14] -
171 m[13] *
m[2] *
m[11] +
172 m[13] *
m[3] *
m[10];
174 inv[2] =
m[1] *
m[6] *
m[15] -
175 m[1] *
m[7] *
m[14] -
176 m[5] *
m[2] *
m[15] +
177 m[5] *
m[3] *
m[14] +
178 m[13] *
m[2] *
m[7] -
181 inv[3] = -
m[1] *
m[6] *
m[11] +
182 m[1] *
m[7] *
m[10] +
183 m[5] *
m[2] *
m[11] -
184 m[5] *
m[3] *
m[10] -
188 inv[4] = -
m[4] *
m[10] *
m[15] +
189 m[4] *
m[11] *
m[14] +
190 m[8] *
m[6] *
m[15] -
191 m[8] *
m[7] *
m[14] -
192 m[12] *
m[6] *
m[11] +
193 m[12] *
m[7] *
m[10];
195 inv[5] =
m[0] *
m[10] *
m[15] -
196 m[0] *
m[11] *
m[14] -
197 m[8] *
m[2] *
m[15] +
198 m[8] *
m[3] *
m[14] +
199 m[12] *
m[2] *
m[11] -
200 m[12] *
m[3] *
m[10];
202 inv[6] = -
m[0] *
m[6] *
m[15] +
203 m[0] *
m[7] *
m[14] +
204 m[4] *
m[2] *
m[15] -
205 m[4] *
m[3] *
m[14] -
206 m[12] *
m[2] *
m[7] +
209 inv[7] =
m[0] *
m[6] *
m[11] -
210 m[0] *
m[7] *
m[10] -
211 m[4] *
m[2] *
m[11] +
212 m[4] *
m[3] *
m[10] +
216 inv[8] =
m[4] *
m[9] *
m[15] -
217 m[4] *
m[11] *
m[13] -
218 m[8] *
m[5] *
m[15] +
219 m[8] *
m[7] *
m[13] +
220 m[12] *
m[5] *
m[11] -
223 inv[9] = -
m[0] *
m[9] *
m[15] +
224 m[0] *
m[11] *
m[13] +
225 m[8] *
m[1] *
m[15] -
226 m[8] *
m[3] *
m[13] -
227 m[12] *
m[1] *
m[11] +
230 inv[10] =
m[0] *
m[5] *
m[15] -
231 m[0] *
m[7] *
m[13] -
232 m[4] *
m[1] *
m[15] +
233 m[4] *
m[3] *
m[13] +
234 m[12] *
m[1] *
m[7] -
237 inv[11] = -
m[0] *
m[5] *
m[11] +
239 m[4] *
m[1] *
m[11] -
244 inv[12] = -
m[4] *
m[9] *
m[14] +
245 m[4] *
m[10] *
m[13] +
246 m[8] *
m[5] *
m[14] -
247 m[8] *
m[6] *
m[13] -
248 m[12] *
m[5] *
m[10] +
251 inv[13] =
m[0] *
m[9] *
m[14] -
252 m[0] *
m[10] *
m[13] -
253 m[8] *
m[1] *
m[14] +
254 m[8] *
m[2] *
m[13] +
255 m[12] *
m[1] *
m[10] -
258 inv[14] = -
m[0] *
m[5] *
m[14] +
259 m[0] *
m[6] *
m[13] +
260 m[4] *
m[1] *
m[14] -
261 m[4] *
m[2] *
m[13] -
262 m[12] *
m[1] *
m[6] +
265 inv[15] =
m[0] *
m[5] *
m[10] -
267 m[4] *
m[1] *
m[10] +
272 float det =
m[0] * inv[0] +
m[1] * inv[4] +
m[2] * inv[8] +
m[3] * inv[12];
276 for(
int i = 0; i < 16; i++)
277 inv[i] = inv[i] * det;
Referenced by prepare_ubo().
◆ load_img()
qerror_t load_img |
( |
const char * |
name, |
|
|
image_t * |
image |
|
) |
| |
Definition at line 927 of file images.c.
933 size_t len = strlen(name);
937 return Q_ERR_NAMETOOSHORT;
939 if (name[len - 4] !=
'.') {
940 return Q_ERR_INVALID_PATH;
943 memcpy(image->name, name, len + 1);
944 image->baselen = len - 4;
947 image->registration_sequence = 1;
950 for (fmt = 0; fmt < IM_MAX; fmt++) {
951 if (!Q_stricmp(image->name + image->baselen + 1,
img_loaders[fmt].ext)) {
961 if (ret == Q_ERR_NOENT) {
968 if (fmt <= IM_WAL && ret > IM_WAL) {
974 if (fmt <= IM_WAL && ret > IM_WAL) {
979 memset(image, 0,
sizeof(*image));
983 #if USE_REF == REF_VKPT
984 image->pix_data = pic;
987 return Q_ERR_SUCCESS;
Referenced by IMG_ReloadAll().
◆ MOD_LoadMD2_RTX()
qerror_t MOD_LoadMD2_RTX |
( |
model_t * |
model, |
|
|
const void * |
rawdata, |
|
|
size_t |
length |
|
) |
| |
Definition at line 186 of file models.c.
189 dmd2frame_t *src_frame;
190 dmd2trivertx_t *src_vert;
191 dmd2triangle_t *src_tri;
192 dmd2stvert_t *src_tc;
201 int numverts, numindices;
202 char skinname[MAX_QPATH];
203 vec_t scale_s, scale_t;
207 if (length <
sizeof(header)) {
208 return Q_ERR_FILE_TOO_SMALL;
212 header = *(dmd2header_t *)rawdata;
213 for (
int i = 0; i <
sizeof(header) / 4; i++) {
214 ((uint32_t *)&header)[i] = LittleLong(((uint32_t *)&header)[i]);
220 if (ret == Q_ERR_TOO_FEW) {
222 model->type = MOD_EMPTY;
223 return Q_ERR_SUCCESS;
230 src_tri = (dmd2triangle_t *)((
byte *)rawdata + header.ofs_tris);
231 for (
int i = 0; i < header.num_tris; i++) {
233 for (
int j = 0; j < 3; j++) {
234 uint16_t idx_xyz = LittleShort(src_tri->index_xyz[j]);
235 uint16_t idx_st = LittleShort(src_tri->index_st[j]);
238 if (idx_xyz >= header.num_xyz || idx_st >= header.num_st) {
243 vertIndices[numindices + j] = idx_xyz;
244 tcIndices[numindices + j] = idx_st;
253 if (numindices < 3) {
254 return Q_ERR_TOO_FEW;
257 qboolean all_normals_same = qtrue;
258 int same_normal = -1;
260 src_frame = (dmd2frame_t *)((
byte *)rawdata + header.ofs_frames);
261 for (
int i = 0; i < numindices; i++)
263 int v = vertIndices[i];
264 int normal = src_frame->verts[v].lightnormalindex;
269 same_normal = normal;
270 else if (normal != same_normal)
271 all_normals_same = qfalse;
274 for (
int i = 0; i < numindices; i++) {
280 src_tc = (dmd2stvert_t *)((
byte *)rawdata + header.ofs_st);
281 for (
int i = 0; i < numindices; i++) {
282 if (remap[i] != 0xFFFF) {
287 if (!all_normals_same)
289 for (
int j = i + 1; j < numindices; j++) {
290 if (vertIndices[i] == vertIndices[j] &&
291 (src_tc[tcIndices[i]].s == src_tc[tcIndices[j]].s &&
292 src_tc[tcIndices[i]].t == src_tc[tcIndices[j]].t)) {
295 finalIndices[j] = numverts;
302 finalIndices[i] = numverts++;
306 model->type = MOD_ALIAS;
307 model->nummeshes = 1;
308 model->numframes = header.num_frames;
310 model->frames = MOD_Malloc(header.num_frames *
sizeof(
maliasframe_t));
312 dst_mesh = model->meshes;
313 dst_mesh->
numtris = numindices / 3;
316 dst_mesh->
numskins = header.num_skins;
317 dst_mesh->
positions = MOD_Malloc(numverts * header.num_frames *
sizeof(vec3_t));
318 dst_mesh->
normals = MOD_Malloc(numverts * header.num_frames *
sizeof(vec3_t));
319 dst_mesh->
tex_coords = MOD_Malloc(numverts * header.num_frames *
sizeof(vec2_t));
320 dst_mesh->
tangents = MOD_Malloc(numverts * header.num_frames *
sizeof(vec4_t));
321 dst_mesh->
indices = MOD_Malloc(numindices *
sizeof(
int));
323 if (dst_mesh->
numtris != header.num_tris) {
324 Com_DPrintf(
"%s has %d bad triangles\n", model->name, header.num_tris - dst_mesh->
numtris);
328 for (
int i = 0; i < numindices; i++) {
329 dst_mesh->
indices[i] = finalIndices[i];
333 src_skin = (
char *)rawdata + header.ofs_skins;
334 for (
int i = 0; i < header.num_skins; i++) {
335 if (!
Q_memccpy(skinname, src_skin, 0,
sizeof(skinname))) {
336 ret = Q_ERR_STRING_TRUNCATED;
343 Com_EPrintf(
"error finding material '%s'\n", skinname);
347 image_t* image_emissive = NULL;
349 if (image_diffuse != R_NOTEXTURE)
352 if (!
Q_strlcpy(skinname, src_skin, strlen(src_skin) - 3))
353 return Q_ERR_STRING_TRUNCATED;
355 Q_concat(skinname,
sizeof(skinname), skinname,
"_n.tga", NULL);
357 image_normals =
IMG_Find(skinname, IT_SKIN, IF_NONE);
358 if (image_normals == R_NOTEXTURE) image_normals = NULL;
361 if (!
Q_strlcpy(skinname, src_skin, strlen(src_skin) - 3))
362 return Q_ERR_STRING_TRUNCATED;
364 Q_concat(skinname,
sizeof(skinname), skinname,
"_light.tga", NULL);
366 image_emissive =
IMG_Find(skinname, IT_SKIN, IF_SRGB);
367 if (image_emissive == R_NOTEXTURE) image_emissive = NULL;
374 src_skin += MD2_MAX_SKINNAME;
378 src_tc = (dmd2stvert_t *)((
byte *)rawdata + header.ofs_st);
379 scale_s = 1.0f / header.skinwidth;
380 scale_t = 1.0f / header.skinheight;
383 src_frame = (dmd2frame_t *)((
byte *)rawdata + header.ofs_frames);
384 dst_frame = model->frames;
385 for (
int j = 0; j < header.num_frames; j++) {
386 LittleVector(src_frame->scale, dst_frame->
scale);
387 LittleVector(src_frame->translate, dst_frame->
translate);
392 for (
int i = 0; i < numindices; i++) {
396 src_vert = &src_frame->verts[vertIndices[i]];
397 vec3_t *dst_pos = &dst_mesh->
positions [j * numverts + finalIndices[i]];
398 vec3_t *dst_nrm = &dst_mesh->
normals [j * numverts + finalIndices[i]];
399 vec2_t *dst_tc = &dst_mesh->
tex_coords[j * numverts + finalIndices[i]];
401 (*dst_tc)[0] = scale_s * src_tc[tcIndices[i]].s;
402 (*dst_tc)[1] = scale_t * src_tc[tcIndices[i]].t;
404 (*dst_pos)[0] = src_vert->v[0] * dst_frame->
scale[0] + dst_frame->
translate[0];
405 (*dst_pos)[1] = src_vert->v[1] * dst_frame->
scale[1] + dst_frame->
translate[1];
406 (*dst_pos)[2] = src_vert->v[2] * dst_frame->
scale[2] + dst_frame->
translate[2];
408 (*dst_nrm)[0] = 0.0f;
409 (*dst_nrm)[1] = 0.0f;
410 (*dst_nrm)[2] = 0.0f;
412 val = src_vert->lightnormalindex;
414 if (val < NUMVERTEXNORMALS) {
420 for (
int k = 0; k < 3; k++) {
430 if (all_normals_same)
432 for (
int tri = 0; tri < numindices / 3; tri++)
434 int i0 = j * numverts + finalIndices[tri * 3 + 0];
435 int i1 = j * numverts + finalIndices[tri * 3 + 1];
436 int i2 = j * numverts + finalIndices[tri * 3 + 2];
443 VectorSubtract(*p1, *p0, e1);
444 VectorSubtract(*p2, *p0, e2);
445 CrossProduct(e2, e1, n);
448 VectorCopy(n, dst_mesh->
normals[i0]);
449 VectorCopy(n, dst_mesh->
normals[i1]);
450 VectorCopy(n, dst_mesh->
normals[i2]);
454 VectorVectorScale(mins, dst_frame->
scale, mins);
455 VectorVectorScale(maxs, dst_frame->
scale, maxs);
462 src_frame = (dmd2frame_t *)((
byte *)src_frame + header.framesize);
467 for (
int i = 0; i < dst_mesh->
numindices; i += 3) {
468 int tmp = dst_mesh->
indices[i + 1];
470 dst_mesh->
indices[i + 2] = tmp;
476 return Q_ERR_SUCCESS;
Referenced by R_RegisterFunctionsRTX().
◆ MOD_LoadMD3_RTX()
qerror_t MOD_LoadMD3_RTX |
( |
model_t * |
model, |
|
|
const void * |
rawdata, |
|
|
size_t |
length |
|
) |
| |
◆ MOD_Reference_RTX()
void MOD_Reference_RTX |
( |
model_t * |
model | ) |
|
Definition at line 731 of file models.c.
733 int mesh_idx, skin_idx, frame_idx;
736 switch (model->type) {
738 for (mesh_idx = 0; mesh_idx < model->nummeshes; mesh_idx++) {
740 for (skin_idx = 0; skin_idx < mesh->
numskins; skin_idx++) {
746 for (frame_idx = 0; frame_idx < model->numframes; frame_idx++) {
753 Com_Error(ERR_FATAL,
"%s: bad model type", __func__);
Referenced by R_RegisterFunctionsRTX().
◆ mult_matrix_matrix()
void mult_matrix_matrix |
( |
float * |
p, |
|
|
const float * |
a, |
|
|
const float * |
b |
|
) |
| |
◆ mult_matrix_vector()
void mult_matrix_vector |
( |
float * |
p, |
|
|
const float * |
a, |
|
|
const float * |
b |
|
) |
| |
◆ qvk_get_current_desc_set_textures()
VkDescriptorSet qvk_get_current_desc_set_textures |
( |
| ) |
|
Definition at line 1847 of file main.c.
Referenced by setup_rt_pipeline(), vkpt_asvgf_create_gradient_samples(), vkpt_asvgf_filter(), vkpt_bloom_record_cmd_buffer(), vkpt_compositing(), vkpt_draw_submit_stretch_pics(), vkpt_final_blit_filtered(), vkpt_interleave(), vkpt_physical_sky_record_cmd_buffer(), vkpt_record_god_rays_filter_command_buffer(), vkpt_record_god_rays_trace_command_buffer(), vkpt_taa(), vkpt_textures_update_descriptor_set(), and vkpt_tone_mapping_record_cmd_buffer().
◆ R_ClearColor_RTX()
◆ R_DrawChar_RTX()
◆ R_DrawFill32_RTX()
◆ R_DrawFill8_RTX()
◆ R_DrawPic_RTX()
void R_DrawPic_RTX |
( |
int |
x, |
|
|
int |
y, |
|
|
qhandle_t |
pic |
|
) |
| |
◆ R_DrawStretchPic_RTX()
◆ R_DrawString_RTX()
int R_DrawString_RTX |
( |
int |
x, |
|
|
int |
y, |
|
|
int |
flags, |
|
|
size_t |
maxlen, |
|
|
const char * |
s, |
|
|
qhandle_t |
font |
|
) |
| |
◆ R_InterceptKey_RTX()
qboolean R_InterceptKey_RTX |
( |
unsigned |
key, |
|
|
qboolean |
down |
|
) |
| |
Definition at line 185 of file freecam.c.
187 if (cl_paused->integer != 2 || !
sv_paused->integer)
191 if (kb && strstr(kb,
"pause"))
194 if (
cvar_pt_dof->integer != 0 && down && (key == K_MWHEELUP || key == K_MWHEELDOWN))
213 float factor =
Key_IsDown(K_CTRL) ? 1.01f : 1.1f;
215 if (key == K_MWHEELDOWN)
216 factor = 1.f / factor;
218 float value = var->value;
220 value = max(minvalue, min(maxvalue, value));
Referenced by R_RegisterFunctionsRTX().
◆ R_LightPoint_RTX()
void R_LightPoint_RTX |
( |
vec3_t |
origin, |
|
|
vec3_t |
light |
|
) |
| |
◆ R_SetAlpha_RTX()
void R_SetAlpha_RTX |
( |
float |
alpha | ) |
|
◆ R_SetAlphaScale_RTX()
void R_SetAlphaScale_RTX |
( |
float |
alpha | ) |
|
◆ R_SetClipRect_RTX()
void R_SetClipRect_RTX |
( |
const clipRect_t * |
clip | ) |
|
◆ R_SetColor_RTX()
void R_SetColor_RTX |
( |
uint32_t |
color | ) |
|
◆ R_SetScale_RTX()
void R_SetScale_RTX |
( |
float |
scale | ) |
|
◆ R_TileClear_RTX()
◆ set_current_gpu()
void set_current_gpu |
( |
VkCommandBuffer |
cmd_buf, |
|
|
int |
gpu_index |
|
) |
| |
◆ 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().
◆ vkpt_asvgf_create_gradient_samples()
VkResult vkpt_asvgf_create_gradient_samples |
( |
VkCommandBuffer |
cmd_buf, |
|
|
uint32_t |
frame_num, |
|
|
int |
do_gradient_samples |
|
) |
| |
Definition at line 251 of file asvgf.c.
253 VkDescriptorSet desc_sets[] = {
258 VkClearColorValue clear_grd_smpl_pos = {
259 .uint32 = { 0, 0, 0, 0 }
262 VkImageSubresourceRange subresource_range = {
263 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
270 int current_sample_pos_image = VKPT_IMG_ASVGF_GRAD_SMPL_POS_A + (
qvk.
frame_counter & 1);
273 vkCmdClearColorImage(cmd_buf,
qvk.
images[current_sample_pos_image],
274 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_grd_smpl_pos, 1, &subresource_range);
291 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
293 vkCmdDispatch(cmd_buf,
303 if (do_gradient_samples)
308 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
310 vkCmdDispatch(cmd_buf,
Referenced by R_RenderFrame_RTX().
◆ vkpt_asvgf_create_pipelines()
VkResult vkpt_asvgf_create_pipelines |
( |
| ) |
|
Definition at line 91 of file asvgf.c.
93 VkSpecializationMapEntry specEntries[] = {
94 { .constantID = 0, .offset = 0, .size =
sizeof(uint32_t) }
97 uint32_t spec_data[] = {
104 VkSpecializationInfo specInfo[] = {
105 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[0] },
106 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[1] },
107 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[2] },
108 { .mapEntryCount = 1, .pMapEntries = specEntries, .dataSize =
sizeof(uint32_t), .pData = &spec_data[3] },
113 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
114 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_SEED_RNG_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
118 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
119 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_FWD_PROJECT_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
123 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
124 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_GRADIENT_IMG_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
128 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
129 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_GRADIENT_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
133 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
134 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_TEMPORAL_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
138 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
139 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_LF_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
143 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
144 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[0]),
148 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
149 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[1]),
153 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
154 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[2]),
158 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
159 .stage =
SHADER_STAGE_SPEC(QVK_MOD_ASVGF_ATROUS_COMP, VK_SHADER_STAGE_COMPUTE_BIT, &specInfo[3]),
163 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
164 .stage =
SHADER_STAGE(QVK_MOD_CHECKERBOARD_INTERLEAVE_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
168 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
169 .stage =
SHADER_STAGE(QVK_MOD_ASVGF_TAA_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
173 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
174 .stage =
SHADER_STAGE(QVK_MOD_COMPOSITING_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
◆ vkpt_asvgf_destroy()
VkResult vkpt_asvgf_destroy |
( |
| ) |
|
◆ vkpt_asvgf_destroy_pipelines()
VkResult vkpt_asvgf_destroy_pipelines |
( |
| ) |
|
◆ vkpt_asvgf_filter()
VkResult vkpt_asvgf_filter |
( |
VkCommandBuffer |
cmd_buf, |
|
|
qboolean |
enable_lf |
|
) |
| |
Definition at line 325 of file asvgf.c.
327 VkDescriptorSet desc_sets[] = {
341 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
343 vkCmdDispatch(cmd_buf,
353 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
357 const int num_atrous_iterations_gradient = 7;
358 for(
int i = 0; i < num_atrous_iterations_gradient; i++) {
368 vkCmdDispatch(cmd_buf,
382 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
384 vkCmdDispatch(cmd_buf,
402 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
406 const int num_atrous_iterations = 4;
407 for(
int i = 0; i < num_atrous_iterations; i++)
420 vkCmdDispatch(cmd_buf,
425 if (i == num_atrous_iterations - 1)
434 vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
pipeline_asvgf[specialization]);
435 vkCmdDispatch(cmd_buf,
Referenced by R_RenderFrame_RTX().
◆ vkpt_asvgf_initialize()
VkResult vkpt_asvgf_initialize |
( |
| ) |
|
Definition at line 45 of file asvgf.c.
47 VkDescriptorSetLayout desc_set_layouts[] = {
52 VkPushConstantRange push_constant_range_atrous = {
53 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
55 .size =
sizeof(uint32_t)
59 .setLayoutCount =
LENGTH(desc_set_layouts),
60 .pSetLayouts = desc_set_layouts,
61 .pushConstantRangeCount = 1,
62 .pPushConstantRanges = &push_constant_range_atrous
67 .setLayoutCount =
LENGTH(desc_set_layouts),
68 .pSetLayouts = desc_set_layouts,
73 .setLayoutCount =
LENGTH(desc_set_layouts),
74 .pSetLayouts = desc_set_layouts,
◆ vkpt_begin_command_buffer()
Definition at line 3301 of file main.c.
3306 VkCommandBuffer* new_buffers = Z_Mallocz(new_count *
MAX_FRAMES_IN_FLIGHT *
sizeof(VkCommandBuffer));
3315 VkCommandBufferAllocateInfo cmd_buf_alloc_info = {
3316 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
3318 .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
3336 Z_Free(group->buffer_begin_addrs);
3337 group->buffer_begin_addrs = new_addrs;
3347 VkCommandBufferBeginInfo begin_info = {
3348 .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
3349 .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
3350 .pInheritanceInfo = NULL,
3352 _VK(vkResetCommandBuffer(cmd_buf, 0));
3353 _VK(vkBeginCommandBuffer(cmd_buf, &begin_info));
3359 #if (defined __GNUC__)
3360 *begin_addr = __builtin_return_address(0);
3361 #elif (defined _MSC_VER)
3362 *begin_addr = _ReturnAddress();
Referenced by change_image_layouts(), create_invalid_texture(), create_swapchain(), fill_index_buffer(), FillVertexAndIndexBuffers(), IMG_ReadPixels_RTX(), load_blue_noise(), R_BeginFrame_RTX(), R_EndFrame_RTX(), R_RenderFrame_RTX(), UploadImage(), vkpt_create_images(), vkpt_pt_create_static(), vkpt_shadow_map_initialize(), vkpt_textures_end_registration(), vkpt_textures_upload_envmap(), and vkpt_vertex_buffer_upload_staging().
◆ vkpt_bloom_create_pipelines()
VkResult vkpt_bloom_create_pipelines |
( |
| ) |
|
Definition at line 176 of file bloom.c.
180 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
181 .stage =
SHADER_STAGE(QVK_MOD_BLOOM_BLUR_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
185 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
186 .stage =
SHADER_STAGE(QVK_MOD_BLOOM_COMPOSITE_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
◆ vkpt_bloom_destroy()
VkResult vkpt_bloom_destroy |
( |
| ) |
|
◆ vkpt_bloom_destroy_pipelines()
VkResult vkpt_bloom_destroy_pipelines |
( |
| ) |
|
◆ vkpt_bloom_initialize()
VkResult vkpt_bloom_initialize |
( |
| ) |
|
Definition at line 127 of file bloom.c.
136 VkDescriptorSetLayout desc_set_layouts[] = {
141 VkPushConstantRange push_constant_range = {
142 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
148 .setLayoutCount =
LENGTH(desc_set_layouts),
149 .pSetLayouts = desc_set_layouts,
150 .pushConstantRangeCount = 1,
151 .pPushConstantRanges = &push_constant_range
156 .setLayoutCount =
LENGTH(desc_set_layouts),
157 .pSetLayouts = desc_set_layouts,
◆ vkpt_bloom_record_cmd_buffer()
VkResult vkpt_bloom_record_cmd_buffer |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 301 of file bloom.c.
309 VkImageSubresourceLayers subresource = {
310 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
316 VkOffset3D offset_UL = {
322 VkOffset3D offset_LR_mip_0 = {
328 VkOffset3D offset_LR_mip_1 = {
334 VkOffset3D offset_LR_mip_2 = {
340 VkImageBlit blit_mip_0_to_1 = {
341 .srcSubresource = subresource,
342 .srcOffsets[0] = offset_UL,
343 .srcOffsets[1] = offset_LR_mip_0,
344 .dstSubresource = subresource,
345 .dstOffsets[0] = offset_UL,
346 .dstOffsets[1] = offset_LR_mip_1,
349 VkImageBlit blit_mip_1_to_2 = {
350 .srcSubresource = subresource,
351 .srcOffsets[0] = offset_UL,
352 .srcOffsets[1] = offset_LR_mip_1,
353 .dstSubresource = subresource,
354 .dstOffsets[0] = offset_UL,
355 .dstOffsets[1] = offset_LR_mip_2,
361 vkCmdBlitImage(cmd_buf,
362 qvk.
images[VKPT_IMG_TAA_OUTPUT], VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
363 qvk.
images[VKPT_IMG_BLOOM_DOWNSCALE_MIP_1], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
364 1, &blit_mip_0_to_1, VK_FILTER_LINEAR);
372 vkCmdBlitImage(cmd_buf,
373 qvk.
images[VKPT_IMG_BLOOM_DOWNSCALE_MIP_1], VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
374 qvk.
images[VKPT_IMG_BLOOM_VBLUR], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
375 1, &blit_mip_1_to_2, VK_FILTER_LINEAR);
381 VkDescriptorSet desc_sets[] = {
391 vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
pipelines[
BLUR]);
392 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
397 vkCmdDispatch(cmd_buf,
407 vkCmdDispatch(cmd_buf,
416 VkImageSubresourceLayers subresource = {
417 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
423 VkOffset3D offset_UL = {
429 VkOffset3D offset_LR_input = {
435 VkImageBlit blit_region = {
436 .srcSubresource = subresource,
437 .srcOffsets[0] = offset_UL,
438 .dstSubresource = subresource,
439 .dstOffsets[0] = offset_UL,
440 .dstOffsets[1] = offset_LR_input,
449 vis_img = VKPT_IMG_BLOOM_DOWNSCALE_MIP_1;
450 blit_region.srcOffsets[1].x =
IMG_WIDTH / 2;
455 vis_img = VKPT_IMG_BLOOM_HBLUR;
456 blit_region.srcOffsets[1].x =
IMG_WIDTH / 4;
461 vis_img = VKPT_IMG_BLOOM_VBLUR;
462 blit_region.srcOffsets[1].x =
IMG_WIDTH / 4;
467 vkCmdBlitImage(cmd_buf,
468 qvk.
images[vis_img], VK_IMAGE_LAYOUT_GENERAL,
469 qvk.
images[VKPT_IMG_TAA_OUTPUT], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
470 1, &blit_region, VK_FILTER_LINEAR);
476 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
478 vkCmdDispatch(cmd_buf,
Referenced by R_RenderFrame_RTX().
◆ vkpt_bloom_reset()
void vkpt_bloom_reset |
( |
| ) |
|
◆ vkpt_bloom_update()
void vkpt_bloom_update |
( |
QVKUniformBuffer_t * |
ubo, |
|
|
float |
frame_time, |
|
|
qboolean |
under_water, |
|
|
qboolean |
menu_mode |
|
) |
| |
Definition at line 88 of file bloom.c.
103 static int menu_start_ms = -1;
107 if (menu_start_ms < 0)
111 float phase = max(0.f, min(1.f, (
float)(current_ms - menu_start_ms) / 150.f));
112 phase = powf(phase, 0.25f);
116 ubo->bloom_intensity = 1.f;
Referenced by R_RenderFrame_RTX().
◆ 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().
◆ vkpt_compositing()
VkResult vkpt_compositing |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 460 of file asvgf.c.
462 VkDescriptorSet desc_sets[] = {
476 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
479 vkCmdDispatch(cmd_buf,
Referenced by R_RenderFrame_RTX().
◆ vkpt_create_images()
VkResult vkpt_create_images |
( |
| ) |
|
Definition at line 1442 of file textures.c.
1445 #define IMG_DO(_name, _binding, _vkformat, _glslformat, _w, _h) \
1446 [VKPT_IMG_##_name] = { \
1447 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, \
1448 .imageType = VK_IMAGE_TYPE_2D, \
1449 .format = VK_FORMAT_##_vkformat, \
1457 .samples = VK_SAMPLE_COUNT_1_BIT, \
1458 .tiling = VK_IMAGE_TILING_OPTIMAL, \
1459 .usage = VK_IMAGE_USAGE_STORAGE_BIT \
1460 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT \
1461 | VK_IMAGE_USAGE_TRANSFER_DST_BIT \
1462 | VK_IMAGE_USAGE_SAMPLED_BIT \
1463 | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, \
1464 .sharingMode = VK_SHARING_MODE_EXCLUSIVE, \
1465 .queueFamilyIndexCount = qvk.queue_idx_graphics, \
1466 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED, \
1473 #ifdef VKPT_DEVICE_GROUPS
1474 #define IMG_DO(_name, _binding, _vkformat, _glslformat, _w, _h) \
1475 images_create_info[VKPT_IMG_##_name].flags |= \
1476 VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT;
1482 size_t total_size = 0;
1489 VkMemoryRequirements mem_req;
1492 total_size +=
align(mem_req.size, mem_req.alignment);
1500 #ifdef VKPT_DEVICE_GROUPS
1507 _VK(vkCreateImage(
qvk.
device, images_create_info + i, NULL, &
qvk.images_local[d][i]));
1515 device_indices[j] = (uint32_t)d;
1520 VkMemoryRequirements mem_req;
1521 vkGetImageMemoryRequirements(
qvk.
device,
qvk.images_local[d][i], &mem_req);
1524 VkBindImageMemoryDeviceGroupInfoKHR device_group_info = {
1525 .sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR,
1528 .pDeviceIndices = device_indices,
1529 .splitInstanceBindRegionCount = 0,
1530 .pSplitInstanceBindRegions = NULL,
1533 VkBindImageMemoryInfoKHR bind_info = {
1534 .sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR,
1535 .pNext = &device_group_info,
1536 .image =
qvk.images_local[d][i],
1541 _VK(qvkBindImageMemory2KHR(
qvk.
device, 1, &bind_info));
1547 Com_Printf(
"Screen-space image memory: %.2f MB\n", (
float)total_size / 1048576.f);
1550 #define IMG_DO(_name, _binding, ...) \
1551 ATTACH_LABEL_VARIABLE_NAME(qvk.images[VKPT_IMG_##_name], IMAGE, #_name);
1556 #define IMG_DO(_name, _binding, ...) \
1557 ATTACH_LABEL_VARIABLE_NAME(qvk.images[VKPT_IMG_##_name], IMAGE, #_name);
1563 #define IMG_DO(_name, _binding, _vkformat, _glslformat, _w, _h) \
1564 [VKPT_IMG_##_name] = { \
1565 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, \
1566 .viewType = VK_IMAGE_VIEW_TYPE_2D, \
1567 .format = VK_FORMAT_##_vkformat, \
1568 .image = qvk.images[VKPT_IMG_##_name], \
1569 .subresourceRange = { \
1570 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, \
1571 .baseMipLevel = 0, \
1573 .baseArrayLayer = 0, \
1577 VK_COMPONENT_SWIZZLE_R, \
1578 VK_COMPONENT_SWIZZLE_G, \
1579 VK_COMPONENT_SWIZZLE_B, \
1580 VK_COMPONENT_SWIZZLE_A \
1594 #ifdef VKPT_DEVICE_GROUPS
1597 VkImageViewCreateInfo info = images_view_create_info[i];
1598 info.image =
qvk.images_local[d][i];
1599 _VK(vkCreateImageView(
qvk.
device, &info, NULL, &
qvk.images_views_local[d][i]));
1606 #define IMG_DO(_name, ...) \
1607 ATTACH_LABEL_VARIABLE_NAME(qvk.images_views[VKPT_IMG_##_name], IMAGE_VIEW, #_name);
1612 #define IMG_DO(_name, ...) \
1613 [VKPT_IMG_##_name] = { \
1614 .sampler = VK_NULL_HANDLE, \
1615 .imageView = qvk.images_views[VKPT_IMG_##_name], \
1616 .imageLayout = VK_IMAGE_LAYOUT_GENERAL \
1618 VkDescriptorImageInfo desc_output_img_info[] = {
1624 VkDescriptorImageInfo img_info[] = {
1625 #define IMG_DO(_name, ...) \
1626 [VKPT_IMG_##_name] = { \
1627 .imageLayout = VK_IMAGE_LAYOUT_GENERAL, \
1628 .imageView = qvk.images_views[VKPT_IMG_##_name], \
1629 .sampler = qvk.tex_sampler, \
1637 for(
int i = VKPT_IMG_BLOOM_HBLUR; i <= VKPT_IMG_BLOOM_VBLUR; i++) {
1641 VkWriteDescriptorSet output_img_write[
NUM_IMAGES * 2];
1643 for (
int even_odd = 0; even_odd < 2; even_odd++)
1646 #define IMG_DO(_name, _binding, ...) { \
1647 VkWriteDescriptorSet elem_image = { \
1648 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, \
1649 .dstSet = even_odd ? qvk.desc_set_textures_odd : qvk.desc_set_textures_even, \
1650 .dstBinding = BINDING_OFFSET_IMAGES + _binding, \
1651 .dstArrayElement = 0, \
1652 .descriptorCount = 1, \
1653 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, \
1654 .pImageInfo = desc_output_img_info + VKPT_IMG_##_name, \
1656 VkWriteDescriptorSet elem_texture = { \
1657 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, \
1658 .dstSet = even_odd ? qvk.desc_set_textures_odd : qvk.desc_set_textures_even, \
1659 .dstBinding = BINDING_OFFSET_TEXTURES + _binding, \
1660 .dstArrayElement = 0, \
1661 .descriptorCount = 1, \
1662 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, \
1663 .pImageInfo = img_info + VKPT_IMG_##_name, \
1665 output_img_write[VKPT_IMG_##_name] = elem_image; \
1666 output_img_write[VKPT_IMG_##_name + NUM_VKPT_IMAGES] = elem_texture; \
1679 vkUpdateDescriptorSets(
qvk.
device,
LENGTH(output_img_write), output_img_write, 0, NULL);
1683 #ifdef VKPT_IMAGE_DUMPS
1689 VkImageSubresourceRange subresource_range = {
1690 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1693 .baseArrayLayer = 0,
1700 .subresourceRange = subresource_range,
1702 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
1703 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1704 .newLayout = VK_IMAGE_LAYOUT_GENERAL,
1707 #ifdef VKPT_DEVICE_GROUPS
1714 .image =
qvk.images_local[d][i],
1715 .subresourceRange = subresource_range,
1717 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
1718 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1719 .newLayout = VK_IMAGE_LAYOUT_GENERAL
1731 .subresourceRange = subresource_range,
1733 .dstAccessMask = VK_ACCESS_HOST_READ_BIT,
1734 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1735 .newLayout = VK_IMAGE_LAYOUT_GENERAL,
1738 #ifdef VKPT_IMAGE_DUMPS
1740 .image =
qvk.dump_image,
1741 .subresourceRange = subresource_range,
1743 .dstAccessMask = VK_ACCESS_HOST_READ_BIT,
1744 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1745 .newLayout = VK_IMAGE_LAYOUT_GENERAL,
◆ vkpt_destroy_god_rays()
VkResult vkpt_destroy_god_rays |
( |
| ) |
|
◆ vkpt_destroy_images()
VkResult vkpt_destroy_images |
( |
| ) |
|
Definition at line 1757 of file textures.c.
1766 #ifdef VKPT_DEVICE_GROUPS
1770 vkDestroyImageView(
qvk.
device,
qvk.images_views_local[d][i], NULL);
1771 vkDestroyImage(
qvk.
device,
qvk.images_local[d][i], NULL);
1772 qvk.images_views_local[d][i] = VK_NULL_HANDLE;
1773 qvk.images_local[d][i] = VK_NULL_HANDLE;
1786 #ifdef VKPT_IMAGE_DUMPS
◆ vkpt_destroy_shader_modules()
VkResult vkpt_destroy_shader_modules |
( |
| ) |
|
Definition at line 1180 of file main.c.
1182 #define SHADER_MODULE_DO(a) \
1183 vkDestroyShaderModule(qvk.device, qvk.shader_modules[a], NULL); \
1184 qvk.shader_modules[a] = VK_NULL_HANDLE;
1188 #undef SHADER_MODULE_DO
Referenced by R_Shutdown_RTX(), and vkpt_reload_shader().
◆ vkpt_draw_clear_stretch_pics()
VkResult vkpt_draw_clear_stretch_pics |
( |
| ) |
|
◆ vkpt_draw_create_pipelines()
VkResult vkpt_draw_create_pipelines |
( |
| ) |
|
Definition at line 323 of file draw.c.
328 VkDescriptorSetLayout desc_set_layouts[] = {
332 .setLayoutCount =
LENGTH(desc_set_layouts),
333 .pSetLayouts = desc_set_layouts
339 .setLayoutCount =
LENGTH(desc_set_layouts),
340 .pSetLayouts = desc_set_layouts
343 VkPipelineShaderStageCreateInfo shader_info[] = {
344 SHADER_STAGE(QVK_MOD_STRETCH_PIC_VERT, VK_SHADER_STAGE_VERTEX_BIT),
345 SHADER_STAGE(QVK_MOD_STRETCH_PIC_FRAG, VK_SHADER_STAGE_FRAGMENT_BIT)
348 VkPipelineVertexInputStateCreateInfo vertex_input_info = {
349 .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
350 .vertexBindingDescriptionCount = 0,
351 .pVertexBindingDescriptions = NULL,
352 .vertexAttributeDescriptionCount = 0,
353 .pVertexAttributeDescriptions = NULL,
356 VkPipelineInputAssemblyStateCreateInfo input_assembly_info = {
357 .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
358 .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
359 .primitiveRestartEnable = VK_FALSE,
362 VkViewport viewport = {
376 VkPipelineViewportStateCreateInfo viewport_state = {
377 .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
379 .pViewports = &viewport,
381 .pScissors = &scissor,
384 VkPipelineRasterizationStateCreateInfo rasterizer_state = {
385 .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
386 .depthClampEnable = VK_FALSE,
387 .rasterizerDiscardEnable = VK_FALSE,
388 .polygonMode = VK_POLYGON_MODE_FILL,
390 .cullMode = VK_CULL_MODE_BACK_BIT,
391 .frontFace = VK_FRONT_FACE_CLOCKWISE,
392 .depthBiasEnable = VK_FALSE,
393 .depthBiasConstantFactor = 0.0f,
394 .depthBiasClamp = 0.0f,
395 .depthBiasSlopeFactor = 0.0f,
398 VkPipelineMultisampleStateCreateInfo multisample_state = {
399 .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
400 .sampleShadingEnable = VK_FALSE,
401 .rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
402 .minSampleShading = 1.0f,
404 .alphaToCoverageEnable = VK_FALSE,
405 .alphaToOneEnable = VK_FALSE,
408 VkPipelineColorBlendAttachmentState color_blend_attachment = {
409 .colorWriteMask = VK_COLOR_COMPONENT_R_BIT
410 | VK_COLOR_COMPONENT_G_BIT
411 | VK_COLOR_COMPONENT_B_BIT
412 | VK_COLOR_COMPONENT_A_BIT,
413 .blendEnable = VK_TRUE,
414 .srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA,
415 .dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
416 .colorBlendOp = VK_BLEND_OP_ADD,
417 .srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE,
418 .dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO,
419 .alphaBlendOp = VK_BLEND_OP_ADD,
422 VkPipelineColorBlendStateCreateInfo color_blend_state = {
423 .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
424 .logicOpEnable = VK_FALSE,
425 .logicOp = VK_LOGIC_OP_COPY,
426 .attachmentCount = 1,
427 .pAttachments = &color_blend_attachment,
428 .blendConstants = { 0.0f, 0.0f, 0.0f, 0.0f },
431 VkGraphicsPipelineCreateInfo pipeline_info = {
432 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
433 .stageCount =
LENGTH(shader_info),
434 .pStages = shader_info,
436 .pVertexInputState = &vertex_input_info,
437 .pInputAssemblyState = &input_assembly_info,
438 .pViewportState = &viewport_state,
439 .pRasterizationState = &rasterizer_state,
440 .pMultisampleState = &multisample_state,
441 .pDepthStencilState = NULL,
442 .pColorBlendState = &color_blend_state,
443 .pDynamicState = NULL,
449 .basePipelineHandle = VK_NULL_HANDLE,
450 .basePipelineIndex = -1,
457 VkPipelineShaderStageCreateInfo shader_info_final_blit[] = {
458 SHADER_STAGE(QVK_MOD_FINAL_BLIT_VERT, VK_SHADER_STAGE_VERTEX_BIT),
459 SHADER_STAGE(QVK_MOD_FINAL_BLIT_LANCZOS_FRAG, VK_SHADER_STAGE_FRAGMENT_BIT)
462 pipeline_info.pStages = shader_info_final_blit;
470 VkImageView attachments[] = {
474 VkFramebufferCreateInfo fb_create_info = {
475 .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
477 .attachmentCount = 1,
478 .pAttachments = attachments,
◆ vkpt_draw_destroy()
VkResult vkpt_draw_destroy |
( |
| ) |
|
◆ vkpt_draw_destroy_pipelines()
VkResult vkpt_draw_destroy_pipelines |
( |
| ) |
|
◆ vkpt_draw_initialize()
VkResult vkpt_draw_initialize |
( |
| ) |
|
Definition at line 217 of file draw.c.
224 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
225 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT));
228 VkDescriptorSetLayoutBinding layout_bindings[] = {
230 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
231 .descriptorCount = 1,
233 .stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
237 VkDescriptorSetLayoutCreateInfo layout_info = {
238 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
239 .bindingCount =
LENGTH(layout_bindings),
240 .pBindings = layout_bindings,
246 VkDescriptorPoolSize pool_size = {
247 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
251 VkDescriptorPoolCreateInfo pool_info = {
252 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
254 .pPoolSizes = &pool_size,
262 VkDescriptorSetAllocateInfo descriptor_set_alloc_info = {
263 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
265 .descriptorSetCount = 1,
273 VkDescriptorBufferInfo buf_info = {
279 VkWriteDescriptorSet output_buf_write = {
280 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
283 .dstArrayElement = 0,
284 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
285 .descriptorCount = 1,
286 .pBufferInfo = &buf_info,
289 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
◆ vkpt_draw_submit_stretch_pics()
VkResult vkpt_draw_submit_stretch_pics |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 499 of file draw.c.
510 VkRenderPassBeginInfo render_pass_info = {
511 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
514 .renderArea.offset = { 0, 0 },
518 VkDescriptorSet desc_sets[] = {
523 vkCmdBeginRenderPass(cmd_buf, &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
524 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS,
528 vkCmdEndRenderPass(cmd_buf);
Referenced by R_EndFrame_RTX().
◆ vkpt_extract_emissive_texture_info()
void vkpt_extract_emissive_texture_info |
( |
image_t * |
image | ) |
|
Definition at line 532 of file textures.c.
534 int w = image->upload_width;
535 int h = image->upload_height;
537 byte* current_pixel = image->pix_data;
538 vec3_t emissive_color;
539 VectorClear(emissive_color);
546 for (
int y = 0; y < h; y++) {
547 for (
int x = 0; x < w; x++) {
548 if(current_pixel[0] + current_pixel[1] + current_pixel[2] > 0)
559 VectorAdd(emissive_color,
color, emissive_color);
561 min_x = min(min_x, x);
562 min_y = min(min_y, y);
563 max_x = max(max_x, x);
564 max_y = max(max_y, y);
571 if (min_x <= max_x && min_y <= max_y)
573 float normalization = 1.f / (float)((max_x - min_x + 1) * (max_y - min_y + 1));
574 VectorScale(emissive_color, normalization, image->light_color);
578 VectorSet(image->light_color, 0.f, 0.f, 0.f);
581 image->min_light_texcoord[0] = (float)min_x / (
float)w;
582 image->min_light_texcoord[1] = (float)min_y / (
float)h;
583 image->max_light_texcoord[0] = (float)(max_x + 1) / (float)w;
584 image->max_light_texcoord[1] = (float)(max_y + 1) / (float)h;
586 image->entire_texture_emissive = (min_x == 0) && (min_y == 0) && (max_x == w - 1) && (max_y == h - 1);
588 image->processing_complete = qtrue;
Referenced by bsp_mesh_register_textures().
◆ vkpt_final_blit_filtered()
VkResult vkpt_final_blit_filtered |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 604 of file draw.c.
606 VkRenderPassBeginInfo render_pass_info = {
607 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
610 .renderArea.offset = { 0, 0 },
614 VkDescriptorSet desc_sets[] = {
619 vkCmdBeginRenderPass(cmd_buf, &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
620 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS,
623 vkCmdDraw(cmd_buf, 4, 1, 0, 0);
624 vkCmdEndRenderPass(cmd_buf);
Referenced by R_EndFrame_RTX().
◆ vkpt_final_blit_simple()
VkResult vkpt_final_blit_simple |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 535 of file draw.c.
537 VkImageSubresourceRange subresource_range = {
538 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
547 .subresourceRange = subresource_range,
549 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
550 .oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
551 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
554 int output_img = VKPT_IMG_TAA_OUTPUT;
558 .subresourceRange = subresource_range,
559 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
560 .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
561 .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
562 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
565 VkOffset3D blit_size = {
568 VkOffset3D blit_size_unscaled = {
571 VkImageBlit img_blit = {
572 .srcSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 },
573 .dstSubresource = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1 },
574 .srcOffsets = { [1] = blit_size },
575 .dstOffsets = { [1] = blit_size_unscaled },
577 vkCmdBlitImage(cmd_buf,
578 qvk.
images[output_img], VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
580 1, &img_blit, VK_FILTER_NEAREST);
584 .subresourceRange = subresource_range,
585 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
587 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
588 .newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
593 .subresourceRange = subresource_range,
594 .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
595 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
596 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
597 .newLayout = VK_IMAGE_LAYOUT_GENERAL
Referenced by R_EndFrame_RTX().
◆ vkpt_free_command_buffers()
◆ vkpt_freecam_reset()
void vkpt_freecam_reset |
( |
| ) |
|
◆ vkpt_freecam_update()
void vkpt_freecam_update |
( |
float |
frame_time | ) |
|
Definition at line 120 of file freecam.c.
138 vec3_t prev_viewangles;
143 vec3_t velocity = { 0.f };
152 VectorScale(velocity, 5.f, velocity);
154 VectorScale(velocity, 0.1f, velocity);
Referenced by R_RenderFrame_RTX().
◆ vkpt_get_profiler_result()
double vkpt_get_profiler_result |
( |
int |
idx | ) |
|
◆ vkpt_god_rays_create_pipelines()
VkResult vkpt_god_rays_create_pipelines |
( |
| ) |
|
◆ vkpt_god_rays_destroy_pipelines()
VkResult vkpt_god_rays_destroy_pipelines |
( |
| ) |
|
◆ vkpt_god_rays_enabled()
qboolean vkpt_god_rays_enabled |
( |
const sun_light_t * |
sun_light | ) |
|
◆ vkpt_god_rays_noop()
VkResult vkpt_god_rays_noop |
( |
| ) |
|
◆ vkpt_god_rays_prepare_ubo()
void vkpt_god_rays_prepare_ubo |
( |
QVKUniformBuffer_t * |
ubo, |
|
|
const aabb_t * |
world_aabb, |
|
|
const float * |
proj, |
|
|
const float * |
view, |
|
|
const float * |
shadowmap_viewproj, |
|
|
float |
shadowmap_depth_scale |
|
) |
| |
Definition at line 203 of file god_rays.c.
211 VectorAdd(world_aabb->
mins, world_aabb->
maxs, ubo->world_center);
212 VectorScale(ubo->world_center, 0.5f, ubo->world_center);
213 VectorSubtract(world_aabb->
maxs, world_aabb->
mins, ubo->world_size);
214 VectorScale(ubo->world_size, 0.5f, ubo->world_half_size_inv);
215 ubo->world_half_size_inv[0] = 1.f / ubo->world_half_size_inv[0];
216 ubo->world_half_size_inv[1] = 1.f / ubo->world_half_size_inv[1];
217 ubo->world_half_size_inv[2] = 1.f / ubo->world_half_size_inv[2];
218 ubo->shadow_map_depth_scale = shadowmap_depth_scale;
220 ubo->god_rays_intensity = max(0.f,
god_rays.intensity->value);
221 ubo->god_rays_eccentricity =
god_rays.eccentricity->value;
224 memcpy(ubo->shadow_map_VP, shadowmap_viewproj, 16 *
sizeof(
float));
Referenced by R_RenderFrame_RTX().
◆ vkpt_god_rays_update_images()
VkResult vkpt_god_rays_update_images |
( |
| ) |
|
◆ vkpt_image_copy()
void vkpt_image_copy |
( |
VkCommandBuffer |
cmd_buf, |
|
|
int |
src_image_index, |
|
|
int |
dst_image_index, |
|
|
VkOffset2D |
src_offset, |
|
|
VkOffset2D |
dst_offset, |
|
|
VkExtent2D |
size |
|
) |
| |
Definition at line 111 of file mgpu.c.
118 VkImageSubresourceRange subresource_range = {
119 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
126 VkImageSubresourceLayers subresource_layers = {
127 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
133 VkImageCopy copy_region = {
134 .srcSubresource = subresource_layers,
135 .srcOffset.x = src_offset.x,
136 .srcOffset.y = src_offset.y,
138 .dstSubresource = subresource_layers,
139 .dstOffset.x = dst_offset.x,
140 .dstOffset.y = dst_offset.y,
142 .extent.width = size.width,
143 .extent.height = size.height,
147 VkMemoryBarrier mem_barrier = {
148 .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER,
150 .srcAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
151 .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
154 vkCmdPipelineBarrier(cmd_buf,
155 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
161 vkCmdCopyImage(cmd_buf,
162 qvk.
images[src_image_index], VK_IMAGE_LAYOUT_GENERAL,
163 qvk.
images[dst_image_index], VK_IMAGE_LAYOUT_GENERAL,
◆ vkpt_init_light_textures()
void vkpt_init_light_textures |
( |
| ) |
|
◆ vkpt_initialize_god_rays()
VkResult vkpt_initialize_god_rays |
( |
| ) |
|
Definition at line 51 of file god_rays.c.
55 VkPhysicalDeviceProperties properties;
◆ vkpt_interleave()
VkResult vkpt_interleave |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 492 of file asvgf.c.
494 VkDescriptorSet desc_sets[] = {
500 #ifdef VKPT_DEVICE_GROUPS
505 VkOffset2D offset_left = { 0, 0 };
509 vkpt_mgpu_image_copy(cmd_buf,
518 vkpt_mgpu_image_copy(cmd_buf,
519 VKPT_IMG_ASVGF_COLOR,
520 VKPT_IMG_ASVGF_COLOR,
527 vkpt_mgpu_global_barrier(cmd_buf);
536 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
542 vkCmdDispatch(cmd_buf,
Referenced by R_RenderFrame_RTX().
◆ vkpt_light_buffer_reset_counts()
void vkpt_light_buffer_reset_counts |
( |
| ) |
|
◆ vkpt_light_buffer_upload_staging()
VkResult vkpt_light_buffer_upload_staging |
( |
VkCommandBuffer |
cmd_buf | ) |
|
◆ vkpt_light_buffer_upload_to_staging()
VkResult vkpt_light_buffer_upload_to_staging |
( |
qboolean |
render_world, |
|
|
bsp_mesh_t * |
bsp_mesh, |
|
|
bsp_t * |
bsp, |
|
|
int |
num_model_lights, |
|
|
light_poly_t * |
transformed_model_lights, |
|
|
const float * |
sky_radiance |
|
) |
| |
Definition at line 310 of file vertex_buffer.c.
351 light_poly_t* light = transformed_model_lights + nlight;
352 float* vblight = lbo->light_polys + (nlight + model_light_offset) * (
LIGHT_POLY_VEC4S * 4);
358 lbo->light_list_offsets[0] = 0;
359 lbo->light_list_offsets[1] = 0;
372 float style_scale = 1.f;
376 style_scale = max(0, min(1, style_scale));
378 lbo->light_styles[nstyle] = style_scale;
385 for (
int nmat = 0; nmat < nmaterials; nmat++)
388 uint32_t* mat_data = lbo->material_table + nmat * 4;
389 memset(mat_data, 0,
sizeof(uint32_t) * 4);
394 mat_data[1] |= (material->
num_frames & 0x000f) << 28;
395 mat_data[1] |= (material->
next_frame & 0x0fff) << 16;
Referenced by R_RenderFrame_RTX().
◆ vkpt_light_stats_create()
VkResult vkpt_light_stats_create |
( |
bsp_mesh_t * |
bsp_mesh | ) |
|
Definition at line 699 of file vertex_buffer.c.
713 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
714 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
719 VkDescriptorBufferInfo light_stats_buf_info[] = { {
733 VkWriteDescriptorSet output_buf_write = {
734 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
737 .dstArrayElement = 0,
738 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
739 .descriptorCount =
LENGTH(light_stats_buf_info),
740 .pBufferInfo = light_stats_buf_info,
743 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
Referenced by R_BeginRegistration_RTX().
◆ vkpt_light_stats_destroy()
VkResult vkpt_light_stats_destroy |
( |
| ) |
|
◆ vkpt_load_shader_modules()
VkResult vkpt_load_shader_modules |
( |
| ) |
|
Definition at line 1162 of file main.c.
1164 VkResult ret = VK_SUCCESS;
1165 #define SHADER_MODULE_DO(a) do { \
1166 qvk.shader_modules[a] = create_shader_module_from_file(shader_module_file_names[a], #a); \
1167 ret = (ret == VK_SUCCESS && qvk.shader_modules[a]) ? VK_SUCCESS : VK_ERROR_INITIALIZATION_FAILED; \
1168 if(qvk.shader_modules[a]) { \
1169 ATTACH_LABEL_VARIABLE_NAME((uint64_t)qvk.shader_modules[a], SHADER_MODULE, #a); \
1175 #undef SHADER_MODULE_DO
Referenced by R_Init_RTX(), and vkpt_reload_shader().
◆ vkpt_normalize_normal_map()
Definition at line 592 of file textures.c.
594 int w = image->upload_width;
595 int h = image->upload_height;
597 byte* current_pixel = image->pix_data;
599 for (
int y = 0; y < h; y++) {
600 for (
int x = 0; x < w; x++)
628 image->processing_complete = qtrue;
Referenced by bsp_mesh_register_textures(), and IMG_ReloadAll().
◆ vkpt_profiler_destroy()
VkResult vkpt_profiler_destroy |
( |
| ) |
|
◆ vkpt_profiler_initialize()
VkResult vkpt_profiler_initialize |
( |
| ) |
|
Definition at line 30 of file profiler.c.
32 VkQueryPoolCreateInfo query_pool_info = {
33 .sType = VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,
34 .queryType = VK_QUERY_TYPE_TIMESTAMP,
◆ vkpt_profiler_next_frame()
VkResult vkpt_profiler_next_frame |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 66 of file profiler.c.
68 qboolean any_queries_used = qfalse;
74 any_queries_used = qtrue;
87 VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WITH_AVAILABILITY_BIT);
89 if (result != VK_SUCCESS && result != VK_NOT_READY)
91 Com_EPrintf(
"Failed call to vkGetQueryPoolResults, error code = %d\n", result);
92 any_queries_used = qfalse;
Referenced by R_BeginFrame_RTX().
◆ vkpt_profiler_query()
◆ vkpt_pt_create_all_dynamic()
VkResult vkpt_pt_create_all_dynamic |
( |
VkCommandBuffer |
cmd_buf, |
|
|
int |
idx, |
|
|
VkBuffer |
vertex_buffer, |
|
|
const EntityUploadInfo * |
upload_info |
|
) |
| |
◆ vkpt_pt_create_pipelines()
VkResult vkpt_pt_create_pipelines |
( |
| ) |
|
Definition at line 1216 of file path_tracer.c.
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;
◆ vkpt_pt_create_static()
VkResult vkpt_pt_create_static |
( |
VkBuffer |
vertex_buffer, |
|
|
size_t |
buffer_offset, |
|
|
int |
num_vertices, |
|
|
int |
num_vertices_transparent, |
|
|
int |
num_vertices_sky, |
|
|
int |
num_vertices_custom_sky |
|
) |
| |
Definition at line 574 of file path_tracer.c.
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,
Referenced by R_BeginRegistration_RTX().
◆ vkpt_pt_create_toplevel()
VkResult vkpt_pt_create_toplevel |
( |
VkCommandBuffer |
cmd_buf, |
|
|
int |
idx, |
|
|
qboolean |
include_world, |
|
|
qboolean |
weapon_left_handed |
|
) |
| |
Definition at line 852 of file path_tracer.c.
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(
Referenced by R_RenderFrame_RTX().
◆ vkpt_pt_destroy()
VkResult vkpt_pt_destroy |
( |
| ) |
|
◆ vkpt_pt_destroy_pipelines()
VkResult vkpt_pt_destroy_pipelines |
( |
| ) |
|
◆ vkpt_pt_destroy_static()
VkResult vkpt_pt_destroy_static |
( |
| ) |
|
◆ vkpt_pt_init()
VkResult vkpt_pt_init |
( |
| ) |
|
Definition at line 134 of file path_tracer.c.
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,
◆ vkpt_pt_trace_lighting()
VkResult vkpt_pt_trace_lighting |
( |
VkCommandBuffer |
cmd_buf, |
|
|
float |
num_bounce_rays |
|
) |
| |
Definition at line 1105 of file path_tracer.c.
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,
Referenced by R_RenderFrame_RTX().
◆ vkpt_pt_trace_primary_rays()
VkResult vkpt_pt_trace_primary_rays |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 1009 of file path_tracer.c.
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,
Referenced by R_RenderFrame_RTX().
◆ vkpt_pt_trace_reflections()
VkResult vkpt_pt_trace_reflections |
( |
VkCommandBuffer |
cmd_buf, |
|
|
int |
bounce |
|
) |
| |
Definition at line 1063 of file path_tracer.c.
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,
Referenced by R_RenderFrame_RTX().
◆ vkpt_pt_update_descripter_set_bindings()
VkResult vkpt_pt_update_descripter_set_bindings |
( |
int |
idx | ) |
|
Definition at line 251 of file path_tracer.c.
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,
Referenced by R_RenderFrame_RTX().
◆ vkpt_readback()
◆ vkpt_record_god_rays_filter_command_buffer()
void vkpt_record_god_rays_filter_command_buffer |
( |
VkCommandBuffer |
command_buffer | ) |
|
Definition at line 169 of file god_rays.c.
173 const VkImageSubresourceRange subresource_range = {
174 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
179 vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
god_rays.pipelines[1]);
181 VkDescriptorSet desc_sets[] = {
188 vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
god_rays.pipeline_layout, 0,
LENGTH(desc_sets),
192 vkCmdPushConstants(command_buffer,
god_rays.pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0,
sizeof(
int), &pass);
196 uint32_t group_num_y = (
qvk.
extent_render.height + (group_size - 1)) / group_size;
198 vkCmdDispatch(command_buffer, group_num_x, group_num_y, 1);
Referenced by R_RenderFrame_RTX().
◆ vkpt_record_god_rays_trace_command_buffer()
void vkpt_record_god_rays_trace_command_buffer |
( |
VkCommandBuffer |
command_buffer, |
|
|
int |
pass |
|
) |
| |
Definition at line 140 of file god_rays.c.
145 vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
god_rays.pipelines[0]);
147 VkDescriptorSet desc_sets[] = {
154 vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE,
god_rays.pipeline_layout, 0,
LENGTH(desc_sets),
157 vkCmdPushConstants(command_buffer,
god_rays.pipeline_layout, VK_SHADER_STAGE_COMPUTE_BIT, 0,
sizeof(
int), &pass);
161 uint32_t group_num_y = (
qvk.
extent_render.height / 2 + (group_size - 1)) / group_size;
163 vkCmdDispatch(command_buffer, group_num_x, group_num_y, 1);
Referenced by R_RenderFrame_RTX().
◆ vkpt_reset_accumulation()
void vkpt_reset_accumulation |
( |
| ) |
|
◆ vkpt_reset_command_buffers()
◆ vkpt_shadow_map_create_pipelines()
VkResult vkpt_shadow_map_create_pipelines |
( |
| ) |
|
Definition at line 209 of file shadow_map.c.
213 VkPipelineShaderStageCreateInfo shader_info[] = {
214 SHADER_STAGE(QVK_MOD_SHADOW_MAP_VERT, VK_SHADER_STAGE_VERTEX_BIT)
217 VkVertexInputBindingDescription vertex_binding_desc = {
219 .stride =
sizeof(float) * 3,
220 .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
223 VkVertexInputAttributeDescription vertex_attribute_desc = {
226 .format = VK_FORMAT_R32G32B32_SFLOAT,
230 VkPipelineVertexInputStateCreateInfo vertex_input_info = {
231 .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
232 .vertexBindingDescriptionCount = 1,
233 .pVertexBindingDescriptions = &vertex_binding_desc,
234 .vertexAttributeDescriptionCount = 1,
235 .pVertexAttributeDescriptions = &vertex_attribute_desc,
238 VkPipelineInputAssemblyStateCreateInfo input_assembly_info = {
239 .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
240 .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
243 VkViewport viewport = {
257 VkPipelineViewportStateCreateInfo viewport_state = {
258 .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
260 .pViewports = &viewport,
262 .pScissors = &scissor,
265 VkPipelineRasterizationStateCreateInfo rasterizer_state = {
266 .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
267 .polygonMode = VK_POLYGON_MODE_FILL,
269 .cullMode = VK_CULL_MODE_FRONT_BIT,
270 .frontFace = VK_FRONT_FACE_CLOCKWISE,
273 VkPipelineMultisampleStateCreateInfo multisample_state = {
274 .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
275 .sampleShadingEnable = VK_FALSE,
276 .rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
277 .minSampleShading = 1.0f,
279 .alphaToCoverageEnable = VK_FALSE,
280 .alphaToOneEnable = VK_FALSE,
283 VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {
284 .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
285 .depthTestEnable = VK_TRUE,
286 .depthWriteEnable = VK_TRUE,
287 .depthCompareOp = VK_COMPARE_OP_LESS,
290 VkDynamicState dynamic_states[] = {
291 VK_DYNAMIC_STATE_VIEWPORT,
292 VK_DYNAMIC_STATE_SCISSOR
295 VkPipelineDynamicStateCreateInfo dynamic_state_info = {
296 .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
297 .dynamicStateCount =
LENGTH(dynamic_states),
298 .pDynamicStates = dynamic_states
301 VkGraphicsPipelineCreateInfo pipeline_info = {
302 .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
303 .stageCount =
LENGTH(shader_info),
304 .pStages = shader_info,
306 .pVertexInputState = &vertex_input_info,
307 .pInputAssemblyState = &input_assembly_info,
308 .pViewportState = &viewport_state,
309 .pRasterizationState = &rasterizer_state,
310 .pMultisampleState = &multisample_state,
311 .pDepthStencilState = &depth_stencil_state,
312 .pColorBlendState = NULL,
313 .pDynamicState = &dynamic_state_info,
319 .basePipelineHandle = VK_NULL_HANDLE,
320 .basePipelineIndex = -1,
326 VkImageView attachments[] = {
330 VkFramebufferCreateInfo fb_create_info = {
331 .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
333 .attachmentCount = 1,
334 .pAttachments = attachments,
◆ vkpt_shadow_map_destroy()
VkResult vkpt_shadow_map_destroy |
( |
| ) |
|
◆ vkpt_shadow_map_destroy_pipelines()
VkResult vkpt_shadow_map_destroy_pipelines |
( |
| ) |
|
◆ vkpt_shadow_map_get_view()
VkImageView vkpt_shadow_map_get_view |
( |
| ) |
|
◆ vkpt_shadow_map_initialize()
VkResult vkpt_shadow_map_initialize |
( |
| ) |
|
Definition at line 87 of file shadow_map.c.
91 VkPushConstantRange push_constant_range = {
92 .stageFlags = VK_SHADER_STAGE_VERTEX_BIT,
94 .size =
sizeof(float) * 16,
98 .pushConstantRangeCount = 1,
99 .pPushConstantRanges = &push_constant_range,
103 VkImageCreateInfo img_info = {
104 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
110 .imageType = VK_IMAGE_TYPE_2D,
111 .format = VK_FORMAT_D32_SFLOAT,
114 .samples = VK_SAMPLE_COUNT_1_BIT,
115 .tiling = VK_IMAGE_TILING_OPTIMAL,
116 .usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
117 | VK_IMAGE_USAGE_SAMPLED_BIT,
118 .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
120 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
126 VkMemoryRequirements mem_req;
133 VkImageViewCreateInfo img_view_info = {
134 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
135 .viewType = VK_IMAGE_VIEW_TYPE_2D,
136 .format = VK_FORMAT_D32_SFLOAT,
138 .subresourceRange = {
139 .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT,
146 VK_COMPONENT_SWIZZLE_R,
147 VK_COMPONENT_SWIZZLE_G,
148 VK_COMPONENT_SWIZZLE_B,
149 VK_COMPONENT_SWIZZLE_A,
155 img_view_info.subresourceRange.baseArrayLayer = 1;
159 img_view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
160 img_view_info.subresourceRange.baseArrayLayer = 0;
161 img_view_info.subresourceRange.layerCount = 2;
169 .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT,.levelCount = 1,.layerCount = 2 },
170 .srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
171 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
172 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
173 .newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
◆ vkpt_shadow_map_render()
VkResult vkpt_shadow_map_render |
( |
VkCommandBuffer |
cmd_buf, |
|
|
float * |
view_projection_matrix, |
|
|
int |
num_static_verts, |
|
|
int |
num_dynamic_verts, |
|
|
int |
transparent_offset, |
|
|
int |
num_transparent_verts |
|
) |
| |
Definition at line 364 of file shadow_map.c.
368 .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT, .levelCount = 1, .layerCount = 2 },
369 .srcAccessMask = VK_ACCESS_SHADER_READ_BIT,
370 .dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
371 .oldLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
372 .newLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
375 VkClearValue clear_depth = { .depthStencil = { .depth = 1.f } };
377 VkRenderPassBeginInfo render_pass_info = {
378 .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
381 .renderArea.offset = { 0, 0 },
383 .clearValueCount = 1,
384 .pClearValues = &clear_depth
387 vkCmdBeginRenderPass(cmd_buf, &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
388 vkCmdBindPipeline(cmd_buf, VK_PIPELINE_BIND_POINT_GRAPHICS,
pipeline_smap);
390 VkViewport viewport =
398 vkCmdSetViewport(cmd_buf, 0, 1, &viewport);
408 vkCmdSetScissor(cmd_buf, 0, 1, &scissor);
410 vkCmdPushConstants(cmd_buf,
pipeline_layout_smap, VK_SHADER_STAGE_VERTEX_BIT, 0,
sizeof(
float) * 16, view_projection_matrix);
412 VkDeviceSize vertex_offset = offsetof(
struct VertexBuffer, positions_bsp);
415 vkCmdDraw(cmd_buf, num_static_verts, 1, 0, 0);
417 vertex_offset = offsetof(
struct VertexBuffer, positions_instanced);
420 vkCmdDraw(cmd_buf, num_dynamic_verts, 1, 0, 0);
422 vkCmdEndRenderPass(cmd_buf);
426 vkCmdBeginRenderPass(cmd_buf, &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
428 vertex_offset = offsetof(
struct VertexBuffer, positions_bsp);
431 vkCmdDraw(cmd_buf, num_transparent_verts, 1, transparent_offset, 0);
433 vkCmdEndRenderPass(cmd_buf);
438 .subresourceRange = { .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT,.levelCount = 1,.layerCount = 2 },
439 .srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT,
440 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
441 .oldLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
442 .newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
Referenced by R_RenderFrame_RTX().
◆ vkpt_shadow_map_setup()
void vkpt_shadow_map_setup |
( |
const sun_light_t * |
light, |
|
|
const float * |
bbox_min, |
|
|
const float * |
bbox_max, |
|
|
float * |
VP, |
|
|
float * |
depth_scale, |
|
|
qboolean |
random_sampling |
|
) |
| |
Definition at line 460 of file shadow_map.c.
462 vec3_t up_dir = { 0.0f, 0.0f, 1.0f };
464 VectorSet(up_dir, 1.f, 0.f, 0.f);
467 VectorScale(light->
direction, -1.f, look_dir);
470 CrossProduct(up_dir, look_dir, left_dir);
472 CrossProduct(look_dir, left_dir, up_dir);
485 CrossProduct(up_dir, look_dir, left_dir);
487 CrossProduct(look_dir, left_dir, up_dir);
491 float view_matrix[16] = {
492 left_dir[0], up_dir[0], look_dir[0], 0.f,
493 left_dir[1], up_dir[1], look_dir[1], 0.f,
494 left_dir[2], up_dir[2], look_dir[2], 0.f,
498 vec3_t view_aabb_min = { FLT_MAX, FLT_MAX, FLT_MAX };
499 vec3_t view_aabb_max = { -FLT_MAX, -FLT_MAX, -FLT_MAX };
501 for (
int i = 0; i < 8; i++)
504 corner[0] = (i & 1) ? bbox_max[0] : bbox_min[0];
505 corner[1] = (i & 2) ? bbox_max[1] : bbox_min[1];
506 corner[2] = (i & 4) ? bbox_max[2] : bbox_min[2];
509 float view_corner[4];
512 view_aabb_min[0] = min(view_aabb_min[0], view_corner[0]);
513 view_aabb_min[1] = min(view_aabb_min[1], view_corner[1]);
514 view_aabb_min[2] = min(view_aabb_min[2], view_corner[2]);
515 view_aabb_max[0] = max(view_aabb_max[0], view_corner[0]);
516 view_aabb_max[1] = max(view_aabb_max[1], view_corner[1]);
517 view_aabb_max[2] = max(view_aabb_max[2], view_corner[2]);
521 VectorSubtract(view_aabb_max, view_aabb_min, diagonal);
523 float maxXY = max(diagonal[0], diagonal[1]);
525 diff[0] = (maxXY - diagonal[0]) * 0.5f;
526 diff[1] = (maxXY - diagonal[1]) * 0.5f;
528 VectorSubtract(view_aabb_min,
diff, view_aabb_min);
529 VectorAdd(view_aabb_max,
diff, view_aabb_max);
531 float projection_matrix[16];
532 create_orthographic_matrix(projection_matrix, view_aabb_min[0], view_aabb_max[0], view_aabb_min[1], view_aabb_max[1], view_aabb_min[2], view_aabb_max[2]);
535 *depth_scale = view_aabb_max[2] - view_aabb_min[2];
Referenced by R_RenderFrame_RTX().
◆ vkpt_submit_command_buffer()
void vkpt_submit_command_buffer |
( |
VkCommandBuffer |
cmd_buf, |
|
|
VkQueue |
queue, |
|
|
uint32_t |
execute_device_mask, |
|
|
int |
wait_semaphore_count, |
|
|
VkSemaphore * |
wait_semaphores, |
|
|
VkPipelineStageFlags * |
wait_stages, |
|
|
uint32_t * |
wait_device_indices, |
|
|
int |
signal_semaphore_count, |
|
|
VkSemaphore * |
signal_semaphores, |
|
|
uint32_t * |
signal_device_indices, |
|
|
VkFence |
fence |
|
) |
| |
Definition at line 3411 of file main.c.
3424 _VK(vkEndCommandBuffer(cmd_buf));
3426 VkSubmitInfo submit_info = {
3427 .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
3428 .waitSemaphoreCount = wait_semaphore_count,
3429 .pWaitSemaphores = wait_semaphores,
3430 .pWaitDstStageMask = wait_stages,
3431 .signalSemaphoreCount = signal_semaphore_count,
3432 .pSignalSemaphores = signal_semaphores,
3433 .commandBufferCount = 1,
3434 .pCommandBuffers = &cmd_buf,
3437 #ifdef VKPT_DEVICE_GROUPS
3438 VkDeviceGroupSubmitInfoKHR device_group_submit_info = {
3439 .sType = VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO_KHR,
3441 .waitSemaphoreCount = wait_semaphore_count,
3442 .pWaitSemaphoreDeviceIndices = wait_device_indices,
3443 .commandBufferCount = 1,
3444 .pCommandBufferDeviceMasks = &execute_device_mask,
3445 .signalSemaphoreCount = signal_semaphore_count,
3446 .pSignalSemaphoreDeviceIndices = signal_device_indices,
3450 submit_info.pNext = &device_group_submit_info;
3454 _VK(vkQueueSubmit(queue, 1, &submit_info, fence));
3458 for (
int ngroup = 0; ngroup <
LENGTH(groups); ngroup++)
3463 if (group->
buffers[i] == cmd_buf)
3465 group->buffer_begin_addrs[i] = NULL;
Referenced by R_EndFrame_RTX(), R_RenderFrame_RTX(), vkpt_submit_command_buffer_simple(), and vkpt_vertex_buffer_upload_staging().
◆ vkpt_submit_command_buffer_simple()
void vkpt_submit_command_buffer_simple |
( |
VkCommandBuffer |
cmd_buf, |
|
|
VkQueue |
queue, |
|
|
qboolean |
all_gpus |
|
) |
| |
Definition at line 3473 of file main.c.
3478 vkpt_submit_command_buffer(cmd_buf, queue, all_gpus ? (1 <<
qvk.
device_count) - 1 : 1, 0, NULL, NULL, NULL, 0, NULL, NULL, 0);
Referenced by change_image_layouts(), create_invalid_texture(), create_swapchain(), fill_index_buffer(), FillVertexAndIndexBuffers(), IMG_ReadPixels_RTX(), load_blue_noise(), R_BeginFrame_RTX(), R_RenderFrame_RTX(), UploadImage(), vkpt_create_images(), vkpt_pt_create_static(), vkpt_shadow_map_initialize(), vkpt_textures_end_registration(), and vkpt_textures_upload_envmap().
◆ vkpt_taa()
VkResult vkpt_taa |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 555 of file asvgf.c.
557 VkDescriptorSet desc_sets[] = {
566 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
572 dispatch_size.width += 8;
575 dispatch_size.height += 8;
577 vkCmdDispatch(cmd_buf,
578 (dispatch_size.width + 15) / 16,
579 (dispatch_size.height + 15) / 16,
Referenced by R_RenderFrame_RTX().
◆ vkpt_textures_destroy()
VkResult vkpt_textures_destroy |
( |
| ) |
|
◆ vkpt_textures_destroy_unused()
void vkpt_textures_destroy_unused |
( |
| ) |
|
◆ vkpt_textures_end_registration()
VkResult vkpt_textures_end_registration |
( |
| ) |
|
Definition at line 1087 of file textures.c.
1093 VkImageCreateInfo img_info = {
1094 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
1100 .imageType = VK_IMAGE_TYPE_2D,
1101 .format = VK_FORMAT_UNDEFINED,
1104 .samples = VK_SAMPLE_COUNT_1_BIT,
1105 .tiling = VK_IMAGE_TILING_OPTIMAL,
1106 .usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT
1107 | VK_IMAGE_USAGE_TRANSFER_SRC_BIT
1108 | VK_IMAGE_USAGE_SAMPLED_BIT,
1109 .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
1111 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1114 VkImageViewCreateInfo img_view_info = {
1115 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
1116 .viewType = VK_IMAGE_VIEW_TYPE_2D,
1117 .format = VK_FORMAT_UNDEFINED,
1118 .subresourceRange = {
1119 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1122 .baseArrayLayer = 0,
1126 VK_COMPONENT_SWIZZLE_R,
1127 VK_COMPONENT_SWIZZLE_G,
1128 VK_COMPONENT_SWIZZLE_B,
1129 VK_COMPONENT_SWIZZLE_A
1133 #ifdef VKPT_DEVICE_GROUPS
1139 uint32_t new_image_num = 0;
1140 size_t total_size = 0;
1141 for(
int i = 0; i < MAX_RIMAGES; i++) {
1144 if (
tex_images[i] != VK_NULL_HANDLE || !q_img->registration_sequence || q_img->pix_data == NULL)
1147 img_info.extent.width = q_img->upload_width;
1148 img_info.extent.height = q_img->upload_height;
1149 img_info.mipLevels =
get_num_miplevels(q_img->upload_width, q_img->upload_height);
1150 img_info.format = q_img->is_srgb ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM;
1155 VkMemoryRequirements mem_req;
1158 assert(!(mem_req.alignment & (mem_req.alignment - 1)));
1159 total_size += mem_req.alignment - 1;
1160 total_size &= ~(mem_req.alignment - 1);
1161 total_size += mem_req.size;
1164 image_memory->
size = mem_req.size;
1165 image_memory->
alignment = mem_req.alignment;
1171 bind_info->sType = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO;
1173 bind_info->memory = image_memory->
memory;
1179 if (new_image_num == 0)
1184 buffer_create(&buf_img_upload, total_size, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
1185 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
1189 char *staging_buffer =
buffer_map(&buf_img_upload);
1192 for(
int i = 0; i < MAX_RIMAGES; i++) {
1198 int num_mip_levels =
get_num_miplevels(q_img->upload_width, q_img->upload_height);
1200 VkMemoryRequirements mem_req;
1203 assert(!(mem_req.alignment & (mem_req.alignment - 1)));
1204 offset += mem_req.alignment - 1;
1205 offset &= ~(mem_req.alignment - 1);
1207 uint32_t wd = q_img->upload_width;
1208 uint32_t ht = q_img->upload_height;
1210 VkImageSubresourceRange subresource_range = {
1211 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1213 .levelCount = num_mip_levels,
1214 .baseArrayLayer = 0,
1220 .subresourceRange = subresource_range,
1222 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
1223 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
1224 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
1228 memcpy(staging_buffer + offset, q_img->pix_data, wd * ht * 4);
1230 VkBufferImageCopy cpy_info = {
1231 .bufferOffset = offset,
1232 .imageSubresource = {
1233 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1235 .baseArrayLayer = 0,
1238 .imageOffset = { 0, 0, 0 },
1239 .imageExtent = { wd, ht, 1 }
1243 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &cpy_info);
1246 subresource_range.levelCount = 1;
1248 for (
int mip = 1; mip < num_mip_levels; mip++)
1250 subresource_range.baseMipLevel = mip - 1;
1254 .subresourceRange = subresource_range,
1255 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
1256 .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
1257 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1258 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1261 int nwd = (wd > 1) ? (wd >> 1) : wd;
1262 int nht = (ht > 1) ? (ht >> 1) : ht;
1264 VkImageBlit region = {
1266 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1267 .mipLevel = mip - 1,
1268 .baseArrayLayer = 0,
1276 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
1278 .baseArrayLayer = 0,
1288 tex_images[i], VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1289 tex_images[i], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1293 subresource_range.baseMipLevel = mip - 1;
1297 .subresourceRange = subresource_range,
1298 .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
1299 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
1300 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1301 .newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
1308 subresource_range.baseMipLevel = num_mip_levels - 1;
1312 .subresourceRange = subresource_range,
1313 .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
1314 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
1315 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
1316 .newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
1320 img_view_info.subresourceRange.levelCount = num_mip_levels;
1321 img_view_info.format = q_img->is_srgb ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM;
1325 offset += mem_req.size;
1329 staging_buffer = NULL;
1337 const uint32_t unused_index = unused_resources->
buffer_num++;
1338 unused_resources->
buffers[unused_index] = buf_img_upload.
buffer;
Referenced by R_BeginFrame_RTX().
◆ vkpt_textures_initialize()
VkResult vkpt_textures_initialize |
( |
| ) |
|
Definition at line 821 of file textures.c.
830 VkSamplerCreateInfo sampler_info = {
831 .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
832 .magFilter = VK_FILTER_LINEAR,
833 .minFilter = VK_FILTER_LINEAR,
834 .addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT,
835 .addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT,
836 .addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
837 .anisotropyEnable = VK_TRUE,
839 .borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
840 .unnormalizedCoordinates = VK_FALSE,
841 .mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
847 VkSamplerCreateInfo sampler_nearest_info = {
848 .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
849 .magFilter = VK_FILTER_NEAREST,
850 .minFilter = VK_FILTER_NEAREST,
851 .addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT,
852 .addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT,
853 .addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT,
854 .anisotropyEnable = VK_FALSE,
856 .borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
857 .unnormalizedCoordinates = VK_FALSE,
858 .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
863 VkSamplerCreateInfo sampler_linear_clamp_info = {
864 .sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
865 .magFilter = VK_FILTER_LINEAR,
866 .minFilter = VK_FILTER_LINEAR,
867 .addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
868 .addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
869 .addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
870 .anisotropyEnable = VK_FALSE,
872 .borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK,
873 .unnormalizedCoordinates = VK_FALSE,
874 .mipmapMode = VK_SAMPLER_MIPMAP_MODE_LINEAR,
879 VkDescriptorSetLayoutBinding layout_bindings[] = {
881 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
882 .descriptorCount = MAX_RIMAGES,
884 .stageFlags = VK_SHADER_STAGE_ALL,
886 #define IMG_DO(_name, _binding, ...) \
888 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, \
889 .descriptorCount = 1, \
890 .binding = BINDING_OFFSET_IMAGES + _binding, \
891 .stageFlags = VK_SHADER_STAGE_ALL, \
896 #define IMG_DO(_name, _binding, ...) \
898 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, \
899 .descriptorCount = 1, \
900 .binding = BINDING_OFFSET_TEXTURES + _binding, \
901 .stageFlags = VK_SHADER_STAGE_ALL, \
907 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
908 .descriptorCount = 1,
910 .stageFlags = VK_SHADER_STAGE_ALL,
913 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
914 .descriptorCount = 1,
916 .stageFlags = VK_SHADER_STAGE_ALL,
919 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
920 .descriptorCount = 1,
922 .stageFlags = VK_SHADER_STAGE_ALL,
925 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
926 .descriptorCount = 1,
928 .stageFlags = VK_SHADER_STAGE_ALL,
931 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
932 .descriptorCount = 1,
934 .stageFlags = VK_SHADER_STAGE_ALL,
937 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
938 .descriptorCount = 1,
940 .stageFlags = VK_SHADER_STAGE_ALL,
943 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
944 .descriptorCount = 1,
946 .stageFlags = VK_SHADER_STAGE_ALL,
949 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
950 .descriptorCount = 1,
952 .stageFlags = VK_SHADER_STAGE_ALL,
955 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
956 .descriptorCount = 1,
958 .stageFlags = VK_SHADER_STAGE_ALL,
961 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
962 .descriptorCount = 1,
964 .stageFlags = VK_SHADER_STAGE_ALL,
967 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
968 .descriptorCount = 1,
970 .stageFlags = VK_SHADER_STAGE_ALL,
973 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
974 .descriptorCount = 1,
976 .stageFlags = VK_SHADER_STAGE_ALL,
980 VkDescriptorSetLayoutCreateInfo layout_info = {
981 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
982 .bindingCount =
LENGTH(layout_bindings),
983 .pBindings = layout_bindings,
988 VkDescriptorPoolSize pool_size = {
989 .type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
993 VkDescriptorPoolCreateInfo pool_info = {
994 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
996 .pPoolSizes = &pool_size,
1003 VkDescriptorSetAllocateInfo descriptor_set_alloc_info = {
1004 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
1006 .descriptorSetCount = 1,
1017 return VK_ERROR_INITIALIZATION_FAILED;
◆ vkpt_textures_prefetch()
void vkpt_textures_prefetch |
( |
| ) |
|
Definition at line 75 of file textures.c.
78 ssize_t buffer_size = 0;
79 char const * filename =
"prefetch.txt";
80 buffer_size = FS_LoadFile(filename, (
void**)&buffer);
83 Com_EPrintf(
"Can't load '%s'\n", filename);
87 char const * ptr = buffer;
88 char linebuf[MAX_QPATH];
89 while (
sgets(linebuf,
sizeof(linebuf), &ptr))
91 char* line = strtok(linebuf,
" \t\r\n");
97 char other_name[MAX_QPATH];
100 if (!
Q_strlcpy(other_name, line, strlen(line) - 3))
102 Q_concat(other_name,
sizeof(other_name), other_name,
"_n.tga", NULL);
109 if (!
Q_strlcpy(other_name, line, strlen(line) - 3))
111 Q_concat(other_name,
sizeof(other_name), other_name,
"_light.tga", NULL);
113 image_t const * img3 =
IMG_Find(other_name, IT_SKIN, IF_PERMANENT | IF_SRGB);
Referenced by vkpt_initialize_all().
◆ vkpt_textures_update_descriptor_set()
void vkpt_textures_update_descriptor_set |
( |
| ) |
|
Definition at line 1346 of file textures.c.
1353 for(
int i = 0; i < MAX_RIMAGES; i++) {
1357 if (image_view == VK_NULL_HANDLE)
1361 if (!strcmp(q_img->name,
"pics/conchars.pcx") || !strcmp(q_img->name,
"pics/ch1.pcx"))
1363 else if (q_img->type == IT_SPRITE)
1366 VkDescriptorImageInfo img_info = {
1367 .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
1368 .imageView = image_view,
1372 if (i >= VKPT_IMG_BLOOM_HBLUR &&
1373 i <= VKPT_IMG_BLOOM_VBLUR) {
1377 VkWriteDescriptorSet descriptor_set_write = {
1378 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
1381 .dstArrayElement = i,
1382 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1383 .descriptorCount = 1,
1384 .pImageInfo = &img_info,
1387 vkUpdateDescriptorSets(
qvk.
device, 1, &descriptor_set_write, 0, NULL);
Referenced by R_BeginFrame_RTX().
◆ vkpt_textures_upload_envmap()
VkResult vkpt_textures_upload_envmap |
( |
int |
w, |
|
|
int |
h, |
|
|
byte * |
data |
|
) |
| |
Definition at line 150 of file textures.c.
162 const int num_images = 6;
163 size_t img_size = w * h * 4;
166 buffer_create(&buf_img_upload, img_size * num_images, VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
167 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
169 byte *envmap = (
byte *)
buffer_map(&buf_img_upload);
170 memcpy(envmap, data, img_size * num_images);
174 VkImageCreateInfo img_info = {
175 .sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
181 .imageType = VK_IMAGE_TYPE_2D,
182 .format = VK_FORMAT_R8G8B8A8_UNORM,
184 .arrayLayers = num_images,
185 .samples = VK_SAMPLE_COUNT_1_BIT,
186 .tiling = VK_IMAGE_TILING_OPTIMAL,
187 .usage = VK_IMAGE_USAGE_STORAGE_BIT
188 | VK_IMAGE_USAGE_TRANSFER_DST_BIT
189 | VK_IMAGE_USAGE_SAMPLED_BIT,
190 .flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT,
191 .sharingMode = VK_SHARING_MODE_EXCLUSIVE,
193 .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
199 VkMemoryRequirements mem_req;
201 assert(mem_req.size >= buf_img_upload.
size);
207 VkImageViewCreateInfo img_view_info = {
208 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
209 .viewType = VK_IMAGE_VIEW_TYPE_CUBE,
210 .format = VK_FORMAT_R8G8B8A8_UNORM,
212 .subresourceRange = {
213 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
217 .layerCount = num_images,
220 VK_COMPONENT_SWIZZLE_R,
221 VK_COMPONENT_SWIZZLE_G,
222 VK_COMPONENT_SWIZZLE_B,
223 VK_COMPONENT_SWIZZLE_A,
231 for(
int layer = 0; layer < num_images; layer++) {
233 VkImageSubresourceRange subresource_range = {
234 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
237 .baseArrayLayer = layer,
243 .subresourceRange = subresource_range,
245 .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
246 .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
247 .newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
250 VkBufferImageCopy cpy_info = {
251 .bufferOffset = img_size * layer,
252 .imageSubresource = {
253 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
255 .baseArrayLayer = layer,
258 .imageOffset = { 0, 0, 0 },
259 .imageExtent = { w, h, 1 }
262 VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &cpy_info);
267 .subresourceRange = subresource_range,
268 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
269 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
270 .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
271 .newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
278 VkDescriptorImageInfo desc_img_info = {
279 .imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
284 VkWriteDescriptorSet s = {
285 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
288 .dstArrayElement = 0,
289 .descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
290 .descriptorCount = 1,
291 .pImageInfo = &desc_img_info,
294 vkUpdateDescriptorSets(
qvk.
device, 1, &s, 0, NULL);
297 vkUpdateDescriptorSets(
qvk.
device, 1, &s, 0, NULL);
Referenced by R_SetSky_RTX().
◆ vkpt_tone_mapping_create_pipelines()
VkResult vkpt_tone_mapping_create_pipelines |
( |
| ) |
|
Definition at line 146 of file tone_mapping.c.
150 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
151 .stage =
SHADER_STAGE(QVK_MOD_TONE_MAPPING_HISTOGRAM_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
155 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
156 .stage =
SHADER_STAGE(QVK_MOD_TONE_MAPPING_CURVE_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
160 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
161 .stage =
SHADER_STAGE(QVK_MOD_TONE_MAPPING_APPLY_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
◆ vkpt_tone_mapping_destroy()
VkResult vkpt_tone_mapping_destroy |
( |
| ) |
|
◆ vkpt_tone_mapping_destroy_pipelines()
VkResult vkpt_tone_mapping_destroy_pipelines |
( |
| ) |
|
◆ vkpt_tone_mapping_initialize()
VkResult vkpt_tone_mapping_initialize |
( |
| ) |
|
Definition at line 76 of file tone_mapping.c.
78 VkDescriptorSetLayout desc_set_layouts[] = {
84 VkPushConstantRange push_constant_range_curve = {
85 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
87 .size = 16*
sizeof(float)
90 VkPushConstantRange push_constant_range_apply = {
91 .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
93 .size = 3*
sizeof(float)
97 .setLayoutCount =
LENGTH(desc_set_layouts),
98 .pSetLayouts = desc_set_layouts,
99 .pushConstantRangeCount = 0,
100 .pPushConstantRanges = NULL
105 .setLayoutCount =
LENGTH(desc_set_layouts),
106 .pSetLayouts = desc_set_layouts,
107 .pushConstantRangeCount = 1,
108 .pPushConstantRanges = &push_constant_range_curve
113 .setLayoutCount =
LENGTH(desc_set_layouts),
114 .pSetLayouts = desc_set_layouts,
115 .pushConstantRangeCount = 1,
116 .pPushConstantRanges = &push_constant_range_apply
◆ vkpt_tone_mapping_record_cmd_buffer()
VkResult vkpt_tone_mapping_record_cmd_buffer |
( |
VkCommandBuffer |
cmd_buf, |
|
|
float |
frame_time |
|
) |
| |
Definition at line 241 of file tone_mapping.c.
249 VkDescriptorSet desc_sets[] = {
259 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
262 vkCmdDispatch(cmd_buf,
270 .size = VK_WHOLE_SIZE,
271 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
272 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT
279 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
297 float slope_blur_sigma =
Cvar_Get(
"tm_slope_blur_sigma",
"6.0", 0)->value;
298 float push_constants_tm2_curve[16] = {
308 float gaussian_sum = 0.0;
309 for (
int i = 0; i < 14; ++i)
311 float kernel_value = exp(-i * i / (2.0 * slope_blur_sigma * slope_blur_sigma));
312 gaussian_sum += kernel_value * (i == 0 ? 1 : 2);
313 push_constants_tm2_curve[i + 2] = kernel_value;
317 for (
int i = 0; i < 14; ++i) {
318 push_constants_tm2_curve[i + 2] /= gaussian_sum;
322 VK_SHADER_STAGE_COMPUTE_BIT, 0,
sizeof(push_constants_tm2_curve), push_constants_tm2_curve);
324 vkCmdDispatch(cmd_buf, 1, 1, 1);
329 .size = VK_WHOLE_SIZE,
330 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
331 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT
339 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
364 float knee_start =
Cvar_Get(
"tm_knee_start",
"0.9", 0)->value;
366 float knee_white_point =
Cvar_Get(
"tm_white_point",
"10.0", 0)->value;
374 float knee_w = (knee_start*(knee_start - 2.0) + knee_white_point) / (knee_white_point - 1.0);
375 float knee_a = -knee_start * knee_start;
376 float knee_b = knee_w - 2.0*knee_start;
378 float push_constants_tm2_apply[3] = {
385 VK_SHADER_STAGE_COMPUTE_BIT, 0,
sizeof(push_constants_tm2_apply), push_constants_tm2_apply);
387 vkCmdDispatch(cmd_buf,
Referenced by R_RenderFrame_RTX().
◆ vkpt_tone_mapping_request_reset()
void vkpt_tone_mapping_request_reset |
( |
| ) |
|
◆ vkpt_tone_mapping_reset()
VkResult vkpt_tone_mapping_reset |
( |
VkCommandBuffer |
cmd_buf | ) |
|
Definition at line 176 of file tone_mapping.c.
178 VkClearColorValue clear_histogram = {
179 .uint32 = { 0, 0, 0, 0 }
185 .size = VK_WHOLE_SIZE,
191 0, VK_WHOLE_SIZE, 0);
196 .size = VK_WHOLE_SIZE,
198 .dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT
Referenced by vkpt_tone_mapping_record_cmd_buffer().
◆ vkpt_uniform_buffer_create()
VkResult vkpt_uniform_buffer_create |
( |
| ) |
|
Definition at line 30 of file uniform_buffer.c.
32 VkDescriptorSetLayoutBinding ubo_layout_bindings[2] = { 0 };
34 ubo_layout_bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
35 ubo_layout_bindings[0].descriptorCount = 1;
37 ubo_layout_bindings[0].stageFlags = VK_SHADER_STAGE_ALL;
39 ubo_layout_bindings[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
40 ubo_layout_bindings[1].descriptorCount = 1;
42 ubo_layout_bindings[1].stageFlags = VK_SHADER_STAGE_ALL;
44 VkDescriptorSetLayoutCreateInfo layout_info = {
45 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
46 .bindingCount =
LENGTH(ubo_layout_bindings),
47 .pBindings = ubo_layout_bindings,
52 const VkMemoryPropertyFlags host_memory_flags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT |
53 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
55 const VkMemoryPropertyFlags device_memory_flags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
57 VkPhysicalDeviceProperties properties;
59 ubo_alignment = properties.limits.minUniformBufferOffsetAlignment;
68 VkDescriptorPoolSize pool_size = {
69 .type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
73 VkDescriptorPoolCreateInfo pool_info = {
74 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
76 .pPoolSizes = &pool_size,
82 VkDescriptorSetAllocateInfo descriptor_set_alloc_info = {
83 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
85 .descriptorSetCount = 1,
91 VkDescriptorBufferInfo buf_info = {
97 VkDescriptorBufferInfo buf1_info = {
103 VkWriteDescriptorSet writes[2] = { 0 };
105 writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
108 writes[0].dstArrayElement = 0,
109 writes[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
110 writes[0].descriptorCount = 1,
111 writes[0].pBufferInfo = &buf_info,
113 writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
116 writes[1].dstArrayElement = 0,
117 writes[1].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
118 writes[1].descriptorCount = 1,
119 writes[1].pBufferInfo = &buf1_info,
◆ vkpt_uniform_buffer_destroy()
VkResult vkpt_uniform_buffer_destroy |
( |
| ) |
|
◆ vkpt_uniform_buffer_update()
VkResult vkpt_uniform_buffer_update |
( |
VkCommandBuffer |
command_buffer | ) |
|
Definition at line 142 of file uniform_buffer.c.
146 assert(ubo->
memory != VK_NULL_HANDLE);
147 assert(ubo->
buffer != VK_NULL_HANDLE);
160 VkBufferCopy copy = { 0 };
164 VkBufferMemoryBarrier barrier = {
165 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
166 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
167 .dstAccessMask = VK_ACCESS_UNIFORM_READ_BIT | VK_ACCESS_SHADER_READ_BIT,
168 .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
169 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
174 vkCmdPipelineBarrier(command_buffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
175 0, 0, NULL, 1, &barrier, 0, NULL);
Referenced by R_RenderFrame_RTX().
◆ vkpt_vertex_buffer_create()
VkResult vkpt_vertex_buffer_create |
( |
| ) |
|
Definition at line 492 of file vertex_buffer.c.
494 VkDescriptorSetLayoutBinding vbo_layout_bindings[] = {
496 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
497 .descriptorCount = 1,
499 .stageFlags = VK_SHADER_STAGE_ALL,
502 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
503 .descriptorCount = 1,
505 .stageFlags = VK_SHADER_STAGE_ALL,
508 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
509 .descriptorCount = 1,
511 .stageFlags = VK_SHADER_STAGE_ALL,
514 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
515 .descriptorCount = 1,
517 .stageFlags = VK_SHADER_STAGE_ALL,
520 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
521 .descriptorCount = 1,
523 .stageFlags = VK_SHADER_STAGE_ALL,
526 .descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
527 .descriptorCount = 1,
529 .stageFlags = VK_SHADER_STAGE_ALL,
532 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
533 .descriptorCount = 3,
535 .stageFlags = VK_SHADER_STAGE_ALL,
539 VkDescriptorSetLayoutCreateInfo layout_info = {
540 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
541 .bindingCount =
LENGTH(vbo_layout_bindings),
542 .pBindings = vbo_layout_bindings,
549 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
550 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
554 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
555 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
558 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
559 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
564 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
565 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
569 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
570 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
573 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT,
574 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
577 VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
578 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
583 VK_BUFFER_USAGE_TRANSFER_DST_BIT,
584 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
587 VkDescriptorPoolSize pool_size = {
588 .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
589 .descriptorCount =
LENGTH(vbo_layout_bindings),
592 VkDescriptorPoolCreateInfo pool_info = {
593 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
595 .pPoolSizes = &pool_size,
601 VkDescriptorSetAllocateInfo descriptor_set_alloc_info = {
602 .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
604 .descriptorSetCount = 1,
610 VkDescriptorBufferInfo buf_info = {
616 VkWriteDescriptorSet output_buf_write = {
617 .sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
620 .dstArrayElement = 0,
621 .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
622 .descriptorCount = 1,
623 .pBufferInfo = &buf_info,
626 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
628 output_buf_write.dstBinding = 1;
631 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
633 output_buf_write.dstBinding = 2;
636 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
638 output_buf_write.dstBinding = 3;
641 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
643 output_buf_write.dstBinding = 4;
646 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
648 output_buf_write.dstBinding = 5;
649 output_buf_write.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
652 vkUpdateDescriptorSets(
qvk.
device, 1, &output_buf_write, 0, NULL);
◆ vkpt_vertex_buffer_create_instance()
VkResult vkpt_vertex_buffer_create_instance |
( |
VkCommandBuffer |
cmd_buf, |
|
|
uint32_t |
num_instances, |
|
|
qboolean |
update_world_animations |
|
) |
| |
Definition at line 818 of file vertex_buffer.c.
820 VkDescriptorSet desc_sets[] = {
825 vkCmdBindDescriptorSets(cmd_buf, VK_PIPELINE_BIND_POINT_COMPUTE,
828 vkCmdDispatch(cmd_buf, num_instances, 1, 1);
830 if (update_world_animations)
835 vkCmdDispatch(cmd_buf, num_groups, 1, 1);
838 VkBufferMemoryBarrier barrier = {
839 .sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
840 .srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT,
841 .dstAccessMask = VK_ACCESS_SHADER_READ_BIT,
848 vkCmdPipelineBarrier(
850 VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
851 VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Referenced by R_RenderFrame_RTX().
◆ vkpt_vertex_buffer_create_pipelines()
VkResult vkpt_vertex_buffer_create_pipelines |
( |
| ) |
|
Definition at line 759 of file vertex_buffer.c.
768 VkDescriptorSetLayout desc_set_layouts[] = {
773 .setLayoutCount =
LENGTH(desc_set_layouts),
774 .pSetLayouts = desc_set_layouts,
777 VkComputePipelineCreateInfo compute_pipeline_info[] = {
779 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
780 .stage =
SHADER_STAGE(QVK_MOD_INSTANCE_GEOMETRY_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
784 .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
785 .stage =
SHADER_STAGE(QVK_MOD_ANIMATE_MATERIALS_COMP, VK_SHADER_STAGE_COMPUTE_BIT),
◆ vkpt_vertex_buffer_destroy()
VkResult vkpt_vertex_buffer_destroy |
( |
| ) |
|
◆ vkpt_vertex_buffer_destroy_pipelines()
VkResult vkpt_vertex_buffer_destroy_pipelines |
( |
| ) |
|
◆ vkpt_vertex_buffer_upload_bsp_mesh_to_staging()
VkResult vkpt_vertex_buffer_upload_bsp_mesh_to_staging |
( |
bsp_mesh_t * |
bsp_mesh | ) |
|
Definition at line 90 of file vertex_buffer.c.
99 assert(!
"Vertex buffer overflow");
103 memcpy(vbo->positions_bsp, bsp_mesh->
positions, num_vertices *
sizeof(
float) * 3 );
104 memcpy(vbo->tex_coords_bsp, bsp_mesh->
tex_coords,num_vertices *
sizeof(
float) * 2 );
105 memcpy(vbo->tangents_bsp, bsp_mesh->
tangents, num_vertices *
sizeof(
float));
106 memcpy(vbo->materials_bsp, bsp_mesh->
materials, num_vertices *
sizeof(uint32_t) / 3);
107 memcpy(vbo->clusters_bsp, bsp_mesh->
clusters, num_vertices *
sizeof(uint32_t) / 3);
108 memcpy(vbo->texel_density_bsp, bsp_mesh->
texel_density, num_vertices *
sizeof(
float) / 3);
113 assert(!
"Visibility buffer overflow");
117 memcpy(vbo->sky_visibility, bsp_mesh->
sky_visibility, (num_clusters + 7) / 8);
Referenced by R_BeginRegistration_RTX().
◆ vkpt_vertex_buffer_upload_models_to_staging()
VkResult vkpt_vertex_buffer_upload_models_to_staging |
( |
| ) |
|
Definition at line 412 of file vertex_buffer.c.
418 int vertex_offset = 0;
419 for(
int i = 0; i < MAX_MODELS; i++) {
424 for (
int nmesh = 0; nmesh <
r_models[i].nummeshes; nmesh++)
428 m->idx_offset = idx_offset;
429 m->vertex_offset = vertex_offset;
433 int num_verts =
r_models[i].numframes *
m->numverts;
434 assert(num_verts > 0);
436 for (
int j = 0; j < num_verts; j++)
437 Com_Printf(
"%f %f %f\n",
442 for (
int j = 0; j <
m->numtris; j++)
443 Com_Printf(
"%d %d %d\n",
444 m->indices[j * 3 + 0],
445 m->indices[j * 3 + 1],
446 m->indices[j * 3 + 2]);
451 snprintf(buf,
sizeof buf,
"model_%04d.obj", i);
452 FILE *f = fopen(buf,
"wb+");
454 for (
int j = 0; j <
m->numverts; j++) {
455 fprintf(f,
"v %f %f %f\n",
460 for (
int j = 0; j <
m->numindices / 3; j++) {
461 fprintf(f,
"f %d %d %d\n",
462 m->indices[j * 3 + 0] + 1,
463 m->indices[j * 3 + 1] + 1,
464 m->indices[j * 3 + 2] + 1);
469 memcpy(vbo->positions_model + vertex_offset * 3,
m->positions,
sizeof(
float) * 3 * num_verts);
470 memcpy(vbo->normals_model + vertex_offset * 3,
m->normals,
sizeof(
float) * 3 * num_verts);
471 memcpy(vbo->tex_coords_model + vertex_offset * 2,
m->tex_coords,
sizeof(
float) * 2 * num_verts);
472 memcpy(vbo->tangents_model + vertex_offset * 4,
m->tangents,
sizeof(
float) * 4 * num_verts);
473 memcpy(vbo->idx_model + idx_offset,
m->indices,
sizeof(uint32_t) *
m->numindices);
475 vertex_offset += num_verts;
476 idx_offset +=
m->numtris * 3;
Referenced by R_BeginFrame_RTX().
◆ vkpt_vertex_buffer_upload_staging()
VkResult vkpt_vertex_buffer_upload_staging |
( |
| ) |
|
Definition at line 36 of file vertex_buffer.c.
43 VkBufferCopy copyRegion = {
49 .srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
50 .dstAccessMask = VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV,
53 .size = VK_WHOLE_SIZE,
63 vkpt_submit_command_buffer(cmd_buf,
qvk.
queue_graphics, (1 <<
qvk.
device_count) - 1, 0, NULL, NULL, NULL, 0, NULL, NULL,
qvk.
fence_vertex_sync);
Referenced by R_BeginFrame_RTX(), and R_BeginRegistration_RTX().
◆ vkpt_wait_idle()
◆ draw
Definition at line 21 of file draw.c.
Referenced by _GL_StretchPic(), draw_char(), enqueue_stretch_pic(), GL_Setup2D(), R_ClearColor(), R_ClearColor_GL(), R_ClearColor_RTX(), R_DrawFixedData(), R_DrawPic(), R_DrawPic_GL(), R_DrawStretchData(), R_DrawStretchPic(), R_DrawStretchPic_GL(), R_DrawStretchPic_RTX(), R_InitDraw(), R_SetAlpha(), R_SetAlpha_GL(), R_SetAlpha_RTX(), R_SetAlphaScale_RTX(), R_SetClipRect(), R_SetClipRect_GL(), R_SetColor(), R_SetColor_GL(), R_SetColor_RTX(), R_SetScale_GL(), R_SetScale_RTX(), and SCR_DrawLayout().
◆ qvk
Definition at line 377 of file main.c.
Referenced by allocate_and_bind_memory_to_blas(), allocate_and_bind_memory_to_buffers(), allocate_gpu_memory(), append_blas(), buffer_create(), buffer_destroy(), buffer_map(), buffer_unmap(), calculate_scratch_buffer_size(), change_image_layouts(), compute_push_constants(), create_blas(), create_buffer_views(), create_buffers(), create_command_pool_and_fences(), create_descriptor_set(), create_image_views(), create_invalid_texture(), create_pipeline_layout(), create_pipelines(), create_readback_image(), create_render_pass(), create_shader_module_from_file(), create_sub_allocator(), create_swapchain(), CreateShadowMap(), destroy_invalid_texture(), destroy_readback_image(), destroy_swapchain(), destroy_tex_images(), destroy_transparency(), destroy_vulkan(), destroyEnvTexture(), draw_profiler(), fill_index_buffer(), FillVertexAndIndexBuffers(), get_memory_type(), get_render_extent(), get_scratch_buffer_size(), get_screen_image_extent(), IMG_ReadPixels_RTX(), IMG_ReloadAll(), IMG_Unload_RTX(), init_vulkan(), initializeEnvTexture(), load_blue_noise(), prepare_ubo(), qvk_get_current_desc_set_textures(), R_BeginFrame_RTX(), R_BeginRegistration_RTX(), R_EndFrame_RTX(), R_Init_RTX(), R_ModeChanged_RTX(), R_RenderFrame_RTX(), R_Shutdown_RTX(), recreate_swapchain(), ReleaseInfo(), ReleaseShadowmap(), reset_sun_color_buffer(), set_current_gpu(), setup_rt_pipeline(), textures_destroy_unused_set(), update_descriptor_set(), UploadImage(), vkpt_asvgf_create_gradient_samples(), vkpt_asvgf_create_pipelines(), vkpt_asvgf_destroy(), vkpt_asvgf_destroy_pipelines(), vkpt_asvgf_filter(), vkpt_asvgf_initialize(), vkpt_begin_command_buffer(), vkpt_bloom_create_pipelines(), vkpt_bloom_destroy(), vkpt_bloom_destroy_pipelines(), vkpt_bloom_initialize(), vkpt_bloom_record_cmd_buffer(), vkpt_compositing(), vkpt_create_images(), vkpt_destroy_all(), vkpt_destroy_god_rays(), vkpt_destroy_images(), vkpt_draw_create_pipelines(), vkpt_draw_destroy(), vkpt_draw_destroy_pipelines(), vkpt_draw_get_extent(), vkpt_draw_initialize(), vkpt_draw_submit_stretch_pics(), vkpt_evaluate_sun_light(), vkpt_final_blit_filtered(), vkpt_final_blit_simple(), vkpt_free_command_buffers(), vkpt_god_rays_destroy_pipelines(), vkpt_image_copy(), vkpt_initialize_all(), vkpt_initialize_god_rays(), vkpt_interleave(), vkpt_light_buffer_upload_staging(), vkpt_light_buffer_upload_to_staging(), vkpt_light_stats_create(), vkpt_light_stats_destroy(), vkpt_physical_sky_create_pipelines(), vkpt_physical_sky_destroy(), vkpt_physical_sky_destroy_pipelines(), vkpt_physical_sky_initialize(), vkpt_physical_sky_record_cmd_buffer(), vkpt_profiler_destroy(), vkpt_profiler_initialize(), vkpt_profiler_next_frame(), vkpt_profiler_query(), vkpt_pt_create_accel_bottom(), vkpt_pt_create_all_dynamic(), vkpt_pt_create_pipelines(), vkpt_pt_create_static(), vkpt_pt_create_toplevel(), vkpt_pt_destroy(), vkpt_pt_destroy_dynamic(), vkpt_pt_destroy_explosions(), vkpt_pt_destroy_pipelines(), vkpt_pt_destroy_static(), vkpt_pt_destroy_toplevel(), vkpt_pt_destroy_transparent_models(), vkpt_pt_destroy_viewer_models(), vkpt_pt_destroy_viewer_weapon(), vkpt_pt_init(), vkpt_pt_trace_lighting(), vkpt_pt_trace_primary_rays(), vkpt_pt_trace_reflections(), vkpt_pt_update_descripter_set_bindings(), vkpt_readback(), vkpt_record_god_rays_filter_command_buffer(), vkpt_record_god_rays_trace_command_buffer(), vkpt_reset_command_buffers(), vkpt_shadow_map_create_pipelines(), vkpt_shadow_map_destroy(), vkpt_shadow_map_destroy_pipelines(), vkpt_shadow_map_initialize(), vkpt_shadow_map_render(), vkpt_submit_command_buffer(), vkpt_submit_command_buffer_simple(), vkpt_taa(), vkpt_textures_destroy(), vkpt_textures_destroy_unused(), vkpt_textures_end_registration(), vkpt_textures_initialize(), vkpt_textures_update_descriptor_set(), vkpt_textures_upload_envmap(), vkpt_tone_mapping_create_pipelines(), vkpt_tone_mapping_destroy(), vkpt_tone_mapping_destroy_pipelines(), vkpt_tone_mapping_initialize(), vkpt_tone_mapping_record_cmd_buffer(), vkpt_tone_mapping_reset(), vkpt_uniform_buffer_create(), vkpt_uniform_buffer_destroy(), vkpt_uniform_buffer_update(), vkpt_uniform_precomputed_buffer_create(), vkpt_uniform_precomputed_buffer_destroy(), vkpt_uniform_precomputed_buffer_update(), vkpt_vertex_buffer_create(), vkpt_vertex_buffer_create_instance(), vkpt_vertex_buffer_create_pipelines(), vkpt_vertex_buffer_destroy(), vkpt_vertex_buffer_destroy_pipelines(), vkpt_vertex_buffer_upload_bsp_mesh_to_staging(), vkpt_vertex_buffer_upload_models_to_staging(), and vkpt_vertex_buffer_upload_staging().
◆ vkpt_refdef
Definition at line 372 of file main.c.
Referenced by fill_model_instance(), prepare_entities(), prepare_ubo(), process_bsp_entity(), process_regular_entity(), process_render_feedback(), R_BeginFrame_RTX(), R_BeginRegistration_RTX(), R_RenderFrame_RTX(), vkpt_freecam_update(), vkpt_print_material(), vkpt_set_material(), vkpt_show_pvs(), vkpt_uniform_buffer_update(), write_beam_geometry(), write_particle_geometry(), and write_sprite_geometry().
#define MAX_LIGHT_LIST_NODES
VkDescriptorSet desc_set_ubo
vec_t RadiusFromBounds(const vec3_t mins, const vec3_t maxs)
static void update_sprite_blas(VkCommandBuffer command_buffer)
#define BUFFER_BARRIER(cmd_buf,...)
static VkAccelerationStructureNV accel_dynamic[MAX_FRAMES_IN_FLIGHT]
char * Key_GetBindingForKey(int keynum)
static VkDeviceMemory mem_accel_top[MAX_FRAMES_IN_FLIGHT]
static void update_particle_blas(VkCommandBuffer command_buffer)
int MAT_GetNumPBRMaterials()
#define SUN_COLOR_UBO_BINDING_IDX
cvar_t * cvar_bloom_sigma_water
static VkResult vkpt_pt_create_viewer_models(VkCommandBuffer cmd_buf, int idx, VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices, int vertex_offset)
static VkAccelerationStructureNV accel_viewer_models[MAX_FRAMES_IN_FLIGHT]
#define CREATE_PIPELINE_LAYOUT(dev, layout,...)
static VkDeviceMemory mem_images[NUM_VKPT_IMAGES]
static int filter_static_sky(int flags)
#define SUN_COLOR_BUFFER_BINDING_IDX
#define READBACK_BUFFER_BINDING_IDX
static int max_model_lights
#define SBT_RGEN_PRIMARY_RAYS
static float decode_srgb(byte pix)
uint32_t num_swap_chain_images
VkResult vkpt_pt_destroy_explosions(int idx)
VkBuffer buffers[MAX_RBUFFERS]
#define SBT_RGEN_DIRECT_LIGHTING_CAUSTICS
#define MATERIAL_KIND_LAVA
#define MAX_FRAMES_IN_FLIGHT
char sky_visibility[VIS_MAX_BYTES]
#define GLOBAL_TEXTURES_TEX_ARR_BINDING_IDX
VkAccelerationStructureNV get_transparency_beam_blas()
static BufferResource_t buf_shader_binding_table
#define BARRIER_FROM_COPY_DEST(cmd_buf, img)
size_t Q_snprintf(char *dest, size_t size, const char *fmt,...)
static VkPipelineLayout pipeline_layout_atrous
VkBufferView sprite_info_buffer_view
int num_accumulated_frames
VkResult allocate_gpu_memory(VkMemoryRequirements mem_req, VkDeviceMemory *pMemory)
static int viewer_model_primitive_offset
#define SHADER_STAGE_SPEC(_module, _stage, _spec)
static void vkpt_freecam_mousemove()
static VkDeviceMemory mem_blue_noise
BufferResource_t buf_tonemap
void destroy_invalid_texture()
uint32_t viewer_model_vertex_num
static VkPipeline pipeline_asvgf[ASVGF_NUM_PIPELINES]
static VkRenderPass render_pass_stretch_pic
static size_t get_scratch_buffer_size(VkAccelerationStructureNV ac)
static qboolean allocate_and_bind_memory_to_buffers()
void Hunk_Begin(memhunk_t *hunk, size_t maxsize)
model_t * MOD_ForHandle(qhandle_t h)
static VkDescriptorPool rt_descriptor_pool
static qboolean freecam_keystate[6]
static void compute_cluster_aabbs(bsp_mesh_t *wm)
#define PROFILER_DO(a,...)
static const uint32_t FILTER_THREAD_GROUP_SIZE
#define RAY_GEN_BEAM_COLOR_BUFFER_BINDING_IDX
VkResult vkpt_pt_destroy_viewer_models(int idx)
static TextureSystem texture_system
static size_t align(size_t x, size_t alignment)
static VkPipelineLayout pipeline_layout_tone_mapping_histogram
static VkPipelineLayout pipeline_layout_blur
uint32_t dynamic_vertex_num
vkpt_refdef_t vkpt_refdef
static void computeTangents(model_t *model)
static accel_top_match_info_t accel_top_match[MAX_FRAMES_IN_FLIGHT]
VkAccelerationStructureNV get_transparency_sprite_blas()
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags)
light_poly_t * light_polys
void MAT_UpdateRegistration(pbr_material_t *mat)
static cparticle_t particles[MAX_PARTICLES]
cmd_buf_group_t cmd_buffers_transfer
DeviceMemoryAllocator * create_device_memory_allocator(VkDevice device)
static void collect_ligth_polys(bsp_mesh_t *wm, bsp_t *bsp, int model_idx, int *num_lights, int *allocated_lights, light_poly_t **lights)
static VkPipelineLayout rt_pipeline_layout
#define BINDING_OFFSET_SKY_CLOUDS
void cast_u32_to_f32_color(int color_index, const color_t *pcolor, float *color_f32, float hdr_factor)
#define GLOBAL_INSTANCE_BUFFER_BINDING_IDX
static clipRect_t clip_rect
static VkPipelineLayout pipeline_layout_instance_geometry
DMAResult allocate_device_memory(DeviceMemoryAllocator *allocator, DeviceMemory *device_memory)
BufferResource_t buf_vertex
char cluster_debug_mask[VIS_MAX_BYTES]
static void collect_surfaces(int *idx_ctr, bsp_mesh_t *wm, bsp_t *bsp, int model_idx, int(*filter)(int))
struct pbr_material_s * material
cvar_t * cvar_pt_particle_size
#define _VK_EXTENSION_DO(a)
#define BARRIER_COMPUTE(cmd_buf, img)
static VkDescriptorPool desc_pool_textures
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 int get_num_miplevels(int w, int h)
static VkAccelerationStructureNV accel_static
static void compute_sky_visibility(bsp_mesh_t *wm, bsp_t *bsp)
void buffer_unmap(BufferResource_t *buf)
static qboolean bsp_mesh_load_custom_sky(int *idx_ctr, bsp_mesh_t *wm, bsp_t *bsp, const char *map_name)
static DeviceMemory tex_image_memory[MAX_RIMAGES]
uint32_t current_frame_index
static struct bloom_blur_push_constants push_constants_hblur
#define NUM_PROFILER_QUERIES_PER_FRAME
BufferResource_t buf_readback
static void write_particle_geometry(const float *view_matrix, const particle_t *particles, int particle_num)
#define AS_FLAG_VIEWER_MODELS
void get_transparency_counts(int *particle_num, int *beam_num, int *sprite_num)
static VkPipeline pipelines[TM_NUM_PIPELINES]
#define BARRIER_COMPUTE(cmd_buf, img)
static VkResult vkpt_pt_create_accel_bottom(VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices, VkAccelerationStructureNV *accel, accel_bottom_match_info_t *match, VkDeviceMemory *mem_accel, VkCommandBuffer cmd_buf, int fast_build)
static VkResult vkpt_pt_create_transparent_models(VkCommandBuffer cmd_buf, int idx, VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices, int vertex_offset)
VkBufferView get_transparency_sprite_info_buffer_view()
#define BINDING_OFFSET_BLUE_NOISE
uint32_t d_8to24table[256]
#define VERTEX_BUFFER_BINDING_IDX
void R_DrawStretchPic(int x, int y, int w, int h, qhandle_t pic)
VkResult buffer_destroy(BufferResource_t *buf)
static VkAccelerationStructureNV accel_explosions[MAX_FRAMES_IN_FLIGHT]
VkFence fence_vertex_sync
static int filter_all(int flags)
UnusedResources unused_resources[DESTROY_LATENCY]
#define MATERIAL_FLAG_LIGHT
#define BINDING_OFFSET_TERRAIN_ALBEDO
static void load_sky_and_lava_clusters(bsp_mesh_t *wm, const char *map_name)
#define AS_INSTANCE_FLAG_DYNAMIC
static void destroy_readback_image(VkImage *image, VkDeviceMemory *memory, VkDeviceSize *memory_size)
VkResult vkpt_pt_destroy_viewer_weapon(int idx)
qerror_t MOD_ValidateMD2(dmd2header_t *header, size_t length)
static DeviceMemoryAllocator * tex_device_memory_allocator
#define TR_SPRITE_MAX_NUM
int allocated_light_polys
static VkDeviceMemory mem_accel_transparent
static qboolean freecam_active
static VkImageView imv_smap_depth_array
static VkPipeline pipeline_final_blit
VkExtent2D vkpt_draw_get_extent()
static VkAccelerationStructureNV accel_custom_sky
#define PROFILER_DO(name, indent)
qboolean BSP_SavePatchedPVS(bsp_t *bsp)
static VkDescriptorPool desc_pool_vertex_buffer
static void write_beam_geometry(const float *view_matrix, const entity_t *entities, int entity_num)
void create_orthographic_matrix(float matrix[16], float xmin, float xmax, float ymin, float ymax, float znear, float zfar)
cvar_t * cvar_pt_aperture
#define TONE_MAPPING_BUFFER_BINDING_IDX
static VkPipelineLayout pipeline_layout_general
cvar_t * cvar_bloom_intensity
static float bloom_intensity
static void create_buffer_views()
static BufferResource_t buf_instances[MAX_FRAMES_IN_FLIGHT]
static void enqueue_stretch_pic(float x, float y, float w, float h, float s1, float t1, float s2, float t2, uint32_t color, int tex_handle)
cmd_buf_group_t cmd_buffers_graphics
static int compare_beams(const void *_a, const void *_b)
VkShaderModule shader_modules[NUM_QVK_SHADER_MODULES]
static void build_pvs2(bsp_t *bsp)
static void create_render_pass()
static VkFramebuffer framebuffer_smap2
unsigned Sys_Milliseconds(void)
static VkFramebuffer framebuffer_smap
mleaf_t * BSP_PointLeaf(mnode_t *node, vec3_t p)
qerror_t MAT_RegisterPBRMaterial(pbr_material_t *mat, image_t *image_diffuse, image_t *image_normals, image_t *image_emissive)
static float freecam_zoom
static int _try_image_format(imageformat_t fmt, image_t *image, byte **pic)
static VkImageView imv_smap_depth2
VkPhysicalDevice physical_device
#define END_PERF_MARKER(command_buffer, name)
static qboolean profiler_queries_used[NUM_PROFILER_QUERIES_PER_FRAME *2]
static float under_water_animation
#define TR_VERTEX_MAX_NUM
VkBufferView beam_color_buffer_view
VkDescriptorSet desc_set_textures_even
#define LIGHT_BUFFER_BINDING_IDX
static int custom_sky_primitive_offset
#define CL_PLAYER_MODEL_DISABLED
void compute_world_tangents(bsp_mesh_t *wm)
VkDeviceMemory screenshot_image_memory
static int image_loading_dirty_flag
static VkAccelerationStructureNV accel_top[MAX_FRAMES_IN_FLIGHT]
static VkPipelineLayout pipeline_layout_final_blit
void Hunk_Free(memhunk_t *hunk)
cvar_t * cvar_pt_enable_beams
static int explosions_primitive_offset
struct LightBuffer LightBuffer
static VkPipeline pipeline_instance_geometry
#define AS_FLAG_PARTICLES
static VkImage img_envmap
uint32_t get_memory_type(uint32_t mem_req_type_bits, VkMemoryPropertyFlags mem_prop)
static VkResult vkpt_pt_create_viewer_weapon(VkCommandBuffer cmd_buf, int idx, VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices, int vertex_offset)
#define BINDING_OFFSET_SKY_SCATTERING
#define BARRIER_COMPUTE(cmd_buf, img)
void vkpt_normalize_normal_map(image_t *image)
bsp_mesh_t bsp_mesh_world
static int reset_required
static VkImageView tex_invalid_texture_image_view
#define GLOBAL_UBO_BINDING_IDX
static VkPipelineLayout pipeline_layout_stretch_pic
static VkPipeline pipeline_stretch_pic
void Com_Error(error_type_t type, const char *fmt,...)
#define BARRIER_COMPUTE(cmd_buf, img)
static void collect_cluster_lights(bsp_mesh_t *wm, bsp_t *bsp)
VkImageView image_views[MAX_RIMAGES]
int * cluster_light_offsets
static VkPipelineLayout pipeline_layout_taa
static int explosions_present
int32_t queue_idx_graphics
VkPipelineLayout pipeline_layout_smap
VkExtent2D extent_screen_images
VkDescriptorSet desc_set_vertex_buffer
static void draw_char(int x, int y, int flags, int c, qhandle_t font)
uint32_t current_swap_chain_image_index
#define AS_FLAG_CUSTOM_SKY
static StretchPic_t stretch_pic_queue[MAX_STRETCH_PICS]
static VkPipelineLayout pipeline_layout_tone_mapping_curve
#define RAY_GEN_PARTICLE_COLOR_BUFFER_BINDING_IDX
static float mix(float a, float b, float s)
static VkBindImageMemoryInfo tex_bind_image_info[MAX_RIMAGES]
#define SBT_RAHIT_PARTICLE
#define TR_SPRITE_INFO_SIZE
static const uint32_t THREAD_GROUP_SIZE
cvar_t * cvar_pt_beam_width
qboolean get_triangle_off_center(const float *positions, float *center, float *anti_center)
struct ToneMappingBuffer ToneMappingBuffer
struct pbr_material_s * materials[MAX_ALIAS_SKINS]
static int filter_static_opaque(int flags)
BufferResource_t buf_sun_color
char * va(const char *format,...)
#define SBT_RGEN_REFLECT_REFRACT1
static int num_stretch_pics
static void create_render_pass()
int allocated_light_polys
static VkResult vkpt_pt_create_explosions(VkCommandBuffer cmd_buf, int idx, VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices, int vertex_offset)
static uint8_t descriptor_set_dirty_flags[MAX_FRAMES_IN_FLIGHT]
static BufferResource_t buf_stretch_pic_queue[MAX_FRAMES_IN_FLIGHT]
static vec3_t freecam_vieworg
VkImage swap_chain_images[MAX_SWAPCHAIN_IMAGES]
static int try_other_formats(imageformat_t orig, image_t *image, byte **pic)
#define CL_PLAYER_MODEL_FIRST_PERSON
static BufferResource_t buf_accel_scratch
void vkpt_extract_emissive_texture_info(image_t *image)
VkBufferView get_transparency_beam_color_buffer_view()
static VkPipeline pipeline_animate_materials
void ClearBounds(vec3_t mins, vec3_t maxs)
static VkAccelerationStructureNV accel_viewer_weapon[MAX_FRAMES_IN_FLIGHT]
cvar_t * cvar_bloom_intensity_water
VkCommandBuffer * buffers
image_t r_images[MAX_RIMAGES]
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
static int max_cluster_model_lights[MAX_MAP_LEAFS]
static VkDeviceMemory mem_accel_static
void mult_matrix_vector(float *p, const float *a, const float *b)
#define _VK_INST_EXTENSION_DO(a)
void Hunk_End(memhunk_t *hunk)
static byte encode_linear(float x)
static int viewer_weapon_primitive_offset
static int transparent_models_present
static vec3_t freecam_viewangles
VkImage images[NUM_VKPT_IMAGES]
static void setup_rt_pipeline(VkCommandBuffer cmd_buf)
void set_current_gpu(VkCommandBuffer cmd_buf, int gpu_index)
#define MEM_BARRIER_BUILD_ACCEL(cmd_buf,...)
static void update_descriptor_set()
static void create_descriptor_set()
vkpt_refdef_t vkpt_refdef
void Cvar_SetByVar(cvar_t *var, const char *value, from_t from)
size_t Q_strlcpy(char *dst, const char *src, size_t size)
cvar_t * cvar_pt_beam_lights
static int freecam_player_model
#define AS_INSTANCE_FLAG_SKY
void vkpt_reset_command_buffers(cmd_buf_group_t *group)
static VkFramebuffer framebuffer_stretch_pic[MAX_FRAMES_IN_FLIGHT]
static VkImageView imv_blue_noise
void vkpt_wait_idle(VkQueue queue, cmd_buf_group_t *group)
#define BARRIER_TO_COPY_SRC(cmd_buf, img)
VkCommandPool command_pool
cvar_t * physical_sky_space
static void write_sprite_geometry(const float *view_matrix, const entity_t *entities, int entity_num)
#define BEGIN_PERF_MARKER(command_buffer, name)
const pbr_material_t * MAT_GetPBRMaterialsTable()
#define NUM_LIGHT_STATS_BUFFERS
struct VertexBuffer VertexBuffer
qboolean MAT_IsKind(uint32_t material, uint32_t kind)
cvar_t * cvar_bloom_debug
struct QVKUniformBuffer_s QVKUniformBuffer_t
static VkPipeline pipelines[BLOOM_NUM_PIPELINES]
static struct bloom_blur_push_constants push_constants_vblur
#define SBT_RGEN_INDIRECT_LIGHTING_FIRST
static int transparent_model_primitive_offset
#define BINDING_OFFSET_SKY_IRRADIANCE
VkDeviceMemory buffer_memory[MAX_RBUFFERS]
#define BINDING_OFFSET_PHYSICAL_SKY_IMG
static void create_pipelines()
struct QVKInstanceBuffer_s QVKInstanceBuffer_t
#define BINDING_OFFSET_TERRAIN_DEPTH
#define AS_FLAG_VIEWER_WEAPON
void vkpt_pt_destroy_toplevel(int idx)
cvar_t * cvar_pt_reflect_refract
cvar_t * cvar_pt_caustics
static VkDeviceMemory mem_envmap
static int sky_primitive_offset
VkSampler tex_sampler_linear_clamp
static void create_pipeline_layout()
VkDescriptorSet desc_set_textures_odd
cmd_buf_group_t cmd_buffers_compute
image_t * IMG_Find(const char *name, imagetype_t type, imageflags_t flags)
#define LIGHT_STATS_BUFFER_BINDING_IDX
#define BINDING_OFFSET_PHYSICAL_SKY
#define MAX_PBR_MATERIALS
static void fill_index_buffer()
#define SBT_RMISS_PATH_TRACER
static int filter_static_transparent(int flags)
@ CHECKERBOARD_INTERLEAVE
void destroy_device_memory_allocator(DeviceMemoryAllocator *allocator)
VkDeviceSize screenshot_image_memory_size
unsigned int particle_num
static void create_blas()
BufferResource_t buf_light
uint32_t gpu_slice_width_prev
uint32_t world_transparent_count
static const struct @12 img_loaders[IM_MAX]
void inject_model_lights(bsp_mesh_t *bsp_mesh, bsp_t *bsp, int num_model_lights, light_poly_t *transformed_model_lights, int model_light_offset, uint32_t *dst_list_offsets, uint32_t *dst_lists)
static int num_model_lights
static void create_image_views()
static void create_buffers()
#define BINDING_OFFSET_TERRAIN_NORMALS
light_poly_t * light_polys
#define TR_PARTICLE_MAX_NUM
void vkpt_submit_command_buffer_simple(VkCommandBuffer cmd_buf, VkQueue queue, qboolean all_gpus)
struct ReadbackBuffer ReadbackBuffer
#define EMISSIVE_TRANSFORM_BIAS
static void sample_disk(float *u, float *v)
char * sgets(char *str, int num, char const **input)
static VkImageView imv_envmap
cvar_t * cvar_pt_enable_particles
static VkDeviceMemory mem_accel_sky
int registration_sequence
VkResult vkpt_pt_destroy_static()
void compute_aabb(const float *positions, int numvert, float *aabb_min, float *aabb_max)
#define SHADER_STAGE(_module, _stage)
static VkAccelerationStructureNV accel_transparent
static VkPhysicalDeviceRayTracingPropertiesNV rt_properties
DeviceMemory image_memory[MAX_RIMAGES]
uint32_t world_custom_sky_offset
#define SIZE_SCRATCH_BUFFER
#define BARRIER_FROM_CLEAR(cmd_buf, img)
VkBufferView get_transparency_particle_color_buffer_view()
#define BARRIER_FROM_COPY_SRC(cmd_buf, img)
struct SunColorBuffer SunColorBuffer
VkSampler tex_sampler_nearest
static void textures_destroy_unused_set(uint32_t set_index)
static VkDescriptorSet rt_descriptor_set[MAX_FRAMES_IN_FLIGHT]
VkExtent2D extent_unscaled
static VkAccelerationStructureNV accel_transparent_models[MAX_FRAMES_IN_FLIGHT]
void mult_matrix_matrix(float *p, const float *a, const float *b)
BufferResource_t buf_light_staging[MAX_FRAMES_IN_FLIGHT]
static VkAccelerationStructureNV accel_sky
cvar_t * cvar_bloom_sigma
static q_noinline int diff(uint32_t A_u32, uint32_t B_u32)
void vkpt_reset_accumulation()
uint32_t explosions_vertex_offset
uint32_t explosions_vertex_num
uint32_t transparent_model_vertex_num
VkBufferView particle_color_buffer_view
static void update_beam_blas(VkCommandBuffer command_buffer)
QVKInstanceBuffer_t uniform_instance_buffer
static void upload_geometry(VkCommandBuffer command_buffer)
static VkDescriptorSetLayout rt_descriptor_set_layout
static VkImage img_blue_noise
static VkPipeline rt_pipeline
static VkResult vkpt_pt_create_dynamic(VkCommandBuffer cmd_buf, int idx, VkBuffer vertex_buffer, size_t buffer_offset, int num_vertices)
VkResult buffer_create(BufferResource_t *buf, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags mem_properties)
#define LIST_SHADER_MODULES
#define SBT_RGEN_DIRECT_LIGHTING
static VkPipelineLayout pipeline_layout_composite
VkImageView images_views[NUM_VKPT_IMAGES]
static void collect_sky_and_lava_ligth_polys(bsp_mesh_t *wm, bsp_t *bsp)
static void copy_light(const light_poly_t *light, float *vblight, const float *sky_radiance)
void * Q_memccpy(void *dst, const void *src, int c, size_t size)
cvar_t * cvar_pt_enable_sprites
uint32_t world_sky_offset
uint32_t viewer_weapon_vertex_num
#define SBT_RGEN_REFLECT_REFRACT2
VkImage images[MAX_RIMAGES]
static VkDescriptorSetLayout desc_set_layout_sbo
#define IMAGE_BARRIER(cmd_buf,...)
cvar_t * cvar_bloom_enable
image_t * IMG_ForHandle(qhandle_t h)
VkResult vkpt_tone_mapping_reset(VkCommandBuffer cmd_buf)
#define ATTACH_LABEL_VARIABLE(a, type)
static uint64_t query_pool_results[NUM_PROFILER_QUERIES_PER_FRAME+1]
VkCommandBuffer vkpt_begin_command_buffer(cmd_buf_group_t *group)
static VkResult create_readback_image(VkImage *image, VkDeviceMemory *memory, VkDeviceSize *memory_size, VkFormat format, uint32_t width, uint32_t height)
void vkpt_freecam_reset()
BufferResource_t buf_light_stats[NUM_LIGHT_STATS_BUFFERS]
static VkResult load_blue_noise()
VkDescriptorSetLayout desc_set_layout_textures
static uint16_t floatToHalf(float value)
size_t Q_concat(char *dest, size_t size,...)
uint32_t world_transparent_offset
VkDescriptorSetLayout desc_set_layout_ubo
#define RAY_GEN_ACCEL_STRUCTURE_BINDING_IDX
static VkImageView imv_smap_depth
BufferResource_t buf_readback_staging[MAX_FRAMES_IN_FLIGHT]
#define BINDING_OFFSET_ENVMAP
VkResult vkpt_pt_destroy_dynamic(int idx)
static int transparent_primitive_offset
static VkImage tex_images[MAX_RIMAGES]
#define RAY_GEN_SPRITE_INFO_BUFFER_BINDING_IDX
#define MATERIAL_INDEX_MASK
void * buffer_map(BufferResource_t *buf)
static VkPipelineLayout pipeline_layout_tone_mapping_apply
VkRenderPass render_pass_smap
VkAccelerationStructureNV get_transparency_particle_blas()
CONST PIXELFORMATDESCRIPTOR int
VkSurfaceFormatKHR surf_format
#define AS_FLAG_TRANSPARENT
#define BARRIER_COMPUTE(cmd_buf, img)
const vec3_t bytedirs[NUMVERTEXNORMALS]
static void get_image_dimensions(imageformat_t fmt, image_t *image)
static void load_cameras(bsp_mesh_t *wm, const char *map_name)
static float decode_linear(byte pix)
static VkQueryPool query_pool
VkImageView swap_chain_image_views[MAX_SWAPCHAIN_IMAGES]
#define BARRIER_TO_CLEAR(cmd_buf, img)
static VkImageView tex_image_views[MAX_RIMAGES]
#define BINDING_OFFSET_TERRAIN_SHADOWMAP
static VkDescriptorPool desc_pool_sbo
void vkpt_submit_command_buffer(VkCommandBuffer cmd_buf, VkQueue queue, uint32_t execute_device_mask, int wait_semaphore_count, VkSemaphore *wait_semaphores, VkPipelineStageFlags *wait_stages, uint32_t *wait_device_indices, int signal_semaphore_count, VkSemaphore *signal_semaphores, uint32_t *signal_device_indices, VkFence fence)
static void destroy_tex_images()
void create_invalid_texture()
uint32_t viewer_model_vertex_offset
VkResult vkpt_light_stats_destroy()
static void compute_push_constants()
#define SBT_RAHIT_EXPLOSION
VkExtent2D extent_render_prev
QVKUniformBuffer_t uniform_buffer
VkResult vkpt_pt_destroy_transparent_models(int idx)
static void append_blas(QvkGeometryInstance_t *instances, int *num_instances, VkAccelerationStructureNV blas, int instance_id, int mask, int flags, int sbt_offset)
static VkDeviceMemory mem_smap
vec_t VectorNormalize(vec3_t v)
size_t FS_NormalizePath(char *out, const char *in)
VkDescriptorSet qvk_get_current_desc_set_textures()
static qboolean clip_enable
#define AS_FLAG_EXPLOSIONS
BufferResource_t buf_vertex_staging
static VkDeviceMemory mem_accel_custom_sky
uint32_t transparent_model_vertex_offset
#define SBT_RGEN_INDIRECT_LIGHTING_SECOND
pbr_material_t * MAT_FindPBRMaterial(char const *name)
uint32_t world_custom_sky_count
static size_t scratch_buf_ptr
VkResult vkpt_profiler_query(VkCommandBuffer cmd_buf, int idx, VKPTProfilerAction action)
#define BINDING_OFFSET_SKY_TRANSMITTANCE
static qboolean is_model_transparent(bsp_mesh_t *wm, bsp_model_t *model)
#define BARRIER_TO_COPY_DEST(cmd_buf, img)
static VkDescriptorSet desc_set_sbo[MAX_FRAMES_IN_FLIGHT]
VkDescriptorSetLayout desc_set_layout_vertex_buffer
static void allocate_and_bind_memory_to_blas()
#define CL_PLAYER_MODEL_THIRD_PERSON
uint32_t viewer_weapon_vertex_offset
model_t r_models[MAX_RMODELS]