Skip to content

Commit b034398

Browse files
author
Tim Foley
authored
Initial work on getting render-test to support vulkan (shader-slang#391)
* Basic fixes to gets some Vulkan GLSL out of the IR path We haven't been paying much attention to the Vulkan output from the IR path, but that needs to change ASAP. This commit really just implements quick fixes, without concern for whether they are a good fit in the long term. - Add some more mappings from D3D `SV_*` semantics to built-in GLSL variables, and stop redeclaring those built-in variables in our output GLSL. - Add custom output logic for HLSL `*StructuredBuffer<T>` types, so that they emit as `buffer` declarations with an unsized array inside. This has some real limitations: - What if the user passes the type into a function? The parameter should be typed as an (unsized) array, and not a buffer. - What happens if we have an array of structured buffers? We need to declare an array of blocks (which GLSL allows), but this changes the GLSL we should emit when indexing. - Customize the way that we emit entry point attributes (e.g., `[numthread(...)]`) to also support outputting equivalent GLSL `layout` qualifiers. In many of these cases, a better fix might involve doing more of this work in the IR as part of legalization (e.g., we already have a pass that deals with varying input/output for GLSL, so that should probalby be responsible for swapping the `SV_*` to `gl_*`, especially in cases where the types don't match perfectly across langauges). * Start adding Vulkan support to render-test - Add both Vulkan and D3D12 as nominally supported back-ends - Add a git submodule to pull in the Vulkan SDK dependencies - I don't want our users to have to install it manually, since the SDK is huge - Checking in the binaries to our main repository seems like a bad idea, but my hope is that we can prune the bloat using a subodule with the `shallow` cloning option - Implement enough logic for the Vulkan back-end to get a single test passing on Vulkan * Fix warning * Fixup: disable new compute tests for Linux * Fixup: ignore Vulkan tests on AppVeyor * Dynamically load Vulkan implementation Rather than statically link to the Vulkan library, we will dynamically load all of the required functions. This removes the need to have the stub libs involved at all. * Remove vulkan submodule I had set up a `vulkan` submodule to pull in the headers and stub libs, but now that we are going to dynamically load all the symbols anyway, the stub lib binaries aren't needed and we can just commit the headers. * Add Vulkan headers to external/
1 parent 652a3c9 commit b034398

20 files changed

+8971
-116
lines changed

external/vulkan/vk_platform.h

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
//
2+
// File: vk_platform.h
3+
//
4+
/*
5+
** Copyright (c) 2014-2017 The Khronos Group Inc.
6+
**
7+
** Licensed under the Apache License, Version 2.0 (the "License");
8+
** you may not use this file except in compliance with the License.
9+
** You may obtain a copy of the License at
10+
**
11+
** http://www.apache.org/licenses/LICENSE-2.0
12+
**
13+
** Unless required by applicable law or agreed to in writing, software
14+
** distributed under the License is distributed on an "AS IS" BASIS,
15+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
** See the License for the specific language governing permissions and
17+
** limitations under the License.
18+
*/
19+
20+
21+
#ifndef VK_PLATFORM_H_
22+
#define VK_PLATFORM_H_
23+
24+
#ifdef __cplusplus
25+
extern "C"
26+
{
27+
#endif // __cplusplus
28+
29+
/*
30+
***************************************************************************************************
31+
* Platform-specific directives and type declarations
32+
***************************************************************************************************
33+
*/
34+
35+
/* Platform-specific calling convention macros.
36+
*
37+
* Platforms should define these so that Vulkan clients call Vulkan commands
38+
* with the same calling conventions that the Vulkan implementation expects.
39+
*
40+
* VKAPI_ATTR - Placed before the return type in function declarations.
41+
* Useful for C++11 and GCC/Clang-style function attribute syntax.
42+
* VKAPI_CALL - Placed after the return type in function declarations.
43+
* Useful for MSVC-style calling convention syntax.
44+
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
45+
*
46+
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
47+
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
48+
*/
49+
#if defined(_WIN32)
50+
// On Windows, Vulkan commands use the stdcall convention
51+
#define VKAPI_ATTR
52+
#define VKAPI_CALL __stdcall
53+
#define VKAPI_PTR VKAPI_CALL
54+
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
55+
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
56+
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
57+
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
58+
// calling convention, i.e. float parameters are passed in registers. This
59+
// is true even if the rest of the application passes floats on the stack,
60+
// as it does by default when compiling for the armeabi-v7a NDK ABI.
61+
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
62+
#define VKAPI_CALL
63+
#define VKAPI_PTR VKAPI_ATTR
64+
#else
65+
// On other platforms, use the default calling convention
66+
#define VKAPI_ATTR
67+
#define VKAPI_CALL
68+
#define VKAPI_PTR
69+
#endif
70+
71+
#include <stddef.h>
72+
73+
#if !defined(VK_NO_STDINT_H)
74+
#if defined(_MSC_VER) && (_MSC_VER < 1600)
75+
typedef signed __int8 int8_t;
76+
typedef unsigned __int8 uint8_t;
77+
typedef signed __int16 int16_t;
78+
typedef unsigned __int16 uint16_t;
79+
typedef signed __int32 int32_t;
80+
typedef unsigned __int32 uint32_t;
81+
typedef signed __int64 int64_t;
82+
typedef unsigned __int64 uint64_t;
83+
#else
84+
#include <stdint.h>
85+
#endif
86+
#endif // !defined(VK_NO_STDINT_H)
87+
88+
#ifdef __cplusplus
89+
} // extern "C"
90+
#endif // __cplusplus
91+
92+
// Platform-specific headers required by platform window system extensions.
93+
// These are enabled prior to #including "vulkan.h". The same enable then
94+
// controls inclusion of the extension interfaces in vulkan.h.
95+
96+
#ifdef VK_USE_PLATFORM_ANDROID_KHR
97+
#include <android/native_window.h>
98+
#endif
99+
100+
#ifdef VK_USE_PLATFORM_MIR_KHR
101+
#include <mir_toolkit/client_types.h>
102+
#endif
103+
104+
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
105+
#include <wayland-client.h>
106+
#endif
107+
108+
#ifdef VK_USE_PLATFORM_WIN32_KHR
109+
#include <windows.h>
110+
#endif
111+
112+
#ifdef VK_USE_PLATFORM_XLIB_KHR
113+
#include <X11/Xlib.h>
114+
#endif
115+
116+
#ifdef VK_USE_PLATFORM_XCB_KHR
117+
#include <xcb/xcb.h>
118+
#endif
119+
120+
#endif

0 commit comments

Comments
 (0)