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 ...@@ -69,6 +69,11 @@ class DisplayVk : public DisplayImpl
virtual const char *getWSIName() const = 0; 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: private:
virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window,
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "libANGLE/renderer/vulkan/android/WindowSurfaceVkAndroid.h" #include "libANGLE/renderer/vulkan/android/WindowSurfaceVkAndroid.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
namespace rx namespace rx
{ {
...@@ -36,54 +37,17 @@ SurfaceImpl *DisplayVkAndroid::createWindowSurfaceVk(const egl::SurfaceState &st ...@@ -36,54 +37,17 @@ SurfaceImpl *DisplayVkAndroid::createWindowSurfaceVk(const egl::SurfaceState &st
egl::ConfigSet DisplayVkAndroid::generateConfigs() egl::ConfigSet DisplayVkAndroid::generateConfigs()
{ {
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs. constexpr GLenum kColorFormats[] = {GL_RGBA8};
egl::Config rgba; constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
rgba.renderTargetFormat = GL_RGBA8; constexpr EGLint kSampleCounts[] = {0};
rgba.depthStencilFormat = GL_NONE; return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
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;
egl::ConfigSet configSet; bool DisplayVkAndroid::checkConfigSupport(egl::Config *config)
configSet.add(rgba); {
configSet.add(rgbaD24S8); // TODO(geofflang): Test for native support and modify the config accordingly.
return configSet; // anglebug.com/2692
return true;
} }
const char *DisplayVkAndroid::getWSIName() const const char *DisplayVkAndroid::getWSIName() const
......
...@@ -27,6 +27,7 @@ class DisplayVkAndroid : public DisplayVk ...@@ -27,6 +27,7 @@ class DisplayVkAndroid : public DisplayVk
EGLint height) override; EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override;
const char *getWSIName() const override; const char *getWSIName() const override;
}; };
......
...@@ -8,7 +8,12 @@ ...@@ -8,7 +8,12 @@
// //
#include "libANGLE/renderer/vulkan/vk_caps_utils.h" #include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "common/utilities.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/vulkan/DisplayVk.h"
#include "vk_format_utils.h" #include "vk_format_utils.h"
namespace namespace
...@@ -138,4 +143,98 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -138,4 +143,98 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
outCaps->maxVertexOutputComponents = outCaps->maxVaryingVectors * 4; outCaps->maxVertexOutputComponents = outCaps->maxVaryingVectors * 4;
} }
} // namespace vk } // 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 } // namespace rx
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "libANGLE/Config.h"
namespace gl namespace gl
{ {
struct Limitations; struct Limitations;
...@@ -19,11 +21,14 @@ struct Extensions; ...@@ -19,11 +21,14 @@ struct Extensions;
class TextureCapsMap; class TextureCapsMap;
struct Caps; struct Caps;
struct TextureCaps; struct TextureCaps;
struct InternalFormat;
} }
namespace rx namespace rx
{ {
class DisplayVk;
namespace vk namespace vk
{ {
void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
...@@ -32,6 +37,36 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties, ...@@ -32,6 +37,36 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
gl::Extensions *outExtensions, gl::Extensions *outExtensions,
gl::Limitations * /* outLimitations */); gl::Limitations * /* outLimitations */);
} // namespace vk } // 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 } // namespace rx
#endif #endif
\ No newline at end of file
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/win32/WindowSurfaceVkWin32.h" #include "libANGLE/renderer/vulkan/win32/WindowSurfaceVkWin32.h"
namespace rx namespace rx
...@@ -35,54 +36,17 @@ SurfaceImpl *DisplayVkWin32::createWindowSurfaceVk(const egl::SurfaceState &stat ...@@ -35,54 +36,17 @@ SurfaceImpl *DisplayVkWin32::createWindowSurfaceVk(const egl::SurfaceState &stat
egl::ConfigSet DisplayVkWin32::generateConfigs() egl::ConfigSet DisplayVkWin32::generateConfigs()
{ {
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs. constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT};
egl::Config bgra; constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
bgra.renderTargetFormat = GL_BGRA8_EXT; constexpr EGLint kSampleCounts[] = {0};
bgra.depthStencilFormat = GL_NONE; return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
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;
egl::ConfigSet configSet; bool DisplayVkWin32::checkConfigSupport(egl::Config *config)
configSet.add(bgra); {
configSet.add(bgraD24S8); // TODO(geofflang): Test for native support and modify the config accordingly.
return configSet; // anglebug.com/2692
return true;
} }
const char *DisplayVkWin32::getWSIName() const const char *DisplayVkWin32::getWSIName() const
......
...@@ -27,6 +27,7 @@ class DisplayVkWin32 : public DisplayVk ...@@ -27,6 +27,7 @@ class DisplayVkWin32 : public DisplayVk
EGLint height) override; EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override;
const char *getWSIName() const override; const char *getWSIName() const override;
}; };
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/xcb/WindowSurfaceVkXcb.h" #include "libANGLE/renderer/vulkan/xcb/WindowSurfaceVkXcb.h"
namespace rx namespace rx
...@@ -63,54 +64,17 @@ SurfaceImpl *DisplayVkXcb::createWindowSurfaceVk(const egl::SurfaceState &state, ...@@ -63,54 +64,17 @@ SurfaceImpl *DisplayVkXcb::createWindowSurfaceVk(const egl::SurfaceState &state,
egl::ConfigSet DisplayVkXcb::generateConfigs() egl::ConfigSet DisplayVkXcb::generateConfigs()
{ {
// TODO(jmadill): Multiple configs, pbuffers, and proper checking of config attribs. constexpr GLenum kColorFormats[] = {GL_BGRA8_EXT};
egl::Config bgra; constexpr GLenum kDepthStencilFormats[] = {GL_NONE, GL_DEPTH24_STENCIL8};
bgra.renderTargetFormat = GL_BGRA8_EXT; constexpr EGLint kSampleCounts[] = {0};
bgra.depthStencilFormat = GL_NONE; return egl_vk::GenerateConfigs(kColorFormats, kDepthStencilFormats, kSampleCounts, this);
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;
egl::ConfigSet configSet; bool DisplayVkXcb::checkConfigSupport(egl::Config *config)
configSet.add(bgra); {
configSet.add(bgraD24S8); // TODO(geofflang): Test for native support and modify the config accordingly.
return configSet; // anglebug.com/2692
return true;
} }
const char *DisplayVkXcb::getWSIName() const const char *DisplayVkXcb::getWSIName() const
......
...@@ -33,6 +33,7 @@ class DisplayVkXcb : public DisplayVk ...@@ -33,6 +33,7 @@ class DisplayVkXcb : public DisplayVk
EGLint height) override; EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override;
const char *getWSIName() const 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