浏览代码

libobs-d3d11: Create shader cache directory when creating device

derrod 2 年之前
父节点
当前提交
2e4d1f3f54
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      libobs-d3d11/d3d11-subsystem.cpp

+ 12 - 0
libobs-d3d11/d3d11-subsystem.cpp

@@ -1494,6 +1494,17 @@ static inline void LogD3DAdapters()
 	}
 }
 
+static void CreateShaderCacheDirectory()
+{
+	BPtr cachePath =
+		os_get_program_data_path_ptr("obs-studio/shader-cache");
+
+	if (os_mkdirs(cachePath) == MKDIR_ERROR) {
+		blog(LOG_WARNING, "Failed to create shader cache directory, "
+				  "cache may not be available.");
+	}
+}
+
 int device_create(gs_device_t **p_device, uint32_t adapter)
 {
 	gs_device *device = NULL;
@@ -1503,6 +1514,7 @@ int device_create(gs_device_t **p_device, uint32_t adapter)
 		blog(LOG_INFO, "---------------------------------");
 		blog(LOG_INFO, "Initializing D3D11...");
 		LogD3DAdapters();
+		CreateShaderCacheDirectory();
 
 		device = new gs_device(adapter);