@@ -262,6 +262,14 @@ struct VulkanProgram : public HwProgram, fvkmemory::Resource {
262262 VulkanProgram (VkDevice device, Program const & builder) noexcept ;
263263 ~VulkanProgram ();
264264
265+ /* *
266+ * Cancels any parallel compilation jobs that have not yet run for this
267+ * program.
268+ */
269+ inline void cancelParallelCompilation () {
270+ mParallelCompilationCanceled .store (true , std::memory_order_release);
271+ }
272+
265273 /* *
266274 * Writes out any queued push constants using the provided VkPipelineLayout.
267275 *
@@ -284,6 +292,17 @@ struct VulkanProgram : public HwProgram, fvkmemory::Resource {
284292 return mInfo ->pushConstantDescription .getVkRanges ();
285293 }
286294
295+ /* *
296+ * Returns true if parallel compilation is canceled, false if not. Parallel
297+ * compilation will be canceled if this program is destroyed before relevant
298+ * pipelines are created.
299+ *
300+ * @return true if parallel compilation should run for this program, false if not
301+ */
302+ inline bool isParallelCompilationCanceled () const {
303+ return mParallelCompilationCanceled .load (std::memory_order_acquire);
304+ }
305+
287306 inline void writePushConstant (VkCommandBuffer cmdbuf, VkPipelineLayout layout,
288307 backend::ShaderStage stage, uint8_t index, backend::PushConstantVariant const & value) {
289308 // It's possible that we don't have the layout yet. When external samplers are used, bindPipeline()
@@ -320,6 +339,7 @@ struct VulkanProgram : public HwProgram, fvkmemory::Resource {
320339
321340 PipelineInfo* mInfo ;
322341 VkDevice mDevice = VK_NULL_HANDLE;
342+ std::atomic<bool > mParallelCompilationCanceled { false };
323343 std::vector<PushConstantInfo> mQueuedPushConstants ;
324344};
325345
0 commit comments