2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-07-14 14:58:07 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/ComputePipeline.h"
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/Device.h"
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
namespace dawn_native {
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
MaybeError ValidateComputePipelineDescriptor(DeviceBase*,
|
|
|
|
const ComputePipelineDescriptor* descriptor) {
|
2018-09-10 14:17:24 +00:00
|
|
|
if (descriptor->nextInChain != nullptr) {
|
|
|
|
return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
|
|
|
|
}
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-12-10 10:03:08 +00:00
|
|
|
if (descriptor->module == nullptr) {
|
|
|
|
return DAWN_VALIDATION_ERROR("module cannot be null");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (descriptor->layout == nullptr) {
|
|
|
|
return DAWN_VALIDATION_ERROR("layout cannot be null");
|
|
|
|
}
|
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
if (descriptor->entryPoint != std::string("main")) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Currently the entry point has to be main()");
|
2017-07-14 14:58:07 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
if (descriptor->module->GetExecutionModel() != dawn::ShaderStage::Compute) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Setting module with wrong execution model");
|
2018-08-27 21:12:56 +00:00
|
|
|
}
|
2017-07-14 14:58:07 +00:00
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
if (!descriptor->module->IsCompatibleWithPipelineLayout(descriptor->layout)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Stage not compatible with layout");
|
2018-08-27 21:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {};
|
2017-07-14 14:58:07 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
// ComputePipelineBase
|
|
|
|
|
|
|
|
ComputePipelineBase::ComputePipelineBase(DeviceBase* device,
|
|
|
|
const ComputePipelineDescriptor* descriptor)
|
|
|
|
: PipelineBase(device, descriptor->layout, dawn::ShaderStageBit::Compute) {
|
|
|
|
ExtractModuleData(dawn::ShaderStage::Compute, descriptor->module);
|
2017-07-14 14:58:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
} // namespace dawn_native
|