@@ -150,7 +150,39 @@ Adapter::Adapter(
150150 pipeline_layout_cache_ (device_.handle),
151151 compute_pipeline_cache_ (device_.handle, cache_data_path),
152152 sampler_cache_ (device_.handle),
153- vma_ (instance_, physical_device_.handle, device_.handle) {}
153+ vma_ (instance_, physical_device_.handle, device_.handle),
154+ linear_tiling_3d_enabled_{true } {
155+ // Test creating a 3D image with linear tiling to see if it is supported.
156+ // According to the Vulkan spec, linear tiling may not be supported for 3D
157+ // images.
158+ VkExtent3D image_extents{1u , 1u , 1u };
159+ const VkImageCreateInfo image_create_info{
160+ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
161+ nullptr , // pNext
162+ 0u , // flags
163+ VK_IMAGE_TYPE_3D, // imageType
164+ VK_FORMAT_R32G32B32A32_SFLOAT, // format
165+ image_extents, // extents
166+ 1u , // mipLevels
167+ 1u , // arrayLayers
168+ VK_SAMPLE_COUNT_1_BIT, // samples
169+ VK_IMAGE_TILING_LINEAR, // tiling
170+ VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, // usage
171+ VK_SHARING_MODE_EXCLUSIVE, // sharingMode
172+ 0u , // queueFamilyIndexCount
173+ nullptr , // pQueueFamilyIndices
174+ VK_IMAGE_LAYOUT_UNDEFINED, // initialLayout
175+ };
176+ VkImage image = VK_NULL_HANDLE;
177+ VkResult res =
178+ vkCreateImage (device_.handle , &image_create_info, nullptr , &image);
179+ if (res == VK_ERROR_FEATURE_NOT_PRESENT) {
180+ linear_tiling_3d_enabled_ = false ;
181+ } else if (res == VK_SUCCESS) {
182+ vkDestroyImage (device_.handle , image, nullptr );
183+ }
184+ return ;
185+ }
154186
155187Adapter::Queue Adapter::request_queue () {
156188 // Lock the mutex as multiple threads can request a queue at the same time
0 commit comments