- replaced MIN/MAX in common code.

This commit is contained in:
Christoph Oelckers 2021-10-30 10:46:17 +02:00
commit eb69bbcae0
63 changed files with 200 additions and 236 deletions

View file

@ -228,7 +228,7 @@ void VkRenderState::ApplyRenderPass(int dt)
pipelineKey.ColorMask = mColorMask;
pipelineKey.CullMode = mCullMode;
pipelineKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->NumLayers() : 0;
pipelineKey.NumTextureLayers = std::max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it
pipelineKey.NumTextureLayers = max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it
if (mSpecialEffect > EFF_NONE)
{
pipelineKey.SpecialEffect = mSpecialEffect;

View file

@ -73,7 +73,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage)
{
auto fb = GetVulkanFrameBuffer();
size_t bufsize = std::max(size, (size_t)16); // For supporting zero byte buffers
size_t bufsize = max(size, (size_t)16); // For supporting zero byte buffers
// If SetData is called multiple times we have to keep the old buffers alive as there might still be draw commands referencing them
if (mBuffer)
@ -153,7 +153,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage)
void VKBuffer::SetSubData(size_t offset, size_t size, const void *data)
{
size = std::max(size, (size_t)16); // For supporting zero byte buffers
size = max(size, (size_t)16); // For supporting zero byte buffers
auto fb = GetVulkanFrameBuffer();
if (mStaging)
@ -174,7 +174,7 @@ void VKBuffer::SetSubData(size_t offset, size_t size, const void *data)
void VKBuffer::Resize(size_t newsize)
{
newsize = std::max(newsize, (size_t)16); // For supporting zero byte buffers
newsize = max(newsize, (size_t)16); // For supporting zero byte buffers
auto fb = GetVulkanFrameBuffer();
@ -222,7 +222,7 @@ void VKBuffer::Unmap()
void *VKBuffer::Lock(unsigned int size)
{
size = std::max(size, (unsigned int)16); // For supporting zero byte buffers
size = max(size, (unsigned int)16); // For supporting zero byte buffers
if (!mBuffer)
{

View file

@ -571,7 +571,7 @@ inline BufferBuilder::BufferBuilder()
inline void BufferBuilder::setSize(size_t size)
{
bufferInfo.size = std::max(size, (size_t)16);
bufferInfo.size = max(size, (size_t)16);
}
inline void BufferBuilder::setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocFlags)

View file

@ -309,7 +309,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish, bool uploadOnly)
swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get());
}
int numWaitFences = MIN(mNextSubmit, (int)maxConcurrentSubmitCount);
int numWaitFences = min(mNextSubmit, (int)maxConcurrentSubmitCount);
if (numWaitFences > 0)
{
@ -345,8 +345,8 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::function<voi
IntRect bounds;
bounds.left = bounds.top = 0;
bounds.width = std::min(tex->GetWidth(), image->Image->width);
bounds.height = std::min(tex->GetHeight(), image->Image->height);
bounds.width = min(tex->GetWidth(), image->Image->width);
bounds.height = min(tex->GetHeight(), image->Image->height);
renderFunc(bounds);
@ -628,7 +628,7 @@ void VulkanFrameBuffer::UpdateGpuStats()
if (q.endIndex <= q.startIndex)
continue;
int64_t timeElapsed = std::max(static_cast<int64_t>(timestamps[q.endIndex] - timestamps[q.startIndex]), (int64_t)0);
int64_t timeElapsed = max(static_cast<int64_t>(timestamps[q.endIndex] - timestamps[q.startIndex]), (int64_t)0);
double timeNS = timeElapsed * timestampPeriod;
FString out;

View file

@ -161,8 +161,8 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
VkSurfaceCapabilitiesKHR surfaceCapabilities = GetSurfaceCapabilities();
actualExtent = { static_cast<uint32_t>(width), static_cast<uint32_t>(height) };
actualExtent.width = std::max(surfaceCapabilities.minImageExtent.width, std::min(surfaceCapabilities.maxImageExtent.width, actualExtent.width));
actualExtent.height = std::max(surfaceCapabilities.minImageExtent.height, std::min(surfaceCapabilities.maxImageExtent.height, actualExtent.height));
actualExtent.width = max(surfaceCapabilities.minImageExtent.width, min(surfaceCapabilities.maxImageExtent.width, actualExtent.width));
actualExtent.height = max(surfaceCapabilities.minImageExtent.height, min(surfaceCapabilities.maxImageExtent.height, actualExtent.height));
if (actualExtent.width == 0 || actualExtent.height == 0)
{
swapChain = VK_NULL_HANDLE;
@ -176,9 +176,9 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain)
// When vsync is on we only want two images. This creates a slight performance penalty in exchange for reduced input latency (less mouse lag).
// When vsync is off we want three images as it allows us to generate new images even during the vertical blanking period where one entry is being used by the presentation engine.
if (swapChainPresentMode == VK_PRESENT_MODE_MAILBOX_KHR || swapChainPresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR)
imageCount = std::min(imageCount, (uint32_t)3);
imageCount = min(imageCount, (uint32_t)3);
else
imageCount = std::min(imageCount, (uint32_t)2);
imageCount = min(imageCount, (uint32_t)2);
VkSwapchainCreateInfoKHR swapChainCreateInfo = {};
swapChainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;

View file

@ -218,8 +218,8 @@ int VkHardwareTexture::GetMipLevels(int w, int h)
int levels = 1;
while (w > 1 || h > 1)
{
w = std::max(w >> 1, 1);
h = std::max(h >> 1, 1);
w = max(w >> 1, 1);
h = max(h >> 1, 1);
levels++;
}
return levels;
@ -391,7 +391,7 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
int numLayers = NumLayers();
auto fb = GetVulkanFrameBuffer();
auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(std::max(numLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS));
auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(max(numLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS));
descriptor->SetDebugName("VkHardwareTexture.mDescriptorSets");

View file

@ -117,8 +117,8 @@ void VkTextureImage::GenerateMipmaps(VulkanCommandBuffer *cmdbuffer)
barrier0.execute(cmdbuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT);
Layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
int nextWidth = std::max(mipWidth >> 1, 1);
int nextHeight = std::max(mipHeight >> 1, 1);
int nextWidth = max(mipWidth >> 1, 1);
int nextHeight = max(mipHeight >> 1, 1);
VkImageBlit blit = {};
blit.srcOffsets[0] = { 0, 0, 0 };