Skip to content

Commit 1aedc7d

Browse files
committed
Fix invalid Vulkan image setup in depth_format (alloc size, dedicated alloc, STORAGE usage)
1 parent 58ed3fc commit 1aedc7d

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

sycl/test-e2e/bindless_images/vulkan_interop/depth_format.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
namespace syclexp = sycl::ext::oneapi::experimental;
2222

23+
// imgSizeBytes is now passed in: it must be the real (tiling-padded) import
24+
// size, not globalSize.size()*sizeof(float).
2325
template <typename InteropMemHandleT>
2426
void runSycl(const sycl::device &syclDevice, sycl::range<2> globalSize,
2527
sycl::range<2> localSize, InteropMemHandleT extMemInHandle,
@@ -121,9 +123,7 @@ bool runTest(const sycl::device &syclDevice, sycl::range<2> dims,
121123
VkImage vkOutputImage;
122124
VkDeviceMemory vkOutputImageMemory;
123125

124-
// The imported allocation size must match the image's real (tiling-padded)
125-
// memory requirement, not the element-count size, or the SYCL import
126-
// under-describes the image on drivers that pad. Captured below.
126+
// Real import size; set to the image memory requirement below.
127127
size_t importSizeBytes = imgSizeBytes;
128128

129129
// Initialize image input data.
@@ -135,10 +135,8 @@ bool runTest(const sycl::device &syclDevice, sycl::range<2> dims,
135135

136136
// Create/allocate device images.
137137
{
138-
// STORAGE usage is required: SYCL accesses the imported image as a storage
139-
// image, and only that usage bit yields a layout compatible with the
140-
// storage-image reads/writes the kernel performs. Without it the import is
141-
// laid out for transfer only and reads land at the wrong offset.
138+
// STORAGE_BIT: SYCL reads/writes this as a storage image; without it the
139+
// layout is transfer-only and imported reads land at the wrong offset.
142140
vkInputImage = vkutil::createImage(imgType, imgInFormat, imgExtent,
143141
VK_IMAGE_USAGE_STORAGE_BIT |
144142
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
@@ -147,12 +145,14 @@ bool runTest(const sycl::device &syclDevice, sycl::range<2> dims,
147145
VkMemoryRequirements memRequirements;
148146
auto inputImageMemoryTypeIndex = vkutil::getImageMemoryTypeIndex(
149147
vkInputImage, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, memRequirements);
148+
// Import must describe the whole (padded) allocation the driver requires.
150149
importSizeBytes = std::max<size_t>(imgSizeBytes, memRequirements.size);
151150
vkInputImageMemory = vkutil::allocateDeviceMemory(
152151
imgSizeBytes, inputImageMemoryTypeIndex, vkInputImage);
153152
VK_CHECK_CALL(vkBindImageMemory(vk_device, vkInputImage, vkInputImageMemory,
154153
0 /*memoryOffset*/));
155154

155+
// STORAGE_BIT: same as input image; the kernel writes it as a storage image.
156156
vkOutputImage = vkutil::createImage(imgType, imgOutFormat, imgExtent,
157157
VK_IMAGE_USAGE_STORAGE_BIT |
158158
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
@@ -277,6 +277,7 @@ bool runTest(const sycl::device &syclDevice, sycl::range<2> dims,
277277

278278
// Call into SYCL to fetch from input image, and populate the output image.
279279
printString("Calling into SYCL with interop memory handles\n");
280+
// Pass the real import size so the SYCL import matches the Vulkan allocation.
280281
runSycl(syclDevice, dims, localSize, imgMemIn, imgMemOut, importSizeBytes);
281282

282283
// Copy image memory to temporary staging buffer, and back to host.

0 commit comments

Comments
 (0)