Add primitive topology to NXT API
This commit is contained in:
parent
c275f7cf9f
commit
3e9e315636
38
next.json
38
next.json
|
@ -691,6 +691,16 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"primitive topology": {
|
||||
"category": "enum",
|
||||
"values": [
|
||||
{"value": 0, "name": "point"},
|
||||
{"value": 1, "name": "line"},
|
||||
{"value": 2, "name": "line strip"},
|
||||
{"value": 3, "name": "triangle"},
|
||||
{"value": 4, "name": "triangle strip"}
|
||||
]
|
||||
},
|
||||
"queue": {
|
||||
"category": "object",
|
||||
"methods": [
|
||||
|
@ -773,6 +783,18 @@
|
|||
"name": "get result",
|
||||
"returns": "render pipeline"
|
||||
},
|
||||
{
|
||||
"name": "set depth stencil state",
|
||||
"args": [
|
||||
{"name": "depth stencil state", "type": "depth stencil state"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set input state",
|
||||
"args": [
|
||||
{"name": "input", "type": "input state"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set layout",
|
||||
"args": [
|
||||
|
@ -780,10 +802,9 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "set subpass",
|
||||
"name": "set primitive topology",
|
||||
"args": [
|
||||
{"name": "render pass", "type": "render pass"},
|
||||
{"name": "subpass", "type": "uint32_t"}
|
||||
{"name": "primitive topology", "type": "primitive topology"}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -795,15 +816,10 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "set input state",
|
||||
"name": "set subpass",
|
||||
"args": [
|
||||
{"name": "input", "type": "input state"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set depth stencil state",
|
||||
"args": [
|
||||
{"name": "depth stencil state", "type": "depth stencil state"}
|
||||
{"name": "render pass", "type": "render pass"},
|
||||
{"name": "subpass", "type": "uint32_t"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -24,8 +24,11 @@ namespace backend {
|
|||
// RenderPipelineBase
|
||||
|
||||
RenderPipelineBase::RenderPipelineBase(RenderPipelineBuilder* builder)
|
||||
: PipelineBase(builder), renderPass(std::move(builder->renderPass)), subpass(builder->subpass),
|
||||
inputState(std::move(builder->inputState)), depthStencilState(std::move(builder->depthStencilState)) {
|
||||
: PipelineBase(builder),
|
||||
depthStencilState(std::move(builder->depthStencilState)),
|
||||
inputState(std::move(builder->inputState)),
|
||||
primitiveTopology(builder->primitiveTopology),
|
||||
renderPass(std::move(builder->renderPass)), subpass(builder->subpass) {
|
||||
|
||||
if (GetStageMask() != (nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment)) {
|
||||
builder->HandleError("Render pipeline should have exactly a vertex and fragment stage");
|
||||
|
@ -45,20 +48,24 @@ namespace backend {
|
|||
}
|
||||
}
|
||||
|
||||
RenderPassBase* RenderPipelineBase::GetRenderPass() {
|
||||
return renderPass.Get();
|
||||
}
|
||||
|
||||
uint32_t RenderPipelineBase::GetSubPass() {
|
||||
return subpass;
|
||||
DepthStencilStateBase* RenderPipelineBase::GetDepthStencilState() {
|
||||
return depthStencilState.Get();
|
||||
}
|
||||
|
||||
InputStateBase* RenderPipelineBase::GetInputState() {
|
||||
return inputState.Get();
|
||||
}
|
||||
|
||||
DepthStencilStateBase* RenderPipelineBase::GetDepthStencilState() {
|
||||
return depthStencilState.Get();
|
||||
nxt::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
|
||||
return primitiveTopology;
|
||||
}
|
||||
|
||||
RenderPassBase* RenderPipelineBase::GetRenderPass() {
|
||||
return renderPass.Get();
|
||||
}
|
||||
|
||||
uint32_t RenderPipelineBase::GetSubPass() {
|
||||
return subpass;
|
||||
}
|
||||
|
||||
// RenderPipelineBuilder
|
||||
|
@ -79,17 +86,21 @@ namespace backend {
|
|||
return device->CreateRenderPipeline(this);
|
||||
}
|
||||
|
||||
void RenderPipelineBuilder::SetSubpass(RenderPassBase* renderPass, uint32_t subpass) {
|
||||
this->renderPass = renderPass;
|
||||
this->subpass = subpass;
|
||||
void RenderPipelineBuilder::SetDepthStencilState(DepthStencilStateBase* depthStencilState) {
|
||||
this->depthStencilState = depthStencilState;
|
||||
}
|
||||
|
||||
void RenderPipelineBuilder::SetInputState(InputStateBase* inputState) {
|
||||
this->inputState = inputState;
|
||||
}
|
||||
|
||||
void RenderPipelineBuilder::SetDepthStencilState(DepthStencilStateBase* depthStencilState) {
|
||||
this->depthStencilState = depthStencilState;
|
||||
void RenderPipelineBuilder::SetPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology) {
|
||||
this->primitiveTopology = primitiveTopology;
|
||||
}
|
||||
|
||||
void RenderPipelineBuilder::SetSubpass(RenderPassBase* renderPass, uint32_t subpass) {
|
||||
this->renderPass = renderPass;
|
||||
this->subpass = subpass;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,16 +25,18 @@ namespace backend {
|
|||
public:
|
||||
RenderPipelineBase(RenderPipelineBuilder* builder);
|
||||
|
||||
DepthStencilStateBase* GetDepthStencilState();
|
||||
InputStateBase* GetInputState();
|
||||
nxt::PrimitiveTopology GetPrimitiveTopology() const;
|
||||
RenderPassBase* GetRenderPass();
|
||||
uint32_t GetSubPass();
|
||||
InputStateBase* GetInputState();
|
||||
DepthStencilStateBase* GetDepthStencilState();
|
||||
|
||||
private:
|
||||
Ref<DepthStencilStateBase> depthStencilState;
|
||||
Ref<InputStateBase> inputState;
|
||||
nxt::PrimitiveTopology primitiveTopology;
|
||||
Ref<RenderPassBase> renderPass;
|
||||
uint32_t subpass;
|
||||
Ref<InputStateBase> inputState;
|
||||
Ref<DepthStencilStateBase> depthStencilState;
|
||||
};
|
||||
|
||||
class RenderPipelineBuilder : public Builder<RenderPipelineBase>, public PipelineBuilder {
|
||||
|
@ -42,19 +44,22 @@ namespace backend {
|
|||
RenderPipelineBuilder(DeviceBase* device);
|
||||
|
||||
// NXT API
|
||||
void SetSubpass(RenderPassBase* renderPass, uint32_t subpass);
|
||||
void SetInputState(InputStateBase* inputState);
|
||||
void SetDepthStencilState(DepthStencilStateBase* depthStencilState);
|
||||
void SetPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology);
|
||||
void SetInputState(InputStateBase* inputState);
|
||||
void SetSubpass(RenderPassBase* renderPass, uint32_t subpass);
|
||||
|
||||
private:
|
||||
friend class RenderPipelineBase;
|
||||
|
||||
RenderPipelineBase* GetResultImpl() override;
|
||||
|
||||
Ref<DepthStencilStateBase> depthStencilState;
|
||||
Ref<InputStateBase> inputState;
|
||||
// TODO(enga@google.com): Remove default when we validate that all required properties are set
|
||||
nxt::PrimitiveTopology primitiveTopology = nxt::PrimitiveTopology::Triangle;
|
||||
Ref<RenderPassBase> renderPass;
|
||||
uint32_t subpass;
|
||||
Ref<InputStateBase> inputState;
|
||||
Ref<DepthStencilStateBase> depthStencilState;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue