[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
Signed by: crueter
GPG key ID: 425ACD2D4830EBC6
276 changed files with 973 additions and 1010 deletions

View file

@ -67,8 +67,8 @@ void DecompressBlocks(std::span<const u8> input, std::span<u8> output, BufferIma
const u32 width = copy.image_extent.width;
const u32 height = copy.image_extent.height * copy.image_subresource.num_layers;
const u32 depth = copy.image_extent.depth;
const u32 block_width = std::min(width, BLOCK_SIZE);
const u32 block_height = std::min(height, BLOCK_SIZE);
const u32 block_width = (std::min)(width, BLOCK_SIZE);
const u32 block_height = (std::min)(height, BLOCK_SIZE);
const u32 pitch = width * out_bpp;
size_t input_offset = 0;
size_t output_offset = 0;

View file

@ -185,7 +185,7 @@ bool AddImageAlias(ImageBase& lhs, ImageBase& rhs, ImageId lhs_id, ImageId rhs_i
const bool is_rhs_compressed = rhs_block.width > 1 || rhs_block.height > 1;
const s32 lhs_mips = lhs.info.resources.levels;
const s32 rhs_mips = rhs.info.resources.levels;
const s32 num_mips = std::min(lhs_mips - base->level, rhs_mips);
const s32 num_mips = (std::min)(lhs_mips - base->level, rhs_mips);
AliasedImage lhs_alias;
AliasedImage rhs_alias;
lhs_alias.id = rhs_id;
@ -204,9 +204,9 @@ bool AddImageAlias(ImageBase& lhs, ImageBase& rhs, ImageId lhs_id, ImageId rhs_i
rhs_size.height = Common::DivCeil(rhs_size.height, rhs_block.height);
}
const Extent3D copy_size{
.width = std::min(lhs_size.width, rhs_size.width),
.height = std::min(lhs_size.height, rhs_size.height),
.depth = std::min(lhs_size.depth, rhs_size.depth),
.width = (std::min)(lhs_size.width, rhs_size.width),
.height = (std::min)(lhs_size.height, rhs_size.height),
.depth = (std::min)(lhs_size.depth, rhs_size.depth),
};
if (copy_size.width == 0 || copy_size.height == 0) {
LOG_WARNING(HW_GPU, "Copy size is smaller than block size. Mip cannot be aliased.");
@ -218,7 +218,7 @@ bool AddImageAlias(ImageBase& lhs, ImageBase& rhs, ImageId lhs_id, ImageId rhs_i
const Offset3D rhs_offset{0, 0, is_rhs_3d ? base->layer : 0};
const s32 lhs_layers = is_lhs_3d ? 1 : lhs.info.resources.layers - base->layer;
const s32 rhs_layers = is_rhs_3d ? 1 : rhs.info.resources.layers;
const s32 num_layers = std::min(lhs_layers, rhs_layers);
const s32 num_layers = (std::min)(lhs_layers, rhs_layers);
const SubresourceLayers lhs_subresource{
.base_level = mip_level,
.base_layer = 0,

View file

@ -18,9 +18,9 @@ ImageViewBase::ImageViewBase(const ImageViewInfo& info, const ImageInfo& image_i
ImageId image_id_, GPUVAddr addr)
: image_id{image_id_}, gpu_addr{addr}, format{info.format}, type{info.type}, range{info.range},
size{
.width = std::max(image_info.size.width >> range.base.level, 1u),
.height = std::max(image_info.size.height >> range.base.level, 1u),
.depth = std::max(image_info.size.depth >> range.base.level, 1u),
.width = (std::max)(image_info.size.width >> range.base.level, 1u),
.height = (std::max)(image_info.size.height >> range.base.level, 1u),
.depth = (std::max)(image_info.size.depth >> range.base.level, 1u),
} {
ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false, true),
"Image view format {} is incompatible with image format {}", info.format,

View file

@ -19,7 +19,7 @@ namespace {
using Tegra::Texture::TextureType;
constexpr u8 RENDER_TARGET_SWIZZLE = std::numeric_limits<u8>::max();
constexpr u8 RENDER_TARGET_SWIZZLE = (std::numeric_limits<u8>::max)();
[[nodiscard]] u8 CastSwizzle(SwizzleSource source) {
const u8 casted = static_cast<u8>(source);

View file

@ -56,14 +56,14 @@ TextureCache<P>::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManag
const s64 device_local_memory = static_cast<s64>(runtime.GetDeviceLocalMemory());
const s64 min_spacing_expected = device_local_memory - 1_GiB;
const s64 min_spacing_critical = device_local_memory - 512_MiB;
const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD);
const s64 mem_threshold = (std::min)(device_local_memory, TARGET_THRESHOLD);
const s64 min_vacancy_expected = (6 * mem_threshold) / 10;
const s64 min_vacancy_critical = (2 * mem_threshold) / 10;
expected_memory = static_cast<u64>(
std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected),
(std::max)((std::min)(device_local_memory - min_vacancy_expected, min_spacing_expected),
DEFAULT_EXPECTED_MEMORY));
critical_memory = static_cast<u64>(
std::max(std::min(device_local_memory - min_vacancy_critical, min_spacing_critical),
(std::max)((std::min)(device_local_memory - min_vacancy_critical, min_spacing_critical),
DEFAULT_CRITICAL_MEMORY));
minimum_memory = static_cast<u64>((device_local_memory - mem_threshold) / 2);
} else {
@ -586,8 +586,8 @@ std::optional<VideoCore::RasterizerDownloadArea> TextureCache<P>::GetFlushArea(D
area->end_address = cpu_addr + size;
area->preemtive = true;
}
area->start_address = std::min(area->start_address, image.cpu_addr);
area->end_address = std::max(area->end_address, image.cpu_addr_end);
area->start_address = (std::min)(area->start_address, image.cpu_addr);
area->end_address = (std::max)(area->end_address, image.cpu_addr_end);
for (auto image_view_id : image.image_view_ids) {
auto& image_view = slot_image_views[image_view_id];
image_view.flags |= ImageViewFlagBits::PreemtiveDownload;
@ -1273,7 +1273,7 @@ u64 TextureCache<P>::GetScaledImageSizeBytes(const ImageBase& image) {
const u64 down_shift = static_cast<u64>(Settings::values.resolution_info.down_shift +
Settings::values.resolution_info.down_shift);
const u64 image_size_bytes =
static_cast<u64>(std::max(image.guest_size_bytes, image.unswizzled_size_bytes));
static_cast<u64>((std::max)(image.guest_size_bytes, image.unswizzled_size_bytes));
const u64 tentative_size = (image_size_bytes * scale_up) >> down_shift;
const u64 fitted_size = Common::AlignUp(tentative_size, 1024);
return fitted_size;
@ -1994,7 +1994,7 @@ void TextureCache<P>::RegisterImage(ImageId image_id) {
ASSERT_MSG(False(image.flags & ImageFlagBits::Registered),
"Trying to register an already registered image");
image.flags |= ImageFlagBits::Registered;
u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes);
u64 tentative_size = (std::max)(image.guest_size_bytes, image.unswizzled_size_bytes);
if ((IsPixelFormatASTC(image.info.format) &&
True(image.flags & ImageFlagBits::AcceleratedUpload)) ||
True(image.flags & ImageFlagBits::Converted)) {
@ -2168,7 +2168,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) {
if (image.HasScaled()) {
total_used_memory -= GetScaledImageSizeBytes(image);
}
u64 tentative_size = std::max(image.guest_size_bytes, image.unswizzled_size_bytes);
u64 tentative_size = (std::max)(image.guest_size_bytes, image.unswizzled_size_bytes);
if ((IsPixelFormatASTC(image.info.format) &&
True(image.flags & ImageFlagBits::AcceleratedUpload)) ||
True(image.flags & ImageFlagBits::Converted)) {
@ -2302,7 +2302,7 @@ void TextureCache<P>::SynchronizeAliases(ImageId image_id) {
for (const AliasedImage& aliased : image.aliased_images) {
ImageBase& aliased_image = slot_images[aliased.id];
if (image.modification_tick < aliased_image.modification_tick) {
most_recent_tick = std::max(most_recent_tick, aliased_image.modification_tick);
most_recent_tick = (std::max)(most_recent_tick, aliased_image.modification_tick);
aliased_images.push_back(&aliased);
any_rescaled |= True(aliased_image.flags & ImageFlagBits::Rescaled);
any_modified |= True(aliased_image.flags & ImageFlagBits::GpuModified);
@ -2443,9 +2443,9 @@ void TextureCache<P>::CopyImage(ImageId dst_id, ImageId src_id, std::vector<Imag
ImageView& dst_view = slot_image_views[dst_view_id];
ImageView& src_view = slot_image_views[src_view_id];
[[maybe_unused]] const Extent3D expected_size{
.width = std::min(dst_view.size.width, src_view.size.width),
.height = std::min(dst_view.size.height, src_view.size.height),
.depth = std::min(dst_view.size.depth, src_view.size.depth),
.width = (std::min)(dst_view.size.width, src_view.size.width),
.height = (std::min)(dst_view.size.height, src_view.size.height),
.depth = (std::min)(dst_view.size.depth, src_view.size.depth),
};
const Extent3D scaled_extent = [is_rescaled, expected_size]() {
if (!is_rescaled) {

View file

@ -108,7 +108,7 @@ class TextureCache : public VideoCommon::ChannelSetupCaches<TextureCacheChannelI
/// True when the API can do asynchronous texture downloads.
static constexpr bool IMPLEMENTS_ASYNC_DOWNLOADS = P::IMPLEMENTS_ASYNC_DOWNLOADS;
static constexpr size_t UNSET_CHANNEL{std::numeric_limits<size_t>::max()};
static constexpr size_t UNSET_CHANNEL{(std::numeric_limits<size_t>::max)()};
static constexpr s64 TARGET_THRESHOLD = 4_GiB;
static constexpr s64 DEFAULT_EXPECTED_MEMORY = 1_GiB + 125_MiB;

View file

@ -327,8 +327,8 @@ template <u32 GOB_EXTENT>
}
const SubresourceExtent resources = new_info.resources;
return SubresourceExtent{
.levels = std::max(resources.levels, info.resources.levels),
.layers = std::max(resources.layers, info.resources.layers),
.levels = (std::max)(resources.levels, info.resources.levels),
.layers = (std::max)(resources.layers, info.resources.layers),
};
}
@ -354,7 +354,7 @@ template <u32 GOB_EXTENT>
return std::nullopt;
}
return SubresourceExtent{
.levels = std::max(new_info.resources.levels, info.resources.levels + base.level),
.levels = (std::max)(new_info.resources.levels, info.resources.levels + base.level),
.layers = 1,
};
}
@ -388,8 +388,8 @@ template <u32 GOB_EXTENT>
return std::nullopt;
}
return SubresourceExtent{
.levels = std::max(new_info.resources.levels, info.resources.levels + base.level),
.layers = std::max(new_info.resources.layers, info.resources.layers + base.layer),
.levels = (std::max)(new_info.resources.levels, info.resources.levels + base.level),
.layers = (std::max)(new_info.resources.layers, info.resources.layers + base.layer),
};
}
@ -439,14 +439,14 @@ template <u32 GOB_EXTENT>
}
layers = 1;
} else {
layers = std::max(resources.layers, info.resources.layers + base->layer);
layers = (std::max)(resources.layers, info.resources.layers + base->layer);
}
return OverlapResult{
.gpu_addr = overlap.gpu_addr,
.cpu_addr = overlap.cpu_addr,
.resources =
{
.levels = std::max(resources.levels + base->level, info.resources.levels),
.levels = (std::max)(resources.levels + base->level, info.resources.levels),
.layers = layers,
},
};