vkQuake2 doxygen  1.0 dev
vk_rsurf.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_rsurf.c: surface-related refresh code
22 #include <assert.h>
23 
24 #include "vk_local.h"
25 
26 static vec3_t modelorg; // relative to viewpoint
27 
29 
30 #define DYNAMIC_LIGHT_WIDTH 128
31 #define DYNAMIC_LIGHT_HEIGHT 128
32 
33 #define LIGHTMAP_BYTES 4
34 
35 #define BLOCK_WIDTH 128
36 #define BLOCK_HEIGHT 128
37 
40 
41 typedef struct
42 {
44 
45  msurface_t *lightmap_surfaces[MAX_LIGHTMAPS];
46 
47  int allocated[BLOCK_WIDTH];
48 
49  // the lightmap texture data needs to be kept in
50  // main memory so texsubimage can update properly
51  byte lightmap_buffer[4*BLOCK_WIDTH*BLOCK_HEIGHT];
53 
55 
56 
57 static void LM_InitBlock( void );
58 static void LM_UploadBlock( qboolean dynamic );
59 static qboolean LM_AllocBlock (int w, int h, int *x, int *y);
60 
61 extern void R_SetCacheState( msurface_t *surf );
62 extern void R_BuildLightMap (msurface_t *surf, byte *dest, int stride);
63 
64 /*
65 =============================================================
66 
67  BRUSH MODELS
68 
69 =============================================================
70 */
71 
72 /*
73 ===============
74 R_TextureAnimation
75 
76 Returns the proper texture for a given time and base texture
77 ===============
78 */
80 {
81  int c;
82 
83  if (!tex->next)
84  return tex->image;
85 
86  c = currententity->frame % tex->numframes;
87  while (c)
88  {
89  tex = tex->next;
90  c--;
91  }
92 
93  return tex->image;
94 }
95 
96 /*
97 ================
98 DrawVkPoly
99 ================
100 */
101 void DrawVkPoly (vkpoly_t *p, image_t *texture, float *color)
102 {
103  int i;
104  float *v;
105 
106  typedef struct {
107  float vertex[3];
108  float texCoord[2];
109  } polyvert;
110 
111  static polyvert verts[MAX_VERTS];
112 
113  v = p->verts[0];
114  for (i = 0; i < p->numverts; i++, v += VERTEXSIZE)
115  {
116  verts[i].vertex[0] = v[0];
117  verts[i].vertex[1] = v[1];
118  verts[i].vertex[2] = v[2];
119  verts[i].texCoord[0] = v[3];
120  verts[i].texCoord[1] = v[4];
121  }
122 
124 
125  VkBuffer vbo;
126  VkDeviceSize vboOffset;
127  uint32_t uboOffset;
128  VkDescriptorSet uboDescriptorSet;
129  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(polyvert) * p->numverts, &vbo, &vboOffset);
130  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(float) * 4, &uboOffset, &uboDescriptorSet);
131  memcpy(vertData, verts, sizeof(polyvert) * p->numverts);
132  memcpy(uboData, color, sizeof(float) * 4);
133 
134  VkDescriptorSet descriptorSets[] = { texture->vk_texture.descriptorSet, uboDescriptorSet };
135  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
136  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
137  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((p->numverts - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
138  vkCmdDrawIndexed(vk_activeCmdbuffer, (p->numverts - 2) * 3, 1, 0, 0, 0);
139 }
140 
141 //============
142 //PGM
143 /*
144 ================
145 DrawVkFlowingPoly -- version of DrawVkPoly that handles scrolling texture
146 ================
147 */
148 void DrawVkFlowingPoly (msurface_t *fa, image_t *texture, float *color)
149 {
150  int i;
151  float *v;
152  vkpoly_t *p;
153  float scroll;
154 
155  typedef struct {
156  float vertex[3];
157  float texCoord[2];
158  } polyvert;
159 
160  static polyvert verts[MAX_VERTS];
161 
162  p = fa->polys;
163 
164  scroll = -64 * ((r_newrefdef.time / 40.0) - (int)(r_newrefdef.time / 40.0));
165  if (scroll == 0.0)
166  scroll = -64.0;
167 
168  v = p->verts[0];
169  for (i = 0; i < p->numverts; i++, v += VERTEXSIZE)
170  {
171  verts[i].vertex[0] = v[0];
172  verts[i].vertex[1] = v[1];
173  verts[i].vertex[2] = v[2];
174  verts[i].texCoord[0] = v[3] + scroll;
175  verts[i].texCoord[1] = v[4];
176  }
177 
179 
180  VkBuffer vbo;
181  VkDeviceSize vboOffset;
182  uint32_t uboOffset;
183  VkDescriptorSet uboDescriptorSet;
184  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(polyvert) * p->numverts, &vbo, &vboOffset);
185  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(float) * 4, &uboOffset, &uboDescriptorSet);
186  memcpy(vertData, verts, sizeof(polyvert) * p->numverts);
187  memcpy(uboData, color, sizeof(float) * 4);
188 
189  VkDescriptorSet descriptorSets[] = { texture->vk_texture.descriptorSet, uboDescriptorSet };
190  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyPipeline.layout, 0, 2, descriptorSets, 1, &uboOffset);
191  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
192  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((p->numverts - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
193  vkCmdDrawIndexed(vk_activeCmdbuffer, (p->numverts - 2) * 3, 1, 0, 0, 0);
194 }
195 //PGM
196 //============
197 
198 /*
199 ** R_DrawTriangleOutlines
200 */
202 {
203  int i, j, k;
204  vkpoly_t *p;
205 
206  if (!vk_showtris->value)
207  return;
208 
209  VkBuffer vbo;
210  VkDeviceSize vboOffset;
211  float color[3] = { 1.f, 1.f, 1.f };
212  struct {
213  vec3_t v;
214  float color[3];
215  } triVert[4];
216 
218  uint32_t uboOffset;
219  VkDescriptorSet uboDescriptorSet;
220  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(r_viewproj_matrix), &uboOffset, &uboDescriptorSet);
221  memcpy(uboData, r_viewproj_matrix, sizeof(r_viewproj_matrix));
222  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_showTrisPipeline.layout, 0, 1, &uboDescriptorSet, 1, &uboOffset);
223 
224  for (i = 0; i < MAX_LIGHTMAPS; i++)
225  {
226  msurface_t *surf;
227 
228  for (surf = vk_lms.lightmap_surfaces[i]; surf != 0; surf = surf->lightmapchain)
229  {
230  p = surf->polys;
231  for (; p; p = p->chain)
232  {
233  for (j = 2, k = 0; j < p->numverts; j++, k++)
234  {
235  triVert[0].v[0] = p->verts[0][0];
236  triVert[0].v[1] = p->verts[0][1];
237  triVert[0].v[2] = p->verts[0][2];
238  memcpy(triVert[0].color, color, sizeof(color));
239 
240  triVert[1].v[0] = p->verts[j - 1][0];
241  triVert[1].v[1] = p->verts[j - 1][1];
242  triVert[1].v[2] = p->verts[j - 1][2];
243  memcpy(triVert[1].color, color, sizeof(color));
244 
245  triVert[2].v[0] = p->verts[j][0];
246  triVert[2].v[1] = p->verts[j][1];
247  triVert[2].v[2] = p->verts[j][2];
248  memcpy(triVert[2].color, color, sizeof(color));
249 
250  triVert[3].v[0] = p->verts[0][0];
251  triVert[3].v[1] = p->verts[0][1];
252  triVert[3].v[2] = p->verts[0][2];
253  memcpy(triVert[3].color, color, sizeof(color));
254 
255  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(triVert), &vbo, &vboOffset);
256  memcpy(vertData, triVert, sizeof(triVert));
257 
258  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
259  vkCmdDraw(vk_activeCmdbuffer, 4, 1, 0, 0);
260  }
261  }
262  }
263  }
264 }
265 
266 /*
267 ================
268 R_RenderBrushPoly
269 ================
270 */
271 void R_RenderBrushPoly (msurface_t *fa, float *modelMatrix, float alpha)
272 {
273  int maps;
274  image_t *image;
275  qboolean is_dynamic = false;
276  float color[4] = { 1.f, 1.f, 1.f, alpha };
277  c_brush_polys++;
278 
279  image = R_TextureAnimation(fa->texinfo);
280 
281  if (fa->flags & SURF_DRAWTURB)
282  {
283  color[0] = color[1] = color[2] = vk_state.inverse_intensity;
284  color[3] = 1.f;
285  // warp texture, no lightmaps
286  EmitWaterPolys(fa, image, modelMatrix, color);
287  return;
288  }
289 
290  //======
291  //PGM
292  if (fa->texinfo->flags & SURF_FLOWING)
293  DrawVkFlowingPoly(fa, image, color);
294  else
295  DrawVkPoly(fa->polys, image, color);
296  //PGM
297  //======
298 
299  /*
300  ** check for lightmap modification
301  */
302  for (maps = 0; maps < MAXLIGHTMAPS && fa->styles[maps] != 255; maps++)
303  {
304  if (r_newrefdef.lightstyles[fa->styles[maps]].white != fa->cached_light[maps])
305  goto dynamic;
306  }
307 
308  // dynamic this frame or dynamic previously
309  if (fa->dlightframe == r_framecount)
310  {
311  dynamic:
312  if (vk_dynamic->value)
313  {
315  {
316  is_dynamic = true;
317  }
318  }
319  }
320 
321  if (is_dynamic)
322  {
323  if ((fa->styles[maps] >= 32 || fa->styles[maps] == 0) && (fa->dlightframe != r_framecount))
324  {
325  unsigned temp[34 * 34];
326  int smax, tmax;
327 
328  smax = (fa->extents[0] >> 4) + 1;
329  tmax = (fa->extents[1] >> 4) + 1;
330 
331  R_BuildLightMap(fa, (void *)temp, smax * 4);
332  R_SetCacheState(fa);
333 
334  QVk_UpdateTextureData(&vk_state.lightmap_textures[fa->lightmaptexturenum], (unsigned char*)temp, fa->light_s, fa->light_t, smax, tmax);
335 
338  }
339  else
340  {
342  vk_lms.lightmap_surfaces[0] = fa;
343  }
344  }
345  else
346  {
349  }
350 }
351 
352 
353 /*
354 ================
355 R_DrawAlphaSurfaces
356 
357 Draw water surfaces and windows.
358 The BSP tree is waled front to back, so unwinding the chain
359 of alpha_surfaces will draw back to front, giving proper ordering.
360 ================
361 */
363 {
364  msurface_t *s;
365  float intens;
366 
367  // the textures are prescaled up for a better lighting range,
368  // so scale it back down
369  intens = vk_state.inverse_intensity;
370  float color[4] = { intens, intens, intens, 1.f };
371 
372  for (s = r_alpha_surfaces; s; s = s->texturechain)
373  {
374  c_brush_polys++;
375  if (s->texinfo->flags & SURF_TRANS33)
376  color[3] = 0.33f;
377  else if (s->texinfo->flags & SURF_TRANS66)
378  color[3] = 0.66f;
379 
380  if (s->flags & SURF_DRAWTURB)
381  EmitWaterPolys(s, s->texinfo->image, NULL, color);
382  else if (s->texinfo->flags & SURF_FLOWING) // PGM 9/16/98
383  DrawVkFlowingPoly(s, s->texinfo->image, color); // PGM
384  else
385  DrawVkPoly(s->polys, s->texinfo->image, color);
386  }
387 
389 }
390 
391 /*
392 ================
393 DrawTextureChains
394 ================
395 */
396 void DrawTextureChains (void)
397 {
398  int i;
399  msurface_t *s;
400  image_t *image;
401 
402  c_visible_textures = 0;
403 
404  for (i = 0, image = vktextures; i < numvktextures; i++, image++)
405  {
406  if (!image->registration_sequence)
407  continue;
408  if (!image->texturechain)
409  continue;
411 
412  for (s = image->texturechain; s; s = s->texturechain)
413  {
414  if (!(s->flags & SURF_DRAWTURB))
415  R_RenderBrushPoly(s, NULL, 1.f);
416  }
417  }
418 
419  for (i = 0, image = vktextures; i < numvktextures; i++, image++)
420  {
421  if (!image->registration_sequence)
422  continue;
423  s = image->texturechain;
424  if (!s)
425  continue;
426 
427  for (; s; s = s->texturechain)
428  {
429  if (s->flags & SURF_DRAWTURB)
430  R_RenderBrushPoly(s, NULL, 1.f);
431  }
432 
433  image->texturechain = NULL;
434  }
435 }
436 
437 
438 static void Vk_RenderLightmappedPoly( msurface_t *surf, float *modelMatrix, float alpha )
439 {
440  int i, nv = surf->polys->numverts;
441  int map;
442  float *v;
443  image_t *image = R_TextureAnimation(surf->texinfo);
444  qboolean is_dynamic = false;
445  unsigned lmtex = surf->lightmaptexturenum;
446  vkpoly_t *p;
447 
448  typedef struct {
449  float vertex[3];
450  float texCoord[2];
451  float texCoordLmap[2];
452  } lmappolyvert;
453 
454  static lmappolyvert verts[MAX_VERTS];
455 
456  struct {
457  float model[16];
458  float viewLightmaps;
459  } lmapPolyUbo;
460 
461  lmapPolyUbo.viewLightmaps = vk_lightmap->value ? 1.f : 0.f;
462 
463  if (modelMatrix)
464  {
465  memcpy(lmapPolyUbo.model, modelMatrix, sizeof(float) * 16);
466  }
467  else
468  {
469  Mat_Identity(lmapPolyUbo.model);
470  }
471 
473 
474  uint32_t uboOffset;
475  VkDescriptorSet uboDescriptorSet;
476  uint8_t *uboData = QVk_GetUniformBuffer(sizeof(lmapPolyUbo), &uboOffset, &uboDescriptorSet);
477  memcpy(uboData, &lmapPolyUbo, sizeof(lmapPolyUbo));
478 
479  for (map = 0; map < MAXLIGHTMAPS && surf->styles[map] != 255; map++)
480  {
481  if (r_newrefdef.lightstyles[surf->styles[map]].white != surf->cached_light[map])
482  goto dynamic;
483  }
484 
485  // dynamic this frame or dynamic previously
486  if (surf->dlightframe == r_framecount)
487  {
488  dynamic:
489  if (vk_dynamic->value)
490  {
491  if (!(surf->texinfo->flags & (SURF_SKY | SURF_TRANS33 | SURF_TRANS66 | SURF_WARP)))
492  {
493  is_dynamic = true;
494  }
495  }
496  }
497 
498  if (is_dynamic)
499  {
500  unsigned temp[128 * 128];
501  int smax, tmax;
502 
503  if ((surf->styles[map] >= 32 || surf->styles[map] == 0) && (surf->dlightframe != r_framecount))
504  {
505  smax = (surf->extents[0] >> 4) + 1;
506  tmax = (surf->extents[1] >> 4) + 1;
507 
508  R_BuildLightMap(surf, (void *)temp, smax * 4);
509  R_SetCacheState(surf);
510 
511  lmtex = surf->lightmaptexturenum;
512  QVk_UpdateTextureData(&vk_state.lightmap_textures[surf->lightmaptexturenum], (unsigned char *)temp, surf->light_s, surf->light_t, smax, tmax);
513  }
514  else
515  {
516  smax = (surf->extents[0] >> 4) + 1;
517  tmax = (surf->extents[1] >> 4) + 1;
518 
519  R_BuildLightMap(surf, (void *)temp, smax * 4);
520 
521  lmtex = surf->lightmaptexturenum + DYNLIGHTMAP_OFFSET;
522  QVk_UpdateTextureData(&vk_state.lightmap_textures[lmtex], (unsigned char *)temp, surf->light_s, surf->light_t, smax, tmax);
523  }
524 
525  c_brush_polys++;
526 
527  //==========
528  //PGM
529  if (surf->texinfo->flags & SURF_FLOWING)
530  {
531  float scroll;
532 
533  scroll = -64 * ((r_newrefdef.time / 40.0) - (int)(r_newrefdef.time / 40.0));
534  if (scroll == 0.0)
535  scroll = -64.0;
536 
537  VkBuffer vbo;
538  VkDeviceSize vboOffset;
539  VkDescriptorSet descriptorSets[] = { image->vk_texture.descriptorSet, uboDescriptorSet, vk_state.lightmap_textures[lmtex].descriptorSet };
540  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
541 
542  for (p = surf->polys; p; p = p->chain)
543  {
544  v = p->verts[0];
545  for (i = 0; i < nv; i++, v += VERTEXSIZE)
546  {
547  verts[i].vertex[0] = v[0];
548  verts[i].vertex[1] = v[1];
549  verts[i].vertex[2] = v[2];
550  verts[i].texCoord[0] = v[3] + scroll;
551  verts[i].texCoord[1] = v[4];
552  verts[i].texCoordLmap[0] = v[5];
553  verts[i].texCoordLmap[1] = v[6];
554  }
555 
556  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(lmappolyvert) * nv, &vbo, &vboOffset);
557  memcpy(vertData, verts, sizeof(lmappolyvert) * nv);
558 
559  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
560  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((nv - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
561  vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);
562  }
563  }
564  else
565  {
566  VkBuffer vbo;
567  VkDeviceSize vboOffset;
568  VkDescriptorSet descriptorSets[] = { image->vk_texture.descriptorSet, uboDescriptorSet, vk_state.lightmap_textures[lmtex].descriptorSet };
569  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
570 
571  for (p = surf->polys; p; p = p->chain)
572  {
573  v = p->verts[0];
574  for (i = 0; i < nv; i++, v += VERTEXSIZE)
575  {
576  verts[i].vertex[0] = v[0];
577  verts[i].vertex[1] = v[1];
578  verts[i].vertex[2] = v[2];
579  verts[i].texCoord[0] = v[3];
580  verts[i].texCoord[1] = v[4];
581  verts[i].texCoordLmap[0] = v[5];
582  verts[i].texCoordLmap[1] = v[6];
583  }
584 
585  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(lmappolyvert) * nv, &vbo, &vboOffset);
586  memcpy(vertData, verts, sizeof(lmappolyvert) * nv);
587 
588  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
589  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((nv - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
590  vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);
591  }
592  }
593  //PGM
594  //==========
595  }
596  else
597  {
598  c_brush_polys++;
599 
600  //==========
601  //PGM
602  if (surf->texinfo->flags & SURF_FLOWING)
603  {
604  float scroll;
605 
606  scroll = -64 * ((r_newrefdef.time / 40.0) - (int)(r_newrefdef.time / 40.0));
607  if (scroll == 0.0)
608  scroll = -64.0;
609 
610  for (p = surf->polys; p; p = p->chain)
611  {
612  v = p->verts[0];
613  for (i = 0; i < nv; i++, v += VERTEXSIZE)
614  {
615  verts[i].vertex[0] = v[0];
616  verts[i].vertex[1] = v[1];
617  verts[i].vertex[2] = v[2];
618  verts[i].texCoord[0] = v[3] + scroll;
619  verts[i].texCoord[1] = v[4];
620  verts[i].texCoordLmap[0] = v[5];
621  verts[i].texCoordLmap[1] = v[6];
622  }
623  VkBuffer vbo;
624  VkDeviceSize vboOffset;
625  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(lmappolyvert) * nv, &vbo, &vboOffset);
626  memcpy(vertData, verts, sizeof(lmappolyvert) * nv);
627 
628  VkDescriptorSet descriptorSets[] = { image->vk_texture.descriptorSet, uboDescriptorSet, vk_state.lightmap_textures[lmtex].descriptorSet };
629  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
630  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
631  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((nv - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
632  vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);
633  }
634  }
635  else
636  {
637  //PGM
638  //==========
639  for (p = surf->polys; p; p = p->chain)
640  {
641  v = p->verts[0];
642  for (i = 0; i < nv; i++, v += VERTEXSIZE)
643  {
644  verts[i].vertex[0] = v[0];
645  verts[i].vertex[1] = v[1];
646  verts[i].vertex[2] = v[2];
647  verts[i].texCoord[0] = v[3];
648  verts[i].texCoord[1] = v[4];
649  verts[i].texCoordLmap[0] = v[5];
650  verts[i].texCoordLmap[1] = v[6];
651  }
652  VkBuffer vbo;
653  VkDeviceSize vboOffset;
654  uint8_t *vertData = QVk_GetVertexBuffer(sizeof(lmappolyvert) * nv, &vbo, &vboOffset);
655  memcpy(vertData, verts, sizeof(lmappolyvert) * nv);
656 
657  VkDescriptorSet descriptorSets[] = { image->vk_texture.descriptorSet, uboDescriptorSet, vk_state.lightmap_textures[lmtex].descriptorSet };
658  vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_drawPolyLmapPipeline.layout, 0, 3, descriptorSets, 1, &uboOffset);
659  vkCmdBindVertexBuffers(vk_activeCmdbuffer, 0, 1, &vbo, &vboOffset);
660  vkCmdBindIndexBuffer(vk_activeCmdbuffer, QVk_GetTriangleFanIbo((nv - 2) * 3), 0, VK_INDEX_TYPE_UINT16);
661  vkCmdDrawIndexed(vk_activeCmdbuffer, (nv - 2) * 3, 1, 0, 0, 0);
662  }
663  //==========
664  //PGM
665  }
666  //PGM
667  //==========
668  }
669 }
670 
671 /*
672 =================
673 R_DrawInlineBModel
674 =================
675 */
676 void R_DrawInlineBModel (float *modelMatrix)
677 {
678  int i, k;
679  cplane_t *pplane;
680  float dot;
681  msurface_t *psurf;
682  dlight_t *lt;
683  float alpha = 1.f;
684 
685  // calculate dynamic lighting for bmodel
686  if (!vk_flashblend->value)
687  {
688  lt = r_newrefdef.dlights;
689  for (k = 0; k<r_newrefdef.num_dlights; k++, lt++)
690  {
692  }
693  }
694 
696 
698  {
699  alpha = .25f;
700  }
701 
702  //
703  // draw texture
704  //
705  for (i = 0; i<currentmodel->nummodelsurfaces; i++, psurf++)
706  {
707  // find which side of the node we are on
708  pplane = psurf->plane;
709 
710  dot = DotProduct(modelorg, pplane->normal) - pplane->dist;
711 
712  // draw the polygon
713  if (((psurf->flags & SURF_PLANEBACK) && (dot < -BACKFACE_EPSILON)) ||
714  (!(psurf->flags & SURF_PLANEBACK) && (dot > BACKFACE_EPSILON)))
715  {
716  if (psurf->texinfo->flags & (SURF_TRANS33 | SURF_TRANS66))
717  { // add to the translucent chain
719  r_alpha_surfaces = psurf;
720  }
721  else if (!(psurf->flags & SURF_DRAWTURB) && !vk_showtris->value)
722  {
723  Vk_RenderLightmappedPoly(psurf, modelMatrix, alpha);
724  }
725  else
726  {
727  R_RenderBrushPoly(psurf, modelMatrix, alpha);
728  }
729  }
730  }
731 }
732 
733 /*
734 =================
735 R_DrawBrushModel
736 =================
737 */
739 {
740  vec3_t mins, maxs;
741  int i;
742  qboolean rotated;
743 
744  if (currentmodel->nummodelsurfaces == 0)
745  return;
746 
747  currententity = e;
748 
749  if (e->angles[0] || e->angles[1] || e->angles[2])
750  {
751  rotated = true;
752  for (i = 0; i<3; i++)
753  {
754  mins[i] = e->origin[i] - currentmodel->radius;
755  maxs[i] = e->origin[i] + currentmodel->radius;
756  }
757  }
758  else
759  {
760  rotated = false;
761  VectorAdd(e->origin, currentmodel->mins, mins);
762  VectorAdd(e->origin, currentmodel->maxs, maxs);
763  }
764 
765  if (R_CullBox(mins, maxs))
766  return;
767 
768  memset(vk_lms.lightmap_surfaces, 0, sizeof(vk_lms.lightmap_surfaces));
769 
771  if (rotated)
772  {
773  vec3_t temp;
775 
776  VectorCopy(modelorg, temp);
778  modelorg[0] = DotProduct(temp, forward);
779  modelorg[1] = -DotProduct(temp, right);
780  modelorg[2] = DotProduct(temp, up);
781  }
782 
783  e->angles[0] = -e->angles[0]; // stupid quake bug
784  e->angles[2] = -e->angles[2]; // stupid quake bug
785  float model[16];
786  Mat_Identity(model);
787  R_RotateForEntity(e, model);
788  e->angles[0] = -e->angles[0]; // stupid quake bug
789  e->angles[2] = -e->angles[2]; // stupid quake bug
790 
791  R_DrawInlineBModel(model);
792 }
793 
794 /*
795 =============================================================
796 
797  WORLD MODEL
798 
799 =============================================================
800 */
801 
802 /*
803 ================
804 R_RecursiveWorldNode
805 ================
806 */
808 {
809  int c, side, sidebit;
810  cplane_t *plane;
811  msurface_t *surf, **mark;
812  mleaf_t *pleaf;
813  float dot;
814  image_t *image;
815 
816  if (node->contents == CONTENTS_SOLID)
817  return; // solid
818 
819  if (node->visframe != r_visframecount)
820  return;
821  if (R_CullBox (node->minmaxs, node->minmaxs+3))
822  return;
823 
824 // if a leaf node, draw stuff
825  if (node->contents != -1)
826  {
827  pleaf = (mleaf_t *)node;
828 
829  // check for door connected areas
830  if (r_newrefdef.areabits)
831  {
832  if (! (r_newrefdef.areabits[pleaf->area>>3] & (1<<(pleaf->area&7)) ) )
833  return; // not visible
834  }
835 
836  mark = pleaf->firstmarksurface;
837  c = pleaf->nummarksurfaces;
838 
839  if (c)
840  {
841  do
842  {
843  (*mark)->visframe = r_framecount;
844  mark++;
845  } while (--c);
846  }
847 
848  return;
849  }
850 
851 // node is just a decision point, so go down the apropriate sides
852 
853 // find which side of the node we are on
854  plane = node->plane;
855 
856  switch (plane->type)
857  {
858  case PLANE_X:
859  dot = modelorg[0] - plane->dist;
860  break;
861  case PLANE_Y:
862  dot = modelorg[1] - plane->dist;
863  break;
864  case PLANE_Z:
865  dot = modelorg[2] - plane->dist;
866  break;
867  default:
868  dot = DotProduct (modelorg, plane->normal) - plane->dist;
869  break;
870  }
871 
872  if (dot >= 0)
873  {
874  side = 0;
875  sidebit = 0;
876  }
877  else
878  {
879  side = 1;
880  sidebit = SURF_PLANEBACK;
881  }
882 
883 // recurse down the children, front side first
884  R_RecursiveWorldNode (node->children[side]);
885 
886  // draw stuff
887  for ( c = node->numsurfaces, surf = r_worldmodel->surfaces + node->firstsurface; c ; c--, surf++)
888  {
889  if (surf->visframe != r_framecount)
890  continue;
891 
892  if ( (surf->flags & SURF_PLANEBACK) != sidebit )
893  continue; // wrong side
894 
895  if (surf->texinfo->flags & SURF_SKY)
896  { // just adds to visible sky bounds
897  R_AddSkySurface (surf);
898  }
899  else if (surf->texinfo->flags & (SURF_TRANS33|SURF_TRANS66))
900  { // add to the translucent chain
902  r_alpha_surfaces = surf;
903  }
904  else
905  {
906  if (!(surf->flags & SURF_DRAWTURB) && !vk_showtris->value)
907  {
908  Vk_RenderLightmappedPoly(surf, NULL, 1.f);
909  }
910  else
911  {
912  // the polygon is visible, so add it to the texture
913  // sorted chain
914  // FIXME: this is a hack for animation
915  image = R_TextureAnimation(surf->texinfo);
916  surf->texturechain = image->texturechain;
917  image->texturechain = surf;
918  }
919  }
920  }
921 
922  // recurse down the back side
923  R_RecursiveWorldNode (node->children[!side]);
924 }
925 
926 
927 /*
928 =============
929 R_DrawWorld
930 =============
931 */
932 void R_DrawWorld (void)
933 {
934  entity_t ent;
935 
936  if (!r_drawworld->value)
937  return;
938 
940  return;
941 
943 
945 
946  // auto cycle the world frame for texture animation
947  memset (&ent, 0, sizeof(ent));
948  ent.frame = (int)(r_newrefdef.time*2);
949  currententity = &ent;
950 
951  memset (vk_lms.lightmap_surfaces, 0, sizeof(vk_lms.lightmap_surfaces));
952  R_ClearSkyBox ();
953 
955 
956  /*
957  ** theoretically nothing should happen in the next two functions
958  ** if multitexture is enabled - in practice, this code renders non-transparent liquids!
959  */
961 
962  R_DrawSkyBox ();
963 
965 }
966 
967 
968 /*
969 ===============
970 R_MarkLeaves
971 
972 Mark the leaves and nodes that are in the PVS for the current
973 cluster
974 ===============
975 */
976 void R_MarkLeaves (void)
977 {
978  byte *vis;
979  byte fatvis[MAX_MAP_LEAFS/8];
980  mnode_t *node;
981  int i, c;
982  mleaf_t *leaf;
983  int cluster;
984 
986  return;
987 
988  // development aid to let you run around and see exactly where
989  // the pvs ends
990  if (vk_lockpvs->value)
991  return;
992 
993  r_visframecount++;
996 
997  if (r_novis->value || r_viewcluster == -1 || !r_worldmodel->vis)
998  {
999  // mark everything
1000  for (i=0 ; i<r_worldmodel->numleafs ; i++)
1002  for (i=0 ; i<r_worldmodel->numnodes ; i++)
1004  return;
1005  }
1006 
1008  // may have to combine two clusters because of solid water boundaries
1010  {
1011  memcpy (fatvis, vis, (r_worldmodel->numleafs+7)/8);
1013  c = (r_worldmodel->numleafs+31)/32;
1014  for (i=0 ; i<c ; i++)
1015  ((int *)fatvis)[i] |= ((int *)vis)[i];
1016  vis = fatvis;
1017  }
1018 
1019  for (i=0,leaf=r_worldmodel->leafs ; i<r_worldmodel->numleafs ; i++, leaf++)
1020  {
1021  cluster = leaf->cluster;
1022  if (cluster == -1)
1023  continue;
1024  if (vis[cluster>>3] & (1<<(cluster&7)))
1025  {
1026  node = (mnode_t *)leaf;
1027  do
1028  {
1029  if (node->visframe == r_visframecount)
1030  break;
1031  node->visframe = r_visframecount;
1032  node = node->parent;
1033  } while (node);
1034  }
1035  }
1036 }
1037 
1038 
1039 
1040 /*
1041 =============================================================================
1042 
1043  LIGHTMAP ALLOCATION
1044 
1045 =============================================================================
1046 */
1047 
1048 static void LM_InitBlock( void )
1049 {
1050  memset( vk_lms.allocated, 0, sizeof( vk_lms.allocated ) );
1051 }
1052 
1053 static void LM_UploadBlock( qboolean dynamic )
1054 {
1055  int texture;
1056  int height = 0;
1057 
1058  if ( dynamic )
1059  {
1060  texture = 0;
1061  }
1062  else
1063  {
1065  }
1066 
1067  if ( dynamic )
1068  {
1069  int i;
1070 
1071  for ( i = 0; i < BLOCK_WIDTH; i++ )
1072  {
1073  if ( vk_lms.allocated[i] > height )
1074  height = vk_lms.allocated[i];
1075  }
1077  }
1078  else
1079  {
1080  if (vk_state.lightmap_textures[texture].image != VK_NULL_HANDLE)
1082  else
1083  {
1086  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[texture].image, VK_OBJECT_TYPE_IMAGE, va("Image: dynamic lightmap #%d", texture));
1087  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[texture].imageView, VK_OBJECT_TYPE_IMAGE_VIEW, va("Image View: dynamic lightmap #%d", texture));
1088  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[texture].descriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET, va("Descriptor Set: dynamic lightmap #%d", texture));
1089  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[texture].allocInfo.deviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY, va("Memory: dynamic lightmap #%d", texture));
1090  }
1092  ri.Sys_Error( ERR_DROP, "LM_UploadBlock() - MAX_LIGHTMAPS exceeded\n" );
1093  }
1094 }
1095 
1096 // returns a texture number and the position inside it
1097 static qboolean LM_AllocBlock (int w, int h, int *x, int *y)
1098 {
1099  int i, j;
1100  int best, best2;
1101 
1102  best = BLOCK_HEIGHT;
1103 
1104  for (i=0 ; i<BLOCK_WIDTH-w ; i++)
1105  {
1106  best2 = 0;
1107 
1108  for (j=0 ; j<w ; j++)
1109  {
1110  if (vk_lms.allocated[i+j] >= best)
1111  break;
1112  if (vk_lms.allocated[i+j] > best2)
1113  best2 = vk_lms.allocated[i+j];
1114  }
1115  if (j == w)
1116  { // this is a valid spot
1117  *x = i;
1118  *y = best = best2;
1119  }
1120  }
1121 
1122  if (best + h > BLOCK_HEIGHT)
1123  return false;
1124 
1125  for (i=0 ; i<w ; i++)
1126  vk_lms.allocated[*x + i] = best + h;
1127 
1128  return true;
1129 }
1130 
1131 /*
1132 ================
1133 Vk_BuildPolygonFromSurface
1134 ================
1135 */
1137 {
1138  int i, lindex, lnumverts;
1139  medge_t *pedges, *r_pedge;
1140  float *vec;
1141  float s, t;
1142  vkpoly_t *poly;
1143  vec3_t total;
1144 
1145 // reconstruct the polygon
1146  pedges = currentmodel->edges;
1147  lnumverts = fa->numedges;
1148 
1149  VectorClear (total);
1150  //
1151  // draw texture
1152  //
1153  poly = Hunk_Alloc (sizeof(vkpoly_t) + (lnumverts-4) * VERTEXSIZE*sizeof(float));
1154  poly->next = fa->polys;
1155  poly->flags = fa->flags;
1156  fa->polys = poly;
1157  poly->numverts = lnumverts;
1158 
1159  for (i=0 ; i<lnumverts ; i++)
1160  {
1161  lindex = currentmodel->surfedges[fa->firstedge + i];
1162 
1163  if (lindex > 0)
1164  {
1165  r_pedge = &pedges[lindex];
1166  vec = currentmodel->vertexes[r_pedge->v[0]].position;
1167  }
1168  else
1169  {
1170  r_pedge = &pedges[-lindex];
1171  vec = currentmodel->vertexes[r_pedge->v[1]].position;
1172  }
1173  s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
1174  s /= fa->texinfo->image->width;
1175 
1176  t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
1177  t /= fa->texinfo->image->height;
1178 
1179  VectorAdd (total, vec, total);
1180  VectorCopy (vec, poly->verts[i]);
1181  poly->verts[i][3] = s;
1182  poly->verts[i][4] = t;
1183 
1184  //
1185  // lightmap texture coordinates
1186  //
1187  s = DotProduct (vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3];
1188  s -= fa->texturemins[0];
1189  s += fa->light_s*16;
1190  s += 8;
1191  s /= BLOCK_WIDTH*16; //fa->texinfo->texture->width;
1192 
1193  t = DotProduct (vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3];
1194  t -= fa->texturemins[1];
1195  t += fa->light_t*16;
1196  t += 8;
1197  t /= BLOCK_HEIGHT*16; //fa->texinfo->texture->height;
1198 
1199  poly->verts[i][5] = s;
1200  poly->verts[i][6] = t;
1201  }
1202 
1203  poly->numverts = lnumverts;
1204 
1205 }
1206 
1207 /*
1208 ========================
1209 Vk_CreateSurfaceLightmap
1210 ========================
1211 */
1213 {
1214  int smax, tmax;
1215  byte *base;
1216 
1217  if (surf->flags & (SURF_DRAWSKY|SURF_DRAWTURB))
1218  return;
1219 
1220  smax = (surf->extents[0]>>4)+1;
1221  tmax = (surf->extents[1]>>4)+1;
1222 
1223  if ( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ) )
1224  {
1225  LM_UploadBlock( false );
1226  LM_InitBlock();
1227  if ( !LM_AllocBlock( smax, tmax, &surf->light_s, &surf->light_t ) )
1228  {
1229  ri.Sys_Error( ERR_FATAL, "Consecutive calls to LM_AllocBlock(%d,%d) failed\n", smax, tmax );
1230  }
1231  }
1232 
1234 
1235  base = vk_lms.lightmap_buffer;
1236  base += (surf->light_t * BLOCK_WIDTH + surf->light_s) * LIGHTMAP_BYTES;
1237 
1238  R_SetCacheState( surf );
1240 }
1241 
1242 
1243 /*
1244 ==================
1245 Vk_BeginBuildingLightmaps
1246 
1247 ==================
1248 */
1250 {
1251  static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
1252  int i;
1253  unsigned dummy[BLOCK_WIDTH * BLOCK_HEIGHT];
1254 
1255  memset(vk_lms.allocated, 0, sizeof(vk_lms.allocated));
1256 
1257  r_framecount = 1; // no dlightcache
1258 
1259  /*
1260  ** setup the base lightstyles so the lightmaps won't have to be regenerated
1261  ** the first time they're seen
1262  */
1263  for (i = 0; i < MAX_LIGHTSTYLES; i++)
1264  {
1265  lightstyles[i].rgb[0] = 1;
1266  lightstyles[i].rgb[1] = 1;
1267  lightstyles[i].rgb[2] = 1;
1268  lightstyles[i].white = 3;
1269  }
1270  r_newrefdef.lightstyles = lightstyles;
1271 
1273 
1274  /*
1275  ** initialize the dynamic lightmap textures
1276  */
1277  if (vk_state.lightmap_textures[DYNLIGHTMAP_OFFSET].image == VK_NULL_HANDLE)
1278  {
1279  for (i = DYNLIGHTMAP_OFFSET; i < MAX_LIGHTMAPS*2; i++)
1280  {
1283  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[i].image, VK_OBJECT_TYPE_IMAGE, va("Image: dynamic lightmap #%d", i));
1284  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[i].imageView, VK_OBJECT_TYPE_IMAGE_VIEW, va("Image View: dynamic lightmap #%d", i));
1285  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[i].descriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET, va("Descriptor Set: dynamic lightmap #%d", i));
1286  QVk_DebugSetObjectName((uint64_t)vk_state.lightmap_textures[i].allocInfo.deviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY, va("Memory: dynamic lightmap #%d", i));
1287  }
1288  }
1289 }
1290 
1291 /*
1292 =======================
1293 Vk_EndBuildingLightmaps
1294 =======================
1295 */
1297 {
1298  LM_UploadBlock( false );
1299 }
1300 
RF_TRANSLUCENT
#define RF_TRANSLUCENT
Definition: q_shared.h:604
vk_dynamic
cvar_t * vk_dynamic
Definition: vk_rmain.c:112
MAX_MAP_LEAFS
#define MAX_MAP_LEAFS
Definition: qfiles.h:239
image_s::vk_texture
qvktexture_t vk_texture
Definition: vk_local.h:116
cplane_s::normal
vec3_t normal
Definition: q_shared.h:415
vk_lms
static vklightmapstate_t vk_lms
Definition: vk_rsurf.c:54
QVk_DebugSetObjectName
#define QVk_DebugSetObjectName(a, b, c)
Definition: qvk.h:317
refdef_t::vieworg
float vieworg[3]
Definition: ref.h:106
cplane_s::type
byte type
Definition: q_shared.h:417
height
GLsizei height
Definition: qgl_win.c:69
currentmodel
model_t * currentmodel
Definition: r_main.c:39
r_framecount
int r_framecount
Definition: r_main.c:97
msurface_s::plane
mplane_t * plane
Definition: r_model.h:100
msurface_s::styles
byte styles[MAXLIGHTMAPS]
Definition: r_model.h:115
entity_s::origin
float origin[3]
Definition: ref.h:57
mtexinfo_s::numframes
int numframes
Definition: r_model.h:89
mleaf_s::area
int area
Definition: r_model.h:155
BACKFACE_EPSILON
#define BACKFACE_EPSILON
Definition: r_local.h:228
vk_showtris
cvar_t * vk_showtris
Definition: vk_rmain.c:114
vk_local.h
lightstyle_t::rgb
float rgb[3]
Definition: ref.h:98
r_novis
cvar_t * r_novis
Definition: r_main.c:139
model_s::vis
dvis_t * vis
Definition: r_model.h:229
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
VectorSubtract
#define VectorSubtract(a, b, c)
Definition: q_shared.h:163
LM_InitBlock
static void LM_InitBlock(void)
Definition: vk_rsurf.c:1048
R_DrawInlineBModel
void R_DrawInlineBModel(float *modelMatrix)
Definition: vk_rsurf.c:676
model_s::nummodelsurfaces
int nummodelsurfaces
Definition: r_model.h:196
msurface_s::light_t
int light_t
Definition: gl_model.h:108
vkstate_t::lightmap_textures
qvktexture_t lightmap_textures[MAX_LIGHTMAPS *2]
Definition: vk_local.h:339
ri
refimport_t ri
Definition: r_main.c:25
refdef_t::areabits
byte * areabits
Definition: ref.h:112
v
GLdouble v
Definition: qgl_win.c:143
VmaAllocationInfo::deviceMemory
VkDeviceMemory deviceMemory
Handle to Vulkan memory object.
Definition: vk_mem_alloc.h:2545
model_s::edges
medge_t * edges
Definition: r_model.h:211
R_DrawWorld
void R_DrawWorld(void)
Definition: vk_rsurf.c:932
vkpoly_s::verts
float verts[4][VERTEXSIZE]
Definition: vk_model.h:93
mtexinfo_s
Definition: r_model.h:83
mnode_s::visframe
int visframe
Definition: r_model.h:127
LM_AllocBlock
static qboolean LM_AllocBlock(int w, int h, int *x, int *y)
Definition: vk_rsurf.c:1097
VERTEXSIZE
#define VERTEXSIZE
Definition: gl_model.h:84
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
VectorClear
#define VectorClear(a)
Definition: q_shared.h:166
i
int i
Definition: q_shared.c:305
msurface_s::numedges
int numedges
Definition: r_model.h:104
msurface_s::visframe
int visframe
Definition: r_model.h:95
msurface_s::dlightframe
int dlightframe
Definition: r_model.h:97
model_s::firstnode
int firstnode
Definition: r_model.h:214
mleaf_s::visframe
int visframe
Definition: r_model.h:147
mnode_s::parent
struct mnode_s * parent
Definition: r_model.h:131
mnode_s
Definition: r_model.h:123
model_s
Definition: r_model.h:171
r_drawworld
cvar_t * r_drawworld
Definition: r_main.c:134
mleaf_s::firstmarksurface
msurface_t ** firstmarksurface
Definition: r_model.h:157
R_BuildLightMap
void R_BuildLightMap(msurface_t *surf, byte *dest, int stride)
Definition: gl_light.c:455
r_oldviewcluster
int r_oldviewcluster
Definition: r_local.h:791
refdef_t::rdflags
int rdflags
Definition: ref.h:110
r_viewproj_matrix
float r_viewproj_matrix[16]
Definition: vk_rmain.c:64
vkpoly_s
Definition: vk_model.h:87
r_visframecount
int r_visframecount
Definition: r_main.c:98
mnode_s::children
struct mnode_s * children[2]
Definition: r_model.h:135
CONTENTS_SOLID
#define CONTENTS_SOLID
Definition: qfiles.h:333
entity_s::flags
int flags
Definition: ref.h:76
image_s::registration_sequence
int registration_sequence
Definition: r_local.h:77
currententity
entity_t * currententity
Definition: r_bsp.c:28
SURF_WARP
#define SURF_WARP
Definition: qfiles.h:372
msurface_s::extents
short extents[2]
Definition: r_model.h:110
R_MarkLights
void R_MarkLights(dlight_t *light, int bit, mnode_t *node)
Definition: r_light.c:40
msurface_s::cached_light
float cached_light[MAXLIGHTMAPS]
Definition: gl_model.h:123
mleaf_s
Definition: r_model.h:143
SURF_TRANS66
#define SURF_TRANS66
Definition: qfiles.h:374
vklightmapstate_t::lightmap_surfaces
msurface_t * lightmap_surfaces[MAX_LIGHTMAPS]
Definition: vk_rsurf.c:45
r_viewcluster
int r_viewcluster
Definition: r_main.c:108
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_BeginBuildingLightmaps
void Vk_BeginBuildingLightmaps(model_t *m)
Definition: vk_rsurf.c:1249
va
char * va(char *format,...)
Definition: q_shared.c:1050
mvertex_t::position
vec3_t position
Definition: r_model.h:47
Mat_Identity
void Mat_Identity(float *matrix)
Definition: vk_rmain.c:675
qvktexture_t::descriptorSet
VkDescriptorSet descriptorSet
Definition: qvk.h:87
AngleVectors
void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition: q_shared.c:93
glpoly_s::numverts
int numverts
Definition: gl_model.h:90
SURF_PLANEBACK
#define SURF_PLANEBACK
Definition: r_model.h:68
mtexinfo_s::image
image_t * image
Definition: r_model.h:87
vklightmapstate_t::current_lightmap_texture
int current_lightmap_texture
Definition: vk_rsurf.c:43
RDF_NOWORLDMODEL
#define RDF_NOWORLDMODEL
Definition: q_shared.h:622
qvktexture_t::image
VkImage image
Definition: qvk.h:79
c_visible_lightmaps
int c_visible_lightmaps
Definition: vk_rsurf.c:38
numleafs
int numleafs
Definition: cmodel.c:77
R_DrawAlphaSurfaces
void R_DrawAlphaSurfaces(void)
Definition: vk_rsurf.c:362
qvktexture_t::allocInfo
VmaAllocationInfo allocInfo
Definition: qvk.h:81
numvktextures
int numvktextures
Definition: vk_image.c:25
medge_t
Definition: r_model.h:77
image_s::height
int height
Definition: r_local.h:75
DrawTextureChains
void DrawTextureChains(void)
Definition: vk_rsurf.c:396
mnode_s::minmaxs
short minmaxs[6]
Definition: r_model.h:129
refdef_t::num_dlights
int num_dlights
Definition: ref.h:119
DrawVkFlowingPoly
void DrawVkFlowingPoly(msurface_t *fa, image_t *texture, float *color)
Definition: vk_rsurf.c:148
R_ClearSkyBox
void R_ClearSkyBox(void)
Definition: gl_warp.c:508
R_AddSkySurface
void R_AddSkySurface(msurface_t *fa)
Definition: gl_warp.c:485
R_DrawTriangleOutlines
void R_DrawTriangleOutlines(void)
Definition: vk_rsurf.c:201
forward
static vec3_t forward
Definition: p_view.c:29
vkpoly_s::next
struct vkpoly_s * next
Definition: vk_model.h:89
DrawVkPoly
void DrawVkPoly(vkpoly_t *p, image_t *texture, float *color)
Definition: vk_rsurf.c:101
QVk_GetUniformBuffer
uint8_t * QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet)
Definition: vk_common.c:2100
vkstate_t::inverse_intensity
float inverse_intensity
Definition: vk_local.h:332
msurface_s::texinfo
mtexinfo_t * texinfo
Definition: r_model.h:112
model_s::leafs
mleaf_t * leafs
Definition: r_model.h:205
t
GLdouble t
Definition: qgl_win.c:328
model_s::nodes
mnode_t * nodes
Definition: r_model.h:215
model_s::mins
vec3_t mins
Definition: r_model.h:185
mleaf_s::cluster
int cluster
Definition: r_model.h:154
vk_lockpvs
cvar_t * vk_lockpvs
Definition: vk_rmain.c:100
vk_activeCmdbuffer
VkCommandBuffer vk_activeCmdbuffer
Definition: vk_common.c:127
QVk_CreateTexture
void QVk_CreateTexture(qvktexture_t *texture, const unsigned char *data, uint32_t width, uint32_t height, qvksampler_t samplerType)
Definition: vk_image.c:382
vkpoly_s::chain
struct vkpoly_s * chain
Definition: vk_model.h:90
PLANE_Y
#define PLANE_Y
Definition: qfiles.h:308
refimport_t::Sys_Error
void(* Sys_Error)(int err_level, char *str,...)
Definition: ref.h:194
SURF_DRAWSKY
#define SURF_DRAWSKY
Definition: r_model.h:69
vk_drawPolyPipeline
qvkpipeline_t vk_drawPolyPipeline
Definition: vk_common.c:150
BLOCK_WIDTH
#define BLOCK_WIDTH
Definition: vk_rsurf.c:35
msurface_s::texturechain
struct msurface_s * texturechain
Definition: gl_model.h:112
SURF_FLOWING
#define SURF_FLOWING
Definition: qfiles.h:375
r_newrefdef
refdef_t r_newrefdef
Definition: r_main.c:38
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
SURF_TRANS33
#define SURF_TRANS33
Definition: qfiles.h:373
msurface_s::lightmapchain
struct msurface_s * lightmapchain
Definition: gl_model.h:113
vktextures
image_t vktextures[MAX_VKTEXTURES]
Definition: vk_image.c:24
r_worldmodel
model_t * r_worldmodel
Definition: r_main.c:41
cvar_s::value
float value
Definition: q_shared.h:331
cplane_s::dist
float dist
Definition: q_shared.h:416
r_alpha_surfaces
msurface_t * r_alpha_surfaces
Definition: vk_rsurf.c:28
vk_state
vkstate_t vk_state
Definition: vk_rmain.c:31
SURF_DRAWTURB
#define SURF_DRAWTURB
Definition: r_model.h:70
r_viewcluster2
int r_viewcluster2
Definition: gl_local.h:174
NULL
#define NULL
Definition: q_shared.h:67
Vk_EndBuildingLightmaps
void Vk_EndBuildingLightmaps(void)
Definition: vk_rsurf.c:1296
refdef_t::time
float time
Definition: ref.h:109
model_s::surfedges
int * surfedges
Definition: r_model.h:224
mleaf_s::nummarksurfaces
int nummarksurfaces
Definition: r_model.h:158
image_s::width
int width
Definition: r_local.h:75
DYNLIGHTMAP_OFFSET
#define DYNLIGHTMAP_OFFSET
Definition: vk_local.h:328
QVk_UpdateTextureData
void QVk_UpdateTextureData(qvktexture_t *texture, const unsigned char *data, uint32_t offset_x, uint32_t offset_y, uint32_t width, uint32_t height)
Definition: vk_image.c:402
qvktexture_t::imageView
VkImageView imageView
Definition: qvk.h:83
alpha
GLfloat GLfloat GLfloat alpha
Definition: qgl_win.c:74
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
modelorg
static vec3_t modelorg
Definition: vk_rsurf.c:26
qvkpipeline_t::layout
VkPipelineLayout layout
Definition: qvk.h:154
MAXLIGHTMAPS
#define MAXLIGHTMAPS
Definition: qfiles.h:409
R_DrawSkyBox
void R_DrawSkyBox(void)
Definition: gl_warp.c:562
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
vk_showTrisPipeline
qvkpipeline_t vk_showTrisPipeline
Definition: vk_common.c:156
msurface_s::flags
int flags
Definition: r_model.h:101
lightstyle_t
Definition: ref.h:96
VectorAdd
#define VectorAdd(a, b, c)
Definition: q_shared.h:164
vkpoly_s::numverts
int numverts
Definition: vk_model.h:91
model_s::maxs
vec3_t maxs
Definition: r_model.h:185
s
static fixed16_t s
Definition: r_scan.c:30
model_s::radius
float radius
Definition: gl_model.h:189
LM_UploadBlock
static void LM_UploadBlock(qboolean dynamic)
Definition: vk_rsurf.c:1053
y
GLint y
Definition: qgl_win.c:115
mtexinfo_s::next
struct mtexinfo_s * next
Definition: r_model.h:90
c_visible_textures
int c_visible_textures
Definition: vk_rsurf.c:39
LIGHTMAP_BYTES
#define LIGHTMAP_BYTES
Definition: vk_rsurf.c:33
r_pedge
medge_t * r_pedge
Definition: r_rast.c:41
msurface_s::polys
glpoly_t * polys
Definition: gl_model.h:111
entity_s::frame
int frame
Definition: ref.h:58
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
Vk_CreateSurfaceLightmap
void Vk_CreateSurfaceLightmap(msurface_t *surf)
Definition: vk_rsurf.c:1212
vk_drawPolyLmapPipeline
qvkpipeline_t vk_drawPolyLmapPipeline
Definition: vk_common.c:151
R_RenderBrushPoly
void R_RenderBrushPoly(msurface_t *fa, float *modelMatrix, float alpha)
Definition: vk_rsurf.c:271
vk_flashblend
cvar_t * vk_flashblend
Definition: vk_rmain.c:97
vklightmapstate_t
Definition: vk_rsurf.c:41
MAX_LIGHTMAPS
#define MAX_LIGHTMAPS
Definition: gl_rsurf.c:38
refdef_t::lightstyles
lightstyle_t * lightstyles
Definition: ref.h:114
PLANE_X
#define PLANE_X
Definition: qfiles.h:307
mtexinfo_s::vecs
float vecs[2][4]
Definition: r_model.h:85
MAX_VERTS
#define MAX_VERTS
Definition: qfiles.h:90
r_oldviewcluster2
int r_oldviewcluster2
Definition: gl_local.h:174
QVk_BindPipeline
void QVk_BindPipeline(qvkpipeline_t *pipeline)
Definition: vk_common.c:2284
R_CullBox
qboolean R_CullBox(vec3_t mins, vec3_t maxs)
Definition: gl_rmain.c:151
msurface_s::light_s
int light_s
Definition: gl_model.h:108
mnode_s::contents
int contents
Definition: r_model.h:126
mnode_s::firstsurface
unsigned short firstsurface
Definition: r_model.h:137
PLANE_Z
#define PLANE_Z
Definition: qfiles.h:309
up
static vec3_t up
Definition: p_view.c:29
EmitWaterPolys
void EmitWaterPolys(msurface_t *fa)
Definition: gl_warp.c:211
dlight_t
Definition: ref.h:82
R_SetCacheState
void R_SetCacheState(msurface_t *surf)
Definition: gl_light.c:437
entity_s
Definition: ref.h:49
model_s::firstmodelsurface
int firstmodelsurface
Definition: r_model.h:196
model_s::surfaces
msurface_t * surfaces
Definition: r_model.h:221
medge_t::v
unsigned short v[2]
Definition: r_model.h:79
mnode_s::plane
mplane_t * plane
Definition: r_model.h:134
R_DrawBrushModel
void R_DrawBrushModel(entity_t *e)
Definition: vk_rsurf.c:738
stride
GLenum GLsizei stride
Definition: qgl_win.c:114
model_s::numleafs
int numleafs
Definition: r_model.h:204
msurface_s::lightmaptexturenum
int lightmaptexturenum
Definition: gl_model.h:121
vk_lightmap
cvar_t * vk_lightmap
Definition: vk_rmain.c:115
msurface_s
Definition: r_model.h:93
mtexinfo_s::flags
int flags
Definition: r_model.h:88
model_s::numnodes
int numnodes
Definition: r_model.h:213
R_RecursiveWorldNode
void R_RecursiveWorldNode(mnode_t *node)
Definition: vk_rsurf.c:807
refdef_t::dlights
dlight_t * dlights
Definition: ref.h:120
Vk_BuildPolygonFromSurface
void Vk_BuildPolygonFromSurface(msurface_t *fa)
Definition: vk_rsurf.c:1136
R_RotateForEntity
void R_RotateForEntity(entity_t *e)
Definition: gl_rmain.c:165
R_TextureAnimation
image_t * R_TextureAnimation(mtexinfo_t *tex)
Definition: vk_rsurf.c:79
msurface_s::texturemins
short texturemins[2]
Definition: r_model.h:109
texture
GLuint texture
Definition: qgl_win.c:68
vk_current_lmap_sampler
qvksampler_t vk_current_lmap_sampler
Definition: vk_image.c:43
lightstyle_t::white
float white
Definition: ref.h:99
vklightmapstate_t::allocated
int allocated[BLOCK_WIDTH]
Definition: vk_rsurf.c:47
Vk_RenderLightmappedPoly
static void Vk_RenderLightmappedPoly(msurface_t *surf, float *modelMatrix, float alpha)
Definition: vk_rsurf.c:438
w
GLdouble GLdouble GLdouble w
Definition: qgl_win.c:291
vklightmapstate_t::lightmap_buffer
byte lightmap_buffer[4 *BLOCK_WIDTH *BLOCK_HEIGHT]
Definition: vk_rsurf.c:51
right
GLdouble right
Definition: qgl_win.c:159
image_s
Definition: r_local.h:71
cplane_s
Definition: q_shared.h:413
mnode_s::numsurfaces
unsigned short numsurfaces
Definition: r_model.h:138
model_s::vertexes
mvertex_t * vertexes
Definition: r_model.h:208
c_brush_polys
int c_brush_polys
Definition: gl_rmain.c:55
R_MarkLeaves
void R_MarkLeaves(void)
Definition: vk_rsurf.c:976
MAX_LIGHTSTYLES
#define MAX_LIGHTSTYLES
Definition: q_shared.h:88
BLOCK_HEIGHT
#define BLOCK_HEIGHT
Definition: vk_rsurf.c:36
Mod_ClusterPVS
byte * Mod_ClusterPVS(int cluster, model_t *model)
Definition: r_model.c:268
QVVKTEXTURE_CLEAR
#define QVVKTEXTURE_CLEAR(i)
Definition: qvk.h:104
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
Hunk_Alloc
void * Hunk_Alloc(int size)
Definition: q_shwin.c:57
entity_s::angles
float angles[3]
Definition: ref.h:52
msurface_s::firstedge
int firstedge
Definition: r_model.h:103
SURF_SKY
#define SURF_SKY
Definition: qfiles.h:371
vkpoly_s::flags
int flags
Definition: vk_model.h:92
image_s::texturechain
struct msurface_s * texturechain
Definition: gl_local.h:94