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
|
|
|
|
2023-05-04 19:30:13 +02:00
|
|
|
struct ref_viewpass_s;
|
|
|
|
void VK_RenderSetupCamera( const struct ref_viewpass_s *rvp );
|
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
|
2023-04-21 20:47:07 +02:00
|
|
|
// figure out what it is given heuristics like render_mode, texture name, surface flags, source entity type, etc.
|
2021-06-19 21:52:13 +02:00
|
|
|
typedef enum {
|
2021-08-26 18:18:20 +02:00
|
|
|
kXVkMaterialRegular = 0,
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Set for SURF_DRAWSKY surfaces in vk_brush.c.
|
2023-05-02 00:34:13 +02:00
|
|
|
// Used: for setting TEX_BASE_SKYBOX for skybox texture sampling and environment shadows.
|
2023-04-21 20:07:58 +02:00
|
|
|
// Remove: pass it as a special texture/material index (e.g. -2).
|
2021-06-19 21:52:13 +02:00
|
|
|
kXVkMaterialSky,
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Set for chrome studio submodels.
|
|
|
|
// Used: ray tracing sets gray roughness texture to get smooth surface look.
|
|
|
|
// Remove: Have an explicit material for chrome surfaces.
|
2021-10-31 21:46:02 +01:00
|
|
|
kXVkMaterialChrome,
|
2021-06-19 21:52:13 +02:00
|
|
|
} XVkMaterialType;
|
|
|
|
|
2023-03-03 08:23:31 +01: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-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
|
2023-04-21 20:07:58 +02:00
|
|
|
// Used for updating animated textures for brush models
|
|
|
|
// Remove: have an explicit list of surfaces with animated textures
|
|
|
|
const struct msurface_s *surf_deprecate;
|
|
|
|
|
|
|
|
// Animated textures will be dynamic and change between frames
|
|
|
|
int texture;
|
|
|
|
|
|
|
|
// If this geometry is special, it will have a material type override
|
|
|
|
XVkMaterialType material;
|
2021-06-05 21:48:16 +02:00
|
|
|
|
2023-03-03 08:23:31 +01:00
|
|
|
// for kXVkMaterialEmissive{,Glow} and others
|
2021-11-28 20:15:02 +01:00
|
|
|
vec3_t emissive;
|
2021-04-07 21:11:20 +02:00
|
|
|
} vk_render_geometry_t;
|
|
|
|
|
2023-02-25 21:09:20 +01:00
|
|
|
typedef enum {
|
|
|
|
kVkRenderTypeSolid, // no blending, depth RW
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Mix alpha blending with depth test and write
|
|
|
|
// Set by:
|
|
|
|
// - brush: kRenderTransColor
|
|
|
|
// - studio: kRenderTransColor, kRenderTransTexture, kRenderTransAlpha, kRenderGlow
|
|
|
|
// - sprite: kRenderTransColor, kRenderTransTexture
|
|
|
|
// - triapi: kRenderTransColor, kRenderTransTexture
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_A_1mA_RW, // blend: src*a + dst*(1-a), depth: RW
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Mix alpha blending with depth test only
|
|
|
|
// Set by:
|
|
|
|
// - brush: kRenderTransTexture, kRenderGlow
|
|
|
|
// - sprite: kRenderTransAlpha
|
|
|
|
// - triapi: kRenderTransAlpha
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_A_1mA_R, // blend: src*a + dst*(1-a), depth test
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Additive alpha blending, no depth
|
|
|
|
// Set by:
|
|
|
|
// - sprite: kRenderGlow
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_A_1, // blend: src*a + dst, no depth test or write
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Additive alpha blending with depth test
|
|
|
|
// Set by:
|
|
|
|
// - brush: kRenderTransAdd
|
|
|
|
// - beams: all modes except kRenderNormal and beams going through triapi
|
|
|
|
// - sprite: kRenderTransAdd
|
|
|
|
// - triapi: kRenderTransAdd, kRenderGlow
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_A_1_R, // blend: src*a + dst, depth test
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// No blend, alpha test, depth test and write
|
|
|
|
// Set by:
|
|
|
|
// - brush: kRenderTransAlpha
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_AT, // no blend, depth RW, alpha test
|
2023-04-21 20:07:58 +02:00
|
|
|
|
|
|
|
// Additive no alpha blend, depth test only
|
|
|
|
// Set by:
|
|
|
|
// - studio: kRenderTransAdd
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_1_1_R, // blend: src + dst, depth test
|
2023-04-21 20:07:58 +02:00
|
|
|
|
2023-02-25 21:09:20 +01:00
|
|
|
kVkRenderType_COUNT
|
|
|
|
} vk_render_type_e;
|
2023-03-03 07:32:08 +01:00
|
|
|
|
2022-05-27 20:16:15 +02:00
|
|
|
struct rt_light_add_polygon_s;
|
2023-05-30 21:14:44 +02:00
|
|
|
struct rt_model_s;
|
2023-03-03 07:32:08 +01:00
|
|
|
|
2021-04-09 23:59:04 +02:00
|
|
|
typedef struct vk_render_model_s {
|
2023-03-03 07:32:08 +01:00
|
|
|
#define MAX_MODEL_NAME_LENGTH 64
|
2021-09-14 19:20:15 +02:00
|
|
|
char debug_name[MAX_MODEL_NAME_LENGTH];
|
2023-02-25 07:48:26 +01:00
|
|
|
|
2023-05-30 21:14:44 +02:00
|
|
|
// TODO per-geometry?
|
2023-02-25 08:54:41 +01:00
|
|
|
int lightmap; // <= 0 if no lightmap
|
2023-02-25 07:48:26 +01:00
|
|
|
|
2021-04-07 21:11:20 +02:00
|
|
|
int num_geometries;
|
|
|
|
vk_render_geometry_t *geometries;
|
|
|
|
|
2023-05-31 18:39:27 +02:00
|
|
|
struct rt_model_s *rt_model;
|
2023-04-28 21:35:48 +02:00
|
|
|
|
2021-04-24 21:53:42 +02:00
|
|
|
// This model will be one-frame only, its buffers are not preserved between frames
|
2023-05-30 21:14:44 +02:00
|
|
|
// TODO deprecate
|
2021-04-24 21:53:42 +02:00
|
|
|
qboolean dynamic;
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2023-03-03 07:32:08 +01:00
|
|
|
// Polylights which need to be added per-frame dynamically
|
|
|
|
// Used for non-worldmodel brush models which are not static
|
2023-05-30 21:14:44 +02:00
|
|
|
// TODO this doesn't belong here at all
|
2023-03-03 07:32:08 +01:00
|
|
|
struct rt_light_add_polygon_s *dynamic_polylights;
|
|
|
|
int dynamic_polylights_count;
|
2021-04-07 21:11:20 +02:00
|
|
|
} vk_render_model_t;
|
|
|
|
|
2023-05-30 21:14:44 +02:00
|
|
|
// Initialize model from scratch
|
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
vk_render_geometry_t *geometries;
|
|
|
|
int geometries_count;
|
2023-06-09 19:03:00 +02:00
|
|
|
|
|
|
|
// Geometry data can and will be updated
|
|
|
|
// Upading geometry locations is not supported though, only vertex/index values
|
|
|
|
qboolean dynamic;
|
2023-05-30 21:14:44 +02:00
|
|
|
} vk_render_model_init_t;
|
2023-06-09 19:03:00 +02:00
|
|
|
qboolean R_RenderModelCreate( vk_render_model_t *model, vk_render_model_init_t args );
|
|
|
|
void R_RenderModelDestroy( vk_render_model_t* model );
|
|
|
|
|
2023-06-09 20:28:30 +02:00
|
|
|
qboolean R_RenderModelUpdate( const vk_render_model_t *model );
|
2023-05-30 21:14:44 +02:00
|
|
|
|
2023-05-31 18:39:27 +02:00
|
|
|
typedef struct {
|
|
|
|
vk_render_type_e render_type;
|
|
|
|
|
|
|
|
// These are "consumed": copied into internal storage and can be pointers to stack vars
|
|
|
|
const vec4_t *color;
|
|
|
|
const matrix4x4 *transform, *prev_transform;
|
|
|
|
|
|
|
|
// These are expected to be alive and valid until frame end at least
|
|
|
|
int geometries_changed_count;
|
|
|
|
int *geometries_changed;
|
2023-05-31 20:00:28 +02:00
|
|
|
|
|
|
|
// Global texture override if > 0
|
|
|
|
// Used by sprite+quad instancing
|
|
|
|
int textures_override;
|
2023-05-31 18:39:27 +02:00
|
|
|
} r_model_draw_t;
|
|
|
|
|
|
|
|
void R_RenderModelDraw(const vk_render_model_t *model, r_model_draw_t args);
|
2021-04-07 21:11:20 +02:00
|
|
|
|
2023-06-06 18:50:24 +02:00
|
|
|
typedef struct {
|
|
|
|
const char *name;
|
|
|
|
const struct vk_vertex_s *vertices;
|
|
|
|
const uint16_t *indices;
|
|
|
|
int vertices_count, indices_count;
|
|
|
|
|
|
|
|
int render_type;
|
|
|
|
int texture;
|
|
|
|
const vec4_t *emissive;
|
|
|
|
const vec4_t *color;
|
|
|
|
} r_draw_once_t;
|
|
|
|
void R_RenderDrawOnce(r_draw_once_t args);
|
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 );
|
2023-04-01 06:01:17 +02:00
|
|
|
struct vk_combuf_s;
|
|
|
|
void VK_RenderEndRTX( struct vk_combuf_s* combuf, 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 );
|