Commit 62edcce8 by Geoff Lang Committed by Commit Bot

Vulkan: Initialize the max pbuffer size members of Config.

Pass the VkPhysicalDeviceProperties to GenerateDefaultConfig to initialize the pbuffer size limitations in a platform independent way. BUG=angleproject:2622 Change-Id: Id99bc505a1965cc037c5dcd65af031c1c655d424 Reviewed-on: https://chromium-review.googlesource.com/1126406 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org>
parent bf6dc379
...@@ -9,11 +9,14 @@ ...@@ -9,11 +9,14 @@
#include "libANGLE/renderer/vulkan/vk_caps_utils.h" #include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include <type_traits>
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h" #include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "libANGLE/renderer/vulkan/FeaturesVk.h" #include "libANGLE/renderer/vulkan/FeaturesVk.h"
#include "libANGLE/renderer/vulkan/RendererVk.h"
#include "vk_format_utils.h" #include "vk_format_utils.h"
namespace namespace
...@@ -155,7 +158,38 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -155,7 +158,38 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
namespace egl_vk namespace egl_vk
{ {
egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat,
namespace
{
EGLint ComputeMaximumPBufferPixels(const VkPhysicalDeviceProperties &physicalDeviceProperties)
{
// EGLints are signed 32-bit integers, it's fairly easy to overflow them, especially since
// Vulkan's minimum guaranteed VkImageFormatProperties::maxResourceSize is 2^31 bytes.
constexpr uint64_t kMaxValueForEGLint =
static_cast<uint64_t>(std::numeric_limits<EGLint>::max());
// TODO(geofflang): Compute the maximum size of a pbuffer by using the maxResourceSize result
// from vkGetPhysicalDeviceImageFormatProperties for both the color and depth stencil format and
// the exact image creation parameters that would be used to create the pbuffer. Because it is
// always safe to return out-of-memory errors on pbuffer allocation, it's fine to simply return
// the number of pixels in a max width by max height pbuffer for now. http://anglebug.com/2622
// Storing the result of squaring a 32-bit unsigned int in a 64-bit unsigned int is safe.
static_assert(std::is_same<decltype(physicalDeviceProperties.limits.maxImageDimension2D),
uint32_t>::value,
"physicalDeviceProperties.limits.maxImageDimension2D expected to be a uint32_t.");
const uint64_t maxDimensionsSquared =
static_cast<uint64_t>(physicalDeviceProperties.limits.maxImageDimension2D) *
static_cast<uint64_t>(physicalDeviceProperties.limits.maxImageDimension2D);
return static_cast<EGLint>(std::min(maxDimensionsSquared, kMaxValueForEGLint));
}
// Generates a basic config for a combination of color format, depth stencil format and sample
// count.
egl::Config GenerateDefaultConfig(const VkPhysicalDeviceProperties &physicalDeviceProperties,
const gl::InternalFormat &colorFormat,
const gl::InternalFormat &depthStencilFormat, const gl::InternalFormat &depthStencilFormat,
EGLint sampleCount) EGLint sampleCount)
{ {
...@@ -178,9 +212,9 @@ egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat, ...@@ -178,9 +212,9 @@ egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat,
config.stencilSize = depthStencilFormat.stencilBits; config.stencilSize = depthStencilFormat.stencilBits;
config.level = 0; config.level = 0;
config.matchNativePixmap = EGL_NONE; config.matchNativePixmap = EGL_NONE;
config.maxPBufferWidth = 0; config.maxPBufferWidth = physicalDeviceProperties.limits.maxImageDimension2D;
config.maxPBufferHeight = 0; config.maxPBufferHeight = physicalDeviceProperties.limits.maxImageDimension2D;
config.maxPBufferPixels = 0; config.maxPBufferPixels = ComputeMaximumPBufferPixels(physicalDeviceProperties);
config.maxSwapInterval = 1; config.maxSwapInterval = 1;
config.minSwapInterval = 1; config.minSwapInterval = 1;
config.nativeRenderable = EGL_TRUE; config.nativeRenderable = EGL_TRUE;
...@@ -201,6 +235,8 @@ egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat, ...@@ -201,6 +235,8 @@ egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat,
return config; return config;
} }
} // anonymous namespace
egl::ConfigSet GenerateConfigs(const GLenum *colorFormats, egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
size_t colorFormatsCount, size_t colorFormatsCount,
const GLenum *depthStencilFormats, const GLenum *depthStencilFormats,
...@@ -214,6 +250,10 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats, ...@@ -214,6 +250,10 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
egl::ConfigSet configSet; egl::ConfigSet configSet;
const RendererVk *renderer = display->getRenderer();
const VkPhysicalDeviceProperties &physicalDeviceProperties =
renderer->getPhysicalDeviceProperties();
for (size_t colorFormatIdx = 0; colorFormatIdx < colorFormatsCount; colorFormatIdx++) for (size_t colorFormatIdx = 0; colorFormatIdx < colorFormatsCount; colorFormatIdx++)
{ {
const gl::InternalFormat &colorFormatInfo = const gl::InternalFormat &colorFormatInfo =
...@@ -231,8 +271,9 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats, ...@@ -231,8 +271,9 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
for (size_t sampleCountIndex = 0; sampleCountIndex < sampleCountsCount; for (size_t sampleCountIndex = 0; sampleCountIndex < sampleCountsCount;
sampleCountIndex++) sampleCountIndex++)
{ {
egl::Config config = GenerateDefaultConfig(colorFormatInfo, depthStencilFormatInfo, egl::Config config =
sampleCounts[sampleCountIndex]); GenerateDefaultConfig(physicalDeviceProperties, colorFormatInfo,
depthStencilFormatInfo, sampleCounts[sampleCountIndex]);
if (display->checkConfigSupport(&config)) if (display->checkConfigSupport(&config))
{ {
configSet.add(config); configSet.add(config);
......
...@@ -42,12 +42,6 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -42,12 +42,6 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
namespace egl_vk namespace egl_vk
{ {
// Generates a basic config for a combination of color format, depth stencil format and sample
// count.
egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat,
const gl::InternalFormat &depthStencilFormat,
EGLint sampleCount);
// Permutes over all combinations of color format, depth stencil format and sample count and // Permutes over all combinations of color format, depth stencil format and sample count and
// generates a basic config which is passed to DisplayVk::checkConfigSupport. // generates a basic config which is passed to DisplayVk::checkConfigSupport.
egl::ConfigSet GenerateConfigs(const GLenum *colorFormats, egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
......
...@@ -163,8 +163,6 @@ ...@@ -163,8 +163,6 @@
2546 WIN : dEQP-EGL.functional.thread_cleanup.* = SKIP 2546 WIN : dEQP-EGL.functional.thread_cleanup.* = SKIP
// Windows Vulkan failures // Windows Vulkan failures
2635 WIN VULKAN : dEQP-EGL.functional.create_surface.pbuffer.rgba8888_depth_stencil = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.create_surface.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.multicontext.non_shared_clear = FAIL 2635 WIN VULKAN : dEQP-EGL.functional.multicontext.non_shared_clear = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.multicontext.non_shared_make_current = FAIL 2635 WIN VULKAN : dEQP-EGL.functional.multicontext.non_shared_make_current = FAIL
2635 WIN VULKAN : dEQP-EGL.functional.multicontext.shared_clear = FAIL 2635 WIN VULKAN : dEQP-EGL.functional.multicontext.shared_clear = FAIL
...@@ -218,8 +216,6 @@ ...@@ -218,8 +216,6 @@
2546 LINUX : dEQP-EGL.functional.query_surface.simple.pbuffer.rgba8888_no_depth_no_stencil = FAIL 2546 LINUX : dEQP-EGL.functional.query_surface.simple.pbuffer.rgba8888_no_depth_no_stencil = FAIL
// Linux Vulkan failures // Linux Vulkan failures
2635 LINUX VULKAN : dEQP-EGL.functional.create_surface.pbuffer.rgba8888_depth_stencil = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.create_surface.pbuffer.rgba8888_no_depth_no_stencil = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.negative_api.wait_native = FAIL 2635 LINUX VULKAN : dEQP-EGL.functional.negative_api.wait_native = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.query_context.get_current_context.rgba8888_pbuffer = FAIL 2635 LINUX VULKAN : dEQP-EGL.functional.query_context.get_current_context.rgba8888_pbuffer = FAIL
2635 LINUX VULKAN : dEQP-EGL.functional.query_context.get_current_display.rgba8888_pbuffer = FAIL 2635 LINUX VULKAN : dEQP-EGL.functional.query_context.get_current_display.rgba8888_pbuffer = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment