Vulkan: make GenerateCaps a member of RendererVk.

Instead of passing lots of RendererVk member variables into
GenerateCaps(), do the work in a member function.

BUG=angleproject:2672

Change-Id: Icf16f3388174ddb676272ec0fa76a288ce2d1e4e
Reviewed-on: https://chromium-review.googlesource.com/c/1463959
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index 5c0c847..79a241a 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -1157,18 +1157,6 @@
     return angle::Result::Continue;
 }
 
-void RendererVk::ensureCapsInitialized() const
-{
-    if (!mCapsInitialized)
-    {
-        ASSERT(mCurrentQueueFamilyIndex < mQueueFamilyProperties.size());
-        vk::GenerateCaps(mPhysicalDeviceProperties, mPhysicalDeviceFeatures,
-                         mQueueFamilyProperties[mCurrentQueueFamilyIndex], mNativeTextureCaps,
-                         &mNativeCaps, &mNativeExtensions, &mNativeLimitations);
-        mCapsInitialized = true;
-    }
-}
-
 void RendererVk::getSubmitWaitSemaphores(
     vk::Context *context,
     angle::FixedVector<VkSemaphore, kMaxWaitSemaphores> *waitSemaphores,
diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
index ef3917c..1304420 100644
--- a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
+++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
@@ -25,126 +25,131 @@
 
 namespace rx
 {
-namespace vk
-{
 
-void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
-                  const VkPhysicalDeviceFeatures &physicalDeviceFeatures,
-                  const VkQueueFamilyProperties &queueFamilyProperties,
-                  const gl::TextureCapsMap &textureCaps,
-                  gl::Caps *outCaps,
-                  gl::Extensions *outExtensions,
-                  gl::Limitations * /* outLimitations */)
+void RendererVk::ensureCapsInitialized() const
 {
-    outExtensions->setTextureExtensionSupport(textureCaps);
+    if (mCapsInitialized)
+        return;
+    mCapsInitialized = true;
+
+    ASSERT(mCurrentQueueFamilyIndex < mQueueFamilyProperties.size());
+    const VkQueueFamilyProperties &queueFamilyProperties =
+        mQueueFamilyProperties[mCurrentQueueFamilyIndex];
+
+    mNativeExtensions.setTextureExtensionSupport(mNativeTextureCaps);
 
     // Enable this for simple buffer readback testing, but some functionality is missing.
     // TODO(jmadill): Support full mapBufferRange extension.
-    outExtensions->mapBuffer              = true;
-    outExtensions->mapBufferRange         = true;
-    outExtensions->textureStorage         = true;
-    outExtensions->framebufferBlit        = true;
-    outExtensions->copyTexture            = true;
-    outExtensions->debugMarker            = true;
-    outExtensions->robustness             = true;
-    outExtensions->textureBorderClamp     = false;  // not implemented yet
-    outExtensions->translatedShaderSource = true;
+    mNativeExtensions.mapBuffer              = true;
+    mNativeExtensions.mapBufferRange         = true;
+    mNativeExtensions.textureStorage         = true;
+    mNativeExtensions.framebufferBlit        = true;
+    mNativeExtensions.copyTexture            = true;
+    mNativeExtensions.debugMarker            = true;
+    mNativeExtensions.robustness             = true;
+    mNativeExtensions.textureBorderClamp     = false;  // not implemented yet
+    mNativeExtensions.translatedShaderSource = true;
 
-    outExtensions->eglImage = true;
+    mNativeExtensions.eglImage = true;
     // TODO(geofflang): Support GL_OES_EGL_image_external. http://anglebug.com/2668
-    outExtensions->eglImageExternal = false;
+    mNativeExtensions.eglImageExternal = false;
     // TODO(geofflang): Support GL_OES_EGL_image_external_essl3. http://anglebug.com/2668
-    outExtensions->eglImageExternalEssl3 = false;
+    mNativeExtensions.eglImageExternalEssl3 = false;
 
     // Only expose robust buffer access if the physical device supports it.
-    outExtensions->robustBufferAccessBehavior = physicalDeviceFeatures.robustBufferAccess;
+    mNativeExtensions.robustBufferAccessBehavior = mPhysicalDeviceFeatures.robustBufferAccess;
 
-    outExtensions->eglSync = true;
+    mNativeExtensions.eglSync = true;
 
     // We use secondary command buffers almost everywhere and they require a feature to be
     // able to execute in the presence of queries.  As a result, we won't support queries
     // unless that feature is available.
-    outExtensions->occlusionQueryBoolean = physicalDeviceFeatures.inheritedQueries;
+    mNativeExtensions.occlusionQueryBoolean = mPhysicalDeviceFeatures.inheritedQueries;
 
     // From the Vulkan specs:
     // > The number of valid bits in a timestamp value is determined by the
     // > VkQueueFamilyProperties::timestampValidBits property of the queue on which the timestamp is
     // > written. Timestamps are supported on any queue which reports a non-zero value for
     // > timestampValidBits via vkGetPhysicalDeviceQueueFamilyProperties.
-    outExtensions->disjointTimerQuery          = queueFamilyProperties.timestampValidBits > 0;
-    outExtensions->queryCounterBitsTimeElapsed = queueFamilyProperties.timestampValidBits;
-    outExtensions->queryCounterBitsTimestamp   = queueFamilyProperties.timestampValidBits;
+    mNativeExtensions.disjointTimerQuery          = queueFamilyProperties.timestampValidBits > 0;
+    mNativeExtensions.queryCounterBitsTimeElapsed = queueFamilyProperties.timestampValidBits;
+    mNativeExtensions.queryCounterBitsTimestamp   = queueFamilyProperties.timestampValidBits;
 
-    outExtensions->textureFilterAnisotropic =
-        physicalDeviceFeatures.samplerAnisotropy &&
-        physicalDeviceProperties.limits.maxSamplerAnisotropy > 1.0f;
-    outExtensions->maxTextureAnisotropy = outExtensions->textureFilterAnisotropic
-                                              ? physicalDeviceProperties.limits.maxSamplerAnisotropy
-                                              : 0.0f;
+    mNativeExtensions.textureFilterAnisotropic =
+        mPhysicalDeviceFeatures.samplerAnisotropy &&
+        mPhysicalDeviceProperties.limits.maxSamplerAnisotropy > 1.0f;
+    mNativeExtensions.maxTextureAnisotropy =
+        mNativeExtensions.textureFilterAnisotropic
+            ? mPhysicalDeviceProperties.limits.maxSamplerAnisotropy
+            : 0.0f;
 
     // TODO(lucferron): Eventually remove everything above this line in this function as the caps
     // get implemented.
     // https://vulkan.lunarg.com/doc/view/1.0.30.0/linux/vkspec.chunked/ch31s02.html
-    outCaps->maxElementIndex       = std::numeric_limits<GLuint>::max() - 1;
-    outCaps->max3DTextureSize      = physicalDeviceProperties.limits.maxImageDimension3D;
-    outCaps->max2DTextureSize      = physicalDeviceProperties.limits.maxImageDimension2D;
-    outCaps->maxArrayTextureLayers = physicalDeviceProperties.limits.maxImageArrayLayers;
-    outCaps->maxLODBias            = physicalDeviceProperties.limits.maxSamplerLodBias;
-    outCaps->maxCubeMapTextureSize = physicalDeviceProperties.limits.maxImageDimensionCube;
-    outCaps->maxRenderbufferSize   = outCaps->max2DTextureSize;
-    outCaps->minAliasedPointSize =
-        std::max(1.0f, physicalDeviceProperties.limits.pointSizeRange[0]);
-    outCaps->maxAliasedPointSize = physicalDeviceProperties.limits.pointSizeRange[1];
+    mNativeCaps.maxElementIndex       = std::numeric_limits<GLuint>::max() - 1;
+    mNativeCaps.max3DTextureSize      = mPhysicalDeviceProperties.limits.maxImageDimension3D;
+    mNativeCaps.max2DTextureSize      = mPhysicalDeviceProperties.limits.maxImageDimension2D;
+    mNativeCaps.maxArrayTextureLayers = mPhysicalDeviceProperties.limits.maxImageArrayLayers;
+    mNativeCaps.maxLODBias            = mPhysicalDeviceProperties.limits.maxSamplerLodBias;
+    mNativeCaps.maxCubeMapTextureSize = mPhysicalDeviceProperties.limits.maxImageDimensionCube;
+    mNativeCaps.maxRenderbufferSize   = mNativeCaps.max2DTextureSize;
+    mNativeCaps.minAliasedPointSize =
+        std::max(1.0f, mPhysicalDeviceProperties.limits.pointSizeRange[0]);
+    mNativeCaps.maxAliasedPointSize = mPhysicalDeviceProperties.limits.pointSizeRange[1];
 
-    outCaps->minAliasedLineWidth = 1.0f;
-    outCaps->maxAliasedLineWidth = 1.0f;
+    mNativeCaps.minAliasedLineWidth = 1.0f;
+    mNativeCaps.maxAliasedLineWidth = 1.0f;
 
-    outCaps->maxDrawBuffers =
-        std::min<uint32_t>(physicalDeviceProperties.limits.maxColorAttachments,
-                           physicalDeviceProperties.limits.maxFragmentOutputAttachments);
-    outCaps->maxFramebufferWidth    = physicalDeviceProperties.limits.maxFramebufferWidth;
-    outCaps->maxFramebufferHeight   = physicalDeviceProperties.limits.maxFramebufferHeight;
-    outCaps->maxColorAttachments    = physicalDeviceProperties.limits.maxColorAttachments;
-    outCaps->maxViewportWidth       = physicalDeviceProperties.limits.maxViewportDimensions[0];
-    outCaps->maxViewportHeight      = physicalDeviceProperties.limits.maxViewportDimensions[1];
-    outCaps->maxSampleMaskWords     = physicalDeviceProperties.limits.maxSampleMaskWords;
-    outCaps->maxColorTextureSamples = physicalDeviceProperties.limits.sampledImageColorSampleCounts;
-    outCaps->maxDepthTextureSamples = physicalDeviceProperties.limits.sampledImageDepthSampleCounts;
-    outCaps->maxIntegerSamples = physicalDeviceProperties.limits.sampledImageIntegerSampleCounts;
+    mNativeCaps.maxDrawBuffers =
+        std::min<uint32_t>(mPhysicalDeviceProperties.limits.maxColorAttachments,
+                           mPhysicalDeviceProperties.limits.maxFragmentOutputAttachments);
+    mNativeCaps.maxFramebufferWidth  = mPhysicalDeviceProperties.limits.maxFramebufferWidth;
+    mNativeCaps.maxFramebufferHeight = mPhysicalDeviceProperties.limits.maxFramebufferHeight;
+    mNativeCaps.maxColorAttachments  = mPhysicalDeviceProperties.limits.maxColorAttachments;
+    mNativeCaps.maxViewportWidth     = mPhysicalDeviceProperties.limits.maxViewportDimensions[0];
+    mNativeCaps.maxViewportHeight    = mPhysicalDeviceProperties.limits.maxViewportDimensions[1];
+    mNativeCaps.maxSampleMaskWords   = mPhysicalDeviceProperties.limits.maxSampleMaskWords;
+    mNativeCaps.maxColorTextureSamples =
+        mPhysicalDeviceProperties.limits.sampledImageColorSampleCounts;
+    mNativeCaps.maxDepthTextureSamples =
+        mPhysicalDeviceProperties.limits.sampledImageDepthSampleCounts;
+    mNativeCaps.maxIntegerSamples =
+        mPhysicalDeviceProperties.limits.sampledImageIntegerSampleCounts;
 
-    outCaps->maxVertexAttributes     = physicalDeviceProperties.limits.maxVertexInputAttributes;
-    outCaps->maxVertexAttribBindings = physicalDeviceProperties.limits.maxVertexInputBindings;
-    outCaps->maxVertexAttribRelativeOffset =
-        physicalDeviceProperties.limits.maxVertexInputAttributeOffset;
-    outCaps->maxVertexAttribStride = physicalDeviceProperties.limits.maxVertexInputBindingStride;
+    mNativeCaps.maxVertexAttributes     = mPhysicalDeviceProperties.limits.maxVertexInputAttributes;
+    mNativeCaps.maxVertexAttribBindings = mPhysicalDeviceProperties.limits.maxVertexInputBindings;
+    mNativeCaps.maxVertexAttribRelativeOffset =
+        mPhysicalDeviceProperties.limits.maxVertexInputAttributeOffset;
+    mNativeCaps.maxVertexAttribStride =
+        mPhysicalDeviceProperties.limits.maxVertexInputBindingStride;
 
-    outCaps->maxElementsIndices  = std::numeric_limits<GLuint>::max();
-    outCaps->maxElementsVertices = std::numeric_limits<GLuint>::max();
+    mNativeCaps.maxElementsIndices  = std::numeric_limits<GLuint>::max();
+    mNativeCaps.maxElementsVertices = std::numeric_limits<GLuint>::max();
 
     // Looks like all floats are IEEE according to the docs here:
     // https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/html/vkspec.html#spirvenv-precision-operation
-    outCaps->vertexHighpFloat.setIEEEFloat();
-    outCaps->vertexMediumpFloat.setIEEEFloat();
-    outCaps->vertexLowpFloat.setIEEEFloat();
-    outCaps->fragmentHighpFloat.setIEEEFloat();
-    outCaps->fragmentMediumpFloat.setIEEEFloat();
-    outCaps->fragmentLowpFloat.setIEEEFloat();
+    mNativeCaps.vertexHighpFloat.setIEEEFloat();
+    mNativeCaps.vertexMediumpFloat.setIEEEFloat();
+    mNativeCaps.vertexLowpFloat.setIEEEFloat();
+    mNativeCaps.fragmentHighpFloat.setIEEEFloat();
+    mNativeCaps.fragmentMediumpFloat.setIEEEFloat();
+    mNativeCaps.fragmentLowpFloat.setIEEEFloat();
 
     // Can't find documentation on the int precision in Vulkan.
-    outCaps->vertexHighpInt.setTwosComplementInt(32);
-    outCaps->vertexMediumpInt.setTwosComplementInt(32);
-    outCaps->vertexLowpInt.setTwosComplementInt(32);
-    outCaps->fragmentHighpInt.setTwosComplementInt(32);
-    outCaps->fragmentMediumpInt.setTwosComplementInt(32);
-    outCaps->fragmentLowpInt.setTwosComplementInt(32);
+    mNativeCaps.vertexHighpInt.setTwosComplementInt(32);
+    mNativeCaps.vertexMediumpInt.setTwosComplementInt(32);
+    mNativeCaps.vertexLowpInt.setTwosComplementInt(32);
+    mNativeCaps.fragmentHighpInt.setTwosComplementInt(32);
+    mNativeCaps.fragmentMediumpInt.setTwosComplementInt(32);
+    mNativeCaps.fragmentLowpInt.setTwosComplementInt(32);
 
     // TODO(lucferron): This is something we'll need to implement custom in the back-end.
     // Vulkan doesn't do any waiting for you, our back-end code is going to manage sync objects,
     // and we'll have to check that we've exceeded the max wait timeout. Also, this is ES 3.0 so
     // we'll defer the implementation until we tackle the next version.
-    // outCaps->maxServerWaitTimeout
+    // mNativeCaps.maxServerWaitTimeout
 
-    GLuint maxUniformVectors = physicalDeviceProperties.limits.maxUniformBufferRange /
+    GLuint maxUniformVectors = mPhysicalDeviceProperties.limits.maxUniformBufferRange /
                                (sizeof(GLfloat) * kComponentsPerVector);
 
     // Clamp the maxUniformVectors to 1024u, on AMD the maxUniformBufferRange is way too high.
@@ -154,24 +159,24 @@
 
     // Uniforms are implemented using a uniform buffer, so the max number of uniforms we can
     // support is the max buffer range divided by the size of a single uniform (4X float).
-    outCaps->maxVertexUniformVectors                              = maxUniformVectors;
-    outCaps->maxShaderUniformComponents[gl::ShaderType::Vertex]   = maxUniformComponents;
-    outCaps->maxFragmentUniformVectors                            = maxUniformVectors;
-    outCaps->maxShaderUniformComponents[gl::ShaderType::Fragment] = maxUniformComponents;
+    mNativeCaps.maxVertexUniformVectors                              = maxUniformVectors;
+    mNativeCaps.maxShaderUniformComponents[gl::ShaderType::Vertex]   = maxUniformComponents;
+    mNativeCaps.maxFragmentUniformVectors                            = maxUniformVectors;
+    mNativeCaps.maxShaderUniformComponents[gl::ShaderType::Fragment] = maxUniformComponents;
 
     // TODO(jmadill): this is an ES 3.0 property and we can skip implementing it for now.
     // This is maxDescriptorSetUniformBuffers minus the number of uniform buffers we
     // reserve for internal variables. We reserve one per shader stage for default uniforms
     // and likely one per shader stage for ANGLE internal variables.
-    // outCaps->maxShaderUniformBlocks[gl::ShaderType::Vertex] = ...
+    // mNativeCaps.maxShaderUniformBlocks[gl::ShaderType::Vertex] = ...
 
     // we use the same bindings on each stage, so the limitation is the same combined or not.
-    outCaps->maxCombinedTextureImageUnits =
-        physicalDeviceProperties.limits.maxPerStageDescriptorSamplers;
-    outCaps->maxShaderTextureImageUnits[gl::ShaderType::Fragment] =
-        physicalDeviceProperties.limits.maxPerStageDescriptorSamplers;
-    outCaps->maxShaderTextureImageUnits[gl::ShaderType::Vertex] =
-        physicalDeviceProperties.limits.maxPerStageDescriptorSamplers;
+    mNativeCaps.maxCombinedTextureImageUnits =
+        mPhysicalDeviceProperties.limits.maxPerStageDescriptorSamplers;
+    mNativeCaps.maxShaderTextureImageUnits[gl::ShaderType::Fragment] =
+        mPhysicalDeviceProperties.limits.maxPerStageDescriptorSamplers;
+    mNativeCaps.maxShaderTextureImageUnits[gl::ShaderType::Vertex] =
+        mPhysicalDeviceProperties.limits.maxPerStageDescriptorSamplers;
 
     // The max vertex output components should not include gl_Position.
     // The gles2.0 section 2.10 states that "gl_Position is not a varying variable and does
@@ -181,11 +186,10 @@
     // and can often crash. Reserving an additional varying just for them bringing the total to 2.
     // http://anglebug.com/2483
     constexpr GLint kReservedVaryingCount = 2;
-    outCaps->maxVaryingVectors =
-        (physicalDeviceProperties.limits.maxVertexOutputComponents / 4) - kReservedVaryingCount;
-    outCaps->maxVertexOutputComponents = outCaps->maxVaryingVectors * 4;
+    mNativeCaps.maxVaryingVectors =
+        (mPhysicalDeviceProperties.limits.maxVertexOutputComponents / 4) - kReservedVaryingCount;
+    mNativeCaps.maxVertexOutputComponents = mNativeCaps.maxVaryingVectors * 4;
 }
-}  // namespace vk
 
 namespace egl_vk
 {