From 8690aa356c8134174ad3c12dca07363143af16d4 Mon Sep 17 00:00:00 2001 From: mogemimi Date: Sat, 12 Sep 2015 20:15:11 +0900 Subject: [PATCH] Add RSV and DSV formats to PipelineStateDescription --- .../AssetBuilders/PipelineStateBuilder.hpp | 7 +++ .../Graphics/PipelineStateDescription.hpp | 4 ++ .../AssetBuilders/PipelineStateBuilder.cpp | 52 +++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/include/Pomdog/Content/AssetBuilders/PipelineStateBuilder.hpp b/include/Pomdog/Content/AssetBuilders/PipelineStateBuilder.hpp index bbd79b3a9..8b5290695 100644 --- a/include/Pomdog/Content/AssetBuilders/PipelineStateBuilder.hpp +++ b/include/Pomdog/Content/AssetBuilders/PipelineStateBuilder.hpp @@ -7,6 +7,7 @@ #include "Pomdog/Basic/Export.hpp" #include #include +#include namespace Pomdog { namespace Detail { @@ -46,6 +47,12 @@ class POMDOG_EXPORT Builder { Builder & SetConstantBufferBindSlot(std::string const& name, int slotIndex); + Builder & SetRenderTargetViewFormats(std::vector const& renderTargetViewFormats); + + Builder & SetRenderTargetViewFormats(std::vector && renderTargetViewFormats); + + Builder & SetDepthStencilViewFormat(DepthFormat depthStencilViewFormat); + std::shared_ptr Build(); std::shared_ptr CreateEffectReflection( diff --git a/include/Pomdog/Graphics/PipelineStateDescription.hpp b/include/Pomdog/Graphics/PipelineStateDescription.hpp index 07e7f248e..74428b83b 100644 --- a/include/Pomdog/Graphics/PipelineStateDescription.hpp +++ b/include/Pomdog/Graphics/PipelineStateDescription.hpp @@ -4,9 +4,11 @@ #include "Pomdog/Graphics/detail/ForwardDeclarations.hpp" #include "Pomdog/Graphics/BlendDescription.hpp" +#include "Pomdog/Graphics/DepthFormat.hpp" #include "Pomdog/Graphics/DepthStencilDescription.hpp" #include "Pomdog/Graphics/InputLayoutDescription.hpp" #include "Pomdog/Graphics/RasterizerDescription.hpp" +#include "Pomdog/Graphics/SurfaceFormat.hpp" #include #include #include @@ -24,6 +26,8 @@ struct PipelineStateDescription { BlendDescription BlendState; RasterizerDescription RasterizerState; DepthStencilDescription DepthStencilState; + std::vector RenderTargetViewFormats; + DepthFormat DepthStencilViewFormat; std::uint32_t MultiSampleMask; }; diff --git a/src/Content/AssetBuilders/PipelineStateBuilder.cpp b/src/Content/AssetBuilders/PipelineStateBuilder.cpp index 803d2ee22..d6f66e12c 100644 --- a/src/Content/AssetBuilders/PipelineStateBuilder.cpp +++ b/src/Content/AssetBuilders/PipelineStateBuilder.cpp @@ -9,6 +9,7 @@ #include "Pomdog/Graphics/Shader.hpp" #include "Pomdog/Utility/Assert.hpp" #include "Pomdog/Utility/Exception.hpp" +#include "Pomdog/Logging/Log.hpp" #include namespace Pomdog { @@ -22,6 +23,8 @@ class Builder::Impl final { bool hasBlendState; bool hasRasterizerState; bool hasDepthStencilState; + bool hasRenderTargetViewFormats; + bool hasDepthStencilViewFormat; Impl(); @@ -35,6 +38,8 @@ Builder::Impl::Impl() hasBlendState = false; hasRasterizerState = false; hasDepthStencilState = false; + hasRenderTargetViewFormats = false; + hasDepthStencilViewFormat = false; } //----------------------------------------------------------------------- std::shared_ptr Builder::Impl::Load() @@ -56,6 +61,26 @@ std::shared_ptr Builder::Impl::Load() hasDepthStencilState = true; } + if (!hasRenderTargetViewFormats) { +#if defined(DEBUG) && !defined(NDEBUG) + Log::Warning( + "Pomdog", + "[Warning] Please call Builder::SetRenderTargetViewFormats() in your code."); +#endif + description.RenderTargetViewFormats = { SurfaceFormat::R8G8B8A8_UNorm }; + hasRenderTargetViewFormats = true; + } + + if (!hasDepthStencilViewFormat) { +#if defined(DEBUG) && !defined(NDEBUG) + Log::Warning( + "Pomdog", + "[Warning] Please call Builder::SetDepthStencilViewFormat() in your code."); +#endif + description.DepthStencilViewFormat = DepthFormat::None; + hasDepthStencilViewFormat = true; + } + auto pipelineState = std::make_shared(graphicsDevice, description); return std::move(pipelineState); } @@ -174,6 +199,33 @@ Builder & Builder::SetConstantBufferBindSlot( return *this; } //----------------------------------------------------------------------- +Builder & Builder::SetRenderTargetViewFormats( + std::vector const& renderTargetViewFormats) +{ + POMDOG_ASSERT(impl); + impl->description.RenderTargetViewFormats = renderTargetViewFormats; + impl->hasRenderTargetViewFormats = true; + return *this; +} +//----------------------------------------------------------------------- +Builder & Builder::SetRenderTargetViewFormats( + std::vector && renderTargetViewFormats) +{ + POMDOG_ASSERT(impl); + impl->description.RenderTargetViewFormats = std::move(renderTargetViewFormats); + impl->hasRenderTargetViewFormats = true; + return *this; +} +//----------------------------------------------------------------------- +Builder & Builder::SetDepthStencilViewFormat( + DepthFormat depthStencilViewFormat) +{ + POMDOG_ASSERT(impl); + impl->description.DepthStencilViewFormat = depthStencilViewFormat; + impl->hasDepthStencilViewFormat = true; + return *this; +} +//----------------------------------------------------------------------- std::shared_ptr Builder::Build() { POMDOG_ASSERT(impl);