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"
|
|
|
|
|
2022-05-22 16:28:43 +00:00
|
|
|
typedef struct bsp_face_s {
|
|
|
|
uint32_t first_index;
|
|
|
|
uint32_t index_count;
|
|
|
|
uint32_t tex_id;
|
|
|
|
uint32_t flags;
|
|
|
|
} bsp_face_t;
|
|
|
|
|
2022-05-25 04:29:11 +00:00
|
|
|
typedef struct bsp_model_s {
|
|
|
|
uint32_t first_face;
|
|
|
|
uint32_t face_count;
|
|
|
|
} bsp_model_t;
|
|
|
|
|
2022-05-22 16:28:43 +00:00
|
|
|
typedef struct bsp_packet_s {
|
|
|
|
int first_index;
|
|
|
|
int index_count;
|
|
|
|
int transform_id;
|
|
|
|
int color_id;
|
|
|
|
} bsp_packet_t;
|
|
|
|
|
|
|
|
typedef struct bsp_packetset_s
|
|
|
|
DARRAY_TYPE (bsp_packet_t) bsp_packetset_t;
|
|
|
|
|
|
|
|
typedef struct bsp_indexset_s
|
|
|
|
DARRAY_TYPE (uint32_t) bsp_indexset_t;
|
|
|
|
|
|
|
|
typedef struct bsp_tex_s {
|
|
|
|
VkDescriptorSet descriptors;
|
|
|
|
bsp_packetset_t packets;
|
|
|
|
bsp_indexset_t indices;
|
|
|
|
} bsp_tex_t;
|
|
|
|
|
2021-07-21 07:36:51 +00:00
|
|
|
typedef struct vulktex_s {
|
|
|
|
struct qfv_tex_s *tex;
|
2021-12-17 03:20:32 +00:00
|
|
|
VkDescriptorSet descriptor;
|
2022-05-22 16:28:43 +00:00
|
|
|
int tex_id;
|
2021-07-21 07:36:51 +00:00
|
|
|
} vulktex_t;
|
|
|
|
|
2022-05-22 16:28:43 +00:00
|
|
|
typedef struct regtexset_s
|
|
|
|
DARRAY_TYPE (vulktex_t *) regtexset_t;
|
|
|
|
|
|
|
|
typedef struct bsp_texset_s
|
|
|
|
DARRAY_TYPE (bsp_tex_t) bsp_texset_t;
|
|
|
|
|
|
|
|
typedef struct bsp_draw_s {
|
|
|
|
uint32_t tex_id;
|
2022-05-25 04:29:11 +00:00
|
|
|
uint32_t inst_id;
|
2022-05-22 16:28:43 +00:00
|
|
|
uint32_t index_count;
|
|
|
|
uint32_t instance_count;
|
|
|
|
uint32_t first_index;
|
|
|
|
uint32_t first_instance;
|
|
|
|
} bsp_draw_t;
|
|
|
|
|
|
|
|
typedef struct bsp_drawset_s
|
|
|
|
DARRAY_TYPE (bsp_draw_t) bsp_drawset_t;
|
|
|
|
|
|
|
|
typedef struct instface_s {
|
|
|
|
uint32_t inst_id;
|
|
|
|
uint32_t face;
|
|
|
|
} instface_t;
|
|
|
|
|
|
|
|
typedef struct bsp_instfaceset_s
|
|
|
|
DARRAY_TYPE (instface_t) bsp_instfaceset_t;
|
|
|
|
|
2022-05-25 04:29:11 +00:00
|
|
|
typedef struct bsp_modelentset_s
|
|
|
|
DARRAY_TYPE (uint32_t) bsp_modelentset_t;
|
|
|
|
|
|
|
|
typedef struct bsp_instance_s {
|
|
|
|
int first_instance;
|
|
|
|
bsp_modelentset_t entities;
|
|
|
|
} bsp_instance_t;
|
|
|
|
|
2022-05-22 16:28:43 +00:00
|
|
|
typedef struct bsp_pass_s {
|
|
|
|
uint32_t *indices; // points into index buffer
|
|
|
|
uint32_t index_count; // number of indices written to buffer
|
2022-05-24 15:17:57 +00:00
|
|
|
uint32_t *entid_data;
|
|
|
|
uint32_t entid_count;
|
2022-05-22 16:28:43 +00:00
|
|
|
int vis_frame;
|
|
|
|
int *face_frames;
|
|
|
|
int *leaf_frames;
|
|
|
|
int *node_frames;
|
|
|
|
bsp_instfaceset_t *face_queue;
|
|
|
|
regtexset_t *textures;
|
|
|
|
int num_queues;
|
|
|
|
bsp_drawset_t *draw_queues;
|
2022-05-25 04:29:11 +00:00
|
|
|
uint32_t inst_id;
|
|
|
|
bsp_instance_t *instances;
|
2022-05-22 16:28:43 +00:00
|
|
|
} bsp_pass_t;
|
|
|
|
|
2021-01-19 16:25:54 +00:00
|
|
|
typedef struct bspvert_s {
|
|
|
|
quat_t vertex;
|
|
|
|
quat_t tlst;
|
|
|
|
} bspvert_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
|
|
|
|
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 {
|
2022-05-24 15:17:57 +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)
|
|
|
|
uint32_t *entid_data;
|
|
|
|
uint32_t entid_offset;
|
|
|
|
uint32_t entid_count;
|
2021-02-14 02:35:06 +00:00
|
|
|
qfv_cmdbufferset_t cmdSet;
|
2021-01-19 16:25:54 +00:00
|
|
|
} bspframe_t;
|
|
|
|
|
|
|
|
typedef struct bspframeset_s
|
|
|
|
DARRAY_TYPE (bspframe_t) bspframeset_t;
|
|
|
|
|
|
|
|
typedef struct bspctx_s {
|
2022-05-22 16:28:43 +00:00
|
|
|
regtexset_t registered_textures;
|
2021-01-19 16:25:54 +00:00
|
|
|
|
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-12-17 03:20:32 +00:00
|
|
|
VkDescriptorSet skybox_descriptor;
|
2021-01-19 16:25:54 +00:00
|
|
|
|
|
|
|
quat_t default_color;
|
|
|
|
quat_t last_color;
|
|
|
|
|
|
|
|
struct scrap_s *light_scrap;
|
|
|
|
struct qfv_stagebuf_s *light_stage;
|
|
|
|
|
2022-05-25 04:29:11 +00:00
|
|
|
bsp_model_t *models;
|
2022-05-22 16:28:43 +00:00
|
|
|
bsp_face_t *faces;
|
|
|
|
uint32_t *poly_indices;
|
|
|
|
|
2022-05-25 04:29:11 +00:00
|
|
|
int model_id;
|
|
|
|
|
2022-05-22 16:28:43 +00:00
|
|
|
bsp_pass_t main_pass; // camera view depth, gbuffer, etc
|
2021-01-20 06:11:50 +00:00
|
|
|
|
2021-01-20 17:13:40 +00:00
|
|
|
VkSampler sampler;
|
2021-12-08 12:11:36 +00:00
|
|
|
VkPipelineLayout layout;
|
|
|
|
|
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
|
|
|
size_t vertex_buffer_size;
|
|
|
|
size_t index_buffer_size;
|
|
|
|
VkBuffer vertex_buffer;
|
|
|
|
VkDeviceMemory vertex_memory;
|
|
|
|
VkBuffer index_buffer;
|
|
|
|
VkDeviceMemory index_memory;
|
2022-05-24 15:17:57 +00:00
|
|
|
VkBuffer entid_buffer;
|
|
|
|
VkDeviceMemory entid_memory;
|
2021-01-19 16:25:54 +00:00
|
|
|
bspframeset_t frames;
|
|
|
|
} bspctx_t;
|
|
|
|
|
|
|
|
struct vulkan_ctx_s;
|
2021-12-02 12:58:29 +00:00
|
|
|
struct qfv_renderframe_s;
|
2021-01-19 16:25:54 +00:00
|
|
|
void Vulkan_ClearElements (struct vulkan_ctx_s *ctx);
|
2021-12-02 12:58:29 +00:00
|
|
|
void Vulkan_DrawWorld (struct qfv_renderframe_s *rFrame);
|
|
|
|
void Vulkan_DrawSky (struct qfv_renderframe_s *rFrame);
|
|
|
|
void Vulkan_DrawWaterSurfaces (struct qfv_renderframe_s *rFrame);
|
2021-12-17 06:52:17 +00:00
|
|
|
void Vulkan_Bsp_Flush (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);
|
|
|
|
|
|
|
|
#endif//__QF_Vulkan_qf_bsp_h
|