2017-05-31 00:03:44 +00:00
|
|
|
// Copyright 2017 The NXT 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.
|
|
|
|
|
2017-07-06 18:41:13 +00:00
|
|
|
#ifndef BACKEND_PIPELINE_H_
|
|
|
|
#define BACKEND_PIPELINE_H_
|
2017-05-31 00:03:44 +00:00
|
|
|
|
2017-07-06 18:41:13 +00:00
|
|
|
#include "backend/Forward.h"
|
|
|
|
#include "backend/Builder.h"
|
|
|
|
#include "backend/PerStage.h"
|
|
|
|
#include "backend/RefCounted.h"
|
2017-05-31 00:03:44 +00:00
|
|
|
|
|
|
|
#include "nxt/nxtcpp.h"
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
namespace backend {
|
|
|
|
|
|
|
|
enum PushConstantType : uint8_t {
|
|
|
|
Int,
|
|
|
|
UInt,
|
|
|
|
Float,
|
|
|
|
};
|
|
|
|
|
|
|
|
class PipelineBase : public RefCounted {
|
|
|
|
public:
|
|
|
|
PipelineBase(PipelineBuilder* builder);
|
|
|
|
|
|
|
|
struct PushConstantInfo {
|
|
|
|
std::bitset<kMaxPushConstants> mask;
|
|
|
|
std::array<PushConstantType, kMaxPushConstants> types;
|
|
|
|
};
|
|
|
|
const PushConstantInfo& GetPushConstants(nxt::ShaderStage stage) const;
|
|
|
|
nxt::ShaderStageBit GetStageMask() const;
|
|
|
|
|
|
|
|
PipelineLayoutBase* GetLayout();
|
|
|
|
RenderPassBase* GetRenderPass();
|
2017-07-07 18:39:38 +00:00
|
|
|
uint32_t GetSubPass();
|
2017-05-31 00:03:44 +00:00
|
|
|
InputStateBase* GetInputState();
|
|
|
|
DepthStencilStateBase* GetDepthStencilState();
|
|
|
|
|
|
|
|
// TODO(cwallez@chromium.org): split compute and render pipelines
|
|
|
|
bool IsCompute() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
nxt::ShaderStageBit stageMask;
|
|
|
|
Ref<PipelineLayoutBase> layout;
|
|
|
|
Ref<RenderPassBase> renderPass;
|
|
|
|
uint32_t subpass;
|
|
|
|
PerStage<PushConstantInfo> pushConstants;
|
|
|
|
Ref<InputStateBase> inputState;
|
|
|
|
Ref<DepthStencilStateBase> depthStencilState;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PipelineBuilder : public Builder<PipelineBase> {
|
|
|
|
public:
|
|
|
|
PipelineBuilder(DeviceBase* device);
|
|
|
|
|
|
|
|
struct StageInfo {
|
|
|
|
std::string entryPoint;
|
|
|
|
Ref<ShaderModuleBase> module;
|
|
|
|
};
|
|
|
|
const StageInfo& GetStageInfo(nxt::ShaderStage stage) const;
|
|
|
|
|
|
|
|
// NXT API
|
|
|
|
void SetLayout(PipelineLayoutBase* layout);
|
|
|
|
void SetSubpass(RenderPassBase* renderPass, uint32_t subpass);
|
|
|
|
void SetStage(nxt::ShaderStage stage, ShaderModuleBase* module, const char* entryPoint);
|
|
|
|
void SetInputState(InputStateBase* inputState);
|
|
|
|
void SetDepthStencilState(DepthStencilStateBase* depthStencilState);
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class PipelineBase;
|
|
|
|
|
|
|
|
PipelineBase* GetResultImpl() override;
|
|
|
|
|
2017-06-01 15:30:03 +00:00
|
|
|
bool IsCompute() const;
|
|
|
|
|
2017-05-31 00:03:44 +00:00
|
|
|
Ref<PipelineLayoutBase> layout;
|
|
|
|
Ref<RenderPassBase> renderPass;
|
|
|
|
uint32_t subpass;
|
|
|
|
nxt::ShaderStageBit stageMask;
|
|
|
|
PerStage<StageInfo> stages;
|
|
|
|
Ref<InputStateBase> inputState;
|
|
|
|
Ref<DepthStencilStateBase> depthStencilState;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-07-06 18:41:13 +00:00
|
|
|
#endif // BACKEND_PIPELINE_H_
|