Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 84bd9da

Browse files
ShabbyXCommit Bot
authored andcommitted
Vulkan: Allow pbuffer usage if no window support
Vulkan allows rendering to non-swapchain images, so pbuffers can always be supported on every config. With this change, if the window system does not support a configuration, EGL_WINDOW_BIT is removed from the config instead of dropping the config entirely. Bug: chromium:1034840 Change-Id: Ib972ed8ddf7660c327123fa83ae0674456cf2a35 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2378921 Commit-Queue: Shahbaz Youssefi <[email protected]> Reviewed-by: Geoff Lang <[email protected]> Reviewed-by: back sept 10 - Jamie Madill <[email protected]>
1 parent a568b7e commit 84bd9da

14 files changed

+40
-32
lines changed

src/libANGLE/renderer/vulkan/DisplayVk.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ class DisplayVk : public DisplayImpl, public vk::Context
8383
virtual const char *getWSILayer() const;
8484

8585
// Determine if a config with given formats and sample counts is supported. This callback may
86-
// modify the config to add or remove platform specific attributes such as nativeVisualID before
87-
// returning a bool to indicate if the config should be supported.
88-
virtual bool checkConfigSupport(egl::Config *config) = 0;
86+
// modify the config to add or remove platform specific attributes such as nativeVisualID. If
87+
// the config is not supported by the window system, it removes the EGL_WINDOW_BIT from
88+
// surfaceType, which would still allow the config to be used for pbuffers.
89+
virtual void checkConfigSupport(egl::Config *config) = 0;
8990

9091
ANGLE_NO_DISCARD bool getScratchBuffer(size_t requestedSizeBytes,
9192
angle::MemoryBuffer **scratchBufferOut) const;

src/libANGLE/renderer/vulkan/android/DisplayVkAndroid.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ egl::ConfigSet DisplayVkAndroid::generateConfigs()
5555
return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this);
5656
}
5757

58-
bool DisplayVkAndroid::checkConfigSupport(egl::Config *config)
58+
void DisplayVkAndroid::checkConfigSupport(egl::Config *config)
5959
{
6060
// TODO(geofflang): Test for native support and modify the config accordingly.
6161
// anglebug.com/2692
62-
return true;
6362
}
6463

6564
egl::Error DisplayVkAndroid::validateImageClientBuffer(const gl::Context *context,

src/libANGLE/renderer/vulkan/android/DisplayVkAndroid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DisplayVkAndroid : public DisplayVk
2727
EGLNativeWindowType window) override;
2828

2929
egl::ConfigSet generateConfigs() override;
30-
bool checkConfigSupport(egl::Config *config) override;
30+
void checkConfigSupport(egl::Config *config) override;
3131

3232
egl::Error validateImageClientBuffer(const gl::Context *context,
3333
EGLenum target,

src/libANGLE/renderer/vulkan/fuchsia/DisplayVkFuchsia.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ egl::ConfigSet DisplayVkFuchsia::generateConfigs()
3535
return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this);
3636
}
3737

38-
bool DisplayVkFuchsia::checkConfigSupport(egl::Config *config)
38+
void DisplayVkFuchsia::checkConfigSupport(egl::Config *config)
3939
{
4040
// TODO(geofflang): Test for native support and modify the config accordingly.
4141
// anglebug.com/2692
42-
return true;
4342
}
4443

4544
const char *DisplayVkFuchsia::getWSIExtension() const

src/libANGLE/renderer/vulkan/fuchsia/DisplayVkFuchsia.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DisplayVkFuchsia : public DisplayVk
2626
EGLNativeWindowType window) override;
2727

2828
egl::ConfigSet generateConfigs() override;
29-
bool checkConfigSupport(egl::Config *config) override;
29+
void checkConfigSupport(egl::Config *config) override;
3030

3131
const char *getWSIExtension() const override;
3232
const char *getWSILayer() const override;

src/libANGLE/renderer/vulkan/ggp/DisplayVkGGP.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ egl::ConfigSet DisplayVkGGP::generateConfigs()
3535
return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this);
3636
}
3737

38-
bool DisplayVkGGP::checkConfigSupport(egl::Config *config)
39-
{
40-
return true;
41-
}
38+
void DisplayVkGGP::checkConfigSupport(egl::Config *config) {}
4239

4340
const char *DisplayVkGGP::getWSIExtension() const
4441
{

src/libANGLE/renderer/vulkan/ggp/DisplayVkGGP.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class DisplayVkGGP : public DisplayVk
2525
EGLNativeWindowType window) override;
2626

2727
egl::ConfigSet generateConfigs() override;
28-
bool checkConfigSupport(egl::Config *config) override;
28+
void checkConfigSupport(egl::Config *config) override;
2929

3030
const char *getWSIExtension() const override;
3131
};

src/libANGLE/renderer/vulkan/mac/DisplayVkMac.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DisplayVkMac : public DisplayVk
3131
const egl::AttributeMap &attribs) override;
3232

3333
egl::ConfigSet generateConfigs() override;
34-
bool checkConfigSupport(egl::Config *config) override;
34+
void checkConfigSupport(egl::Config *config) override;
3535

3636
void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
3737

src/libANGLE/renderer/vulkan/mac/DisplayVkMac.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@
5252
return egl_vk::GenerateConfigs(kColorFormats, egl_vk::kConfigDepthStencilFormats, this);
5353
}
5454

55-
bool DisplayVkMac::checkConfigSupport(egl::Config *config)
55+
void DisplayVkMac::checkConfigSupport(egl::Config *config)
5656
{
5757
// TODO(geofflang): Test for native support and modify the config accordingly.
5858
// anglebug.com/2692
59-
return true;
6059
}
6160

6261
const char *DisplayVkMac::getWSIExtension() const

src/libANGLE/renderer/vulkan/vk_caps_utils.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,13 @@ EGLint ComputeMaximumPBufferPixels(const VkPhysicalDeviceProperties &physicalDev
628628

629629
// Generates a basic config for a combination of color format, depth stencil format and sample
630630
// count.
631-
egl::Config GenerateDefaultConfig(const RendererVk *renderer,
631+
egl::Config GenerateDefaultConfig(DisplayVk *display,
632632
const gl::InternalFormat &colorFormat,
633633
const gl::InternalFormat &depthStencilFormat,
634634
EGLint sampleCount)
635635
{
636+
const RendererVk *renderer = display->getRenderer();
637+
636638
const VkPhysicalDeviceProperties &physicalDeviceProperties =
637639
renderer->getPhysicalDeviceProperties();
638640
gl::Version maxSupportedESVersion = renderer->getMaxSupportedESVersion();
@@ -683,6 +685,11 @@ egl::Config GenerateDefaultConfig(const RendererVk *renderer,
683685
config.colorComponentType =
684686
gl_egl::GLComponentTypeToEGLColorComponentType(colorFormat.componentType);
685687

688+
// Vulkan always supports off-screen rendering. Check the config with display to see if it can
689+
// also have window support. If not, the following call should automatically remove
690+
// EGL_WINDOW_BIT.
691+
display->checkConfigSupport(&config);
692+
686693
return config;
687694
}
688695

@@ -749,12 +756,9 @@ egl::ConfigSet GenerateConfigs(const GLenum *colorFormats,
749756

750757
for (EGLint sampleCount : *configSampleCounts)
751758
{
752-
egl::Config config = GenerateDefaultConfig(display->getRenderer(), colorFormatInfo,
759+
egl::Config config = GenerateDefaultConfig(display, colorFormatInfo,
753760
depthStencilFormatInfo, sampleCount);
754-
if (display->checkConfigSupport(&config))
755-
{
756-
configSet.add(config);
757-
}
761+
configSet.add(config);
758762
}
759763
}
760764
}

0 commit comments

Comments
 (0)