This repository has been 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] Add MockFence
to mock_vulkan
.
#45862
Closed
matanlurey
wants to merge
12
commits into
flutter:main
from
matanlurey:impeller-vk-mock-fence-injector
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2ff38d2
[Impeller] transitioned mock vulkan context to the builder pattern
gaaclarke 60b871d
made creating a context with validation layers work
gaaclarke 67e9055
added capabilties asserts
gaaclarke ba4bc1e
moved to fml thread_local
gaaclarke 004f79b
removed strcpy
gaaclarke da1aada
switched to strncpy
gaaclarke 630f915
moved to sizeof since its a bit more robust
gaaclarke 10b7cdc
Merge branch 'mock-vulkan-context-builder' of https://github.com/gaac…
matanlurey c89d30d
Add MockFence and MockFence::SetStatus.
matanlurey ce6a1c5
Remove unused code.
matanlurey 30ab4af
Merge to HEAD.
matanlurey d9d7cef
Remove dead code.
matanlurey 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 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 |
---|---|---|
|
@@ -4,10 +4,13 @@ | |
|
||
#include "impeller/renderer/backend/vulkan/test/mock_vulkan.h" | ||
#include <cstring> | ||
#include <utility> | ||
#include <vector> | ||
#include "fml/macros.h" | ||
#include "fml/thread_local.h" | ||
#include "impeller/base/thread_safety.h" | ||
#include "vulkan/vulkan_core.h" | ||
#include "vulkan/vulkan_enums.hpp" | ||
|
||
namespace impeller { | ||
namespace testing { | ||
|
@@ -410,7 +413,8 @@ VkResult vkCreateFence(VkDevice device, | |
const VkFenceCreateInfo* pCreateInfo, | ||
const VkAllocationCallbacks* pAllocator, | ||
VkFence* pFence) { | ||
*pFence = reinterpret_cast<VkFence>(0xfe0ce); | ||
MockDevice* mock_device = reinterpret_cast<MockDevice*>(device); | ||
*pFence = reinterpret_cast<VkFence>(new MockFence()); | ||
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. You need to add an override to |
||
return VK_SUCCESS; | ||
} | ||
|
||
|
@@ -430,7 +434,9 @@ VkResult vkWaitForFences(VkDevice device, | |
} | ||
|
||
VkResult vkGetFenceStatus(VkDevice device, VkFence fence) { | ||
return VK_SUCCESS; | ||
MockDevice* mock_device = reinterpret_cast<MockDevice*>(device); | ||
MockFence* mock_fence = reinterpret_cast<MockFence*>(fence); | ||
return mock_fence->GetStatus(); | ||
} | ||
|
||
VkResult vkCreateDebugUtilsMessengerEXT( | ||
|
This file contains 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 |
---|---|---|
|
@@ -5,17 +5,41 @@ | |
#pragma once | ||
|
||
#include <functional> | ||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "impeller/renderer/backend/vulkan/context_vk.h" | ||
#include "vulkan/vulkan_enums.hpp" | ||
|
||
namespace impeller { | ||
namespace testing { | ||
|
||
std::shared_ptr<std::vector<std::string>> GetMockVulkanFunctions( | ||
VkDevice device); | ||
|
||
// A test-controlled version of |vk::Fence|. | ||
class MockFence final { | ||
public: | ||
MockFence() = default; | ||
|
||
// Returns the result that was set in the constructor or |SetStatus|. | ||
VkResult GetStatus() { return static_cast<VkResult>(result_); } | ||
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. nit: I think vk::Status has cast operators to make this conversion implicit |
||
|
||
// Sets the result that will be returned by `GetFenceStatus`. | ||
static void SetStatus(vk::UniqueFence& fence, vk::Result result) { | ||
// Cast the fence to a MockFence and set the result. | ||
VkFence raw_fence = fence.get(); | ||
MockFence* mock_fence = reinterpret_cast<MockFence*>(raw_fence); | ||
mock_fence->result_ = result; | ||
} | ||
|
||
private: | ||
vk::Result result_ = vk::Result::eSuccess; | ||
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. You should make this atomic since potentially people are reading and writing from this at the same time. |
||
|
||
FML_DISALLOW_COPY_AND_ASSIGN(MockFence); | ||
}; | ||
|
||
class MockVulkanContextBuilder { | ||
public: | ||
MockVulkanContextBuilder(); | ||
|
This file contains 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
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.
mock_device
appears unused.