Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 1 | // Copyright 2018 The SwiftShader Authors. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #ifndef VK_CONFIG_HPP_ |
| 16 | #define VK_CONFIG_HPP_ |
| 17 | |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 18 | #include "Version.hpp" |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 19 | |
Antonio Maiorano | 42fd159 | 2020-04-27 11:30:40 -0400 | [diff] [blame] | 20 | #include "Vulkan/VulkanPlatform.hpp" |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 21 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 22 | namespace vk { |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 23 | |
| 24 | // Note: Constant array initialization requires a string literal. |
| 25 | // constexpr char* or char[] does not work for that purpose. |
Antonio Maiorano | 71c49f8 | 2020-04-27 11:33:30 -0400 | [diff] [blame] | 26 | #define SWIFTSHADER_DEVICE_NAME "SwiftShader Device" // Max length: VK_MAX_PHYSICAL_DEVICE_NAME_SIZE |
| 27 | #define SWIFTSHADER_UUID "SwiftShaderUUID" // Max length: VK_UUID_SIZE (16) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 28 | |
| 29 | enum |
| 30 | { |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 31 | API_VERSION = VK_API_VERSION_1_1, |
| 32 | DRIVER_VERSION = VK_MAKE_VERSION(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION), |
Antonio Maiorano | 71c49f8 | 2020-04-27 11:33:30 -0400 | [diff] [blame] | 33 | VENDOR_ID = 0x1AE0, // Google, Inc.: https://pcisig.com/google-inc-1 |
| 34 | DEVICE_ID = 0xC0DE, // SwiftShader (placeholder) |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | enum |
| 38 | { |
Nicolas Capens | bd54e07 | 2019-04-25 23:28:28 -0400 | [diff] [blame] | 39 | // Alignment of all Vulkan objects, pools, device memory, images, buffers, descriptors. |
| 40 | REQUIRED_MEMORY_ALIGNMENT = 16, // 16 bytes for 128-bit vector types. |
Nicolas Capens | 52b5aae | 2019-05-24 16:27:55 -0400 | [diff] [blame] | 41 | |
Alexis Hetu | 6123455 | 2019-01-21 17:22:51 -0500 | [diff] [blame] | 42 | MIN_TEXEL_BUFFER_OFFSET_ALIGNMENT = 256, |
| 43 | MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT = 256, |
| 44 | MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT = 256, |
Nicolas Capens | bd54e07 | 2019-04-25 23:28:28 -0400 | [diff] [blame] | 45 | |
Antonio Maiorano | 71c49f8 | 2020-04-27 11:33:30 -0400 | [diff] [blame] | 46 | MEMORY_TYPE_GENERIC_BIT = 0x1, // Generic system memory. |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | enum |
| 50 | { |
| 51 | MAX_IMAGE_LEVELS_1D = 14, |
| 52 | MAX_IMAGE_LEVELS_2D = 14, |
| 53 | MAX_IMAGE_LEVELS_3D = 11, |
| 54 | MAX_IMAGE_LEVELS_CUBE = 14, |
Chris Forbes | abdfa17 | 2019-03-07 17:20:32 -0800 | [diff] [blame] | 55 | MAX_IMAGE_ARRAY_LAYERS = 2048, |
Nicolas Capens | 324bdfe | 2019-07-30 17:27:56 -0400 | [diff] [blame] | 56 | MAX_SAMPLER_LOD_BIAS = 15, |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 57 | }; |
| 58 | |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 59 | enum |
| 60 | { |
Alexis Hetu | 5edafb5 | 2019-02-15 14:56:22 -0500 | [diff] [blame] | 61 | MAX_BOUND_DESCRIPTOR_SETS = 4, |
Nicolas Capens | ee841c5 | 2018-11-13 14:18:26 -0500 | [diff] [blame] | 62 | MAX_VERTEX_INPUT_BINDINGS = 16, |
Chris Forbes | a30de54 | 2019-03-18 18:51:55 -0700 | [diff] [blame] | 63 | MAX_PUSH_CONSTANT_SIZE = 128, |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 64 | }; |
| 65 | |
Chris Forbes | 54c4772 | 2019-02-25 13:35:59 -0800 | [diff] [blame] | 66 | enum |
| 67 | { |
Ben Clayton | 225a130 | 2019-04-02 12:28:22 +0100 | [diff] [blame] | 68 | MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC = 8, |
| 69 | MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC = 4, |
| 70 | MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC = |
Antonio Maiorano | 71c49f8 | 2020-04-27 11:33:30 -0400 | [diff] [blame] | 71 | MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC + |
| 72 | MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC, |
Ben Clayton | 225a130 | 2019-04-02 12:28:22 +0100 | [diff] [blame] | 73 | }; |
| 74 | |
| 75 | enum |
| 76 | { |
Marc-Antoine Desroches | b44162f | 2020-03-05 13:35:43 -0500 | [diff] [blame] | 77 | MAX_POINT_SIZE = 1023, |
Chris Forbes | 54c4772 | 2019-02-25 13:35:59 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
Antonio Maiorano | ae022fa | 2019-10-07 12:57:19 -0400 | [diff] [blame] | 80 | constexpr int SUBPIXEL_PRECISION_BITS = 4; |
| 81 | constexpr float SUBPIXEL_PRECISION_FACTOR = static_cast<float>(1 << SUBPIXEL_PRECISION_BITS); |
| 82 | constexpr int SUBPIXEL_PRECISION_MASK = 0xFFFFFFFF >> (32 - SUBPIXEL_PRECISION_BITS); |
| 83 | |
Nicolas Capens | 157ba26 | 2019-12-10 17:49:14 -0500 | [diff] [blame] | 84 | } // namespace vk |
Alexis Hetu | 767b41b | 2018-09-26 11:25:46 -0400 | [diff] [blame] | 85 | |
David 'Digit' Turner | 3a7101b | 2019-11-22 11:55:53 +0100 | [diff] [blame] | 86 | #if defined(__linux__) || defined(__ANDROID__) |
Antonio Maiorano | 71c49f8 | 2020-04-27 11:33:30 -0400 | [diff] [blame] | 87 | # define SWIFTSHADER_EXTERNAL_MEMORY_OPAQUE_FD 1 |
| 88 | # define SWIFTSHADER_EXTERNAL_SEMAPHORE_OPAQUE_FD 1 |
David 'Digit' Turner | fda994c | 2019-09-04 16:36:36 +0200 | [diff] [blame] | 89 | #endif |
| 90 | |
Nicolas Capens | a57e2ec | 2019-12-27 02:05:18 -0500 | [diff] [blame] | 91 | constexpr VkDeviceSize MAX_MEMORY_ALLOCATION_SIZE = 0x40000000ull; // 0x40000000 = 1 GiB |
| 92 | |
| 93 | // Memory offset calculations in 32-bit SIMD elements limit us to addressing at most 4 GiB. |
| 94 | // Signed arithmetic further restricts it to 2 GiB. |
| 95 | static_assert(MAX_MEMORY_ALLOCATION_SIZE <= 0x80000000ull, "maxMemoryAllocationSize must not exceed 2 GiB"); |
| 96 | |
Antonio Maiorano | 71c49f8 | 2020-04-27 11:33:30 -0400 | [diff] [blame] | 97 | #endif // VK_CONFIG_HPP_ |