cppcheck fixes

vk_common.c:1618:19: style: The if condition is the same as the previous if condition [duplicateCondition]
vk_draw.c:93:7: style: The scope of the variable 'fullname' can be reduced. [variableScope]
vk_draw.c:273:9: style: The scope of the variable 'source' can be reduced. [variableScope]
vk_draw.c:274:8: style: The scope of the variable 'frac' can be reduced. [variableScope]
vk_draw.c:274:14: style: The scope of the variable 'fracstep' can be reduced. [variableScope]
vk_draw.c:276:8: style: The scope of the variable 'row' can be reduced. [variableScope]
vk_draw.c:295:12: style: The scope of the variable 'dest' can be reduced. [variableScope]
vk_draw.c:111:45: style:inconclusive: Function 'Draw_GetPicSize' argument 3 names different: declaration 'name' definition 'pic'. [funcArgNamesDifferent]
vk_draw.c:131:57: style:inconclusive: Function 'Draw_StretchPic' argument 5 names different: declaration 'name' definition 'pic'. [funcArgNamesDifferent]
vk_draw.c:159:53: style:inconclusive: Function 'Draw_PicScaled' argument 4 names different: declaration 'factor' definition 'scale'. [funcArgNamesDifferent]
vk_draw.c:185:56: style:inconclusive: Function 'Draw_TileClear' argument 5 names different: declaration 'name' definition 'pic'. [funcArgNamesDifferent]
vk_image.c:586:7: style: The scope of the variable 'best' can be reduced. [variableScope]
vk_image.c:1170:8: style: The scope of the variable 'p' can be reduced. [variableScope]
vk_image.c:1591:7: style: The scope of the variable 'r' can be reduced. [variableScope]
vk_image.c:1591:10: style: The scope of the variable 'g' can be reduced. [variableScope]
vk_image.c:1591:13: style: The scope of the variable 'b' can be reduced. [variableScope]
vk_image.c:1592:11: style: The scope of the variable 'v' can be reduced. [variableScope]
vk_image.c:1628:9: style: The scope of the variable 'j' can be reduced. [variableScope]
vk_image.c:1261:8: style: Local variable 'i' shadows outer variable [shadowVariable]
vk_light.c:231:18: warning: Identical condition '(back<0)==side', second condition is always false [identicalConditionAfterEarlyExit]
vk_light.c:40:8: style: The scope of the variable 'a' can be reduced. [variableScope]
vk_light.c:306:9: style: The scope of the variable 'add' can be reduced. [variableScope]
vk_mesh.c:107:7: style: The scope of the variable 'count' can be reduced. [variableScope]
vk_mesh.c:316:7: style: The scope of the variable 'count' can be reduced. [variableScope]
vk_mesh.c:317:7: style: The scope of the variable 'i' can be reduced. [variableScope]
vk_mesh.c:647:9: style: The scope of the variable 'min' can be reduced. [variableScope]
vk_mesh.c:766:9: style: Local variable 'model' shadows outer variable [shadowVariable]
vk_mesh.c:267:52: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_mesh.c:750:128: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_model.c:53:9: style: The scope of the variable 'd' can be reduced. [variableScope]
vk_model.c:54:12: style: The scope of the variable 'plane' can be reduced. [variableScope]
vk_model.c:407:7: style: The scope of the variable 'next' can be reduced. [variableScope]
vk_model.c:462:12: style: The scope of the variable 'e' can be reduced. [variableScope]
vk_model.c:519:8: style: The scope of the variable 'planenum' can be reduced. [variableScope]
vk_model.c:519:18: style: The scope of the variable 'side' can be reduced. [variableScope]
vk_model.c:520:8: style: The scope of the variable 'ti' can be reduced. [variableScope]
vk_model.c:613:21: style: The scope of the variable 'p' can be reduced. [variableScope]
vk_model.c:663:21: style: The scope of the variable 'p' can be reduced. [variableScope]
vk_model.c:722:10: style: The scope of the variable 'j' can be reduced. [variableScope]
vk_model.c:783:8: style: The scope of the variable 'bits' can be reduced. [variableScope]
vk_model.c:901:18: style: The scope of the variable 'pinframe' can be reduced. [variableScope]
vk_model.c:901:29: style: The scope of the variable 'poutframe' can be reduced. [variableScope]
vk_model.c:1102:7: style: The scope of the variable 'i' can be reduced. [variableScope]
vk_model.c:1103:13: style: The scope of the variable 'sprout' can be reduced. [variableScope]
vk_model.c:1072:28: style:inconclusive: Function 'R_BeginRegistration' argument 1 names different: declaration 'map' definition 'model'. [funcArgNamesDifferent]
vk_pipeline.c:51:87: style:inconclusive: Function 'QVk_CreatePipeline' argument 2 names different: declaration 'desLayoutCount' definition 'descLayoutCount'. [funcArgNamesDifferent]
vk_rmain.c:405:10: style: The scope of the variable 'scale' can be reduced. [variableScope]
vk_rmain.c:400:28: style:inconclusive: Function 'Vk_DrawParticles' argument 1 names different: declaration 'n' definition 'num_particles'. [funcArgNamesDifferent]
vk_rmain.c:956:62: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_rmain.c:1196:12: style: Variable 'err' is assigned a value that is never used. [unreadVariable]
vk_rmisc.c:97:10: style: The scope of the variable 'temp' can be reduced. [variableScope]
vk_rmisc.c:140:23: style: Variable 'isPreferred' is assigned a value that is never used. [unreadVariable]
vk_rsurf.c:678:11: style: The scope of the variable 'k' can be reduced. [variableScope]
vk_rsurf.c:679:12: style: The scope of the variable 'pplane' can be reduced. [variableScope]
vk_rsurf.c:680:9: style: The scope of the variable 'dot' can be reduced. [variableScope]
vk_rsurf.c:682:12: style: The scope of the variable 'lt' can be reduced. [variableScope]
vk_rsurf.c:741:8: style: The scope of the variable 'i' can be reduced. [variableScope]
vk_rsurf.c:811:22: style: The scope of the variable 'mark' can be reduced. [variableScope]
vk_rsurf.c:980:10: style: The scope of the variable 'c' can be reduced. [variableScope]
vk_rsurf.c:982:7: style: The scope of the variable 'cluster' can be reduced. [variableScope]
vk_rsurf.c:1055:6: style: The scope of the variable 'height' can be reduced. [variableScope]
vk_rsurf.c:1104:13: style: The scope of the variable 'best2' can be reduced. [variableScope]
vk_rsurf.c:1142:11: style: The scope of the variable 'lindex' can be reduced. [variableScope]
vk_rsurf.c:1145:9: style: The scope of the variable 's' can be reduced. [variableScope]
vk_rsurf.c:1145:12: style: The scope of the variable 't' can be reduced. [variableScope]
vk_rsurf.c:1257:12: style: The scope of the variable 'dummy' can be reduced. [variableScope]
vk_swapchain.c:68:7: warning: Possible null pointer dereference: presentModes [nullPointer]
vk_swapchain.c:182:91: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]
vk_warp.c:57:8: style: The scope of the variable 'm' can be reduced. [variableScope]
vk_warp.c:64:8: style: The scope of the variable 's' can be reduced. [variableScope]
vk_warp.c:64:11: style: The scope of the variable 't' can be reduced. [variableScope]
vk_warp.c:168:8: style: The scope of the variable 'lindex' can be reduced. [variableScope]
vk_warp.c:325:9: style: The scope of the variable 'j' can be reduced. [variableScope]
vk_warp.c:530:11: style: The scope of the variable 'k' can be reduced. [variableScope]
This commit is contained in:
Denis Pauk 2020-03-15 14:05:03 +02:00 committed by Yamagi
parent 9e71e69d1c
commit a701226a19
13 changed files with 188 additions and 128 deletions

View file

@ -238,7 +238,7 @@ void Vk_ImageList_f (void);
void Vk_InitImages (void);
void Vk_ShutdownImages (void);
void Vk_FreeUnusedImages (void);
void Vk_DrawParticles( int n, const particle_t particles[], const unsigned colortable[768] );
void Vk_DrawParticles( int num_particles, const particle_t particles[], const unsigned colortable[768] );
void R_BeginRegistration (char *model);
struct model_s *R_RegisterModel (char *name);

View file

@ -293,7 +293,7 @@ VkResult QVk_CreateUniformBuffer(VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMe
void QVk_CreateVertexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
void QVk_CreateIndexBuffer(const void *data, VkDeviceSize size, qvkbuffer_t *dstBuffer, VkMemoryPropertyFlags reqMemFlags, VkMemoryPropertyFlags prefMemFlags);
qvkshader_t QVk_CreateShader(const uint32_t *shaderSrc, size_t shaderCodeSize, VkShaderStageFlagBits shaderStage);
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t desLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo, qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount, VkPushConstantRange *pcRange);
void QVk_CreatePipeline(const VkDescriptorSetLayout *descriptorLayout, const uint32_t descLayoutCount, const VkPipelineVertexInputStateCreateInfo *vertexInputInfo, qvkpipeline_t *pipeline, const qvkrenderpass_t *renderpass, const qvkshader_t *shaders, uint32_t shaderCount, VkPushConstantRange *pcRange);
void QVk_DestroyPipeline(qvkpipeline_t *pipeline);
uint8_t* QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSize *dstOffset);
uint8_t* QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescriptorSet *dstUboDescriptorSet);

View file

@ -1613,10 +1613,10 @@ qboolean QVk_Init(SDL_Window *window)
// restore extensions count
if (vk_validation->value)
{
extCount++;
if (vk_validation->value)
wantedExtensions[extCount - 1] = VK_EXT_DEBUG_UTILS_EXTENSION_NAME;
}
R_Printf(PRINT_ALL, "Enabled extensions: ");
for (int i = 0; i < extCount; i++)

View file

@ -90,10 +90,11 @@ Draw_FindPic
image_t *Draw_FindPic (char *name)
{
image_t *vk;
char fullname[MAX_QPATH];
if (name[0] != '/' && name[0] != '\\')
{
char fullname[MAX_QPATH];
Com_sprintf(fullname, sizeof(fullname), "pics/%s.pcx", name);
vk = Vk_FindImage(fullname, it_pic, NULL);
}
@ -108,11 +109,11 @@ image_t *Draw_FindPic (char *name)
Draw_GetPicSize
=============
*/
void Draw_GetPicSize (int *w, int *h, char *pic)
void Draw_GetPicSize (int *w, int *h, char *name)
{
image_t *vk;
vk = Draw_FindPic(pic);
vk = Draw_FindPic(name);
if (!vk)
{
*w = *h = -1;
@ -128,7 +129,7 @@ void Draw_GetPicSize (int *w, int *h, char *pic)
Draw_StretchPic
=============
*/
void Draw_StretchPic (int x, int y, int w, int h, char *pic)
void Draw_StretchPic (int x, int y, int w, int h, char *name)
{
image_t *vk;
@ -136,10 +137,10 @@ void Draw_StretchPic (int x, int y, int w, int h, char *pic)
// buffers is not initialized
return;
vk = Draw_FindPic(pic);
vk = Draw_FindPic(name);
if (!vk)
{
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, pic);
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, name);
return;
}
@ -156,7 +157,7 @@ void Draw_StretchPic (int x, int y, int w, int h, char *pic)
Draw_PicScaled
=============
*/
void Draw_PicScaled (int x, int y, char *pic, float scale)
void Draw_PicScaled (int x, int y, char *pic, float factor)
{
image_t *vk;
@ -171,7 +172,7 @@ void Draw_PicScaled (int x, int y, char *pic, float scale)
return;
}
Draw_StretchPic(x, y, vk->width*scale, vk->height*scale, pic);
Draw_StretchPic(x, y, vk->width*factor, vk->height*factor, pic);
}
/*
@ -182,7 +183,7 @@ This repeats a 64*64 tile graphic to fill the screen around a sized down
refresh window.
=============
*/
void Draw_TileClear (int x, int y, int w, int h, char *pic)
void Draw_TileClear (int x, int y, int w, int h, char *name)
{
image_t *image;
@ -190,10 +191,10 @@ void Draw_TileClear (int x, int y, int w, int h, char *pic)
// buffers is not initialized
return;
image = Draw_FindPic(pic);
image = Draw_FindPic(name);
if (!image)
{
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, pic);
R_Printf(PRINT_ALL, "%s(): Can't find pic: %s\n", __func__, name);
return;
}
@ -270,10 +271,7 @@ void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data
{
unsigned image32[256 * 256];
int i, j, trows;
byte *source;
int frac, fracstep;
float hscale;
int row;
float t;
if(!R_EndWorldRenderReady())
@ -292,10 +290,13 @@ void Draw_StretchRaw (int x, int y, int w, int h, int cols, int rows, byte *data
}
t = rows * hscale / 256;
unsigned *dest;
for (i = 0; i < trows; i++)
{
unsigned *dest;
byte *source;
int row;
int frac, fracstep;
row = (int)(i*hscale);
if (row > rows)
break;

View file

@ -583,15 +583,18 @@ qvktexture_t vk_scrapTextures[MAX_SCRAPS] = { QVVKTEXTURE_INIT };
static int Scrap_AllocBlock (int w, int h, int *x, int *y)
{
int i, j;
int best, best2;
int texnum;
for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++)
{
int best;
best = BLOCK_HEIGHT;
for (i=0 ; i<BLOCK_WIDTH-w ; i++)
{
int best2;
best2 = 0;
for (j=0 ; j<w ; j++)
@ -1167,7 +1170,6 @@ static uint32_t Vk_Upload8 (byte *data, int width, int height, qboolean mipmap,
{
unsigned *trans;
int i, s;
int p;
int miplevel;
s = width * height;
@ -1178,6 +1180,8 @@ static uint32_t Vk_Upload8 (byte *data, int width, int height, qboolean mipmap,
for (i = 0; i < s; i++)
{
int p;
p = data[i];
trans[i] = d_8to24table[p];
@ -1221,23 +1225,25 @@ Vk_LoadPic(char *name, byte *pic, int width, int realwidth,
int bits, qvksampler_t *samplerType)
{
image_t *image;
int i;
byte *texBuffer;
int upload_width, upload_height;
// find a free image_t
for (i = 0, image = vktextures; i<numvktextures; i++, image++)
{
if (image->vk_texture.resource.image == VK_NULL_HANDLE && !image->scrap)
break;
int i;
// find a free image_t
for (i = 0, image = vktextures; i<numvktextures; i++, image++)
{
if (image->vk_texture.resource.image == VK_NULL_HANDLE && !image->scrap)
break;
}
if (i == numvktextures)
{
if (numvktextures == MAX_VKTEXTURES)
ri.Sys_Error(ERR_DROP, "%s: MAX_VKTEXTURES", __func__);
numvktextures++;
}
image = &vktextures[i];
}
if (i == numvktextures)
{
if (numvktextures == MAX_VKTEXTURES)
ri.Sys_Error(ERR_DROP, "%s: MAX_VKTEXTURES", __func__);
numvktextures++;
}
image = &vktextures[i];
if (strlen(name) >= sizeof(image->name))
ri.Sys_Error(ERR_DROP, "%s: \"%s\" is too long", __func__, name);
@ -1588,8 +1594,6 @@ Draw_GetPalette
static int Draw_GetPalette (void)
{
int i;
int r, g, b;
unsigned v;
byte *pic, *pal;
int width, height;
@ -1601,6 +1605,9 @@ static int Draw_GetPalette (void)
for (i=0 ; i<256 ; i++)
{
unsigned v;
int r, g, b;
r = pal[i*3+0];
g = pal[i*3+1];
b = pal[i*3+2];
@ -1625,7 +1632,7 @@ Vk_InitImages
*/
void Vk_InitImages (void)
{
int i, j;
int i;
float overbright;
registration_sequence = 1;
@ -1640,6 +1647,8 @@ void Vk_InitImages (void)
for (i = 0; i<256; i++)
{
int j;
j = i * intensity->value;
if (j > 255)
j = 255;

View file

@ -37,7 +37,6 @@ DYNAMIC LIGHTS BLEND RENDERING
void R_RenderDlight (dlight_t *light)
{
int i, j;
float a;
float rad;
rad = light->intensity * 0.35;
@ -56,6 +55,8 @@ void R_RenderDlight (dlight_t *light)
for (i = 16; i >= 0; i--)
{
float a;
a = i / 16.0 * M_PI * 2;
for (j = 0; j < 3; j++)
{
@ -228,9 +229,6 @@ static int RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end)
if (r >= 0)
return r; // hit something
if ( (back < 0) == side )
return -1; // didn't hit anuthing
// check for impact on this node
VectorCopy (mid, lightspot);
lightplane = plane;
@ -303,7 +301,6 @@ void R_LightPoint (vec3_t p, vec3_t color)
int lnum;
dlight_t *dl;
vec3_t dist;
float add;
if (!r_worldmodel->lightdata || !currententity)
{
@ -332,6 +329,8 @@ void R_LightPoint (vec3_t p, vec3_t color)
dl = r_newrefdef.dlights;
for (lnum=0 ; lnum<r_newrefdef.num_dlights ; lnum++, dl++)
{
float add;
VectorSubtract (currententity->origin,
dl->origin,
dist);

View file

@ -104,7 +104,6 @@ static void Vk_DrawAliasFrameLerp (dmdl_t *paliashdr, float backlerp, image_t *s
daliasframe_t *frame, *oldframe;
dtrivertx_t *v, *ov, *verts;
int *order;
int count;
float frontlerp;
float alpha;
vec3_t move, delta, vectors[3];
@ -186,6 +185,8 @@ static void Vk_DrawAliasFrameLerp (dmdl_t *paliashdr, float backlerp, image_t *s
while (1)
{
int count;
// get the vertex count and primitive type
count = *order++;
if (!count)
@ -264,7 +265,7 @@ static void Vk_DrawAliasFrameLerp (dmdl_t *paliashdr, float backlerp, image_t *s
memcpy(uboData, &meshUbo, sizeof(meshUbo));
// player configuration screen model is using the UI renderpass
int pidx = r_newrefdef.rdflags & RDF_NOWORLDMODEL ? RP_UI : RP_WORLD;
int pidx = (r_newrefdef.rdflags & RDF_NOWORLDMODEL) ? RP_UI : RP_WORLD;
// non-depth write alias models don't occur with RF_WEAPONMODEL set, so no need for additional left-handed pipelines
qvkpipeline_t pipelines[2][4] = { { vk_drawModelPipelineStrip[pidx], vk_drawModelPipelineFan[pidx], vk_drawLefthandModelPipelineStrip, vk_drawLefthandModelPipelineFan },
{ vk_drawNoDepthModelPipelineStrip, vk_drawNoDepthModelPipelineFan, vk_drawLefthandModelPipelineStrip, vk_drawLefthandModelPipelineFan } };
@ -313,8 +314,6 @@ static void Vk_DrawAliasShadow (dmdl_t *paliashdr, int posenum, float *modelMatr
int *order;
vec3_t point;
float height, lheight;
int count;
int i;
qvkpipeline_t pipelines[2] = { vk_shadowsPipelineStrip, vk_shadowsPipelineFan };
enum {
@ -338,6 +337,9 @@ static void Vk_DrawAliasShadow (dmdl_t *paliashdr, int posenum, float *modelMatr
static vec3_t shadowverts[MAX_VERTS];
while (1)
{
int i;
int count;
i = 0;
// get the vertex count and primitive type
count = *order++;
@ -552,7 +554,6 @@ void R_DrawAliasModel (entity_t *e)
dmdl_t *paliashdr;
float an;
vec3_t bbox[8];
image_t *skin;
float prev_viewproj[16];
if ( !( e->flags & RF_WEAPONMODEL ) )
@ -644,11 +645,12 @@ void R_DrawAliasModel (entity_t *e)
if ( currententity->flags & RF_GLOW )
{ // bonus items will pulse with time
float scale;
float min;
scale = 0.1 * sin(r_newrefdef.time*7);
for (i=0 ; i<3 ; i++)
{
float min;
min = shadelight[i] * 0.8;
shadelight[i] += scale;
if (shadelight[i] < min)
@ -704,50 +706,54 @@ void R_DrawAliasModel (entity_t *e)
}
e->angles[PITCH] = -e->angles[PITCH]; // sigh.
float model[16];
Mat_Identity(model);
R_RotateForEntity (e, model);
e->angles[PITCH] = -e->angles[PITCH]; // sigh.
// select skin
if (currententity->skin)
skin = currententity->skin; // custom player skin
else
{
if (currententity->skinnum >= MAX_MD2SKINS)
skin = currentmodel->skins[0];
float model[16];
image_t *skin;
Mat_Identity(model);
R_RotateForEntity (e, model);
e->angles[PITCH] = -e->angles[PITCH]; // sigh.
// select skin
if (currententity->skin)
skin = currententity->skin; // custom player skin
else
{
skin = currentmodel->skins[currententity->skinnum];
if (!skin)
if (currententity->skinnum >= MAX_MD2SKINS)
skin = currentmodel->skins[0];
else
{
skin = currentmodel->skins[currententity->skinnum];
if (!skin)
skin = currentmodel->skins[0];
}
}
}
if (!skin)
skin = r_notexture; // fallback...
if (!skin)
skin = r_notexture; // fallback...
// draw it
if ( (currententity->frame >= paliashdr->num_frames)
|| (currententity->frame < 0) )
{
R_Printf(PRINT_ALL, "%s %s: no such frame %d\n",
__func__, currentmodel->name, currententity->frame);
currententity->frame = 0;
currententity->oldframe = 0;
}
// draw it
if ( (currententity->frame >= paliashdr->num_frames)
|| (currententity->frame < 0) )
{
R_Printf(PRINT_ALL, "%s %s: no such frame %d\n",
__func__, currentmodel->name, currententity->frame);
currententity->frame = 0;
currententity->oldframe = 0;
}
if ( (currententity->oldframe >= paliashdr->num_frames)
|| (currententity->oldframe < 0))
{
R_Printf(PRINT_ALL, "%s %s: no such oldframe %d\n",
__func__, currentmodel->name, currententity->oldframe);
currententity->frame = 0;
currententity->oldframe = 0;
}
if ( (currententity->oldframe >= paliashdr->num_frames)
|| (currententity->oldframe < 0))
{
R_Printf(PRINT_ALL, "%s %s: no such oldframe %d\n",
__func__, currentmodel->name, currententity->oldframe);
currententity->frame = 0;
currententity->oldframe = 0;
}
if ( !r_lerpmodels->value )
currententity->backlerp = 0;
Vk_DrawAliasFrameLerp (paliashdr, currententity->backlerp, skin, model, leftHandOffset, currententity->flags & RF_TRANSLUCENT ? 1 : 0);
if ( !r_lerpmodels->value )
currententity->backlerp = 0;
Vk_DrawAliasFrameLerp (paliashdr, currententity->backlerp, skin, model, leftHandOffset, (currententity->flags & RF_TRANSLUCENT) ? 1 : 0);
}
if ( ( currententity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ) )
{

View file

@ -50,8 +50,6 @@ Mod_PointInLeaf
mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
{
mnode_t *node;
float d;
cplane_t *plane;
if (!model || !model->nodes)
ri.Sys_Error (ERR_DROP, "Mod_PointInLeaf: bad model");
@ -59,6 +57,9 @@ mleaf_t *Mod_PointInLeaf (vec3_t p, model_t *model)
node = model->nodes;
while (1)
{
cplane_t *plane;
float d;
if (node->contents != -1)
return (mleaf_t *)node;
plane = node->plane;
@ -404,7 +405,6 @@ static void Mod_LoadTexinfo (lump_t *l)
mtexinfo_t *out, *step;
int i, j, count;
char name[MAX_QPATH];
int next;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
@ -417,6 +417,8 @@ static void Mod_LoadTexinfo (lump_t *l)
for ( i=0 ; i<count ; i++, in++, out++)
{
int next;
for (j=0 ; j<4 ; j++)
{
out->vecs[0][j] = LittleFloat (in->vecs[0][j]);
@ -459,7 +461,7 @@ Fills in s->texturemins[] and s->extents[]
static void CalcSurfaceExtents (msurface_t *s)
{
float mins[2], maxs[2], val;
int i,j, e;
int i,j;
mvertex_t *v;
mtexinfo_t *tex;
int bmins[2], bmaxs[2];
@ -471,6 +473,8 @@ static void CalcSurfaceExtents (msurface_t *s)
for (i=0 ; i<s->numedges ; i++)
{
int e;
e = loadmodel->surfedges[s->firstedge+i];
if (e >= 0)
v = &loadmodel->vertexes[loadmodel->edges[e].v[0]];
@ -516,8 +520,6 @@ static void Mod_LoadFaces (lump_t *l)
dface_t *in;
msurface_t *out;
int i, count, surfnum;
int planenum, side;
int ti;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
@ -534,6 +536,10 @@ static void Mod_LoadFaces (lump_t *l)
for (surfnum = 0; surfnum<count; surfnum++, in++, out++)
{
int side;
int ti;
int planenum;
out->firstedge = LittleLong(in->firstedge);
out->numedges = LittleShort(in->numedges);
out->flags = 0;
@ -610,7 +616,7 @@ Mod_LoadNodes
*/
static void Mod_LoadNodes (lump_t *l)
{
int i, j, count, p;
int i, j, count;
dnode_t *in;
mnode_t *out;
@ -625,6 +631,8 @@ static void Mod_LoadNodes (lump_t *l)
for ( i=0 ; i<count ; i++, in++, out++)
{
int p;
for (j=0 ; j<3 ; j++)
{
out->minmaxs[j] = LittleShort (in->mins[j]);
@ -660,7 +668,7 @@ static void Mod_LoadLeafs (lump_t *l)
{
dleaf_t *in;
mleaf_t *out;
int i, j, count, p;
int i, j, count;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
@ -673,6 +681,7 @@ static void Mod_LoadLeafs (lump_t *l)
for ( i=0 ; i<count ; i++, in++, out++)
{
int p;
unsigned firstleafface;
for (j=0 ; j<3 ; j++)
@ -719,7 +728,7 @@ Mod_LoadMarksurfaces
*/
static void Mod_LoadMarksurfaces (lump_t *l)
{
int i, j, count;
int i, count;
short *in;
msurface_t **out;
@ -734,6 +743,8 @@ static void Mod_LoadMarksurfaces (lump_t *l)
for ( i=0 ; i<count ; i++)
{
int j;
j = LittleShort(in[i]);
if (j < 0 || j >= loadmodel->numsurfaces)
ri.Sys_Error (ERR_DROP, "Mod_ParseMarksurfaces: bad surface number");
@ -780,7 +791,6 @@ static void Mod_LoadPlanes (lump_t *l)
cplane_t *out;
dplane_t *in;
int count;
int bits;
in = (void *)(mod_base + l->fileofs);
if (l->filelen % sizeof(*in))
@ -793,6 +803,8 @@ static void Mod_LoadPlanes (lump_t *l)
for ( i=0 ; i<count ; i++, in++, out++)
{
int bits;
bits = 0;
for (j=0 ; j<3 ; j++)
{
@ -898,7 +910,6 @@ static void Mod_LoadAliasModel (model_t *mod, void *buffer)
dmdl_t *pinmodel, *pheader;
dstvert_t *pinst, *poutst;
dtriangle_t *pintri, *pouttri;
daliasframe_t *pinframe, *poutframe;
int *pincmd, *poutcmd;
int version;
@ -966,6 +977,8 @@ static void Mod_LoadAliasModel (model_t *mod, void *buffer)
//
for (i=0 ; i<pheader->num_frames ; i++)
{
daliasframe_t *pinframe, *poutframe;
pinframe = (daliasframe_t *) ((byte *)pinmodel
+ pheader->ofs_frames + i * pheader->framesize);
poutframe = (daliasframe_t *) ((byte *)pheader
@ -1069,7 +1082,7 @@ Specifies the model that will be used as the world
=====================
*/
void
R_BeginRegistration (char *model)
R_BeginRegistration (char *map)
{
char fullname[MAX_QPATH];
cvar_t *flushmap;
@ -1077,7 +1090,7 @@ R_BeginRegistration (char *model)
registration_sequence++;
r_oldviewcluster = -1; // force markleafs
Com_sprintf (fullname, sizeof(fullname), "maps/%s.bsp", model);
Com_sprintf (fullname, sizeof(fullname), "maps/%s.bsp", map);
// explicitly free the old map if different
// this guarantees that mod_known[0] is the world map
@ -1099,18 +1112,20 @@ R_RegisterModel
struct model_s *R_RegisterModel (char *name)
{
model_t *mod;
int i;
dsprite_t *sprout;
dmdl_t *pheader;
mod = Mod_ForName (name, false);
if (mod)
{
int i;
mod->registration_sequence = registration_sequence;
// register any images used by the models
if (mod->type == mod_sprite)
{
dsprite_t *sprout;
sprout = (dsprite_t *)mod->extradata;
for (i=0 ; i<sprout->numframes ; i++)
mod->skins[i] = Vk_FindImage (sprout->frames[i].name, it_sprite, NULL);

View file

@ -402,7 +402,6 @@ void Vk_DrawParticles( int num_particles, const particle_t particles[], const un
const particle_t *p;
int i;
vec3_t up, right;
float scale;
byte color[4];
if (!num_particles)
@ -419,6 +418,8 @@ void Vk_DrawParticles( int num_particles, const particle_t particles[], const un
for (p = particles, i = 0; i < num_particles; i++, p++)
{
float scale;
// hack a scale up to keep particles from disapearing
scale = (p->origin[0] - r_origin[0]) * vpn[0] +
(p->origin[1] - r_origin[1]) * vpn[1] +
@ -953,7 +954,7 @@ qboolean R_EndWorldRenderReady(void)
// apply postprocessing effects (underwater view warp if the player is submerged in liquid) to offscreen buffer
QVk_BeginRenderpass(RP_WORLD_WARP);
float pushConsts[] = { r_newrefdef.rdflags & RDF_UNDERWATER ? r_newrefdef.time : 0.f, viewsize->value / 100, vid.width, vid.height };
float pushConsts[] = { (r_newrefdef.rdflags & RDF_UNDERWATER) ? r_newrefdef.time : 0.f, viewsize->value / 100, vid.width, vid.height };
vkCmdPushConstants(vk_activeCmdbuffer, vk_worldWarpPipeline.layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(pushConsts), pushConsts);
vkCmdBindDescriptorSets(vk_activeCmdbuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vk_worldWarpPipeline.layout, 0, 1, &vk_colorbuffer.descriptorSet, 0, NULL);
QVk_BindPipeline(&vk_worldWarpPipeline);
@ -1182,7 +1183,7 @@ qboolean R_SetMode (void)
ri.Cvar_SetValue("vid_fullscreen", 0);
vid_fullscreen->modified = false;
R_Printf(PRINT_ALL, "%s() - fullscreen unavailable in this mode\n", __func__);
if ((err = Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, r_mode->value, false)) == rserr_ok)
if (Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, r_mode->value, false) == rserr_ok)
return true;
}
else if (err == rserr_invalid_mode)
@ -1193,7 +1194,7 @@ qboolean R_SetMode (void)
}
// try setting it back to something safe
if ((err = Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, vk_state.prev_mode, false)) != rserr_ok)
if (Vkimp_SetMode((int*)&vid.width, (int*)&vid.height, vk_state.prev_mode, false) != rserr_ok)
{
R_Printf(PRINT_ALL, "%s() - could not revert to safe mode\n", __func__);
return false;

View file

@ -94,7 +94,7 @@ Vk_ScreenShot_f
void Vk_ScreenShot_f (void)
{
byte *buffer;
int i, temp;
int i;
size_t buffSize = vid.width * vid.height * 4;
buffer = malloc(buffSize);
@ -114,6 +114,8 @@ void Vk_ScreenShot_f (void)
{
for (i = 0; i < buffSize; i += 4)
{
int temp;
temp = buffer[i];
buffer[i] = buffer[i + 2];
buffer[i + 2] = temp;
@ -137,7 +139,6 @@ void Vk_Strings_f(void)
int usedDevice = 0;
VkPhysicalDevice *physicalDevices;
VkPhysicalDeviceProperties deviceProperties;
qboolean isPreferred = false;
int preferredDevice = (int)vk_device_idx->value;
int msaa = (int)ri.Cvar_Get("vk_msaa", "0", CVAR_ARCHIVE)->value;
uint32_t driverMajor = VK_VERSION_MAJOR(vk_device.properties.driverVersion);
@ -180,6 +181,8 @@ void Vk_Strings_f(void)
R_Printf(PRINT_ALL, "Devices found:\n");
for (i = 0; i < numDevices; ++i)
{
qboolean isPreferred = false;
vkGetPhysicalDeviceProperties(physicalDevices[i], &deviceProperties);
isPreferred = (preferredDevice == i) || (
preferredDevice < 0 &&

View file

@ -675,16 +675,16 @@ R_DrawInlineBModel
*/
static void R_DrawInlineBModel (float *modelMatrix)
{
int i, k;
cplane_t *pplane;
float dot;
int i;
msurface_t *psurf;
dlight_t *lt;
float alpha = 1.f;
// calculate dynamic lighting for bmodel
if (!vk_flashblend->value)
{
dlight_t *lt;
int k;
lt = r_newrefdef.dlights;
for (k = 0; k<r_newrefdef.num_dlights; k++, lt++)
{
@ -704,6 +704,9 @@ static void R_DrawInlineBModel (float *modelMatrix)
//
for (i = 0; i<currentmodel->nummodelsurfaces; i++, psurf++)
{
float dot;
cplane_t *pplane;
// find which side of the node we are on
pplane = psurf->plane;
@ -738,7 +741,6 @@ R_DrawBrushModel
void R_DrawBrushModel (entity_t *e)
{
vec3_t mins, maxs;
int i;
qboolean rotated;
if (currentmodel->nummodelsurfaces == 0)
@ -748,6 +750,8 @@ void R_DrawBrushModel (entity_t *e)
if (e->angles[0] || e->angles[1] || e->angles[2])
{
int i;
rotated = true;
for (i = 0; i<3; i++)
{
@ -808,7 +812,7 @@ static void R_RecursiveWorldNode (mnode_t *node)
{
int c, side, sidebit;
cplane_t *plane;
msurface_t *surf, **mark;
msurface_t *surf;
mleaf_t *pleaf;
float dot;
image_t *image;
@ -824,6 +828,8 @@ static void R_RecursiveWorldNode (mnode_t *node)
// if a leaf node, draw stuff
if (node->contents != -1)
{
msurface_t **mark;
pleaf = (mleaf_t *)node;
// check for door connected areas
@ -977,9 +983,8 @@ void R_MarkLeaves (void)
byte *vis;
byte fatvis[MAX_MAP_LEAFS/8];
mnode_t *node;
int i, c;
int i;
mleaf_t *leaf;
int cluster;
if (r_oldviewcluster == r_viewcluster && r_oldviewcluster2 == r_viewcluster2 && !r_novis->value && r_viewcluster != -1)
return;
@ -1007,6 +1012,8 @@ void R_MarkLeaves (void)
// may have to combine two clusters because of solid water boundaries
if (r_viewcluster2 != r_viewcluster)
{
int c;
memcpy (fatvis, vis, (r_worldmodel->numleafs+7)/8);
vis = Mod_ClusterPVS (r_viewcluster2, r_worldmodel);
c = (r_worldmodel->numleafs+31)/32;
@ -1017,6 +1024,8 @@ void R_MarkLeaves (void)
for (i=0,leaf=r_worldmodel->leafs ; i<r_worldmodel->numleafs ; i++, leaf++)
{
int cluster;
cluster = leaf->cluster;
if (cluster == -1)
continue;
@ -1052,7 +1061,6 @@ static void LM_InitBlock( void )
static void LM_UploadBlock( qboolean dynamic )
{
int texture;
int height = 0;
if ( dynamic )
{
@ -1066,6 +1074,7 @@ static void LM_UploadBlock( qboolean dynamic )
if ( dynamic )
{
int i;
int height = 0;
for ( i = 0; i < BLOCK_WIDTH; i++ )
{
@ -1100,13 +1109,14 @@ static void LM_UploadBlock( qboolean dynamic )
// returns a texture number and the position inside it
static qboolean LM_AllocBlock (int w, int h, int *x, int *y)
{
int i, j;
int best, best2;
int i, best;
best = BLOCK_HEIGHT;
for (i=0 ; i<BLOCK_WIDTH-w ; i++)
{
int j, best2;
best2 = 0;
for (j=0 ; j<w ; j++)
@ -1139,14 +1149,13 @@ Vk_BuildPolygonFromSurface
*/
void Vk_BuildPolygonFromSurface(msurface_t *fa)
{
int i, lindex, lnumverts;
int i, lnumverts;
medge_t *pedges, *r_pedge;
float *vec;
float s, t;
vkpoly_t *poly;
vec3_t total;
// reconstruct the polygon
// reconstruct the polygon
pedges = currentmodel->edges;
lnumverts = fa->numedges;
@ -1162,6 +1171,9 @@ void Vk_BuildPolygonFromSurface(msurface_t *fa)
for (i=0 ; i<lnumverts ; i++)
{
int lindex;
float s, t;
lindex = currentmodel->surfedges[fa->firstedge + i];
if (lindex > 0)
@ -1254,7 +1266,6 @@ void Vk_BeginBuildingLightmaps (model_t *m)
{
static lightstyle_t lightstyles[MAX_LIGHTSTYLES];
int i;
unsigned dummy[BLOCK_WIDTH * BLOCK_HEIGHT];
memset(vk_lms.allocated, 0, sizeof(vk_lms.allocated));
@ -1282,6 +1293,8 @@ void Vk_BeginBuildingLightmaps (model_t *m)
{
for (i = DYNLIGHTMAP_OFFSET; i < MAX_LIGHTMAPS*2; i++)
{
unsigned dummy[BLOCK_WIDTH * BLOCK_HEIGHT];
QVVKTEXTURE_CLEAR(vk_state.lightmap_textures[i]);
QVk_CreateTexture(&vk_state.lightmap_textures[i], (unsigned char*)dummy,
BLOCK_WIDTH, BLOCK_HEIGHT, vk_current_lmap_sampler);

View file

@ -61,6 +61,14 @@ static VkSurfaceFormatKHR getSwapSurfaceFormat(const VkSurfaceFormatKHR *surface
// internal helper
static VkPresentModeKHR getSwapPresentMode(const VkPresentModeKHR *presentModes, uint32_t presentModesCount, VkPresentModeKHR desiredMode)
{
// PRESENT_MODE_FIFO_KHR is guaranteed to exist due to spec requirements
VkPresentModeKHR usedPresentMode = VK_PRESENT_MODE_FIFO_KHR;
if (!presentModes)
{
return usedPresentMode;
}
// check if the desired present mode is supported
for (uint32_t i = 0; i < presentModesCount; ++i)
{
@ -73,8 +81,6 @@ static VkPresentModeKHR getSwapPresentMode(const VkPresentModeKHR *presentModes,
}
}
// PRESENT_MODE_FIFO_KHR is guaranteed to exist due to spec requirements
VkPresentModeKHR usedPresentMode = VK_PRESENT_MODE_FIFO_KHR;
// preferred present mode not found - choose the next best thing
for (uint32_t i = 0; i < presentModesCount; ++i)
{
@ -179,7 +185,7 @@ VkResult QVk_CreateSwapchain()
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = NULL,
.preTransform = surfaceCaps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : surfaceCaps.currentTransform,
.preTransform = (surfaceCaps.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) ? VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR : surfaceCaps.currentTransform,
.compositeAlpha = getSupportedCompositeAlpha(surfaceCaps.supportedCompositeAlpha),
.presentMode = swapPresentMode,
.clipped = VK_TRUE,

View file

@ -54,14 +54,12 @@ static void SubdividePolygon (int numverts, float *verts)
{
int i, j, k;
vec3_t mins, maxs;
float m;
float *v;
vec3_t front[64], back[64];
int f, b;
float dist[64];
float frac;
vkpoly_t *poly;
float s, t;
vec3_t total;
float total_s, total_t;
@ -72,6 +70,8 @@ static void SubdividePolygon (int numverts, float *verts)
for (i=0 ; i<3 ; i++)
{
float m;
m = (mins[i] + maxs[i]) * 0.5;
m = SUBDIVIDE_SIZE * floor (m/SUBDIVIDE_SIZE + 0.5);
if (maxs[i] - m < 8)
@ -131,6 +131,8 @@ static void SubdividePolygon (int numverts, float *verts)
total_t = 0;
for (i=0 ; i<numverts ; i++, verts+= 3)
{
float s, t;
VectorCopy (verts, poly->verts[i+1]);
s = DotProduct (verts, warpface->texinfo->vecs[0]);
t = DotProduct (verts, warpface->texinfo->vecs[1]);
@ -165,7 +167,6 @@ void Vk_SubdivideSurface (msurface_t *fa)
vec3_t verts[64];
int numverts;
int i;
int lindex;
float *vec;
warpface = fa;
@ -176,6 +177,8 @@ void Vk_SubdivideSurface (msurface_t *fa)
numverts = 0;
for (i=0 ; i<fa->numedges ; i++)
{
int lindex;
lindex = loadmodel->surfedges[fa->firstedge + i];
if (lindex > 0)
@ -322,7 +325,7 @@ static float sky_min, sky_max;
static void DrawSkyPolygon (int nump, vec3_t vecs)
{
int i,j;
int i;
vec3_t v, av;
float s, t, dv;
int axis;
@ -362,6 +365,8 @@ static void DrawSkyPolygon (int nump, vec3_t vecs)
// project new texture coords
for (i=0 ; i<nump ; i++, vecs+=3)
{
int j;
j = vec_to_st[axis][2];
if (j > 0)
dv = vecs[j - 1];
@ -527,7 +532,7 @@ void R_ClearSkyBox (void)
static void MakeSkyVec (float s, float t, int axis, float *vertexData)
{
vec3_t v, b;
int j, k;
int j;
b[0] = s * 2300;
b[1] = t * 2300;
@ -535,6 +540,8 @@ static void MakeSkyVec (float s, float t, int axis, float *vertexData)
for (j = 0; j<3; j++)
{
int k;
k = st_to_vec[axis][j];
if (k < 0)
v[j] = -b[-k - 1];