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

Commit 97843bd

Browse files
null77Commit Bot
authored andcommitted
Vulkan: Fix EGL Surface robust init.
The error here was related to using a single cache variable for the robust init setting for all the surfaces in a DisplayVk. Fix this by passing down the robust init setting from the SurfaceVk to image init. Bug: angleproject:5274 Change-Id: I9bc9c20990268d1d5166411fb53f8f2593fd1971 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2510694 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 parent 6c618ce commit 97843bd

20 files changed

+266
-128
lines changed

src/libANGLE/Surface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ SurfaceState::~SurfaceState()
4444
delete config;
4545
}
4646

47+
bool SurfaceState::isRobustResourceInitEnabled() const
48+
{
49+
return attributes.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE;
50+
}
51+
4752
Surface::Surface(EGLint surfaceType,
4853
const egl::Config *config,
4954
const AttributeMap &attributes,

src/libANGLE/Surface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ struct SurfaceState final : private angle::NonCopyable
4848
SurfaceState(const egl::Config *configIn, const AttributeMap &attributesIn);
4949
~SurfaceState();
5050

51+
bool isRobustResourceInitEnabled() const;
52+
5153
EGLLabelKHR label;
5254
const egl::Config *config;
5355
AttributeMap attributes;

src/libANGLE/renderer/vulkan/CommandProcessor.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,12 +469,6 @@ CommandProcessor::CommandProcessor(RendererVk *renderer)
469469

470470
CommandProcessor::~CommandProcessor() = default;
471471

472-
bool CommandProcessor::isRobustResourceInitEnabled() const
473-
{
474-
// Unused for worker thread, just return false.
475-
return false;
476-
}
477-
478472
vk::Error CommandProcessor::getAndClearPendingError()
479473
{
480474
std::lock_guard<std::mutex> queueLock(mErrorMutex);

src/libANGLE/renderer/vulkan/CommandProcessor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ class CommandProcessor : public vk::Context
215215
const char *function,
216216
unsigned int line) override;
217217

218-
bool isRobustResourceInitEnabled() const override;
219-
220218
// Entry point for command processor thread, calls processTasksImpl to do the
221219
// work. called by RendererVk::initialization on main thread
222220
void processTasks();

src/libANGLE/renderer/vulkan/ContextVk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ class ContextVk : public ContextImpl, public vk::Context
641641
const ProgramExecutableVk *getExecutable() const { return mExecutable; }
642642
ProgramExecutableVk *getExecutable() { return mExecutable; }
643643

644-
bool isRobustResourceInitEnabled() const override;
644+
bool isRobustResourceInitEnabled() const;
645645

646646
// occlusion query
647647
void beginOcclusionQuery(QueryVk *queryVk);

src/libANGLE/renderer/vulkan/DisplayVk.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ DisplayVk::DisplayVk(const egl::DisplayState &state)
2626
: DisplayImpl(state),
2727
vk::Context(new RendererVk()),
2828
mScratchBuffer(1000u),
29-
mSavedError({VK_SUCCESS, "", "", 0}),
30-
mHasSurfaceWithRobustInit(false)
29+
mSavedError({VK_SUCCESS, "", "", 0})
3130
{}
3231

3332
DisplayVk::~DisplayVk()
@@ -114,22 +113,12 @@ SurfaceImpl *DisplayVk::createWindowSurface(const egl::SurfaceState &state,
114113
EGLNativeWindowType window,
115114
const egl::AttributeMap &attribs)
116115
{
117-
if (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE)
118-
{
119-
mHasSurfaceWithRobustInit = true;
120-
}
121-
122116
return createWindowSurfaceVk(state, window);
123117
}
124118

125119
SurfaceImpl *DisplayVk::createPbufferSurface(const egl::SurfaceState &state,
126120
const egl::AttributeMap &attribs)
127121
{
128-
if (attribs.get(EGL_ROBUST_RESOURCE_INITIALIZATION_ANGLE, EGL_FALSE) == EGL_TRUE)
129-
{
130-
mHasSurfaceWithRobustInit = true;
131-
}
132-
133122
ASSERT(mRenderer);
134123
return new OffscreenSurfaceVk(state, mRenderer);
135124
}
@@ -299,12 +288,6 @@ void DisplayVk::populateFeatureList(angle::FeatureList *features)
299288
mRenderer->getFeatures().populateFeatureList(features);
300289
}
301290

302-
bool DisplayVk::isRobustResourceInitEnabled() const
303-
{
304-
// We return true if any surface was created with robust resource init enabled.
305-
return mHasSurfaceWithRobustInit;
306-
}
307-
308291
void ShareGroupVk::onDestroy(const egl::Display *display)
309292
{
310293
DisplayVk *displayVk = vk::GetImpl(display);

src/libANGLE/renderer/vulkan/DisplayVk.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ class DisplayVk : public DisplayImpl, public vk::Context
124124

125125
void populateFeatureList(angle::FeatureList *features) override;
126126

127-
bool isRobustResourceInitEnabled() const override;
128-
129127
ShareGroupImpl *createShareGroup() override;
130128

131129
protected:
@@ -141,7 +139,6 @@ class DisplayVk : public DisplayImpl, public vk::Context
141139
mutable angle::ScratchBuffer mScratchBuffer;
142140

143141
vk::Error mSavedError;
144-
bool mHasSurfaceWithRobustInit;
145142
};
146143

147144
} // namespace rx

src/libANGLE/renderer/vulkan/FramebufferVk.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,9 +1575,9 @@ angle::Result FramebufferVk::updateColorAttachment(const gl::Context *context,
15751575
updateActiveColorMasks(colorIndexGL, actualFormat.redBits > 0, actualFormat.greenBits > 0,
15761576
actualFormat.blueBits > 0, actualFormat.alphaBits > 0);
15771577

1578-
const angle::Format &sourceFormat = renderTarget->getImageFormat().intendedFormat();
1579-
mEmulatedAlphaAttachmentMask.set(colorIndexGL,
1580-
sourceFormat.alphaBits == 0 && actualFormat.alphaBits > 0);
1578+
const angle::Format &intendedFormat = renderTarget->getImageFormat().intendedFormat();
1579+
mEmulatedAlphaAttachmentMask.set(
1580+
colorIndexGL, intendedFormat.alphaBits == 0 && actualFormat.alphaBits > 0);
15811581

15821582
contextVk->updateColorMasks(context->getState().getBlendStateExt());
15831583

src/libANGLE/renderer/vulkan/MemoryObjectVk.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ angle::Result MemoryObjectVk::createImage(ContextVk *contextVk,
204204
// ANGLE_external_objects_flags allows create flags to be specified by the application instead
205205
// of getting defaulted to zero. Note that the GL enum values constituting the bits of
206206
// |createFlags| are identical to their corresponding Vulkan value.
207-
ANGLE_TRY(image->initExternal(contextVk, type, vkExtents, vkFormat, 1, imageUsageFlags,
208-
createFlags, vk::ImageLayout::Undefined,
209-
&externalMemoryImageCreateInfo, gl::LevelIndex(0),
210-
gl::LevelIndex(static_cast<uint32_t>(levels) - 1),
211-
static_cast<uint32_t>(levels), layerCount));
207+
ANGLE_TRY(image->initExternal(
208+
contextVk, type, vkExtents, vkFormat, 1, imageUsageFlags, createFlags,
209+
vk::ImageLayout::Undefined, &externalMemoryImageCreateInfo, gl::LevelIndex(0),
210+
gl::LevelIndex(static_cast<uint32_t>(levels) - 1), static_cast<uint32_t>(levels),
211+
layerCount, contextVk->isRobustResourceInitEnabled()));
212212

213213
VkMemoryRequirements externalMemoryRequirements;
214214
image->getImage().getMemoryRequirements(renderer->getDevice(), &externalMemoryRequirements);

src/libANGLE/renderer/vulkan/OverlayVk.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,16 @@ angle::Result OverlayVk::createFont(ContextVk *contextVk)
105105
ANGLE_TRY(fontDataBuffer.get().flush(renderer, 0, fontDataBuffer.get().getSize()));
106106
fontDataBuffer.get().unmap(renderer);
107107

108+
// Don't use robust resource init for overlay widgets.
109+
bool useRobustInit = false;
110+
108111
// Create the font image.
109-
ANGLE_TRY(
110-
mFontImage.init(contextVk, gl::TextureType::_2D,
111-
VkExtent3D{gl::overlay::kFontImageWidth, gl::overlay::kFontImageHeight, 1},
112-
renderer->getFormat(angle::FormatID::R8_UNORM), 1,
113-
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
114-
gl::LevelIndex(0), gl::LevelIndex(0), 1, gl::overlay::kFontCount));
112+
ANGLE_TRY(mFontImage.init(
113+
contextVk, gl::TextureType::_2D,
114+
VkExtent3D{gl::overlay::kFontImageWidth, gl::overlay::kFontImageHeight, 1},
115+
renderer->getFormat(angle::FormatID::R8_UNORM), 1,
116+
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, gl::LevelIndex(0),
117+
gl::LevelIndex(0), 1, gl::overlay::kFontCount, useRobustInit));
115118
ANGLE_TRY(mFontImage.initMemory(contextVk, renderer->getMemoryProperties(),
116119
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
117120
ANGLE_TRY(mFontImage.initImageView(contextVk, gl::TextureType::_2DArray,
@@ -176,10 +179,13 @@ angle::Result OverlayVk::cullWidgets(ContextVk *contextVk)
176179
UnsignedCeilDivide(mPresentImageExtent.width, mSubgroupSize[0]),
177180
UnsignedCeilDivide(mPresentImageExtent.height, mSubgroupSize[1]), 1};
178181

182+
// Don't use robust resource init for overlay widgets.
183+
bool useRobustInit = false;
184+
179185
ANGLE_TRY(mCulledWidgets.init(contextVk, gl::TextureType::_2D, culledWidgetsExtent,
180186
renderer->getFormat(angle::FormatID::R32G32_UINT), 1,
181187
VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
182-
gl::LevelIndex(0), gl::LevelIndex(0), 1, 1));
188+
gl::LevelIndex(0), gl::LevelIndex(0), 1, 1, useRobustInit));
183189
ANGLE_TRY(mCulledWidgets.initMemory(contextVk, renderer->getMemoryProperties(),
184190
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
185191
ANGLE_TRY(mCulledWidgets.initImageView(contextVk, gl::TextureType::_2D,

0 commit comments

Comments
 (0)