vkQuake2 doxygen  1.0 dev
vk_rmain.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 Copyright (C) 2018-2019 Krzysztof Kondrak
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14 See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 */
21 // vk_rmain.c
22 #include "vk_local.h"
23 
25 
27 
29 
32 
33 image_t *r_notexture; // use for bad textures
34 image_t *r_particletexture; // little dot for particles
35 
38 
40 
41 int r_visframecount; // bumped when going to a new PVS
42 int r_framecount; // used for dlight push checking
43 
45 
46 float v_blend[4]; // final blending color
47 
48 void Vk_Strings_f(void);
49 void Vk_Mem_f(void);
50 
51 //
52 // view origin
53 //
58 
63 float r_view_matrix[16];
65 // correction matrix for perspective in Vulkan
66 static float r_vulkan_correction[16] = { 1.f, 0.f, 0.f, 0.f,
67  0.f, -1.f, 0.f, 0.f,
68  0.f, 0.f, .5f, 0.f,
69  0.f, 0.f, .5f, 1.f
70  };
71 //
72 // screen size info
73 //
75 
77 
87 
88 cvar_t *r_lightlevel; // FIXME: This is a HACK to get the client's light level
89 
123 
128 
129 /*
130 =================
131 R_CullBox
132 
133 Returns true if the box is completely outside the frustom
134 =================
135 */
137 {
138  int i;
139 
140  if (r_nocull->value)
141  return false;
142 
143  for (i=0 ; i<4 ; i++)
144  if ( BOX_ON_PLANE_SIDE(mins, maxs, &frustum[i]) == 2)
145  return true;
146  return false;
147 }
148 
149 
150 void R_RotateForEntity (entity_t *e, float *mvMatrix)
151 {
152  Mat_Rotate(mvMatrix, -e->angles[2], 1.f, 0.f, 0.f);
153  Mat_Rotate(mvMatrix, -e->angles[0], 0.f, 1.f, 0.f);
154  Mat_Rotate(mvMatrix, e->angles[1], 0.f, 0.f, 1.f);
155  Mat_Translate(mvMatrix, e->origin[0], e->origin[1], e->origin[2]);
156 }
157 
158 /*
159 =============================================================
160 
161  SPRITE MODELS
162 
163 =============================================================
164 */
165 
166 
167 /*
168 =================
169 R_DrawSpriteModel
170 
171 =================
172 */
174 {
175  float alpha = 1.0F;
176  vec3_t point;
177  dsprframe_t *frame;
178  float *up, *right;
179  dsprite_t *psprite;
180 
181  // don't even bother culling, because it's just a single
182  // polygon without a surface cache
183 
184  psprite = (dsprite_t *)currentmodel->extradata;
185 
186  e->frame %= psprite->numframes;
187 
188  frame = &psprite->frames[e->frame];
189 
190  // normal sprite
191  up = vup;
192  right = vright;
193 
194  if (e->flags & RF_TRANSLUCENT)
195  alpha = e->alpha;
196 
197  vec3_t spriteQuad[4];
198 
199  VectorMA(e->origin, -frame->origin_y, up, point);
200  VectorMA(point, -frame->origin_x, right, spriteQuad[0]);
201  VectorMA(e->origin, frame->height - frame->origin_y, up, point);
202  VectorMA(point, -frame->origin_x, right, spriteQuad[1]);
203  VectorMA(e->origin, frame->height - frame->origin_y, up, point);
204  VectorMA(point, frame->width - frame->origin_x, right, spriteQuad[2]);
205  VectorMA(e->origin, -frame->origin_y, up, point);
206  VectorMA(point, frame->width - frame->origin_x, right, spriteQuad[3]);
207 
208  float quadVerts[] = { spriteQuad[0][0], spriteQuad[0][1], spriteQuad[0][2], 0.f, 1.f,
209  spriteQuad[1][0], spriteQuad[1][1], spriteQuad[1][2], 0.f, 0.f,
210  spriteQuad[2][0], spriteQuad[2][1], spriteQuad[2][2], 1.f, 0.f,
211  spriteQuad[0][0], spriteQuad[0][1], spriteQuad[0][2], 0.f, 1.f,
212  spriteQuad[2][0], spriteQuad[2][1], spriteQuad[2][2], 1.f, 0.f,
213  spriteQuad[3][0], spriteQuad[3][1], spriteQuad[3][2], 1.f, 1.f };
214 
215  vkCmdPushConstants(vk_activeCmdbuffer, vk_drawSpritePipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, sizeof(r_viewproj_matrix), sizeof(float), &alpha);
217 
218  VkBuffer vbo;
219  VkDeviceSize vboOffset;
220  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(quadVerts), &vbo, &vboOffset);
221  memcpy(vertData, quadVerts, sizeof(quadVerts));
222 
223  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
224  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawSpritePipeline.layout, 0, 1, &currentmodel->skins[e->frame]->vk_texture.descriptorSet, 0, NULL);
225  vkCmdDraw(vk_activeCmdbuffer, 6, 1, 0, 0);
226 }
227 
228 //==================================================================================
229 
230 /*
231 =============
232 R_DrawNullModel
233 =============
234 */
235 void R_DrawNullModel (void)
236 {
238  int i,j;
239 
241  shadelight[0] = shadelight[1] = shadelight[2] = 1.0F;
242  else
244 
245  float model[16];
246  Mat_Identity(model);
248 
249  vec3_t verts[24];
250  verts[0][0] = 0.f;
251  verts[0][1] = 0.f;
252  verts[0][2] = -16.f;
253  verts[1][0] = shadelight[0];
254  verts[1][1] = shadelight[1];
255  verts[1][2] = shadelight[2];
256 
257  for (i = 2, j = 0; i < 12; i+=2, j++)
258  {
259  verts[i][0] = 16 * cos(j*M_PI / 2);
260  verts[i][1] = 16 * sin(j*M_PI / 2);
261  verts[i][2] = 0.f;
262  verts[i+1][0] = shadelight[0];
263  verts[i+1][1] = shadelight[1];
264  verts[i+1][2] = shadelight[2];
265  }
266 
267  verts[12][0] = 0.f;
268  verts[12][1] = 0.f;
269  verts[12][2] = 16.f;
270  verts[13][0] = shadelight[0];
271  verts[13][1] = shadelight[1];
272  verts[13][2] = shadelight[2];
273 
274  for (i = 23, j = 4; i > 13; i-=2, j--)
275  {
276  verts[i-1][0] = 16 * cos(j*M_PI / 2);
277  verts[i-1][1] = 16 * sin(j*M_PI / 2);
278  verts[i-1][2] = 0.f;
279  verts[i][0] = shadelight[0];
280  verts[i][1] = shadelight[1];
281  verts[i][2] = shadelight[2];
282  }
283 
284  VkBuffer vbo;
285  VkDeviceSize vboOffset;
286  uint32_t uboOffset;
287  VkDescriptorSet uboDescriptorSet;
288  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(verts), &vbo, &vboOffset);
289  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(model), &uboOffset, &uboDescriptorSet);
290  memcpy(vertData, verts, sizeof(verts));
291  memcpy(uboData, model, sizeof(model));
292 
294  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawNullModelPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
295  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
296  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo(12), 0, VK_INDEX_TYPE_UINT16);
297  vkCmdDrawIndexed(vk_activeCmdbuffer, 12, 1, 0, 0, 0);
298  vkCmdDrawIndexed(vk_activeCmdbuffer, 12, 1, 0, 6, 0);
299 }
300 
301 /*
302 =============
303 R_DrawEntitiesOnList
304 =============
305 */
307 {
308  int i;
309 
310  if (!r_drawentities->value)
311  return;
312 
313  // draw non-transparent first
314  for (i = 0; i<r_newrefdef.num_entities; i++)
315  {
318  continue; // solid
319 
320  if (currententity->flags & RF_BEAM)
321  {
323  }
324  else
325  {
327  if (!currentmodel)
328  {
329  R_DrawNullModel();
330  continue;
331  }
332  switch (currentmodel->type)
333  {
334  case mod_alias:
336  break;
337  case mod_brush:
339  break;
340  case mod_sprite:
342  break;
343  default:
344  ri.Sys_Error(ERR_DROP, "Bad modeltype");
345  break;
346  }
347  }
348  }
349 
350  // draw transparent entities
351  // we could sort these if it ever becomes a problem...
352  for (i = 0; i<r_newrefdef.num_entities; i++)
353  {
356  continue; // solid
357 
358  if (currententity->flags & RF_BEAM)
359  {
361  }
362  else
363  {
365 
366  if (!currentmodel)
367  {
368  R_DrawNullModel();
369  continue;
370  }
371  switch (currentmodel->type)
372  {
373  case mod_alias:
375  break;
376  case mod_brush:
378  break;
379  case mod_sprite:
381  break;
382  default:
383  ri.Sys_Error(ERR_DROP, "Bad modeltype");
384  break;
385  }
386  }
387  }
388 }
389 
390 /*
391 ** Vk_DrawParticles
392 **
393 */
394 void Vk_DrawParticles( int num_particles, const particle_t particles[], const unsigned colortable[768] )
395 {
396  const particle_t *p;
397  int i;
398  vec3_t up, right;
399  float scale;
400  byte color[4];
401 
402  if (!num_particles)
403  return;
404 
405  VectorScale(vup, 1.5, up);
406  VectorScale(vright, 1.5, right);
407 
408  typedef struct {
409  float x,y,z,r,g,b,a,u,v;
410  } pvertex;
411 
412  static pvertex visibleParticles[MAX_PARTICLES*3];
413 
414  for (p = particles, i = 0; i < num_particles; i++, p++)
415  {
416  // hack a scale up to keep particles from disapearing
417  scale = (p->origin[0] - r_origin[0]) * vpn[0] +
418  (p->origin[1] - r_origin[1]) * vpn[1] +
419  (p->origin[2] - r_origin[2]) * vpn[2];
420 
421  if (scale < 20)
422  scale = 1;
423  else
424  scale = 1 + scale * 0.004;
425 
426  *(int *)color = colortable[p->color];
427 
428  int idx = i * 3;
429  float r = color[0] / 255.f;
430  float g = color[1] / 255.f;
431  float b = color[2] / 255.f;
432 
433  visibleParticles[idx].x = p->origin[0];
434  visibleParticles[idx].y = p->origin[1];
435  visibleParticles[idx].z = p->origin[2];
436  visibleParticles[idx].r = r;
437  visibleParticles[idx].g = g;
438  visibleParticles[idx].b = b;
439  visibleParticles[idx].a = p->alpha;
440  visibleParticles[idx].u = 0.0625;
441  visibleParticles[idx].v = 0.0625;
442 
443  visibleParticles[idx + 1].x = p->origin[0] + up[0] * scale;
444  visibleParticles[idx + 1].y = p->origin[1] + up[1] * scale;
445  visibleParticles[idx + 1].z = p->origin[2] + up[2] * scale;
446  visibleParticles[idx + 1].r = r;
447  visibleParticles[idx + 1].g = g;
448  visibleParticles[idx + 1].b = b;
449  visibleParticles[idx + 1].a = p->alpha;
450  visibleParticles[idx + 1].u = 1.0625;
451  visibleParticles[idx + 1].v = 0.0625;
452 
453  visibleParticles[idx + 2].x = p->origin[0] + right[0] * scale;
454  visibleParticles[idx + 2].y = p->origin[1] + right[1] * scale;
455  visibleParticles[idx + 2].z = p->origin[2] + right[2] * scale;
456  visibleParticles[idx + 2].r = r;
457  visibleParticles[idx + 2].g = g;
458  visibleParticles[idx + 2].b = b;
459  visibleParticles[idx + 2].a = p->alpha;
460  visibleParticles[idx + 2].u = 0.0625;
461  visibleParticles[idx + 2].v = 1.0625;
462  }
463 
465 
466  VkBuffer vbo;
467  VkDeviceSize vboOffset;
468  uint8_t *vertData = QVk_GetVertexBuffer(3 * sizeof(pvertex) * num_particles, &vbo, &vboOffset);
469  memcpy(vertData, &visibleParticles, 3 * sizeof(pvertex) * num_particles);
470 
471  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawParticlesPipeline.layout, 0, 1, &r_particletexture->vk_texture.descriptorSet, 0, NULL);
472  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
473  vkCmdDraw(vk_activeCmdbuffer, 3 * num_particles, 1, 0, 0);
474 }
475 
476 /*
477 ===============
478 R_DrawParticles
479 ===============
480 */
481 void R_DrawParticles (void)
482 {
484  {
485  int i;
486  unsigned char color[4];
487  const particle_t *p;
488 
490  return;
491 
492  typedef struct {
493  float x, y, z, r, g, b, a;
494  } ppoint;
495 
496  struct {
497  float particleSize;
498  float particleScale;
499  float minPointSize;
500  float maxPointSize;
501  float att_a;
502  float att_b;
503  float att_c;
504  } particleUbo;
505 
506  particleUbo.particleSize = vk_particle_size->value;
507  particleUbo.particleScale = vid.width * ri.Cvar_Get("viewsize", "100", CVAR_ARCHIVE)->value / 102400;
508  particleUbo.minPointSize = vk_particle_min_size->value;
509  particleUbo.maxPointSize = vk_particle_max_size->value;
510  particleUbo.att_a = vk_particle_att_a->value;
511  particleUbo.att_b = vk_particle_att_b->value;
512  particleUbo.att_c = vk_particle_att_c->value;
513 
514  static ppoint visibleParticles[MAX_PARTICLES];
515 
516  for (i = 0, p = r_newrefdef.particles; i < r_newrefdef.num_particles; i++, p++)
517  {
518  *(int *)color = d_8to24table[p->color];
519 
520  float r = color[0] / 255.f;
521  float g = color[1] / 255.f;
522  float b = color[2] / 255.f;
523 
524  visibleParticles[i].x = p->origin[0];
525  visibleParticles[i].y = p->origin[1];
526  visibleParticles[i].z = p->origin[2];
527  visibleParticles[i].r = r;
528  visibleParticles[i].g = g;
529  visibleParticles[i].b = b;
530  visibleParticles[i].a = p->alpha;
531  }
532 
534 
535  VkBuffer vbo;
536  VkDeviceSize vboOffset;
537  uint32_t uboOffset;
538  VkDescriptorSet uboDescriptorSet;
539  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(ppoint) * r_newrefdef.num_particles, &vbo, &vboOffset);
540  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(particleUbo), &uboOffset, &uboDescriptorSet);
541  memcpy(vertData, &visibleParticles, sizeof(ppoint) * r_newrefdef.num_particles);
542  memcpy(uboData, &particleUbo, sizeof(particleUbo));
543  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPointParticlesPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
544  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
545  vkCmdDraw(vk_activeCmdbuffer, r_newrefdef.num_particles, 1, 0, 0);
546  }
547  else
548  {
550  }
551 }
552 
553 /*
554 ============
555 R_PolyBlend
556 ============
557 */
558 void R_PolyBlend (void)
559 {
560  if (!vk_polyblend->value)
561  return;
562  if (!v_blend[3])
563  return;
564 
565  float polyTransform[] = { 0.f, 0.f, vid.width, vid.height, v_blend[0], v_blend[1], v_blend[2], v_blend[3] };
566  QVk_DrawColorRect(polyTransform, sizeof(polyTransform), RP_WORLD);
567 }
568 
569 //=======================================================================
570 
572 {
573  int bits, j;
574 
575  // for fast box on planeside test
576 
577  bits = 0;
578  for (j = 0; j<3; j++)
579  {
580  if (out->normal[j] < 0)
581  bits |= 1 << j;
582  }
583  return bits;
584 }
585 
586 
587 void R_SetFrustum (float fovx, float fovy)
588 {
589  // rotate VPN right by FOV_X/2 degrees
590  RotatePointAroundVector(frustum[0].normal, vup, vpn, -(90 - fovx / 2));
591  // rotate VPN left by FOV_X/2 degrees
592  RotatePointAroundVector(frustum[1].normal, vup, vpn, 90 - fovx / 2);
593  // rotate VPN up by FOV_X/2 degrees
594  RotatePointAroundVector(frustum[2].normal, vright, vpn, 90 - fovy / 2);
595  // rotate VPN down by FOV_X/2 degrees
596  RotatePointAroundVector(frustum[3].normal, vright, vpn, -(90 - fovy / 2));
597 
598  for (int i = 0; i < 4; i++)
599  {
601  frustum[i].dist = DotProduct(r_origin, frustum[i].normal);
603  }
604 }
605 
606 //=======================================================================
607 
608 /*
609 ===============
610 R_SetupFrame
611 ===============
612 */
613 void R_SetupFrame (void)
614 {
615  int i;
616  mleaf_t *leaf;
617 
618  r_framecount++;
619 
620  // build the transformation matrix for the given view angles
622 
624 
625  // current viewcluster
627  {
632 
633  // check above and below so crossing solid water doesn't draw wrong
634  if (!leaf->contents)
635  { // look down a bit
636  vec3_t temp;
637 
638  VectorCopy(r_origin, temp);
639  temp[2] -= 16;
640  leaf = Mod_PointInLeaf(temp, r_worldmodel);
641  if (!(leaf->contents & CONTENTS_SOLID) &&
642  (leaf->cluster != r_viewcluster2))
643  r_viewcluster2 = leaf->cluster;
644  }
645  else
646  { // look up a bit
647  vec3_t temp;
648 
649  VectorCopy(r_origin, temp);
650  temp[2] += 16;
651  leaf = Mod_PointInLeaf(temp, r_worldmodel);
652  if (!(leaf->contents & CONTENTS_SOLID) &&
653  (leaf->cluster != r_viewcluster2))
654  r_viewcluster2 = leaf->cluster;
655  }
656  }
657 
658  for (i = 0; i < 4; i++)
660 
661  c_brush_polys = 0;
662  c_alias_polys = 0;
663 
664  // clear out the portion of the screen that the NOWORLDMODEL defines
665  // unlike OpenGL, draw a rectangle in proper location - it's easier to do in Vulkan
667  {
668  float clearArea[] = { (float)r_newrefdef.x / vid.width, (float)r_newrefdef.y / vid.height,
669  (float)r_newrefdef.width / vid.width, (float)r_newrefdef.height / vid.height,
670  .3f, .3f, .3f, 1.f };
671  QVk_DrawColorRect(clearArea, sizeof(clearArea), RP_UI);
672  }
673 }
674 
675 void Mat_Identity(float *matrix)
676 {
677  matrix[0] = 1.f;
678  matrix[1] = 0.f;
679  matrix[2] = 0.f;
680  matrix[3] = 0.f;
681  matrix[4] = 0.f;
682  matrix[5] = 1.f;
683  matrix[6] = 0.f;
684  matrix[7] = 0.f;
685  matrix[8] = 0.f;
686  matrix[9] = 0.f;
687  matrix[10] = 1.f;
688  matrix[11] = 0.f;
689  matrix[12] = 0.f;
690  matrix[13] = 0.f;
691  matrix[14] = 0.f;
692  matrix[15] = 1.f;
693 }
694 
695 void Mat_Mul(float *m1, float *m2, float *res)
696 {
697  float mul[16] = { m1[0] * m2[0] + m1[1] * m2[4] + m1[2] * m2[8] + m1[3] * m2[12],
698  m1[0] * m2[1] + m1[1] * m2[5] + m1[2] * m2[9] + m1[3] * m2[13],
699  m1[0] * m2[2] + m1[1] * m2[6] + m1[2] * m2[10] + m1[3] * m2[14],
700  m1[0] * m2[3] + m1[1] * m2[7] + m1[2] * m2[11] + m1[3] * m2[15],
701  m1[4] * m2[0] + m1[5] * m2[4] + m1[6] * m2[8] + m1[7] * m2[12],
702  m1[4] * m2[1] + m1[5] * m2[5] + m1[6] * m2[9] + m1[7] * m2[13],
703  m1[4] * m2[2] + m1[5] * m2[6] + m1[6] * m2[10] + m1[7] * m2[14],
704  m1[4] * m2[3] + m1[5] * m2[7] + m1[6] * m2[11] + m1[7] * m2[15],
705  m1[8] * m2[0] + m1[9] * m2[4] + m1[10] * m2[8] + m1[11] * m2[12],
706  m1[8] * m2[1] + m1[9] * m2[5] + m1[10] * m2[9] + m1[11] * m2[13],
707  m1[8] * m2[2] + m1[9] * m2[6] + m1[10] * m2[10] + m1[11] * m2[14],
708  m1[8] * m2[3] + m1[9] * m2[7] + m1[10] * m2[11] + m1[11] * m2[15],
709  m1[12] * m2[0] + m1[13] * m2[4] + m1[14] * m2[8] + m1[15] * m2[12],
710  m1[12] * m2[1] + m1[13] * m2[5] + m1[14] * m2[9] + m1[15] * m2[13],
711  m1[12] * m2[2] + m1[13] * m2[6] + m1[14] * m2[10] + m1[15] * m2[14],
712  m1[12] * m2[3] + m1[13] * m2[7] + m1[14] * m2[11] + m1[15] * m2[15]
713  };
714 
715  memcpy(res, mul, sizeof(float) * 16);
716 }
717 
718 void Mat_Translate(float *matrix, float x, float y, float z)
719 {
720  float t[16] = { 1.f, 0.f, 0.f, 0.f,
721  0.f, 1.f, 0.f, 0.f,
722  0.f, 0.f, 1.f, 0.f,
723  x, y, z, 1.f };
724 
725  Mat_Mul(matrix, t, matrix);
726 }
727 
728 void Mat_Rotate(float *matrix, float deg, float x, float y, float z)
729 {
730  double c = cos(deg * M_PI / 180.0);
731  double s = sin(deg * M_PI / 180.0);
732  double cd = 1.0 - c;
733  vec3_t r = { x, y, z };
735 
736  float rot[16] = { r[0]*r[0]*cd + c, r[1]*r[0]*cd + r[2]*s, r[0]*r[2]*cd - r[1]*s, 0.f,
737  r[0]*r[1]*cd - r[2]*s, r[1]*r[1]*cd + c, r[1]*r[2]*cd + r[0]*s, 0.f,
738  r[0]*r[2]*cd + r[1]*s, r[1]*r[2]*cd - r[0]*s, r[2]*r[2]*cd + c, 0.f,
739  0.f, 0.f, 0.f, 1.f
740  };
741 
742  Mat_Mul(matrix, rot, matrix);
743 }
744 
745 void Mat_Scale(float *matrix, float x, float y, float z)
746 {
747  float s[16] = { x, 0.f, 0.f, 0.f,
748  0.f, y, 0.f, 0.f,
749  0.f, 0.f, z, 0.f,
750  0.f, 0.f, 0.f, 1.f
751  };
752 
753  Mat_Mul(matrix, s, matrix);
754 }
755 
756 void Mat_Perspective(float *matrix, float *correction_matrix, float fovy, float aspect,
757  float zNear, float zFar)
758 {
759  float xmin, xmax, ymin, ymax;
760 
761  ymax = zNear * tan(fovy * M_PI / 360.0);
762  ymin = -ymax;
763 
764  xmin = ymin * aspect;
765  xmax = ymax * aspect;
766 
767  xmin += -(2 * vk_state.camera_separation) / zNear;
768  xmax += -(2 * vk_state.camera_separation) / zNear;
769 
770  float proj[16];
771  memset(proj, 0, sizeof(float) * 16);
772  proj[0] = 2.f * zNear / (xmax - xmin);
773  proj[2] = (xmax + xmin) / (xmax - xmin);
774  proj[5] = 2.f * zNear / (ymax - ymin);
775  proj[6] = (ymax + ymin) / (ymax - ymin);
776  proj[10] = -(zFar + zNear) / (zFar - zNear);
777  proj[11] = -1.f;
778  proj[14] = -2.f * zFar * zNear / (zFar - zNear);
779 
780  // Convert projection matrix to Vulkan coordinate system (https://matthewwellings.com/blog/the-new-vulkan-coordinate-system/)
781  Mat_Mul(proj, correction_matrix, matrix);
782 }
783 
784 void Mat_Ortho(float *matrix, float left, float right, float bottom, float top,
785  float zNear, float zFar)
786 {
787  float proj[16];
788  memset(proj, 0, sizeof(float) * 16);
789  proj[0] = 2.f / (right - left);
790  proj[3] = (right + left) / (right - left);
791  proj[5] = 2.f / (top - bottom);
792  proj[7] = (top + bottom) / (top - bottom);
793  proj[10] = -2.f / (zFar - zNear);
794  proj[11] = -(zFar + zNear) / (zFar - zNear);
795  proj[15] = 1.f;
796 
797  // Convert projection matrix to Vulkan coordinate system (https://matthewwellings.com/blog/the-new-vulkan-coordinate-system/)
798  Mat_Mul(proj, r_vulkan_correction, matrix);
799 }
800 
801 
802 /*
803 =============
804 R_SetupVulkan
805 =============
806 */
807 void R_SetupVulkan (void)
808 {
809  int x, x2, y2, y, w, h;
810 
811  //
812  // set up viewport
813  //
814  x = floor(r_newrefdef.x * vid.width / vid.width);
815  x2 = ceil((r_newrefdef.x + r_newrefdef.width) * vid.width / vid.width);
816  y = floor(vid.height - r_newrefdef.y * vid.height / vid.height);
818 
819  w = x2 - x;
820  h = y - y2;
821 
822  VkViewport viewport = {
823  .x = x,
824  .y = vid.height - h - y2,
825  .width = w,
826  .height = h,
827  .minDepth = 0.f,
828  .maxDepth = 1.f,
829  };
830  vkCmdSetViewport(vk_activeCmdbuffer, 0, 1, &viewport);
831 
832  // set up projection matrix
837 
839 
840  // set up view matrix
842  // put Z going up
844  Mat_Rotate(r_view_matrix, -r_newrefdef.viewangles[1], 0.f, 0.f, 1.f);
845  Mat_Rotate(r_view_matrix, -r_newrefdef.viewangles[0], 0.f, 1.f, 0.f);
846  Mat_Rotate(r_view_matrix, -r_newrefdef.viewangles[2], 1.f, 0.f, 0.f);
847  Mat_Rotate(r_view_matrix, 90.f, 0.f, 0.f, 1.f);
848  Mat_Rotate(r_view_matrix, -90.f, 1.f, 0.f, 0.f);
849 
850  // precalculate view-projection matrix
852  // view-projection matrix will always be stored as the first push constant item, so set no offset
853  vkCmdPushConstants(vk_activeCmdbuffer, vk_drawTexQuadPipeline.layout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(r_viewproj_matrix), r_viewproj_matrix);
854 }
855 
856 void R_Flash( void )
857 {
858  R_PolyBlend ();
859 }
860 
861 /*
862 ================
863 R_RenderView
864 
865 r_newrefdef must be set before the first call
866 ================
867 */
869 {
870  if (r_norefresh->value)
871  return;
872 
873  r_newrefdef = *fd;
874 
876  ri.Sys_Error(ERR_DROP, "R_RenderView: NULL worldmodel");
877 
878  if (r_speeds->value)
879  {
880  c_brush_polys = 0;
881  c_alias_polys = 0;
882  }
883 
884  VkRect2D scissor = {
885  .offset = { r_newrefdef.x, r_newrefdef.y },
886  .extent = { r_newrefdef.width, r_newrefdef.height }
887  };
888 
889  vkCmdSetScissor(vk_activeCmdbuffer, 0, 1, &scissor);
890 
891  R_PushDlights();
892 
893  // added for compatibility sake with OpenGL implementation - don't use it!
894  if (vk_finish->value)
895  vkDeviceWaitIdle(vk_device.logical);
896 
897  R_SetupFrame();
898 
899  R_SetupVulkan();
900 
901  R_MarkLeaves(); // done here so we know if we're in water
902 
903  R_DrawWorld();
904 
906 
907  R_RenderDlights();
908 
909  R_DrawParticles();
910 
912 
913  R_Flash();
914 
915  if (r_speeds->value)
916  {
917  ri.Con_Printf(PRINT_ALL, "%4i wpoly %4i epoly %i tex %i lmaps\n",
922  }
923 }
924 
926 {
927  // this may happen if swapchain image acquisition fails
928  if (!vk_frameStarted)
929  return;
930 
931  // finish rendering world view to offsceen buffer
932  vkCmdEndRenderPass(vk_activeCmdbuffer);
933 
934  // apply postprocessing effects (underwater view warp if the player is submerged in liquid) to offscreen buffer
936  float pushConsts[] = { r_newrefdef.rdflags & RDF_UNDERWATER ? r_newrefdef.time : 0.f, viewsize->value / 100, vid.width, vid.height };
937  vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConsts), pushConsts);
938  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_worldWarpPipeline.layout, 0, 1, &vk_colorbuffer.descriptorSet, 0, NULL);
940  vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0);
941  vkCmdEndRenderPass(vk_activeCmdbuffer);
942 
943  // start drawing UI
945 }
946 
947 void R_SetVulkan2D (void)
948 {
949  // player configuration screen renders a model using the UI renderpass, so skip finishing RP_WORLD twice
952 
953  extern VkViewport vk_viewport;
954  extern VkRect2D vk_scissor;
955  vkCmdSetViewport(vk_activeCmdbuffer, 0, 1, &vk_viewport);
956  vkCmdSetScissor(vk_activeCmdbuffer, 0, 1, &vk_scissor);
957 
958  // first, blit offscreen color buffer with warped/postprocessed world view
959  // skip this step if we're in player config screen since it uses RP_UI and draws directly to swapchain
961  {
962  float pushConsts[] = { vk_postprocess->value, vid_gamma->value };
963  vkCmdPushConstants(vk_activeCmdbuffer, vk_postprocessPipeline.layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConsts), pushConsts);
964  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_postprocessPipeline.layout, 0, 1, &vk_colorbufferWarp.descriptorSet, 0, NULL);
966  vkCmdDraw(vk_activeCmdbuffer, 3, 1, 0, 0);
967  }
968 }
969 
970 
971 /*
972 ====================
973 R_SetLightLevel
974 
975 ====================
976 */
977 void R_SetLightLevel (void)
978 {
980 
982  return;
983 
984  // save off light value for server to look at (BIG HACK!)
985 
987 
988  // pick the greatest component, which should be the same
989  // as the mono value returned by software
990  if (shadelight[0] > shadelight[1])
991  {
992  if (shadelight[0] > shadelight[2])
993  r_lightlevel->value = 150 * shadelight[0];
994  else
995  r_lightlevel->value = 150 * shadelight[2];
996  }
997  else
998  {
999  if (shadelight[1] > shadelight[2])
1000  r_lightlevel->value = 150 * shadelight[1];
1001  else
1002  r_lightlevel->value = 150 * shadelight[2];
1003  }
1004 }
1005 
1006 /*
1007 @@@@@@@@@@@@@@@@@@@@@
1008 R_RenderFrame
1009 
1010 @@@@@@@@@@@@@@@@@@@@@
1011 */
1013 {
1014  R_RenderView( fd );
1015  R_SetLightLevel ();
1016  R_SetVulkan2D ();
1017 }
1018 
1019 
1020 void R_Register( void )
1021 {
1022  r_lefthand = ri.Cvar_Get("hand", "0", CVAR_USERINFO | CVAR_ARCHIVE);
1023  r_norefresh = ri.Cvar_Get("r_norefresh", "0", 0);
1024  r_fullbright = ri.Cvar_Get("r_fullbright", "0", 0);
1025  r_drawentities = ri.Cvar_Get("r_drawentities", "1", 0);
1026  r_drawworld = ri.Cvar_Get("r_drawworld", "1", 0);
1027  r_novis = ri.Cvar_Get("r_novis", "0", 0);
1028  r_nocull = ri.Cvar_Get("r_nocull", "0", 0);
1029  r_lerpmodels = ri.Cvar_Get("r_lerpmodels", "1", 0);
1030  r_speeds = ri.Cvar_Get("r_speeds", "0", 0);
1031  r_lightlevel = ri.Cvar_Get("r_lightlevel", "0", 0);
1032 #if defined(_DEBUG)
1033  vk_validation = ri.Cvar_Get("vk_validation", "2", 0);
1034 #else
1035  vk_validation = ri.Cvar_Get("vk_validation", "0", 0);
1036 #endif
1037  vk_mode = ri.Cvar_Get("vk_mode", "11", CVAR_ARCHIVE);
1038  vk_bitdepth = ri.Cvar_Get("vk_bitdepth", "0", 0);
1039  vk_log = ri.Cvar_Get("vk_log", "0", 0);
1040  vk_picmip = ri.Cvar_Get("vk_picmip", "0", 0);
1041  vk_skymip = ri.Cvar_Get("vk_skymip", "0", 0);
1042  vk_round_down = ri.Cvar_Get("vk_round_down", "1", 0);
1043  vk_flashblend = ri.Cvar_Get("vk_flashblend", "0", 0);
1044  vk_finish = ri.Cvar_Get("vk_finish", "0", CVAR_ARCHIVE);
1045  vk_clear = ri.Cvar_Get("vk_clear", "0", CVAR_ARCHIVE);
1046  vk_lockpvs = ri.Cvar_Get("vk_lockpvs", "0", 0);
1047  vk_polyblend = ri.Cvar_Get("vk_polyblend", "1", 0);
1048  vk_modulate = ri.Cvar_Get("vk_modulate", "1", CVAR_ARCHIVE);
1049  vk_shadows = ri.Cvar_Get("vk_shadows", "0", CVAR_ARCHIVE);
1050  vk_particle_size = ri.Cvar_Get("vk_particle_size", "40", CVAR_ARCHIVE);
1051  vk_particle_att_a = ri.Cvar_Get("vk_particle_att_a", "0.01", CVAR_ARCHIVE);
1052  vk_particle_att_b = ri.Cvar_Get("vk_particle_att_b", "0.0", CVAR_ARCHIVE);
1053  vk_particle_att_c = ri.Cvar_Get("vk_particle_att_c", "0.01", CVAR_ARCHIVE);
1054  vk_particle_min_size = ri.Cvar_Get("vk_particle_min_size", "2", CVAR_ARCHIVE);
1055  vk_particle_max_size = ri.Cvar_Get("vk_particle_max_size", "40", CVAR_ARCHIVE);
1056  vk_point_particles = ri.Cvar_Get("vk_point_particles", "1", CVAR_ARCHIVE);
1057  vk_postprocess = ri.Cvar_Get("vk_postprocess", "1", CVAR_ARCHIVE);
1058  vk_dynamic = ri.Cvar_Get("vk_dynamic", "1", 0);
1059  vk_msaa = ri.Cvar_Get("vk_msaa", "0", CVAR_ARCHIVE);
1060  vk_showtris = ri.Cvar_Get("vk_showtris", "0", 0);
1061  vk_lightmap = ri.Cvar_Get("vk_lightmap", "0", 0);
1062  vk_texturemode = ri.Cvar_Get("vk_texturemode", "VK_MIPMAP_LINEAR", CVAR_ARCHIVE);
1063  vk_lmaptexturemode = ri.Cvar_Get("vk_lmaptexturemode", "VK_MIPMAP_LINEAR", CVAR_ARCHIVE);
1064  vk_aniso = ri.Cvar_Get("vk_aniso", "1", CVAR_ARCHIVE);
1065  vk_mip_nearfilter = ri.Cvar_Get("vk_mip_nearfilter", "0", CVAR_ARCHIVE);
1066  vk_sampleshading = ri.Cvar_Get("vk_sampleshading", "1", CVAR_ARCHIVE);
1067  vk_vsync = ri.Cvar_Get("vk_vsync", "0", CVAR_ARCHIVE);
1068  vk_device_idx = ri.Cvar_Get("vk_device", "-1", CVAR_ARCHIVE);
1069  // clamp vk_msaa to accepted range so that video menu doesn't crash on us
1070  if (vk_msaa->value < 0)
1071  ri.Cvar_Set("vk_msaa", "0");
1072  else if (vk_msaa->value > 4)
1073  ri.Cvar_Set("vk_msaa", "4");
1074 
1075  vid_fullscreen = ri.Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
1076  vid_gamma = ri.Cvar_Get("vid_gamma", "1.0", CVAR_ARCHIVE);
1077  vid_ref = ri.Cvar_Get("vid_ref", "soft", CVAR_ARCHIVE);
1078  viewsize = ri.Cvar_Get("viewsize", "100", CVAR_ARCHIVE);
1079 
1080  ri.Cmd_AddCommand("vk_strings", Vk_Strings_f);
1081  ri.Cmd_AddCommand("vk_mem", Vk_Mem_f);
1082  ri.Cmd_AddCommand("imagelist", Vk_ImageList_f);
1083  ri.Cmd_AddCommand("screenshot", Vk_ScreenShot_f);
1084 }
1085 
1086 /*
1087 ==================
1088 R_SetMode
1089 ==================
1090 */
1092 {
1093  rserr_t err;
1094  qboolean fullscreen;
1095 
1096  fullscreen = vid_fullscreen->value;
1097 
1098  vid_gamma->modified = false;
1099  vid_fullscreen->modified = false;
1100  vk_mode->modified = false;
1101  vk_msaa->modified = false;
1102  vk_clear->modified = false;
1103  vk_validation->modified = false;
1104  vk_mip_nearfilter->modified = false;
1105  vk_sampleshading->modified = false;
1106  vk_vsync->modified = false;
1107  vk_device_idx->modified = false;
1108  vk_picmip->modified = false;
1109  // refresh texture samplers
1110  vk_texturemode->modified = true;
1111  vk_lmaptexturemode->modified = true;
1112 
1113  if ((err = Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, vk_mode->value, fullscreen)) == rserr_ok)
1114  {
1116  }
1117  else
1118  {
1119  if (err == rserr_invalid_fullscreen)
1120  {
1121  ri.Cvar_SetValue("vid_fullscreen", 0);
1122  vid_fullscreen->modified = false;
1123  ri.Con_Printf(PRINT_ALL, "ref_vk::R_SetMode() - fullscreen unavailable in this mode\n");
1124  if ((err = Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, vk_mode->value, false)) == rserr_ok)
1125  return true;
1126  }
1127  else if (err == rserr_invalid_mode)
1128  {
1129  ri.Cvar_SetValue("vk_mode", vk_state.prev_mode);
1130  vk_mode->modified = false;
1131  ri.Con_Printf(PRINT_ALL, "ref_vk::R_SetMode() - invalid mode\n");
1132  }
1133 
1134  // try setting it back to something safe
1135  if ((err = Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, vk_state.prev_mode, false)) != rserr_ok)
1136  {
1137  ri.Con_Printf(PRINT_ALL, "ref_vk::R_SetMode() - could not revert to safe mode\n");
1138  return false;
1139  }
1140  }
1141  return true;
1142 }
1143 
1144 /*
1145 ===============
1146 R_Init
1147 ===============
1148 */
1149 qboolean R_Init( void *hinstance, void *hWnd )
1150 {
1151  ri.Con_Printf(PRINT_ALL, "ref_vk version: "REF_VERSION"\n");
1152 
1153  R_Register();
1154 
1155  // create the window (OS-specific)
1156  if (!Vkimp_Init(hinstance, hWnd))
1157  {
1158  return false;
1159  }
1160 
1161  // set our "safe" modes
1162  vk_state.prev_mode = 6;
1163  // set video mode/screen resolution
1164  if (!R_SetMode())
1165  {
1166  ri.Con_Printf(PRINT_ALL, "ref_vk::R_Init() - could not R_SetMode()\n");
1167  return false;
1168  }
1169  ri.Vid_MenuInit();
1170 
1171  // window is ready, initialize Vulkan now
1172  if (!QVk_Init())
1173  {
1174  ri.Con_Printf(PRINT_ALL, "ref_vk::R_Init() - could not initialize Vulkan!\n");
1175  return false;
1176  }
1177 
1178  ri.Con_Printf(PRINT_ALL, "Successfully initialized Vulkan!\n");
1179  // print device information during startup
1180  Vk_Strings_f();
1181 
1182  Vk_InitImages();
1183  Mod_Init();
1185  Draw_InitLocal();
1186 
1187  return true;
1188 }
1189 
1190 /*
1191 ===============
1192 R_Shutdown
1193 ===============
1194 */
1195 void R_Shutdown (void)
1196 {
1197  ri.Cmd_RemoveCommand("vk_strings");
1198  ri.Cmd_RemoveCommand("vk_mem");
1199  ri.Cmd_RemoveCommand("imagelist");
1200  ri.Cmd_RemoveCommand("screenshot");
1201 
1202  vkDeviceWaitIdle(vk_device.logical);
1203 
1204  Mod_FreeAll();
1206 
1207  // Shutdown Vulkan subsystem
1208  QVk_Shutdown();
1209  // shut down OS specific Vulkan stuff (in our case: window)
1210  Vkimp_Shutdown();
1211 }
1212 
1213 
1214 
1215 /*
1216 @@@@@@@@@@@@@@@@@@@@@
1217 R_BeginFrame
1218 @@@@@@@@@@@@@@@@@@@@@
1219 */
1220 void R_BeginFrame( float camera_separation )
1221 {
1222  // if ri.Sys_Error() had been issued mid-frame, we might end up here without properly submitting the image, so call QVk_EndFrame to be safe
1223  QVk_EndFrame(true);
1224  /*
1225  ** change modes if necessary
1226  */
1230  {
1232  {
1234  {
1236  vk_texturemode->modified = false;
1237  }
1239  {
1241  vk_lmaptexturemode->modified = false;
1242  }
1243 
1244  vk_aniso->modified = false;
1245  }
1246  else
1247  {
1248  cvar_t *ref = ri.Cvar_Get("vid_ref", "vk", 0);
1249  ref->modified = true;
1250  }
1251  }
1252 
1253  if (vk_log->modified)
1254  {
1256  vk_log->modified = false;
1257  }
1258 
1259  if (vk_log->value)
1260  {
1262  }
1263 
1264  Vkimp_BeginFrame(camera_separation);
1265 
1266  VkResult swapChainValid = QVk_BeginFrame();
1267  // if the swapchain is invalid, just recreate the video system and revert to safe windowed mode
1268  if (swapChainValid != VK_SUCCESS)
1269  {
1270  vid_ref->modified = true;
1271  vid_fullscreen->value = false;
1272  ri.Cvar_SetValue("vid_fullscreen", 0);
1273  }
1274  else
1275  {
1277  }
1278 }
1279 
1280 /*
1281 @@@@@@@@@@@@@@@@@@@@@
1282 R_EndFrame
1283 @@@@@@@@@@@@@@@@@@@@@
1284 */
1285 void R_EndFrame( void )
1286 {
1287  QVk_EndFrame(false);
1288 }
1289 
1290 /*
1291 =============
1292 R_SetPalette
1293 =============
1294 */
1295 unsigned r_rawpalette[256];
1296 
1297 void R_SetPalette ( const unsigned char *palette)
1298 {
1299  int i;
1300 
1301  byte *rp = (byte *)r_rawpalette;
1302 
1303  if (palette)
1304  {
1305  for (i = 0; i < 256; i++)
1306  {
1307  rp[i * 4 + 0] = palette[i * 3 + 0];
1308  rp[i * 4 + 1] = palette[i * 3 + 1];
1309  rp[i * 4 + 2] = palette[i * 3 + 2];
1310  rp[i * 4 + 3] = 0xff;
1311  }
1312  }
1313  else
1314  {
1315  for (i = 0; i < 256; i++)
1316  {
1317  rp[i * 4 + 0] = d_8to24table[i] & 0xff;
1318  rp[i * 4 + 1] = (d_8to24table[i] >> 8) & 0xff;
1319  rp[i * 4 + 2] = (d_8to24table[i] >> 16) & 0xff;
1320  rp[i * 4 + 3] = 0xff;
1321  }
1322  }
1323 }
1324 
1325 /*
1326 ** R_DrawBeam
1327 */
1329 {
1330 #define NUM_BEAM_SEGS 6
1331 
1332  int i;
1333  float r, g, b;
1334 
1335  vec3_t perpvec;
1336  vec3_t direction, normalized_direction;
1337  vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
1338  vec3_t oldorigin, origin;
1339 
1340  oldorigin[0] = e->oldorigin[0];
1341  oldorigin[1] = e->oldorigin[1];
1342  oldorigin[2] = e->oldorigin[2];
1343 
1344  origin[0] = e->origin[0];
1345  origin[1] = e->origin[1];
1346  origin[2] = e->origin[2];
1347 
1348  normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
1349  normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
1350  normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
1351 
1352  if (VectorNormalize(normalized_direction) == 0)
1353  return;
1354 
1355  PerpendicularVector(perpvec, normalized_direction);
1356  VectorScale(perpvec, e->frame / 2, perpvec);
1357 
1358  for (i = 0; i < 6; i++)
1359  {
1360  RotatePointAroundVector(start_points[i], normalized_direction, perpvec, (360.0 / NUM_BEAM_SEGS)*i);
1361  VectorAdd(start_points[i], origin, start_points[i]);
1362  VectorAdd(start_points[i], direction, end_points[i]);
1363  }
1364 
1365  r = (d_8to24table[e->skinnum & 0xFF]) & 0xFF;
1366  g = (d_8to24table[e->skinnum & 0xFF] >> 8) & 0xFF;
1367  b = (d_8to24table[e->skinnum & 0xFF] >> 16) & 0xFF;
1368 
1369  r *= 1 / 255.0F;
1370  g *= 1 / 255.0F;
1371  b *= 1 / 255.0F;
1372 
1373  float color[4] = { r, g, b, e->alpha };
1374 
1375  struct {
1376  float v[3];
1377  } beamvertex[NUM_BEAM_SEGS*4];
1378 
1379  for (i = 0; i < NUM_BEAM_SEGS; i++)
1380  {
1381  int idx = i * 4;
1382  beamvertex[idx].v[0] = start_points[i][0];
1383  beamvertex[idx].v[1] = start_points[i][1];
1384  beamvertex[idx].v[2] = start_points[i][2];
1385 
1386  beamvertex[idx + 1].v[0] = end_points[i][0];
1387  beamvertex[idx + 1].v[1] = end_points[i][1];
1388  beamvertex[idx + 1].v[2] = end_points[i][2];
1389 
1390  beamvertex[idx + 2].v[0] = start_points[(i + 1) % NUM_BEAM_SEGS][0];
1391  beamvertex[idx + 2].v[1] = start_points[(i + 1) % NUM_BEAM_SEGS][1];
1392  beamvertex[idx + 2].v[2] = start_points[(i + 1) % NUM_BEAM_SEGS][2];
1393 
1394  beamvertex[idx + 3].v[0] = end_points[(i + 1) % NUM_BEAM_SEGS][0];
1395  beamvertex[idx + 3].v[1] = end_points[(i + 1) % NUM_BEAM_SEGS][1];
1396  beamvertex[idx + 3].v[2] = end_points[(i + 1) % NUM_BEAM_SEGS][2];
1397  }
1398 
1400 
1401  VkBuffer vbo;
1402  VkDeviceSize vboOffset;
1403  uint32_t uboOffset;
1404  VkDescriptorSet uboDescriptorSet;
1405  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(beamvertex), &vbo, &vboOffset);
1406  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(color), &uboOffset, &uboDescriptorSet);
1407  memcpy(vertData, beamvertex, sizeof(beamvertex));
1408  memcpy(uboData, color, sizeof(color));
1409 
1410  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawBeamPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
1411  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
1412  vkCmdDraw(vk_activeCmdbuffer, NUM_BEAM_SEGS * 4, 1, 0, 0);
1413 }
1414 
1415 //===================================================================
1416 
1417 
1418 void R_BeginRegistration (char *map);
1419 struct model_s *R_RegisterModel (char *name);
1420 struct image_s *R_RegisterSkin (char *name);
1421 void R_SetSky (char *name, float rotate, vec3_t axis);
1422 void R_EndRegistration (void);
1423 
1424 void R_RenderFrame (refdef_t *fd);
1425 
1426 struct image_s *Draw_FindPic (char *name);
1427 
1428 void Draw_Pic (int x, int y, char *name);
1429 void Draw_Char (int x, int y, int c);
1430 void Draw_TileClear (int x, int y, int w, int h, char *name);
1431 void Draw_Fill (int x, int y, int w, int h, int c);
1432 void Draw_FadeScreen (void);
1433 
1434 /*
1435 @@@@@@@@@@@@@@@@@@@@@
1436 GetRefAPI
1437 
1438 @@@@@@@@@@@@@@@@@@@@@
1439 */
1441 {
1442  refexport_t re;
1443 
1444  ri = rimp;
1445 
1447 
1452  re.SetSky = R_SetSky;
1454 
1456 
1458  re.DrawPic = Draw_Pic;
1460  re.DrawChar = Draw_Char;
1462  re.DrawFill = Draw_Fill;
1464 
1466 
1467  re.Init = R_Init;
1469 
1474 
1476 
1477  Swap_Init ();
1478 
1479  return re;
1480 }
1481 
1482 
1483 #ifndef REF_HARD_LINKED
1484 // this is only here so the functions in q_shared.c and q_shwin.c can link
1485 void Sys_Error (char *error, ...)
1486 {
1487  va_list argptr;
1488  char text[1024];
1489 
1490  va_start (argptr, error);
1491  vsnprintf (text, 1024, error, argptr);
1492  va_end (argptr);
1493 
1494  ri.Sys_Error (ERR_FATAL, "%s", text);
1495 }
1496 
1497 void Com_Printf (char *fmt, ...)
1498 {
1499  va_list argptr;
1500  char text[1024];
1501 
1502  va_start (argptr, fmt);
1503  vsnprintf (text, 1024, fmt, argptr);
1504  va_end (argptr);
1505 
1506  ri.Con_Printf (PRINT_ALL, "%s", text);
1507 }
1508 
1509 #endif
Vk_LmapTextureMode
void Vk_LmapTextureMode(char *string)
Definition: vk_image.c:705
R_DrawNullModel
void R_DrawNullModel(void)
Definition: vk_rmain.c:235
r_drawworld
cvar_t * r_drawworld
Definition: vk_rmain.c:80
RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:604
viewsize
cvar_t * viewsize
Definition: vk_rmain.c:127
image_s::vk_texture
qvktexture_t vk_texture
Definition: vk_local.h:116
R_DrawParticles
void R_DrawParticles(void)
Definition: vk_rmain.c:481
refexport_t::RegisterSkin
struct image_s *(* RegisterSkin)(char *name)
Definition: ref.h:159
cplane_s::normal
vec3_t normal
Definition: q_shared.h:415
v_blend
float v_blend[4]
Definition: vk_rmain.c:46
refdef_t::vieworg
float vieworg[3]
Definition: ref.h:106
refimport_t::Cmd_RemoveCommand
void(* Cmd_RemoveCommand)(char *name)
Definition: ref.h:197
R_SetFrustum
void R_SetFrustum(float fovx, float fovy)
Definition: vk_rmain.c:587
rserr_t
rserr_t
Definition: r_local.h:103
y2
GLdouble GLdouble GLdouble y2
Definition: qgl_win.c:301
Draw_FindPic
struct image_s * Draw_FindPic(char *name)
Definition: r_draw.c:37
cplane_s::type
byte type
Definition: q_shared.h:417
QVk_Shutdown
void QVk_Shutdown(void)
Definition: vk_common.c:1376
qvkdevice_t::logical
VkDevice logical
Definition: qvk.h:40
entity_s::origin
float origin[3]
Definition: ref.h:57
entity_s::model
struct model_s * model
Definition: ref.h:51
Mat_Scale
void Mat_Scale(float *matrix, float x, float y, float z)
Definition: vk_rmain.c:745
vk_aniso
cvar_t * vk_aniso
Definition: vk_rmain.c:118
vk_local.h
Draw_TileClear
void Draw_TileClear(int x, int y, int w, int h, char *name)
Definition: r_draw.c:537
vk_particle_size
cvar_t * vk_particle_size
Definition: vk_rmain.c:104
refdef_t
Definition: ref.h:102
R_RotateForEntity
void R_RotateForEntity(entity_t *e, float *mvMatrix)
Definition: vk_rmain.c:150
vk_drawSpritePipeline
qvkpipeline_t vk_drawSpritePipeline
Definition: vk_common.c:149
r_rawpalette
unsigned r_rawpalette[256]
Definition: vk_rmain.c:1295
QVk_DrawColorRect
void QVk_DrawColorRect(float *ubo, VkDeviceSize uboSize, qvkrenderpasstype_t rpType)
Definition: vk_common.c:2253
Swap_Init
void Swap_Init(void)
Definition: q_shared.c:1011
c_visible_lightmaps
int c_visible_lightmaps
Definition: gl_rsurf.c:40
QVk_BeginFrame
VkResult QVk_BeginFrame(void)
Definition: vk_common.c:1824
vk_colorbuffer
qvktexture_t vk_colorbuffer
Definition: vk_common.c:104
BOX_ON_PLANE_SIDE
#define BOX_ON_PLANE_SIDE(emins, emaxs, p)
Definition: q_shared.h:197
vk_particle_att_b
cvar_t * vk_particle_att_b
Definition: vk_rmain.c:106
vid
viddef_t vid
Definition: vk_rmain.c:24
R_PushDlights
void R_PushDlights(model_t *model)
Definition: r_light.c:94
bottom
GLdouble GLdouble bottom
Definition: qgl_win.c:159
Vkimp_LogNewFrame
void Vkimp_LogNewFrame(void)
Definition: vk_common.c:2356
Draw_StretchRaw
void Draw_StretchRaw(int x, int y, int w, int h, int cols, int rows, byte *data)
Definition: r_draw.c:423
vk_state
vkstate_t vk_state
Definition: vk_rmain.c:31
r_fullbright
cvar_t * r_fullbright
Definition: vk_rmain.c:82
vk_polyblend
cvar_t * vk_polyblend
Definition: vk_rmain.c:101
vk_viewport
VkViewport vk_viewport
Definition: vk_common.c:114
refexport_t::DrawStretchRaw
void(* DrawStretchRaw)(int x, int y, int w, int h, int cols, int rows, byte *data)
Definition: ref.h:175
v
GLdouble v
Definition: qgl_win.c:143
cvar_s::modified
qboolean modified
Definition: q_shared.h:330
ri
refimport_t ri
Definition: vk_rmain.c:26
zNear
GLdouble GLdouble GLdouble GLdouble zNear
Definition: qgl_win.c:159
cplane_s::signbits
byte signbits
Definition: q_shared.h:418
dsprframe_t::height
int height
Definition: qfiles.h:176
vup
vec3_t vup
Definition: vk_rmain.c:54
vk_flashblend
cvar_t * vk_flashblend
Definition: vk_rmain.c:97
GetRefAPI
refexport_t GetRefAPI(refimport_t rimp)
Definition: vk_rmain.c:1440
r_notexture
image_t * r_notexture
Definition: vk_rmain.c:33
refexport_t::RegisterPic
struct image_s *(* RegisterPic)(char *name)
Definition: ref.h:160
refexport_t::DrawFill
void(* DrawFill)(int x, int y, int w, int h, int c)
Definition: ref.h:171
vk_particle_att_a
cvar_t * vk_particle_att_a
Definition: vk_rmain.c:105
vk_particle_max_size
cvar_t * vk_particle_max_size
Definition: vk_rmain.c:109
Mod_PointInLeaf
mleaf_t * Mod_PointInLeaf(vec3_t p, model_t *model)
Definition: r_model.c:188
R_LightPoint
void R_LightPoint(vec3_t p, vec3_t color)
Definition: r_light.c:226
vk_log
cvar_t * vk_log
Definition: vk_rmain.c:93
R_EndRegistration
void R_EndRegistration(void)
Definition: r_model.c:1282
r_norefresh
cvar_t * r_norefresh
Definition: vk_rmain.c:78
x2
GLdouble GLdouble x2
Definition: qgl_win.c:301
vpn
vec3_t vpn
Definition: vk_rmain.c:55
vkstate_t::prev_mode
int prev_mode
Definition: vk_local.h:335
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
Vkimp_Shutdown
void Vkimp_Shutdown(void)
Definition: vk_imp.c:274
cvar_s::string
char * string
Definition: q_shared.h:327
VectorScale
void VectorScale(vec3_t in, vec_t scale, vec3_t out)
Definition: q_shared.c:782
qboolean
qboolean
Definition: q_shared.h:63
x
GLint GLenum GLint x
Definition: qgl_win.c:116
QVk_GetTriangleFanIbo
VkBuffer QVk_GetTriangleFanIbo(VkDeviceSize indexCount)
Definition: vk_common.c:2198
R_DrawEntitiesOnList
void R_DrawEntitiesOnList(void)
Definition: vk_rmain.c:306
z
GLdouble GLdouble z
Definition: qgl_win.c:283
entity_s::skinnum
int skinnum
Definition: ref.h:70
Mat_Rotate
void Mat_Rotate(float *matrix, float deg, float x, float y, float z)
Definition: vk_rmain.c:728
i
int i
Definition: q_shared.c:305
R_BeginFrame
void R_BeginFrame(float camera_separation)
Definition: vk_rmain.c:1220
R_SetVulkan2D
void R_SetVulkan2D(void)
Definition: vk_rmain.c:947
API_VERSION
#define API_VERSION
Definition: ref.h:128
refdef_t::y
int y
Definition: ref.h:104
Draw_Char
void Draw_Char(int x, int y, int c)
Definition: r_draw.c:242
vkconfig_t
Definition: vk_local.h:304
RP_WORLD_WARP
@ RP_WORLD_WARP
Definition: qvk.h:198
model_s
Definition: r_model.h:171
vk_drawParticlesPipeline
qvkpipeline_t vk_drawParticlesPipeline
Definition: vk_common.c:147
Vk_TextureMode
void Vk_TextureMode(char *string)
Definition: vk_image.c:657
frustum
cplane_t frustum[4]
Definition: vk_rmain.c:39
refimport_t::Cvar_Set
cvar_t *(* Cvar_Set)(char *name, char *value)
Definition: ref.h:217
Com_Printf
void Com_Printf(char *fmt,...)
Definition: vk_rmain.c:1497
r_vulkan_correction
static float r_vulkan_correction[16]
Definition: vk_rmain.c:66
Vk_DrawParticles
void Vk_DrawParticles(int num_particles, const particle_t particles[], const unsigned colortable[768])
Definition: vk_rmain.c:394
R_RegisterModel
struct model_s * R_RegisterModel(char *name)
Definition: r_model.c:1239
refdef_t::rdflags
int rdflags
Definition: ref.h:110
Vk_Mem_f
void Vk_Mem_f(void)
Definition: vk_rmisc.c:278
vk_texturemode
cvar_t * vk_texturemode
Definition: vk_rmain.c:116
CONTENTS_SOLID
#define CONTENTS_SOLID
Definition: qfiles.h:333
c_alias_polys
int c_alias_polys
Definition: vk_rmain.c:44
entity_s::flags
int flags
Definition: ref.h:76
M_PI
#define M_PI
Definition: q_shared.h:142
SignbitsForPlane
int SignbitsForPlane(cplane_t *out)
Definition: vk_rmain.c:571
refexport_t::AppActivate
void(* AppActivate)(qboolean activate)
Definition: ref.h:185
mleaf_s::contents
int contents
Definition: r_model.h:146
vk_finish
cvar_t * vk_finish
Definition: vk_rmain.c:98
r_lerpmodels
cvar_t * r_lerpmodels
Definition: vk_rmain.c:85
R_EndFrame
void R_EndFrame(void)
Definition: vk_rmain.c:1285
viddef_t
Definition: vid.h:27
cvar_s
Definition: q_shared.h:324
mod_brush
@ mod_brush
Definition: r_model.h:169
vk_colorbufferWarp
qvktexture_t vk_colorbufferWarp
Definition: vk_common.c:106
Vk_ScreenShot_f
void Vk_ScreenShot_f(void)
Definition: vk_rmisc.c:101
mleaf_s
Definition: r_model.h:143
vk_scissor
VkRect2D vk_scissor
Definition: vk_common.c:115
vk_drawTexQuadPipeline
qvkpipeline_t vk_drawTexQuadPipeline
Definition: vk_common.c:138
model_s::extradata
void * extradata
Definition: r_model.h:235
Vkimp_BeginFrame
void Vkimp_BeginFrame(float camera_separation)
Definition: vk_imp.c:350
vk_device
qvkdevice_t vk_device
Definition: vk_common.c:51
R_Flash
void R_Flash(void)
Definition: vk_rmain.c:856
R_DrawBeam
void R_DrawBeam(entity_t *e)
Definition: vk_rmain.c:1328
vk_modulate
cvar_t * vk_modulate
Definition: vk_rmain.c:102
refexport_t::EndRegistration
void(* EndRegistration)(void)
Definition: ref.h:162
refexport_t::EndFrame
void(* EndFrame)(void)
Definition: ref.h:182
j
GLint j
Definition: qgl_win.c:150
QVk_GetVertexBuffer
uint8_t * QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSize *dstOffset)
Definition: vk_common.c:2019
vk_bitdepth
cvar_t * vk_bitdepth
Definition: vk_rmain.c:92
Draw_FadeScreen
void Draw_FadeScreen(void)
Definition: r_draw.c:620
vk_postprocessPipeline
qvkpipeline_t vk_postprocessPipeline
Definition: vk_common.c:160
Mod_FreeAll
void Mod_FreeAll(void)
Definition: r_model.c:1324
r_speeds
cvar_t * r_speeds
Definition: vk_rmain.c:81
QVk_BeginRenderpass
void QVk_BeginRenderpass(qvkrenderpasstype_t rpType)
Definition: vk_common.c:1946
qvktexture_t::descriptorSet
VkDescriptorSet descriptorSet
Definition: qvk.h:87
dsprite_t
Definition: qfiles.h:181
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
r_novis
cvar_t * r_novis
Definition: vk_rmain.c:83
RF_BEAM
#define RF_BEAM
Definition: q_shared.h:606
ref
GLclampf ref
Definition: qgl_win.c:64
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
u
static int u
Definition: r_part.c:472
vk_particle_min_size
cvar_t * vk_particle_min_size
Definition: vk_rmain.c:108
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
r_lefthand
cvar_t * r_lefthand
Definition: vk_rmain.c:86
refexport_t::DrawFadeScreen
void(* DrawFadeScreen)(void)
Definition: ref.h:172
r_origin
vec3_t r_origin
Definition: vk_rmain.c:57
c_brush_polys
int c_brush_polys
Definition: vk_rmain.c:44
RDF_NOWORLDMODEL
#define RDF_NOWORLDMODEL
Definition: q_shared.h:622
Draw_Pic
void Draw_Pic(int x, int y, char *name)
Definition: r_draw.c:438
r_projection_matrix
float r_projection_matrix[16]
Definition: vk_rmain.c:59
Draw_InitLocal
void Draw_InitLocal(void)
Definition: r_draw.c:222
vk_validation
cvar_t * vk_validation
Definition: vk_rmain.c:90
Vk_Strings_f
void Vk_Strings_f(void)
Definition: vk_rmisc.c:177
R_DrawSpriteModel
void R_DrawSpriteModel(entity_t *e)
Definition: vk_rmain.c:173
entity_s::alpha
float alpha
Definition: ref.h:73
r
GLdouble GLdouble r
Definition: qgl_win.c:336
viddef_t::width
unsigned width
Definition: vid.h:29
refimport_t
Definition: ref.h:192
model_s::type
modtype_t type
Definition: r_model.h:177
R_SetLightLevel
void R_SetLightLevel(void)
Definition: vk_rmain.c:977
Vkimp_EnableLogging
void Vkimp_EnableLogging(qboolean enable)
Definition: vk_common.c:2328
refimport_t::Cmd_AddCommand
void(* Cmd_AddCommand)(char *name, void(*cmd)(void))
Definition: ref.h:196
vk_skymip
cvar_t * vk_skymip
Definition: vk_rmain.c:95
Vkimp_SetMode
rserr_t Vkimp_SetMode(int *pwidth, int *pheight, int mode, qboolean fullscreen)
Definition: vk_imp.c:186
R_SetSky
void R_SetSky(char *name, float rotate, vec3_t axis)
Definition: r_main.c:1401
vk_shadows
cvar_t * vk_shadows
Definition: vk_rmain.c:103
vk_showtris
cvar_t * vk_showtris
Definition: vk_rmain.c:114
r_proj_fovy
float r_proj_fovy
Definition: vk_rmain.c:62
particle_t::alpha
float alpha
Definition: ref.h:93
rserr_invalid_mode
@ rserr_invalid_mode
Definition: r_local.h:108
QVk_GetUniformBuffer
uint8_t * QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet)
Definition: vk_common.c:2100
PerpendicularVector
void PerpendicularVector(vec3_t dst, const vec3_t src)
Definition: q_shared.c:152
vk_drawPointParticlesPipeline
qvkpipeline_t vk_drawPointParticlesPipeline
Definition: vk_common.c:148
t
GLdouble t
Definition: qgl_win.c:328
vk_drawNullModelPipeline
qvkpipeline_t vk_drawNullModelPipeline
Definition: vk_common.c:146
mleaf_s::cluster
int cluster
Definition: r_model.h:154
vk_mode
cvar_t * vk_mode
Definition: vk_rmain.c:91
vk_activeCmdbuffer
VkCommandBuffer vk_activeCmdbuffer
Definition: vk_common.c:127
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
r_newrefdef
refdef_t r_newrefdef
Definition: vk_rmain.c:74
r_nocull
cvar_t * r_nocull
Definition: vk_rmain.c:84
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:316
viddef_t::height
unsigned height
Definition: vid.h:29
vk_picmip
cvar_t * vk_picmip
Definition: vk_rmain.c:94
R_BeginRegistration
void R_BeginRegistration(char *map)
Definition: r_model.c:1213
refexport_t
Definition: ref.h:133
vk_lmaptexturemode
cvar_t * vk_lmaptexturemode
Definition: vk_rmain.c:117
cvar_s::value
float value
Definition: q_shared.h:331
cplane_s::dist
float dist
Definition: q_shared.h:416
R_RenderView
void R_RenderView(refdef_t *fd)
Definition: vk_rmain.c:868
vid_gamma
cvar_t * vid_gamma
Definition: vk_rmain.c:125
error
static int error(vorb *f, enum STBVorbisError e)
Definition: stb_vorbis.c:865
Mat_Identity
void Mat_Identity(float *matrix)
Definition: vk_rmain.c:675
Mod_Init
void Mod_Init(void)
Definition: r_model.c:78
vk_vsync
cvar_t * vk_vsync
Definition: vk_rmain.c:121
r_worldmodel
model_t * r_worldmodel
Definition: vk_rmain.c:28
refdef_t::blend
float blend[4]
Definition: ref.h:108
Draw_Fill
void Draw_Fill(int x, int y, int w, int h, int c)
Definition: r_draw.c:586
VectorNormalize
vec_t VectorNormalize(vec3_t v)
Definition: q_shared.c:681
R_PolyBlend
void R_PolyBlend(void)
Definition: vk_rmain.c:558
R_RegisterSkin
struct image_s * R_RegisterSkin(char *name)
Definition: r_image.c:550
refexport_t::DrawGetPicSize
void(* DrawGetPicSize)(int *w, int *h, char *name)
Definition: ref.h:166
NULL
#define NULL
Definition: q_shared.h:67
refdef_t::time
float time
Definition: ref.h:109
refexport_t::CinematicSetPalette
void(* CinematicSetPalette)(const unsigned char *palette)
Definition: ref.h:180
vk_worldWarpPipeline
qvkpipeline_t vk_worldWarpPipeline
Definition: vk_common.c:159
r_view_matrix
float r_view_matrix[16]
Definition: vk_rmain.c:63
Mat_Perspective
void Mat_Perspective(float *matrix, float *correction_matrix, float fovy, float aspect, float zNear, float zFar)
Definition: vk_rmain.c:756
vid_fullscreen
cvar_t * vid_fullscreen
Definition: vk_rmain.c:124
particle_t
Definition: ref.h:89
refexport_t::DrawPic
void(* DrawPic)(int x, int y, char *name)
Definition: ref.h:167
R_SetMode
qboolean R_SetMode(void)
Definition: vk_rmain.c:1091
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
R_SetPalette
void R_SetPalette(const unsigned char *palette)
Definition: vk_rmain.c:1297
refdef_t::num_particles
int num_particles
Definition: ref.h:122
refdef_t::height
int height
Definition: ref.h:104
R_EndWorldRenderpass
void R_EndWorldRenderpass(void)
Definition: vk_rmain.c:925
refexport_t::RegisterModel
struct model_s *(* RegisterModel)(char *name)
Definition: ref.h:158
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
dsprite_t::frames
dsprframe_t frames[1]
Definition: qfiles.h:185
vk_drawBeamPipeline
qvkpipeline_t vk_drawBeamPipeline
Definition: vk_common.c:153
qvkpipeline_t::layout
VkPipelineLayout layout
Definition: qvk.h:154
dsprframe_t::width
int width
Definition: qfiles.h:176
particle_t::origin
vec3_t origin
Definition: ref.h:91
name
cvar_t * name
Definition: cl_main.c:79
REF_VERSION
#define REF_VERSION
Definition: r_local.h:36
R_DrawWorld
void R_DrawWorld(void)
Definition: gl_rsurf.c:1197
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
refexport_t::BeginRegistration
void(* BeginRegistration)(char *map)
Definition: ref.h:157
vright
vec3_t vright
Definition: vk_rmain.c:56
mod_sprite
@ mod_sprite
Definition: r_model.h:169
r_proj_aspect
float r_proj_aspect
Definition: vk_rmain.c:60
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:164
vk_round_down
cvar_t * vk_round_down
Definition: vk_rmain.c:96
s
static fixed16_t s
Definition: r_scan.c:30
PLANE_ANYZ
#define PLANE_ANYZ
Definition: qfiles.h:314
y
GLint y
Definition: qgl_win.c:115
re
refexport_t re
Definition: vid_dll.c:32
r_oldviewcluster2
int r_oldviewcluster2
Definition: vk_rmain.c:76
RDF_UNDERWATER
#define RDF_UNDERWATER
Definition: q_shared.h:621
entity_s::frame
int frame
Definition: ref.h:58
vk_clear
cvar_t * vk_clear
Definition: vk_rmain.c:99
zFar
GLclampd zFar
Definition: qgl_win.c:125
refexport_t::BeginFrame
void(* BeginFrame)(float camera_separation)
Definition: ref.h:181
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
vk_dynamic
cvar_t * vk_dynamic
Definition: vk_rmain.c:112
R_Shutdown
void R_Shutdown(void)
Definition: vk_rmain.c:1195
model_s::skins
image_t * skins[MAX_MD2SKINS]
Definition: r_model.h:234
r_drawentities
cvar_t * r_drawentities
Definition: vk_rmain.c:79
QVk_EndFrame
VkResult QVk_EndFrame(qboolean force)
Definition: vk_common.c:1880
vk_frameStarted
qboolean vk_frameStarted
Definition: vk_common.c:135
refexport_t::EndWorldRenderpass
void(* EndWorldRenderpass)(void)
Definition: ref.h:183
R_CullBox
qboolean R_CullBox(vec3_t mins, vec3_t maxs)
Definition: vk_rmain.c:136
refdef_t::particles
particle_t * particles
Definition: ref.h:123
RP_UI
@ RP_UI
Definition: qvk.h:197
currententity
entity_t * currententity
Definition: vk_rmain.c:36
d_8to24table
unsigned d_8to24table[256]
Definition: r_main.c:27
Vkimp_AppActivate
void Vkimp_AppActivate(qboolean active)
Definition: vk_imp.c:376
R_RenderDlights
void R_RenderDlights(void)
Definition: gl_light.c:77
r_proj_fovx
float r_proj_fovx
Definition: vk_rmain.c:61
QVk_BindPipeline
void QVk_BindPipeline(qvkpipeline_t *pipeline)
Definition: vk_common.c:2284
refdef_t::num_entities
int num_entities
Definition: ref.h:116
refexport_t::SetSky
void(* SetSky)(char *name, float rotate, vec3_t axis)
Definition: ref.h:161
Mat_Translate
void Mat_Translate(float *matrix, float x, float y, float z)
Definition: vk_rmain.c:718
up
static vec3_t up
Definition: p_view.c:29
r_viewcluster2
int r_viewcluster2
Definition: vk_rmain.c:76
dsprite_t::numframes
int numframes
Definition: qfiles.h:184
R_DrawBrushModel
void R_DrawBrushModel(entity_t *e)
Definition: gl_rsurf.c:957
vkstate_t::camera_separation
float camera_separation
Definition: vk_local.h:344
r_framecount
int r_framecount
Definition: vk_rmain.c:42
rserr_ok
@ rserr_ok
Definition: r_local.h:105
refimport_t::Vid_MenuInit
void(* Vid_MenuInit)(void)
Definition: ref.h:221
Draw_GetPicSize
void Draw_GetPicSize(int *w, int *h, char *pic)
Definition: r_draw.c:321
dsprframe_t::origin_y
int origin_y
Definition: qfiles.h:177
entity_s
Definition: ref.h:49
Mat_Ortho
void Mat_Ortho(float *matrix, float left, float right, float bottom, float top, float zNear, float zFar)
Definition: vk_rmain.c:784
RF_FULLBRIGHT
#define RF_FULLBRIGHT
Definition: q_shared.h:602
vk_config
vkconfig_t vk_config
Definition: vk_rmain.c:30
R_SetupVulkan
void R_SetupVulkan(void)
Definition: vk_rmain.c:807
CVAR_USERINFO
#define CVAR_USERINFO
Definition: q_shared.h:317
R_Init
qboolean R_Init(void *hinstance, void *hWnd)
Definition: vk_rmain.c:1149
c_visible_textures
int c_visible_textures
Definition: gl_rsurf.c:41
VectorMA
void VectorMA(vec3_t veca, float scale, vec3_t vecb, vec3_t vecc)
Definition: q_shared.c:719
mod_alias
@ mod_alias
Definition: r_model.h:169
r_viewcluster
int r_viewcluster
Definition: vk_rmain.c:76
R_Register
void R_Register(void)
Definition: vk_rmain.c:1020
refdef_t::fov_x
float fov_x
Definition: ref.h:105
currentmodel
model_t * currentmodel
Definition: vk_rmain.c:37
refexport_t::Shutdown
void(* Shutdown)(void)
Definition: ref.h:142
vk_lockpvs
cvar_t * vk_lockpvs
Definition: vk_rmain.c:100
refexport_t::DrawStretchPic
void(* DrawStretchPic)(int x, int y, int w, int h, char *name)
Definition: ref.h:168
refdef_t::fov_y
float fov_y
Definition: ref.h:105
particle_t::color
int color
Definition: ref.h:92
vk_device_idx
cvar_t * vk_device_idx
Definition: vk_rmain.c:122
QVk_Init
qboolean QVk_Init(void)
Definition: vk_common.c:1510
vk_msaa
cvar_t * vk_msaa
Definition: vk_rmain.c:113
Vk_InitImages
void Vk_InitImages(void)
Definition: vk_image.c:1654
dsprframe_t
Definition: qfiles.h:174
refexport_t::api_version
int api_version
Definition: ref.h:136
vk_lightmap
cvar_t * vk_lightmap
Definition: vk_rmain.c:115
refdef_t::width
int width
Definition: ref.h:104
vk_mip_nearfilter
cvar_t * vk_mip_nearfilter
Definition: vk_rmain.c:119
refexport_t::DrawTileClear
void(* DrawTileClear)(int x, int y, int w, int h, char *name)
Definition: ref.h:170
refexport_t::DrawChar
void(* DrawChar)(int x, int y, int c)
Definition: ref.h:169
R_DrawAlphaSurfaces
void R_DrawAlphaSurfaces(void)
Definition: r_poly.c:1342
r_particletexture
image_t * r_particletexture
Definition: vk_rmain.c:34
r_oldviewcluster
int r_oldviewcluster
Definition: vk_rmain.c:76
dsprframe_t::origin_x
int origin_x
Definition: qfiles.h:177
R_SetupFrame
void R_SetupFrame(void)
Definition: vk_rmain.c:613
vk_sampleshading
cvar_t * vk_sampleshading
Definition: vk_rmain.c:120
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
top
GLdouble GLdouble GLdouble top
Definition: qgl_win.c:159
right
GLdouble right
Definition: qgl_win.c:159
refimport_t::Cvar_SetValue
void(* Cvar_SetValue)(char *name, float value)
Definition: ref.h:218
image_s
Definition: r_local.h:71
refdef_t::viewangles
float viewangles[3]
Definition: ref.h:107
particles
cparticle_t particles[MAX_PARTICLES]
Definition: cl_fx.c:887
refdef_t::entities
entity_t * entities
Definition: ref.h:117
refdef_t::x
int x
Definition: ref.h:104
Vkimp_Init
qboolean Vkimp_Init(void *hinstance, void *wndproc)
Definition: vk_imp.c:304
R_InitParticleTexture
void R_InitParticleTexture(void)
Definition: gl_rmisc.c:41
r_viewproj_matrix
float r_viewproj_matrix[16]
Definition: vk_rmain.c:64
R_MarkLeaves
void R_MarkLeaves(void)
Definition: r_main.c:467
cplane_s
Definition: q_shared.h:413
Draw_StretchPic
void Draw_StretchPic(int x, int y, int w, int h, char *name)
Definition: r_draw.c:405
refexport_t::Init
qboolean(* Init)(void *hinstance, void *wndproc)
Definition: ref.h:139
r_visframecount
int r_visframecount
Definition: vk_rmain.c:41
R_RenderFrame
void R_RenderFrame(refdef_t *fd)
Definition: vk_rmain.c:1012
RP_WORLD
@ RP_WORLD
Definition: qvk.h:196
r_lightlevel
cvar_t * r_lightlevel
Definition: vk_rmain.c:88
vk_postprocess
cvar_t * vk_postprocess
Definition: vk_rmain.c:111
rserr_invalid_fullscreen
@ rserr_invalid_fullscreen
Definition: r_local.h:107
entity_s::oldorigin
float oldorigin[3]
Definition: ref.h:63
vk_particle_att_c
cvar_t * vk_particle_att_c
Definition: vk_rmain.c:107
vid_ref
cvar_t * vid_ref
Definition: vk_rmain.c:126
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
NUM_BEAM_SEGS
#define NUM_BEAM_SEGS
refexport_t::RenderFrame
void(* RenderFrame)(refdef_t *fd)
Definition: ref.h:164
vkstate_t
Definition: vk_local.h:330
entity_s::angles
float angles[3]
Definition: ref.h:52
RotatePointAroundVector
void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees)
Definition: q_shared.c:32
Vk_ImageList_f
void Vk_ImageList_f(void)
Definition: vk_image.c:535
Vk_ShutdownImages
void Vk_ShutdownImages(void)
Definition: vk_image.c:1704
vk_point_particles
cvar_t * vk_point_particles
Definition: vk_rmain.c:110
Sys_Error
void Sys_Error(char *error,...)
Definition: vk_rmain.c:1485
Mat_Mul
void Mat_Mul(float *m1, float *m2, float *res)
Definition: vk_rmain.c:695
R_DrawAliasModel
void R_DrawAliasModel(entity_t *e)
Definition: gl_mesh.c:519
MAX_PARTICLES
#define MAX_PARTICLES
Definition: ref.h:27
shadelight
float shadelight[3]
Definition: r_local.h:645