Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebe862d8 authored by Trevor Black's avatar Trevor Black Committed by Gerrit Code Review
Browse files

Merge "Vulkan loader changes to address previous comments in image_compression_control"

parents f533eb15 929e9cd8
Loading
Loading
Loading
Loading
+37 −7
Original line number Diff line number Diff line
@@ -1027,8 +1027,11 @@ void QueryPresentationProperties(
    }
}

bool GetAndroidNativeBufferSpecVersion9Support(
    VkPhysicalDevice physicalDevice) {
VkResult GetAndroidNativeBufferSpecVersion9Support(
    VkPhysicalDevice physicalDevice,
    bool& support) {
    support = false;

    const InstanceData& data = GetData(physicalDevice);

    // Call to get propertyCount
@@ -1038,6 +1041,10 @@ bool GetAndroidNativeBufferSpecVersion9Support(
        physicalDevice, nullptr, &propertyCount, nullptr);
    ATRACE_END();

    if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
        return result;
    }

    // Call to enumerate properties
    std::vector<VkExtensionProperties> properties(propertyCount);
    ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties");
@@ -1045,6 +1052,10 @@ bool GetAndroidNativeBufferSpecVersion9Support(
        physicalDevice, nullptr, &propertyCount, properties.data());
    ATRACE_END();

    if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
        return result;
    }

    for (uint32_t i = 0; i < propertyCount; i++) {
        auto& prop = properties[i];

@@ -1053,11 +1064,12 @@ bool GetAndroidNativeBufferSpecVersion9Support(
            continue;

        if (prop.specVersion >= 9) {
            return true;
            support = true;
            return result;
        }
    }

    return false;
    return result;
}

VkResult EnumerateDeviceExtensionProperties(
@@ -1101,18 +1113,30 @@ VkResult EnumerateDeviceExtensionProperties(
    swapchainCompFeats.sType =
        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT;
    swapchainCompFeats.pNext = nullptr;
    swapchainCompFeats.imageCompressionControlSwapchain = false;
    VkPhysicalDeviceImageCompressionControlFeaturesEXT imageCompFeats = {};
    imageCompFeats.sType =
        VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT;
    imageCompFeats.pNext = &swapchainCompFeats;
    imageCompFeats.imageCompressionControl = false;

    VkPhysicalDeviceFeatures2 feats2 = {};
    feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
    feats2.pNext = &imageCompFeats;

    const auto& driver = GetData(physicalDevice).driver;
    if (driver.GetPhysicalDeviceFeatures2 ||
        driver.GetPhysicalDeviceFeatures2KHR) {
        GetPhysicalDeviceFeatures2(physicalDevice, &feats2);
    }

    bool anb9 = false;
    VkResult result =
        GetAndroidNativeBufferSpecVersion9Support(physicalDevice, anb9);

    bool anb9 = GetAndroidNativeBufferSpecVersion9Support(physicalDevice);
    if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
        return result;
    }

    if (anb9 && imageCompFeats.imageCompressionControl) {
        loader_extensions.push_back(
@@ -1142,7 +1166,7 @@ VkResult EnumerateDeviceExtensionProperties(
    }

    ATRACE_BEGIN("driver.EnumerateDeviceExtensionProperties");
    VkResult result = data.driver.EnumerateDeviceExtensionProperties(
    result = data.driver.EnumerateDeviceExtensionProperties(
        physicalDevice, pLayerName, pPropertyCount, pProperties);
    ATRACE_END();

@@ -1532,6 +1556,11 @@ void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
            } break;

            case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT: {
                VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT*
                    compressionFeat = reinterpret_cast<
                        VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT*>(
                        pFeats);
                compressionFeat->imageCompressionControlSwapchain = false;
                imageCompressionControlSwapchainInChain = true;
            } break;

@@ -1551,6 +1580,7 @@ void GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
        imageCompFeats.sType =
            VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT;
        imageCompFeats.pNext = nullptr;
        imageCompFeats.imageCompressionControl = false;

        VkPhysicalDeviceFeatures2 feats2 = {};
        feats2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
+35 −22
Original line number Diff line number Diff line
@@ -950,7 +950,8 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR(
        return GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice,
                                                  pSurfaceInfo->surface,
                                                  pSurfaceFormatCount, nullptr);
    } else {
    }

    // temp vector for forwarding; we'll marshal it into the pSurfaceFormats
    // after the call.
    std::vector<VkSurfaceFormatKHR> surface_formats(*pSurfaceFormatCount);
@@ -958,7 +959,10 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR(
        physicalDevice, pSurfaceInfo->surface, pSurfaceFormatCount,
        surface_formats.data());

        if (result == VK_SUCCESS || result == VK_INCOMPLETE) {
    if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
        return result;
    }

    const auto& driver = GetData(physicalDevice).driver;

    // marshal results individually due to stride difference.
@@ -967,10 +971,15 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR(
        pSurfaceFormats[i].surfaceFormat = surface_formats[i];

        // Query the compression properties for the surface format
                if (pSurfaceFormats[i].pNext) {
        VkSurfaceFormat2KHR* pSurfaceFormat = &pSurfaceFormats[i];
        while (pSurfaceFormat->pNext) {
            pSurfaceFormat =
                reinterpret_cast<VkSurfaceFormat2KHR*>(pSurfaceFormat->pNext);
            switch (pSurfaceFormat->sType) {
                case VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT: {
                    VkImageCompressionPropertiesEXT* surfaceCompressionProps =
                        reinterpret_cast<VkImageCompressionPropertiesEXT*>(
                            pSurfaceFormats[i].pNext);
                            pSurfaceFormat);

                    if (surfaceCompressionProps &&
                        driver.GetPhysicalDeviceImageFormatProperties2KHR) {
@@ -1012,13 +1021,17 @@ VkResult GetPhysicalDeviceSurfaceFormats2KHR(
                            return compressionRes;
                        }
                    }
                } break;

                default:
                    // Ignore all other extension structs
                    break;
            }
        }
    }

    return result;
}
}

VKAPI_ATTR
VkResult GetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice pdev,