Add BlendState to NXT API
This commit is contained in:
parent
fc9775f7df
commit
94bebe517d
94
next.json
94
next.json
|
@ -105,6 +105,78 @@
|
||||||
{"value": 3, "name": "storage buffer"}
|
{"value": 3, "name": "storage buffer"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"blend factor": {
|
||||||
|
"category": "enum",
|
||||||
|
"values": [
|
||||||
|
{"value": 0, "name": "zero"},
|
||||||
|
{"value": 1, "name": "one"},
|
||||||
|
{"value": 2, "name": "src color"},
|
||||||
|
{"value": 3, "name": "one minus src color"},
|
||||||
|
{"value": 4, "name": "src alpha"},
|
||||||
|
{"value": 5, "name": "one minus src alpha"},
|
||||||
|
{"value": 6, "name": "dst color"},
|
||||||
|
{"value": 7, "name": "one minus dst color"},
|
||||||
|
{"value": 8, "name": "dst alpha"},
|
||||||
|
{"value": 9, "name": "one minus dst alpha"},
|
||||||
|
{"value": 10, "name": "src alpha saturated"},
|
||||||
|
{"value": 11, "name": "blend color"},
|
||||||
|
{"value": 12, "name": "one minus blend color"},
|
||||||
|
{"value": 13, "name": "src1 color"},
|
||||||
|
{"value": 14, "name": "one minus src1 color"},
|
||||||
|
{"value": 15, "name": "src1 alpha"},
|
||||||
|
{"value": 16, "name": "one minus src1 alpha"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"blend operation": {
|
||||||
|
"category": "enum",
|
||||||
|
"values": [
|
||||||
|
{"value": 0, "name": "add"},
|
||||||
|
{"value": 1, "name": "subtract"},
|
||||||
|
{"value": 2, "name": "reverse subtract"},
|
||||||
|
{"value": 3, "name": "min"},
|
||||||
|
{"value": 4, "name": "max"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"blend state": {
|
||||||
|
"category": "object"
|
||||||
|
},
|
||||||
|
"blend state builder": {
|
||||||
|
"category": "object",
|
||||||
|
"methods": [
|
||||||
|
{
|
||||||
|
"name": "get result",
|
||||||
|
"returns": "blend state"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set blend enabled",
|
||||||
|
"args": [
|
||||||
|
{"name": "blend enabled", "type": "bool"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set alpha blend",
|
||||||
|
"args": [
|
||||||
|
{"name": "blend operation", "type": "blend operation"},
|
||||||
|
{"name": "src factor", "type": "blend factor"},
|
||||||
|
{"name": "dst factor", "type": "blend factor"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set color blend",
|
||||||
|
"args": [
|
||||||
|
{"name": "blend operation", "type": "blend operation"},
|
||||||
|
{"name": "src factor", "type": "blend factor"},
|
||||||
|
{"name": "dst factor", "type": "blend factor"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "set color write mask",
|
||||||
|
"args": [
|
||||||
|
{"name": "color write mask", "type": "color write mask"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"builder error status": {
|
"builder error status": {
|
||||||
"category": "enum",
|
"category": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
|
@ -237,6 +309,17 @@
|
||||||
"char": {
|
"char": {
|
||||||
"category": "native"
|
"category": "native"
|
||||||
},
|
},
|
||||||
|
"color write mask": {
|
||||||
|
"category": "bitmask",
|
||||||
|
"values": [
|
||||||
|
{"value": 0, "name": "none"},
|
||||||
|
{"value": 1, "name": "red"},
|
||||||
|
{"value": 2, "name": "green"},
|
||||||
|
{"value": 4, "name": "blue"},
|
||||||
|
{"value": 8, "name": "alpha"},
|
||||||
|
{"value": 15, "name": "all"}
|
||||||
|
]
|
||||||
|
},
|
||||||
"command buffer": {
|
"command buffer": {
|
||||||
"category": "object"
|
"category": "object"
|
||||||
},
|
},
|
||||||
|
@ -473,6 +556,10 @@
|
||||||
"name": "create bind group layout builder",
|
"name": "create bind group layout builder",
|
||||||
"returns": "bind group layout builder"
|
"returns": "bind group layout builder"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "create blend state builder",
|
||||||
|
"returns": "blend state builder"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "create buffer builder",
|
"name": "create buffer builder",
|
||||||
"returns": "buffer builder"
|
"returns": "buffer builder"
|
||||||
|
@ -787,6 +874,13 @@
|
||||||
"name": "get result",
|
"name": "get result",
|
||||||
"returns": "render pipeline"
|
"returns": "render pipeline"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "set color attachment blend state",
|
||||||
|
"args": [
|
||||||
|
{"name": "attachment slot", "type": "uint32_t"},
|
||||||
|
{"name": "blend state", "type": "blend state"}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "set depth stencil state",
|
"name": "set depth stencil state",
|
||||||
"args": [
|
"args": [
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "backend/BlendState.h"
|
||||||
|
|
||||||
|
#include "backend/Device.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
|
||||||
|
// BlendStateBase
|
||||||
|
|
||||||
|
BlendStateBase::BlendStateBase(BlendStateBuilder* builder) : blendInfo(builder->blendInfo) {
|
||||||
|
}
|
||||||
|
|
||||||
|
const BlendStateBase::BlendInfo& BlendStateBase::GetBlendInfo() const {
|
||||||
|
return blendInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// BlendStateBuilder
|
||||||
|
|
||||||
|
enum BlendStateSetProperties {
|
||||||
|
BLEND_STATE_PROPERTY_BLEND_ENABLED = 0x1,
|
||||||
|
BLEND_STATE_PROPERTY_ALPHA_BLEND = 0x2,
|
||||||
|
BLEND_STATE_PROPERTY_COLOR_BLEND = 0x4,
|
||||||
|
BLEND_STATE_PROPERTY_COLOR_WRITE_MASK = 0x08,
|
||||||
|
};
|
||||||
|
|
||||||
|
BlendStateBuilder::BlendStateBuilder(DeviceBase* device) : Builder(device) {
|
||||||
|
}
|
||||||
|
|
||||||
|
BlendStateBase* BlendStateBuilder::GetResultImpl() {
|
||||||
|
return device->CreateBlendState(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlendStateBuilder::SetBlendEnabled(bool blendEnabled) {
|
||||||
|
if ((propertiesSet & BLEND_STATE_PROPERTY_BLEND_ENABLED) != 0) {
|
||||||
|
HandleError("Blend enabled property set multiple times");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
propertiesSet |= BLEND_STATE_PROPERTY_BLEND_ENABLED;
|
||||||
|
|
||||||
|
blendInfo.blendEnabled = blendEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlendStateBuilder::SetAlphaBlend(nxt::BlendOperation blendOperation, nxt::BlendFactor srcFactor, nxt::BlendFactor dstFactor) {
|
||||||
|
if ((propertiesSet & BLEND_STATE_PROPERTY_ALPHA_BLEND) != 0) {
|
||||||
|
HandleError("Alpha blend property set multiple times");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
propertiesSet |= BLEND_STATE_PROPERTY_ALPHA_BLEND;
|
||||||
|
|
||||||
|
blendInfo.alphaBlend = { blendOperation, srcFactor, dstFactor };
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlendStateBuilder::SetColorBlend(nxt::BlendOperation blendOperation, nxt::BlendFactor srcFactor, nxt::BlendFactor dstFactor) {
|
||||||
|
if ((propertiesSet & BLEND_STATE_PROPERTY_COLOR_BLEND) != 0) {
|
||||||
|
HandleError("Color blend property set multiple times");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
propertiesSet |= BLEND_STATE_PROPERTY_COLOR_BLEND;
|
||||||
|
|
||||||
|
blendInfo.colorBlend = { blendOperation, srcFactor, dstFactor };
|
||||||
|
}
|
||||||
|
|
||||||
|
void BlendStateBuilder::SetColorWriteMask(nxt::ColorWriteMask colorWriteMask) {
|
||||||
|
if ((propertiesSet & BLEND_STATE_PROPERTY_COLOR_WRITE_MASK) != 0) {
|
||||||
|
HandleError("Color write mask property set multiple times");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
propertiesSet |= BLEND_STATE_PROPERTY_COLOR_WRITE_MASK;
|
||||||
|
|
||||||
|
blendInfo.colorWriteMask = colorWriteMask;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef BACKEND_BLENDSTATE_H_
|
||||||
|
#define BACKEND_BLENDSTATE_H_
|
||||||
|
|
||||||
|
#include "backend/Forward.h"
|
||||||
|
#include "backend/Builder.h"
|
||||||
|
#include "backend/RefCounted.h"
|
||||||
|
|
||||||
|
#include "nxt/nxtcpp.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
|
||||||
|
class BlendStateBase : public RefCounted {
|
||||||
|
public:
|
||||||
|
BlendStateBase(BlendStateBuilder* builder);
|
||||||
|
|
||||||
|
struct BlendInfo {
|
||||||
|
struct BlendOpFactor {
|
||||||
|
nxt::BlendOperation operation = nxt::BlendOperation::Add;
|
||||||
|
nxt::BlendFactor srcFactor = nxt::BlendFactor::One;
|
||||||
|
nxt::BlendFactor dstFactor = nxt::BlendFactor::Zero;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool blendEnabled = false;
|
||||||
|
BlendOpFactor alphaBlend;
|
||||||
|
BlendOpFactor colorBlend;
|
||||||
|
nxt::ColorWriteMask colorWriteMask = nxt::ColorWriteMask::All;
|
||||||
|
};
|
||||||
|
|
||||||
|
const BlendInfo& GetBlendInfo() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BlendInfo blendInfo;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class BlendStateBuilder : public Builder<BlendStateBase> {
|
||||||
|
public:
|
||||||
|
BlendStateBuilder(DeviceBase* device);
|
||||||
|
|
||||||
|
// NXT API
|
||||||
|
void SetBlendEnabled(bool blendEnabled);
|
||||||
|
void SetAlphaBlend(nxt::BlendOperation blendOperation, nxt::BlendFactor srcFactor, nxt::BlendFactor dstFactor);
|
||||||
|
void SetColorBlend(nxt::BlendOperation blendOperation, nxt::BlendFactor srcFactor, nxt::BlendFactor dstFactor);
|
||||||
|
void SetColorWriteMask(nxt::ColorWriteMask colorWriteMask);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class BlendStateBase;
|
||||||
|
|
||||||
|
BlendStateBase* GetResultImpl() override;
|
||||||
|
|
||||||
|
int propertiesSet = 0;
|
||||||
|
|
||||||
|
BlendStateBase::BlendInfo blendInfo;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BACKEND_BLENDSTATE_H_
|
|
@ -38,6 +38,8 @@ if (NXT_ENABLE_OPENGL)
|
||||||
target_include_directories(opengl_autogen PUBLIC ${GENERATED_DIR})
|
target_include_directories(opengl_autogen PUBLIC ${GENERATED_DIR})
|
||||||
|
|
||||||
list(APPEND BACKEND_SOURCES
|
list(APPEND BACKEND_SOURCES
|
||||||
|
${OPENGL_DIR}/BlendStateGL.cpp
|
||||||
|
${OPENGL_DIR}/BlendStateGL.h
|
||||||
${OPENGL_DIR}/BufferGL.cpp
|
${OPENGL_DIR}/BufferGL.cpp
|
||||||
${OPENGL_DIR}/BufferGL.h
|
${OPENGL_DIR}/BufferGL.h
|
||||||
${OPENGL_DIR}/CommandBufferGL.cpp
|
${OPENGL_DIR}/CommandBufferGL.cpp
|
||||||
|
@ -110,6 +112,8 @@ if (NXT_ENABLE_METAL)
|
||||||
target_include_directories(metal_autogen PUBLIC ${GENERATED_DIR})
|
target_include_directories(metal_autogen PUBLIC ${GENERATED_DIR})
|
||||||
|
|
||||||
list(APPEND BACKEND_SOURCES
|
list(APPEND BACKEND_SOURCES
|
||||||
|
${METAL_DIR}/BlendStateMTL.mm
|
||||||
|
${METAL_DIR}/BlendStateMTL.h
|
||||||
${METAL_DIR}/BufferMTL.mm
|
${METAL_DIR}/BufferMTL.mm
|
||||||
${METAL_DIR}/BufferMTL.h
|
${METAL_DIR}/BufferMTL.h
|
||||||
${METAL_DIR}/CommandBufferMTL.mm
|
${METAL_DIR}/CommandBufferMTL.mm
|
||||||
|
@ -218,6 +222,8 @@ if (NXT_ENABLE_D3D12)
|
||||||
${D3D12_DIR}/BindGroupD3D12.h
|
${D3D12_DIR}/BindGroupD3D12.h
|
||||||
${D3D12_DIR}/BindGroupLayoutD3D12.cpp
|
${D3D12_DIR}/BindGroupLayoutD3D12.cpp
|
||||||
${D3D12_DIR}/BindGroupLayoutD3D12.h
|
${D3D12_DIR}/BindGroupLayoutD3D12.h
|
||||||
|
${D3D12_DIR}/BlendStateD3D12.cpp
|
||||||
|
${D3D12_DIR}/BlendStateD3D12.h
|
||||||
${D3D12_DIR}/BufferD3D12.cpp
|
${D3D12_DIR}/BufferD3D12.cpp
|
||||||
${D3D12_DIR}/BufferD3D12.h
|
${D3D12_DIR}/BufferD3D12.h
|
||||||
${D3D12_DIR}/CommandAllocatorManager.cpp
|
${D3D12_DIR}/CommandAllocatorManager.cpp
|
||||||
|
@ -268,6 +274,8 @@ list(APPEND BACKEND_SOURCES
|
||||||
${BACKEND_DIR}/BindGroup.h
|
${BACKEND_DIR}/BindGroup.h
|
||||||
${BACKEND_DIR}/BindGroupLayout.cpp
|
${BACKEND_DIR}/BindGroupLayout.cpp
|
||||||
${BACKEND_DIR}/BindGroupLayout.h
|
${BACKEND_DIR}/BindGroupLayout.h
|
||||||
|
${BACKEND_DIR}/BlendState.cpp
|
||||||
|
${BACKEND_DIR}/BlendState.h
|
||||||
${BACKEND_DIR}/Builder.cpp
|
${BACKEND_DIR}/Builder.cpp
|
||||||
${BACKEND_DIR}/Builder.h
|
${BACKEND_DIR}/Builder.h
|
||||||
${BACKEND_DIR}/Buffer.cpp
|
${BACKEND_DIR}/Buffer.cpp
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "backend/BindGroup.h"
|
#include "backend/BindGroup.h"
|
||||||
#include "backend/BindGroupLayout.h"
|
#include "backend/BindGroupLayout.h"
|
||||||
|
#include "backend/BlendState.h"
|
||||||
#include "backend/Buffer.h"
|
#include "backend/Buffer.h"
|
||||||
#include "backend/CommandBuffer.h"
|
#include "backend/CommandBuffer.h"
|
||||||
#include "backend/ComputePipeline.h"
|
#include "backend/ComputePipeline.h"
|
||||||
|
@ -95,6 +96,9 @@ namespace backend {
|
||||||
BindGroupLayoutBuilder* DeviceBase::CreateBindGroupLayoutBuilder() {
|
BindGroupLayoutBuilder* DeviceBase::CreateBindGroupLayoutBuilder() {
|
||||||
return new BindGroupLayoutBuilder(this);
|
return new BindGroupLayoutBuilder(this);
|
||||||
}
|
}
|
||||||
|
BlendStateBuilder* DeviceBase::CreateBlendStateBuilder() {
|
||||||
|
return new BlendStateBuilder(this);
|
||||||
|
}
|
||||||
BufferBuilder* DeviceBase::CreateBufferBuilder() {
|
BufferBuilder* DeviceBase::CreateBufferBuilder() {
|
||||||
return new BufferBuilder(this);
|
return new BufferBuilder(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ namespace backend {
|
||||||
|
|
||||||
virtual BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) = 0;
|
virtual BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) = 0;
|
||||||
virtual BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) = 0;
|
virtual BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) = 0;
|
||||||
|
virtual BlendStateBase* CreateBlendState(BlendStateBuilder* builder) = 0;
|
||||||
virtual BufferBase* CreateBuffer(BufferBuilder* builder) = 0;
|
virtual BufferBase* CreateBuffer(BufferBuilder* builder) = 0;
|
||||||
virtual BufferViewBase* CreateBufferView(BufferViewBuilder* builder) = 0;
|
virtual BufferViewBase* CreateBufferView(BufferViewBuilder* builder) = 0;
|
||||||
virtual CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) = 0;
|
virtual CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) = 0;
|
||||||
|
@ -75,6 +76,7 @@ namespace backend {
|
||||||
// NXT API
|
// NXT API
|
||||||
BindGroupBuilder* CreateBindGroupBuilder();
|
BindGroupBuilder* CreateBindGroupBuilder();
|
||||||
BindGroupLayoutBuilder* CreateBindGroupLayoutBuilder();
|
BindGroupLayoutBuilder* CreateBindGroupLayoutBuilder();
|
||||||
|
BlendStateBuilder* CreateBlendStateBuilder();
|
||||||
BufferBuilder* CreateBufferBuilder();
|
BufferBuilder* CreateBufferBuilder();
|
||||||
BufferViewBuilder* CreateBufferViewBuilder();
|
BufferViewBuilder* CreateBufferViewBuilder();
|
||||||
CommandBufferBuilder* CreateCommandBufferBuilder();
|
CommandBufferBuilder* CreateCommandBufferBuilder();
|
||||||
|
|
|
@ -23,6 +23,8 @@ namespace backend {
|
||||||
class BindGroupBuilder;
|
class BindGroupBuilder;
|
||||||
class BindGroupLayoutBase;
|
class BindGroupLayoutBase;
|
||||||
class BindGroupLayoutBuilder;
|
class BindGroupLayoutBuilder;
|
||||||
|
class BlendStateBase;
|
||||||
|
class BlendStateBuilder;
|
||||||
class BufferBase;
|
class BufferBase;
|
||||||
class BufferBuilder;
|
class BufferBuilder;
|
||||||
class BufferViewBase;
|
class BufferViewBase;
|
||||||
|
|
|
@ -68,12 +68,14 @@ namespace backend {
|
||||||
HandleError("Render pass missing properties");
|
HandleError("Render pass missing properties");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& prop : attachmentProperties) {
|
for (const auto& prop : attachmentProperties) {
|
||||||
if (!prop.all()) {
|
if (!prop.all()) {
|
||||||
HandleError("A render pass attachment is missing some property");
|
HandleError("A render pass attachment is missing some property");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return device->CreateRenderPass(this);
|
return device->CreateRenderPass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +90,6 @@ namespace backend {
|
||||||
propertiesSet |= RENDERPASS_PROPERTY_ATTACHMENT_COUNT;
|
propertiesSet |= RENDERPASS_PROPERTY_ATTACHMENT_COUNT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderPassBuilder::AttachmentSetFormat(uint32_t attachmentSlot, nxt::TextureFormat format) {
|
void RenderPassBuilder::AttachmentSetFormat(uint32_t attachmentSlot, nxt::TextureFormat format) {
|
||||||
if ((propertiesSet & RENDERPASS_PROPERTY_ATTACHMENT_COUNT) == 0) {
|
if ((propertiesSet & RENDERPASS_PROPERTY_ATTACHMENT_COUNT) == 0) {
|
||||||
HandleError("Render pass attachment count not set yet");
|
HandleError("Render pass attachment count not set yet");
|
||||||
|
|
|
@ -14,10 +14,12 @@
|
||||||
|
|
||||||
#include "backend/RenderPipeline.h"
|
#include "backend/RenderPipeline.h"
|
||||||
|
|
||||||
|
#include "backend/BlendState.h"
|
||||||
#include "backend/Device.h"
|
#include "backend/Device.h"
|
||||||
#include "backend/DepthStencilState.h"
|
#include "backend/DepthStencilState.h"
|
||||||
#include "backend/InputState.h"
|
#include "backend/InputState.h"
|
||||||
#include "backend/RenderPass.h"
|
#include "backend/RenderPass.h"
|
||||||
|
#include "common/BitSetIterator.h"
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
|
|
||||||
|
@ -28,6 +30,7 @@ namespace backend {
|
||||||
depthStencilState(std::move(builder->depthStencilState)),
|
depthStencilState(std::move(builder->depthStencilState)),
|
||||||
inputState(std::move(builder->inputState)),
|
inputState(std::move(builder->inputState)),
|
||||||
primitiveTopology(builder->primitiveTopology),
|
primitiveTopology(builder->primitiveTopology),
|
||||||
|
blendStates(builder->blendStates),
|
||||||
renderPass(std::move(builder->renderPass)), subpass(builder->subpass) {
|
renderPass(std::move(builder->renderPass)), subpass(builder->subpass) {
|
||||||
|
|
||||||
if (GetStageMask() != (nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment)) {
|
if (GetStageMask() != (nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment)) {
|
||||||
|
@ -35,11 +38,6 @@ namespace backend {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!renderPass) {
|
|
||||||
builder->HandleError("Pipeline render pass not set");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(kainino@chromium.org): Need to verify the pipeline against its render subpass.
|
// TODO(kainino@chromium.org): Need to verify the pipeline against its render subpass.
|
||||||
|
|
||||||
if ((builder->GetStageInfo(nxt::ShaderStage::Vertex).module->GetUsedVertexAttributes() & ~inputState->GetAttributesSetMask()).any()) {
|
if ((builder->GetStageInfo(nxt::ShaderStage::Vertex).module->GetUsedVertexAttributes() & ~inputState->GetAttributesSetMask()).any()) {
|
||||||
|
@ -48,6 +46,11 @@ namespace backend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BlendStateBase* RenderPipelineBase::GetBlendState(uint32_t attachmentSlot) {
|
||||||
|
ASSERT(attachmentSlot < blendStates.size());
|
||||||
|
return blendStates[attachmentSlot].Get();
|
||||||
|
}
|
||||||
|
|
||||||
DepthStencilStateBase* RenderPipelineBase::GetDepthStencilState() {
|
DepthStencilStateBase* RenderPipelineBase::GetDepthStencilState() {
|
||||||
return depthStencilState.Get();
|
return depthStencilState.Get();
|
||||||
}
|
}
|
||||||
|
@ -82,10 +85,39 @@ namespace backend {
|
||||||
if (!depthStencilState) {
|
if (!depthStencilState) {
|
||||||
depthStencilState = device->CreateDepthStencilStateBuilder()->GetResult();
|
depthStencilState = device->CreateDepthStencilStateBuilder()->GetResult();
|
||||||
}
|
}
|
||||||
|
if (!renderPass) {
|
||||||
|
HandleError("Pipeline render pass not set");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
const auto& subpassInfo = renderPass->GetSubpassInfo(subpass);
|
||||||
|
if ((blendStatesSet | subpassInfo.colorAttachmentsSet) != subpassInfo.colorAttachmentsSet) {
|
||||||
|
HandleError("Blend state set on unset color attachment");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign all color attachments without a blend state the default state
|
||||||
|
// TODO(enga@google.com): Put the default objects in the device
|
||||||
|
for (uint32_t attachmentSlot : IterateBitSet(subpassInfo.colorAttachmentsSet & ~blendStatesSet)) {
|
||||||
|
blendStates[attachmentSlot] = device->CreateBlendStateBuilder()->GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
return device->CreateRenderPipeline(this);
|
return device->CreateRenderPipeline(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderPipelineBuilder::SetColorAttachmentBlendState(uint32_t attachmentSlot, BlendStateBase* blendState) {
|
||||||
|
if (attachmentSlot > blendStates.size()) {
|
||||||
|
HandleError("Attachment index out of bounds");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (blendStatesSet[attachmentSlot]) {
|
||||||
|
HandleError("Attachment blend state already set");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
blendStatesSet.set(attachmentSlot);
|
||||||
|
blendStates[attachmentSlot] = blendState;
|
||||||
|
}
|
||||||
|
|
||||||
void RenderPipelineBuilder::SetDepthStencilState(DepthStencilStateBase* depthStencilState) {
|
void RenderPipelineBuilder::SetDepthStencilState(DepthStencilStateBase* depthStencilState) {
|
||||||
this->depthStencilState = depthStencilState;
|
this->depthStencilState = depthStencilState;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,16 @@
|
||||||
|
|
||||||
#include "nxt/nxtcpp.h"
|
#include "nxt/nxtcpp.h"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <bitset>
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
|
|
||||||
class RenderPipelineBase : public RefCounted, public PipelineBase {
|
class RenderPipelineBase : public RefCounted, public PipelineBase {
|
||||||
public:
|
public:
|
||||||
RenderPipelineBase(RenderPipelineBuilder* builder);
|
RenderPipelineBase(RenderPipelineBuilder* builder);
|
||||||
|
|
||||||
|
BlendStateBase* GetBlendState(uint32_t attachmentSlot);
|
||||||
DepthStencilStateBase* GetDepthStencilState();
|
DepthStencilStateBase* GetDepthStencilState();
|
||||||
InputStateBase* GetInputState();
|
InputStateBase* GetInputState();
|
||||||
nxt::PrimitiveTopology GetPrimitiveTopology() const;
|
nxt::PrimitiveTopology GetPrimitiveTopology() const;
|
||||||
|
@ -35,6 +39,7 @@ namespace backend {
|
||||||
Ref<DepthStencilStateBase> depthStencilState;
|
Ref<DepthStencilStateBase> depthStencilState;
|
||||||
Ref<InputStateBase> inputState;
|
Ref<InputStateBase> inputState;
|
||||||
nxt::PrimitiveTopology primitiveTopology;
|
nxt::PrimitiveTopology primitiveTopology;
|
||||||
|
std::array<Ref<BlendStateBase>, kMaxColorAttachments> blendStates;
|
||||||
Ref<RenderPassBase> renderPass;
|
Ref<RenderPassBase> renderPass;
|
||||||
uint32_t subpass;
|
uint32_t subpass;
|
||||||
};
|
};
|
||||||
|
@ -44,6 +49,7 @@ namespace backend {
|
||||||
RenderPipelineBuilder(DeviceBase* device);
|
RenderPipelineBuilder(DeviceBase* device);
|
||||||
|
|
||||||
// NXT API
|
// NXT API
|
||||||
|
void SetColorAttachmentBlendState(uint32_t attachmentSlot, BlendStateBase* blendState);
|
||||||
void SetDepthStencilState(DepthStencilStateBase* depthStencilState);
|
void SetDepthStencilState(DepthStencilStateBase* depthStencilState);
|
||||||
void SetPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology);
|
void SetPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology);
|
||||||
void SetInputState(InputStateBase* inputState);
|
void SetInputState(InputStateBase* inputState);
|
||||||
|
@ -58,6 +64,8 @@ namespace backend {
|
||||||
Ref<InputStateBase> inputState;
|
Ref<InputStateBase> inputState;
|
||||||
// TODO(enga@google.com): Remove default when we validate that all required properties are set
|
// TODO(enga@google.com): Remove default when we validate that all required properties are set
|
||||||
nxt::PrimitiveTopology primitiveTopology = nxt::PrimitiveTopology::TriangleList;
|
nxt::PrimitiveTopology primitiveTopology = nxt::PrimitiveTopology::TriangleList;
|
||||||
|
std::bitset<kMaxColorAttachments> blendStatesSet;
|
||||||
|
std::array<Ref<BlendStateBase>, kMaxColorAttachments> blendStates;
|
||||||
Ref<RenderPassBase> renderPass;
|
Ref<RenderPassBase> renderPass;
|
||||||
uint32_t subpass;
|
uint32_t subpass;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,6 +33,11 @@ namespace backend {
|
||||||
using BackendType = typename BackendTraits::BindGroupLayoutType;
|
using BackendType = typename BackendTraits::BindGroupLayoutType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename BackendTraits>
|
||||||
|
struct ToBackendTraits<BlendStateBase, BackendTraits> {
|
||||||
|
using BackendType = typename BackendTraits::BlendStateType;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename BackendTraits>
|
template<typename BackendTraits>
|
||||||
struct ToBackendTraits<BufferBase, BackendTraits> {
|
struct ToBackendTraits<BufferBase, BackendTraits> {
|
||||||
using BackendType = typename BackendTraits::BufferType;
|
using BackendType = typename BackendTraits::BufferType;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "backend/d3d12/BlendStateD3D12.h"
|
||||||
|
|
||||||
|
#include "backend/d3d12/D3D12Backend.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
namespace d3d12 {
|
||||||
|
|
||||||
|
BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef BACKEND_D3D12_BLENDSTATED3D12_H_
|
||||||
|
#define BACKEND_D3D12_BLENDSTATED3D12_H_
|
||||||
|
|
||||||
|
#include "backend/BlendState.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
namespace d3d12 {
|
||||||
|
|
||||||
|
class BlendState : public BlendStateBase {
|
||||||
|
public:
|
||||||
|
BlendState(BlendStateBuilder* builder);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BACKEND_D3D12_BLENDSTATED3D12_H_
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "backend/d3d12/BindGroupD3D12.h"
|
#include "backend/d3d12/BindGroupD3D12.h"
|
||||||
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
||||||
|
#include "backend/d3d12/BlendStateD3D12.h"
|
||||||
#include "backend/d3d12/BufferD3D12.h"
|
#include "backend/d3d12/BufferD3D12.h"
|
||||||
#include "backend/d3d12/CommandAllocatorManager.h"
|
#include "backend/d3d12/CommandAllocatorManager.h"
|
||||||
#include "backend/d3d12/CommandBufferD3D12.h"
|
#include "backend/d3d12/CommandBufferD3D12.h"
|
||||||
|
@ -209,6 +210,9 @@ namespace d3d12 {
|
||||||
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
||||||
return new BindGroupLayout(this, builder);
|
return new BindGroupLayout(this, builder);
|
||||||
}
|
}
|
||||||
|
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
|
||||||
|
return new BlendState(builder);
|
||||||
|
}
|
||||||
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
||||||
return new Buffer(this, builder);
|
return new Buffer(this, builder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace d3d12 {
|
||||||
|
|
||||||
class BindGroup;
|
class BindGroup;
|
||||||
class BindGroupLayout;
|
class BindGroupLayout;
|
||||||
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
|
@ -56,6 +57,7 @@ namespace d3d12 {
|
||||||
struct D3D12BackendTraits {
|
struct D3D12BackendTraits {
|
||||||
using BindGroupType = BindGroup;
|
using BindGroupType = BindGroup;
|
||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
using BufferViewType = BufferView;
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
|
@ -90,6 +92,7 @@ namespace d3d12 {
|
||||||
|
|
||||||
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
||||||
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
||||||
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "backend/d3d12/D3D12Backend.h"
|
#include "backend/d3d12/D3D12Backend.h"
|
||||||
#include "backend/d3d12/BindGroupD3D12.h"
|
#include "backend/d3d12/BindGroupD3D12.h"
|
||||||
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
||||||
|
#include "backend/d3d12/BlendStateD3D12.h"
|
||||||
#include "backend/d3d12/BufferD3D12.h"
|
#include "backend/d3d12/BufferD3D12.h"
|
||||||
#include "backend/d3d12/CommandBufferD3D12.h"
|
#include "backend/d3d12/CommandBufferD3D12.h"
|
||||||
#include "backend/d3d12/ComputePipelineD3D12.h"
|
#include "backend/d3d12/ComputePipelineD3D12.h"
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef BACKEND_METAL_BLENDSTATEMTL_H_
|
||||||
|
#define BACKEND_METAL_BLENDSTATEMTL_H_
|
||||||
|
|
||||||
|
#include "backend/BlendState.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
namespace metal {
|
||||||
|
|
||||||
|
class BlendState : public BlendStateBase {
|
||||||
|
public:
|
||||||
|
BlendState(BlendStateBuilder* builder);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BACKEND_METAL_BLENDSTATEMTL_H_
|
|
@ -0,0 +1,26 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "backend/metal/BlendStateMTL.h"
|
||||||
|
|
||||||
|
#include "backend/metal/MetalBackend.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
namespace metal {
|
||||||
|
|
||||||
|
BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "backend/metal/MetalBackend.h"
|
#include "backend/metal/MetalBackend.h"
|
||||||
|
#include "backend/metal/BlendStateMTL.h"
|
||||||
#include "backend/metal/BufferMTL.h"
|
#include "backend/metal/BufferMTL.h"
|
||||||
#include "backend/metal/CommandBufferMTL.h"
|
#include "backend/metal/CommandBufferMTL.h"
|
||||||
#include "backend/metal/ComputePipelineMTL.h"
|
#include "backend/metal/ComputePipelineMTL.h"
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace metal {
|
||||||
|
|
||||||
class BindGroup;
|
class BindGroup;
|
||||||
class BindGroupLayout;
|
class BindGroupLayout;
|
||||||
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
|
@ -56,6 +57,7 @@ namespace metal {
|
||||||
struct MetalBackendTraits {
|
struct MetalBackendTraits {
|
||||||
using BindGroupType = BindGroup;
|
using BindGroupType = BindGroup;
|
||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
using BufferViewType = BufferView;
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
|
@ -90,6 +92,7 @@ namespace metal {
|
||||||
|
|
||||||
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
||||||
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
||||||
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "backend/metal/MetalBackend.h"
|
#include "backend/metal/MetalBackend.h"
|
||||||
|
|
||||||
|
#include "backend/metal/BlendStateMTL.h"
|
||||||
#include "backend/metal/BufferMTL.h"
|
#include "backend/metal/BufferMTL.h"
|
||||||
#include "backend/metal/CommandBufferMTL.h"
|
#include "backend/metal/CommandBufferMTL.h"
|
||||||
#include "backend/metal/ComputePipelineMTL.h"
|
#include "backend/metal/ComputePipelineMTL.h"
|
||||||
|
@ -84,6 +85,9 @@ namespace metal {
|
||||||
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
||||||
return new BindGroupLayout(builder);
|
return new BindGroupLayout(builder);
|
||||||
}
|
}
|
||||||
|
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
|
||||||
|
return new BlendState(builder);
|
||||||
|
}
|
||||||
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
||||||
return new Buffer(builder);
|
return new Buffer(builder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,9 @@ namespace null {
|
||||||
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
||||||
return new BindGroupLayout(builder);
|
return new BindGroupLayout(builder);
|
||||||
}
|
}
|
||||||
|
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
|
||||||
|
return new BlendState(builder);
|
||||||
|
}
|
||||||
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
||||||
return new Buffer(builder);
|
return new Buffer(builder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "backend/Buffer.h"
|
#include "backend/Buffer.h"
|
||||||
#include "backend/BindGroup.h"
|
#include "backend/BindGroup.h"
|
||||||
#include "backend/BindGroupLayout.h"
|
#include "backend/BindGroupLayout.h"
|
||||||
|
#include "backend/BlendState.h"
|
||||||
#include "backend/Device.h"
|
#include "backend/Device.h"
|
||||||
#include "backend/CommandBuffer.h"
|
#include "backend/CommandBuffer.h"
|
||||||
#include "backend/ComputePipeline.h"
|
#include "backend/ComputePipeline.h"
|
||||||
|
@ -41,6 +42,7 @@ namespace null {
|
||||||
|
|
||||||
using BindGroup = BindGroupBase;
|
using BindGroup = BindGroupBase;
|
||||||
using BindGroupLayout = BindGroupLayoutBase;
|
using BindGroupLayout = BindGroupLayoutBase;
|
||||||
|
using BlendState = BlendStateBase;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
using BufferView = BufferViewBase;
|
using BufferView = BufferViewBase;
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
|
@ -62,6 +64,7 @@ namespace null {
|
||||||
struct NullBackendTraits {
|
struct NullBackendTraits {
|
||||||
using BindGroupType = BindGroup;
|
using BindGroupType = BindGroup;
|
||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
using BufferViewType = BufferView;
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
|
@ -98,6 +101,7 @@ namespace null {
|
||||||
|
|
||||||
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
||||||
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
||||||
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include "backend/opengl/BlendStateGL.h"
|
||||||
|
|
||||||
|
#include "backend/opengl/OpenGLBackend.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
|
BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef BACKEND_OPENGL_BLENDSTATED3D12_H_
|
||||||
|
#define BACKEND_OPENGL_BLENDSTATED3D12_H_
|
||||||
|
|
||||||
|
#include "backend/BlendState.h"
|
||||||
|
|
||||||
|
namespace backend {
|
||||||
|
namespace opengl {
|
||||||
|
|
||||||
|
class BlendState : public BlendStateBase {
|
||||||
|
public:
|
||||||
|
BlendState(BlendStateBuilder* builder);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BACKEND_OPENGL_BLENDSTATED3D12_H_
|
|
@ -13,6 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "backend/opengl/OpenGLBackend.h"
|
#include "backend/opengl/OpenGLBackend.h"
|
||||||
|
#include "backend/opengl/BlendStateGL.h"
|
||||||
#include "backend/opengl/BufferGL.h"
|
#include "backend/opengl/BufferGL.h"
|
||||||
#include "backend/opengl/CommandBufferGL.h"
|
#include "backend/opengl/CommandBufferGL.h"
|
||||||
#include "backend/opengl/ComputePipelineGL.h"
|
#include "backend/opengl/ComputePipelineGL.h"
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "backend/opengl/OpenGLBackend.h"
|
#include "backend/opengl/OpenGLBackend.h"
|
||||||
|
|
||||||
|
#include "backend/opengl/BlendStateGL.h"
|
||||||
#include "backend/opengl/BufferGL.h"
|
#include "backend/opengl/BufferGL.h"
|
||||||
#include "backend/opengl/CommandBufferGL.h"
|
#include "backend/opengl/CommandBufferGL.h"
|
||||||
#include "backend/opengl/ComputePipelineGL.h"
|
#include "backend/opengl/ComputePipelineGL.h"
|
||||||
|
@ -49,6 +50,9 @@ namespace opengl {
|
||||||
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
BindGroupLayoutBase* Device::CreateBindGroupLayout(BindGroupLayoutBuilder* builder) {
|
||||||
return new BindGroupLayout(builder);
|
return new BindGroupLayout(builder);
|
||||||
}
|
}
|
||||||
|
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
|
||||||
|
return new BlendState(builder);
|
||||||
|
}
|
||||||
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
BufferBase* Device::CreateBuffer(BufferBuilder* builder) {
|
||||||
return new Buffer(builder);
|
return new Buffer(builder);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "nxt/nxtcpp.h"
|
#include "nxt/nxtcpp.h"
|
||||||
|
|
||||||
#include "backend/Buffer.h"
|
#include "backend/Buffer.h"
|
||||||
|
#include "backend/BlendState.h"
|
||||||
#include "backend/BindGroup.h"
|
#include "backend/BindGroup.h"
|
||||||
#include "backend/BindGroupLayout.h"
|
#include "backend/BindGroupLayout.h"
|
||||||
#include "backend/Device.h"
|
#include "backend/Device.h"
|
||||||
|
@ -35,6 +36,7 @@ namespace opengl {
|
||||||
|
|
||||||
class BindGroup;
|
class BindGroup;
|
||||||
class BindGroupLayout;
|
class BindGroupLayout;
|
||||||
|
class BlendState;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class BufferView;
|
class BufferView;
|
||||||
class CommandBuffer;
|
class CommandBuffer;
|
||||||
|
@ -57,6 +59,7 @@ namespace opengl {
|
||||||
struct OpenGLBackendTraits {
|
struct OpenGLBackendTraits {
|
||||||
using BindGroupType = BindGroup;
|
using BindGroupType = BindGroup;
|
||||||
using BindGroupLayoutType = BindGroupLayout;
|
using BindGroupLayoutType = BindGroupLayout;
|
||||||
|
using BlendStateType = BlendState;
|
||||||
using BufferType = Buffer;
|
using BufferType = Buffer;
|
||||||
using BufferViewType = BufferView;
|
using BufferViewType = BufferView;
|
||||||
using CommandBufferType = CommandBuffer;
|
using CommandBufferType = CommandBuffer;
|
||||||
|
@ -86,6 +89,7 @@ namespace opengl {
|
||||||
public:
|
public:
|
||||||
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
|
||||||
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
BindGroupLayoutBase* CreateBindGroupLayout(BindGroupLayoutBuilder* builder) override;
|
||||||
|
BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
|
||||||
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
BufferBase* CreateBuffer(BufferBuilder* builder) override;
|
||||||
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
|
||||||
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
|
||||||
|
|
Loading…
Reference in New Issue