2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-05-31 00:03:44 +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/Pipeline.h"
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/Device.h"
|
|
|
|
#include "dawn_native/InputState.h"
|
|
|
|
#include "dawn_native/PipelineLayout.h"
|
|
|
|
#include "dawn_native/ShaderModule.h"
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
namespace dawn_native {
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
// PipelineBase
|
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
PipelineBase::PipelineBase(DeviceBase* device,
|
|
|
|
PipelineLayoutBase* layout,
|
|
|
|
dawn::ShaderStageBit stages)
|
2018-10-15 12:54:30 +00:00
|
|
|
: ObjectBase(device), mStageMask(stages), mLayout(layout), mDevice(device) {
|
2018-08-27 21:12:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PipelineBase::ExtractModuleData(dawn::ShaderStage stage, ShaderModuleBase* module) {
|
|
|
|
PushConstantInfo* info = &mPushConstants[stage];
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
const auto& moduleInfo = module->GetPushConstants();
|
|
|
|
info->mask = moduleInfo.mask;
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
for (uint32_t i = 0; i < moduleInfo.names.size(); i++) {
|
|
|
|
uint32_t size = moduleInfo.sizes[i];
|
|
|
|
if (size == 0) {
|
|
|
|
continue;
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
for (uint32_t offset = 0; offset < size; offset++) {
|
|
|
|
info->types[i + offset] = moduleInfo.types[i];
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
2018-08-27 21:12:56 +00:00
|
|
|
i += size - 1;
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
const PipelineBase::PushConstantInfo& PipelineBase::GetPushConstants(
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::ShaderStage stage) const {
|
2017-11-23 18:32:51 +00:00
|
|
|
return mPushConstants[stage];
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::ShaderStageBit PipelineBase::GetStageMask() const {
|
2017-11-23 18:32:51 +00:00
|
|
|
return mStageMask;
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PipelineLayoutBase* PipelineBase::GetLayout() {
|
2017-11-23 18:32:51 +00:00
|
|
|
return mLayout.Get();
|
2017-05-31 00:03:44 +00:00
|
|
|
}
|
|
|
|
|
2018-08-27 21:12:56 +00:00
|
|
|
DeviceBase* PipelineBase::GetDevice() const {
|
|
|
|
return mDevice;
|
|
|
|
}
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
} // namespace dawn_native
|