flushAlloc(vk, device, alloc);
// Staging image
+ const auto& imgResource = m_resource.getImage();
m_image = de::MovePtr<Image>(new Image(
vk, device, allocator,
- makeImageCreateInfo(m_resource.getImage().imageType, m_resource.getImage().extent, m_resource.getImage().format, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT),
+ makeImageCreateInfo(imgResource.imageType, imgResource.extent, imgResource.format,
+ (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT), VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
MemoryRequirement::Any));
}
{
const InstanceInterface& vki = m_context.getInstanceInterface();
const VkPhysicalDevice physDevice = m_context.getPhysicalDevice();
- const VkFormatProperties formatProps = getPhysicalDeviceFormatProperties(vki, physDevice, m_resource.getImage().format);
+ const auto& imgResource = m_resource.getImage();
+ const VkFormatProperties formatProps = getPhysicalDeviceFormatProperties(vki, physDevice, imgResource.format);
+ const auto& features = ((imgResource.tiling == VK_IMAGE_TILING_LINEAR) ? formatProps.linearTilingFeatures : formatProps.optimalTilingFeatures);
const VkFormatFeatureFlags requiredFlags = (VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT);
// SRC and DST blit is required because both images are using the same format.
- if ((formatProps.optimalTilingFeatures & requiredFlags) != requiredFlags)
+ if ((features & requiredFlags) != requiredFlags)
TCU_THROW(NotSupportedError, "Format doesn't support blits");
}
const InstanceInterface& vki = m_context.getInstanceInterface();
const VkPhysicalDevice physDevice = m_context.getPhysicalDevice();
- const VkFormatProperties formatProps = getPhysicalDeviceFormatProperties(vki, physDevice, m_inResource.getImage().format);
+ const auto& imgResource = m_inResource.getImage();
+ const VkFormatProperties formatProps = getPhysicalDeviceFormatProperties(vki, physDevice, imgResource.format);
+ const auto& features = ((imgResource.tiling == VK_IMAGE_TILING_LINEAR) ? formatProps.linearTilingFeatures : formatProps.optimalTilingFeatures);
const VkFormatFeatureFlags requiredFlags = (VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT);
// SRC and DST blit is required because both images are using the same format.
- if ((formatProps.optimalTilingFeatures & requiredFlags) != requiredFlags)
+ if ((features & requiredFlags) != requiredFlags)
TCU_THROW(NotSupportedError, "Format doesn't support blits");
}
m_colorImageSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
m_colorImageExtent = makeExtent3D(16u, 16u, 1u);
m_colorAttachmentImage = de::MovePtr<Image>(new Image(vk, device, allocator,
- makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_colorImageExtent, m_colorFormat, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT),
+ makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_colorImageExtent, m_colorFormat, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+ VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
MemoryRequirement::Any));
// Pipeline
requireFeaturesForSSBOAccess(m_context, m_stage);
// Some storage image formats may not be supported
- requireStorageImageSupport(vki, physDevice, m_resource.getImage().format);
+ const auto& imgResource = m_resource.getImage();
+ requireStorageImageSupport(vki, physDevice, imgResource.format, imgResource.tiling);
m_hostBuffer = de::MovePtr<Buffer>(new Buffer(
vk, device, allocator, makeBufferCreateInfo(m_hostBufferSizeBytes, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT),
{
m_image = de::MovePtr<Image>(new Image(vk, device, allocator,
makeImageCreateInfo(m_resource.getImage().imageType, m_resource.getImage().extent, m_resource.getImage().format,
- VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_STORAGE_BIT),
+ (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_STORAGE_BIT),
+ VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
MemoryRequirement::Any));
if (m_mode == ACCESS_MODE_READ)
requireFeaturesForSSBOAccess(m_context, m_stage);
// Some storage image formats may not be supported
- requireStorageImageSupport(vki, physDevice, m_inResource.getImage().format);
+ const auto& imgResource = m_inResource.getImage();
+ requireStorageImageSupport(vki, physDevice, imgResource.format, imgResource.tiling);
// Image resources
{
const VkPhysicalDeviceFeatures features = getPhysicalDeviceFeatures(vki, physDevice);
Allocator& allocator = m_context.getAllocator();
- requireStorageImageSupport(vki, physDevice, m_resource.getImage().format);
+ const auto& imgResource = m_resource.getImage();
+ requireStorageImageSupport(vki, physDevice, imgResource.format, imgResource.tiling);
if (!features.shaderStorageImageMultisample)
TCU_THROW(NotSupportedError, "Using multisample images as storage is not supported");
// Copy destination image.
m_image = de::MovePtr<Image>(new Image(
- vk, device, allocator, makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_imageExtent, format, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT), MemoryRequirement::Any));
+ vk, device, allocator,
+ makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_imageExtent, format,
+ (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT),
+ VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
+ MemoryRequirement::Any));
// Image data will be copied here, so it can be read on the host.
m_hostBuffer = de::MovePtr<Buffer>(new Buffer(
// Source data image
m_image = de::MovePtr<Image>(new Image(
- vk, device, allocator, makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_imageExtent, format, VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT), MemoryRequirement::Any));
+ vk, device, allocator,
+ makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_imageExtent, format, (VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT),
+ VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
+ MemoryRequirement::Any));
}
void recordCommands (const VkCommandBuffer cmdBuffer)
m_colorImageSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
m_colorImageExtent = makeExtent3D(16u, 16u, 1u);
m_colorAttachmentImage = de::MovePtr<Image>(new Image(vk, device, allocator,
- makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_colorImageExtent, m_colorFormat, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT),
+ makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_colorImageExtent, m_colorFormat, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+ VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
MemoryRequirement::Any));
// Pipeline
m_colorImageSubresourceRange = makeImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u);
m_colorImageExtent = makeExtent3D(16u, 16u, 1u);
m_colorAttachmentImage = de::MovePtr<Image>(new Image(vk, device, allocator,
- makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_colorImageExtent, m_colorFormat, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT),
+ makeImageCreateInfo(VK_IMAGE_TYPE_2D, m_colorImageExtent, m_colorFormat, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+ VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_TILING_OPTIMAL),
MemoryRequirement::Any));
// Pipeline
if (m_type == RESOURCE_TYPE_BUFFER || m_type == RESOURCE_TYPE_INDEX_BUFFER || isIndirectBuffer(m_type))
{
- m_bufferData.offset = 0u;
- m_bufferData.size = static_cast<VkDeviceSize>(desc.size.x());
- VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_bufferData.size, usage);
+ m_bufferData = de::MovePtr<BufferResource>(new BufferResource(DE_NULL, 0u, static_cast<VkDeviceSize>(desc.size.x())));
+ VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(m_bufferData->size, usage);
bufferCreateInfo.sharingMode = sharingMode;
if (queueFamilyIndex.size() > 0)
{
bufferCreateInfo.queueFamilyIndexCount = static_cast<deUint32>(queueFamilyIndex.size());
bufferCreateInfo.pQueueFamilyIndices = &queueFamilyIndex[0];
}
- m_buffer = de::MovePtr<Buffer>(new Buffer(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Any));
- m_bufferData.handle = **m_buffer;
+ m_buffer = de::MovePtr<Buffer>(new Buffer(vk, device, allocator, bufferCreateInfo, MemoryRequirement::Any));
+ m_bufferData->handle = **m_buffer;
}
else if (m_type == RESOURCE_TYPE_IMAGE)
{
- m_imageData.extent = makeExtent3D(desc.size.x(), std::max(1, desc.size.y()), std::max(1, desc.size.z()));
- m_imageData.imageType = desc.imageType;
- m_imageData.format = desc.imageFormat;
- m_imageData.subresourceRange = makeImageSubresourceRange(desc.imageAspect, 0u, 1u, 0u, 1u);
- m_imageData.subresourceLayers = makeImageSubresourceLayers(desc.imageAspect, 0u, 0u, 1u);
- VkImageCreateInfo imageInfo = makeImageCreateInfo(m_imageData.imageType, m_imageData.extent, m_imageData.format, usage, desc.imageSamples);
+ m_imageData = de::MovePtr<ImageResource>(new ImageResource(
+ DE_NULL,
+ makeExtent3D(desc.size.x(), std::max(1, desc.size.y()), std::max(1, desc.size.z())),
+ desc.imageType,
+ desc.imageFormat,
+ makeImageSubresourceRange(desc.imageAspect, 0u, 1u, 0u, 1u),
+ makeImageSubresourceLayers(desc.imageAspect, 0u, 0u, 1u),
+ vk::VK_IMAGE_TILING_OPTIMAL
+ ));
+ VkImageCreateInfo imageInfo = makeImageCreateInfo(m_imageData->imageType, m_imageData->extent, m_imageData->format, usage, desc.imageSamples, m_imageData->tiling);
imageInfo.sharingMode = sharingMode;
if (queueFamilyIndex.size() > 0)
{
TCU_THROW(NotSupportedError, "Requested sample count is not supported");
m_image = de::MovePtr<Image>(new Image(vk, device, allocator, imageInfo, MemoryRequirement::Any));
- m_imageData.handle = **m_image;
+ m_imageData->handle = **m_image;
}
else
DE_ASSERT(0);
de::MovePtr<vk::Allocation> allocation,
vk::VkDeviceSize offset,
vk::VkDeviceSize size)
- : m_type (type)
- , m_buffer (new Buffer(buffer, allocation))
+ : m_type (type)
+ , m_buffer (new Buffer(buffer, allocation))
+ , m_bufferData (de::MovePtr<BufferResource>(new BufferResource(m_buffer->get(), offset, size)))
{
DE_ASSERT(type != RESOURCE_TYPE_IMAGE);
-
- m_bufferData.handle = m_buffer->get();
- m_bufferData.offset = offset;
- m_bufferData.size = size;
}
Resource::Resource (vk::Move<vk::VkImage> image,
vk::VkImageType imageType,
vk::VkFormat format,
vk::VkImageSubresourceRange subresourceRange,
- vk::VkImageSubresourceLayers subresourceLayers)
- : m_type (RESOURCE_TYPE_IMAGE)
- , m_image (new Image(image, allocation))
+ vk::VkImageSubresourceLayers subresourceLayers,
+ vk::VkImageTiling tiling)
+ : m_type (RESOURCE_TYPE_IMAGE)
+ , m_image (new Image(image, allocation))
+ , m_imageData (de::MovePtr<ImageResource>(new ImageResource(m_image->get(), extent, imageType, format, subresourceRange, subresourceLayers, tiling)))
{
- m_imageData.handle = m_image->get();
- m_imageData.extent = extent;
- m_imageData.imageType = imageType;
- m_imageData.format = format;
- m_imageData.subresourceRange = subresourceRange;
- m_imageData.subresourceLayers = subresourceLayers;
}
vk::VkDeviceMemory Resource::getMemory (void) const
DE_NULL,
(VkExternalMemoryHandleTypeFlags)externalType
};
+ const VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
const VkImageCreateInfo createInfo =
{
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
1u,
1u,
resourceDesc.imageSamples,
- VK_IMAGE_TILING_OPTIMAL,
+ tiling,
readOp.getInResourceUsageFlags() | writeOp.getOutResourceUsageFlags(),
VK_SHARING_MODE_EXCLUSIVE,
Move<VkImage> image = createImage(vkd, device, &createInfo);
MovePtr<Allocation> allocation = importAndBindMemory(vkd, device, *image, nativeHandle, externalType, exportedMemoryTypeIndex);
- return MovePtr<Resource>(new Resource(image, allocation, extent, resourceDesc.imageType, resourceDesc.imageFormat, subresourceRange, subresourceLayers));
+ return MovePtr<Resource>(new Resource(image, allocation, extent, resourceDesc.imageType, resourceDesc.imageFormat, subresourceRange, subresourceLayers, tiling));
}
else
{
Move<VkImage> createImage (const vk::DeviceInterface& vkd,
vk::VkDevice device,
const vk::VkExtent3D& extent,
- deUint32 queueFamilyIndex)
+ deUint32 queueFamilyIndex,
+ vk::VkImageTiling tiling)
{
const VkExternalMemoryImageCreateInfo externalInfo =
{
1u,
1u,
m_resourceDesc.imageSamples,
- VK_IMAGE_TILING_OPTIMAL,
+ tiling,
m_readOpSupport->getInResourceUsageFlags() | m_writeOpSupport->getOutResourceUsageFlags(),
VK_SHARING_MODE_EXCLUSIVE,
1u
};
- Move<VkImage> image = createImage(vkA, deviceA, extent, universalQueueFamilyIndex);
+ const vk::VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
+ Move<VkImage> image = createImage(vkA, deviceA, extent, universalQueueFamilyIndex, tiling);
const vk::VkMemoryRequirements requirements = getMemoryRequirements(vkA, deviceA, *image);
memoryTypeIndex = chooseMemoryType(requirements.memoryTypeBits);
vk::Move<vk::VkDeviceMemory> memory = allocateExportableMemory(vkA, deviceA, requirements.size, memoryTypeIndex, m_memoryHandleType, *image);
VK_CHECK(vkA.bindImageMemory(deviceA, *image, *memory, 0u));
MovePtr<Allocation> allocation(new SimpleAllocation(vkA, deviceA, memory.disown()));
- iter.resourceA = makeSharedPtr(new Resource(image, allocation, extent, m_resourceDesc.imageType, m_resourceDesc.imageFormat, subresourceRange, subresourceLayers));
+ iter.resourceA = makeSharedPtr(new Resource(image, allocation, extent, m_resourceDesc.imageType, m_resourceDesc.imageFormat, subresourceRange, subresourceLayers, tiling));
}
else
{