Fix build with Q_min/Q_max: 5da0e5f0

This commit is contained in:
Denis Pauk 2023-12-16 23:36:54 +02:00
parent 6b70251341
commit 80ff901765
12 changed files with 53 additions and 30 deletions

View file

@ -2065,7 +2065,7 @@ Mod_LoadBSPX(int filesize, const byte *mod_base)
} }
for (i = 0; i < numlumps; i++) { for (i = 0; i < numlumps; i++) {
xofs = max(xofs, xofs = Q_max(xofs,
(header->lumps[i].fileofs + header->lumps[i].filelen + 3) & ~3); (header->lumps[i].fileofs + header->lumps[i].filelen + 3) & ~3);
} }

View file

@ -291,7 +291,8 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp)
{ {
R_DrawAliasDrawCommands(currententity, R_DrawAliasDrawCommands(currententity,
order + mesh_nodes[i * 2], order + mesh_nodes[i * 2],
order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), order + Q_min(
paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]),
alpha, verts); alpha, verts);
} }
} }
@ -423,7 +424,7 @@ R_DrawAliasShadow(entity_t *currententity, dmdl_t *paliashdr, int posenum)
{ {
R_DrawAliasShadowCommand(currententity, R_DrawAliasShadowCommand(currententity,
order + mesh_nodes[i * 2], order + mesh_nodes[i * 2],
order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), order + Q_min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]),
height, lheight); height, lheight);
} }
} }

View file

@ -343,7 +343,8 @@ DrawAliasFrameLerp(dmdl_t *paliashdr, entity_t* entity, vec3_t shadelight)
{ {
DrawAliasFrameLerpCommands(paliashdr, entity, shadelight, DrawAliasFrameLerpCommands(paliashdr, entity, shadelight,
order + mesh_nodes[i * 2], order + mesh_nodes[i * 2],
order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]),
shadedots, alpha, colorOnly, verts); shadedots, alpha, colorOnly, verts);
} }
} }
@ -532,7 +533,8 @@ DrawAliasShadow(gl3_shadowinfo_t* shadowInfo)
{ {
DrawAliasShadowCommands( DrawAliasShadowCommands(
order + mesh_nodes[i * 2], order + mesh_nodes[i * 2],
order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), order + Q_min(
paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]),
shadevector, height, lheight); shadevector, height, lheight);
} }
} }

View file

@ -116,7 +116,8 @@ GL4_TextureMode(char *string)
/* Set anisotropic filter if supported and enabled */ /* Set anisotropic filter if supported and enabled */
if (gl4config.anisotropic && gl_anisotropic->value) if (gl4config.anisotropic && gl_anisotropic->value)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, max(gl_anisotropic->value, 1.f)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY,
Q_max(gl_anisotropic->value, 1.f));
} }
} }
else /* texture has no mipmaps */ else /* texture has no mipmaps */
@ -227,7 +228,7 @@ GL4_Upload32(unsigned *data, int width, int height, qboolean mipmap)
if (mipmap && gl4config.anisotropic && gl_anisotropic->value) if (mipmap && gl4config.anisotropic && gl_anisotropic->value)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, max(gl_anisotropic->value, 1.f)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY, Q_max(gl_anisotropic->value, 1.f));
} }
return res; return res;

View file

@ -874,7 +874,8 @@ static void CreateSamplersHelper(VkSampler *samplers, VkSamplerAddressMode addre
assert((vk_device.properties.limits.maxSamplerAnisotropy > 1.f) && "maxSamplerAnisotropy is 1"); assert((vk_device.properties.limits.maxSamplerAnisotropy > 1.f) && "maxSamplerAnisotropy is 1");
if (vk_device.features.samplerAnisotropy && vk_aniso->value > 0.f) if (vk_device.features.samplerAnisotropy && vk_aniso->value > 0.f)
{ {
const float maxAniso = min(max(vk_aniso->value, 1.f), vk_device.properties.limits.maxSamplerAnisotropy); const float maxAniso = Q_min(Q_max(vk_aniso->value, 1.f),
vk_device.properties.limits.maxSamplerAnisotropy);
samplerInfo.anisotropyEnable = VK_TRUE; samplerInfo.anisotropyEnable = VK_TRUE;
samplerInfo.maxAnisotropy = maxAniso; samplerInfo.maxAnisotropy = maxAniso;
} }
@ -1973,8 +1974,10 @@ qboolean QVk_Init(void)
if (vid_fullscreen->value == 2) if (vid_fullscreen->value == 2)
{ {
// Center viewport in "keep resolution mode". // Center viewport in "keep resolution mode".
vk_viewport.x = max(0.f, (float)(vk_swapchain.extent.width - (uint32_t)(vid.width)) / 2.0f); vk_viewport.x = Q_max(
vk_viewport.y = max(0.f, (float)(vk_swapchain.extent.height - (uint32_t)(vid.height)) / 2.0f); 0.f, (float)(vk_swapchain.extent.width - (uint32_t)(vid.width)) / 2.0f);
vk_viewport.y = Q_max(
0.f, (float)(vk_swapchain.extent.height - (uint32_t)(vid.height)) / 2.0f);
} }
else else
{ {
@ -1983,8 +1986,10 @@ qboolean QVk_Init(void)
} }
vk_viewport.minDepth = 0.f; vk_viewport.minDepth = 0.f;
vk_viewport.maxDepth = 1.f; vk_viewport.maxDepth = 1.f;
vk_viewport.width = min((float)vid.width, (float)(vk_swapchain.extent.width) - vk_viewport.x); vk_viewport.width = Q_min(
vk_viewport.height = min((float)vid.height, (float)(vk_swapchain.extent.height) - vk_viewport.y); (float)vid.width, (float)(vk_swapchain.extent.width) - vk_viewport.x);
vk_viewport.height = Q_min(
(float)vid.height, (float)(vk_swapchain.extent.height) - vk_viewport.y);
vk_scissor.offset.x = 0; vk_scissor.offset.x = 0;
vk_scissor.offset.y = 0; vk_scissor.offset.y = 0;
vk_scissor.extent = vk_swapchain.extent; vk_scissor.extent = vk_swapchain.extent;
@ -2387,16 +2392,21 @@ uint8_t *QVk_GetVertexBuffer(VkDeviceSize size, VkBuffer *dstBuffer, VkDeviceSiz
{ {
if (vk_dynVertexBuffers[vk_activeDynBufferIdx].currentOffset + size > vk_config.vertex_buffer_size) if (vk_dynVertexBuffers[vk_activeDynBufferIdx].currentOffset + size > vk_config.vertex_buffer_size)
{ {
vk_config.vertex_buffer_size = max(vk_config.vertex_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); vk_config.vertex_buffer_size = Q_max(
vk_config.vertex_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size));
R_Printf(PRINT_ALL, "Resizing dynamic vertex buffer to %ukB\n", vk_config.vertex_buffer_size / 1024); R_Printf(PRINT_ALL, "Resizing dynamic vertex buffer to %ukB\n", vk_config.vertex_buffer_size / 1024);
int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx]; int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx];
vk_swapBuffersCnt[vk_activeSwapBufferIdx] += NUM_DYNBUFFERS; vk_swapBuffersCnt[vk_activeSwapBufferIdx] += NUM_DYNBUFFERS;
if (vk_swapBuffers[vk_activeSwapBufferIdx] == NULL) if (vk_swapBuffers[vk_activeSwapBufferIdx] == NULL)
{
vk_swapBuffers[vk_activeSwapBufferIdx] = malloc(sizeof(qvkbuffer_t) * vk_swapBuffersCnt[vk_activeSwapBufferIdx]); vk_swapBuffers[vk_activeSwapBufferIdx] = malloc(sizeof(qvkbuffer_t) * vk_swapBuffersCnt[vk_activeSwapBufferIdx]);
}
else else
{
vk_swapBuffers[vk_activeSwapBufferIdx] = realloc(vk_swapBuffers[vk_activeSwapBufferIdx], sizeof(qvkbuffer_t) * vk_swapBuffersCnt[vk_activeSwapBufferIdx]); vk_swapBuffers[vk_activeSwapBufferIdx] = realloc(vk_swapBuffers[vk_activeSwapBufferIdx], sizeof(qvkbuffer_t) * vk_swapBuffersCnt[vk_activeSwapBufferIdx]);
}
for (int i = 0; i < NUM_DYNBUFFERS; ++i) for (int i = 0; i < NUM_DYNBUFFERS; ++i)
{ {
@ -2433,7 +2443,8 @@ static uint8_t *QVk_GetIndexBuffer(VkDeviceSize size, VkDeviceSize *dstOffset, i
if (vk_dynIndexBuffers[currentBufferIdx].currentOffset + aligned_size > vk_config.index_buffer_size) if (vk_dynIndexBuffers[currentBufferIdx].currentOffset + aligned_size > vk_config.index_buffer_size)
{ {
vk_config.index_buffer_size = max(vk_config.index_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); vk_config.index_buffer_size = Q_max(
vk_config.index_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size));
R_Printf(PRINT_ALL, "Resizing dynamic index buffer to %ukB\n", vk_config.index_buffer_size / 1024); R_Printf(PRINT_ALL, "Resizing dynamic index buffer to %ukB\n", vk_config.index_buffer_size / 1024);
int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx]; int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx];
@ -2478,7 +2489,8 @@ uint8_t *QVk_GetUniformBuffer(VkDeviceSize size, uint32_t *dstOffset, VkDescript
if (vk_dynUniformBuffers[vk_activeDynBufferIdx].currentOffset + UNIFORM_ALLOC_SIZE > vk_config.uniform_buffer_size) if (vk_dynUniformBuffers[vk_activeDynBufferIdx].currentOffset + UNIFORM_ALLOC_SIZE > vk_config.uniform_buffer_size)
{ {
vk_config.uniform_buffer_size = max(vk_config.uniform_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size)); vk_config.uniform_buffer_size = Q_max(
vk_config.uniform_buffer_size * BUFFER_RESIZE_FACTOR, NextPow2(size));
R_Printf(PRINT_ALL, "Resizing dynamic uniform buffer to %ukB\n", vk_config.uniform_buffer_size / 1024); R_Printf(PRINT_ALL, "Resizing dynamic uniform buffer to %ukB\n", vk_config.uniform_buffer_size / 1024);
int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx]; int swapBufferOffset = vk_swapBuffersCnt[vk_activeSwapBufferIdx];

View file

@ -304,7 +304,7 @@ Vk_DrawAliasFrameLerpCommands (entity_t *currententity, int *order, int *order_e
} }
drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].vertexCount = count; drawInfo[pipelineIdx][pipeCounters[pipelineIdx]].vertexCount = count;
maxTriangleFanIdxCnt = max(maxTriangleFanIdxCnt, ((count - 2) * 3)); maxTriangleFanIdxCnt = Q_max(maxTriangleFanIdxCnt, ((count - 2) * 3));
if (currententity->flags & if (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE)) (RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE))
@ -530,7 +530,8 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdl_t *paliashdr, float backlerp
{ {
Vk_DrawAliasFrameLerpCommands(currententity, Vk_DrawAliasFrameLerpCommands(currententity,
order + mesh_nodes[i * 2], order + mesh_nodes[i * 2],
order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]),
alpha, skin, alpha, skin,
modelMatrix, leftHandOffset, translucentIdx, verts); modelMatrix, leftHandOffset, translucentIdx, verts);
} }
@ -1084,7 +1085,8 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)
{ {
Vk_DrawAliasShadow ( Vk_DrawAliasShadow (
order + mesh_nodes[i * 2], order + mesh_nodes[i * 2],
order + min(paliashdr->num_glcmds, mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]), order + Q_min(paliashdr->num_glcmds,
mesh_nodes[i * 2] + mesh_nodes[i * 2 + 1]),
currententity->frame, model, currententity); currententity->frame, model, currententity);
} }
} }

View file

@ -179,17 +179,21 @@ VkResult QVk_CreateSwapchain()
VkExtent2D extent = surfaceCaps.currentExtent; VkExtent2D extent = surfaceCaps.currentExtent;
if(extent.width == UINT32_MAX || extent.height == UINT32_MAX) if(extent.width == UINT32_MAX || extent.height == UINT32_MAX)
{ {
extent.width = max(surfaceCaps.minImageExtent.width, min(surfaceCaps.maxImageExtent.width, vid.width)); extent.width = Q_max(surfaceCaps.minImageExtent.width,
extent.height = max(surfaceCaps.minImageExtent.height, min(surfaceCaps.maxImageExtent.height, vid.height)); Q_min(surfaceCaps.maxImageExtent.width, vid.width));
extent.height = Q_max(surfaceCaps.minImageExtent.height,
Q_min(surfaceCaps.maxImageExtent.height, vid.height));
} }
// request at least 2 images - this fixes fullscreen crashes on AMD when launching the game in fullscreen // request at least 2 images - this fixes fullscreen crashes on AMD when launching the game in fullscreen
uint32_t imageCount = max(2, surfaceCaps.minImageCount); uint32_t imageCount = Q_max(2, surfaceCaps.minImageCount);
if (swapPresentMode != VK_PRESENT_MODE_FIFO_KHR) if (swapPresentMode != VK_PRESENT_MODE_FIFO_KHR)
imageCount = max(3, surfaceCaps.minImageCount); imageCount = Q_max(3, surfaceCaps.minImageCount);
if (surfaceCaps.maxImageCount > 0) if (surfaceCaps.maxImageCount > 0)
imageCount = min(imageCount, surfaceCaps.maxImageCount); {
imageCount = Q_min(imageCount, surfaceCaps.maxImageCount);
}
VkImageUsageFlags imgUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; VkImageUsageFlags imgUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;

View file

@ -1153,7 +1153,7 @@ ai_run_slide(edict_t *self, float distance)
/* clamp maximum sideways move for non flyers to make them look less jerky */ /* clamp maximum sideways move for non flyers to make them look less jerky */
if (!(self->flags & FL_FLY)) if (!(self->flags & FL_FLY))
{ {
distance = min(distance, 8.0); distance = Q_min(distance, 8.0);
} }
if (M_walkmove(self, self->ideal_yaw + ofs, distance)) if (M_walkmove(self, self->ideal_yaw + ofs, distance))

View file

@ -1182,12 +1182,12 @@ T_RadiusNukeDamage(edict_t *inflictor, edict_t *attacker, float damage,
if (dist < 2048) if (dist < 2048)
{ {
ent->client->nuke_framenum = max(ent->client->nuke_framenum, ent->client->nuke_framenum = Q_max(ent->client->nuke_framenum,
level.framenum + 15); level.framenum + 15);
} }
else else
{ {
ent->client->nuke_framenum = max(ent->client->nuke_framenum, ent->client->nuke_framenum = Q_max(ent->client->nuke_framenum,
level.framenum + 10); level.framenum + 10);
} }
} }

View file

@ -1538,7 +1538,7 @@ SP_monster_carrier(edict_t *self)
VectorSet(self->maxs, 56, 56, 44); VectorSet(self->maxs, 56, 56, 44);
/* 2000 - 4000 health */ /* 2000 - 4000 health */
self->health = max(2000, 2000 + 1000 * ((skill->value) - 1)); self->health = Q_max(2000, 2000 + 1000 * ((skill->value) - 1));
/* add health in coop (500 * skill) */ /* add health in coop (500 * skill) */
if (coop->value) if (coop->value)

View file

@ -1815,7 +1815,8 @@ WidowCalcSlots(edict_t *self)
if (coop->value) if (coop->value)
{ {
self->monsterinfo.monster_slots = min(6, self->monsterinfo.monster_slots + ((skill->value) * (CountPlayers() - 1))); self->monsterinfo.monster_slots = Q_min(
6, self->monsterinfo.monster_slots + ((skill->value) * (CountPlayers() - 1)));
} }
} }

View file

@ -1251,7 +1251,7 @@ widow2_die(edict_t *self, edict_t *inflictor /* unused */, edict_t *attacker /*
/* check for gib */ /* check for gib */
if (self->health <= self->gib_health) if (self->health <= self->gib_health)
{ {
clipped = min(damage, 100); clipped = Q_min(damage, 100);
gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0); gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 0);
@ -1704,7 +1704,7 @@ ThrowWidowGibReal(edict_t *self, char *gibname, int damage, int type,
gib->velocity[0] *= 2; gib->velocity[0] *= 2;
gib->velocity[1] *= 2; gib->velocity[1] *= 2;
ClipGibVelocity(gib); ClipGibVelocity(gib);
gib->velocity[2] = max((350 + (random() * 100.0)), gib->velocity[2]); gib->velocity[2] = Q_max((350 + (random() * 100.0)), gib->velocity[2]);
gib->gravity = 0.25; gib->gravity = 0.25;
gib->touch = widow_gib_touch; gib->touch = widow_gib_touch;
gib->owner = self; gib->owner = self;