Vulkan: Begin implementing caps mappings
Bug: angleproject:1577
Change-Id: Ibed36dee9120e9182362bc9858cf513f798079cf
Reviewed-on: https://chromium-review.googlesource.com/887225
Commit-Queue: Luc Ferron <lucferron@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp
index ebd6d92..71f2bef 100644
--- a/src/libANGLE/renderer/vulkan/RendererVk.cpp
+++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp
@@ -24,6 +24,7 @@
#include "libANGLE/renderer/vulkan/ProgramVk.h"
#include "libANGLE/renderer/vulkan/TextureVk.h"
#include "libANGLE/renderer/vulkan/VertexArrayVk.h"
+#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/vk_format_utils.h"
#include "platform/Platform.h"
@@ -54,14 +55,14 @@
return VK_SUCCESS;
}
-VKAPI_ATTR VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags,
- VkDebugReportObjectTypeEXT objectType,
- uint64_t object,
- size_t location,
- int32_t messageCode,
- const char *layerPrefix,
- const char *message,
- void *userData)
+VkBool32 VKAPI_CALL DebugReportCallback(VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT objectType,
+ uint64_t object,
+ size_t location,
+ int32_t messageCode,
+ const char *layerPrefix,
+ const char *message,
+ void *userData)
{
if ((flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) != 0)
{
@@ -546,35 +547,12 @@
{
if (!mCapsInitialized)
{
- generateCaps(&mNativeCaps, &mNativeTextureCaps, &mNativeExtensions, &mNativeLimitations);
+ vk::GenerateCaps(mPhysicalDeviceProperties, &mNativeCaps, &mNativeTextureCaps,
+ &mNativeExtensions, &mNativeLimitations);
mCapsInitialized = true;
}
}
-void RendererVk::generateCaps(gl::Caps *outCaps,
- gl::TextureCapsMap * /*outTextureCaps*/,
- gl::Extensions *outExtensions,
- gl::Limitations * /* outLimitations */) const
-{
- // TODO(jmadill): Caps.
- outCaps->maxDrawBuffers = 1;
- outCaps->maxVertexAttributes = gl::MAX_VERTEX_ATTRIBS;
- outCaps->maxVertexAttribBindings = gl::MAX_VERTEX_ATTRIB_BINDINGS;
- outCaps->maxVaryingVectors = 16;
- outCaps->maxTextureImageUnits = 1;
- outCaps->maxCombinedTextureImageUnits = 1;
- outCaps->max2DTextureSize = 1024;
- outCaps->maxElementIndex = std::numeric_limits<GLuint>::max() - 1;
- outCaps->maxFragmentUniformVectors = 8;
- outCaps->maxVertexUniformVectors = 8;
- outCaps->maxColorAttachments = 1;
-
- // Enable this for simple buffer readback testing, but some functionality is missing.
- // TODO(jmadill): Support full mapBufferRange extension.
- outExtensions->mapBuffer = true;
- outExtensions->mapBufferRange = true;
-}
-
const gl::Caps &RendererVk::getNativeCaps() const
{
ensureCapsInitialized();
diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
new file mode 100644
index 0000000..bf49941
--- /dev/null
+++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.cpp
@@ -0,0 +1,73 @@
+//
+// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// vk_utils:
+// Helper functions for the Vulkan Caps.
+//
+
+#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
+#include "libANGLE/Caps.h"
+
+namespace rx
+{
+
+namespace vk
+{
+
+void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
+ gl::Caps *outCaps,
+ gl::TextureCapsMap * /*outTextureCaps*/,
+ gl::Extensions *outExtensions,
+ gl::Limitations * /* outLimitations */)
+{
+ // TODO(jmadill): Caps.
+ outCaps->maxVertexAttributes = gl::MAX_VERTEX_ATTRIBS;
+ outCaps->maxVertexAttribBindings = gl::MAX_VERTEX_ATTRIB_BINDINGS;
+ outCaps->maxVaryingVectors = 16;
+ outCaps->maxTextureImageUnits = 1;
+ outCaps->maxCombinedTextureImageUnits = 1;
+ outCaps->maxFragmentUniformVectors = 8;
+ outCaps->maxVertexUniformVectors = 8;
+
+ // Enable this for simple buffer readback testing, but some functionality is missing.
+ // TODO(jmadill): Support full mapBufferRange extension.
+ outExtensions->mapBuffer = true;
+ outExtensions->mapBufferRange = true;
+
+ // 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 = physicalDeviceProperties.limits.pointSizeRange[0];
+ outCaps->maxAliasedPointSize = physicalDeviceProperties.limits.pointSizeRange[1];
+ outCaps->minAliasedLineWidth = physicalDeviceProperties.limits.lineWidthRange[0];
+ outCaps->maxAliasedLineWidth = physicalDeviceProperties.limits.lineWidthRange[1];
+ 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;
+
+ // 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. Alsom this is ES 3.0 so
+ // we'll defer the implementation until we tackle the next version.
+ // outCaps->maxServerWaitTimeout
+}
+} // namespace vk
+} // namespace rx
\ No newline at end of file
diff --git a/src/libANGLE/renderer/vulkan/vk_caps_utils.h b/src/libANGLE/renderer/vulkan/vk_caps_utils.h
new file mode 100644
index 0000000..ca7a455
--- /dev/null
+++ b/src/libANGLE/renderer/vulkan/vk_caps_utils.h
@@ -0,0 +1,37 @@
+//
+// Copyright 2018 The ANGLE Project Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// vk_utils:
+// Helper functions for the Vulkan Caps.
+//
+
+#ifndef LIBANGLE_RENDERER_VULKAN_VK_CAPS_UTILS_H_
+#define LIBANGLE_RENDERER_VULKAN_VK_CAPS_UTILS_H_
+
+#include <vulkan/vulkan.h>
+
+namespace gl
+{
+struct Limitations;
+struct Extensions;
+class TextureCapsMap;
+struct Caps;
+}
+
+namespace rx
+{
+
+namespace vk
+{
+
+void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
+ gl::Caps *outCaps,
+ gl::TextureCapsMap * /*outTextureCaps*/,
+ gl::Extensions *outExtensions,
+ gl::Limitations * /* outLimitations */);
+} // namespace vk
+} // namespace rx
+
+#endif
\ No newline at end of file
diff --git a/src/libGLESv2.gypi b/src/libGLESv2.gypi
index 81dc3fc..8c6d197 100644
--- a/src/libGLESv2.gypi
+++ b/src/libGLESv2.gypi
@@ -757,6 +757,8 @@
'libANGLE/renderer/vulkan/VertexArrayVk.h',
'libANGLE/renderer/vulkan/vk_cache_utils.cpp',
'libANGLE/renderer/vulkan/vk_cache_utils.h',
+ 'libANGLE/renderer/vulkan/vk_caps_utils.cpp',
+ 'libANGLE/renderer/vulkan/vk_caps_utils.h',
'libANGLE/renderer/vulkan/vk_format_table_autogen.cpp',
'libANGLE/renderer/vulkan/vk_format_utils.h',
'libANGLE/renderer/vulkan/vk_format_utils.cpp',