Commit 58ff77a8 by Mohan Maiya Committed by Commit Bot

Vulkan: Set new layout based on VkImageUsageFlags

When transferring vkImages between queues, the new layout needs to be set based on the usage flags of the vkImage instead of hardcoding it to AllGraphicsShadersReadWrite Bug: angleproject:4791 Change-Id: I3b543a6280e6c2317cc11bf65dc4c337bc5f90b1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2271563 Commit-Queue: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b31a1939
...@@ -1070,10 +1070,24 @@ angle::Result TextureVk::setEGLImageTarget(const gl::Context *context, ...@@ -1070,10 +1070,24 @@ angle::Result TextureVk::setEGLImageTarget(const gl::Context *context,
if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex)) if (mImage->isQueueChangeNeccesary(rendererQueueFamilyIndex))
{ {
vk::CommandBuffer *commandBuffer = nullptr; vk::CommandBuffer *commandBuffer = nullptr;
vk::ImageLayout newLayout = vk::ImageLayout::AllGraphicsShadersReadWrite;
if (mImage->getUsage() & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT)
{
newLayout = vk::ImageLayout::ColorAttachment;
}
else if (mImage->getUsage() & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT)
{
newLayout = vk::ImageLayout::DepthStencilAttachment;
}
else if (mImage->getUsage() &
(VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT))
{
newLayout = vk::ImageLayout::AllGraphicsShadersReadOnly;
}
ANGLE_TRY(contextVk->endRenderPassAndGetCommandBuffer(&commandBuffer)); ANGLE_TRY(contextVk->endRenderPassAndGetCommandBuffer(&commandBuffer));
mImage->changeLayoutAndQueue(VK_IMAGE_ASPECT_COLOR_BIT, mImage->changeLayoutAndQueue(VK_IMAGE_ASPECT_COLOR_BIT, newLayout, rendererQueueFamilyIndex,
vk::ImageLayout::AllGraphicsShadersReadWrite, commandBuffer);
rendererQueueFamilyIndex, commandBuffer);
} }
return angle::Result::Continue; return angle::Result::Continue;
......
...@@ -2459,6 +2459,7 @@ ImageHelper::ImageHelper(ImageHelper &&other) ...@@ -2459,6 +2459,7 @@ ImageHelper::ImageHelper(ImageHelper &&other)
mDeviceMemory(std::move(other.mDeviceMemory)), mDeviceMemory(std::move(other.mDeviceMemory)),
mImageType(other.mImageType), mImageType(other.mImageType),
mTilingMode(other.mTilingMode), mTilingMode(other.mTilingMode),
mUsage(other.mUsage),
mExtents(other.mExtents), mExtents(other.mExtents),
mFormat(other.mFormat), mFormat(other.mFormat),
mSamples(other.mSamples), mSamples(other.mSamples),
...@@ -2491,6 +2492,7 @@ void ImageHelper::resetCachedProperties() ...@@ -2491,6 +2492,7 @@ void ImageHelper::resetCachedProperties()
mSamples = 1; mSamples = 1;
mSerial = rx::kZeroSerial; mSerial = rx::kZeroSerial;
mTilingMode = VK_IMAGE_TILING_OPTIMAL; mTilingMode = VK_IMAGE_TILING_OPTIMAL;
mUsage = 0;
mCurrentLayout = ImageLayout::Undefined; mCurrentLayout = ImageLayout::Undefined;
mCurrentQueueFamilyIndex = std::numeric_limits<uint32_t>::max(); mCurrentQueueFamilyIndex = std::numeric_limits<uint32_t>::max();
mLastNonShaderReadOnlyLayout = ImageLayout::Undefined; mLastNonShaderReadOnlyLayout = ImageLayout::Undefined;
...@@ -2550,6 +2552,7 @@ angle::Result ImageHelper::initExternal(Context *context, ...@@ -2550,6 +2552,7 @@ angle::Result ImageHelper::initExternal(Context *context,
mMaxLevel = maxLevel; mMaxLevel = maxLevel;
mLevelCount = mipLevels; mLevelCount = mipLevels;
mLayerCount = layerCount; mLayerCount = layerCount;
mUsage = usage;
// Validate that mLayerCount is compatible with the texture type // Validate that mLayerCount is compatible with the texture type
ASSERT(textureType != gl::TextureType::_3D || mLayerCount == 1); ASSERT(textureType != gl::TextureType::_3D || mLayerCount == 1);
...@@ -2569,7 +2572,7 @@ angle::Result ImageHelper::initExternal(Context *context, ...@@ -2569,7 +2572,7 @@ angle::Result ImageHelper::initExternal(Context *context,
imageInfo.arrayLayers = mLayerCount; imageInfo.arrayLayers = mLayerCount;
imageInfo.samples = gl_vk::GetSamples(samples); imageInfo.samples = gl_vk::GetSamples(samples);
imageInfo.tiling = mTilingMode; imageInfo.tiling = mTilingMode;
imageInfo.usage = usage; imageInfo.usage = mUsage;
imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
imageInfo.queueFamilyIndexCount = 0; imageInfo.queueFamilyIndexCount = 0;
imageInfo.pQueueFamilyIndices = nullptr; imageInfo.pQueueFamilyIndices = nullptr;
......
...@@ -1127,7 +1127,8 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -1127,7 +1127,8 @@ class ImageHelper final : public Resource, public angle::Subject
const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; } const DeviceMemory &getDeviceMemory() const { return mDeviceMemory; }
void setTilingMode(VkImageTiling tilingMode) { mTilingMode = tilingMode; } void setTilingMode(VkImageTiling tilingMode) { mTilingMode = tilingMode; }
VkImageTiling getTilingMode() { return mTilingMode; } VkImageTiling getTilingMode() const { return mTilingMode; }
VkImageUsageFlags getUsage() const { return mUsage; }
VkImageType getType() const { return mImageType; } VkImageType getType() const { return mImageType; }
const VkExtent3D &getExtents() const { return mExtents; } const VkExtent3D &getExtents() const { return mExtents; }
uint32_t getLayerCount() const { return mLayerCount; } uint32_t getLayerCount() const { return mLayerCount; }
...@@ -1501,6 +1502,7 @@ class ImageHelper final : public Resource, public angle::Subject ...@@ -1501,6 +1502,7 @@ class ImageHelper final : public Resource, public angle::Subject
// Image properties. // Image properties.
VkImageType mImageType; VkImageType mImageType;
VkImageTiling mTilingMode; VkImageTiling mTilingMode;
VkImageUsageFlags mUsage;
VkExtent3D mExtents; VkExtent3D mExtents;
const Format *mFormat; const Format *mFormat;
GLint mSamples; GLint mSamples;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment