Merge pull request #723 from billhollings/master

Track supported instance and device extensions correctly.
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index b47e4ac..e2decfe 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -22,6 +22,7 @@
 	- `VK_KHR_device_group`
 - Add support for `VkEvent`, using either native `MTLEvent` or emulation when `MTLEvent` not available.
 - `vkInvalidateMappedMemoryRanges()` synchronizes managed device memory to CPU.
+- Track supported instance and device extensions correctly.
 - Revert to supporting host-coherent memory for linear images on macOS.
 - Disable depth and/or stencil testing if corresponding attachment is missing.
 - Ensure Vulkan loader magic number is set every time before returning any dispatchable Vulkan handle.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
index b4a7461..893c47f 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.h
@@ -332,7 +332,6 @@
 	void initProperties();
 	void initMemoryProperties();
 	void initExtensions();
-	MVKExtensionList* getSupportedExtensions(const char* pLayerName = nullptr);
 	MVKVector<MVKQueueFamily*>& getQueueFamilies();
 	void initPipelineCacheUUID();
 	MTLFeatureSet getHighestMTLFeatureSet();
@@ -342,7 +341,7 @@
 
 	id<MTLDevice> _mtlDevice;
 	MVKInstance* _mvkInstance;
-	MVKExtensionList _supportedExtensions;
+	const MVKExtensionList _supportedExtensions;
 	VkPhysicalDeviceFeatures _features;
 	MVKPhysicalDeviceMetalFeatures _metalFeatures;
 	VkPhysicalDeviceProperties _properties;
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
index 170a6c4..3d2945b 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
@@ -57,8 +57,7 @@
 #pragma mark MVKPhysicalDevice
 
 VkResult MVKPhysicalDevice::getExtensionProperties(const char* pLayerName, uint32_t* pCount, VkExtensionProperties* pProperties) {
-	MVKExtensionList* extensions = getSupportedExtensions(pLayerName);
-	return extensions->getProperties(pCount, pProperties);
+	return _supportedExtensions.getProperties(pCount, pProperties);
 }
 
 void MVKPhysicalDevice::getFeatures(VkPhysicalDeviceFeatures* features) {
@@ -1636,20 +1635,17 @@
 }
 
 void MVKPhysicalDevice::initExtensions() {
+	MVKExtensionList* pWritableExtns = (MVKExtensionList*)&_supportedExtensions;
+	pWritableExtns->disableAllButEnabledDeviceExtensions();
+
 	if (!_metalFeatures.postDepthCoverage) {
-		_supportedExtensions.vk_EXT_post_depth_coverage.enabled = false;
+		pWritableExtns->vk_EXT_post_depth_coverage.enabled = false;
 	}
 	if (!_metalFeatures.stencilFeedback) {
-		_supportedExtensions.vk_EXT_shader_stencil_export.enabled = false;
+		pWritableExtns->vk_EXT_shader_stencil_export.enabled = false;
 	}
 }
 
-// Return all extensions supported by this physical device.
-MVKExtensionList* MVKPhysicalDevice::getSupportedExtensions(const char* pLayerName) {
-	if (!pLayerName || strcmp(pLayerName, "MoltenVK") == 0) { return &_supportedExtensions; }
-	return getInstance()->getLayerManager()->getLayerNamed(pLayerName)->getSupportedExtensions();
-}
-
 void MVKPhysicalDevice::logGPUInfo() {
 	string devTypeStr;
 	switch (_properties.deviceType) {
@@ -2548,7 +2544,7 @@
 	MVKExtensionList* pWritableExtns = (MVKExtensionList*)&_enabledExtensions;
 	setConfigurationResult(pWritableExtns->enable(pCreateInfo->enabledExtensionCount,
 												  pCreateInfo->ppEnabledExtensionNames,
-												  getPhysicalDevice()->getSupportedExtensions()));
+												  &_physicalDevice->_supportedExtensions));
 }
 
 // Create the command queues
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm
index c184f7d..24c5e38 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKInstance.mm
@@ -348,7 +348,7 @@
 	MVKExtensionList* pWritableExtns = (MVKExtensionList*)&_enabledExtensions;
 	setConfigurationResult(pWritableExtns->enable(pCreateInfo->enabledExtensionCount,
 												  pCreateInfo->ppEnabledExtensionNames,
-												  getDriverLayer()->getSupportedExtensions()));
+												  getDriverLayer()->getSupportedInstanceExtensions()));
 	logVersions();	// Log the MoltenVK and Vulkan versions
 
 	if (MVK_VULKAN_API_VERSION_CONFORM(MVK_VULKAN_API_VERSION) <
@@ -638,12 +638,12 @@
 }
 
 void MVKInstance::logVersions() {
-	MVKExtensionList* pExtns  = getDriverLayer()->getSupportedExtensions();
+	MVKExtensionList allExtns(this, true);
 	MVKLogInfo("MoltenVK version %s. Vulkan version %s.\n\tThe following %d Vulkan extensions are supported:%s",
 			   mvkGetMoltenVKVersionString(MVK_VERSION).c_str(),
 			   mvkGetVulkanVersionString(MVK_VULKAN_API_VERSION).c_str(),
-			   pExtns->getEnabledCount(),
-			   pExtns->enabledNamesString("\n\t\t", true).c_str());
+			   allExtns.getEnabledCount(),
+			   allExtns.enabledNamesString("\n\t\t", true).c_str());
 }
 
 void MVKInstance::initConfig() {
diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.def b/MoltenVK/MoltenVK/Layers/MVKExtensions.def
index a7edcb7..8f8ab03 100644
--- a/MoltenVK/MoltenVK/Layers/MVKExtensions.def
+++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.def
@@ -16,69 +16,80 @@
  * limitations under the License.
  */
 
-// To use this file, define the macro MVK_EXTENSION(var, EXT), then #include this file.
+// To use this file, define the macro MVK_EXTENSION(var, EXT, type), then #include this file.
 // To add a new extension, simply add an MVK_EXTENSION line below. The macro takes the
-// portion of the extension name without the leading "VK_", both in lowercase and uppercase.
+// portion of the extension name without the leading "VK_", both in lowercase and uppercase,
+// plus a value representing the extension type (instance/device/...).
 // The last line in the list must be an MVK_EXTENSION_LAST line; this is used in the MVKExtensionList
 // constructor to avoid a dangling ',' at the end of the initializer list.
 
+#ifndef MVK_EXTENSION_INSTANCE
+#define MVK_EXTENSION_INSTANCE	0
+#endif
+
+#ifndef MVK_EXTENSION_DEVICE
+#define MVK_EXTENSION_DEVICE	0
+#endif
+
 #ifndef MVK_EXTENSION
 #error MVK_EXTENSION must be defined before including this file
 #endif
 
 #ifndef MVK_EXTENSION_LAST
-#define MVK_EXTENSION_LAST(var, EXT) MVK_EXTENSION(var, EXT)
+#define MVK_EXTENSION_LAST(var, EXT, type) MVK_EXTENSION(var, EXT, type)
 #endif
 
-MVK_EXTENSION(KHR_16bit_storage, KHR_16BIT_STORAGE)
-MVK_EXTENSION(KHR_8bit_storage, KHR_8BIT_STORAGE)
-MVK_EXTENSION(KHR_bind_memory2, KHR_BIND_MEMORY_2)
-MVK_EXTENSION(KHR_dedicated_allocation, KHR_DEDICATED_ALLOCATION)
-MVK_EXTENSION(KHR_descriptor_update_template, KHR_DESCRIPTOR_UPDATE_TEMPLATE)
-MVK_EXTENSION(KHR_device_group, KHR_DEVICE_GROUP)
-MVK_EXTENSION(KHR_device_group_creation, KHR_DEVICE_GROUP_CREATION)
-MVK_EXTENSION(KHR_get_memory_requirements2, KHR_GET_MEMORY_REQUIREMENTS_2)
-MVK_EXTENSION(KHR_get_physical_device_properties2, KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2)
-MVK_EXTENSION(KHR_get_surface_capabilities2, KHR_GET_SURFACE_CAPABILITIES_2)
-MVK_EXTENSION(KHR_image_format_list, KHR_IMAGE_FORMAT_LIST)
-MVK_EXTENSION(KHR_maintenance1, KHR_MAINTENANCE1)
-MVK_EXTENSION(KHR_maintenance2, KHR_MAINTENANCE2)
-MVK_EXTENSION(KHR_maintenance3, KHR_MAINTENANCE3)
-MVK_EXTENSION(KHR_push_descriptor, KHR_PUSH_DESCRIPTOR)
-MVK_EXTENSION(KHR_relaxed_block_layout, KHR_RELAXED_BLOCK_LAYOUT)
-MVK_EXTENSION(KHR_sampler_mirror_clamp_to_edge, KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE)
-MVK_EXTENSION(KHR_shader_draw_parameters, KHR_SHADER_DRAW_PARAMETERS)
-MVK_EXTENSION(KHR_shader_float16_int8, KHR_SHADER_FLOAT16_INT8)
-MVK_EXTENSION(KHR_storage_buffer_storage_class, KHR_STORAGE_BUFFER_STORAGE_CLASS)
-MVK_EXTENSION(KHR_surface, KHR_SURFACE)
-MVK_EXTENSION(KHR_swapchain, KHR_SWAPCHAIN)
-MVK_EXTENSION(KHR_swapchain_mutable_format, KHR_SWAPCHAIN_MUTABLE_FORMAT)
-MVK_EXTENSION(KHR_uniform_buffer_standard_layout, KHR_UNIFORM_BUFFER_STANDARD_LAYOUT)
-MVK_EXTENSION(KHR_variable_pointers, KHR_VARIABLE_POINTERS)
-MVK_EXTENSION(EXT_debug_marker, EXT_DEBUG_MARKER)
-MVK_EXTENSION(EXT_debug_report, EXT_DEBUG_REPORT)
-MVK_EXTENSION(EXT_debug_utils, EXT_DEBUG_UTILS)
-MVK_EXTENSION(EXT_host_query_reset, EXT_HOST_QUERY_RESET)
-MVK_EXTENSION(EXT_memory_budget, EXT_MEMORY_BUDGET)
-MVK_EXTENSION(EXT_metal_surface, EXT_METAL_SURFACE)
-MVK_EXTENSION(EXT_post_depth_coverage, EXT_POST_DEPTH_COVERAGE)
-MVK_EXTENSION(EXT_scalar_block_layout, EXT_SCALAR_BLOCK_LAYOUT)
-MVK_EXTENSION(EXT_shader_stencil_export, EXT_SHADER_STENCIL_EXPORT)
-MVK_EXTENSION(EXT_shader_viewport_index_layer, EXT_SHADER_VIEWPORT_INDEX_LAYER)
-MVK_EXTENSION(EXT_swapchain_colorspace, EXT_SWAPCHAIN_COLOR_SPACE)
-MVK_EXTENSION(EXT_texel_buffer_alignment, EXT_TEXEL_BUFFER_ALIGNMENT)
-MVK_EXTENSION(EXT_vertex_attribute_divisor, EXT_VERTEX_ATTRIBUTE_DIVISOR)
-MVK_EXTENSION(EXTX_portability_subset, EXTX_PORTABILITY_SUBSET)
-MVK_EXTENSION(MVK_ios_surface, MVK_IOS_SURFACE)
-MVK_EXTENSION(MVK_macos_surface, MVK_MACOS_SURFACE)
-MVK_EXTENSION(MVK_moltenvk, MVK_MOLTENVK)
-MVK_EXTENSION(AMD_gpu_shader_half_float, AMD_GPU_SHADER_HALF_FLOAT)
-MVK_EXTENSION(AMD_negative_viewport_height, AMD_NEGATIVE_VIEWPORT_HEIGHT)
-MVK_EXTENSION(AMD_shader_image_load_store_lod, AMD_SHADER_IMAGE_LOAD_STORE_LOD)
-MVK_EXTENSION(AMD_shader_trinary_minmax, AMD_SHADER_TRINARY_MINMAX)
-MVK_EXTENSION(IMG_format_pvrtc, IMG_FORMAT_PVRTC)
-MVK_EXTENSION(INTEL_shader_integer_functions2, INTEL_SHADER_INTEGER_FUNCTIONS2)
-MVK_EXTENSION_LAST(NV_glsl_shader, NV_GLSL_SHADER)
+MVK_EXTENSION(KHR_16bit_storage, KHR_16BIT_STORAGE, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_8bit_storage, KHR_8BIT_STORAGE, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_bind_memory2, KHR_BIND_MEMORY_2, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_dedicated_allocation, KHR_DEDICATED_ALLOCATION, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_descriptor_update_template, KHR_DESCRIPTOR_UPDATE_TEMPLATE, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_device_group, KHR_DEVICE_GROUP, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_device_group_creation, KHR_DEVICE_GROUP_CREATION, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(KHR_get_memory_requirements2, KHR_GET_MEMORY_REQUIREMENTS_2, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_get_physical_device_properties2, KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(KHR_get_surface_capabilities2, KHR_GET_SURFACE_CAPABILITIES_2, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(KHR_image_format_list, KHR_IMAGE_FORMAT_LIST, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_maintenance1, KHR_MAINTENANCE1, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_maintenance2, KHR_MAINTENANCE2, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_maintenance3, KHR_MAINTENANCE3, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_push_descriptor, KHR_PUSH_DESCRIPTOR, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_relaxed_block_layout, KHR_RELAXED_BLOCK_LAYOUT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_sampler_mirror_clamp_to_edge, KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_shader_draw_parameters, KHR_SHADER_DRAW_PARAMETERS, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_shader_float16_int8, KHR_SHADER_FLOAT16_INT8, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_storage_buffer_storage_class, KHR_STORAGE_BUFFER_STORAGE_CLASS, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_surface, KHR_SURFACE, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(KHR_swapchain, KHR_SWAPCHAIN, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_swapchain_mutable_format, KHR_SWAPCHAIN_MUTABLE_FORMAT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_uniform_buffer_standard_layout, KHR_UNIFORM_BUFFER_STANDARD_LAYOUT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(KHR_variable_pointers, KHR_VARIABLE_POINTERS, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_debug_marker, EXT_DEBUG_MARKER, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_debug_report, EXT_DEBUG_REPORT, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(EXT_debug_utils, EXT_DEBUG_UTILS, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(EXT_host_query_reset, EXT_HOST_QUERY_RESET, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_memory_budget, EXT_MEMORY_BUDGET, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_metal_surface, EXT_METAL_SURFACE, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(EXT_post_depth_coverage, EXT_POST_DEPTH_COVERAGE, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_scalar_block_layout, EXT_SCALAR_BLOCK_LAYOUT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_shader_stencil_export, EXT_SHADER_STENCIL_EXPORT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_shader_viewport_index_layer, EXT_SHADER_VIEWPORT_INDEX_LAYER, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_swapchain_colorspace, EXT_SWAPCHAIN_COLOR_SPACE, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(EXT_texel_buffer_alignment, EXT_TEXEL_BUFFER_ALIGNMENT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXT_vertex_attribute_divisor, EXT_VERTEX_ATTRIBUTE_DIVISOR, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(EXTX_portability_subset, EXTX_PORTABILITY_SUBSET, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(MVK_ios_surface, MVK_IOS_SURFACE, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(MVK_macos_surface, MVK_MACOS_SURFACE, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(MVK_moltenvk, MVK_MOLTENVK, MVK_EXTENSION_INSTANCE)
+MVK_EXTENSION(AMD_gpu_shader_half_float, AMD_GPU_SHADER_HALF_FLOAT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(AMD_negative_viewport_height, AMD_NEGATIVE_VIEWPORT_HEIGHT, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(AMD_shader_image_load_store_lod, AMD_SHADER_IMAGE_LOAD_STORE_LOD, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(AMD_shader_trinary_minmax, AMD_SHADER_TRINARY_MINMAX, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(IMG_format_pvrtc, IMG_FORMAT_PVRTC, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION(INTEL_shader_integer_functions2, INTEL_SHADER_INTEGER_FUNCTIONS2, MVK_EXTENSION_DEVICE)
+MVK_EXTENSION_LAST(NV_glsl_shader, NV_GLSL_SHADER, MVK_EXTENSION_DEVICE)
 
 #undef MVK_EXTENSION
 #undef MVK_EXTENSION_LAST
+#undef MVK_EXTENSION_INSTANCE
+#undef MVK_EXTENSION_DEVICE
diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.h b/MoltenVK/MoltenVK/Layers/MVKExtensions.h
index f42aa0f..c43e7da 100644
--- a/MoltenVK/MoltenVK/Layers/MVKExtensions.h
+++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.h
@@ -52,7 +52,7 @@
 
 	union {
 		struct {
-#define MVK_EXTENSION(var, EXT) MVKExtension vk_ ##var;
+#define MVK_EXTENSION(var, EXT, type) MVKExtension vk_ ##var;
 #include "MVKExtensions.def"
 		};
 		MVKExtension extensionArray;
@@ -77,7 +77,7 @@
 	 * for it to be enabled here. If it is not enabled in the parent, an error is logged
 	 * and returned. Returns VK_SUCCESS if all requested extensions were able to be enabled.
 	 */
-	VkResult enable(uint32_t count, const char* const* names, MVKExtensionList* parent = nullptr);
+	VkResult enable(uint32_t count, const char* const* names, const MVKExtensionList* parent = nullptr);
 
 	/**
 	 * Returns a string containing the names of the enabled extensions, separated by the separator string.
@@ -86,6 +86,18 @@
 	std::string enabledNamesString(const char* separator = " ", bool prefixFirstWithSeparator = false) const;
 
 	/**
+	 * Disables all extensions except instance extensions that are already enabled,
+	 * effectively leaving a list of platform-supported instance extensions.
+	 */
+	void disableAllButEnabledInstanceExtensions();
+
+	/**
+	 * Disables all extensions except device extensions that are already enabled,
+	 * effectively leaving a list of platform-supported device extensions.
+	 */
+	void disableAllButEnabledDeviceExtensions();
+
+	/**
 	 * If pProperties is null, the value of pCount is updated with the number of extensions
 	 * enabled in this list.
 	 *
@@ -97,7 +109,7 @@
 	 * enabled in this list is larger than the specified pCount. Returns other values
 	 * if an error occurs.
 	 */
-	VkResult getProperties(uint32_t* pCount, VkExtensionProperties* pProperties);
+	VkResult getProperties(uint32_t* pCount, VkExtensionProperties* pProperties) const;
 
 	MVKExtensionList(MVKVulkanAPIObject* apiObject, bool enableForPlatform = false);
 
diff --git a/MoltenVK/MoltenVK/Layers/MVKExtensions.mm b/MoltenVK/MoltenVK/Layers/MVKExtensions.mm
index f6bad88..1a670ee 100644
--- a/MoltenVK/MoltenVK/Layers/MVKExtensions.mm
+++ b/MoltenVK/MoltenVK/Layers/MVKExtensions.mm
@@ -40,7 +40,7 @@
 }
 
 // Extension properties
-#define MVK_EXTENSION(var, EXT) \
+#define MVK_EXTENSION(var, EXT, type) \
 static VkExtensionProperties kVkExtProps_ ##EXT = mvkMakeExtProps(VK_ ##EXT ##_EXTENSION_NAME, VK_ ##EXT ##_SPEC_VERSION);
 #include "MVKExtensions.def"
 
@@ -99,8 +99,8 @@
 #pragma mark MVKExtensionList
 
 MVKExtensionList::MVKExtensionList(MVKVulkanAPIObject* apiObject, bool enableForPlatform) : _apiObject(apiObject),
-#define MVK_EXTENSION_LAST(var, EXT)	vk_ ##var(&kVkExtProps_ ##EXT, enableForPlatform)
-#define MVK_EXTENSION(var, EXT)			MVK_EXTENSION_LAST(var, EXT),
+#define MVK_EXTENSION_LAST(var, EXT, type)		vk_ ##var(&kVkExtProps_ ##EXT, enableForPlatform)
+#define MVK_EXTENSION(var, EXT, type)			MVK_EXTENSION_LAST(var, EXT, type),
 #include "MVKExtensions.def"
 {
 	initCount();
@@ -111,7 +111,21 @@
 void MVKExtensionList::initCount() {
 	_count = 0;
 
-#define MVK_EXTENSION(var, EXT) _count++;
+#define MVK_EXTENSION(var, EXT, type) _count++;
+#include "MVKExtensions.def"
+}
+
+void MVKExtensionList::disableAllButEnabledInstanceExtensions() {
+#define MVK_EXTENSION_INSTANCE	true
+#define MVK_EXTENSION_DEVICE	false
+#define MVK_EXTENSION(var, EXT, type) vk_ ##var.enabled = type && vk_ ##var.enabled;
+#include "MVKExtensions.def"
+}
+
+void MVKExtensionList::disableAllButEnabledDeviceExtensions() {
+#define MVK_EXTENSION_INSTANCE	false
+#define MVK_EXTENSION_DEVICE	true
+#define MVK_EXTENSION(var, EXT, type) vk_ ##var.enabled = type && vk_ ##var.enabled;
 #include "MVKExtensions.def"
 }
 
@@ -151,7 +165,7 @@
 	}
 }
 
-VkResult MVKExtensionList::enable(uint32_t count, const char* const* names, MVKExtensionList* parent) {
+VkResult MVKExtensionList::enable(uint32_t count, const char* const* names, const MVKExtensionList* parent) {
 	VkResult result = VK_SUCCESS;
 	for (uint32_t i = 0; i < count; i++) {
 		auto extnName = names[i];
@@ -182,14 +196,14 @@
 	return logMsg;
 }
 
-VkResult MVKExtensionList::getProperties(uint32_t* pCount, VkExtensionProperties* pProperties) {
+VkResult MVKExtensionList::getProperties(uint32_t* pCount, VkExtensionProperties* pProperties) const {
 
 	uint32_t enabledCnt = 0;
 
 	// Iterate extensions and handle those that are enabled. Count them,
 	// and if they are to be returned, and there is room, do so.
 	uint32_t extnCnt = getCount();
-	MVKExtension* extnAry = &extensionArray;
+	const MVKExtension* extnAry = &extensionArray;
 	for (uint32_t extnIdx = 0; extnIdx < extnCnt; extnIdx++) {
 		if (extnAry[extnIdx].enabled) {
 			if (pProperties) {
diff --git a/MoltenVK/MoltenVK/Layers/MVKLayers.h b/MoltenVK/MoltenVK/Layers/MVKLayers.h
index e4bbc42..bfda9aa 100644
--- a/MoltenVK/MoltenVK/Layers/MVKLayers.h
+++ b/MoltenVK/MoltenVK/Layers/MVKLayers.h
@@ -40,28 +40,27 @@
 	VkLayerProperties* const getLayerProperties();
 
 	/**
-	 * If pProperties is null, the value of pCount is updated with the number of extensions
-	 * available in this layer.
+	 * If pProperties is null, the value of pCount is updated with the number of instance
+	 * extensions available in this layer.
 	 *
 	 * If pProperties is not null, then pCount extension properties are copied into the array.
-	 * If the number of available layers is less than pCount, the value of pCount is updated
-	 * to indicate the number of extension properties actually returned in the array.
+	 * If the number of available instance extensions is less than pCount, the value of pCount
+	 * is updated to indicate the number of extension properties actually returned in the array.
 	 *
-	 * Returns VK_SUCCESS if successful. Returns VK_INCOMPLETE if the number of extensions
-	 * available in this instance is larger than the specified pCount. Returns other values
-	 * if an error occurs.
+	 * Returns VK_SUCCESS if successful. Returns VK_INCOMPLETE if the number of extensions available
+	 * in this instance is larger than the specified pCount. Returns other values if an error occurs.
 	 */
-	VkResult getExtensionProperties(uint32_t* pCount, VkExtensionProperties* pProperties);
+	VkResult getInstanceExtensionProperties(uint32_t* pCount, VkExtensionProperties* pProperties);
 
-	/** Returns the list of supported extensions. */
-	MVKExtensionList* getSupportedExtensions() { return &_supportedExtensions; }
+	/** Returns the list of supported instance extensions. */
+	const MVKExtensionList* getSupportedInstanceExtensions() { return &_supportedInstanceExtensions; }
 
 	/** Default constructor.  This represents the driver implementation. */
 	MVKLayer();
 
 protected:
 	VkLayerProperties _layerProperties;
-	MVKExtensionList _supportedExtensions;
+	const MVKExtensionList _supportedInstanceExtensions;
 
 };
 
diff --git a/MoltenVK/MoltenVK/Layers/MVKLayers.mm b/MoltenVK/MoltenVK/Layers/MVKLayers.mm
index 0fb19e6..d741b8b 100644
--- a/MoltenVK/MoltenVK/Layers/MVKLayers.mm
+++ b/MoltenVK/MoltenVK/Layers/MVKLayers.mm
@@ -30,15 +30,14 @@
 
 VkLayerProperties* const MVKLayer::getLayerProperties() { return &_layerProperties; }
 
-VkResult MVKLayer::getExtensionProperties(uint32_t* pCount, VkExtensionProperties* pProperties) {
-
-	return _supportedExtensions.getProperties(pCount, pProperties);
+VkResult MVKLayer::getInstanceExtensionProperties(uint32_t* pCount, VkExtensionProperties* pProperties) {
+	return _supportedInstanceExtensions.getProperties(pCount, pProperties);
 }
 
 
 #pragma mark Object Creation
 
-MVKLayer::MVKLayer() : _supportedExtensions(nullptr, true) {
+MVKLayer::MVKLayer() : _supportedInstanceExtensions(nullptr, true) {
 
 	// The core driver layer
 	memset(_layerProperties.layerName, 0, sizeof(_layerProperties.layerName));
@@ -47,6 +46,8 @@
 	strcpy(_layerProperties.description, "MoltenVK driver layer");
 	_layerProperties.specVersion = MVK_VULKAN_API_VERSION;
 	_layerProperties.implementationVersion = MVK_VERSION;
+
+	((MVKExtensionList*)&_supportedInstanceExtensions)->disableAllButEnabledInstanceExtensions();
 }
 
 
diff --git a/MoltenVK/MoltenVK/Vulkan/vulkan.mm b/MoltenVK/MoltenVK/Vulkan/vulkan.mm
index a1e2fc9..ec368a6 100644
--- a/MoltenVK/MoltenVK/Vulkan/vulkan.mm
+++ b/MoltenVK/MoltenVK/Vulkan/vulkan.mm
@@ -269,7 +269,7 @@
     VkExtensionProperties*                      pProperties) {
 
 	MVKTraceVulkanCallStart();
-	VkResult rslt = MVKLayerManager::globalManager()->getLayerNamed(pLayerName)->getExtensionProperties(pCount, pProperties);
+	VkResult rslt = MVKLayerManager::globalManager()->getLayerNamed(pLayerName)->getInstanceExtensionProperties(pCount, pProperties);
 	MVKTraceVulkanCallEnd();
 	return rslt;
 }