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

Commit 004fc91

Browse files
committed
No wait + GL_LINEAR.
1 parent 55604b8 commit 004fc91

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

impeller/toolkit/glvk/trampoline.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,8 @@ bool Trampoline::BlitTextureOpenGLToVulkan(
281281

282282
gl.ActiveTexture(GL_TEXTURE0);
283283
gl.BindTexture(src_texture.target, src_texture.texture);
284-
// Sampling from the source is always nearest. The sampling from the Vulkan
285-
// texture is user-specified.
286-
gl.TexParameteri(src_texture.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
287-
gl.TexParameteri(src_texture.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
284+
gl.TexParameteri(src_texture.target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
285+
gl.TexParameteri(src_texture.target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
288286
gl.TexParameteri(src_texture.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
289287
gl.TexParameteri(src_texture.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
290288
gl.Uniform1i(texture_uniform_location_, 0u);

shell/platform/android/surface_texture_external_texture_vk_impeller.cc

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,15 @@ SurfaceTextureExternalTextureVKImpeller::
3737
SurfaceTextureExternalTextureVKImpeller::
3838
~SurfaceTextureExternalTextureVKImpeller() = default;
3939

40-
static bool SetTextureLayoutSync(const ContextVK& context,
41-
const TextureSourceVK* texture,
42-
vk::ImageLayout layout) {
40+
enum class LayoutUpdateMode {
41+
kSync,
42+
kAsync,
43+
};
44+
45+
static bool SetTextureLayout(const ContextVK& context,
46+
const TextureSourceVK* texture,
47+
vk::ImageLayout layout,
48+
LayoutUpdateMode mode) {
4349
TRACE_EVENT0("flutter", __FUNCTION__);
4450
if (!texture) {
4551
return true;
@@ -76,24 +82,32 @@ static bool SetTextureLayoutSync(const ContextVK& context,
7682

7783
// There is no need to track the fence in the encoder since we are going to do
7884
// a sync wait for completion.
79-
auto fence = context.GetDevice().createFenceUnique(vk::FenceCreateFlags{});
80-
if (fence.result != impeller::vk::Result::eSuccess) {
81-
VALIDATION_LOG << "Could not create fence.";
82-
return false;
85+
vk::UniqueFence fence;
86+
87+
if (mode == LayoutUpdateMode::kSync) {
88+
auto fence_pair =
89+
context.GetDevice().createFenceUnique(vk::FenceCreateFlags{});
90+
if (fence_pair.result != impeller::vk::Result::eSuccess) {
91+
VALIDATION_LOG << "Could not create fence.";
92+
return false;
93+
}
94+
fence = std::move(fence_pair.value);
8395
}
8496

85-
if (context.GetGraphicsQueue()->Submit(submit_info, fence.value.get()) !=
97+
if (context.GetGraphicsQueue()->Submit(submit_info, fence.get()) !=
8698
impeller::vk::Result::eSuccess) {
8799
VALIDATION_LOG << "Could not submit layout transition fence.";
88100
return false;
89101
}
90102

91103
using namespace std::chrono_literals;
92104

93-
if (context.GetDevice().waitForFences(
94-
fence.value.get(), VK_TRUE,
95-
std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count()) !=
96-
impeller::vk::Result::eSuccess) {
105+
if (fence &&
106+
context.GetDevice().waitForFences(
107+
fence.get(), //
108+
VK_TRUE, //
109+
std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count() //
110+
) != impeller::vk::Result::eSuccess) {
97111
VALIDATION_LOG << "Could not perform sync wait on fence.";
98112
return false;
99113
}
@@ -130,8 +144,9 @@ void SurfaceTextureExternalTextureVKImpeller::ProcessFrame(
130144
Attach(src_gl_texture);
131145
Update();
132146

133-
SetTextureLayoutSync(context_vk, dst_texture.get(),
134-
vk::ImageLayout::eColorAttachmentOptimal);
147+
SetTextureLayout(context_vk, dst_texture.get(),
148+
vk::ImageLayout::eColorAttachmentOptimal,
149+
LayoutUpdateMode::kSync);
135150

136151
SkM44 transformation(GetCurrentUVTransformation());
137152
impeller::Matrix uv_transformation;
@@ -146,8 +161,9 @@ void SurfaceTextureExternalTextureVKImpeller::ProcessFrame(
146161
VALIDATION_LOG << "Texture copy failed.";
147162
}
148163

149-
SetTextureLayoutSync(context_vk, dst_texture.get(),
150-
vk::ImageLayout::eShaderReadOnlyOptimal);
164+
SetTextureLayout(context_vk, dst_texture.get(),
165+
vk::ImageLayout::eShaderReadOnlyOptimal,
166+
LayoutUpdateMode::kAsync);
151167

152168
glDeleteTextures(1u, &src_gl_texture);
153169

0 commit comments

Comments
 (0)