1
0
mirror of https://github.com/libretro/RetroArch synced 2025-02-16 03:40:12 +00:00

(Vulkan/Win32) C89_BUILD fixes

This commit is contained in:
twinaphex 2017-08-12 17:56:30 +02:00
parent 6611ccf3fa
commit 9c32d03c1e
7 changed files with 94 additions and 76 deletions

@ -772,9 +772,12 @@ static void vulkan_check_dynamic_state(
if (vk->tracker.dirty & VULKAN_DIRTY_DYNAMIC_BIT)
{
const VkRect2D sci = {
{ vk->vp.x, vk->vp.y },
{ vk->vp.width, vk->vp.height }};
VkRect2D sci;
sci.offset.x = vk->vp.x;
sci.offset.y = vk->vp.y;
sci.extent.width = vk->vp.width;
sci.extent.height = vk->vp.height;
vkCmdSetViewport(vk->cmd, 0, 1, &vk->vk_vp);
vkCmdSetScissor (vk->cmd, 0, 1, &sci);
@ -1144,8 +1147,15 @@ struct vk_buffer_chain vulkan_buffer_chain_init(
VkDeviceSize alignment,
VkBufferUsageFlags usage)
{
struct vk_buffer_chain chain = {
block_size, alignment, 0, usage, NULL, NULL };
struct vk_buffer_chain chain;
chain.block_size = block_size;
chain.alignment = alignment;
chain.offset = 0;
chain.usage = usage;
chain.head = NULL;
chain.current = NULL;
return chain;
}
@ -1487,12 +1497,13 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
for (i = 0; i < queue_count; i++)
{
VkQueueFlags required;
VkBool32 supported = VK_FALSE;
vkGetPhysicalDeviceSurfaceSupportKHR(
vk->context.gpu, i,
vk->vk_surface, &supported);
VkQueueFlags required = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT;
required = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT;
if (supported && ((queue_properties[i].queueFlags & required) == required))
{
vk->context.graphics_queue_index = i;
@ -1573,6 +1584,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
{
unsigned i;
VkResult res;
PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
VkInstanceCreateInfo info = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO };
VkApplicationInfo app = { VK_STRUCTURE_TYPE_APPLICATION_INFO };
@ -1647,7 +1659,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
RARCH_LOG("Vulkan dynamic library loaded.\n");
PFN_vkGetInstanceProcAddr GetInstanceProcAddr =
GetInstanceProcAddr =
(PFN_vkGetInstanceProcAddr)dylib_proc(vulkan_library, "vkGetInstanceProcAddr");
if (!GetInstanceProcAddr)
@ -2018,10 +2030,11 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk,
case VULKAN_WSI_WIN32:
#ifdef _WIN32
{
VkWin32SurfaceCreateInfoKHR surf_info;
PFN_vkCreateWin32SurfaceKHR create;
if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(vk->context.instance, "vkCreateWin32SurfaceKHR", create))
return false;
VkWin32SurfaceCreateInfoKHR surf_info;
memset(&surf_info, 0, sizeof(surf_info));

@ -1194,12 +1194,12 @@ error:
static void vulkan_update_filter_chain(vk_t *vk)
{
const struct vulkan_filter_chain_swapchain_info info = {
vk->vk_vp,
vk->context->swapchain_format,
vk->render_pass,
vk->context->num_swapchain_images,
};
struct vulkan_filter_chain_swapchain_info info;
info.viewport = vk->vk_vp;
info.format = vk->context->swapchain_format;
info.render_pass = vk->render_pass;
info.num_indices = vk->context->num_swapchain_images;
if (!vulkan_filter_chain_update_swapchain_info((vulkan_filter_chain_t*)vk->filter_chain, &info))
RARCH_ERR("Failed to update filter chain info. This will probably lead to a crash ...\n");
@ -1346,9 +1346,10 @@ static void vulkan_set_video_mode(void *data,
unsigned width, unsigned height,
bool fullscreen)
{
(void)data;
gfx_ctx_mode_t mode;
(void)data;
mode.width = width;
mode.height = height;
mode.fullscreen = fullscreen;

@ -1,6 +1,7 @@
//
// File: vk_platform.h
//
/*
* File: vk_platform.h
*/
/*
** Copyright (c) 2014-2015 The Khronos Group Inc.
**
@ -24,7 +25,7 @@
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
#endif /* __cplusplus */
/*
***************************************************************************************************
@ -47,22 +48,22 @@ extern "C"
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
*/
#if defined(_WIN32)
// On Windows, Vulkan commands use the stdcall convention
/* On Windows, Vulkan commands use the stdcall convention */
#define VKAPI_ATTR
#define VKAPI_CALL __stdcall
#define VKAPI_PTR VKAPI_CALL
#elif defined(__ANDROID__) && defined(__ARM_EABI__) && !defined(__ARM_ARCH_7A__)
// Android does not support Vulkan in native code using the "armeabi" ABI.
/* Android does not support Vulkan in native code using the "armeabi" ABI. */
#error "Vulkan requires the 'armeabi-v7a' or 'armeabi-v7a-hard' ABI on 32-bit ARM CPUs"
#elif defined(__ANDROID__) && defined(__ARM_ARCH_7A__)
// On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling
// convention, even if the application's native code is compiled with the
// armeabi-v7a calling convention.
/* On Android/ARMv7a, Vulkan functions use the armeabi-v7a-hard calling
* convention, even if the application's native code is compiled with the
* armeabi-v7a calling convention. */
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
#define VKAPI_CALL
#define VKAPI_PTR VKAPI_ATTR
#else
// On other platforms, use the default calling convention
/* On other platforms, use the default calling convention */
#define VKAPI_ATTR
#define VKAPI_CALL
#define VKAPI_PTR
@ -83,15 +84,15 @@ extern "C"
#else
#include <stdint.h>
#endif
#endif // !defined(VK_NO_STDINT_H)
#endif /* !defined(VK_NO_STDINT_H) */
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
// Platform-specific headers required by platform window system extensions.
// These are enabled prior to #including "vulkan.h". The same enable then
// controls inclusion of the extension interfaces in vulkan.h.
/* Platform-specific headers required by platform window system extensions.
* These are enabled prior to #including "vulkan.h". The same enable then
* controls inclusion of the extension interfaces in vulkan.h. */
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#include <android/native_window.h>

@ -1,6 +1,7 @@
//
// File: vk_sdk_platform.h
//
/*
* File: vk_sdk_platform.h
*/
/*
* Copyright (c) 2015-2016 The Khronos Group Inc.
* Copyright (c) 2015-2016 Valve Corporation
@ -27,20 +28,20 @@
#ifndef __cplusplus
#undef inline
#define inline __inline
#endif // __cplusplus
#endif /* __cplusplus */
#if (defined(_MSC_VER) && _MSC_VER < 1900 /*vs2015*/)
// C99:
// Microsoft didn't implement C99 in Visual Studio; but started adding it with
// VS2013. However, VS2013 still didn't have snprintf(). The following is a
// work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the
// "CMakeLists.txt" file).
// NOTE: This is fixed in Visual Studio 2015.
/* C99:
* Microsoft didn't implement C99 in Visual Studio; but started adding it with
* VS2013. However, VS2013 still didn't have snprintf(). The following is a
* work-around (Note: The _CRT_SECURE_NO_WARNINGS macro must be set in the
* "CMakeLists.txt" file).
* NOTE: This is fixed in Visual Studio 2015. */
#define snprintf _snprintf
#endif
#define strdup _strdup
#endif // _WIN32
#endif /* _WIN32 */
#endif // VK_SDK_PLATFORM_H
#endif /* VK_SDK_PLATFORM_H */

@ -33,16 +33,18 @@ extern "C" {
#define VK_MAKE_VERSION(major, minor, patch) \
(((major) << 22) | ((minor) << 12) | (patch))
// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead.
//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0)
/* DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. */
#if 0
#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0)
#endif
// Vulkan 1.0 version number
/* Vulkan 1.0 version number */
#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)
#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
// Version of this file
/* Version of this file */
#define VK_HEADER_VERSION 17

@ -29,16 +29,16 @@
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
#endif /* __cplusplus */
#define VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL 1024
typedef struct VkDmaBufImageCreateInfo_
{
VkStructureType sType; // Must be VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL
const void* pNext; // Pointer to next structure.
VkStructureType sType; /* Must be VK_STRUCTURE_TYPE_DMA_BUF_IMAGE_CREATE_INFO_INTEL */
const void* pNext; /* Pointer to next structure. */
int fd;
VkFormat format;
VkExtent3D extent; // Depth must be 1
VkExtent3D extent; /* Depth must be 1 */
uint32_t strideInBytes;
} VkDmaBufImageCreateInfo;
@ -56,7 +56,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDmaBufImageINTEL(
#endif
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
} /* extern "C" */
#endif /* __cplusplus */
#endif // __VULKAN_INTEL_H__
#endif /* __VULKAN_INTEL_H__ */

@ -101,7 +101,7 @@ typedef struct
HWND label_title;
HWND label_val;
} trackbar;
};
} elems;
} shader_param_ctrl_t;
typedef struct
@ -128,7 +128,7 @@ static bool shader_dlg_refresh_trackbar_label(int index,
snprintf(val_buffer, sizeof(val_buffer), "%.2f",
shader_info->data->parameters[index].current);
SendMessage(g_shader_dlg.controls[index].trackbar.label_val,
SendMessage(g_shader_dlg.controls[index].elems.trackbar.label_val,
WM_SETTEXT, 0, (LPARAM)val_buffer);
return true;
@ -155,7 +155,7 @@ static void shader_dlg_params_refresh(void)
bool checked = shader_info.data ?
(shader_info.data->parameters[i].current ==
shader_info.data->parameters[i].maximum) : false;
SendMessage(control->checkbox.hwnd, BM_SETCHECK, checked, 0);
SendMessage(control->elems.checkbox.hwnd, BM_SETCHECK, checked, 0);
}
break;
case SHADER_PARAM_CTRL_TRACKBAR:
@ -167,14 +167,14 @@ static void shader_dlg_params_refresh(void)
if (shader_info.data)
{
SendMessage(control->trackbar.hwnd,
SendMessage(control->elems.trackbar.hwnd,
TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)0);
SendMessage(control->trackbar.hwnd,
SendMessage(control->elems.trackbar.hwnd,
TBM_SETRANGEMAX, (WPARAM)TRUE,
(LPARAM)((shader_info.data->parameters[i].maximum -
shader_info.data->parameters[i].minimum)
/ shader_info.data->parameters[i].step));
SendMessage(control->trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE,
SendMessage(control->elems.trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE,
(LPARAM)((shader_info.data->parameters[i].current -
shader_info.data->parameters[i].minimum) /
shader_info.data->parameters[i].step));
@ -207,13 +207,13 @@ static void shader_dlg_params_clear(void)
{
const ui_window_t *window = ui_companion_driver_get_window_ptr();
if (window)
window->destroy(&control->checkbox);
window->destroy(&control->elems.checkbox);
}
break;
case SHADER_PARAM_CTRL_TRACKBAR:
DestroyWindow(control->trackbar.label_title);
DestroyWindow(control->trackbar.label_val);
DestroyWindow(control->trackbar.hwnd);
DestroyWindow(control->elems.trackbar.label_title);
DestroyWindow(control->elems.trackbar.label_val);
DestroyWindow(control->elems.trackbar.hwnd);
break;
}
@ -260,12 +260,12 @@ void shader_dlg_params_reload(void)
}
control->type = SHADER_PARAM_CTRL_CHECKBOX;
control->checkbox.hwnd = CreateWindowEx(0, "BUTTON",
control->elems.checkbox.hwnd = CreateWindowEx(0, "BUTTON",
shader_info.data->parameters[i].desc,
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, pos_x, pos_y,
SHADER_DLG_CTRL_WIDTH, SHADER_DLG_CHECKBOX_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
SendMessage(control->checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->elems.checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN;
}
else
@ -277,29 +277,29 @@ void shader_dlg_params_reload(void)
pos_x += SHADER_DLG_WIDTH;
}
control->type = SHADER_PARAM_CTRL_TRACKBAR;
control->trackbar.label_title = CreateWindowEx(0, "STATIC",
control->type = SHADER_PARAM_CTRL_TRACKBAR;
control->elems.trackbar.label_title = CreateWindowEx(0, "STATIC",
shader_info.data->parameters[i].desc,
WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, pos_y,
SHADER_DLG_CTRL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.window.hwnd,
(HMENU)(size_t)i, NULL, NULL);
SendMessage(control->trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->elems.trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_LABEL_HEIGHT;
control->trackbar.hwnd = CreateWindowEx(0, (LPCSTR)TRACKBAR_CLASS, "",
control->elems.trackbar.hwnd = CreateWindowEx(0, (LPCSTR)TRACKBAR_CLASS, "",
WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS,
pos_x + SHADER_DLG_TRACKBAR_LABEL_WIDTH, pos_y,
SHADER_DLG_TRACKBAR_WIDTH, SHADER_DLG_TRACKBAR_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
control->trackbar.label_val = CreateWindowEx(0, "STATIC", "",
control->elems.trackbar.label_val = CreateWindowEx(0, "STATIC", "",
WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x,
pos_y, SHADER_DLG_TRACKBAR_LABEL_WIDTH, SHADER_DLG_LABEL_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
SendMessage(control->trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->elems.trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE,
(LPARAM)control->trackbar.label_val);
SendMessage(control->elems.trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE,
(LPARAM)control->elems.trackbar.label_val);
pos_y += SHADER_DLG_TRACKBAR_HEIGHT + SHADER_DLG_CTRL_MARGIN;
@ -402,7 +402,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
video_shader_ctx_t shader_info;
video_shader_driver_get_current_shader(&shader_info);
if (SendMessage(g_shader_dlg.controls[i].checkbox.hwnd,
if (SendMessage(g_shader_dlg.controls[i].elems.checkbox.hwnd,
BM_GETCHECK, 0, 0) == BST_CHECKED)
shader_info.data->parameters[i].current =
shader_info.data->parameters[i].maximum;
@ -424,7 +424,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_TRACKBAR)
break;
pos = (int)SendMessage(g_shader_dlg.controls[i].trackbar.hwnd, TBM_GETPOS, 0, 0);
pos = (int)SendMessage(g_shader_dlg.controls[i].elems.trackbar.hwnd, TBM_GETPOS, 0, 0);
{