aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-autoroll <android-autoroll@skia-public.iam.gserviceaccount.com>2023-04-18 19:08:17 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-04-18 19:08:17 +0000
commit02c16af6bb4d826c023f755399b5ec6d938baea2 (patch)
tree3510c8ab5f089949460ddea239538746dbf8e670
parent5b2807ba5379c7cbb285f6cfabddcee792ae92e8 (diff)
parent1518a3b91f285f059557b5fd9fce94bcc77b9073 (diff)
downloadangle-02c16af6bb4d826c023f755399b5ec6d938baea2.tar.gz
Roll ANGLE from 7bc4b7e31f72 to be9fcaa96785 (4 revisions) am: 304449f4f9 am: 1518a3b91f
Original change: https://android-review.googlesource.com/c/platform/external/angle/+/2541572 Change-Id: I07fea37bbc198a16ad67168ff5da44fd872a7787 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--src/gpu_info_util/SystemInfo_macos.mm6
-rw-r--r--src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp24
-rw-r--r--src/libANGLE/renderer/vulkan/RendererVk.cpp53
-rw-r--r--src/libANGLE/renderer/vulkan/RendererVk.h9
-rw-r--r--src/libANGLE/renderer/vulkan/vk_helpers.cpp68
-rw-r--r--src/libANGLE/renderer/vulkan/vk_helpers.h2
-rw-r--r--src/libANGLE/renderer/vulkan/vk_utils.cpp40
-rw-r--r--src/libANGLE/renderer/vulkan/vk_utils.h6
8 files changed, 135 insertions, 73 deletions
diff --git a/src/gpu_info_util/SystemInfo_macos.mm b/src/gpu_info_util/SystemInfo_macos.mm
index 0dfa62cfb3..dd5b4d5203 100644
--- a/src/gpu_info_util/SystemInfo_macos.mm
+++ b/src/gpu_info_util/SystemInfo_macos.mm
@@ -189,6 +189,12 @@ void GetIORegistryDevices(std::vector<GPUDeviceInfo> *devices)
void ForceGPUSwitchIndex(SystemInfo *info)
{
+ // Early-out if on a single-GPU system
+ if (info->gpus.size() < 2)
+ {
+ return;
+ }
+
VendorID activeVendor = 0;
DeviceID activeDevice = 0;
diff --git a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
index 62e8d1c389..a85a74ae31 100644
--- a/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/TextureStorage11.cpp
@@ -1305,11 +1305,11 @@ angle::Result TextureStorage11_2D::ensureTextureExists(const gl::Context *contex
if (useLevelZeroTexture)
{
- outputTexture->setLabels("TexStorage2D.Level0Texture", &mKHRDebugLabel);
+ outputTexture->setLabels("TexStorage2D.Level0", &mKHRDebugLabel);
}
else
{
- outputTexture->setLabels("TexStorage2D.Texture", &mKHRDebugLabel);
+ outputTexture->setLabels("TexStorage2D", &mKHRDebugLabel);
}
}
@@ -1570,7 +1570,7 @@ angle::Result TextureStorage11_2D::getSwizzleTexture(const gl::Context *context,
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, format,
&mSwizzleTexture));
- mSwizzleTexture.setLabels("TexStorage2D.SwizzleTexture", &mKHRDebugLabel);
+ mSwizzleTexture.setLabels("TexStorage2D.Swizzle", &mKHRDebugLabel);
}
*outTexture = &mSwizzleTexture;
@@ -2039,7 +2039,7 @@ angle::Result TextureStorage11_EGLImage::getSwizzleTexture(const gl::Context *co
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, format,
&mSwizzleTexture));
- mSwizzleTexture.setLabels("TexStorageEGLImage.SwizzleTexture", &mKHRDebugLabel);
+ mSwizzleTexture.setLabels("TexStorageEGLImage.Swizzle", &mKHRDebugLabel);
}
*outTexture = &mSwizzleTexture;
@@ -2504,7 +2504,7 @@ angle::Result TextureStorage11_Cube::ensureTextureExists(const gl::Context *cont
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, mFormatInfo,
outputTexture));
- outputTexture->setLabels("TexStorageCube.Texture", &mKHRDebugLabel);
+ outputTexture->setLabels("TexStorageCube", &mKHRDebugLabel);
}
return angle::Result::Continue;
@@ -2815,7 +2815,7 @@ angle::Result TextureStorage11_Cube::getSwizzleTexture(const gl::Context *contex
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, format,
&mSwizzleTexture));
- mSwizzleTexture.setLabels("TexStorageCube.SwizzleTexture", &mKHRDebugLabel);
+ mSwizzleTexture.setLabels("TexStorageCube.Swizzle", &mKHRDebugLabel);
}
*outTexture = &mSwizzleTexture;
@@ -3045,7 +3045,7 @@ angle::Result TextureStorage11_3D::getResource(const gl::Context *context,
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, mFormatInfo,
&mTexture));
- mTexture.setLabels("TexStorage3D.Texture", &mKHRDebugLabel);
+ mTexture.setLabels("TexStorage3D", &mKHRDebugLabel);
}
*outResource = &mTexture;
@@ -3245,7 +3245,7 @@ angle::Result TextureStorage11_3D::getSwizzleTexture(const gl::Context *context,
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, format,
&mSwizzleTexture));
- mSwizzleTexture.setLabels("TexStorage3D.SwizzleTexture", &mKHRDebugLabel);
+ mSwizzleTexture.setLabels("TexStorage3D.Swizzle", &mKHRDebugLabel);
}
*outTexture = &mSwizzleTexture;
@@ -3440,7 +3440,7 @@ angle::Result TextureStorage11_2DArray::getResource(const gl::Context *context,
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, mFormatInfo,
&mTexture));
- mTexture.setLabels("TexStorage2DArray.Texture", &mKHRDebugLabel);
+ mTexture.setLabels("TexStorage2DArray", &mKHRDebugLabel);
}
*outResource = &mTexture;
@@ -3655,7 +3655,7 @@ angle::Result TextureStorage11_2DArray::getSwizzleTexture(const gl::Context *con
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, format,
&mSwizzleTexture));
- mSwizzleTexture.setLabels("TexStorage2DArray.SwizzleTexture", &mKHRDebugLabel);
+ mSwizzleTexture.setLabels("TexStorage2DArray.Swizzle", &mKHRDebugLabel);
}
*outTexture = &mSwizzleTexture;
@@ -3829,7 +3829,7 @@ angle::Result TextureStorage11_2DMultisample::ensureTextureExists(const gl::Cont
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, mFormatInfo,
&mTexture));
- mTexture.setLabels("TexStorage2DMS.Texture", &mKHRDebugLabel);
+ mTexture.setLabels("TexStorage2DMS", &mKHRDebugLabel);
}
return angle::Result::Continue;
@@ -4050,7 +4050,7 @@ angle::Result TextureStorage11_2DMultisampleArray::ensureTextureExists(const gl:
ANGLE_TRY(mRenderer->allocateTexture(GetImplAs<Context11>(context), desc, mFormatInfo,
&mTexture));
- mTexture.setLabels("TexStorage2DMSArray.Texture", &mKHRDebugLabel);
+ mTexture.setLabels("TexStorage2DMSArray", &mKHRDebugLabel);
}
return angle::Result::Continue;
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 446afd8ed0..47ff8df2bd 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -177,6 +177,8 @@ VkResult VerifyExtensionsPresent(const vk::ExtensionNameList &haystack,
constexpr const char *kSkippedMessages[] = {
// http://anglebug.com/2866
"UNASSIGNED-CoreValidation-Shader-OutputNotConsumed",
+ // http://anglebug.com/4883
+ "UNASSIGNED-CoreValidation-Shader-InputNotProduced",
// http://anglebug.com/4928
"VUID-vkMapMemory-memory-00683",
// http://anglebug.com/5027
@@ -195,6 +197,8 @@ constexpr const char *kSkippedMessages[] = {
"VUID-vkCmdDrawIndexedIndirectCount-None-04584",
// http://anglebug.com/5912
"VUID-VkImageViewCreateInfo-pNext-01585",
+ // http://anglebug.com/6442
+ "UNASSIGNED-CoreValidation-Shader-InterfaceTypeMismatch",
// http://anglebug.com/6514
"vkEnumeratePhysicalDevices: One or more layers modified physical devices",
// When using Vulkan secondary command buffers, the command buffer is begun with the current
@@ -5534,16 +5538,59 @@ VkResult ImageMemorySuballocator::allocateAndBindMemory(RendererVk *renderer,
Image *image,
VkMemoryPropertyFlags requiredFlags,
VkMemoryPropertyFlags preferredFlags,
+ MemoryAllocationType memoryAllocationType,
Allocation *allocationOut,
+ VkMemoryPropertyFlags *memoryFlagsOut,
uint32_t *memoryTypeIndexOut,
VkDeviceSize *sizeOut)
{
ASSERT(image && image->valid());
ASSERT(allocationOut && !allocationOut->valid());
const Allocator &allocator = renderer->getAllocator();
- return vma::AllocateAndBindMemoryForImage(allocator.getHandle(), &image->mHandle, requiredFlags,
- preferredFlags, &allocationOut->mHandle,
- memoryTypeIndexOut, sizeOut);
+
+ VkResult result = vma::AllocateAndBindMemoryForImage(
+ allocator.getHandle(), &image->mHandle, requiredFlags, preferredFlags,
+ &allocationOut->mHandle, memoryTypeIndexOut, sizeOut);
+ if (result != VK_SUCCESS)
+ {
+ return result;
+ }
+
+ // We need to get the property flags of the allocated memory.
+ *memoryFlagsOut =
+ renderer->getMemoryProperties().getMemoryType(*memoryTypeIndexOut).propertyFlags;
+
+ renderer->onMemoryAlloc(memoryAllocationType, *sizeOut, *memoryTypeIndexOut,
+ allocationOut->getHandle());
+ return VK_SUCCESS;
+}
+
+VkResult ImageMemorySuballocator::mapMemoryAndInitWithNonZeroValue(RendererVk *renderer,
+ Allocation *allocation,
+ VkDeviceSize size,
+ int value,
+ VkMemoryPropertyFlags flags)
+{
+ ASSERT(allocation && allocation->valid());
+ const Allocator &allocator = renderer->getAllocator();
+
+ void *mappedMemoryData;
+ VkResult result = vma::MapMemory(allocator.getHandle(), allocation->mHandle, &mappedMemoryData);
+ if (result != VK_SUCCESS)
+ {
+ return result;
+ }
+
+ memset(mappedMemoryData, value, static_cast<size_t>(size));
+ vma::UnmapMemory(allocator.getHandle(), allocation->mHandle);
+
+ // If the memory type is not host coherent, we perform an explicit flush.
+ if ((flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == 0)
+ {
+ vma::FlushAllocation(allocator.getHandle(), allocation->mHandle, 0, VK_WHOLE_SIZE);
+ }
+
+ return VK_SUCCESS;
}
} // namespace vk
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.h b/src/libANGLE/renderer/vulkan/RendererVk.h
index e98721d8a3..dd00d66190 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.h
+++ b/src/libANGLE/renderer/vulkan/RendererVk.h
@@ -81,9 +81,18 @@ class ImageMemorySuballocator : angle::NonCopyable
Image *image,
VkMemoryPropertyFlags requiredFlags,
VkMemoryPropertyFlags preferredFlags,
+ MemoryAllocationType memoryAllocationType,
Allocation *allocationOut,
+ VkMemoryPropertyFlags *memoryFlagsOut,
uint32_t *memoryTypeIndexOut,
VkDeviceSize *sizeOut);
+
+ // Maps the memory to initialize with non-zero value.
+ VkResult mapMemoryAndInitWithNonZeroValue(RendererVk *renderer,
+ Allocation *allocation,
+ VkDeviceSize size,
+ int value,
+ VkMemoryPropertyFlags flags);
};
} // namespace vk
diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.cpp b/src/libANGLE/renderer/vulkan/vk_helpers.cpp
index e3a2371b7a..23d38338c7 100644
--- a/src/libANGLE/renderer/vulkan/vk_helpers.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_helpers.cpp
@@ -5241,6 +5241,35 @@ void BufferHelper::fillWithColor(const angle::Color<uint8_t> &color,
}
}
+// Used for ImageHelper non-zero memory allocation when useVmaForImageSuballocation is disabled.
+angle::Result InitMappableDeviceMemory(Context *context,
+ DeviceMemory *deviceMemory,
+ VkDeviceSize size,
+ int value,
+ VkMemoryPropertyFlags memoryPropertyFlags)
+{
+ ASSERT(!context->getFeatures().useVmaForImageSuballocation.enabled);
+ VkDevice device = context->getDevice();
+
+ uint8_t *mapPointer;
+ ANGLE_VK_TRY(context, deviceMemory->map(device, 0, VK_WHOLE_SIZE, 0, &mapPointer));
+ memset(mapPointer, value, static_cast<size_t>(size));
+
+ // if the memory type is not host coherent, we perform an explicit flush.
+ if ((memoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == 0)
+ {
+ VkMappedMemoryRange mappedRange = {};
+ mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
+ mappedRange.memory = deviceMemory->getHandle();
+ mappedRange.size = VK_WHOLE_SIZE;
+ ANGLE_VK_TRY(context, vkFlushMappedMemoryRanges(device, 1, &mappedRange));
+ }
+
+ deviceMemory->unmap(device);
+
+ return angle::Result::Continue;
+}
+
// ImageHelper implementation.
ImageHelper::ImageHelper()
{
@@ -5736,8 +5765,32 @@ void ImageHelper::resetImageWeakReference()
angle::Result ImageHelper::initializeNonZeroMemory(Context *context,
bool hasProtectedContent,
+ VkMemoryPropertyFlags flags,
VkDeviceSize size)
{
+ // If available, memory mapping should be used.
+ RendererVk *renderer = context->getRenderer();
+ if ((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
+ {
+ // Wipe memory to an invalid value when the 'allocateNonZeroMemory' feature is enabled. The
+ // invalid values ensures our testing doesn't assume zero-initialized memory.
+ constexpr int kNonZeroInitValue = 0x3F;
+ if (renderer->getFeatures().useVmaForImageSuballocation.enabled)
+ {
+ ANGLE_VK_TRY(context,
+ renderer->getImageMemorySuballocator().mapMemoryAndInitWithNonZeroValue(
+ renderer, &mVmaAllocation, size, kNonZeroInitValue, flags));
+ }
+ else
+ {
+ ANGLE_TRY(vk::InitMappableDeviceMemory(context, &mDeviceMemory, size, kNonZeroInitValue,
+ flags));
+ }
+
+ return angle::Result::Continue;
+ }
+
+ // If mapping the memory is unavailable, a staging resource is used.
const angle::Format &angleFormat = getActualFormat();
bool isCompressedFormat = angleFormat.isBlock;
@@ -5749,8 +5802,6 @@ angle::Result ImageHelper::initializeNonZeroMemory(Context *context,
return angle::Result::Continue;
}
- RendererVk *renderer = context->getRenderer();
-
PrimaryCommandBuffer commandBuffer;
auto protectionType = ConvertProtectionBoolToType(hasProtectedContent);
ANGLE_TRY(renderer->getCommandBufferOneOff(context, protectionType, &commandBuffer));
@@ -5870,11 +5921,8 @@ angle::Result ImageHelper::initMemory(Context *context,
if (renderer->getFeatures().useVmaForImageSuballocation.enabled)
{
ANGLE_VK_TRY(context, renderer->getImageMemorySuballocator().allocateAndBindMemory(
- renderer, &mImage, flags, flags, &mVmaAllocation,
- &mMemoryTypeIndex, &mAllocationSize));
-
- renderer->onMemoryAlloc(mMemoryAllocationType, mAllocationSize, mMemoryTypeIndex,
- mVmaAllocation.getHandle());
+ renderer, &mImage, flags, flags, mMemoryAllocationType,
+ &mVmaAllocation, &flags, &mMemoryTypeIndex, &mAllocationSize));
}
else
{
@@ -5886,11 +5934,7 @@ angle::Result ImageHelper::initMemory(Context *context,
if (renderer->getFeatures().allocateNonZeroMemory.enabled)
{
- // Can't map the memory. Use a staging resource.
- if ((flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0)
- {
- ANGLE_TRY(initializeNonZeroMemory(context, hasProtectedContent, mAllocationSize));
- }
+ ANGLE_TRY(initializeNonZeroMemory(context, hasProtectedContent, flags, mAllocationSize));
}
return angle::Result::Continue;
diff --git a/src/libANGLE/renderer/vulkan/vk_helpers.h b/src/libANGLE/renderer/vulkan/vk_helpers.h
index b32794174d..8c1b766d9b 100644
--- a/src/libANGLE/renderer/vulkan/vk_helpers.h
+++ b/src/libANGLE/renderer/vulkan/vk_helpers.h
@@ -1784,6 +1784,7 @@ bool CanCopyWithTransfer(RendererVk *renderer,
VkImageTiling srcTilingMode,
angle::FormatID dstFormatID,
VkImageTiling dstTilingMode);
+
class ImageViewHelper;
class ImageHelper final : public Resource, public angle::Subject
{
@@ -2579,6 +2580,7 @@ class ImageHelper final : public Resource, public angle::Subject
angle::Result initializeNonZeroMemory(Context *context,
bool hasProtectedContent,
+ VkMemoryPropertyFlags flags,
VkDeviceSize size);
std::vector<SubresourceUpdate> *getLevelUpdates(gl::LevelIndex level);
diff --git a/src/libANGLE/renderer/vulkan/vk_utils.cpp b/src/libANGLE/renderer/vulkan/vk_utils.cpp
index 4de33b12b1..8cdb8309fd 100644
--- a/src/libANGLE/renderer/vulkan/vk_utils.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_utils.cpp
@@ -110,19 +110,6 @@ angle::Result FindAndAllocateCompatibleMemory(vk::Context *context,
renderer->onMemoryAlloc(memoryAllocationType, allocInfo.allocationSize, *memoryTypeIndexOut,
deviceMemoryOut->getHandle());
- // Wipe memory to an invalid value when the 'allocateNonZeroMemory' feature is enabled. The
- // invalid values ensures our testing doesn't assume zero-initialized memory.
- if (renderer->getFeatures().allocateNonZeroMemory.enabled)
- {
- if ((*memoryPropertyFlagsOut & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) != 0)
- {
- // Can map the memory.
- ANGLE_TRY(vk::InitMappableDeviceMemory(context, deviceMemoryOut,
- memoryRequirements.size, kNonZeroInitValue,
- *memoryPropertyFlagsOut));
- }
- }
-
return angle::Result::Continue;
}
@@ -582,33 +569,6 @@ angle::Result InitMappableAllocation(Context *context,
return angle::Result::Continue;
}
-angle::Result InitMappableDeviceMemory(Context *context,
- DeviceMemory *deviceMemory,
- VkDeviceSize size,
- int value,
- VkMemoryPropertyFlags memoryPropertyFlags)
-{
- VkDevice device = context->getDevice();
-
- uint8_t *mapPointer;
- ANGLE_VK_TRY(context, deviceMemory->map(device, 0, VK_WHOLE_SIZE, 0, &mapPointer));
- memset(mapPointer, value, static_cast<size_t>(size));
-
- // if the memory type is not host coherent, we perform an explicit flush
- if ((memoryPropertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT) == 0)
- {
- VkMappedMemoryRange mappedRange = {};
- mappedRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
- mappedRange.memory = deviceMemory->getHandle();
- mappedRange.size = VK_WHOLE_SIZE;
- ANGLE_VK_TRY(context, vkFlushMappedMemoryRanges(device, 1, &mappedRange));
- }
-
- deviceMemory->unmap(device);
-
- return angle::Result::Continue;
-}
-
angle::Result AllocateBufferMemory(Context *context,
vk::MemoryAllocationType memoryAllocationType,
VkMemoryPropertyFlags requestedMemoryPropertyFlags,
diff --git a/src/libANGLE/renderer/vulkan/vk_utils.h b/src/libANGLE/renderer/vulkan/vk_utils.h
index f846ed572a..504d589fc2 100644
--- a/src/libANGLE/renderer/vulkan/vk_utils.h
+++ b/src/libANGLE/renderer/vulkan/vk_utils.h
@@ -522,12 +522,6 @@ angle::Result InitMappableAllocation(Context *context,
int value,
VkMemoryPropertyFlags memoryPropertyFlags);
-angle::Result InitMappableDeviceMemory(Context *context,
- DeviceMemory *deviceMemory,
- VkDeviceSize size,
- int value,
- VkMemoryPropertyFlags memoryPropertyFlags);
-
angle::Result AllocateBufferMemory(Context *context,
vk::MemoryAllocationType memoryAllocationType,
VkMemoryPropertyFlags requestedMemoryPropertyFlags,