[cmake] enable clang-cl and WoA builds (#348)

Compilation and CMake fixes for both Windows on ARM and clang-cl, meaning Windows can now be built on both MSVC and clang on both amd64 and aarch64.

Compiling on clang is *dramatically* faster so this should be useful for CI.

Co-authored-by: crueter <crueter@eden-emu.dev>
Co-authored-by: crueter <crueter@crueter.xyz>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/348
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-09-09 20:47:49 +02:00 committed by crueter
parent 428f136a75
commit 9d2681ecc9
No known key found for this signature in database
GPG key ID: 425ACD2D4830EBC6
276 changed files with 973 additions and 1010 deletions

View file

@ -340,8 +340,8 @@ void UpdateTwoTexturesDescriptorSet(const Device& device, VkDescriptorSet descri
void BindBlitState(vk::CommandBuffer cmdbuf, const Region2D& dst_region) {
const VkOffset2D offset{
.x = std::min(dst_region.start.x, dst_region.end.x),
.y = std::min(dst_region.start.y, dst_region.end.y),
.x = (std::min)(dst_region.start.x, dst_region.end.x),
.y = (std::min)(dst_region.start.y, dst_region.end.y),
};
const VkExtent2D extent{
.width = static_cast<u32>(std::abs(dst_region.end.x - dst_region.start.x)),

View file

@ -573,8 +573,8 @@ void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bi
buffer_handles.push_back(handle);
}
const u32 device_max = device.GetMaxVertexInputBindings();
const u32 min_binding = std::min(bindings.min_index, device_max);
const u32 max_binding = std::min(bindings.max_index, device_max);
const u32 min_binding = (std::min)(bindings.min_index, device_max);
const u32 max_binding = (std::min)(bindings.max_index, device_max);
const u32 binding_count = max_binding - min_binding;
if (binding_count == 0) {
return;

View file

@ -562,7 +562,7 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
static_vector<VkVertexInputBindingDivisorDescriptionEXT, 32> vertex_binding_divisors;
static_vector<VkVertexInputAttributeDescription, 32> vertex_attributes;
if (!key.state.dynamic_vertex_input) {
const size_t num_vertex_arrays = std::min(
const size_t num_vertex_arrays = (std::min)(
Maxwell::NumVertexArrays, static_cast<size_t>(device.GetMaxVertexInputBindings()));
for (size_t index = 0; index < num_vertex_arrays; ++index) {
const bool instanced = key.state.binding_divisors[index] != 0;

View file

@ -86,8 +86,8 @@ bool CanBlitToSwapchain(const vk::PhysicalDevice& physical_device, VkFormat form
},
.extent =
{
.width = std::min(frame_width, swapchain_width),
.height = std::min(frame_height, swapchain_height),
.width = (std::min)(frame_width, swapchain_width),
.height = (std::min)(frame_height, swapchain_height),
.depth = 1,
},
};

View file

@ -202,8 +202,8 @@ public:
});
rasterizer->SyncOperation(std::move(func));
accumulation_since_last_sync = false;
first_accumulation_checkpoint = std::min(first_accumulation_checkpoint, num_slots_used);
last_accumulation_checkpoint = std::max(last_accumulation_checkpoint, num_slots_used);
first_accumulation_checkpoint = (std::min)(first_accumulation_checkpoint, num_slots_used);
last_accumulation_checkpoint = (std::max)(last_accumulation_checkpoint, num_slots_used);
}
void CloseCounter() override {
@ -311,9 +311,9 @@ public:
if (has_multi_queries) {
const size_t min_accumulation_limit =
std::min(first_accumulation_checkpoint, num_slots_used);
(std::min)(first_accumulation_checkpoint, num_slots_used);
const size_t max_accumulation_limit =
std::max(last_accumulation_checkpoint, num_slots_used);
(std::max)(last_accumulation_checkpoint, num_slots_used);
const size_t intermediary_buffer_index = ObtainBuffer<false>(num_slots_used);
resolve_buffers.push_back(intermediary_buffer_index);
queries_prefix_scan_pass->Run(*accumulation_buffer, *buffers[intermediary_buffer_index],
@ -332,7 +332,7 @@ public:
rasterizer->SyncOperation(std::move(func));
AbandonCurrentQuery();
num_slots_used = 0;
first_accumulation_checkpoint = std::numeric_limits<size_t>::max();
first_accumulation_checkpoint = (std::numeric_limits<size_t>::max)();
last_accumulation_checkpoint = 0;
accumulation_since_last_sync = has_multi_queries;
pending_sync.clear();
@ -414,7 +414,7 @@ private:
size_t start_slot = query->start_slot;
for (size_t i = 0; i < banks_set; i++) {
auto& the_bank = bank_pool.GetBank(bank_id);
size_t amount = std::min(the_bank.Size() - start_slot, size_slots);
size_t amount = (std::min)(the_bank.Size() - start_slot, size_slots);
func(&the_bank, start_slot, amount);
bank_id = the_bank.next_bank - 1;
start_slot = 0;
@ -431,11 +431,11 @@ private:
auto* query = GetQuery(q);
ApplyBankOp(query, [&indexer](SamplesQueryBank* bank, size_t start, size_t amount) {
auto id_ = bank->GetIndex();
auto pair = indexer.try_emplace(id_, std::numeric_limits<size_t>::max(),
std::numeric_limits<size_t>::min());
auto pair = indexer.try_emplace(id_, (std::numeric_limits<size_t>::max)(),
(std::numeric_limits<size_t>::min)());
auto& current_pair = pair.first->second;
current_pair.first = std::min(current_pair.first, start);
current_pair.second = std::max(current_pair.second, amount + start);
current_pair.first = (std::min)(current_pair.first, start);
current_pair.second = (std::max)(current_pair.second, amount + start);
});
}
for (auto& cont : indexer) {

View file

@ -131,8 +131,8 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
s32 max_y = lower_left ? (clip_height - src.min_y) : src.max_y.Value();
// Bound to render area
min_y = std::max(min_y, 0);
max_y = std::max(max_y, 0);
min_y = (std::max)(min_y, 0);
max_y = (std::max)(max_y, 0);
if (src.enable) {
scissor.offset.x = scale_up(src.min_x);
@ -142,8 +142,8 @@ VkRect2D GetScissorState(const Maxwell& regs, size_t index, u32 up_scale = 1, u3
} else {
scissor.offset.x = 0;
scissor.offset.y = 0;
scissor.extent.width = std::numeric_limits<s32>::max();
scissor.extent.height = std::numeric_limits<s32>::max();
scissor.extent.width = (std::numeric_limits<s32>::max)();
scissor.extent.height = (std::numeric_limits<s32>::max)();
}
return scissor;
}
@ -380,8 +380,8 @@ void RasterizerVulkan::Clear(u32 layer_count) {
VkRect2D default_scissor;
default_scissor.offset.x = 0;
default_scissor.offset.y = 0;
default_scissor.extent.width = std::numeric_limits<s32>::max();
default_scissor.extent.height = std::numeric_limits<s32>::max();
default_scissor.extent.width = (std::numeric_limits<s32>::max)();
default_scissor.extent.height = (std::numeric_limits<s32>::max)();
VkClearRect clear_rect{
.rect = regs.clear_control.use_scissor ? GetScissorState(regs, 0, up_scale, down_shift)
@ -393,8 +393,8 @@ void RasterizerVulkan::Clear(u32 layer_count) {
return;
}
clear_rect.rect.extent = VkExtent2D{
.width = std::min(clear_rect.rect.extent.width, render_area.width),
.height = std::min(clear_rect.rect.extent.height, render_area.height),
.width = (std::min)(clear_rect.rect.extent.width, render_area.width),
.height = (std::min)(clear_rect.rect.extent.height, render_area.height),
};
const u32 color_attachment = regs.clear_surface.RT;

View file

@ -31,7 +31,7 @@ size_t GetStreamBufferSize(const Device& device) {
VkDeviceSize size{0};
if (device.HasDebuggingToolAttached()) {
ForEachDeviceLocalHostVisibleHeap(device, [&size](size_t index, VkMemoryHeap& heap) {
size = std::max(size, heap.size);
size = (std::max)(size, heap.size);
});
// If rebar is not supported, cut the max heap size to 40%. This will allow 2 captures to be
// loaded at the same time in RenderDoc. If rebar is supported, this shouldn't be an issue
@ -42,7 +42,7 @@ size_t GetStreamBufferSize(const Device& device) {
} else {
size = MAX_STREAM_BUFFER_SIZE;
}
return std::min(Common::AlignUp(size, MAX_ALIGNMENT), MAX_STREAM_BUFFER_SIZE);
return (std::min)(Common::AlignUp(size, MAX_ALIGNMENT), MAX_STREAM_BUFFER_SIZE);
}
} // Anonymous namespace
@ -104,7 +104,7 @@ void StagingBufferPool::TickFrame() {
StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) {
if (AreRegionsActive(Region(free_iterator) + 1,
std::min(Region(iterator + size) + 1, NUM_SYNCS))) {
(std::min)(Region(iterator + size) + 1, NUM_SYNCS))) {
// Avoid waiting for the previous usages to be free
return GetStagingBuffer(size, MemoryUsage::Upload);
}
@ -112,7 +112,7 @@ StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) {
std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + Region(iterator),
current_tick);
used_iterator = iterator;
free_iterator = std::max(free_iterator, iterator + size);
free_iterator = (std::max)(free_iterator, iterator + size);
if (iterator + size >= stream_buffer_size) {
std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + NUM_SYNCS,
@ -170,7 +170,7 @@ std::optional<StagingBufferRef> StagingBufferPool::TryGetReservedBuffer(size_t s
}
}
cache_level.iterate_index = std::distance(entries.begin(), it) + 1;
it->tick = deferred ? std::numeric_limits<u64>::max() : scheduler.CurrentTick();
it->tick = deferred ? (std::numeric_limits<u64>::max)() : scheduler.CurrentTick();
ASSERT(!it->deferred);
it->deferred = deferred;
return it->Ref();
@ -206,7 +206,7 @@ StagingBufferRef StagingBufferPool::CreateStagingBuffer(size_t size, MemoryUsage
.usage = usage,
.log2_level = log2,
.index = unique_ids++,
.tick = deferred ? std::numeric_limits<u64>::max() : scheduler.CurrentTick(),
.tick = deferred ? (std::numeric_limits<u64>::max)() : scheduler.CurrentTick(),
.deferred = deferred,
});
return entry.Ref();
@ -240,7 +240,7 @@ void StagingBufferPool::ReleaseLevel(StagingBuffersCache& cache, size_t log2) {
return scheduler.IsFree(entry.tick);
};
const size_t begin_offset = staging.delete_index;
const size_t end_offset = std::min(begin_offset + deletions_per_tick, old_size);
const size_t end_offset = (std::min)(begin_offset + deletions_per_tick, old_size);
const auto begin = entries.begin() + begin_offset;
const auto end = entries.begin() + end_offset;
entries.erase(std::remove_if(begin, end, is_deletable), end);

View file

@ -70,7 +70,7 @@ enum : u8 {
Last,
};
static_assert(Last <= std::numeric_limits<u8>::max());
static_assert(Last <= (std::numeric_limits<u8>::max)());
} // namespace Dirty

View file

@ -79,15 +79,15 @@ static VkPresentModeKHR ChooseSwapPresentMode(bool has_imm, bool has_mailbox,
}
VkExtent2D ChooseSwapExtent(const VkSurfaceCapabilitiesKHR& capabilities, u32 width, u32 height) {
constexpr auto undefined_size{std::numeric_limits<u32>::max()};
constexpr auto undefined_size{(std::numeric_limits<u32>::max)()};
if (capabilities.currentExtent.width != undefined_size) {
return capabilities.currentExtent;
}
VkExtent2D extent;
extent.width = std::max(capabilities.minImageExtent.width,
std::min(capabilities.maxImageExtent.width, width));
extent.height = std::max(capabilities.minImageExtent.height,
std::min(capabilities.maxImageExtent.height, height));
extent.width = (std::max)(capabilities.minImageExtent.width,
(std::min)(capabilities.maxImageExtent.width, width));
extent.height = (std::max)(capabilities.minImageExtent.height,
(std::min)(capabilities.maxImageExtent.height, height));
return extent;
}
@ -172,7 +172,7 @@ void Swapchain::Create(
bool Swapchain::AcquireNextImage() {
const VkResult result = device.GetLogical().AcquireNextImageKHR(
*swapchain, std::numeric_limits<u64>::max(), *present_semaphores[frame_index],
*swapchain, (std::numeric_limits<u64>::max)(), *present_semaphores[frame_index],
VK_NULL_HANDLE, &image_index);
switch (result) {
case VK_SUCCESS:
@ -261,10 +261,10 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
requested_image_count = capabilities.maxImageCount;
} else {
requested_image_count =
std::max(requested_image_count, std::min(3U, capabilities.maxImageCount));
(std::max)(requested_image_count, (std::min)(3U, capabilities.maxImageCount));
}
} else {
requested_image_count = std::max(requested_image_count, 3U);
requested_image_count = (std::max)(requested_image_count, 3U);
}
VkSwapchainCreateInfoKHR swapchain_ci{
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,

View file

@ -509,16 +509,16 @@ TransformBufferCopies(std::span<const VideoCommon::BufferCopy> copies, size_t bu
}
}
struct RangedBarrierRange {
u32 min_mip = std::numeric_limits<u32>::max();
u32 max_mip = std::numeric_limits<u32>::min();
u32 min_layer = std::numeric_limits<u32>::max();
u32 max_layer = std::numeric_limits<u32>::min();
u32 min_mip = (std::numeric_limits<u32>::max)();
u32 max_mip = (std::numeric_limits<u32>::min)();
u32 min_layer = (std::numeric_limits<u32>::max)();
u32 max_layer = (std::numeric_limits<u32>::min)();
void AddLayers(const VkImageSubresourceLayers& layers) {
min_mip = std::min(min_mip, layers.mipLevel);
max_mip = std::max(max_mip, layers.mipLevel + 1);
min_layer = std::min(min_layer, layers.baseArrayLayer);
max_layer = std::max(max_layer, layers.baseArrayLayer + layers.layerCount);
min_mip = (std::min)(min_mip, layers.mipLevel);
max_mip = (std::max)(max_mip, layers.mipLevel + 1);
min_layer = (std::min)(min_layer, layers.baseArrayLayer);
max_layer = (std::max)(max_layer, layers.baseArrayLayer + layers.layerCount);
}
VkImageSubresourceRange SubresourceRange(VkImageAspectFlags aspect_mask) const noexcept {
@ -747,8 +747,8 @@ void BlitScale(Scheduler& scheduler, VkImage src_image, VkImage dst_image, const
.z = 0,
},
{
.x = std::max(1, src_size.x >> level),
.y = std::max(1, src_size.y >> level),
.x = (std::max)(1, src_size.x >> level),
.y = (std::max)(1, src_size.y >> level),
.z = 1,
},
},
@ -765,8 +765,8 @@ void BlitScale(Scheduler& scheduler, VkImage src_image, VkImage dst_image, const
.z = 0,
},
{
.x = std::max(1, dst_size.x >> level),
.y = std::max(1, dst_size.y >> level),
.x = (std::max)(1, dst_size.x >> level),
.y = (std::max)(1, dst_size.y >> level),
.z = 1,
},
},
@ -1956,8 +1956,8 @@ bool Image::BlitScaleHelper(bool scale_up) {
.end = {static_cast<s32>(dst_width), static_cast<s32>(dst_height)},
};
const VkExtent2D extent{
.width = std::max(scaled_width, info.size.width),
.height = std::max(scaled_height, info.size.height),
.width = (std::max)(scaled_width, info.size.width),
.height = (std::max)(scaled_height, info.size.height),
};
auto* view_ptr = blit_view.get();
@ -2310,21 +2310,21 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime,
is_rescaled = is_rescaled_;
const auto& resolution = runtime.resolution;
u32 width = std::numeric_limits<u32>::max();
u32 height = std::numeric_limits<u32>::max();
u32 width = (std::numeric_limits<u32>::max)();
u32 height = (std::numeric_limits<u32>::max)();
for (size_t index = 0; index < NUM_RT; ++index) {
const ImageView* const color_buffer = color_buffers[index];
if (!color_buffer) {
renderpass_key.color_formats[index] = PixelFormat::Invalid;
continue;
}
width = std::min(width, is_rescaled ? resolution.ScaleUp(color_buffer->size.width)
width = (std::min)(width, is_rescaled ? resolution.ScaleUp(color_buffer->size.width)
: color_buffer->size.width);
height = std::min(height, is_rescaled ? resolution.ScaleUp(color_buffer->size.height)
height = (std::min)(height, is_rescaled ? resolution.ScaleUp(color_buffer->size.height)
: color_buffer->size.height);
attachments.push_back(color_buffer->RenderTarget());
renderpass_key.color_formats[index] = color_buffer->format;
num_layers = std::max(num_layers, color_buffer->range.extent.layers);
num_layers = (std::max)(num_layers, color_buffer->range.extent.layers);
images[num_images] = color_buffer->ImageHandle();
image_ranges[num_images] = MakeSubresourceRange(color_buffer);
rt_map[index] = num_images;
@ -2333,13 +2333,13 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime,
}
const size_t num_colors = attachments.size();
if (depth_buffer) {
width = std::min(width, is_rescaled ? resolution.ScaleUp(depth_buffer->size.width)
width = (std::min)(width, is_rescaled ? resolution.ScaleUp(depth_buffer->size.width)
: depth_buffer->size.width);
height = std::min(height, is_rescaled ? resolution.ScaleUp(depth_buffer->size.height)
height = (std::min)(height, is_rescaled ? resolution.ScaleUp(depth_buffer->size.height)
: depth_buffer->size.height);
attachments.push_back(depth_buffer->RenderTarget());
renderpass_key.depth_format = depth_buffer->format;
num_layers = std::max(num_layers, depth_buffer->range.extent.layers);
num_layers = (std::max)(num_layers, depth_buffer->range.extent.layers);
images[num_images] = depth_buffer->ImageHandle();
const VkImageSubresourceRange subresource_range = MakeSubresourceRange(depth_buffer);
image_ranges[num_images] = subresource_range;
@ -2353,8 +2353,8 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime,
renderpass_key.samples = samples;
renderpass = runtime.render_pass_cache.Get(renderpass_key);
render_area.width = std::min(render_area.width, width);
render_area.height = std::min(render_area.height, height);
render_area.width = (std::min)(render_area.width, width);
render_area.height = (std::min)(render_area.height, height);
num_color_buffers = static_cast<u32>(num_colors);
framebuffer = runtime.device.GetLogical().CreateFramebuffer({
@ -2366,7 +2366,7 @@ void Framebuffer::CreateFramebuffer(TextureCacheRuntime& runtime,
.pAttachments = attachments.data(),
.width = render_area.width,
.height = render_area.height,
.layers = static_cast<u32>(std::max(num_layers, 1)),
.layers = static_cast<u32>((std::max)(num_layers, 1)),
});
}