2021-02-08 19:57:27 +01:00
|
|
|
#pragma once
|
|
|
|
#include "vk_common.h"
|
|
|
|
#include "vk_const.h"
|
2021-02-10 19:33:44 +01:00
|
|
|
#include "vk_core.h"
|
2021-02-08 19:57:27 +01:00
|
|
|
|
2021-02-20 21:00:31 +01:00
|
|
|
qboolean VK_RenderInit( void );
|
|
|
|
void VK_RenderShutdown( void );
|
2021-02-10 19:33:44 +01:00
|
|
|
|
2021-02-20 21:00:31 +01:00
|
|
|
// Set UBO state for next VK_RenderScheduleDraw calls
|
|
|
|
// Why? Xash Ref code is organized in a way where we can't reliably pass this info with
|
|
|
|
// ScheduleDraw itself, so we need to either set up per-submodule global state, or
|
|
|
|
// centralize this global state in here
|
|
|
|
void VK_RenderStateSetColor( float r, float g, float b, float a );
|
|
|
|
// TODO void VK_RenderStateGetColor( vec4_t color );
|
|
|
|
|
2021-08-05 03:36:53 +02:00
|
|
|
void VK_RenderStateSetMatrixProjection(const matrix4x4 proj, float fov_angle_y);
|
2021-03-13 22:35:50 +01:00
|
|
|
void VK_RenderStateSetMatrixView(const matrix4x4 view);
|
|
|
|
void VK_RenderStateSetMatrixModel(const matrix4x4 model);
|
2021-03-03 20:58:40 +01:00
|
|
|
|
2021-02-14 02:19:59 +01:00
|
|
|
|
2021-08-26 18:18:20 +02:00
|
|
|
// Quirk for passing surface type to the renderer
|
|
|
|
// xash3d does not really have a notion of materials. Instead there are custom code paths
|
|
|
|
// for different things. There's also render_mode for entities which determine blending mode
|
|
|
|
// and stuff.
|
|
|
|
// For ray tracing we do need to assing a material to each rendered surface, so we need to
|
|
|
|
// figure out what it is given heuristics like render_mode, texture name, etc.
|
|
|
|
// For some things we don't even have that. E.g. water and sky surfaces are weird.
|
|
|
|
// Lets just assigne water and sky materials to those geometries (and probably completely
|
|
|
|
// disregard render_mode, as it should be irrelevant).
|
2021-10-27 19:21:06 +02:00
|
|
|
// FIXME these should be bits, not enums
|
2021-06-19 21:52:13 +02:00
|
|
|
typedef enum {
|
2021-08-26 18:18:20 +02:00
|
|
|
kXVkMaterialRegular = 0,
|
2021-06-19 21:52:13 +02:00
|
|
|
kXVkMaterialWater,
|
|
|
|
kXVkMaterialSky,
|
2021-08-26 18:18:20 +02:00
|
|
|
kXVkMaterialEmissive,
|
2021-10-27 19:21:06 +02:00
|
|
|
kXVkMaterialConveyor,
|
2021-10-31 21:46:02 +01:00
|
|
|
kXVkMaterialChrome,
|
2021-06-19 21:52:13 +02:00
|
|
|
} XVkMaterialType;
|
|
|
|
|
2021-08-26 18:18:20 +02:00
|
|
|
typedef struct vk_render_geometry_s {
|
2021-08-11 20:43:33 +02:00
|
|
|
int index_offset, vertex_offset;
|
2021-02-14 02:19:59 +01:00
|
|
|
|
2021-08-26 18:18:20 +02:00
|
|
|
// Animated textures will be dynamic and change between frames
|
2021-04-07 21:11:20 +02:00
|
|
|
int texture;
|
2021-08-26 18:18:20 +02:00
|
|
|
|
|
|
|
// If this geometry is special, it will have a material type override
|
2021-06-19 21:52:13 +02:00
|
|
|
XVkMaterialType material;
|
2021-04-24 21:53:42 +02:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
uint32_t element_count;
|
2021-08-18 18:17:48 +02:00
|
|
|
|
|
|
|
// Maximum index of vertex used for this geometry; needed for ray tracing BLAS building
|
|
|
|
uint32_t max_vertex;
|
2021-04-24 21:53:42 +02:00
|
|
|
|
2021-06-05 21:48:16 +02:00
|
|
|
// Non-null only for brush models
|
|
|
|
// Used for:
|
|
|
|
// - updating animated textures for brush models
|
|
|
|
// - updating dynamic lights (TODO: can decouple from surface/brush models by providing texture_id and aabb directly here)
|
2021-09-14 19:20:15 +02:00
|
|
|
const struct msurface_s *surf;
|
2021-06-05 21:48:16 +02:00
|
|
|
|
2021-11-28 20:15:02 +01:00
|
|
|
// for kXVkMaterialEmissive
|
|
|
|
vec3_t emissive;
|
2021-04-07 21:11:20 +02:00
|
|
|
} vk_render_geometry_t;
|
|
|
|
|
2021-05-24 20:14:03 +02:00
|
|
|
struct vk_ray_model_s;
|
2021-05-17 18:24:15 +02:00
|
|
|
|
2021-09-14 19:20:15 +02:00
|
|
|
#define MAX_MODEL_NAME_LENGTH 64
|
|
|
|
|
2022-05-27 20:16:15 +02:00
|
|
|
struct rt_light_add_polygon_s;
|
2021-04-09 23:59:04 +02:00
|
|
|
typedef struct vk_render_model_s {
|
2021-09-14 19:20:15 +02:00
|
|
|
char debug_name[MAX_MODEL_NAME_LENGTH];
|
2021-04-07 21:11:20 +02:00
|
|
|
int render_mode;
|
|
|
|
int num_geometries;
|
|
|
|
vk_render_geometry_t *geometries;
|
|
|
|
|
2021-04-24 21:53:42 +02:00
|
|
|
// This model will be one-frame only, its buffers are not preserved between frames
|
|
|
|
qboolean dynamic;
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2021-09-26 18:15:19 +02:00
|
|
|
// FIXME ...
|
|
|
|
qboolean static_map;
|
|
|
|
|
2021-08-26 18:18:20 +02:00
|
|
|
// Non-NULL only for ray tracing
|
2021-05-24 20:14:03 +02:00
|
|
|
struct vk_ray_model_s *ray_model;
|
2022-05-27 20:16:15 +02:00
|
|
|
struct rt_light_add_polygon_s *polylights;
|
|
|
|
int polylights_count;
|
2023-01-22 00:45:29 +01:00
|
|
|
|
|
|
|
// previous frame ObjectToWorld (model) matrix
|
|
|
|
matrix4x4 prev_transform;
|
2021-04-07 21:11:20 +02:00
|
|
|
} vk_render_model_t;
|
|
|
|
|
2022-09-11 20:38:51 +02:00
|
|
|
qboolean VK_RenderModelInit( vk_render_model_t* model );
|
2021-04-07 21:11:20 +02:00
|
|
|
void VK_RenderModelDestroy( vk_render_model_t* model );
|
2021-10-27 19:21:06 +02:00
|
|
|
void VK_RenderModelDraw( const cl_entity_t *ent, vk_render_model_t* model );
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2021-09-14 19:20:15 +02:00
|
|
|
void VK_RenderModelDynamicBegin( int render_mode, const char *debug_name_fmt, ... );
|
2021-04-24 21:53:42 +02:00
|
|
|
void VK_RenderModelDynamicAddGeometry( const vk_render_geometry_t *geom );
|
|
|
|
void VK_RenderModelDynamicCommit( void );
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2021-06-06 23:17:35 +02:00
|
|
|
void VK_RenderDebugLabelBegin( const char *label );
|
|
|
|
void VK_RenderDebugLabelEnd( void );
|
|
|
|
|
2021-07-04 20:18:28 +02:00
|
|
|
void VK_RenderBegin( qboolean ray_tracing );
|
2021-06-06 23:17:35 +02:00
|
|
|
void VK_RenderEnd( VkCommandBuffer cmdbuf );
|
|
|
|
void VK_RenderEndRTX( VkCommandBuffer cmdbuf, VkImageView img_dst_view, VkImage img_dst, uint32_t w, uint32_t h );
|
2022-06-25 20:12:48 +02:00
|
|
|
|
|
|
|
void VK_Render_FIXME_Barrier( VkCommandBuffer cmdbuf );
|