Avoid redundant creation of ComputePipelineBase in GetCachedComputePipeline
This patch removes a redundant creation of ComputePipelineBase object in GetCachedComputePipeline(). Instead, we directly compute the blueprint hash from the uninitialized backend compute pipeline object. BUG=dawn:529 TEST=dawn_end2end_tests Change-Id: I9b982664aa140ab385418a202270b9988cfcb9f3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/66221 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
parent
d174cef8fa
commit
8fd1eb5443
|
@ -46,6 +46,7 @@ namespace dawn_native {
|
||||||
{{SingleShaderStage::Compute, descriptor->compute.module,
|
{{SingleShaderStage::Compute, descriptor->compute.module,
|
||||||
descriptor->compute.entryPoint, descriptor->compute.constantCount,
|
descriptor->compute.entryPoint, descriptor->compute.constantCount,
|
||||||
descriptor->compute.constants}}) {
|
descriptor->compute.constants}}) {
|
||||||
|
SetContentHash(ComputeContentHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputePipelineBase::ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
ComputePipelineBase::ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
||||||
|
@ -59,13 +60,21 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ComputePipelineBase::Initialize() {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) {
|
ComputePipelineBase* ComputePipelineBase::MakeError(DeviceBase* device) {
|
||||||
return new ComputePipelineBase(device, ObjectBase::kError);
|
class ErrorComputePipeline final : public ComputePipelineBase {
|
||||||
|
public:
|
||||||
|
ErrorComputePipeline(DeviceBase* device)
|
||||||
|
: ComputePipelineBase(device, ObjectBase::kError) {
|
||||||
|
}
|
||||||
|
|
||||||
|
MaybeError Initialize() override {
|
||||||
|
UNREACHABLE();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return new ErrorComputePipeline(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectType ComputePipelineBase::GetType() const {
|
ObjectType ComputePipelineBase::GetType() const {
|
||||||
|
|
|
@ -43,11 +43,6 @@ namespace dawn_native {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
ComputePipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||||
|
|
||||||
// CreateComputePipelineAsyncTask is declared as a friend of ComputePipelineBase as it
|
|
||||||
// needs to call the private member function ComputePipelineBase::Initialize().
|
|
||||||
friend class CreateComputePipelineAsyncTask;
|
|
||||||
virtual MaybeError Initialize();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dawn_native
|
} // namespace dawn_native
|
||||||
|
|
|
@ -103,11 +103,9 @@ namespace dawn_native {
|
||||||
|
|
||||||
CreateComputePipelineAsyncTask::CreateComputePipelineAsyncTask(
|
CreateComputePipelineAsyncTask::CreateComputePipelineAsyncTask(
|
||||||
Ref<ComputePipelineBase> nonInitializedComputePipeline,
|
Ref<ComputePipelineBase> nonInitializedComputePipeline,
|
||||||
size_t blueprintHash,
|
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata)
|
void* userdata)
|
||||||
: mComputePipeline(std::move(nonInitializedComputePipeline)),
|
: mComputePipeline(std::move(nonInitializedComputePipeline)),
|
||||||
mBlueprintHash(blueprintHash),
|
|
||||||
mCallback(callback),
|
mCallback(callback),
|
||||||
mUserdata(userdata) {
|
mUserdata(userdata) {
|
||||||
ASSERT(mComputePipeline != nullptr);
|
ASSERT(mComputePipeline != nullptr);
|
||||||
|
@ -122,7 +120,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
mComputePipeline->GetDevice()->AddComputePipelineAsyncCallbackTask(
|
mComputePipeline->GetDevice()->AddComputePipelineAsyncCallbackTask(
|
||||||
mComputePipeline, errorMessage, mCallback, mUserdata, mBlueprintHash);
|
mComputePipeline, errorMessage, mCallback, mUserdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateComputePipelineAsyncTask::RunAsync(
|
void CreateComputePipelineAsyncTask::RunAsync(
|
||||||
|
|
|
@ -72,7 +72,6 @@ namespace dawn_native {
|
||||||
class CreateComputePipelineAsyncTask {
|
class CreateComputePipelineAsyncTask {
|
||||||
public:
|
public:
|
||||||
CreateComputePipelineAsyncTask(Ref<ComputePipelineBase> nonInitializedComputePipeline,
|
CreateComputePipelineAsyncTask(Ref<ComputePipelineBase> nonInitializedComputePipeline,
|
||||||
size_t blueprintHash,
|
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
|
|
||||||
|
@ -82,7 +81,6 @@ namespace dawn_native {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ref<ComputePipelineBase> mComputePipeline;
|
Ref<ComputePipelineBase> mComputePipeline;
|
||||||
size_t mBlueprintHash;
|
|
||||||
WGPUCreateComputePipelineAsyncCallback mCallback;
|
WGPUCreateComputePipelineAsyncCallback mCallback;
|
||||||
void* mUserdata;
|
void* mUserdata;
|
||||||
};
|
};
|
||||||
|
|
|
@ -678,20 +678,15 @@ namespace dawn_native {
|
||||||
return mEmptyBindGroupLayout.Get();
|
return mEmptyBindGroupLayout.Get();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Ref<ComputePipelineBase>, size_t> DeviceBase::GetCachedComputePipeline(
|
Ref<ComputePipelineBase> DeviceBase::GetCachedComputePipeline(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
ComputePipelineBase* uninitializedComputePipeline) {
|
||||||
ComputePipelineBase blueprint(this, descriptor);
|
Ref<ComputePipelineBase> cachedPipeline;
|
||||||
|
auto iter = mCaches->computePipelines.find(uninitializedComputePipeline);
|
||||||
const size_t blueprintHash = blueprint.ComputeContentHash();
|
|
||||||
blueprint.SetContentHash(blueprintHash);
|
|
||||||
|
|
||||||
Ref<ComputePipelineBase> result;
|
|
||||||
auto iter = mCaches->computePipelines.find(&blueprint);
|
|
||||||
if (iter != mCaches->computePipelines.end()) {
|
if (iter != mCaches->computePipelines.end()) {
|
||||||
result = *iter;
|
cachedPipeline = *iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_pair(result, blueprintHash);
|
return cachedPipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<RenderPipelineBase> DeviceBase::GetCachedRenderPipeline(
|
Ref<RenderPipelineBase> DeviceBase::GetCachedRenderPipeline(
|
||||||
|
@ -705,9 +700,7 @@ namespace dawn_native {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ComputePipelineBase> DeviceBase::AddOrGetCachedComputePipeline(
|
Ref<ComputePipelineBase> DeviceBase::AddOrGetCachedComputePipeline(
|
||||||
Ref<ComputePipelineBase> computePipeline,
|
Ref<ComputePipelineBase> computePipeline) {
|
||||||
size_t blueprintHash) {
|
|
||||||
computePipeline->SetContentHash(blueprintHash);
|
|
||||||
auto insertion = mCaches->computePipelines.insert(computePipeline.Get());
|
auto insertion = mCaches->computePipelines.insert(computePipeline.Get());
|
||||||
if (insertion.second) {
|
if (insertion.second) {
|
||||||
computePipeline->SetIsCachedReference();
|
computePipeline->SetIsCachedReference();
|
||||||
|
@ -1226,15 +1219,16 @@ namespace dawn_native {
|
||||||
DAWN_TRY_ASSIGN(layoutRef, ValidateLayoutAndGetComputePipelineDescriptorWithDefaults(
|
DAWN_TRY_ASSIGN(layoutRef, ValidateLayoutAndGetComputePipelineDescriptorWithDefaults(
|
||||||
this, *descriptor, &appliedDescriptor));
|
this, *descriptor, &appliedDescriptor));
|
||||||
|
|
||||||
auto pipelineAndBlueprintFromCache = GetCachedComputePipeline(&appliedDescriptor);
|
Ref<ComputePipelineBase> uninitializedComputePipeline =
|
||||||
if (pipelineAndBlueprintFromCache.first.Get() != nullptr) {
|
CreateUninitializedComputePipelineImpl(&appliedDescriptor);
|
||||||
return std::move(pipelineAndBlueprintFromCache.first);
|
Ref<ComputePipelineBase> cachedComputePipeline =
|
||||||
|
GetCachedComputePipeline(uninitializedComputePipeline.Get());
|
||||||
|
if (cachedComputePipeline.Get() != nullptr) {
|
||||||
|
return cachedComputePipeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<ComputePipelineBase> backendObj;
|
DAWN_TRY(uninitializedComputePipeline->Initialize());
|
||||||
DAWN_TRY_ASSIGN(backendObj, CreateComputePipelineImpl(&appliedDescriptor));
|
return AddOrGetCachedComputePipeline(std::move(uninitializedComputePipeline));
|
||||||
size_t blueprintHash = pipelineAndBlueprintFromCache.second;
|
|
||||||
return AddOrGetCachedComputePipeline(backendObj, blueprintHash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError DeviceBase::CreateComputePipelineAsync(
|
MaybeError DeviceBase::CreateComputePipelineAsync(
|
||||||
|
@ -1251,38 +1245,42 @@ namespace dawn_native {
|
||||||
DAWN_TRY_ASSIGN(layoutRef, ValidateLayoutAndGetComputePipelineDescriptorWithDefaults(
|
DAWN_TRY_ASSIGN(layoutRef, ValidateLayoutAndGetComputePipelineDescriptorWithDefaults(
|
||||||
this, *descriptor, &appliedDescriptor));
|
this, *descriptor, &appliedDescriptor));
|
||||||
|
|
||||||
|
Ref<ComputePipelineBase> uninitializedComputePipeline =
|
||||||
|
CreateUninitializedComputePipelineImpl(&appliedDescriptor);
|
||||||
|
|
||||||
// Call the callback directly when we can get a cached compute pipeline object.
|
// Call the callback directly when we can get a cached compute pipeline object.
|
||||||
auto pipelineAndBlueprintFromCache = GetCachedComputePipeline(&appliedDescriptor);
|
Ref<ComputePipelineBase> cachedComputePipeline =
|
||||||
if (pipelineAndBlueprintFromCache.first.Get() != nullptr) {
|
GetCachedComputePipeline(uninitializedComputePipeline.Get());
|
||||||
Ref<ComputePipelineBase> result = std::move(pipelineAndBlueprintFromCache.first);
|
if (cachedComputePipeline.Get() != nullptr) {
|
||||||
callback(WGPUCreatePipelineAsyncStatus_Success,
|
callback(WGPUCreatePipelineAsyncStatus_Success,
|
||||||
reinterpret_cast<WGPUComputePipeline>(result.Detach()), "", userdata);
|
reinterpret_cast<WGPUComputePipeline>(cachedComputePipeline.Detach()), "",
|
||||||
|
userdata);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise we will create the pipeline object in CreateComputePipelineAsyncImpl(),
|
// Otherwise we will create the pipeline object in InitializeComputePipelineAsyncImpl(),
|
||||||
// where the pipeline object may be created asynchronously and the result will be saved
|
// where the pipeline object may be initialized asynchronously and the result will be
|
||||||
// to mCreatePipelineAsyncTracker.
|
// saved to mCreatePipelineAsyncTracker.
|
||||||
const size_t blueprintHash = pipelineAndBlueprintFromCache.second;
|
InitializeComputePipelineAsyncImpl(std::move(uninitializedComputePipeline), callback,
|
||||||
CreateComputePipelineAsyncImpl(&appliedDescriptor, blueprintHash, callback, userdata);
|
userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is overwritten with the async version on the backends that supports creating
|
// This function is overwritten with the async version on the backends that supports
|
||||||
// compute pipeline asynchronously.
|
// initializing compute pipelines asynchronously.
|
||||||
void DeviceBase::CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
void DeviceBase::InitializeComputePipelineAsyncImpl(
|
||||||
size_t blueprintHash,
|
Ref<ComputePipelineBase> computePipeline,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
Ref<ComputePipelineBase> result;
|
Ref<ComputePipelineBase> result;
|
||||||
std::string errorMessage;
|
std::string errorMessage;
|
||||||
|
|
||||||
auto resultOrError = CreateComputePipelineImpl(descriptor);
|
MaybeError maybeError = computePipeline->Initialize();
|
||||||
if (resultOrError.IsError()) {
|
if (maybeError.IsError()) {
|
||||||
std::unique_ptr<ErrorData> error = resultOrError.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
errorMessage = error->GetMessage();
|
errorMessage = error->GetMessage();
|
||||||
} else {
|
} else {
|
||||||
result = AddOrGetCachedComputePipeline(resultOrError.AcquireSuccess(), blueprintHash);
|
result = AddOrGetCachedComputePipeline(std::move(computePipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CreateComputePipelineAsyncCallbackTask> callbackTask =
|
std::unique_ptr<CreateComputePipelineAsyncCallbackTask> callbackTask =
|
||||||
|
@ -1305,7 +1303,7 @@ namespace dawn_native {
|
||||||
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
std::unique_ptr<ErrorData> error = maybeError.AcquireError();
|
||||||
errorMessage = error->GetMessage();
|
errorMessage = error->GetMessage();
|
||||||
} else {
|
} else {
|
||||||
result = AddOrGetCachedRenderPipeline(renderPipeline);
|
result = AddOrGetCachedRenderPipeline(std::move(renderPipeline));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<CreateRenderPipelineAsyncCallbackTask> callbackTask =
|
std::unique_ptr<CreateRenderPipelineAsyncCallbackTask> callbackTask =
|
||||||
|
@ -1367,7 +1365,7 @@ namespace dawn_native {
|
||||||
this, *descriptor, &appliedDescriptor));
|
this, *descriptor, &appliedDescriptor));
|
||||||
|
|
||||||
Ref<RenderPipelineBase> uninitializedRenderPipeline =
|
Ref<RenderPipelineBase> uninitializedRenderPipeline =
|
||||||
CreateUninitializedRenderPipeline(&appliedDescriptor);
|
CreateUninitializedRenderPipelineImpl(&appliedDescriptor);
|
||||||
|
|
||||||
Ref<RenderPipelineBase> cachedRenderPipeline =
|
Ref<RenderPipelineBase> cachedRenderPipeline =
|
||||||
GetCachedRenderPipeline(uninitializedRenderPipeline.Get());
|
GetCachedRenderPipeline(uninitializedRenderPipeline.Get());
|
||||||
|
@ -1395,7 +1393,7 @@ namespace dawn_native {
|
||||||
this, *descriptor, &appliedDescriptor));
|
this, *descriptor, &appliedDescriptor));
|
||||||
|
|
||||||
Ref<RenderPipelineBase> uninitializedRenderPipeline =
|
Ref<RenderPipelineBase> uninitializedRenderPipeline =
|
||||||
CreateUninitializedRenderPipeline(&appliedDescriptor);
|
CreateUninitializedRenderPipelineImpl(&appliedDescriptor);
|
||||||
|
|
||||||
// Call the callback directly when we can get a cached render pipeline object.
|
// Call the callback directly when we can get a cached render pipeline object.
|
||||||
Ref<RenderPipelineBase> cachedRenderPipeline =
|
Ref<RenderPipelineBase> cachedRenderPipeline =
|
||||||
|
@ -1578,53 +1576,31 @@ namespace dawn_native {
|
||||||
return mWorkerTaskPool.get();
|
return mWorkerTaskPool.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<RenderPipelineBase> DeviceBase::CreateUninitializedRenderPipeline(
|
|
||||||
const RenderPipelineDescriptor* descriptor) {
|
|
||||||
return CreateUninitializedRenderPipelineImpl(descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
void DeviceBase::AddComputePipelineAsyncCallbackTask(
|
||||||
Ref<ComputePipelineBase> pipeline,
|
Ref<ComputePipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata,
|
void* userdata) {
|
||||||
size_t blueprintHash) {
|
|
||||||
// CreateComputePipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
// CreateComputePipelineAsyncWaitableCallbackTask is declared as an internal class as it
|
||||||
// needs to call the private member function DeviceBase::AddOrGetCachedComputePipeline().
|
// needs to call the private member function DeviceBase::AddOrGetCachedComputePipeline().
|
||||||
struct CreateComputePipelineAsyncWaitableCallbackTask final
|
struct CreateComputePipelineAsyncWaitableCallbackTask final
|
||||||
: CreateComputePipelineAsyncCallbackTask {
|
: CreateComputePipelineAsyncCallbackTask {
|
||||||
CreateComputePipelineAsyncWaitableCallbackTask(
|
using CreateComputePipelineAsyncCallbackTask::CreateComputePipelineAsyncCallbackTask;
|
||||||
Ref<ComputePipelineBase> pipeline,
|
|
||||||
std::string errorMessage,
|
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata,
|
|
||||||
size_t blueprintHash)
|
|
||||||
: CreateComputePipelineAsyncCallbackTask(std::move(pipeline),
|
|
||||||
errorMessage,
|
|
||||||
callback,
|
|
||||||
userdata),
|
|
||||||
mBlueprintHash(blueprintHash) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void Finish() final {
|
void Finish() final {
|
||||||
// TODO(dawn:529): call AddOrGetCachedComputePipeline() asynchronously in
|
// TODO(dawn:529): call AddOrGetCachedComputePipeline() asynchronously in
|
||||||
// CreateComputePipelineAsyncTaskImpl::Run() when the front-end pipeline cache is
|
// CreateComputePipelineAsyncTaskImpl::Run() when the front-end pipeline cache is
|
||||||
// thread-safe.
|
// thread-safe.
|
||||||
if (mPipeline.Get() != nullptr) {
|
if (mPipeline.Get() != nullptr) {
|
||||||
mPipeline = mPipeline->GetDevice()->AddOrGetCachedComputePipeline(
|
mPipeline = mPipeline->GetDevice()->AddOrGetCachedComputePipeline(mPipeline);
|
||||||
mPipeline, mBlueprintHash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateComputePipelineAsyncCallbackTask::Finish();
|
CreateComputePipelineAsyncCallbackTask::Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
size_t mBlueprintHash;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mCallbackTaskManager->AddCallbackTask(
|
mCallbackTaskManager->AddCallbackTask(
|
||||||
std::make_unique<CreateComputePipelineAsyncWaitableCallbackTask>(
|
std::make_unique<CreateComputePipelineAsyncWaitableCallbackTask>(
|
||||||
std::move(pipeline), errorMessage, callback, userdata, blueprintHash));
|
std::move(pipeline), errorMessage, callback, userdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceBase::AddRenderPipelineAsyncCallbackTask(
|
void DeviceBase::AddRenderPipelineAsyncCallbackTask(
|
||||||
|
|
|
@ -342,8 +342,7 @@ namespace dawn_native {
|
||||||
void AddComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
void AddComputePipelineAsyncCallbackTask(Ref<ComputePipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata,
|
void* userdata);
|
||||||
size_t blueprintHash);
|
|
||||||
void AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
void AddRenderPipelineAsyncCallbackTask(Ref<RenderPipelineBase> pipeline,
|
||||||
std::string errorMessage,
|
std::string errorMessage,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
|
@ -376,14 +375,10 @@ namespace dawn_native {
|
||||||
PipelineCompatibilityToken pipelineCompatibilityToken) = 0;
|
PipelineCompatibilityToken pipelineCompatibilityToken) = 0;
|
||||||
virtual ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
virtual ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
||||||
const BufferDescriptor* descriptor) = 0;
|
const BufferDescriptor* descriptor) = 0;
|
||||||
virtual ResultOrError<Ref<ComputePipelineBase>> CreateComputePipelineImpl(
|
|
||||||
const ComputePipelineDescriptor* descriptor) = 0;
|
|
||||||
virtual ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
virtual ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) = 0;
|
const PipelineLayoutDescriptor* descriptor) = 0;
|
||||||
virtual ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
virtual ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
||||||
const QuerySetDescriptor* descriptor) = 0;
|
const QuerySetDescriptor* descriptor) = 0;
|
||||||
virtual Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
|
||||||
const RenderPipelineDescriptor* descriptor) = 0;
|
|
||||||
virtual ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
virtual ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
||||||
const SamplerDescriptor* descriptor) = 0;
|
const SamplerDescriptor* descriptor) = 0;
|
||||||
virtual ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
virtual ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
||||||
|
@ -401,6 +396,10 @@ namespace dawn_native {
|
||||||
virtual ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
virtual ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
TextureBase* texture,
|
TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor) = 0;
|
const TextureViewDescriptor* descriptor) = 0;
|
||||||
|
virtual Ref<ComputePipelineBase> CreateUninitializedComputePipelineImpl(
|
||||||
|
const ComputePipelineDescriptor* descriptor) = 0;
|
||||||
|
virtual Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
||||||
|
const RenderPipelineDescriptor* descriptor) = 0;
|
||||||
virtual void SetLabelImpl();
|
virtual void SetLabelImpl();
|
||||||
|
|
||||||
virtual MaybeError TickImpl() = 0;
|
virtual MaybeError TickImpl() = 0;
|
||||||
|
@ -408,21 +407,18 @@ namespace dawn_native {
|
||||||
|
|
||||||
ResultOrError<Ref<BindGroupLayoutBase>> CreateEmptyBindGroupLayout();
|
ResultOrError<Ref<BindGroupLayoutBase>> CreateEmptyBindGroupLayout();
|
||||||
|
|
||||||
std::pair<Ref<ComputePipelineBase>, size_t> GetCachedComputePipeline(
|
Ref<ComputePipelineBase> GetCachedComputePipeline(
|
||||||
const ComputePipelineDescriptor* descriptor);
|
ComputePipelineBase* uninitializedComputePipeline);
|
||||||
Ref<RenderPipelineBase> GetCachedRenderPipeline(
|
Ref<RenderPipelineBase> GetCachedRenderPipeline(
|
||||||
RenderPipelineBase* uninitializedRenderPipeline);
|
RenderPipelineBase* uninitializedRenderPipeline);
|
||||||
Ref<ComputePipelineBase> AddOrGetCachedComputePipeline(
|
Ref<ComputePipelineBase> AddOrGetCachedComputePipeline(
|
||||||
Ref<ComputePipelineBase> computePipeline,
|
Ref<ComputePipelineBase> computePipeline);
|
||||||
size_t blueprintHash);
|
|
||||||
Ref<RenderPipelineBase> AddOrGetCachedRenderPipeline(
|
Ref<RenderPipelineBase> AddOrGetCachedRenderPipeline(
|
||||||
Ref<RenderPipelineBase> renderPipeline);
|
Ref<RenderPipelineBase> renderPipeline);
|
||||||
virtual void CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
virtual void InitializeComputePipelineAsyncImpl(
|
||||||
size_t blueprintHash,
|
Ref<ComputePipelineBase> computePipeline,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
void* userdata);
|
void* userdata);
|
||||||
Ref<RenderPipelineBase> CreateUninitializedRenderPipeline(
|
|
||||||
const RenderPipelineDescriptor* descriptor);
|
|
||||||
virtual void InitializeRenderPipelineAsyncImpl(
|
virtual void InitializeRenderPipelineAsyncImpl(
|
||||||
Ref<RenderPipelineBase> renderPipeline,
|
Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
|
|
|
@ -66,6 +66,9 @@ namespace dawn_native {
|
||||||
// Implementation of the API entrypoint. Do not use in a reentrant manner.
|
// Implementation of the API entrypoint. Do not use in a reentrant manner.
|
||||||
BindGroupLayoutBase* APIGetBindGroupLayout(uint32_t groupIndex);
|
BindGroupLayoutBase* APIGetBindGroupLayout(uint32_t groupIndex);
|
||||||
|
|
||||||
|
// Initialize() should only be called once by the frontend.
|
||||||
|
virtual MaybeError Initialize() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PipelineBase(DeviceBase* device,
|
PipelineBase(DeviceBase* device,
|
||||||
PipelineLayoutBase* layout,
|
PipelineLayoutBase* layout,
|
||||||
|
|
|
@ -105,9 +105,6 @@ namespace dawn_native {
|
||||||
bool operator()(const RenderPipelineBase* a, const RenderPipelineBase* b) const;
|
bool operator()(const RenderPipelineBase* a, const RenderPipelineBase* b) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize() should only be called once by the frontend.
|
|
||||||
virtual MaybeError Initialize() = 0;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RenderPipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
RenderPipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,10 @@
|
||||||
|
|
||||||
namespace dawn_native { namespace d3d12 {
|
namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
ResultOrError<Ref<ComputePipeline>> ComputePipeline::Create(
|
Ref<ComputePipeline> ComputePipeline::CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
return AcquireRef(new ComputePipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize());
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ComputePipeline::Initialize() {
|
MaybeError ComputePipeline::Initialize() {
|
||||||
|
@ -77,14 +75,11 @@ namespace dawn_native { namespace d3d12 {
|
||||||
GetLabel());
|
GetLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePipeline::CreateAsync(Device* device,
|
void ComputePipeline::InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||||
const ComputePipelineDescriptor* descriptor,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
size_t blueprintHash,
|
void* userdata) {
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata) {
|
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
|
||||||
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
||||||
std::make_unique<CreateComputePipelineAsyncTask>(pipeline, blueprintHash, callback,
|
std::make_unique<CreateComputePipelineAsyncTask>(std::move(computePipeline), callback,
|
||||||
userdata);
|
userdata);
|
||||||
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
|
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,25 +25,24 @@ namespace dawn_native { namespace d3d12 {
|
||||||
|
|
||||||
class ComputePipeline final : public ComputePipelineBase {
|
class ComputePipeline final : public ComputePipelineBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<ComputePipeline>> Create(
|
static Ref<ComputePipeline> CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor);
|
const ComputePipelineDescriptor* descriptor);
|
||||||
static void CreateAsync(Device* device,
|
static void InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||||
const ComputePipelineDescriptor* descriptor,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
size_t blueprintHash,
|
void* userdata);
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
ComputePipeline() = delete;
|
ComputePipeline() = delete;
|
||||||
|
|
||||||
ID3D12PipelineState* GetPipelineState() const;
|
ID3D12PipelineState* GetPipelineState() const;
|
||||||
|
|
||||||
|
MaybeError Initialize() override;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void SetLabelImpl() override;
|
void SetLabelImpl() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
MaybeError Initialize() override;
|
|
||||||
ComPtr<ID3D12PipelineState> mPipelineState;
|
ComPtr<ID3D12PipelineState> mPipelineState;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -334,9 +334,9 @@ namespace dawn_native { namespace d3d12 {
|
||||||
const CommandBufferDescriptor* descriptor) {
|
const CommandBufferDescriptor* descriptor) {
|
||||||
return CommandBuffer::Create(encoder, descriptor);
|
return CommandBuffer::Create(encoder, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<ComputePipelineBase>> Device::CreateComputePipelineImpl(
|
Ref<ComputePipelineBase> Device::CreateUninitializedComputePipelineImpl(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
return ComputePipeline::Create(this, descriptor);
|
return ComputePipeline::CreateUninitialized(this, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) {
|
const PipelineLayoutDescriptor* descriptor) {
|
||||||
|
@ -376,16 +376,15 @@ namespace dawn_native { namespace d3d12 {
|
||||||
const TextureViewDescriptor* descriptor) {
|
const TextureViewDescriptor* descriptor) {
|
||||||
return TextureView::Create(texture, descriptor);
|
return TextureView::Create(texture, descriptor);
|
||||||
}
|
}
|
||||||
void Device::CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
void Device::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
size_t blueprintHash,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
void* userdata) {
|
||||||
void* userdata) {
|
ComputePipeline::InitializeAsync(std::move(computePipeline), callback, userdata);
|
||||||
ComputePipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata);
|
|
||||||
}
|
}
|
||||||
void Device::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void Device::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
RenderPipeline::InitializeAsync(renderPipeline, callback, userdata);
|
RenderPipeline::InitializeAsync(std::move(renderPipeline), callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<std::unique_ptr<StagingBufferBase>> Device::CreateStagingBuffer(size_t size) {
|
ResultOrError<std::unique_ptr<StagingBufferBase>> Device::CreateStagingBuffer(size_t size) {
|
||||||
|
|
|
@ -149,14 +149,10 @@ namespace dawn_native { namespace d3d12 {
|
||||||
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
||||||
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
||||||
const BufferDescriptor* descriptor) override;
|
const BufferDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ComputePipelineBase>> CreateComputePipelineImpl(
|
|
||||||
const ComputePipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) override;
|
const PipelineLayoutDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
||||||
const QuerySetDescriptor* descriptor) override;
|
const QuerySetDescriptor* descriptor) override;
|
||||||
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
|
||||||
const RenderPipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
||||||
const SamplerDescriptor* descriptor) override;
|
const SamplerDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
||||||
|
@ -173,10 +169,13 @@ namespace dawn_native { namespace d3d12 {
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
TextureBase* texture,
|
TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor) override;
|
const TextureViewDescriptor* descriptor) override;
|
||||||
void CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
Ref<ComputePipelineBase> CreateUninitializedComputePipelineImpl(
|
||||||
size_t blueprintHash,
|
const ComputePipelineDescriptor* descriptor) override;
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
||||||
void* userdata) override;
|
const RenderPipelineDescriptor* descriptor) override;
|
||||||
|
void InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata) override;
|
||||||
void InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) override;
|
void* userdata) override;
|
||||||
|
|
|
@ -27,14 +27,12 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
class ComputePipeline final : public ComputePipelineBase {
|
class ComputePipeline final : public ComputePipelineBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<ComputePipeline>> Create(
|
static Ref<ComputePipeline> CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor);
|
const ComputePipelineDescriptor* descriptor);
|
||||||
static void CreateAsync(Device* device,
|
static void InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||||
const ComputePipelineDescriptor* descriptor,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
size_t blueprintHash,
|
void* userdata);
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
|
|
||||||
void Encode(id<MTLComputeCommandEncoder> encoder);
|
void Encode(id<MTLComputeCommandEncoder> encoder);
|
||||||
MTLSize GetLocalWorkGroupSize() const;
|
MTLSize GetLocalWorkGroupSize() const;
|
||||||
|
|
|
@ -21,12 +21,10 @@
|
||||||
namespace dawn_native { namespace metal {
|
namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<ComputePipeline>> ComputePipeline::Create(
|
Ref<ComputePipeline> ComputePipeline::CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
return AcquireRef(new ComputePipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize());
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ComputePipeline::Initialize() {
|
MaybeError ComputePipeline::Initialize() {
|
||||||
|
@ -76,14 +74,11 @@ namespace dawn_native { namespace metal {
|
||||||
return mRequiresStorageBufferLength;
|
return mRequiresStorageBufferLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePipeline::CreateAsync(Device* device,
|
void ComputePipeline::InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||||
const ComputePipelineDescriptor* descriptor,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
size_t blueprintHash,
|
void* userdata) {
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata) {
|
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
|
||||||
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
||||||
std::make_unique<CreateComputePipelineAsyncTask>(pipeline, blueprintHash, callback,
|
std::make_unique<CreateComputePipelineAsyncTask>(std::move(computePipeline), callback,
|
||||||
userdata);
|
userdata);
|
||||||
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
|
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,14 +89,10 @@ namespace dawn_native { namespace metal {
|
||||||
ResultOrError<Ref<CommandBufferBase>> CreateCommandBuffer(
|
ResultOrError<Ref<CommandBufferBase>> CreateCommandBuffer(
|
||||||
CommandEncoder* encoder,
|
CommandEncoder* encoder,
|
||||||
const CommandBufferDescriptor* descriptor) override;
|
const CommandBufferDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ComputePipelineBase>> CreateComputePipelineImpl(
|
|
||||||
const ComputePipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) override;
|
const PipelineLayoutDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
||||||
const QuerySetDescriptor* descriptor) override;
|
const QuerySetDescriptor* descriptor) override;
|
||||||
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
|
||||||
const RenderPipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
||||||
const SamplerDescriptor* descriptor) override;
|
const SamplerDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
||||||
|
@ -113,10 +109,13 @@ namespace dawn_native { namespace metal {
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
TextureBase* texture,
|
TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor) override;
|
const TextureViewDescriptor* descriptor) override;
|
||||||
void CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
Ref<ComputePipelineBase> CreateUninitializedComputePipelineImpl(
|
||||||
size_t blueprintHash,
|
const ComputePipelineDescriptor* descriptor) override;
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
||||||
void* userdata) override;
|
const RenderPipelineDescriptor* descriptor) override;
|
||||||
|
void InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata) override;
|
||||||
void InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) override;
|
void* userdata) override;
|
||||||
|
|
|
@ -243,9 +243,9 @@ namespace dawn_native { namespace metal {
|
||||||
const CommandBufferDescriptor* descriptor) {
|
const CommandBufferDescriptor* descriptor) {
|
||||||
return CommandBuffer::Create(encoder, descriptor);
|
return CommandBuffer::Create(encoder, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<ComputePipelineBase>> Device::CreateComputePipelineImpl(
|
Ref<ComputePipelineBase> Device::CreateUninitializedComputePipelineImpl(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
return ComputePipeline::Create(this, descriptor);
|
return ComputePipeline::CreateUninitialized(this, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) {
|
const PipelineLayoutDescriptor* descriptor) {
|
||||||
|
@ -285,16 +285,15 @@ namespace dawn_native { namespace metal {
|
||||||
const TextureViewDescriptor* descriptor) {
|
const TextureViewDescriptor* descriptor) {
|
||||||
return TextureView::Create(texture, descriptor);
|
return TextureView::Create(texture, descriptor);
|
||||||
}
|
}
|
||||||
void Device::CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
void Device::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
size_t blueprintHash,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
void* userdata) {
|
||||||
void* userdata) {
|
ComputePipeline::InitializeAsync(std::move(computePipeline), callback, userdata);
|
||||||
ComputePipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata);
|
|
||||||
}
|
}
|
||||||
void Device::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void Device::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
RenderPipeline::InitializeAsync(renderPipeline, callback, userdata);
|
RenderPipeline::InitializeAsync(std::move(renderPipeline), callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() {
|
ResultOrError<ExecutionSerial> Device::CheckAndUpdateCompletedSerials() {
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace dawn_native { namespace null {
|
||||||
const CommandBufferDescriptor* descriptor) {
|
const CommandBufferDescriptor* descriptor) {
|
||||||
return AcquireRef(new CommandBuffer(encoder, descriptor));
|
return AcquireRef(new CommandBuffer(encoder, descriptor));
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<ComputePipelineBase>> Device::CreateComputePipelineImpl(
|
Ref<ComputePipelineBase> Device::CreateUninitializedComputePipelineImpl(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
return AcquireRef(new ComputePipeline(this, descriptor));
|
return AcquireRef(new ComputePipeline(this, descriptor));
|
||||||
}
|
}
|
||||||
|
@ -371,6 +371,11 @@ namespace dawn_native { namespace null {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ComputePipeline
|
||||||
|
MaybeError ComputePipeline::Initialize() {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
// RenderPipeline
|
// RenderPipeline
|
||||||
MaybeError RenderPipeline::Initialize() {
|
MaybeError RenderPipeline::Initialize() {
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace dawn_native { namespace null {
|
||||||
class BindGroupLayout;
|
class BindGroupLayout;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
using ComputePipeline = ComputePipelineBase;
|
class ComputePipeline;
|
||||||
class Device;
|
class Device;
|
||||||
using PipelineLayout = PipelineLayoutBase;
|
using PipelineLayout = PipelineLayoutBase;
|
||||||
class QuerySet;
|
class QuerySet;
|
||||||
|
@ -129,7 +129,7 @@ namespace dawn_native { namespace null {
|
||||||
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
||||||
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
||||||
const BufferDescriptor* descriptor) override;
|
const BufferDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ComputePipelineBase>> CreateComputePipelineImpl(
|
Ref<ComputePipelineBase> CreateUninitializedComputePipelineImpl(
|
||||||
const ComputePipelineDescriptor* descriptor) override;
|
const ComputePipelineDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) override;
|
const PipelineLayoutDescriptor* descriptor) override;
|
||||||
|
@ -261,6 +261,13 @@ namespace dawn_native { namespace null {
|
||||||
size_t size) override;
|
size_t size) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ComputePipeline final : public ComputePipelineBase {
|
||||||
|
public:
|
||||||
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
|
|
||||||
|
MaybeError Initialize() override;
|
||||||
|
};
|
||||||
|
|
||||||
class RenderPipeline final : public RenderPipelineBase {
|
class RenderPipeline final : public RenderPipelineBase {
|
||||||
public:
|
public:
|
||||||
using RenderPipelineBase::RenderPipelineBase;
|
using RenderPipelineBase::RenderPipelineBase;
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
namespace dawn_native { namespace opengl {
|
namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<ComputePipeline>> ComputePipeline::Create(
|
Ref<ComputePipeline> ComputePipeline::CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
return AcquireRef(new ComputePipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize());
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputePipeline::~ComputePipeline() {
|
ComputePipeline::~ComputePipeline() {
|
||||||
|
|
|
@ -27,16 +27,17 @@ namespace dawn_native { namespace opengl {
|
||||||
|
|
||||||
class ComputePipeline final : public ComputePipelineBase, public PipelineGL {
|
class ComputePipeline final : public ComputePipelineBase, public PipelineGL {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<ComputePipeline>> Create(
|
static Ref<ComputePipeline> CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor);
|
const ComputePipelineDescriptor* descriptor);
|
||||||
|
|
||||||
void ApplyNow();
|
void ApplyNow();
|
||||||
|
|
||||||
|
MaybeError Initialize() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
MaybeError Initialize() override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}} // namespace dawn_native::opengl
|
}} // namespace dawn_native::opengl
|
||||||
|
|
|
@ -130,9 +130,9 @@ namespace dawn_native { namespace opengl {
|
||||||
const CommandBufferDescriptor* descriptor) {
|
const CommandBufferDescriptor* descriptor) {
|
||||||
return AcquireRef(new CommandBuffer(encoder, descriptor));
|
return AcquireRef(new CommandBuffer(encoder, descriptor));
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<ComputePipelineBase>> Device::CreateComputePipelineImpl(
|
Ref<ComputePipelineBase> Device::CreateUninitializedComputePipelineImpl(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
return ComputePipeline::Create(this, descriptor);
|
return ComputePipeline::CreateUninitialized(this, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) {
|
const PipelineLayoutDescriptor* descriptor) {
|
||||||
|
|
|
@ -91,14 +91,10 @@ namespace dawn_native { namespace opengl {
|
||||||
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
||||||
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
||||||
const BufferDescriptor* descriptor) override;
|
const BufferDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ComputePipelineBase>> CreateComputePipelineImpl(
|
|
||||||
const ComputePipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) override;
|
const PipelineLayoutDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
||||||
const QuerySetDescriptor* descriptor) override;
|
const QuerySetDescriptor* descriptor) override;
|
||||||
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
|
||||||
const RenderPipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
||||||
const SamplerDescriptor* descriptor) override;
|
const SamplerDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
||||||
|
@ -115,6 +111,10 @@ namespace dawn_native { namespace opengl {
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
TextureBase* texture,
|
TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor) override;
|
const TextureViewDescriptor* descriptor) override;
|
||||||
|
Ref<ComputePipelineBase> CreateUninitializedComputePipelineImpl(
|
||||||
|
const ComputePipelineDescriptor* descriptor) override;
|
||||||
|
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
||||||
|
const RenderPipelineDescriptor* descriptor) override;
|
||||||
|
|
||||||
void InitTogglesFromDriver();
|
void InitTogglesFromDriver();
|
||||||
ResultOrError<ExecutionSerial> CheckAndUpdateCompletedSerials() override;
|
ResultOrError<ExecutionSerial> CheckAndUpdateCompletedSerials() override;
|
||||||
|
|
|
@ -25,12 +25,10 @@
|
||||||
namespace dawn_native { namespace vulkan {
|
namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ResultOrError<Ref<ComputePipeline>> ComputePipeline::Create(
|
Ref<ComputePipeline> ComputePipeline::CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
return AcquireRef(new ComputePipeline(device, descriptor));
|
||||||
DAWN_TRY(pipeline->Initialize());
|
|
||||||
return pipeline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError ComputePipeline::Initialize() {
|
MaybeError ComputePipeline::Initialize() {
|
||||||
|
@ -102,14 +100,11 @@ namespace dawn_native { namespace vulkan {
|
||||||
return mHandle;
|
return mHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ComputePipeline::CreateAsync(Device* device,
|
void ComputePipeline::InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||||
const ComputePipelineDescriptor* descriptor,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
size_t blueprintHash,
|
void* userdata) {
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata) {
|
|
||||||
Ref<ComputePipeline> pipeline = AcquireRef(new ComputePipeline(device, descriptor));
|
|
||||||
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
std::unique_ptr<CreateComputePipelineAsyncTask> asyncTask =
|
||||||
std::make_unique<CreateComputePipelineAsyncTask>(pipeline, blueprintHash, callback,
|
std::make_unique<CreateComputePipelineAsyncTask>(std::move(computePipeline), callback,
|
||||||
userdata);
|
userdata);
|
||||||
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
|
CreateComputePipelineAsyncTask::RunAsync(std::move(asyncTask));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,24 +26,23 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
class ComputePipeline final : public ComputePipelineBase {
|
class ComputePipeline final : public ComputePipelineBase {
|
||||||
public:
|
public:
|
||||||
static ResultOrError<Ref<ComputePipeline>> Create(
|
static Ref<ComputePipeline> CreateUninitialized(
|
||||||
Device* device,
|
Device* device,
|
||||||
const ComputePipelineDescriptor* descriptor);
|
const ComputePipelineDescriptor* descriptor);
|
||||||
static void CreateAsync(Device* device,
|
static void InitializeAsync(Ref<ComputePipelineBase> computePipeline,
|
||||||
const ComputePipelineDescriptor* descriptor,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
size_t blueprintHash,
|
void* userdata);
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
|
||||||
void* userdata);
|
|
||||||
|
|
||||||
VkPipeline GetHandle() const;
|
VkPipeline GetHandle() const;
|
||||||
|
|
||||||
|
MaybeError Initialize() override;
|
||||||
|
|
||||||
// Dawn API
|
// Dawn API
|
||||||
void SetLabelImpl() override;
|
void SetLabelImpl() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~ComputePipeline() override;
|
~ComputePipeline() override;
|
||||||
using ComputePipelineBase::ComputePipelineBase;
|
using ComputePipelineBase::ComputePipelineBase;
|
||||||
MaybeError Initialize() override;
|
|
||||||
|
|
||||||
VkPipeline mHandle = VK_NULL_HANDLE;
|
VkPipeline mHandle = VK_NULL_HANDLE;
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,9 +120,9 @@ namespace dawn_native { namespace vulkan {
|
||||||
const CommandBufferDescriptor* descriptor) {
|
const CommandBufferDescriptor* descriptor) {
|
||||||
return CommandBuffer::Create(encoder, descriptor);
|
return CommandBuffer::Create(encoder, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<ComputePipelineBase>> Device::CreateComputePipelineImpl(
|
Ref<ComputePipelineBase> Device::CreateUninitializedComputePipelineImpl(
|
||||||
const ComputePipelineDescriptor* descriptor) {
|
const ComputePipelineDescriptor* descriptor) {
|
||||||
return ComputePipeline::Create(this, descriptor);
|
return ComputePipeline::CreateUninitialized(this, descriptor);
|
||||||
}
|
}
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> Device::CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) {
|
const PipelineLayoutDescriptor* descriptor) {
|
||||||
|
@ -162,16 +162,15 @@ namespace dawn_native { namespace vulkan {
|
||||||
const TextureViewDescriptor* descriptor) {
|
const TextureViewDescriptor* descriptor) {
|
||||||
return TextureView::Create(texture, descriptor);
|
return TextureView::Create(texture, descriptor);
|
||||||
}
|
}
|
||||||
void Device::CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
void Device::InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
size_t blueprintHash,
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
void* userdata) {
|
||||||
void* userdata) {
|
ComputePipeline::InitializeAsync(std::move(computePipeline), callback, userdata);
|
||||||
ComputePipeline::CreateAsync(this, descriptor, blueprintHash, callback, userdata);
|
|
||||||
}
|
}
|
||||||
void Device::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void Device::InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) {
|
void* userdata) {
|
||||||
RenderPipeline::InitializeAsync(renderPipeline, callback, userdata);
|
RenderPipeline::InitializeAsync(std::move(renderPipeline), callback, userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
MaybeError Device::TickImpl() {
|
MaybeError Device::TickImpl() {
|
||||||
|
|
|
@ -113,14 +113,10 @@ namespace dawn_native { namespace vulkan {
|
||||||
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
PipelineCompatibilityToken pipelineCompatibilityToken) override;
|
||||||
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
ResultOrError<Ref<BufferBase>> CreateBufferImpl(
|
||||||
const BufferDescriptor* descriptor) override;
|
const BufferDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ComputePipelineBase>> CreateComputePipelineImpl(
|
|
||||||
const ComputePipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
ResultOrError<Ref<PipelineLayoutBase>> CreatePipelineLayoutImpl(
|
||||||
const PipelineLayoutDescriptor* descriptor) override;
|
const PipelineLayoutDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
ResultOrError<Ref<QuerySetBase>> CreateQuerySetImpl(
|
||||||
const QuerySetDescriptor* descriptor) override;
|
const QuerySetDescriptor* descriptor) override;
|
||||||
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
|
||||||
const RenderPipelineDescriptor* descriptor) override;
|
|
||||||
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
ResultOrError<Ref<SamplerBase>> CreateSamplerImpl(
|
||||||
const SamplerDescriptor* descriptor) override;
|
const SamplerDescriptor* descriptor) override;
|
||||||
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
ResultOrError<Ref<ShaderModuleBase>> CreateShaderModuleImpl(
|
||||||
|
@ -137,10 +133,13 @@ namespace dawn_native { namespace vulkan {
|
||||||
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
ResultOrError<Ref<TextureViewBase>> CreateTextureViewImpl(
|
||||||
TextureBase* texture,
|
TextureBase* texture,
|
||||||
const TextureViewDescriptor* descriptor) override;
|
const TextureViewDescriptor* descriptor) override;
|
||||||
void CreateComputePipelineAsyncImpl(const ComputePipelineDescriptor* descriptor,
|
Ref<ComputePipelineBase> CreateUninitializedComputePipelineImpl(
|
||||||
size_t blueprintHash,
|
const ComputePipelineDescriptor* descriptor) override;
|
||||||
WGPUCreateComputePipelineAsyncCallback callback,
|
Ref<RenderPipelineBase> CreateUninitializedRenderPipelineImpl(
|
||||||
void* userdata) override;
|
const RenderPipelineDescriptor* descriptor) override;
|
||||||
|
void InitializeComputePipelineAsyncImpl(Ref<ComputePipelineBase> computePipeline,
|
||||||
|
WGPUCreateComputePipelineAsyncCallback callback,
|
||||||
|
void* userdata) override;
|
||||||
void InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
void InitializeRenderPipelineAsyncImpl(Ref<RenderPipelineBase> renderPipeline,
|
||||||
WGPUCreateRenderPipelineAsyncCallback callback,
|
WGPUCreateRenderPipelineAsyncCallback callback,
|
||||||
void* userdata) override;
|
void* userdata) override;
|
||||||
|
|
Loading…
Reference in New Issue