@@ -183,6 +183,7 @@ typedef struct {
183
183
bool dynamicRendering ;
184
184
bool scalarBlockLayout ;
185
185
bool foveation ;
186
+ bool pipelineCacheControl ;
186
187
} gpu_extensions ;
187
188
188
189
// State
@@ -1344,7 +1345,7 @@ void gpu_bundle_write(gpu_bundle** bundles, gpu_bundle_info* infos, uint32_t cou
1344
1345
1345
1346
// Pipeline
1346
1347
1347
- bool gpu_pipeline_init_graphics (gpu_pipeline * pipeline , gpu_pipeline_info * info ) {
1348
+ bool gpu_pipeline_init_graphics (gpu_pipeline * pipeline , gpu_pipeline_info * info , bool * slow ) {
1348
1349
static const VkPrimitiveTopology topologies [] = {
1349
1350
[GPU_DRAW_POINTS ] = VK_PRIMITIVE_TOPOLOGY_POINT_LIST ,
1350
1351
[GPU_DRAW_LINES ] = VK_PRIMITIVE_TOPOLOGY_LINE_LIST ,
@@ -1628,6 +1629,10 @@ bool gpu_pipeline_init_graphics(gpu_pipeline* pipeline, gpu_pipeline_info* info)
1628
1629
.layout = info -> shader -> pipelineLayout
1629
1630
};
1630
1631
1632
+ if (state .extensions .pipelineCacheControl && slow ) {
1633
+ pipelineInfo .flags |= VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT ;
1634
+ }
1635
+
1631
1636
if (state .extensions .dynamicRendering ) {
1632
1637
pipelineInfo .pNext = & renderingInfo ;
1633
1638
} else {
@@ -1699,16 +1704,19 @@ bool gpu_pipeline_init_graphics(gpu_pipeline* pipeline, gpu_pipeline_info* info)
1699
1704
condemn (pipelineInfo .renderPass , VK_OBJECT_TYPE_RENDER_PASS );
1700
1705
}
1701
1706
1702
- VK (vkCreateGraphicsPipelines (state .device , state .pipelineCache , 1 , & pipelineInfo , NULL , & pipeline -> handle ), "vkCreateGraphicsPipelines" ) {
1703
- if (constants != stackConstants ) state .config .fnFree (constants );
1704
- if (entries != stackEntries ) state .config .fnFree (entries );
1705
- return false;
1706
- }
1707
-
1708
- nickname (pipeline -> handle , VK_OBJECT_TYPE_PIPELINE , info -> label );
1707
+ VkResult result = vkCreateGraphicsPipelines (state .device , state .pipelineCache , 1 , & pipelineInfo , NULL , & pipeline -> handle );
1709
1708
if (constants != stackConstants ) state .config .fnFree (constants );
1710
1709
if (entries != stackEntries ) state .config .fnFree (entries );
1711
- return true;
1710
+
1711
+ if (result < 0 ) {
1712
+ return false;
1713
+ } else if (result == VK_PIPELINE_COMPILE_REQUIRED_EXT ) {
1714
+ * slow = true;
1715
+ return true;
1716
+ } else {
1717
+ if (slow ) * slow = false;
1718
+ return true;
1719
+ }
1712
1720
}
1713
1721
1714
1722
bool gpu_pipeline_init_compute (gpu_pipeline * pipeline , gpu_compute_pipeline_info * info ) {
@@ -2649,7 +2657,8 @@ bool gpu_init(gpu_config* config) {
2649
2657
{ "VK_KHR_synchronization2" , true, & state .extensions .synchronization2 },
2650
2658
{ "VK_KHR_dynamic_rendering" , true, & state .extensions .dynamicRendering },
2651
2659
{ "VK_EXT_scalar_block_layout" , true, & state .extensions .scalarBlockLayout },
2652
- { "VK_EXT_fragment_density_map" , true, & state .extensions .foveation }
2660
+ { "VK_EXT_fragment_density_map" , true, & state .extensions .foveation },
2661
+ { "VK_EXT_pipeline_creation_cache_control" , true, & state .extensions .pipelineCacheControl }
2653
2662
};
2654
2663
2655
2664
uint32_t extensionCount = 0 ;
@@ -2741,6 +2750,7 @@ bool gpu_init(gpu_config* config) {
2741
2750
VkPhysicalDeviceDynamicRenderingFeaturesKHR dynamicRenderingFeatures = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR };
2742
2751
VkPhysicalDeviceScalarBlockLayoutFeaturesEXT scalarBlockLayoutFeatures = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT };
2743
2752
VkPhysicalDeviceFragmentDensityMapFeaturesEXT fragmentDensityMapFeatures = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT };
2753
+ VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT pipelineCreationCacheControlFeatures = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES_EXT };
2744
2754
2745
2755
vkGetPhysicalDeviceFeatures2 (state .adapter , & supported );
2746
2756
@@ -2790,6 +2800,11 @@ bool gpu_init(gpu_config* config) {
2790
2800
CHAIN (fragmentDensityMapFeatures );
2791
2801
}
2792
2802
2803
+ if (state .extensions .pipelineCacheControl ) {
2804
+ pipelineCreationCacheControlFeatures .pipelineCreationCacheControl = true;
2805
+ CHAIN (pipelineCreationCacheControlFeatures );
2806
+ }
2807
+
2793
2808
if (config -> features ) {
2794
2809
config -> features -> textureBC = enabled .features .textureCompressionBC ;
2795
2810
config -> features -> textureASTC = enabled .features .textureCompressionASTC_LDR ;
0 commit comments