mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige DepthStencil
This commit is contained in:
parent
1ca0bf2ffb
commit
0d716d1cd6
@ -1,7 +1,46 @@
|
|||||||
#include "platform-dx/depthstencilstate-dx.hpp"
|
|
||||||
#include "platform-dx/device-dx.hpp"
|
#include "platform-dx/device-dx.hpp"
|
||||||
|
#include "graphics/depthstencilstate.hpp"
|
||||||
|
#include "platform-dx/dxheaders.hpp"
|
||||||
|
#include "platform-dx/implementations.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
static D3D11_DEPTH_STENCIL_DESC defaultDesc() {
|
||||||
|
D3D11_DEPTH_STENCIL_DESC _description{};
|
||||||
|
_description.DepthEnable = true;
|
||||||
|
_description.StencilEnable = true;
|
||||||
|
_description.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||||
|
|
||||||
|
_description.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
|
_description.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
_description.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
_description.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
|
||||||
|
_description.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
|
_description.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
_description.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
_description.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
|
|
||||||
|
_description.StencilReadMask = 0;
|
||||||
|
_description.StencilWriteMask = 0;
|
||||||
|
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
|
return _description;
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthStencilState::DepthStencilState() : GraphicsResource(nullptr) {
|
||||||
|
impl = uNew<PlatformImplementation>();
|
||||||
|
impl->dxDescription = defaultDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthStencilState::DepthStencilState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
|
impl = uNew<PlatformImplementation>();
|
||||||
|
impl->dxDescription = defaultDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
DepthStencilState::~DepthStencilState() {
|
||||||
|
impl = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool DepthStencilState::Initialize(xna_error_ptr_arg)
|
bool DepthStencilState::Initialize(xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->_device) {
|
if (!m_device || !m_device->_device) {
|
||||||
@ -9,12 +48,14 @@ namespace xna {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dxDepthStencil) {
|
if (impl->dxDepthStencil) {
|
||||||
dxDepthStencil->Release();
|
impl->dxDepthStencil->Release();
|
||||||
dxDepthStencil = nullptr;
|
impl->dxDepthStencil = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hr = m_device->_device->CreateDepthStencilState(&dxDescription, &dxDepthStencil);
|
const auto hr = m_device->_device->CreateDepthStencilState(
|
||||||
|
&impl->dxDescription,
|
||||||
|
&impl->dxDepthStencil);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
||||||
@ -31,37 +72,167 @@ namespace xna {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dxDepthStencil) {
|
if (!impl->dxDepthStencil) {
|
||||||
xna_error_apply(err, XnaErrorCode::UNINTIALIZED_RESOURCE);
|
xna_error_apply(err, XnaErrorCode::UNINTIALIZED_RESOURCE);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->_context->OMSetDepthStencilState(dxDepthStencil, 0);
|
m_device->_context->OMSetDepthStencilState(impl->dxDepthStencil, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr<DepthStencilState> DepthStencilState::None() {
|
uptr<DepthStencilState> DepthStencilState::None() {
|
||||||
auto stencil = std::unique_ptr<DepthStencilState>(new DepthStencilState());
|
auto stencil = uNew<DepthStencilState>();
|
||||||
stencil->dxDescription.DepthEnable = false;
|
stencil->impl->dxDescription.DepthEnable = false;
|
||||||
stencil->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
return stencil;
|
return stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr<DepthStencilState> DepthStencilState::Default() {
|
uptr<DepthStencilState> DepthStencilState::Default() {
|
||||||
auto stencil = std::unique_ptr<DepthStencilState>(new DepthStencilState());
|
auto stencil = uNew<DepthStencilState>();
|
||||||
stencil->dxDescription.DepthEnable = true;
|
stencil->impl->dxDescription.DepthEnable = true;
|
||||||
stencil->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
|
|
||||||
return stencil;
|
return stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr<DepthStencilState> DepthStencilState::DepthRead() {
|
uptr<DepthStencilState> DepthStencilState::DepthRead() {
|
||||||
auto stencil = std::unique_ptr<DepthStencilState>(new DepthStencilState());
|
auto stencil = uNew<DepthStencilState>();
|
||||||
stencil->dxDescription.DepthEnable = true;
|
stencil->impl->dxDescription.DepthEnable = true;
|
||||||
stencil->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
return stencil;
|
return stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::DepthEnabled(bool value) {
|
||||||
|
impl->dxDescription.DepthEnable = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::DepthWriteEnabled(bool value) {
|
||||||
|
impl->dxDescription.DepthWriteMask = static_cast<D3D11_DEPTH_WRITE_MASK>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::DepthCompareFunction(ComparisonFunction value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilEnabled(bool value) {
|
||||||
|
impl->dxDescription.StencilEnable = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilReadMask(int value) {
|
||||||
|
impl->dxDescription.StencilReadMask = static_cast<UINT8>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilWriteMask(Int value) {
|
||||||
|
impl->dxDescription.StencilWriteMask = static_cast<UINT8>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilFrontFacePass(StencilOperation value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilFrontFaceFail(StencilOperation value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilFrontFaceDepthFail(StencilOperation value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilFrontFaceCompare(ComparisonFunction value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilBackFacePass(StencilOperation value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilBackFaceFail(StencilOperation value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilBackFaceDepthFail(StencilOperation value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DepthStencilState::StencilBackFaceCompare(ComparisonFunction value) {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
impl->dxDescription.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DepthStencilState::DepthEnabled() const {
|
||||||
|
return impl->dxDescription.DepthEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DepthStencilState::DepthWriteEnabled() const {
|
||||||
|
return static_cast<bool>(impl->dxDescription.DepthWriteMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
ComparisonFunction DepthStencilState::DepthCompareFunction() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.DepthFunc) - 1;
|
||||||
|
return static_cast<ComparisonFunction>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DepthStencilState::StencilEnabled() const {
|
||||||
|
return impl->dxDescription.StencilEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
Int DepthStencilState::StencilReadMask() const {
|
||||||
|
return static_cast<int>(impl->dxDescription.StencilReadMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
Int DepthStencilState::StencilWriteMask() const {
|
||||||
|
return static_cast<int>(impl->dxDescription.StencilWriteMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
StencilOperation DepthStencilState::StencilFrontFacePass() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilPassOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
StencilOperation DepthStencilState::StencilFrontFaceFail() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
StencilOperation DepthStencilState::StencilFrontFaceDepthFail() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilDepthFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
ComparisonFunction DepthStencilState::StencilFrontFaceCompare() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.FrontFace.StencilFunc) - 1;
|
||||||
|
return static_cast<ComparisonFunction>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
StencilOperation DepthStencilState::StencilBackFacePass() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilPassOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
StencilOperation DepthStencilState::StencilBackFaceFail() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
StencilOperation DepthStencilState::StencilBackFaceDepthFail() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilDepthFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
ComparisonFunction DepthStencilState::StencilBackFaceCompare() const {
|
||||||
|
const auto _value = static_cast<int>(impl->dxDescription.BackFace.StencilFunc) - 1;
|
||||||
|
return static_cast<ComparisonFunction>(_value);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
#include "platform-dx/device-dx.hpp"
|
#include "platform-dx/device-dx.hpp"
|
||||||
#include "platform-dx/rasterizerstate-dx.hpp"
|
#include "platform-dx/rasterizerstate-dx.hpp"
|
||||||
#include "platform-dx/depthstencilstate-dx.hpp"
|
|
||||||
#include "platform-dx/samplerstate-dx.hpp"
|
#include "platform-dx/samplerstate-dx.hpp"
|
||||||
#include "platform-dx/texture-dx.hpp"
|
#include "platform-dx/texture-dx.hpp"
|
||||||
#include "common/color.hpp"
|
#include "common/color.hpp"
|
||||||
@ -8,6 +7,7 @@
|
|||||||
#include "graphics/sprite.hpp"
|
#include "graphics/sprite.hpp"
|
||||||
#include "graphics/viewport.hpp"
|
#include "graphics/viewport.hpp"
|
||||||
#include "graphics/blendstate.hpp"
|
#include "graphics/blendstate.hpp"
|
||||||
|
#include "graphics/depthstencilstate.hpp"
|
||||||
#include "platform-dx/implementations.hpp"
|
#include "platform-dx/implementations.hpp"
|
||||||
|
|
||||||
using DxSpriteBatch = DirectX::SpriteBatch;
|
using DxSpriteBatch = DirectX::SpriteBatch;
|
||||||
@ -80,7 +80,7 @@ namespace xna {
|
|||||||
sort,
|
sort,
|
||||||
blendState ? blendState->impl->dxBlendState : nullptr,
|
blendState ? blendState->impl->dxBlendState : nullptr,
|
||||||
samplerState ? samplerState->_samplerState : nullptr,
|
samplerState ? samplerState->_samplerState : nullptr,
|
||||||
depthStencil ? depthStencil->dxDepthStencil : nullptr,
|
depthStencil ? depthStencil->impl->dxDepthStencil : nullptr,
|
||||||
rasterizerState ? rasterizerState->dxRasterizerState : nullptr,
|
rasterizerState ? rasterizerState->dxRasterizerState : nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
matrix
|
matrix
|
||||||
|
@ -2,43 +2,56 @@
|
|||||||
#define XNA_GRAPHICS_DEPTHSTENCILSTATE_HPP
|
#define XNA_GRAPHICS_DEPTHSTENCILSTATE_HPP
|
||||||
|
|
||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
|
#include "gresource.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class IDepthStencilState {
|
class DepthStencilState : public GraphicsResource {
|
||||||
public:
|
public:
|
||||||
virtual ~IDepthStencilState(){}
|
|
||||||
virtual bool Initialize(xna_error_nullarg) = 0;
|
|
||||||
virtual bool Apply(xna_error_ptr_arg) = 0;
|
|
||||||
|
|
||||||
virtual void DepthEnabled(bool value) = 0;
|
|
||||||
virtual void DepthWriteEnabled(bool value) = 0;
|
|
||||||
virtual void DepthCompareFunction(ComparisonFunction value) = 0;
|
|
||||||
virtual void StencilEnabled(bool value) = 0;
|
|
||||||
virtual void StencilReadMask(int value) = 0;
|
|
||||||
virtual void StencilWriteMask(int value) = 0;
|
|
||||||
virtual void StencilFrontFacePass(StencilOperation value) = 0;
|
|
||||||
virtual void StencilFrontFaceFail(StencilOperation value) = 0;
|
|
||||||
virtual void StencilFrontFaceDepthFail(StencilOperation value) = 0;
|
|
||||||
virtual void StencilFrontFaceCompare(ComparisonFunction value) = 0;
|
|
||||||
virtual void StencilBackFacePass(StencilOperation value) = 0;
|
|
||||||
virtual void StencilBackFaceFail(StencilOperation value) = 0;
|
|
||||||
virtual void StencilBackFaceDepthFail(StencilOperation value) = 0;
|
|
||||||
virtual void StencilBackFaceCompare(ComparisonFunction value) = 0;
|
|
||||||
|
|
||||||
virtual bool DepthEnabled() = 0;
|
DepthStencilState();
|
||||||
virtual bool DepthWriteEnabled() = 0;
|
DepthStencilState(sptr<GraphicsDevice> const& device);
|
||||||
virtual ComparisonFunction DepthCompareFunction() = 0;
|
|
||||||
virtual bool StencilEnabled() = 0;
|
~DepthStencilState();
|
||||||
virtual int StencilReadMask() = 0;
|
bool Initialize(xna_error_nullarg);
|
||||||
virtual int StencilWriteMask() = 0;
|
bool Apply(xna_error_ptr_arg);
|
||||||
virtual StencilOperation StencilFrontFacePass() = 0;
|
|
||||||
virtual StencilOperation StencilFrontFaceFail() = 0;
|
void DepthEnabled(bool value);
|
||||||
virtual StencilOperation StencilFrontFaceDepthFail() = 0;
|
void DepthWriteEnabled(bool value);
|
||||||
virtual ComparisonFunction StencilFrontFaceCompare() = 0;
|
void DepthCompareFunction(ComparisonFunction value);
|
||||||
virtual StencilOperation StencilBackFacePass() = 0;
|
void StencilEnabled(bool value);
|
||||||
virtual StencilOperation StencilBackFaceFail() = 0;
|
void StencilReadMask(Int value);
|
||||||
virtual StencilOperation StencilBackFaceDepthFail() = 0;
|
void StencilWriteMask(Int value);
|
||||||
virtual ComparisonFunction StencilBackFaceCompare() = 0;
|
void StencilFrontFacePass(StencilOperation value);
|
||||||
|
void StencilFrontFaceFail(StencilOperation value);
|
||||||
|
void StencilFrontFaceDepthFail(StencilOperation value);
|
||||||
|
void StencilFrontFaceCompare(ComparisonFunction value);
|
||||||
|
void StencilBackFacePass(StencilOperation value);
|
||||||
|
void StencilBackFaceFail(StencilOperation value);
|
||||||
|
void StencilBackFaceDepthFail(StencilOperation value);
|
||||||
|
void StencilBackFaceCompare(ComparisonFunction value);
|
||||||
|
|
||||||
|
bool DepthEnabled() const;
|
||||||
|
bool DepthWriteEnabled() const;
|
||||||
|
ComparisonFunction DepthCompareFunction() const;
|
||||||
|
bool StencilEnabled() const;
|
||||||
|
Int StencilReadMask() const;
|
||||||
|
Int StencilWriteMask() const;
|
||||||
|
StencilOperation StencilFrontFacePass() const;
|
||||||
|
StencilOperation StencilFrontFaceFail() const;
|
||||||
|
StencilOperation StencilFrontFaceDepthFail() const;
|
||||||
|
ComparisonFunction StencilFrontFaceCompare() const;
|
||||||
|
StencilOperation StencilBackFacePass() const;
|
||||||
|
StencilOperation StencilBackFaceFail() const;
|
||||||
|
StencilOperation StencilBackFaceDepthFail() const;
|
||||||
|
ComparisonFunction StencilBackFaceCompare() const;
|
||||||
|
|
||||||
|
static uptr<DepthStencilState> None();
|
||||||
|
static uptr<DepthStencilState> Default();
|
||||||
|
static uptr<DepthStencilState> DepthRead();
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct PlatformImplementation;
|
||||||
|
uptr<PlatformImplementation> impl = nullptr;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,193 +0,0 @@
|
|||||||
#ifndef XNA_PLATFORM_DEPTHSTENCILSTATE_DX_HPP
|
|
||||||
#define XNA_PLATFORM_DEPTHSTENCILSTATE_DX_HPP
|
|
||||||
|
|
||||||
#include "../graphics/depthstencilstate.hpp"
|
|
||||||
#include "../graphics/gresource.hpp"
|
|
||||||
#include "dxheaders.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
class DepthStencilState : public IDepthStencilState, public GraphicsResource {
|
|
||||||
public:
|
|
||||||
DepthStencilState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
|
||||||
dxDescription = defaultDesc();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DepthStencilState() override {
|
|
||||||
if (dxDepthStencil) {
|
|
||||||
dxDepthStencil->Release();
|
|
||||||
dxDepthStencil = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Initialize(xna_error_nullarg) override;
|
|
||||||
virtual bool Apply(xna_error_ptr_arg) override;
|
|
||||||
|
|
||||||
virtual constexpr void DepthEnabled(bool value) override {
|
|
||||||
dxDescription.DepthEnable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void DepthWriteEnabled(bool value) override {
|
|
||||||
dxDescription.DepthWriteMask = static_cast<D3D11_DEPTH_WRITE_MASK>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void DepthCompareFunction(ComparisonFunction value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilEnabled(bool value) override {
|
|
||||||
dxDescription.StencilEnable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilReadMask(int value) override {
|
|
||||||
dxDescription.StencilReadMask = static_cast<UINT8>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilWriteMask(int value) override {
|
|
||||||
dxDescription.StencilWriteMask = static_cast<UINT8>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFacePass(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFaceFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFaceDepthFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFaceCompare(ComparisonFunction value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFacePass(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFaceFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFaceDepthFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFaceCompare(ComparisonFunction value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
dxDescription.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr bool DepthEnabled() override {
|
|
||||||
return dxDescription.DepthEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr bool DepthWriteEnabled() override {
|
|
||||||
return static_cast<bool>(dxDescription.DepthWriteMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr ComparisonFunction DepthCompareFunction() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.DepthFunc) - 1;
|
|
||||||
return static_cast<ComparisonFunction>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr bool StencilEnabled() override {
|
|
||||||
return dxDescription.StencilEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr int StencilReadMask() override {
|
|
||||||
return static_cast<int>(dxDescription.StencilReadMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr int StencilWriteMask() override {
|
|
||||||
return static_cast<int>(dxDescription.StencilWriteMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilFrontFacePass() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilPassOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilFrontFaceFail() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilFrontFaceDepthFail() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilDepthFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr ComparisonFunction StencilFrontFaceCompare() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilFunc) - 1;
|
|
||||||
return static_cast<ComparisonFunction>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilBackFacePass() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.BackFace.StencilPassOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilBackFaceFail() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.BackFace.StencilFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilBackFaceDepthFail() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.BackFace.StencilDepthFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr ComparisonFunction StencilBackFaceCompare() override {
|
|
||||||
const auto _value = static_cast<int>(dxDescription.BackFace.StencilFunc) - 1;
|
|
||||||
return static_cast<ComparisonFunction>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uptr<DepthStencilState> None();
|
|
||||||
static uptr<DepthStencilState> Default();
|
|
||||||
static uptr<DepthStencilState> DepthRead();
|
|
||||||
|
|
||||||
public:
|
|
||||||
ID3D11DepthStencilState* dxDepthStencil = nullptr;
|
|
||||||
D3D11_DEPTH_STENCIL_DESC dxDescription{};
|
|
||||||
|
|
||||||
private:
|
|
||||||
DepthStencilState() : GraphicsResource(nullptr) {
|
|
||||||
dxDescription = defaultDesc();
|
|
||||||
}
|
|
||||||
|
|
||||||
static D3D11_DEPTH_STENCIL_DESC defaultDesc() {
|
|
||||||
D3D11_DEPTH_STENCIL_DESC _description{};
|
|
||||||
_description.DepthEnable = true;
|
|
||||||
_description.StencilEnable = true;
|
|
||||||
_description.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
|
|
||||||
|
|
||||||
_description.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
|
||||||
_description.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
_description.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
_description.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
|
|
||||||
_description.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
|
||||||
_description.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
_description.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
_description.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
|
|
||||||
|
|
||||||
_description.StencilReadMask = 0;
|
|
||||||
_description.StencilWriteMask = 0;
|
|
||||||
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
|
||||||
|
|
||||||
return _description;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -7,6 +7,7 @@
|
|||||||
#include "platform-dx/swapchain-dx.hpp"
|
#include "platform-dx/swapchain-dx.hpp"
|
||||||
#include "platform-dx/rendertarget-dx.hpp"
|
#include "platform-dx/rendertarget-dx.hpp"
|
||||||
#include "graphics/blendstate.hpp"
|
#include "graphics/blendstate.hpp"
|
||||||
|
#include "graphics/depthstencilstate.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
struct SpriteFont::PlatformImplementation {
|
struct SpriteFont::PlatformImplementation {
|
||||||
@ -248,4 +249,16 @@ namespace xna {
|
|||||||
_blob = blob;
|
_blob = blob;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DepthStencilState::PlatformImplementation {
|
||||||
|
~PlatformImplementation() {
|
||||||
|
if (dxDepthStencil) {
|
||||||
|
dxDepthStencil->Release();
|
||||||
|
dxDepthStencil = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11DepthStencilState* dxDepthStencil = nullptr;
|
||||||
|
D3D11_DEPTH_STENCIL_DESC dxDescription{};
|
||||||
|
};
|
||||||
}
|
}
|
@ -1,5 +1,4 @@
|
|||||||
#include "audioengine-dx.hpp"
|
#include "audioengine-dx.hpp"
|
||||||
#include "depthstencilstate-dx.hpp"
|
|
||||||
#include "device-dx.hpp"
|
#include "device-dx.hpp"
|
||||||
#include "displaymode-dx.hpp"
|
#include "displaymode-dx.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user