This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Fixed blit command missing tracking and added mock vulkan for tests #41408
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
46fff48
[Impeller] created mock for vulkan and added tracking resource fix fo…
gaaclarke d8dd4a3
got a "valid" context
gaaclarke dbe43c3
started using the graphcis queue
gaaclarke cd34aea
started allocating the textures
gaaclarke c34e37c
test passes now
gaaclarke 52bb77c
split out mock vulkan into its own file
gaaclarke 34652a6
finished test for one blit command
gaaclarke 6169338
added mip map test
gaaclarke 07b5818
got the blit to buffer working
gaaclarke aa114bc
format gn
gaaclarke 824a32a
pulled out function to make mock vulkan context
gaaclarke 2e907b4
licenses
gaaclarke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
impeller/renderer/backend/vulkan/blit_command_vk_unittests.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "flutter/testing/testing.h" | ||
#include "impeller/renderer/backend/vulkan/blit_command_vk.h" | ||
#include "impeller/renderer/backend/vulkan/command_encoder_vk.h" | ||
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h" | ||
|
||
namespace impeller { | ||
namespace testing { | ||
|
||
TEST(BlitCommandVkTest, BlitCopyTextureToTextureCommandVK) { | ||
auto context = CreateMockVulkanContext(); | ||
auto pool = CommandPoolVK::GetThreadLocal(context.get()); | ||
CommandEncoderVK encoder(context->GetDevice(), context->GetGraphicsQueue(), | ||
pool, context->GetFenceWaiter()); | ||
BlitCopyTextureToTextureCommandVK cmd; | ||
cmd.source = context->GetResourceAllocator()->CreateTexture({ | ||
.size = ISize(100, 100), | ||
}); | ||
cmd.destination = context->GetResourceAllocator()->CreateTexture({ | ||
.size = ISize(100, 100), | ||
}); | ||
bool result = cmd.Encode(encoder); | ||
EXPECT_TRUE(result); | ||
EXPECT_TRUE(encoder.IsTracking(cmd.source)); | ||
EXPECT_TRUE(encoder.IsTracking(cmd.destination)); | ||
} | ||
|
||
TEST(BlitCommandVkTest, BlitCopyTextureToBufferCommandVK) { | ||
auto context = CreateMockVulkanContext(); | ||
auto pool = CommandPoolVK::GetThreadLocal(context.get()); | ||
CommandEncoderVK encoder(context->GetDevice(), context->GetGraphicsQueue(), | ||
pool, context->GetFenceWaiter()); | ||
BlitCopyTextureToBufferCommandVK cmd; | ||
cmd.source = context->GetResourceAllocator()->CreateTexture({ | ||
.size = ISize(100, 100), | ||
}); | ||
cmd.destination = context->GetResourceAllocator()->CreateBuffer({ | ||
.size = 1, | ||
}); | ||
bool result = cmd.Encode(encoder); | ||
EXPECT_TRUE(result); | ||
EXPECT_TRUE(encoder.IsTracking(cmd.source)); | ||
EXPECT_TRUE(encoder.IsTracking(cmd.destination)); | ||
} | ||
|
||
TEST(BlitCommandVkTest, BlitGenerateMipmapCommandVK) { | ||
auto context = CreateMockVulkanContext(); | ||
auto pool = CommandPoolVK::GetThreadLocal(context.get()); | ||
CommandEncoderVK encoder(context->GetDevice(), context->GetGraphicsQueue(), | ||
pool, context->GetFenceWaiter()); | ||
BlitGenerateMipmapCommandVK cmd; | ||
cmd.texture = context->GetResourceAllocator()->CreateTexture({ | ||
.size = ISize(100, 100), | ||
.mip_count = 2, | ||
}); | ||
bool result = cmd.Encode(encoder); | ||
EXPECT_TRUE(result); | ||
EXPECT_TRUE(encoder.IsTracking(cmd.texture)); | ||
} | ||
|
||
} // namespace testing | ||
} // namespace impeller |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,12 @@ | |
|
||
namespace impeller { | ||
|
||
namespace testing { | ||
class BlitCommandVkTest_BlitCopyTextureToTextureCommandVK_Test; | ||
class BlitCommandVkTest_BlitCopyTextureToBufferCommandVK_Test; | ||
class BlitCommandVkTest_BlitGenerateMipmapCommandVK_Test; | ||
} // namespace testing | ||
|
||
class ContextVK; | ||
class DeviceBuffer; | ||
class Texture; | ||
|
@@ -35,8 +41,12 @@ class CommandEncoderVK { | |
|
||
bool Track(std::shared_ptr<const DeviceBuffer> buffer); | ||
|
||
bool IsTracking(const std::shared_ptr<const DeviceBuffer>& texture) const; | ||
|
||
bool Track(const std::shared_ptr<const Texture>& texture); | ||
|
||
bool IsTracking(const std::shared_ptr<const Texture>& texture) const; | ||
|
||
bool Track(std::shared_ptr<const TextureSourceVK> texture); | ||
|
||
vk::CommandBuffer GetCommandBuffer() const; | ||
|
@@ -52,6 +62,12 @@ class CommandEncoderVK { | |
|
||
private: | ||
friend class ContextVK; | ||
friend class ::impeller::testing:: | ||
BlitCommandVkTest_BlitCopyTextureToTextureCommandVK_Test; | ||
friend class ::impeller::testing:: | ||
BlitCommandVkTest_BlitCopyTextureToBufferCommandVK_Test; | ||
friend class ::impeller::testing:: | ||
BlitCommandVkTest_BlitGenerateMipmapCommandVK_Test; | ||
Comment on lines
+65
to
+70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should just make the constructor public? |
||
|
||
vk::Device device_ = {}; | ||
std::shared_ptr<QueueVK> queue_; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a tracking I missed until I wrote the test.