Commit 736e31b6 authored by Dana Fried's avatar Dana Fried

Revert "Metal: Run test shaders on a ThreadPriority::DISPLAY thread"

This reverts commit 16307825.

Reason for revert: crashes in tests on Mac Release (Intel) - see attached bug for information

Bug: 1082966

Original change's description:
> Metal: Run test shaders on a ThreadPriority::DISPLAY thread
> 
> The Metal test shaders are compiled in a function that comes from
> a PostTask.  There is currently no path through which a PostTask
> will end up running on a ThreadPriority::DISPLAY thread.
> 
> Change the Metal test code to create a ThreadPriority::DISPLAY
> thread and do its work there. A separate change is making that
> correspond to a pthread priority of 50.
> 
> Of note is that Metal's callback to Chrome comes from a Metal-created
> thread which has priority 31.
> 
> Also change the default test shader to be a Compile instead of a
> Link (the Link tests have not been completed).
> 
> Bug: 974219
> Change-Id: Ieb5ab0748b3aa255ee7dd3348870ddf812caa682
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2200357
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Commit-Queue: ccameron <ccameron@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#768962}

TBR=avi@chromium.org,ccameron@chromium.org

Change-Id: I852346697048fc916711ea60dd050b646a53705c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 974219
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2203257Reviewed-by: default avatarDana Fried <dfried@google.com>
Cr-Commit-Position: refs/heads/master@{#768986}
parent c383f891
......@@ -59,7 +59,7 @@ void METAL_UTIL_EXPORT
TestShader(TestShaderCallback callback,
const base::TimeDelta& delay = kTestShaderDelay,
const base::TimeDelta& timeout = kTestShaderTimeout,
TestShaderComponent component = TestShaderComponent::kCompile);
TestShaderComponent component = TestShaderComponent::kLink);
} // namespace metal
......
......@@ -710,43 +710,16 @@ void TestRenderPipelineStateNow(base::scoped_nsprotocol<id<MTLDevice>> device,
state->OnMethodCompleted();
}
class API_AVAILABLE(macos(10.11)) TestShaderThread
: public base::PlatformThread::Delegate {
public:
static void Create(base::scoped_nsprotocol<id<MTLDevice>> device,
const base::TimeDelta& timeout,
TestShaderCallback callback) {
// |instance| will be destroyed when its shader compilation completes.
auto* instance = new TestShaderThread;
instance->device_ = device;
instance->timeout_ = timeout;
instance->callback_ = std::move(callback);
base::PlatformThreadHandle thread_handle;
base::PlatformThread::CreateWithPriority(0, instance, &thread_handle,
base::ThreadPriority::DISPLAY);
base::PlatformThread::Detach(thread_handle);
}
private:
TestShaderThread() = default;
~TestShaderThread() override = default;
// base::PlatformThread::Delegate:
void ThreadMain() final;
base::scoped_nsprotocol<id<MTLDevice>> device_;
base::TimeDelta timeout_;
TestShaderCallback callback_;
};
void TestShaderThread::ThreadMain() {
void TestShaderNow(base::scoped_nsprotocol<id<MTLDevice>> device,
const base::TimeDelta& timeout,
TestShaderCallback callback) API_AVAILABLE(macos(10.11)) {
// Initialize the TestShaderState and post the timeout callback, before
// calling into the Metal API.
auto state =
base::MakeRefCounted<TestShaderState>(std::move(callback_), timeout_);
base::MakeRefCounted<TestShaderState>(std::move(callback), timeout);
base::ThreadPool::PostDelayedTask(
FROM_HERE, {}, base::BindOnce(&TestShaderState::OnTimeout, state),
timeout_);
timeout);
const std::string shader_source =
base::StringPrintf(kTestShaderSource, base::RandDouble());
......@@ -766,20 +739,13 @@ void TestShaderThread::ThreadMain() {
}
state->OnCompletionHandlerCalled(library ? TestShaderResult::kSucceeded
: TestShaderResult::kFailed);
delete this;
};
[device_ newLibraryWithSource:source
options:options
completionHandler:completion_handler];
[device newLibraryWithSource:source
options:options
completionHandler:completion_handler];
state->OnMethodCompleted();
}
void TestShaderNow(base::scoped_nsprotocol<id<MTLDevice>> device,
const base::TimeDelta& timeout,
TestShaderCallback callback) API_AVAILABLE(macos(10.11)) {
TestShaderThread::Create(device, timeout, std::move(callback));
}
} // namespace
void TestShader(TestShaderCallback callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment