mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-12 08:05:53 +00:00
If these extern variables are initialized after DAWN_INSTANTIATE_TEST, they will be zero. Change them to be function calls instead. Since they're function calls, fold in arguments from ForceToggles to enable/disable toggles. Bug: dawn:341 Change-Id: I1aeaa1e535a0a003977e8ce7ab3d5278c5d81281 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16162 Reviewed-by: Mark Henderson <mehe@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
62 lines
2.1 KiB
Plaintext
62 lines
2.1 KiB
Plaintext
// Copyright 2020 The Dawn Authors
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#include "tests/DawnTest.h"
|
|
|
|
#include "dawn_native/metal/DeviceMTL.h"
|
|
|
|
using namespace dawn_native::metal;
|
|
|
|
class MetalAutoreleasePoolTests : public DawnTest {
|
|
private:
|
|
void TestSetUp() override {
|
|
DAWN_SKIP_TEST_IF(UsesWire());
|
|
|
|
mMtlDevice = reinterpret_cast<Device*>(device.Get());
|
|
}
|
|
|
|
protected:
|
|
Device* mMtlDevice = nullptr;
|
|
};
|
|
|
|
// Test that the MTLCommandBuffer owned by the pending command context can
|
|
// outlive an autoreleasepool block.
|
|
TEST_P(MetalAutoreleasePoolTests, CommandBufferOutlivesAutorelease) {
|
|
@autoreleasepool {
|
|
// Get the recording context which will allocate a MTLCommandBuffer.
|
|
// It will get autoreleased at the end of this block.
|
|
mMtlDevice->GetPendingCommandContext();
|
|
}
|
|
|
|
// Submitting the command buffer should succeed.
|
|
mMtlDevice->SubmitPendingCommandBuffer();
|
|
}
|
|
|
|
// Test that the MTLBlitCommandEncoder owned by the pending command context
|
|
// can outlive an autoreleasepool block.
|
|
TEST_P(MetalAutoreleasePoolTests, EncoderOutlivesAutorelease) {
|
|
@autoreleasepool {
|
|
// Get the recording context which will allocate a MTLCommandBuffer.
|
|
// Begin a blit encoder.
|
|
// Both will get autoreleased at the end of this block.
|
|
mMtlDevice->GetPendingCommandContext()->EnsureBlit();
|
|
}
|
|
|
|
// Submitting the command buffer should succeed.
|
|
mMtlDevice->GetPendingCommandContext()->EndBlit();
|
|
mMtlDevice->SubmitPendingCommandBuffer();
|
|
}
|
|
|
|
DAWN_INSTANTIATE_TEST(MetalAutoreleasePoolTests, MetalBackend());
|