Skip to content

Commit 814a6cf

Browse files
handling engine runs on macOS (#474)
* handled runs on macos * reverted renderer frame output
1 parent bd3767a commit 814a6cf

File tree

5 files changed

+89
-66
lines changed

5 files changed

+89
-66
lines changed

Resources/Shaders/infinite_grid.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void main()
1717
{
1818
vec2 dudv = vec2(length(vec2(dFdx(uv.x), dFdy(uv.x))), length(vec2(dFdx(uv.y), dFdy(uv.y))));
1919

20-
float lodLevel = max(0.0, log10((length(dudv) * gridMinPixelsBetweenCells) / gridCellSize) + 1.0);
20+
float lodLevel = max(0.0, log_10((length(dudv) * gridMinPixelsBetweenCells) / gridCellSize) + 1.0);
2121
float lodFade = fract(lodLevel);
2222

2323
float lod0 = gridCellSize * pow(10.0, floor(lodLevel + 0));

Resources/Shaders/utility.glsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
float log10(float x)
1+
2+
float log_10(float x)
23
{
34
return log(x) / log(10.0);
45
}

ZEngine/ZEngine/Hardwares/VulkanDevice.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ namespace ZEngine::Hardwares
5757

5858
VkInstanceCreateInfo instance_create_info = {.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pNext = VK_NULL_HANDLE, .flags = 0, .pApplicationInfo = &app_info};
5959

60-
auto scratch = ZGetScratch(Arena);
60+
#ifdef __APPLE__
61+
instance_create_info.flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
62+
#endif
63+
auto scratch = ZGetScratch(Arena);
6164

6265
Array<const char*> enabled_layer_name_collection;
6366
Array<LayerProperty> selected_layer_property_collection;
@@ -71,7 +74,9 @@ namespace ZEngine::Hardwares
7174
validation_layer_name_collection.push("VK_LAYER_LUNARG_api_dump");
7275
validation_layer_name_collection.push("VK_LAYER_KHRONOS_validation");
7376
validation_layer_name_collection.push("VK_LAYER_LUNARG_monitor");
77+
#ifndef __APPLE__
7478
validation_layer_name_collection.push("VK_LAYER_LUNARG_screenshot");
79+
#endif
7580

7681
for (const char* layer_name : validation_layer_name_collection)
7782
{
@@ -126,6 +131,9 @@ namespace ZEngine::Hardwares
126131
}
127132
}
128133

134+
#ifdef __APPLE__
135+
enabled_extension_layer_name_collection.push(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME);
136+
#endif
129137
instance_create_info.enabledLayerCount = enabled_layer_name_collection.size();
130138
instance_create_info.ppEnabledLayerNames = enabled_layer_name_collection.data();
131139
instance_create_info.enabledExtensionCount = enabled_extension_layer_name_collection.size();
@@ -175,16 +183,26 @@ namespace ZEngine::Hardwares
175183

176184
for (VkPhysicalDevice physical_device : physical_device_collection)
177185
{
178-
VkPhysicalDeviceProperties physical_device_properties;
179-
VkPhysicalDeviceFeatures physical_device_feature;
186+
VkPhysicalDeviceDescriptorIndexingProperties indexing_properties = {};
187+
indexing_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES;
188+
189+
VkPhysicalDeviceProperties physical_device_properties;
190+
VkPhysicalDeviceProperties2 physical_device_properties2 = {};
191+
physical_device_properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2;
192+
physical_device_properties2.pNext = &indexing_properties;
193+
194+
VkPhysicalDeviceFeatures physical_device_feature;
195+
180196
vkGetPhysicalDeviceProperties(physical_device, &physical_device_properties);
197+
vkGetPhysicalDeviceProperties2(physical_device, &physical_device_properties2);
181198
vkGetPhysicalDeviceFeatures(physical_device, &physical_device_feature);
182199

183-
if ((physical_device_feature.geometryShader == VK_TRUE) && (physical_device_feature.samplerAnisotropy == VK_TRUE) && ((physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) || (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)))
200+
if (/*(physical_device_feature.geometryShader == VK_TRUE) && (physical_device_feature.samplerAnisotropy == VK_TRUE) && */ ((physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU) || (physical_device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU)))
184201
{
185-
PhysicalDevice = physical_device;
186-
PhysicalDeviceProperties = physical_device_properties;
187-
PhysicalDeviceFeature = physical_device_feature;
202+
PhysicalDevice = physical_device;
203+
PhysicalDeviceProperties = physical_device_properties;
204+
PhysicalDeviceDescriptorIndexingProperties = indexing_properties;
205+
PhysicalDeviceFeature = physical_device_feature;
188206
vkGetPhysicalDeviceMemoryProperties(PhysicalDevice, &PhysicalDeviceMemoryProperties);
189207
break;
190208
}
@@ -197,6 +215,9 @@ namespace ZEngine::Hardwares
197215

198216
requested_device_extension_layer_name_collection.push(VK_KHR_SWAPCHAIN_EXTENSION_NAME);
199217
requested_device_extension_layer_name_collection.push(VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME);
218+
#ifdef __APPLE__
219+
requested_device_extension_layer_name_collection.push("VK_KHR_portability_subset");
220+
#endif
200221

201222
for (LayerProperty& layer : selected_layer_property_collection)
202223
{

0 commit comments

Comments
 (0)