2021-01-19 16:25:54 +00:00
|
|
|
/*
|
|
|
|
qf_bsp.h
|
|
|
|
|
|
|
|
Vulkan specific brush model stuff
|
|
|
|
|
|
|
|
Copyright (C) 2012 Bill Currie <bill@taniwha.org>
|
|
|
|
Copyright (C) 2021 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2012/1/7
|
|
|
|
Date: 2021/1/18
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifndef __QF_Vulkan_qf_bsp_h
|
|
|
|
#define __QF_Vulkan_qf_bsp_h
|
|
|
|
|
|
|
|
#include "QF/darray.h"
|
|
|
|
#include "QF/model.h"
|
|
|
|
#include "QF/Vulkan/qf_vid.h"
|
2021-02-14 02:35:06 +00:00
|
|
|
#include "QF/Vulkan/command.h"
|
2021-01-19 16:25:54 +00:00
|
|
|
|
2021-04-25 06:47:50 +00:00
|
|
|
#include "QF/simd/types.h"
|
|
|
|
|
2021-01-19 16:25:54 +00:00
|
|
|
typedef struct bspvert_s {
|
|
|
|
quat_t vertex;
|
|
|
|
quat_t tlst;
|
|
|
|
} bspvert_t;
|
|
|
|
|
|
|
|
typedef struct elements_s {
|
|
|
|
struct elements_s *_next;
|
|
|
|
struct elements_s *next;
|
2021-01-20 17:13:40 +00:00
|
|
|
uint32_t first_index;
|
|
|
|
uint32_t index_count;
|
2021-01-19 16:25:54 +00:00
|
|
|
} elements_t;
|
|
|
|
|
|
|
|
typedef struct elechain_s {
|
|
|
|
struct elechain_s *_next;
|
|
|
|
struct elechain_s *next;
|
|
|
|
int index;
|
|
|
|
elements_t *elements;
|
|
|
|
vec_t *transform;
|
|
|
|
float *color;
|
|
|
|
} elechain_t;
|
|
|
|
|
2021-01-23 11:42:53 +00:00
|
|
|
typedef enum {
|
|
|
|
qfv_bsp_texture,
|
|
|
|
qfv_bsp_glowmap,
|
|
|
|
qfv_bsp_lightmap,
|
|
|
|
qfv_bsp_skysheet,
|
|
|
|
qfv_bsp_skycube,
|
|
|
|
} qfv_bsp_tex;
|
2021-01-23 04:51:09 +00:00
|
|
|
// view matrix
|
|
|
|
#define BSP_BUFFER_INFOS 1
|
|
|
|
// Texture, GlowMap, LightMap, SkySheet, SkyCube
|
|
|
|
#define BSP_IMAGE_INFOS 5
|
|
|
|
|
2021-02-19 02:14:54 +00:00
|
|
|
typedef enum {
|
2021-02-14 02:35:06 +00:00
|
|
|
QFV_bspDepth,
|
|
|
|
QFV_bspGBuffer,
|
2021-03-23 03:24:24 +00:00
|
|
|
QFV_bspSky,
|
|
|
|
QFV_bspTurb,
|
2021-02-14 02:35:06 +00:00
|
|
|
|
|
|
|
QFV_bspNumPasses
|
2021-02-19 02:14:54 +00:00
|
|
|
} QFV_BspSubpass;
|
2021-02-14 02:35:06 +00:00
|
|
|
|
2021-01-19 16:25:54 +00:00
|
|
|
typedef struct bspframe_s {
|
2021-01-20 17:13:40 +00:00
|
|
|
uint32_t *index_data; // pointer into mega-buffer for this frame (c)
|
|
|
|
uint32_t index_offset; // offset of index_data within mega-buffer (c)
|
|
|
|
uint32_t index_count; // number if indices queued (d)
|
2021-02-14 02:35:06 +00:00
|
|
|
qfv_cmdbufferset_t cmdSet;
|
2021-01-23 04:51:09 +00:00
|
|
|
VkDescriptorBufferInfo bufferInfo[BSP_BUFFER_INFOS];
|
|
|
|
VkDescriptorImageInfo imageInfo[BSP_IMAGE_INFOS];
|
|
|
|
VkWriteDescriptorSet descriptors[BSP_BUFFER_INFOS + BSP_IMAGE_INFOS];
|
2021-01-19 16:25:54 +00:00
|
|
|
} bspframe_t;
|
|
|
|
|
2021-01-23 14:58:34 +00:00
|
|
|
typedef struct fragconst_s {
|
|
|
|
quat_t fog;
|
|
|
|
float time;
|
|
|
|
} fragconst_t;
|
|
|
|
|
2021-01-19 16:25:54 +00:00
|
|
|
typedef struct bspframeset_s
|
|
|
|
DARRAY_TYPE (bspframe_t) bspframeset_t;
|
|
|
|
|
|
|
|
typedef struct texchainset_s
|
|
|
|
DARRAY_TYPE (struct vulktex_s *) texchainset_t;
|
|
|
|
|
|
|
|
typedef struct bspctx_s {
|
|
|
|
instsurf_t *waterchain;
|
|
|
|
instsurf_t **waterchain_tail;
|
|
|
|
instsurf_t *sky_chain;
|
|
|
|
instsurf_t **sky_chain_tail;
|
|
|
|
|
|
|
|
texchainset_t texture_chains;
|
|
|
|
|
|
|
|
// for world and non-instance models
|
|
|
|
instsurf_t *static_instsurfs;
|
|
|
|
instsurf_t **static_instsurfs_tail;
|
|
|
|
instsurf_t *free_static_instsurfs;
|
|
|
|
|
|
|
|
// for instance models
|
|
|
|
elechain_t *elechains;
|
|
|
|
elechain_t **elechains_tail;
|
|
|
|
elechain_t *free_elechains;
|
|
|
|
elements_t *elementss;
|
|
|
|
elements_t **elementss_tail;
|
|
|
|
elements_t *free_elementss;
|
|
|
|
instsurf_t *instsurfs;
|
|
|
|
instsurf_t **instsurfs_tail;
|
|
|
|
instsurf_t *free_instsurfs;
|
|
|
|
|
2021-01-23 11:42:53 +00:00
|
|
|
struct qfv_tex_s *default_skysheet;
|
2021-01-20 17:13:40 +00:00
|
|
|
struct qfv_tex_s *skysheet_tex;
|
2021-01-23 11:42:53 +00:00
|
|
|
|
|
|
|
struct qfv_tex_s *default_skybox;
|
2021-01-19 16:25:54 +00:00
|
|
|
struct qfv_tex_s *skybox_tex;
|
2021-04-25 06:47:50 +00:00
|
|
|
vec4f_t sky_rotation[2];
|
|
|
|
vec4f_t sky_velocity;
|
|
|
|
vec4f_t sky_fix;
|
2021-01-19 16:25:54 +00:00
|
|
|
double sky_time;
|
|
|
|
|
|
|
|
quat_t default_color;
|
|
|
|
quat_t last_color;
|
|
|
|
|
|
|
|
struct scrap_s *light_scrap;
|
|
|
|
struct qfv_stagebuf_s *light_stage;
|
|
|
|
|
2021-01-20 06:11:50 +00:00
|
|
|
struct bsppoly_s *polys;
|
|
|
|
|
2021-01-20 17:13:40 +00:00
|
|
|
VkSampler sampler;
|
2021-01-19 16:25:54 +00:00
|
|
|
VkDeviceMemory texture_memory;
|
2021-02-19 02:14:54 +00:00
|
|
|
VkPipeline depth;
|
|
|
|
VkPipeline gbuf;
|
2021-03-25 06:54:34 +00:00
|
|
|
VkPipeline skysheet;
|
|
|
|
VkPipeline skybox;
|
2021-03-23 03:24:24 +00:00
|
|
|
VkPipeline turb;
|
2021-01-19 16:25:54 +00:00
|
|
|
VkPipelineLayout layout;
|
|
|
|
size_t vertex_buffer_size;
|
|
|
|
size_t index_buffer_size;
|
|
|
|
VkBuffer vertex_buffer;
|
|
|
|
VkDeviceMemory vertex_memory;
|
|
|
|
VkBuffer index_buffer;
|
|
|
|
VkDeviceMemory index_memory;
|
|
|
|
bspframeset_t frames;
|
|
|
|
} bspctx_t;
|
|
|
|
|
|
|
|
struct vulkan_ctx_s;
|
|
|
|
void Vulkan_ClearElements (struct vulkan_ctx_s *ctx);
|
|
|
|
void Vulkan_DrawWorld (struct vulkan_ctx_s *ctx);
|
|
|
|
void Vulkan_DrawSky (struct vulkan_ctx_s *ctx);
|
2021-03-25 06:54:34 +00:00
|
|
|
void Vulkan_LoadSkys (const char *sky, struct vulkan_ctx_s *ctx);
|
2021-01-19 16:25:54 +00:00
|
|
|
void Vulkan_RegisterTextures (model_t **models, int num_models,
|
|
|
|
struct vulkan_ctx_s *ctx);
|
|
|
|
void Vulkan_BuildDisplayLists (model_t **models, int num_models,
|
|
|
|
struct vulkan_ctx_s *ctx);
|
|
|
|
void Vulkan_Bsp_Init (struct vulkan_ctx_s *ctx);
|
|
|
|
void Vulkan_Bsp_Shutdown (struct vulkan_ctx_s *ctx);
|
|
|
|
void Vulkan_DrawWaterSurfaces (struct vulkan_ctx_s *ctx);
|
|
|
|
|
|
|
|
#endif//__QF_Vulkan_qf_bsp_h
|