Commit 092481ad by Shahbaz Youssefi Committed by Commit Bot

Vulkan: prepare for ES3

This makes ES3_VULKAN() pass the instantiability test, allowing it to be specified in end2end tests. Bug: angleproject:2950 Change-Id: Ife70a22fb8193f9eebe64bec491a24b47bc76939 Reviewed-on: https://chromium-review.googlesource.com/c/1325729Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent d1a55e39
...@@ -159,8 +159,7 @@ StreamProducerImpl *DisplayVk::createStreamProducerD3DTexture( ...@@ -159,8 +159,7 @@ StreamProducerImpl *DisplayVk::createStreamProducerD3DTexture(
gl::Version DisplayVk::getMaxSupportedESVersion() const gl::Version DisplayVk::getMaxSupportedESVersion() const
{ {
UNIMPLEMENTED(); return mRenderer->getMaxSupportedESVersion();
return gl::Version(0, 0);
} }
void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
......
...@@ -531,8 +531,8 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk, ...@@ -531,8 +531,8 @@ angle::Result RendererVk::initialize(DisplayVk *displayVk,
GlslangWrapper::Initialize(); GlslangWrapper::Initialize();
// Initialize the format table. // Initialize the format table.
mFormatTable.initialize(mPhysicalDevice, mFeatures, &mNativeTextureCaps, mFormatTable.initialize(mPhysicalDevice, mPhysicalDeviceProperties, mFeatures,
&mNativeCaps.compressedTextureFormats); &mNativeTextureCaps, &mNativeCaps.compressedTextureFormats);
return angle::Result::Continue(); return angle::Result::Continue();
} }
...@@ -733,6 +733,19 @@ std::string RendererVk::getRendererDescription() const ...@@ -733,6 +733,19 @@ std::string RendererVk::getRendererDescription() const
return strstr.str(); return strstr.str();
} }
gl::Version RendererVk::getMaxSupportedESVersion() const
{
// Declare GLES2 support if necessary features for GLES3 are missing
bool necessaryFeaturesForES3 = mPhysicalDeviceFeatures.inheritedQueries;
if (!necessaryFeaturesForES3)
{
return gl::Version(2, 0);
}
return gl::Version(3, 0);
}
void RendererVk::initFeatures() void RendererVk::initFeatures()
{ {
// Use OpenGL line rasterization rules by default. // Use OpenGL line rasterization rules by default.
......
...@@ -55,6 +55,8 @@ class RendererVk : angle::NonCopyable ...@@ -55,6 +55,8 @@ class RendererVk : angle::NonCopyable
std::string getVendorString() const; std::string getVendorString() const;
std::string getRendererDescription() const; std::string getRendererDescription() const;
gl::Version getMaxSupportedESVersion() const;
VkInstance getInstance() const { return mInstance; } VkInstance getInstance() const { return mInstance; }
VkPhysicalDevice getPhysicalDevice() const { return mPhysicalDevice; } VkPhysicalDevice getPhysicalDevice() const { return mPhysicalDevice; }
const VkPhysicalDeviceProperties &getPhysicalDeviceProperties() const const VkPhysicalDeviceProperties &getPhysicalDeviceProperties() const
......
...@@ -200,11 +200,18 @@ EGLint ComputeMaximumPBufferPixels(const VkPhysicalDeviceProperties &physicalDev ...@@ -200,11 +200,18 @@ EGLint ComputeMaximumPBufferPixels(const VkPhysicalDeviceProperties &physicalDev
// Generates a basic config for a combination of color format, depth stencil format and sample // Generates a basic config for a combination of color format, depth stencil format and sample
// count. // count.
egl::Config GenerateDefaultConfig(const VkPhysicalDeviceProperties &physicalDeviceProperties, egl::Config GenerateDefaultConfig(const RendererVk *renderer,
const gl::InternalFormat &colorFormat, const gl::InternalFormat &colorFormat,
const gl::InternalFormat &depthStencilFormat, const gl::InternalFormat &depthStencilFormat,
EGLint sampleCount) EGLint sampleCount)
{ {
const VkPhysicalDeviceProperties &physicalDeviceProperties =
renderer->getPhysicalDeviceProperties();
gl::Version maxSupportedESVersion = renderer->getMaxSupportedESVersion();
EGLint es2Support = (maxSupportedESVersion.major >= 2 ? EGL_OPENGL_ES2_BIT : 0);
EGLint es3Support = (maxSupportedESVersion.major >= 3 ? EGL_OPENGL_ES3_BIT : 0);
egl::Config config; egl::Config config;
config.renderTargetFormat = colorFormat.internalFormat; config.renderTargetFormat = colorFormat.internalFormat;
...@@ -232,7 +239,7 @@ egl::Config GenerateDefaultConfig(const VkPhysicalDeviceProperties &physicalDevi ...@@ -232,7 +239,7 @@ egl::Config GenerateDefaultConfig(const VkPhysicalDeviceProperties &physicalDevi
config.nativeRenderable = EGL_TRUE; config.nativeRenderable = EGL_TRUE;
config.nativeVisualID = 0; config.nativeVisualID = 0;
config.nativeVisualType = EGL_NONE; config.nativeVisualType = EGL_NONE;
config.renderableType = EGL_OPENGL_ES2_BIT; config.renderableType = es2Support | es3Support;
config.sampleBuffers = (sampleCount > 0) ? 1 : 0; config.sampleBuffers = (sampleCount > 0) ? 1 : 0;
config.samples = sampleCount; config.samples = sampleCount;
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
...@@ -264,10 +271,6 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats, ...@@ -264,10 +271,6 @@ 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 =
...@@ -286,7 +289,7 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats, ...@@ -286,7 +289,7 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
sampleCountIndex++) sampleCountIndex++)
{ {
egl::Config config = egl::Config config =
GenerateDefaultConfig(physicalDeviceProperties, colorFormatInfo, GenerateDefaultConfig(display->getRenderer(), colorFormatInfo,
depthStencilFormatInfo, sampleCounts[sampleCountIndex]); depthStencilFormatInfo, sampleCounts[sampleCountIndex]);
if (display->checkConfigSupport(&config)) if (display->checkConfigSupport(&config))
{ {
......
...@@ -29,7 +29,21 @@ bool HasFormatFeatureBits(const VkFormatFeatureFlags featureBits, ...@@ -29,7 +29,21 @@ bool HasFormatFeatureBits(const VkFormatFeatureFlags featureBits,
return IsMaskFlagSet(formatProperties.optimalTilingFeatures, featureBits); return IsMaskFlagSet(formatProperties.optimalTilingFeatures, featureBits);
} }
void FillTextureFormatCaps(const VkFormatProperties &formatProperties, void AddSampleCounts(VkSampleCountFlags sampleCounts, gl::SupportedSampleSet *outSet)
{
// The possible bits are VK_SAMPLE_COUNT_n_BIT = n, with n = 1 << b. At the time of this
// writing, b is in [0, 6], however, we test all 32 bits in case the enum is extended.
for (unsigned int i = 0; i < 32; ++i)
{
if ((sampleCounts & (1 << i)) != 0)
{
outSet->insert(1 << i);
}
}
}
void FillTextureFormatCaps(const VkPhysicalDeviceLimits &physicalDeviceLimits,
const VkFormatProperties &formatProperties,
gl::TextureCaps *outTextureCaps) gl::TextureCaps *outTextureCaps)
{ {
outTextureCaps->texturable = outTextureCaps->texturable =
...@@ -40,6 +54,22 @@ void FillTextureFormatCaps(const VkFormatProperties &formatProperties, ...@@ -40,6 +54,22 @@ void FillTextureFormatCaps(const VkFormatProperties &formatProperties,
HasFormatFeatureBits(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, formatProperties) || HasFormatFeatureBits(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, formatProperties) ||
HasFormatFeatureBits(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, formatProperties); HasFormatFeatureBits(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, formatProperties);
outTextureCaps->renderbuffer = outTextureCaps->textureAttachment; outTextureCaps->renderbuffer = outTextureCaps->textureAttachment;
if (outTextureCaps->renderbuffer)
{
if (HasFormatFeatureBits(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT, formatProperties))
{
AddSampleCounts(physicalDeviceLimits.framebufferColorSampleCounts,
&outTextureCaps->sampleCounts);
}
if (HasFormatFeatureBits(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT, formatProperties))
{
AddSampleCounts(physicalDeviceLimits.framebufferDepthSampleCounts,
&outTextureCaps->sampleCounts);
AddSampleCounts(physicalDeviceLimits.framebufferStencilSampleCounts,
&outTextureCaps->sampleCounts);
}
}
} }
bool HasFullTextureFormatSupport(VkPhysicalDevice physicalDevice, VkFormat vkFormat) bool HasFullTextureFormatSupport(VkPhysicalDevice physicalDevice, VkFormat vkFormat)
...@@ -191,6 +221,7 @@ FormatTable::~FormatTable() ...@@ -191,6 +221,7 @@ FormatTable::~FormatTable()
} }
void FormatTable::initialize(VkPhysicalDevice physicalDevice, void FormatTable::initialize(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceProperties &physicalDeviceProperties,
const angle::FeaturesVk &featuresVk, const angle::FeaturesVk &featuresVk,
gl::TextureCapsMap *outTextureCapsMap, gl::TextureCapsMap *outTextureCapsMap,
std::vector<GLenum> *outCompressedTextureFormats) std::vector<GLenum> *outCompressedTextureFormats)
...@@ -217,7 +248,7 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice, ...@@ -217,7 +248,7 @@ void FormatTable::initialize(VkPhysicalDevice physicalDevice,
VkFormatProperties formatProperties; VkFormatProperties formatProperties;
GetFormatProperties(physicalDevice, vkFormat, &formatProperties); GetFormatProperties(physicalDevice, vkFormat, &formatProperties);
gl::TextureCaps textureCaps; gl::TextureCaps textureCaps;
FillTextureFormatCaps(formatProperties, &textureCaps); FillTextureFormatCaps(physicalDeviceProperties.limits, formatProperties, &textureCaps);
outTextureCapsMap->set(formatID, textureCaps); outTextureCapsMap->set(formatID, textureCaps);
if (angleFormat.isBlock) if (angleFormat.isBlock)
......
...@@ -97,6 +97,7 @@ class FormatTable final : angle::NonCopyable ...@@ -97,6 +97,7 @@ class FormatTable final : angle::NonCopyable
// Also initializes the TextureCapsMap and the compressedTextureCaps in the Caps instance. // Also initializes the TextureCapsMap and the compressedTextureCaps in the Caps instance.
void initialize(VkPhysicalDevice physicalDevice, void initialize(VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceProperties &physicalDeviceProperties,
const angle::FeaturesVk &featuresVk, const angle::FeaturesVk &featuresVk,
gl::TextureCapsMap *outTextureCapsMap, gl::TextureCapsMap *outTextureCapsMap,
std::vector<GLenum> *outCompressedTextureFormats); std::vector<GLenum> *outCompressedTextureFormats);
......
...@@ -690,4 +690,14 @@ PlatformParameters ES2_VULKAN_NULL() ...@@ -690,4 +690,14 @@ PlatformParameters ES2_VULKAN_NULL()
return PlatformParameters(2, 0, egl_platform::VULKAN_NULL()); return PlatformParameters(2, 0, egl_platform::VULKAN_NULL());
} }
PlatformParameters ES3_VULKAN()
{
return PlatformParameters(3, 0, egl_platform::VULKAN());
}
PlatformParameters ES3_VULKAN_NULL()
{
return PlatformParameters(3, 0, egl_platform::VULKAN_NULL());
}
} // namespace angle } // namespace angle
...@@ -171,6 +171,8 @@ PlatformParameters ES1_VULKAN(); ...@@ -171,6 +171,8 @@ PlatformParameters ES1_VULKAN();
PlatformParameters ES1_VULKAN_NULL(); PlatformParameters ES1_VULKAN_NULL();
PlatformParameters ES2_VULKAN(); PlatformParameters ES2_VULKAN();
PlatformParameters ES2_VULKAN_NULL(); PlatformParameters ES2_VULKAN_NULL();
PlatformParameters ES3_VULKAN();
PlatformParameters ES3_VULKAN_NULL();
} // namespace angle } // namespace angle
......
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