Vulkan dispatchable objects
Vulkan has a few dispatchable objects: Instance, Device, Physical Device,
Command Buffer and Queue. These objects, when loaded through an ICD, are
constrained to have a bit of memory allocated at the beginning of these
objects to contain loader data.
In order to do this, a wrapper class, DispatchableObject, was created to handle
pointing directly to the loader data when casting to the associated VK handle
and similarly back to a pointer to the internal object. Note that Queue, being
allocated within another object, and not directly through the API, simply have
the loader data at the beginning of the class, without requiring a wrapper class.
Also, since all these object are allocated through a custom placement new
operator, they have to be deallocated through an associated destroy() function,
so the DispatchableObject destructor is deleted, in order to prevent these
objects from being released any other way.
Bug b/116336664
Change-Id: Iac749f6adcba0eaf7557f0df876ac0474081d9cc
Reviewed-on: https://swiftshader-review.googlesource.com/c/20948
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Vulkan/VkConfig.h b/src/Vulkan/VkConfig.h
new file mode 100644
index 0000000..f68a688
--- /dev/null
+++ b/src/Vulkan/VkConfig.h
@@ -0,0 +1,54 @@
+// Copyright 2018 The SwiftShader Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef VK_CONFIG_HPP_
+#define VK_CONFIG_HPP_
+
+namespace vk
+{
+
+// Note: Constant array initialization requires a string literal.
+// constexpr char* or char[] does not work for that purpose.
+#define SWIFTSHADER_DEVICE_NAME "SwiftShader Device" // Max length: VK_MAX_PHYSICAL_DEVICE_NAME_SIZE
+#define SWIFTSHADER_UUID "SwiftShaderUUID" // Max length: VK_UUID_SIZE
+
+enum
+{
+ DRIVER_VERSION = 1,
+ VENDOR_ID = 0x1AE0, // Google
+ DEVICE_ID = 0xC0DE, // SwiftShader
+};
+
+enum
+{
+ REQUIRED_MEMORY_ALIGNMENT = 8, // For 64 bit formats on ARM64
+ REQUIRED_MEMORY_TYPE_BITS = 1,
+};
+
+enum
+{
+ MAX_IMAGE_LEVELS_1D = 14,
+ MAX_IMAGE_LEVELS_2D = 14,
+ MAX_IMAGE_LEVELS_3D = 11,
+ MAX_IMAGE_LEVELS_CUBE = 14,
+ MAX_IMAGE_ARRAY_LAYERS = 11,
+};
+
+enum {
+ MaxVertexInputBindings = 16,
+};
+
+}
+
+#endif // VK_CONFIG_HPP_