dawn-cmake/src/dawn_native/DepthStencilState.h

86 lines
2.9 KiB
C
Raw Normal View History

// 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.
#ifndef DAWNNATIVE_DEPTHSTENCILSTATE_H_
#define DAWNNATIVE_DEPTHSTENCILSTATE_H_
2017-05-31 00:03:44 +00:00
2018-07-24 11:53:51 +00:00
#include "dawn_native/Builder.h"
#include "dawn_native/Forward.h"
#include "dawn_native/ObjectBase.h"
2017-05-31 00:03:44 +00:00
#include "dawn_native/dawn_platform.h"
2017-05-31 00:03:44 +00:00
namespace dawn_native {
2017-05-31 00:03:44 +00:00
class DepthStencilStateBase : public ObjectBase {
2017-11-24 18:59:42 +00:00
public:
DepthStencilStateBase(DepthStencilStateBuilder* builder);
struct DepthInfo {
2018-07-18 09:38:11 +00:00
dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
2017-11-24 18:59:42 +00:00
bool depthWriteEnabled = false;
};
struct StencilFaceInfo {
2018-07-18 09:38:11 +00:00
dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
dawn::StencilOperation stencilFail = dawn::StencilOperation::Keep;
dawn::StencilOperation depthFail = dawn::StencilOperation::Keep;
dawn::StencilOperation depthStencilPass = dawn::StencilOperation::Keep;
2017-11-24 18:59:42 +00:00
};
struct StencilInfo {
StencilFaceInfo back;
StencilFaceInfo front;
uint32_t readMask = 0xff;
uint32_t writeMask = 0xff;
};
bool StencilTestEnabled() const;
const DepthInfo& GetDepth() const;
const StencilInfo& GetStencil() const;
private:
DepthInfo mDepthInfo;
StencilInfo mStencilInfo;
2017-05-31 00:03:44 +00:00
};
class DepthStencilStateBuilder : public Builder<DepthStencilStateBase> {
2017-11-24 18:59:42 +00:00
public:
DepthStencilStateBuilder(DeviceBase* device);
2017-05-31 00:03:44 +00:00
2018-07-18 13:20:28 +00:00
// Dawn API
2018-07-18 09:38:11 +00:00
void SetDepthCompareFunction(dawn::CompareFunction depthCompareFunction);
2017-11-24 18:59:42 +00:00
void SetDepthWriteEnabled(bool enabled);
2018-07-18 09:38:11 +00:00
void SetStencilFunction(dawn::Face face,
dawn::CompareFunction stencilCompareFunction,
dawn::StencilOperation stencilFail,
dawn::StencilOperation depthFail,
dawn::StencilOperation depthStencilPass);
2017-11-24 18:59:42 +00:00
void SetStencilMask(uint32_t readMask, uint32_t writeMask);
2017-05-31 00:03:44 +00:00
2017-11-24 18:59:42 +00:00
private:
friend class DepthStencilStateBase;
2017-05-31 00:03:44 +00:00
2017-11-24 18:59:42 +00:00
DepthStencilStateBase* GetResultImpl() override;
2017-05-31 00:03:44 +00:00
2017-11-24 18:59:42 +00:00
int mPropertiesSet = 0;
2017-11-24 18:59:42 +00:00
DepthStencilStateBase::DepthInfo mDepthInfo;
DepthStencilStateBase::StencilInfo mStencilInfo;
2017-05-31 00:03:44 +00:00
};
} // namespace dawn_native
2017-05-31 00:03:44 +00:00
#endif // DAWNNATIVE_DEPTHSTENCILSTATE_H_