1 /*
2 Copyright (C) 1996-2001 Id Software, Inc.
3 Copyright (C) 2002-2009 John Fitzgibbons and others
4 Copyright (C) 2007-2008 Kristian Duske
5 Copyright (C) 2010-2014 QuakeSpasm developers
6 Copyright (C) 2016 Axel Gneiting
7 
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 
17 See the GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 
23 */
24 
25 #ifndef GLQUAKE_H
26 #define GLQUAKE_H
27 
28 void GL_WaitForDeviceIdle (void);
29 qboolean GL_BeginRendering (int *x, int *y, int *width, int *height);
30 qboolean GL_AcquireNextSwapChainImage (void);
31 void GL_EndRendering (qboolean swapchain_acquired);
32 qboolean GL_Set2D (void);
33 
34 extern	int glx, gly, glwidth, glheight;
35 
36 // r_local.h -- private refresh defs
37 
38 #define ALIAS_BASE_SIZE_RATIO		(1.0 / 11.0)
39 					// normalizing factor so player model works out to about
40 					//  1 pixel per triangle
41 #define	MAX_LBM_HEIGHT		480
42 
43 #define TILE_SIZE		128		// size of textures generated by R_GenTiledSurf
44 
45 #define SKYSHIFT		7
46 #define	SKYSIZE			(1 << SKYSHIFT)
47 #define SKYMASK			(SKYSIZE - 1)
48 
49 #define BACKFACE_EPSILON	0.01
50 
51 #define	MAX_GLTEXTURES	4096
52 
53 #define NUM_COLOR_BUFFERS 2
54 #define INITIAL_STAGING_BUFFER_SIZE_KB	16384
55 
56 #define FAN_INDEX_BUFFER_SIZE 126
57 
58 void R_TimeRefresh_f (void);
59 void R_ReadPointFile_f (void);
60 texture_t *R_TextureAnimation (texture_t *base, int frame);
61 
62 typedef struct surfcache_s
63 {
64 	struct surfcache_s	*next;
65 	struct surfcache_s 	**owner;		// NULL is an empty chunk of memory
66 	int			lightadj[MAXLIGHTMAPS]; // checked for strobe flush
67 	int			dlight;
68 	int			size;		// including header
69 	unsigned		width;
70 	unsigned		height;		// DEBUG only needed for debug
71 	float			mipscale;
72 	struct texture_s	*texture;	// checked for animating textures
73 	byte			data[4];	// width*height elements
74 } surfcache_t;
75 
76 
77 typedef struct
78 {
79 	pixel_t		*surfdat;	// destination for generated surface
80 	int		rowbytes;	// destination logical width in bytes
81 	msurface_t	*surf;		// description for surface to generate
82 	fixed8_t	lightadj[MAXLIGHTMAPS];
83 							// adjust for lightmap levels for dynamic lighting
84 	texture_t	*texture;	// corrected for animating textures
85 	int		surfmip;	// mipmapped ratio of surface texels / world pixels
86 	int		surfwidth;	// in mipmapped texels
87 	int		surfheight;	// in mipmapped texels
88 } drawsurf_t;
89 
90 
91 typedef enum {
92 	pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2
93 } ptype_t;
94 
95 // !!! if this is changed, it must be changed in d_ifacea.h too !!!
96 typedef struct particle_s
97 {
98 // driver-usable fields
99 	vec3_t		org;
100 	float		color;
101 // drivers never touch the following fields
102 	struct particle_s	*next;
103 	vec3_t		vel;
104 	float		ramp;
105 	float		die;
106 	ptype_t		type;
107 } particle_t;
108 
109 #define P_INVALID -1
110 #ifdef PSET_SCRIPT
111 	void PScript_InitParticles (void);
112 	void PScript_Shutdown (void);
113 	void PScript_DrawParticles (void);
114 	void PScript_DrawParticles_ShowTris (void);
115 	struct trailstate_s;
116 	int PScript_ParticleTrail (vec3_t startpos, vec3_t end, int type, float timeinterval, int dlkey, vec3_t axis[3], struct trailstate_s **tsk);
117 	int PScript_RunParticleEffectState (vec3_t org, vec3_t dir, float count, int typenum, struct trailstate_s **tsk);
118 	void PScript_RunParticleWeather(vec3_t minb, vec3_t maxb, vec3_t dir, float count, int colour, const char *efname);
119 	void PScript_EmitSkyEffectTris(qmodel_t *mod, msurface_t 	*fa, int ptype);
120 	int PScript_FindParticleType(const char *fullname);
121 	int PScript_RunParticleEffectTypeString (vec3_t org, vec3_t dir, float count, const char *name);
122 	int PScript_EntParticleTrail(vec3_t oldorg, entity_t *ent, const char *name);
123 	int PScript_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
124 	void PScript_DelinkTrailstate(struct trailstate_s **tsk);
125 	void PScript_ClearParticles (void);
126 	void PScript_UpdateModelEffects(qmodel_t *mod);
127 	void PScript_ClearSurfaceParticles(qmodel_t *mod);	//model is being unloaded.
128 
129 	extern int r_trace_line_cache_counter;
130 	#define InvalidateTraceLineCache() do { ++r_trace_line_cache_counter; } while(0);
131 #else
132 	#define PScript_RunParticleEffectState(o,d,c,t,s) true
133 	#define PScript_RunParticleEffectTypeString(o,d,c,n) true	//just unconditionally returns an error
134 	#define PScript_EntParticleTrail(o,e,n) true
135 	#define PScript_ParticleTrail(o,e,t,d,a,s) true
136 	#define PScript_EntParticleTrail(o,e,n) true
137 	#define PScript_RunParticleEffect(o,d,p,c) true
138 	#define PScript_RunParticleWeather(min,max,d,c,p,n)
139 	#define PScript_ClearSurfaceParticles(m)
140 	#define PScript_DelinkTrailstate(tsp)
141 	#define InvalidateTraceLineCache()
142 #endif
143 
144 
145 typedef struct vulkan_pipeline_layout_s {
146 	VkPipelineLayout		handle;
147 	VkPushConstantRange		push_constant_range;
148 } vulkan_pipeline_layout_t;
149 
150 typedef struct vulkan_pipeline_s {
151 	VkPipeline					handle;
152 	vulkan_pipeline_layout_t	layout;
153 } vulkan_pipeline_t;
154 
155 typedef struct vulkan_desc_set_layout_s {
156 	VkDescriptorSetLayout		handle;
157 	int							num_combined_image_samplers;
158 	int							num_ubos_dynamic;
159 	int							num_input_attachments;
160 	int							num_storage_images;
161 } vulkan_desc_set_layout_t;
162 
163 typedef enum {
164 	VULKAN_MEMORY_TYPE_DEVICE,
165 	VULKAN_MEMORY_TYPE_HOST,
166 } vulkan_memory_type_t;
167 
168 typedef struct vulkan_memory_s {
169 	VkDeviceMemory				handle;
170 	size_t						size;
171 	vulkan_memory_type_t		type;
172 } vulkan_memory_t;
173 
174 #define WORLD_PIPELINE_COUNT 8
175 #define FTE_PARTICLE_PIPELINE_COUNT 16
176 
177 typedef struct
178 {
179 	VkDevice							device;
180 	qboolean							device_idle;
181 	qboolean							validation;
182 	qboolean							debug_utils;
183 	VkQueue								queue;
184 	VkCommandBuffer						command_buffer;
185 	vulkan_pipeline_t					current_pipeline;
186 	VkClearValue						color_clear_value;
187 	VkFormat							swap_chain_format;
188 	qboolean							want_full_screen_exclusive;
189 	qboolean							swap_chain_full_screen_exclusive;
190 	qboolean							swap_chain_full_screen_acquired;
191 	VkPhysicalDeviceProperties			device_properties;
192 	VkPhysicalDeviceMemoryProperties	memory_properties;
193 	uint32_t							gfx_queue_family_index;
194 	VkFormat							color_format;
195 	VkFormat							depth_format;
196 	VkSampleCountFlagBits				sample_count;
197 	qboolean							supersampling;
198 	qboolean							non_solid_fill;
199 	qboolean							screen_effects_sops;
200 
201 	// Instance extensions
202 	qboolean							get_surface_capabilities_2;
203 	qboolean							get_physical_device_properties_2;
204 	qboolean							vulkan_1_1_available;
205 
206 	// Device extensions
207 	qboolean							dedicated_allocation;
208 	qboolean							full_screen_exclusive;
209 
210 	// Buffers
211 	VkImage								color_buffers[NUM_COLOR_BUFFERS];
212 
213 	// Index buffers
214 	VkBuffer							fan_index_buffer;
215 
216 	// Staging buffers
217 	int									staging_buffer_size;
218 
219 	// Render passes
220 	VkRenderPass						main_render_pass;
221 	VkClearValue						main_clear_values[4];
222 	VkRenderPassBeginInfo				main_render_pass_begin_infos[2];
223 	VkRenderPass						ui_render_pass;
224 	VkRenderPassBeginInfo				ui_render_pass_begin_info;
225 	VkRenderPass						warp_render_pass;
226 
227 	// Pipelines
228 	vulkan_pipeline_t					basic_alphatest_pipeline[2];
229 	vulkan_pipeline_t					basic_blend_pipeline[2];
230 	vulkan_pipeline_t					basic_notex_blend_pipeline[2];
231 	vulkan_pipeline_t					basic_poly_blend_pipeline;
232 	vulkan_pipeline_layout_t			basic_pipeline_layout;
233 	vulkan_pipeline_t					world_pipelines[WORLD_PIPELINE_COUNT];
234 	vulkan_pipeline_layout_t			world_pipeline_layout;
235 	vulkan_pipeline_t					water_pipeline;
236 	vulkan_pipeline_t					water_blend_pipeline;
237 	vulkan_pipeline_t					raster_tex_warp_pipeline;
238 	vulkan_pipeline_t					particle_pipeline;
239 	vulkan_pipeline_t					sprite_pipeline;
240 	vulkan_pipeline_t					sky_stencil_pipeline;
241 	vulkan_pipeline_t					sky_color_pipeline;
242 	vulkan_pipeline_t					sky_box_pipeline;
243 	vulkan_pipeline_t					sky_layer_pipeline;
244 	vulkan_pipeline_t					alias_pipeline;
245 	vulkan_pipeline_t					alias_blend_pipeline;
246 	vulkan_pipeline_t					alias_alphatest_pipeline;
247 	vulkan_pipeline_t					alias_alphatest_blend_pipeline;
248 	vulkan_pipeline_t					postprocess_pipeline;
249 	vulkan_pipeline_t					screen_effects_pipeline;
250 	vulkan_pipeline_t					screen_effects_scale_pipeline;
251 	vulkan_pipeline_t					screen_effects_scale_sops_pipeline;
252 	vulkan_pipeline_t					cs_tex_warp_pipeline;
253 	vulkan_pipeline_t					showtris_pipeline;
254 	vulkan_pipeline_t					showtris_depth_test_pipeline;
255 	vulkan_pipeline_t					showbboxes_pipeline;
256 	vulkan_pipeline_t					alias_showtris_pipeline;
257 	vulkan_pipeline_t					alias_showtris_depth_test_pipeline;
258 #ifdef PSET_SCRIPT
259 	vulkan_pipeline_t					fte_particle_pipelines[FTE_PARTICLE_PIPELINE_COUNT];
260 #endif
261 
262 	// Descriptors
263 	VkDescriptorPool					descriptor_pool;
264 	vulkan_desc_set_layout_t			ubo_set_layout;
265 	vulkan_desc_set_layout_t			single_texture_set_layout;
266 	vulkan_desc_set_layout_t			input_attachment_set_layout;
267 	VkDescriptorSet						screen_warp_desc_set;
268 	vulkan_desc_set_layout_t			screen_warp_set_layout;
269 	vulkan_desc_set_layout_t			single_texture_cs_write_set_layout;
270 
271 	// Samplers
272 	VkSampler							point_sampler;
273 	VkSampler							linear_sampler;
274 	VkSampler							point_aniso_sampler;
275 	VkSampler							linear_aniso_sampler;
276 	VkSampler							point_sampler_lod_bias;
277 	VkSampler							linear_sampler_lod_bias;
278 	VkSampler							point_aniso_sampler_lod_bias;
279 	VkSampler							linear_aniso_sampler_lod_bias;
280 
281 	// Matrices
282 	float								projection_matrix[16];
283 	float								view_matrix[16];
284 	float								view_projection_matrix[16];
285 
286 	//Dispatch table
287 	PFN_vkCmdBindPipeline				vk_cmd_bind_pipeline;
288 	PFN_vkCmdPushConstants				vk_cmd_push_constants;
289 	PFN_vkCmdBindDescriptorSets			vk_cmd_bind_descriptor_sets;
290 	PFN_vkCmdBindIndexBuffer			vk_cmd_bind_index_buffer;
291 	PFN_vkCmdBindVertexBuffers			vk_cmd_bind_vertex_buffers;
292 	PFN_vkCmdDraw						vk_cmd_draw;
293 	PFN_vkCmdDrawIndexed				vk_cmd_draw_indexed;
294 	PFN_vkCmdPipelineBarrier			vk_cmd_pipeline_barrier;
295 	PFN_vkCmdCopyBufferToImage			vk_cmd_copy_buffer_to_image;
296 
297 #ifdef _DEBUG
298 	PFN_vkCmdBeginDebugUtilsLabelEXT	vk_cmd_begin_debug_utils_label;
299 	PFN_vkCmdEndDebugUtilsLabelEXT		vk_cmd_end_debug_utils_label;
300 #endif
301 } vulkanglobals_t;
302 
303 extern vulkanglobals_t vulkan_globals;
304 
305 //====================================================
306 
307 extern	qboolean	r_cache_thrash;		// compatability
308 extern	vec3_t		modelorg, r_entorigin;
309 extern	entity_t	*currententity;
310 extern	int		r_visframecount;	// ??? what difs?
311 extern	int		r_framecount;
312 extern	mplane_t	frustum[4];
313 extern	int render_pass_index;
314 extern	qboolean render_warp;
315 extern	qboolean in_update_screen;
316 extern	qboolean use_simd;
317 extern int render_scale;
318 
319 //
320 // view origin
321 //
322 extern	vec3_t	vup;
323 extern	vec3_t	vpn;
324 extern	vec3_t	vright;
325 extern	vec3_t	r_origin;
326 
327 //
328 // screen size info
329 //
330 extern	refdef_t	r_refdef;
331 extern	mleaf_t		*r_viewleaf, *r_oldviewleaf;
332 extern	int		d_lightstylevalue[256];	// 8.8 fraction of base light value
333 
334 extern	cvar_t	r_drawentities;
335 extern	cvar_t	r_drawworld;
336 extern	cvar_t	r_drawviewmodel;
337 extern	cvar_t	r_speeds;
338 extern	cvar_t	r_pos;
339 extern	cvar_t	r_waterwarp;
340 extern	cvar_t	r_fullbright;
341 extern	cvar_t	r_lightmap;
342 extern	cvar_t	r_wateralpha;
343 extern	cvar_t	r_lavaalpha;
344 extern	cvar_t	r_telealpha;
345 extern	cvar_t	r_slimealpha;
346 extern	cvar_t	r_dynamic;
347 extern	cvar_t	r_novis;
348 extern	cvar_t	r_scale;
349 
350 extern	cvar_t	gl_polyblend;
351 extern	cvar_t	gl_nocolors;
352 
353 extern	cvar_t	gl_subdivide_size;
354 
355 //johnfitz -- polygon offset
356 #define OFFSET_NONE 0
357 #define OFFSET_DECAL 1
358 
359 //johnfitz -- rendering statistics
360 extern unsigned int rs_brushpolys, rs_aliaspolys, rs_skypolys, rs_particles, rs_fogpolys;
361 extern unsigned int rs_dynamiclightmaps, rs_brushpasses, rs_aliaspasses, rs_skypasses;
362 extern float rs_megatexels;
363 
364 extern size_t total_device_vulkan_allocation_size;
365 extern size_t total_host_vulkan_allocation_size;
366 
367 //johnfitz -- track developer statistics that vary every frame
368 extern cvar_t devstats;
369 typedef struct {
370 	int		packetsize;
371 	int		edicts;
372 	int		visedicts;
373 	int		efrags;
374 	int		tempents;
375 	int		beams;
376 	int		dlights;
377 } devstats_t;
378 extern devstats_t dev_stats, dev_peakstats;
379 
380 //ohnfitz -- reduce overflow warning spam
381 typedef struct {
382 	double	packetsize;
383 	double	efrags;
384 	double	beams;
385 	double	varstring;
386 } overflowtimes_t;
387 extern overflowtimes_t dev_overflows; //this stores the last time overflow messages were displayed, not the last time overflows occured
388 #define CONSOLE_RESPAM_TIME 3 // seconds between repeated warning messages
389 
390 typedef struct
391 {
392 	float	position[3];
393 	float	texcoord[2];
394 	byte	color[4];
395 } basicvertex_t;
396 
397 //johnfitz -- moved here from r_brush.c
398 extern int gl_lightmap_format, lightmap_bytes;
399 
400 #define LMBLOCK_WIDTH	1024	//FIXME: make dynamic. if we have a decent card there's no real reason not to use 4k or 16k (assuming there's no lightstyles/dynamics that need uploading...)
401 #define LMBLOCK_HEIGHT	1024	//Alternatively, use texture arrays, which would avoid the need to switch textures as often.
402 
403 typedef struct glRect_s {
404 	unsigned short l,t,w,h;
405 } glRect_t;
406 struct lightmap_s
407 {
408 	gltexture_t *texture;
409 	qboolean	modified;
410 	glRect_t	rectchange;
411 
412 	// the lightmap texture data needs to be kept in
413 	// main memory so texsubimage can update properly
414 	byte		*data;//[4*LMBLOCK_WIDTH*LMBLOCK_HEIGHT];
415 };
416 extern struct lightmap_s *lightmaps;
417 extern int lightmap_count;	//allocated lightmaps
418 
419 extern qboolean r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz
420 
421 extern float	map_wateralpha, map_lavaalpha, map_telealpha, map_slimealpha; //ericw
422 extern float	map_fallbackalpha; //spike -- because we might want r_wateralpha to apply to teleporters while water itself wasn't watervised
423 
424 //johnfitz -- fog functions called from outside gl_fog.c
425 void Fog_ParseServerMessage (void);
426 float *Fog_GetColor (void);
427 float Fog_GetDensity (void);
428 void Fog_EnableGFog (void);
429 void Fog_DisableGFog (void);
430 void Fog_SetupFrame (void);
431 void Fog_NewMap (void);
432 void Fog_Init (void);
433 
434 void R_NewGame (void);
435 
436 void R_AnimateLight (void);
437 void R_MarkSurfaces (void);
438 qboolean R_CullBox (vec3_t emins, vec3_t emaxs);
439 void R_StoreEfrags (efrag_t **ppefrag);
440 qboolean R_CullModelForEntity (entity_t *e);
441 void R_RotateForEntity (float matrix[16], vec3_t origin, vec3_t angles);
442 void R_MarkLights (dlight_t *light, int num, mnode_t *node);
443 
444 void R_InitParticles (void);
445 void R_DrawParticles (void);
446 void CL_RunParticles (void);
447 void R_ClearParticles (void);
448 
449 void R_TranslatePlayerSkin (int playernum);
450 void R_TranslateNewPlayerSkin (int playernum); //johnfitz -- this handles cases when the actual texture changes
451 void R_UpdateWarpTextures (void);
452 
453 void R_DrawWorld (void);
454 void R_DrawAliasModel (entity_t *e);
455 void R_DrawBrushModel (entity_t *e);
456 void R_DrawSpriteModel (entity_t *e);
457 
458 void R_DrawTextureChains_Water (qmodel_t *model, entity_t *ent, texchain_t chain);
459 
460 void GL_BuildLightmaps (void);
461 void GL_DeleteBModelVertexBuffer (void);
462 void GL_BuildBModelVertexBuffer (void);
463 void GLMesh_LoadVertexBuffers (void);
464 void GLMesh_DeleteVertexBuffers (void);
465 
466 int R_LightPoint (vec3_t p, lightcache_t *cache);
467 
468 void GL_SubdivideSurface (msurface_t *fa);
469 void R_BuildLightMap (msurface_t *surf, byte *dest, int stride);
470 void R_RenderDynamicLightmaps (msurface_t *fa);
471 void R_UploadLightmaps (void);
472 
473 void R_DrawWorld_ShowTris(void);
474 void R_DrawBrushModel_ShowTris (entity_t *e);
475 void R_DrawAliasModel_ShowTris (entity_t *e);
476 void R_DrawParticles_ShowTris(void);
477 void R_DrawSpriteModel_ShowTris (entity_t *e);
478 
479 void DrawGLPoly (glpoly_t *p, float color[3], float alpha);
480 void GL_MakeAliasModelDisplayLists (qmodel_t *m, aliashdr_t *hdr);
481 
482 void Sky_Init (void);
483 void Sky_ClearAll (void);
484 void Sky_DrawSky (void);
485 void Sky_NewMap (void);
486 void Sky_LoadTexture (texture_t *mt);
487 void Sky_LoadTextureQ64 (texture_t *mt);
488 void Sky_LoadSkyBox (const char *name);
489 
490 void R_ClearTextureChains (qmodel_t *mod, texchain_t chain);
491 void R_ChainSurface (msurface_t *surf, texchain_t chain);
492 void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain);
493 void R_DrawWorld_Water (void);
494 
495 float GL_WaterAlphaForSurface (msurface_t *fa);
496 
497 int GL_MemoryTypeFromProperties(uint32_t type_bits, VkFlags requirements_mask, VkFlags preferred_mask);
498 
499 void R_CreateDescriptorPool();
500 void R_CreateDescriptorSetLayouts();
501 void R_InitSamplers();
502 void R_CreatePipelineLayouts();
503 void R_CreatePipelines();
504 void R_DestroyPipelines();
505 
506 
507 #define MAX_PUSH_CONSTANT_SIZE 128 // Vulkan guaranteed minimum maxPushConstantsSize
508 
R_BindPipeline(VkPipelineBindPoint bind_point,vulkan_pipeline_t pipeline)509 static inline void R_BindPipeline(VkPipelineBindPoint bind_point, vulkan_pipeline_t pipeline)
510 {
511 	static byte zeroes[MAX_PUSH_CONSTANT_SIZE];
512 	assert(pipeline.handle != VK_NULL_HANDLE);
513 	assert(pipeline.layout.handle != VK_NULL_HANDLE);
514 	assert(vulkan_globals.current_pipeline.layout.push_constant_range.size <= MAX_PUSH_CONSTANT_SIZE);
515 	if(vulkan_globals.current_pipeline.handle != pipeline.handle) {
516 		vulkan_globals.vk_cmd_bind_pipeline(vulkan_globals.command_buffer, bind_point, pipeline.handle);
517 		if ((vulkan_globals.current_pipeline.layout.push_constant_range.stageFlags != pipeline.layout.push_constant_range.stageFlags)
518 			|| (vulkan_globals.current_pipeline.layout.push_constant_range.size != pipeline.layout.push_constant_range.size))
519 			vulkan_globals.vk_cmd_push_constants(vulkan_globals.command_buffer, pipeline.layout.handle, pipeline.layout.push_constant_range.stageFlags, 0, pipeline.layout.push_constant_range.size, zeroes);
520 		vulkan_globals.current_pipeline = pipeline;
521 	}
522 }
523 
R_PushConstants(VkShaderStageFlags stage_flags,int offset,int size,const void * data)524 static inline void R_PushConstants(VkShaderStageFlags stage_flags, int offset, int size, const void * data)
525 {
526 	vulkan_globals.vk_cmd_push_constants(vulkan_globals.command_buffer, vulkan_globals.current_pipeline.layout.handle, stage_flags, offset, size, data);
527 }
528 
R_BeginDebugUtilsLabel(const char * name)529 static inline void R_BeginDebugUtilsLabel(const char * name)
530 {
531 #ifdef _DEBUG
532 	VkDebugUtilsLabelEXT label;
533 	memset(&label, 0, sizeof(label));
534 	label.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
535 	label.pLabelName = name;
536 	if (vulkan_globals.vk_cmd_begin_debug_utils_label)
537 		vulkan_globals.vk_cmd_begin_debug_utils_label(vulkan_globals.command_buffer, &label);
538 #endif
539 }
540 
R_EndDebugUtilsLabel()541 static inline void R_EndDebugUtilsLabel()
542 {
543 #ifdef _DEBUG
544 	if (vulkan_globals.vk_cmd_end_debug_utils_label)
545 		vulkan_globals.vk_cmd_end_debug_utils_label(vulkan_globals.command_buffer);
546 #endif
547 }
548 
549 void R_AllocateVulkanMemory(vulkan_memory_t *, VkMemoryAllocateInfo *, vulkan_memory_type_t);
550 void R_FreeVulkanMemory(vulkan_memory_t *);
551 
552 VkDescriptorSet R_AllocateDescriptorSet(vulkan_desc_set_layout_t * layout);
553 void R_FreeDescriptorSet(VkDescriptorSet desc_set, vulkan_desc_set_layout_t * layout);
554 
555 void R_InitStagingBuffers();
556 void R_SubmitStagingBuffers();
557 byte * R_StagingAllocate(int size, int alignment, VkCommandBuffer * command_buffer, VkBuffer * buffer, int * buffer_offset);
558 
559 void R_InitGPUBuffers();
560 void R_SwapDynamicBuffers();
561 void R_FlushDynamicBuffers();
562 void R_CollectDynamicBufferGarbage();
563 void R_CollectMeshBufferGarbage();
564 byte * R_VertexAllocate(int size, VkBuffer * buffer, VkDeviceSize * buffer_offset);
565 byte * R_IndexAllocate(int size, VkBuffer * buffer, VkDeviceSize * buffer_offset);
566 byte * R_UniformAllocate(int size, VkBuffer * buffer, uint32_t * buffer_offset, VkDescriptorSet * descriptor_set);
567 
568 void GL_SetObjectName(uint64_t object, VkObjectType object_type, const char * name);
569 
570 #endif	/* GLQUAKE_H */
571