mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-23 15:03:43 +00:00
Make fence descriptor optional
Bug: dawn:22 Change-Id: I5d14aa8e12899eb577d7c50081a6ee6f7ec248a0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/21365 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
parent
a6cf7b5b1d
commit
a1800c04f3
@ -909,7 +909,7 @@
|
||||
"name": "create fence",
|
||||
"returns": "fence",
|
||||
"args": [
|
||||
{"name": "descriptor", "type": "fence descriptor", "annotation": "const*"}
|
||||
{"name": "descriptor", "type": "fence descriptor", "annotation": "const*", "optional": true}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -84,6 +84,10 @@ namespace dawn_native {
|
||||
return Fence::MakeError(GetDevice());
|
||||
}
|
||||
|
||||
if (descriptor == nullptr) {
|
||||
FenceDescriptor defaultDescriptor = {};
|
||||
return new Fence(this, &defaultDescriptor);
|
||||
}
|
||||
return new Fence(this, descriptor);
|
||||
}
|
||||
|
||||
@ -135,7 +139,9 @@ namespace dawn_native {
|
||||
MaybeError QueueBase::ValidateCreateFence(const FenceDescriptor* descriptor) {
|
||||
DAWN_TRY(GetDevice()->ValidateIsAlive());
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
DAWN_TRY(ValidateFenceDescriptor(descriptor));
|
||||
if (descriptor != nullptr) {
|
||||
DAWN_TRY(ValidateFenceDescriptor(descriptor));
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -331,8 +331,10 @@ namespace dawn_wire { namespace client {
|
||||
|
||||
Fence* fence = reinterpret_cast<Fence*>(cFence);
|
||||
fence->queue = queue;
|
||||
fence->signaledValue = descriptor->initialValue;
|
||||
fence->completedValue = descriptor->initialValue;
|
||||
|
||||
uint64_t initialValue = descriptor != nullptr ? descriptor->initialValue : 0u;
|
||||
fence->signaledValue = initialValue;
|
||||
fence->completedValue = initialValue;
|
||||
return cFence;
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,7 @@ TEST_P(FenceTests, SimpleSignal) {
|
||||
|
||||
// Test callbacks are called in increasing order of fence completion value
|
||||
TEST_P(FenceTests, OnCompletionOrdering) {
|
||||
wgpu::FenceDescriptor descriptor;
|
||||
descriptor.initialValue = 0u;
|
||||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
wgpu::Fence fence = queue.CreateFence();
|
||||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
@ -133,9 +131,7 @@ TEST_P(FenceTests, OnCompletionOrdering) {
|
||||
|
||||
// Test callbacks still occur if Queue::Signal happens multiple times
|
||||
TEST_P(FenceTests, MultipleSignalOnCompletion) {
|
||||
wgpu::FenceDescriptor descriptor;
|
||||
descriptor.initialValue = 0u;
|
||||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
wgpu::Fence fence = queue.CreateFence();
|
||||
|
||||
queue.Signal(fence, 2);
|
||||
queue.Signal(fence, 4);
|
||||
@ -149,9 +145,7 @@ TEST_P(FenceTests, MultipleSignalOnCompletion) {
|
||||
|
||||
// Test all callbacks are called if they are added for the same fence value
|
||||
TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
|
||||
wgpu::FenceDescriptor descriptor;
|
||||
descriptor.initialValue = 0u;
|
||||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
wgpu::Fence fence = queue.CreateFence();
|
||||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
@ -178,15 +172,11 @@ TEST_P(FenceTests, OnCompletionMultipleCallbacks) {
|
||||
// TODO(enga): Enable when fence is removed from fence signal tracker
|
||||
// Currently it holds a reference and is not destructed
|
||||
TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
|
||||
wgpu::FenceDescriptor descriptor;
|
||||
descriptor.initialValue = 0u;
|
||||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
wgpu::Fence fence = queue.CreateFence();
|
||||
|
||||
// The fence in this block will be deleted when it goes out of scope
|
||||
{
|
||||
wgpu::FenceDescriptor descriptor;
|
||||
descriptor.initialValue = 0u;
|
||||
wgpu::Fence testFence = queue.CreateFence(&descriptor);
|
||||
wgpu::Fence testFence = queue.CreateFence();
|
||||
|
||||
queue.Signal(testFence, 4);
|
||||
|
||||
@ -220,9 +210,7 @@ TEST_P(FenceTests, DISABLED_DestroyBeforeOnCompletionEnd) {
|
||||
// Regression test that validation errors that are tracked client-side are captured
|
||||
// in error scopes.
|
||||
TEST_P(FenceTests, ClientValidationErrorInErrorScope) {
|
||||
wgpu::FenceDescriptor descriptor;
|
||||
descriptor.initialValue = 0u;
|
||||
wgpu::Fence fence = queue.CreateFence(&descriptor);
|
||||
wgpu::Fence fence = queue.CreateFence();
|
||||
|
||||
queue.Signal(fence, 4);
|
||||
|
||||
|
@ -78,6 +78,12 @@ TEST_F(FenceValidationTest, CreationSuccess) {
|
||||
}
|
||||
}
|
||||
|
||||
// Creation succeeds if no descriptor is provided
|
||||
TEST_F(FenceValidationTest, DefaultDescriptor) {
|
||||
wgpu::Fence fence = queue.CreateFence();
|
||||
EXPECT_EQ(fence.GetCompletedValue(), 0u);
|
||||
}
|
||||
|
||||
TEST_F(FenceValidationTest, GetCompletedValue) {
|
||||
// Starts at initial value
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user