Misc: Fix new clang-cl warnings

This commit is contained in:
Stenzek 2024-11-16 14:01:12 +10:00
parent 854a8eb1bb
commit d5e2db0dee
No known key found for this signature in database
12 changed files with 73 additions and 26 deletions

View File

@ -386,7 +386,7 @@ public:
#undef RELATIONAL_OPERATOR
private:
void internal_resize(size_t size, T* prev_ptr, size_t prev_size)
void internal_resize(size_t size, T* prev_ptr, [[maybe_unused]] size_t prev_size)
{
if constexpr (alignment > 0)
{

View File

@ -125,7 +125,7 @@ static void report_at_maximum_capacity(size_t MaxSize) {
// Note: Moving this function into the header may cause performance regression.
template <class Size_T>
static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) {
static size_t getNewCapacity(size_t MinSize, [[maybe_unused]] size_t TSize, size_t OldCapacity) {
constexpr size_t MaxSize = std::numeric_limits<Size_T>::max();
// Ensure we can fit the new capacity.

View File

@ -165,9 +165,13 @@ void DInputSource::Shutdown()
while (!m_controllers.empty())
{
const u32 index = static_cast<u32>(m_controllers.size() - 1);
InputManager::OnInputDeviceDisconnected(
InputBindingKey{{.source_type = InputSourceType::DInput, .source_index = index}},
GetDeviceIdentifier(static_cast<u32>(m_controllers.size() - 1)));
InputManager::OnInputDeviceDisconnected(InputBindingKey{{.source_type = InputSourceType::DInput,
.source_index = index,
.source_subtype = InputSubclass::None,
.modifier = InputModifier::None,
.invert = 0,
.data = 0}},
GetDeviceIdentifier(static_cast<u32>(m_controllers.size() - 1)));
m_controllers.pop_back();
}
}
@ -270,9 +274,13 @@ void DInputSource::PollEvents()
if (hr != DI_OK)
{
InputManager::OnInputDeviceDisconnected(
InputBindingKey{{.source_type = InputSourceType::DInput, .source_index = static_cast<u32>(i)}},
GetDeviceIdentifier(static_cast<u32>(i)));
InputManager::OnInputDeviceDisconnected(InputBindingKey{{.source_type = InputSourceType::DInput,
.source_index = static_cast<u32>(i),
.source_subtype = InputSubclass::None,
.modifier = InputModifier::None,
.invert = 0,
.data = 0}},
GetDeviceIdentifier(static_cast<u32>(i)));
m_controllers.erase(m_controllers.begin() + i);
continue;
}

View File

@ -1630,7 +1630,10 @@ bool GPUDevice::TranslateVulkanSpvToLanguage(const std::span<const u8> spirv, GP
const spvc_hlsl_resource_binding rb = {.stage = execmodel,
.desc_set = UBO_DESCRIPTOR_SET,
.binding = 0,
.cbv = {.register_space = 0, .register_binding = 0}};
.cbv = {.register_space = 0, .register_binding = 0},
.uav = {},
.srv = {},
.sampler = {}};
if ((sres = dyn_libs::spvc_compiler_hlsl_add_resource_binding(scompiler, &rb)) != SPVC_SUCCESS)
{
Error::SetStringFmt(error, "spvc_compiler_hlsl_add_resource_binding() failed: {}", static_cast<int>(sres));
@ -1645,6 +1648,8 @@ bool GPUDevice::TranslateVulkanSpvToLanguage(const std::span<const u8> spirv, GP
const spvc_hlsl_resource_binding rb = {.stage = execmodel,
.desc_set = TEXTURE_DESCRIPTOR_SET,
.binding = i,
.cbv = {},
.uav = {},
.srv = {.register_space = 0, .register_binding = i},
.sampler = {.register_space = 0, .register_binding = i}};
if ((sres = dyn_libs::spvc_compiler_hlsl_add_resource_binding(scompiler, &rb)) != SPVC_SUCCESS)

View File

@ -664,6 +664,8 @@ bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp,
FileCallback cb = {
.mgr = {
.next_input_byte = nullptr,
.bytes_in_buffer = 0,
.init_source = [](j_decompress_ptr cinfo) {},
.fill_input_buffer = [](j_decompress_ptr cinfo) -> boolean {
FileCallback* cb = BASE_FROM_RECORD_FIELD(cinfo->src, FileCallback, mgr);
@ -821,6 +823,8 @@ bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE
FileCallback cb = {
.mgr = {
.next_output_byte = nullptr,
.free_in_buffer = 0,
.init_destination =
[](j_compress_ptr cinfo) {
FileCallback* cb = BASE_FROM_RECORD_FIELD(cinfo->dest, FileCallback, mgr);

View File

@ -72,7 +72,7 @@ union InputBindingKey
InputSubclass source_subtype : 3; ///< if 1, binding is for an axis and not a button (used for controllers)
InputModifier modifier : 2;
u32 invert : 1; ///< if 1, value is inverted prior to being sent to the sink
u32 unused : 14;
u32 : 14;
u32 data;
};

View File

@ -1386,7 +1386,8 @@ bool MediaCaptureMF::SendFrame(const PendingFrame& pf, Error* error)
}
DWORD status;
MFT_OUTPUT_DATA_BUFFER yuv_buf = {.pSample = m_video_yuv_sample.Get()};
MFT_OUTPUT_DATA_BUFFER yuv_buf = {
.dwStreamID = 0, .pSample = m_video_yuv_sample.Get(), .dwStatus = 0, .pEvents = nullptr};
hr = m_video_yuv_transform->ProcessOutput(0, 1, &yuv_buf, &status);
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
break;
@ -1453,7 +1454,8 @@ bool MediaCaptureMF::ProcessVideoOutputSamples(Error* error)
}
}
MFT_OUTPUT_DATA_BUFFER video_buf = {.pSample = m_video_output_sample.Get()};
MFT_OUTPUT_DATA_BUFFER video_buf = {
.dwStreamID = 0, .pSample = m_video_output_sample.Get(), .dwStatus = 0, .pEvents = nullptr};
DWORD status;
hr = m_video_encode_transform->ProcessOutput(0, 1, &video_buf, &status);
if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
@ -1570,7 +1572,8 @@ bool MediaCaptureMF::ProcessVideoEvents(Error* error)
}
}
MFT_OUTPUT_DATA_BUFFER video_buf = {.pSample = m_video_output_sample.Get()};
MFT_OUTPUT_DATA_BUFFER video_buf = {
.dwStreamID = 0, .pSample = m_video_output_sample.Get(), .dwStatus = 0, .pEvents = nullptr};
DWORD status;
if (FAILED(hr = m_video_encode_transform->ProcessOutput(0, 1, &video_buf, &status))) [[unlikely]]
{
@ -2883,12 +2886,13 @@ static constexpr const std::array<const char*, static_cast<size_t>(MediaCaptureB
"FFmpeg",
#endif
};
static constexpr const std::array<const char*, static_cast<size_t>(MediaCaptureBackend::MaxCount)> s_backend_display_names = {
static constexpr const std::array<const char*, static_cast<size_t>(MediaCaptureBackend::MaxCount)>
s_backend_display_names = {
#ifdef _WIN32
TRANSLATE_DISAMBIG_NOOP("Settings", "Media Foundation", "MediaCaptureBackend"),
TRANSLATE_DISAMBIG_NOOP("Settings", "Media Foundation", "MediaCaptureBackend"),
#endif
#ifndef __ANDROID__
TRANSLATE_DISAMBIG_NOOP("Settings", "FFmpeg", "MediaCaptureBackend"),
TRANSLATE_DISAMBIG_NOOP("Settings", "FFmpeg", "MediaCaptureBackend"),
#endif
};
static_assert(s_backend_names.size() == static_cast<size_t>(MediaCaptureBackend::MaxCount));

View File

@ -826,9 +826,13 @@ bool SDLInputSource::CloseDevice(int joystick_index)
if (it == m_controllers.end())
return false;
InputManager::OnInputDeviceDisconnected(
InputBindingKey{{.source_type = InputSourceType::SDL, .source_index = static_cast<u32>(it->player_id)}},
fmt::format("SDL-{}", it->player_id));
InputManager::OnInputDeviceDisconnected(InputBindingKey{{.source_type = InputSourceType::SDL,
.source_index = static_cast<u32>(it->player_id),
.source_subtype = InputSubclass::None,
.modifier = InputModifier::None,
.invert = 0,
.data = 0}},
fmt::format("SDL-{}", it->player_id));
if (it->haptic)
SDL_HapticClose(it->haptic);

View File

@ -89,6 +89,9 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
if (m_window_info.type == WindowInfo::Type::Win32)
{
const VkWin32SurfaceCreateInfoKHR surface_create_info = {.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR,
.pNext = nullptr,
.flags = 0,
.hinstance = NULL,
.hwnd = static_cast<HWND>(m_window_info.window_handle)};
const VkResult res = vkCreateWin32SurfaceKHR(instance, &surface_create_info, nullptr, &m_surface);
if (res != VK_SUCCESS)
@ -109,6 +112,8 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
return false;
const VkMetalSurfaceCreateInfoEXT surface_create_info = {.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT,
.pNext = nullptr,
.flags = 0,
.pLayer = static_cast<const CAMetalLayer*>(m_metal_layer)};
const VkResult res = vkCreateMetalSurfaceEXT(instance, &surface_create_info, nullptr, &m_surface);
if (res != VK_SUCCESS)
@ -126,6 +131,8 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
{
const VkAndroidSurfaceCreateInfoKHR surface_create_info = {
.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR,
.pNext = nullptr,
.flags = 0,
.window = static_cast<ANativeWindow*>(m_window_info.window_handle)};
const VkResult res = vkCreateAndroidSurfaceKHR(instance, &surface_create_info, nullptr, &m_surface);
if (res != VK_SUCCESS)
@ -143,6 +150,8 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
{
const VkXcbSurfaceCreateInfoKHR surface_create_info = {
.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR,
.pNext = nullptr,
.flags = 0,
.connection = static_cast<xcb_connection_t*>(m_window_info.display_connection),
.window = static_cast<xcb_window_t>(reinterpret_cast<uintptr_t>(m_window_info.window_handle))};
const VkResult res = vkCreateXcbSurfaceKHR(instance, &surface_create_info, nullptr, &m_surface);
@ -160,9 +169,11 @@ bool VulkanSwapChain::CreateSurface(VkInstance instance, VkPhysicalDevice physic
if (m_window_info.type == WindowInfo::Type::Wayland)
{
const VkWaylandSurfaceCreateInfoKHR surface_create_info = {
VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR, nullptr, 0,
static_cast<struct wl_display*>(m_window_info.display_connection),
static_cast<struct wl_surface*>(m_window_info.window_handle)};
.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
.pNext = nullptr,
.flags = 0,
.display = static_cast<struct wl_display*>(m_window_info.display_connection),
.surface = static_cast<struct wl_surface*>(m_window_info.window_handle)};
VkResult res = vkCreateWaylandSurfaceKHR(instance, &surface_create_info, nullptr, &m_surface);
if (res != VK_SUCCESS)
{
@ -403,6 +414,8 @@ bool VulkanSwapChain::CreateSwapChain(VulkanDevice& dev, Error* error)
// Now we can actually create the swap chain
VkSwapchainCreateInfoKHR swap_chain_info = {.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.pNext = nullptr,
.flags = 0,
.surface = m_surface,
.minImageCount = image_count,
.imageFormat = surface_format->format,
@ -411,6 +424,8 @@ bool VulkanSwapChain::CreateSwapChain(VulkanDevice& dev, Error* error)
.imageArrayLayers = 1u,
.imageUsage = image_usage,
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
.queueFamilyIndexCount = 0,
.pQueueFamilyIndices = nullptr,
.preTransform = transform,
.compositeAlpha = alpha,
.presentMode = present_mode.value(),
@ -529,6 +544,8 @@ bool VulkanSwapChain::CreateSwapChainImages(VulkanDevice& dev, Error* error)
const VkImageViewCreateInfo view_info = {
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
.pNext = nullptr,
.flags = 0,
.image = images[i],
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = VulkanDevice::TEXTURE_FORMAT_MAPPING[static_cast<u8>(m_window_info.surface_format)],
@ -734,6 +751,7 @@ void VulkanSwapChain::ReleaseCurrentImage()
VulkanDevice::GetInstance().WaitForGPUIdle();
const VkReleaseSwapchainImagesInfoEXT info = {.sType = VK_STRUCTURE_TYPE_RELEASE_SWAPCHAIN_IMAGES_INFO_EXT,
.pNext = nullptr,
.swapchain = m_swap_chain,
.imageIndexCount = 1,
.pImageIndices = &m_current_image};

View File

@ -236,6 +236,7 @@ bool Win32RawInputSource::OpenDevices()
RID_DEVICE_INFO devinfo = {
.cbSize = sizeof(devinfo),
.dwType = RIM_TYPEMOUSE,
.mouse = {},
};
UINT devinfo_size = sizeof(devinfo);
if (GetRawInputDeviceInfoW(rid.hDevice, RIDI_DEVICEINFO, &devinfo, &devinfo_size) <= 0 ||

View File

@ -66,7 +66,8 @@ static std::optional<float> GetRefreshRateFromDisplayConfig(HWND hwnd, Error* er
DISPLAYCONFIG_SOURCE_DEVICE_NAME sdn = {.header = {.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME,
.size = sizeof(DISPLAYCONFIG_SOURCE_DEVICE_NAME),
.adapterId = pi.sourceInfo.adapterId,
.id = pi.sourceInfo.id}};
.id = pi.sourceInfo.id},
.viewGdiDeviceName = {}};
LONG res = DisplayConfigGetDeviceInfo(&sdn.header);
if (res != ERROR_SUCCESS)
{

View File

@ -444,10 +444,12 @@ void XInputSource::HandleControllerDisconnection(u32 index)
{
INFO_LOG("XInput controller {} disconnected.", index);
InputManager::OnInputDeviceDisconnected({{
.source_type = InputSourceType::XInput,
InputManager::OnInputDeviceDisconnected({{.source_type = InputSourceType::XInput,
.source_index = index,
}},
.source_subtype = InputSubclass::None,
.modifier = InputModifier::None,
.invert = 0,
.data = 0}},
fmt::format("XInput-{}", index));
m_controllers[index] = {};
}