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

[Impeller] Add MockFence to mock_vulkan. #45862

Closed

Conversation

matanlurey
Copy link
Contributor

I admit I'm not sure how to do "stacked" PRs properly, so this will look goofy until @gaaclarke merges #45834.

I considered a few different ways to do this, but figured this gives maximum flexibility without needing a lot of API space.

Wdut?

/cc @jonahwilliams

@jonahwilliams
Copy link
Member

I think the way you would do this to make it reviewable is to set the branch to merge against to @gaaclarke 's branch, then change it back to main after that lands.

@matanlurey
Copy link
Contributor Author

matanlurey commented Sep 15, 2023

I think the way you would do this to make it reviewable is to set the branch to merge against to @gaaclarke 's branch, then change it back to main after that lands.

I tried that initially but couldn't see Aaron's branch in the list?

@jonahwilliams
Copy link
Member

Yeah I'm not sure if there is a way to set a forks branch in there though. You'd need to have a branch on flutter/engine

@matanlurey matanlurey self-assigned this Sep 15, 2023
@gaaclarke
Copy link
Member

I tried that initially but couldn't see Aaron's branch in the list?

You have to add my fork of the repo in your remotes. I have for example jonah's repo named so I can grab PR's from him before they have merged. At any rate that PR has landed now finally.

@matanlurey
Copy link
Contributor Author

I tried that initially but couldn't see Aaron's branch in the list?

You have to add my fork of the repo in your remotes. I have for example jonah's repo named so I can grab PR's from him before they have merged. At any rate that PR has landed now finally.

Thanks!

Merged and ready for review.

@matanlurey matanlurey marked this pull request as ready for review September 15, 2023 17:20
@matanlurey matanlurey changed the title [📚 STACKED] Add MockFence to mock_vulkan. [Impeller] Add MockFence to mock_vulkan. Sep 15, 2023
@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mock_device appears unused.

@@ -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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add an override to vkDestroyFence too so you aren't leaking these.

}

private:
vk::Result result_ = vk::Result::eSuccess;
Copy link
Member

Choose a reason for hiding this comment

The 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.

MockFence() = default;

// Returns the result that was set in the constructor or |SetStatus|.
VkResult GetStatus() { return static_cast<VkResult>(result_); }
Copy link
Member

Choose a reason for hiding this comment

The 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

@matanlurey
Copy link
Contributor Author

I wonder if I should just abandon this PR and merge it into #45870 since it has 2/3 of the suggestions you mentioned. @gaaclarke wdut?

@gaaclarke
Copy link
Member

I wonder if I should just abandon this PR and merge it into #45870 since it has 2/3 of the suggestions you mentioned. @gaaclarke wdut?

Whatever is easier for you. That PR doesn't look unwieldy yet.

@matanlurey
Copy link
Contributor Author

Sg, let's do that. Closing this one, thanks Aaron!

Replaced by #45870.

@matanlurey matanlurey closed this Sep 15, 2023
@matanlurey matanlurey deleted the impeller-vk-mock-fence-injector branch September 15, 2023 17:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants