vkQuake2 doxygen  1.0 dev
vk_rmisc.c File Reference
#include "vk_local.h"

Go to the source code of this file.

Classes

struct  _TargaHeader
 

Typedefs

typedef struct _TargaHeader TargaHeader
 

Functions

void R_InitParticleTexture (void)
 
void Vk_ScreenShot_f (void)
 
void Vk_Strings_f (void)
 
void Vk_Mem_f (void)
 

Variables

byte dottexture [8][8]
 

Typedef Documentation

◆ TargaHeader

typedef struct _TargaHeader TargaHeader

Function Documentation

◆ R_InitParticleTexture()

void R_InitParticleTexture ( void  )

Definition at line 42 of file vk_rmisc.c.

43 {
44  int x,y;
45  byte data[8][8][4];
46 
47  //
48  // particle texture
49  //
50  for (x=0 ; x<8 ; x++)
51  {
52  for (y=0 ; y<8 ; y++)
53  {
54  data[y][x][0] = 255;
55  data[y][x][1] = 255;
56  data[y][x][2] = 255;
57  data[y][x][3] = dottexture[x][y]*255;
58  }
59  }
60  r_particletexture = Vk_LoadPic ("***particle***", (byte *)data, 8, 8, it_sprite, 32, NULL);
61 
62  //
63  // also use this for bad textures, but without alpha
64  //
65  for (x=0 ; x<8 ; x++)
66  {
67  for (y=0 ; y<8 ; y++)
68  {
69  data[y][x][0] = dottexture[x&3][y&3]*255;
70  data[y][x][1] = 0;
71  data[y][x][2] = 0;
72  data[y][x][3] = 255;
73  }
74  }
75  r_notexture = Vk_LoadPic ("***r_notexture***", (byte *)data, 8, 8, it_wall, 32, NULL);
76 }

Referenced by R_Init().

◆ Vk_Mem_f()

void Vk_Mem_f ( void  )

Definition at line 278 of file vk_rmisc.c.

279 {
280  ri.Con_Printf(PRINT_ALL, "\nDynamic buffer stats: \n");
281  ri.Con_Printf(PRINT_ALL, "Vertex : %u/%ukB (%.1f%% max: %ukB)\n", vk_config.vertex_buffer_usage / 1024,
285  ri.Con_Printf(PRINT_ALL, "Index : %u/%uB (%.1f%% max: %uB)\n", vk_config.index_buffer_usage,
289  ri.Con_Printf(PRINT_ALL, "Uniform: %u/%ukB (%.1f%% max: %ukB)\n", vk_config.uniform_buffer_usage / 1024,
293  ri.Con_Printf(PRINT_ALL, "Tri fan: %u/%u (%.1f%% max: %u)\n", vk_config.triangle_fan_index_usage,
297 }

Referenced by R_Register().

◆ Vk_ScreenShot_f()

void Vk_ScreenShot_f ( void  )

Definition at line 101 of file vk_rmisc.c.

102 {
103  byte *buffer;
104  char picname[80];
105  char checkname[MAX_OSPATH];
106  int i, temp;
107  FILE *f;
108  size_t buffSize = vid.width * vid.height * 4 + 18;
109 
110  // create the scrnshots directory if it doesn't exist
111  Com_sprintf(checkname, sizeof(checkname), "%s/scrnshot", ri.FS_Gamedir());
112  Sys_Mkdir(checkname);
113 
114  //
115  // find a file name to save it to
116  //
117  strcpy(picname, "quake00.tga");
118 
119  for (i = 0; i <= 99; i++)
120  {
121  picname[5] = i / 10 + '0';
122  picname[6] = i % 10 + '0';
123  Com_sprintf(checkname, sizeof(checkname), "%s/scrnshot/%s", ri.FS_Gamedir(), picname);
124  f = fopen(checkname, "rb");
125  if (!f)
126  break; // file doesn't exist
127  fclose(f);
128  }
129  if (i == 100)
130  {
131  ri.Con_Printf(PRINT_ALL, "SCR_ScreenShot_f: Couldn't create a file\n");
132  return;
133  }
134 
135  buffer = malloc(buffSize);
136  memset(buffer, 0, 18);
137  buffer[2] = 2; // uncompressed type
138  buffer[12] = vid.width & 255;
139  buffer[13] = vid.width >> 8;
140  buffer[14] = vid.height & 255;
141  buffer[15] = vid.height >> 8;
142  buffer[16] = 32; // pixel size
143  buffer[17] = 0x20; // image is upside-down
144 
146 
147  // swap rgb to bgr
148  if (vk_swapchain.format == VK_FORMAT_R8G8B8A8_UNORM || vk_swapchain.format == VK_FORMAT_R8G8B8A8_SRGB)
149  {
150  for (i = 18; i < buffSize; i += 4)
151  {
152  temp = buffer[i];
153  buffer[i] = buffer[i + 2];
154  buffer[i + 2] = temp;
155  buffer[i + 3] = 255; // alpha component
156  }
157  }
158  else
159  {
160  for (i = 18; i < buffSize; i += 4)
161  {
162  buffer[i + 3] = 255;
163  }
164  }
165 
166  f = fopen(checkname, "wb");
167  fwrite(buffer, 1, buffSize, f);
168  fclose(f);
169 
170  free(buffer);
171  ri.Con_Printf(PRINT_ALL, "Wrote %s\n", picname);
172 }

Referenced by R_Register().

◆ Vk_Strings_f()

void Vk_Strings_f ( void  )

Definition at line 177 of file vk_rmisc.c.

178 {
179  int i = 0;
180  char ver[] = { "vkQuake2 v"VKQUAKE2_VERSION };
181  for (i = 0; i < strlen(ver); i++)
182  ver[i] += 128;
183 
184  uint32_t numDevices = 0;
185  int usedDevice = 0;
186  VkPhysicalDevice physicalDevices[32]; // make an assumption that nobody has more than 32 GPUs :-)
187  VkPhysicalDeviceProperties deviceProperties;
188  qboolean isPreferred = false;
189  int preferredDevice = (int)vk_device_idx->value;
190  int msaa = (int)ri.Cvar_Get("vk_msaa", "0", CVAR_ARCHIVE)->value;
191  uint32_t driverMajor = VK_VERSION_MAJOR(vk_device.properties.driverVersion);
192  uint32_t driverMinor = VK_VERSION_MINOR(vk_device.properties.driverVersion);
193  uint32_t driverPatch = VK_VERSION_PATCH(vk_device.properties.driverVersion);
194 
195  // NVIDIA driver version decoding scheme
196  if (vk_device.properties.vendorID == 0x10DE)
197  {
198  driverMajor = ((uint32_t)(vk_device.properties.driverVersion) >> 22) & 0x3ff;
199  driverMinor = ((uint32_t)(vk_device.properties.driverVersion) >> 14) & 0x0ff;
200 
201  uint32_t secondary = ((uint32_t)(vk_device.properties.driverVersion) >> 6) & 0x0ff;
202  uint32_t tertiary = vk_device.properties.driverVersion & 0x03f;
203 
204  driverPatch = (secondary << 8) | tertiary;
205  }
206 
207  VK_VERIFY(vkEnumeratePhysicalDevices(vk_instance, &numDevices, NULL));
208  VK_VERIFY(vkEnumeratePhysicalDevices(vk_instance, &numDevices, physicalDevices));
209 
210  if (preferredDevice >= numDevices) preferredDevice = -1;
211 
212  ri.Con_Printf(PRINT_ALL, "\n%s\n", ver);
213  ri.Con_Printf(PRINT_ALL, "------------------------------------\n");
214  ri.Con_Printf(PRINT_ALL, "Vulkan API: %d.%d\n", VK_VERSION_MAJOR(vk_config.vk_version),
215  VK_VERSION_MINOR(vk_config.vk_version));
216  ri.Con_Printf(PRINT_ALL, "Header version: %d\n", VK_HEADER_VERSION);
217  ri.Con_Printf(PRINT_ALL, "Devices found:\n");
218  for (i = 0; i < numDevices; ++i)
219  {
220  vkGetPhysicalDeviceProperties(physicalDevices[i], &deviceProperties);
221  isPreferred = (preferredDevice == i) || (preferredDevice < 0 && deviceProperties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU);
222  if (isPreferred) usedDevice = i;
223  ri.Con_Printf(PRINT_ALL, "%s#%d: %s\n", isPreferred && numDevices > 1 ? "* " : " ", i, deviceProperties.deviceName);
224  }
225  ri.Con_Printf(PRINT_ALL, "Using device #%d:\n", usedDevice);
226  ri.Con_Printf(PRINT_ALL, " deviceName: %s\n", vk_device.properties.deviceName);
227  ri.Con_Printf(PRINT_ALL, " resolution: %dx%d", vid.width, vid.height);
228  if (msaa > 0)
229  ri.Con_Printf(PRINT_ALL, " (MSAAx%d)\n", 2 << (msaa - 1));
230  else
231  ri.Con_Printf(PRINT_ALL, "\n");
232 #ifndef __linux__
233  // Intel on Windows and MacOS (Linux uses semver for Mesa drivers)
234  if (vk_device.properties.vendorID == 0x8086)
235  ri.Con_Printf(PRINT_ALL, " driverVersion: %d (0x%X)\n", vk_device.properties.driverVersion, vk_device.properties.driverVersion);
236  else
237 #endif
238  ri.Con_Printf(PRINT_ALL, " driverVersion: %d.%d.%d (0x%X)\n", driverMajor, driverMinor, driverPatch, vk_device.properties.driverVersion);
239 
240  ri.Con_Printf(PRINT_ALL, " apiVersion: %d.%d.%d\n", VK_VERSION_MAJOR(vk_device.properties.apiVersion),
241  VK_VERSION_MINOR(vk_device.properties.apiVersion),
242  VK_VERSION_PATCH(vk_device.properties.apiVersion));
243  ri.Con_Printf(PRINT_ALL, " deviceID: %d\n", vk_device.properties.deviceID);
244  ri.Con_Printf(PRINT_ALL, " vendorID: 0x%X (%s)\n", vk_device.properties.vendorID, vk_config.vendor_name);
245  ri.Con_Printf(PRINT_ALL, " deviceType: %s\n", vk_config.device_type);
246  ri.Con_Printf(PRINT_ALL, " gfx/present/transfer: %d/%d/%d\n", vk_device.gfxFamilyIndex,
249  ri.Con_Printf(PRINT_ALL, "Present mode: %s\n", vk_config.present_mode);
250  ri.Con_Printf(PRINT_ALL, "Swapchain image format: %d\n", vk_swapchain.format);
251  ri.Con_Printf(PRINT_ALL, "Supported present modes: ");
252 
253  i = 0;
255  {
257  }
258  ri.Con_Printf(PRINT_ALL, "\nEnabled extensions: ");
259 
260  i = 0;
261  while(vk_config.extensions[i])
262  {
264  }
265  ri.Con_Printf(PRINT_ALL, "\nEnabled layers: ");
266 
267  i = 0;
268  while(vk_config.layers[i])
269  {
270  ri.Con_Printf(PRINT_ALL, "%s ", vk_config.layers[i++]);
271  }
272  ri.Con_Printf(PRINT_ALL, "\n");
273 }

Referenced by R_Init(), and R_Register().

Variable Documentation

◆ dottexture

byte dottexture[8][8]
Initial value:
=
{
{0,0,0,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{0,1,1,1,1,0,0,0},
{0,1,1,1,1,0,0,0},
{0,0,1,1,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
}

Definition at line 30 of file vk_rmisc.c.

Referenced by R_InitParticleTexture().

it_sprite
@ it_sprite
Definition: r_local.h:65
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
r_notexture
image_t * r_notexture
Definition: gl_rmain.c:44
Vk_LoadPic
image_t * Vk_LoadPic(char *name, byte *pic, int width, int height, imagetype_t type, int bits, qvksampler_t *samplerType)
Definition: vk_image.c:1369
vk_instance
VkInstance vk_instance
Definition: vk_common.c:46
vkconfig_t::device_type
const char * device_type
Definition: vk_local.h:308
ri
refimport_t ri
Definition: r_main.c:25
Sys_Mkdir
void Sys_Mkdir(char *path)
Definition: q_shwin.c:135
it_wall
@ it_wall
Definition: r_local.h:66
VKQUAKE2_VERSION
#define VKQUAKE2_VERSION
Definition: vk_local.h:47
qvkdevice_t::properties
VkPhysicalDeviceProperties properties
Definition: qvk.h:41
refimport_t::Cvar_Get
cvar_t *(* Cvar_Get)(char *name, char *value, int flags)
Definition: ref.h:216
qboolean
qboolean
Definition: q_shared.h:63
x
GLint GLenum GLint x
Definition: qgl_win.c:116
i
int i
Definition: q_shared.c:305
vkconfig_t::uniform_buffer_max_usage
uint32_t uniform_buffer_max_usage
Definition: vk_local.h:320
vkconfig_t::uniform_buffer_usage
uint32_t uniform_buffer_usage
Definition: vk_local.h:319
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
vkconfig_t::layers
const char * layers[256]
Definition: vk_local.h:312
qvkdevice_t::gfxFamilyIndex
int gfxFamilyIndex
Definition: qvk.h:46
vk_device_idx
cvar_t * vk_device_idx
Definition: vk_rmain.c:122
vk_device
qvkdevice_t vk_device
Definition: vk_common.c:51
vkconfig_t::triangle_fan_index_count
uint32_t triangle_fan_index_count
Definition: vk_local.h:324
vkconfig_t::index_buffer_size
uint32_t index_buffer_size
Definition: vk_local.h:318
qvkdevice_t::presentFamilyIndex
int presentFamilyIndex
Definition: qvk.h:47
vkconfig_t::index_buffer_usage
uint32_t index_buffer_usage
Definition: vk_local.h:316
refimport_t::Con_Printf
void(* Con_Printf)(int print_level, char *str,...)
Definition: ref.h:202
PRINT_ALL
#define PRINT_ALL
Definition: qcommon.h:751
vkconfig_t::present_mode
const char * present_mode
Definition: vk_local.h:309
vkconfig_t::extensions
const char * extensions[256]
Definition: vk_local.h:311
qvkswapchain_t::format
VkFormat format
Definition: qvk.h:55
viddef_t::width
unsigned width
Definition: vid.h:29
vkconfig_t::index_buffer_max_usage
uint32_t index_buffer_max_usage
Definition: vk_local.h:317
vk_swapchain
qvkswapchain_t vk_swapchain
Definition: vk_common.c:63
CVAR_ARCHIVE
#define CVAR_ARCHIVE
Definition: q_shared.h:316
viddef_t::height
unsigned height
Definition: vid.h:29
vkconfig_t::vk_version
uint32_t vk_version
Definition: vk_local.h:306
vkconfig_t::vertex_buffer_usage
uint32_t vertex_buffer_usage
Definition: vk_local.h:313
cvar_s::value
float value
Definition: q_shared.h:331
r_particletexture
image_t * r_particletexture
Definition: gl_rmain.c:45
MAX_OSPATH
#define MAX_OSPATH
Definition: q_shared.h:81
refimport_t::FS_Gamedir
char *(* FS_Gamedir)(void)
Definition: ref.h:214
NULL
#define NULL
Definition: q_shared.h:67
vk_config
vkconfig_t vk_config
Definition: vk_rmain.c:30
VK_VERIFY
#define VK_VERIFY(x)
Definition: vk_local.h:59
dottexture
byte dottexture[8][8]
Definition: vk_rmisc.c:30
y
GLint y
Definition: qgl_win.c:115
vkconfig_t::vertex_buffer_max_usage
uint32_t vertex_buffer_max_usage
Definition: vk_local.h:314
vkconfig_t::uniform_buffer_size
uint32_t uniform_buffer_size
Definition: vk_local.h:321
vkconfig_t::vendor_name
const char * vendor_name
Definition: vk_local.h:307
QVk_ReadPixels
void QVk_ReadPixels(uint8_t *dstBuffer, uint32_t width, uint32_t height)
Definition: vk_image.c:465
vkconfig_t::triangle_fan_index_usage
uint32_t triangle_fan_index_usage
Definition: vk_local.h:322
qvkdevice_t::transferFamilyIndex
int transferFamilyIndex
Definition: qvk.h:48
vkconfig_t::vertex_buffer_size
uint32_t vertex_buffer_size
Definition: vk_local.h:315
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
vkconfig_t::triangle_fan_index_max_usage
uint32_t triangle_fan_index_max_usage
Definition: vk_local.h:323
vkconfig_t::supported_present_modes
const char * supported_present_modes[256]
Definition: vk_local.h:310
vid
viddef_t vid
Definition: r_main.c:24