For goldfish pipe, compute colorBufferMemoryIndex the same as host.
Reviewed-by: Aaron Ruby <aruby@blackberry.com> Acked-by: Yonggang Luo <luoyonggang@gmail.com> Acked-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27246>
This commit is contained in:
@@ -1668,6 +1668,51 @@ public:
|
||||
}
|
||||
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
uint32_t getColorBufferMemoryIndex(void* context, VkDevice device) {
|
||||
// Create test image to get the memory requirements
|
||||
VkEncoder* enc = (VkEncoder*)context;
|
||||
VkImageCreateInfo createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||
.imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = VK_FORMAT_R8G8B8A8_UNORM,
|
||||
.extent = {64, 64, 1},
|
||||
.mipLevels = 1,
|
||||
.arrayLayers = 1,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT,
|
||||
.tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
|
||||
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
|
||||
.initialLayout = VK_IMAGE_LAYOUT_MAX_ENUM,
|
||||
};
|
||||
VkImage image = VK_NULL_HANDLE;
|
||||
VkResult res = enc->vkCreateImage(device, &createInfo, nullptr, &image, true /* do lock */);
|
||||
|
||||
if (res != VK_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkMemoryRequirements memReqs;
|
||||
enc->vkGetImageMemoryRequirements(
|
||||
device, image, &memReqs, true /* do lock */);
|
||||
enc->vkDestroyImage(device, image, nullptr, true /* do lock */);
|
||||
|
||||
const VkPhysicalDeviceMemoryProperties& memProps =
|
||||
getPhysicalDeviceMemoryProperties(context, device, VK_NULL_HANDLE);
|
||||
|
||||
// Currently, host looks for the last index that has with memory
|
||||
// property type VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
|
||||
VkMemoryPropertyFlags memoryProperty = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
for (int i = VK_MAX_MEMORY_TYPES - 1; i >= 0; --i) {
|
||||
if ((memReqs.memoryTypeBits & (1u << i)) &&
|
||||
(memProps.memoryTypes[i].propertyFlags & memoryProperty)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkResult on_vkGetAndroidHardwareBufferPropertiesANDROID(
|
||||
void* context, VkResult,
|
||||
VkDevice device,
|
||||
@@ -1677,12 +1722,9 @@ public:
|
||||
ResourceTracker::threadingCallbacks.hostConnectionGetFunc()->grallocHelper();
|
||||
|
||||
// Delete once goldfish Linux drivers are gone
|
||||
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
|
||||
const VkPhysicalDeviceMemoryProperties& memProps =
|
||||
getPhysicalDeviceMemoryProperties(context, device, VK_NULL_HANDLE);
|
||||
|
||||
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
|
||||
mCaps.gfxstreamCapset.colorBufferMemoryIndex =
|
||||
(1u << memProps.memoryTypeCount) - 1;
|
||||
getColorBufferMemoryIndex(context, device);
|
||||
}
|
||||
|
||||
updateMemoryTypeBits(&pProperties->memoryTypeBits,
|
||||
@@ -4281,8 +4323,11 @@ public:
|
||||
|
||||
// Delete `protocolVersion` check goldfish drivers are gone.
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
|
||||
mCaps.gfxstreamCapset.colorBufferMemoryIndex =
|
||||
getColorBufferMemoryIndex(context, device);
|
||||
}
|
||||
if (extImgCiPtr &&
|
||||
mCaps.gfxstreamCapset.protocolVersion &&
|
||||
(extImgCiPtr->handleTypes &
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) {
|
||||
updateMemoryTypeBits(&memReqs.memoryTypeBits,
|
||||
@@ -5337,8 +5382,11 @@ public:
|
||||
|
||||
// Delete `protocolVersion` check goldfish drivers are gone.
|
||||
#ifdef VK_USE_PLATFORM_ANDROID_KHR
|
||||
if (mCaps.gfxstreamCapset.colorBufferMemoryIndex == 0xFFFFFFFF) {
|
||||
mCaps.gfxstreamCapset.colorBufferMemoryIndex =
|
||||
getColorBufferMemoryIndex(context, device);
|
||||
}
|
||||
if (extBufCiPtr &&
|
||||
mCaps.gfxstreamCapset.protocolVersion &&
|
||||
(extBufCiPtr->handleTypes &
|
||||
VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID)) {
|
||||
updateMemoryTypeBits(&memReqs.memoryTypeBits,
|
||||
|
||||
Reference in New Issue
Block a user