Commit 475ef575 by Geoff Lang Committed by Commit Bot

Vulkan: Refactor config generation out of platform specific code.

Permuatations of configs are now generated in platform-independent code and a DisplayVk callback is used to determine native support. BUG=angleproject:2692 Change-Id: Iad450c1a3275239d6bcbc350e8dd8e37470fa8e0 Reviewed-on: https://chromium-review.googlesource.com/1117563Reviewed-by: 's avatarLuc Ferron <lucferron@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent ac1a377d
......@@ -69,6 +69,11 @@ class DisplayVk : public DisplayImpl
virtual const char *getWSIName() const = 0;
// Determine if a config with given formats and sample counts is supported. This callback may
// modify the config to add or remove platform specific attributes such as nativeVisualID before
// returning a bool to indicate if the config should be supported.
virtual bool checkConfigSupport(egl::Config *config) = 0;
private:
virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window,
......
......@@ -13,6 +13,7 @@
#include <vulkan/vulkan.h>
#include "libANGLE/renderer/vulkan/android/WindowSurfaceVkAndroid.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
namespace rx
{
......@@ -36,54 +37,17 @@ SurfaceImpl *DisplayVkAndroid::createWindowSurfaceVk(const egl::SurfaceState &st
egl::ConfigSet DisplayVkAndroid::generateConfigs()
{
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs.
egl::Config rgba;
rgba.renderTargetFormat = GL_RGBA8;
rgba.depthStencilFormat = GL_NONE;
rgba.bufferSize = 32;
rgba.redSize = 8;
rgba.greenSize = 8;
rgba.blueSize = 8;
rgba.alphaSize = 8;
rgba.alphaMaskSize = 0;
rgba.bindToTextureRGB = EGL_FALSE;
rgba.bindToTextureRGBA = EGL_FALSE;
rgba.colorBufferType = EGL_RGB_BUFFER;
rgba.configCaveat = EGL_NONE;
rgba.conformant = 0;
rgba.depthSize = 0;
rgba.stencilSize = 0;
rgba.level = 0;
rgba.matchNativePixmap = EGL_NONE;
rgba.maxPBufferWidth = 0;
rgba.maxPBufferHeight = 0;
rgba.maxPBufferPixels = 0;
rgba.maxSwapInterval = 1;
rgba.minSwapInterval = 1;
rgba.nativeRenderable = EGL_TRUE;
rgba.nativeVisualID = 0;
rgba.nativeVisualType = EGL_NONE;
rgba.renderableType = EGL_OPENGL_ES2_BIT;
rgba.sampleBuffers = 0;
rgba.samples = 0;
rgba.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
rgba.optimalOrientation = 0;
rgba.transparentType = EGL_NONE;
rgba.transparentRedValue = 0;
rgba.transparentGreenValue = 0;
rgba.transparentBlueValue = 0;
rgba.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
egl::Config rgbaD24S8;
rgbaD24S8 = rgba;
rgbaD24S8.depthStencilFormat = GL_DEPTH24_STENCIL8;
rgbaD24S8.depthSize = 24;
rgbaD24S8.stencilSize = 8;
constexpr GLenum kColorFormats[] = {GL_RGBA8};
constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
constexpr EGLint kSampleCounts[] = {0};
return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
}
egl::ConfigSet configSet;
configSet.add(rgba);
configSet.add(rgbaD24S8);
return configSet;
bool DisplayVkAndroid::checkConfigSupport(egl::Config *config)
{
// TODO(geofflang): Test for native support and modify the config accordingly.
// anglebug.com/2692
return true;
}
const char *DisplayVkAndroid::getWSIName() const
......
......@@ -27,6 +27,7 @@ class DisplayVkAndroid : public DisplayVk
EGLint height) override;
egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override;
const char *getWSIName() const override;
};
......
......@@ -8,7 +8,12 @@
//
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "common/utilities.h"
#include "libANGLE/Caps.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "vk_format_utils.h"
namespace
......@@ -138,4 +143,98 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
outCaps->maxVertexOutputComponents = outCaps->maxVaryingVectors * 4;
}
} // namespace vk
namespace egl_vk
{
egl::Config GenerateDefaultConfig(const gl::InternalFormat &colorFormat,
const gl::InternalFormat &depthStencilFormat,
EGLint sampleCount)
{
egl::Config config;
config.renderTargetFormat = colorFormat.internalFormat;
config.depthStencilFormat = depthStencilFormat.internalFormat;
config.bufferSize = colorFormat.pixelBytes * 8;
config.redSize = colorFormat.redBits;
config.greenSize = colorFormat.greenBits;
config.blueSize = colorFormat.blueBits;
config.alphaSize = colorFormat.alphaBits;
config.alphaMaskSize = 0;
config.bindToTextureRGB = EGL_FALSE;
config.bindToTextureRGBA = EGL_FALSE;
config.colorBufferType = EGL_RGB_BUFFER;
config.configCaveat = EGL_NONE;
config.conformant = 0;
config.depthSize = depthStencilFormat.depthBits;
config.stencilSize = depthStencilFormat.stencilBits;
config.level = 0;
config.matchNativePixmap = EGL_NONE;
config.maxPBufferWidth = 0;
config.maxPBufferHeight = 0;
config.maxPBufferPixels = 0;
config.maxSwapInterval = 1;
config.minSwapInterval = 1;
config.nativeRenderable = EGL_TRUE;
config.nativeVisualID = 0;
config.nativeVisualType = EGL_NONE;
config.renderableType = EGL_OPENGL_ES2_BIT;
config.sampleBuffers = (sampleCount > 0) ? 1 : 0;
config.samples = sampleCount;
config.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
config.optimalOrientation = 0;
config.transparentType = EGL_NONE;
config.transparentRedValue = 0;
config.transparentGreenValue = 0;
config.transparentBlueValue = 0;
config.colorComponentType =
gl_egl::GLComponentTypeToEGLColorComponentType(colorFormat.componentType);
return config;
}
egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
size_t colorFormatsCount,
const GLenum *depthStencilFormats,
size_t depthStencilFormatCount,
const EGLint *sampleCounts,
size_t sampleCountsCount,
DisplayVk *display)
{
ASSERT(colorFormatsCount > 0);
ASSERT(display != nullptr);
egl::ConfigSet configSet;
for (size_t colorFormatIdx = 0; colorFormatIdx < colorFormatsCount; colorFormatIdx++)
{
const gl::InternalFormat &colorFormatInfo =
gl::GetSizedInternalFormatInfo(colorFormats[colorFormatIdx]);
ASSERT(colorFormatInfo.sized);
for (size_t depthStencilFormatIdx = 0; depthStencilFormatIdx < depthStencilFormatCount;
depthStencilFormatIdx++)
{
const gl::InternalFormat &depthStencilFormatInfo =
gl::GetSizedInternalFormatInfo(depthStencilFormats[depthStencilFormatIdx]);
ASSERT(depthStencilFormats[depthStencilFormatIdx] == GL_NONE ||
depthStencilFormatInfo.sized);
for (size_t sampleCountIndex = 0; sampleCountIndex < sampleCountsCount;
sampleCountIndex++)
{
egl::Config config = GenerateDefaultConfig(colorFormatInfo, depthStencilFormatInfo,
sampleCounts[sampleCountIndex]);
if (display->checkConfigSupport(&config))
{
configSet.add(config);
}
}
}
}
return configSet;
}
} // namespace egl_vk
} // namespace rx
......@@ -12,6 +12,8 @@
#include <vulkan/vulkan.h>
#include "libANGLE/Config.h"
namespace gl
{
struct Limitations;
......@@ -19,11 +21,14 @@ struct Extensions;
class TextureCapsMap;
struct Caps;
struct TextureCaps;
struct InternalFormat;
}
namespace rx
{
class DisplayVk;
namespace vk
{
void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
......@@ -32,6 +37,36 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
gl::Extensions *outExtensions,
gl::Limitations * /* outLimitations */);
} // namespace 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
// generates a basic config which is passed to DisplayVk::checkConfigSupport.
egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
size_t colorFormatsCount,
const GLenum *depthStencilFormats,
size_t depthStencilFormatCount,
const EGLint *sampleCounts,
size_t sampleCountsCount,
DisplayVk *display);
template <size_t ColorFormatCount, size_t DepthStencilFormatCount, size_t SampleCountsCount>
egl::ConfigSet GenerateConfigs(const GLenum (&colorFormats)[ColorFormatCount],
const GLenum (&depthStencilFormats)[DepthStencilFormatCount],
const EGLint (&sampleCounts)[SampleCountsCount],
DisplayVk *display)
{
return GenerateConfigs(colorFormats, ColorFormatCount, depthStencilFormats,
DepthStencilFormatCount, sampleCounts, SampleCountsCount, display);
}
} // namespace egl_vk
} // namespace rx
#endif
\ No newline at end of file
#endif
......@@ -11,6 +11,7 @@
#include <vulkan/vulkan.h>
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/win32/WindowSurfaceVkWin32.h"
namespace rx
......@@ -35,54 +36,17 @@ SurfaceImpl *DisplayVkWin32::createWindowSurfaceVk(const egl::SurfaceState &stat
egl::ConfigSet DisplayVkWin32::generateConfigs()
{
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs.
egl::Config bgra;
bgra.renderTargetFormat = GL_BGRA8_EXT;
bgra.depthStencilFormat = GL_NONE;
bgra.bufferSize = 32;
bgra.redSize = 8;
bgra.greenSize = 8;
bgra.blueSize = 8;
bgra.alphaSize = 8;
bgra.alphaMaskSize = 0;
bgra.bindToTextureRGB = EGL_FALSE;
bgra.bindToTextureRGBA = EGL_FALSE;
bgra.colorBufferType = EGL_RGB_BUFFER;
bgra.configCaveat = EGL_NONE;
bgra.conformant = 0;
bgra.depthSize = 0;
bgra.stencilSize = 0;
bgra.level = 0;
bgra.matchNativePixmap = EGL_NONE;
bgra.maxPBufferWidth = 0;
bgra.maxPBufferHeight = 0;
bgra.maxPBufferPixels = 0;
bgra.maxSwapInterval = 1;
bgra.minSwapInterval = 1;
bgra.nativeRenderable = EGL_TRUE;
bgra.nativeVisualID = 0;
bgra.nativeVisualType = EGL_NONE;
bgra.renderableType = EGL_OPENGL_ES2_BIT;
bgra.sampleBuffers = 0;
bgra.samples = 0;
bgra.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
bgra.optimalOrientation = 0;
bgra.transparentType = EGL_NONE;
bgra.transparentRedValue = 0;
bgra.transparentGreenValue = 0;
bgra.transparentBlueValue = 0;
bgra.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
egl::Config bgraD24S8;
bgraD24S8 = bgra;
bgraD24S8.depthStencilFormat = GL_DEPTH24_STENCIL8;
bgraD24S8.depthSize = 24;
bgraD24S8.stencilSize = 8;
constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT};
constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
constexpr EGLint kSampleCounts[] = {0};
return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
}
egl::ConfigSet configSet;
configSet.add(bgra);
configSet.add(bgraD24S8);
return configSet;
bool DisplayVkWin32::checkConfigSupport(egl::Config *config)
{
// TODO(geofflang): Test for native support and modify the config accordingly.
// anglebug.com/2692
return true;
}
const char *DisplayVkWin32::getWSIName() const
......
......@@ -27,6 +27,7 @@ class DisplayVkWin32 : public DisplayVk
EGLint height) override;
egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override;
const char *getWSIName() const override;
};
......
......@@ -11,6 +11,7 @@
#include <xcb/xcb.h>
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/xcb/WindowSurfaceVkXcb.h"
namespace rx
......@@ -63,54 +64,17 @@ SurfaceImpl *DisplayVkXcb::createWindowSurfaceVk(const egl::SurfaceState &state,
egl::ConfigSet DisplayVkXcb::generateConfigs()
{
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs.
egl::Config bgra;
bgra.renderTargetFormat = GL_BGRA8_EXT;
bgra.depthStencilFormat = GL_NONE;
bgra.bufferSize = 32;
bgra.redSize = 8;
bgra.greenSize = 8;
bgra.blueSize = 8;
bgra.alphaSize = 8;
bgra.alphaMaskSize = 0;
bgra.bindToTextureRGB = EGL_FALSE;
bgra.bindToTextureRGBA = EGL_FALSE;
bgra.colorBufferType = EGL_RGB_BUFFER;
bgra.configCaveat = EGL_NONE;
bgra.conformant = 0;
bgra.depthSize = 0;
bgra.stencilSize = 0;
bgra.level = 0;
bgra.matchNativePixmap = EGL_NONE;
bgra.maxPBufferWidth = 0;
bgra.maxPBufferHeight = 0;
bgra.maxPBufferPixels = 0;
bgra.maxSwapInterval = 1;
bgra.minSwapInterval = 1;
bgra.nativeRenderable = EGL_TRUE;
bgra.nativeVisualID = 0;
bgra.nativeVisualType = EGL_NONE;
bgra.renderableType = EGL_OPENGL_ES2_BIT;
bgra.sampleBuffers = 0;
bgra.samples = 0;
bgra.surfaceType = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
bgra.optimalOrientation = 0;
bgra.transparentType = EGL_NONE;
bgra.transparentRedValue = 0;
bgra.transparentGreenValue = 0;
bgra.transparentBlueValue = 0;
bgra.colorComponentType = EGL_COLOR_COMPONENT_TYPE_FIXED_EXT;
egl::Config bgraD24S8;
bgraD24S8 = bgra;
bgraD24S8.depthStencilFormat = GL_DEPTH24_STENCIL8;
bgraD24S8.depthSize = 24;
bgraD24S8.stencilSize = 8;
constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT};
constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
constexpr EGLint kSampleCounts[] = {0};
return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
}
egl::ConfigSet configSet;
configSet.add(bgra);
configSet.add(bgraD24S8);
return configSet;
bool DisplayVkXcb::checkConfigSupport(egl::Config *config)
{
// TODO(geofflang): Test for native support and modify the config accordingly.
// anglebug.com/2692
return true;
}
const char *DisplayVkXcb::getWSIName() const
......
......@@ -33,6 +33,7 @@ class DisplayVkXcb : public DisplayVk
EGLint height) override;
egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override;
const char *getWSIName() const override;
......
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