Skip to content

Commit

Permalink
Add RSV and DSV formats to PipelineStateDescription
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Mar 22, 2016
1 parent 0ffb391 commit 8690aa3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/Pomdog/Content/AssetBuilders/PipelineStateBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Pomdog/Basic/Export.hpp"
#include <string>
#include <memory>
#include <vector>

namespace Pomdog {
namespace Detail {
Expand Down Expand Up @@ -46,6 +47,12 @@ class POMDOG_EXPORT Builder<PipelineState> {

Builder & SetConstantBufferBindSlot(std::string const& name, int slotIndex);

Builder & SetRenderTargetViewFormats(std::vector<SurfaceFormat> const& renderTargetViewFormats);

Builder & SetRenderTargetViewFormats(std::vector<SurfaceFormat> && renderTargetViewFormats);

Builder & SetDepthStencilViewFormat(DepthFormat depthStencilViewFormat);

std::shared_ptr<PipelineState> Build();

std::shared_ptr<EffectReflection> CreateEffectReflection(
Expand Down
4 changes: 4 additions & 0 deletions include/Pomdog/Graphics/PipelineStateDescription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>
#include <vector>
#include <string>
Expand All @@ -24,6 +26,8 @@ struct PipelineStateDescription {
BlendDescription BlendState;
RasterizerDescription RasterizerState;
DepthStencilDescription DepthStencilState;
std::vector<SurfaceFormat> RenderTargetViewFormats;
DepthFormat DepthStencilViewFormat;
std::uint32_t MultiSampleMask;
};

Expand Down
52 changes: 52 additions & 0 deletions src/Content/AssetBuilders/PipelineStateBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <utility>

namespace Pomdog {
Expand All @@ -22,6 +23,8 @@ class Builder<PipelineState>::Impl final {
bool hasBlendState;
bool hasRasterizerState;
bool hasDepthStencilState;
bool hasRenderTargetViewFormats;
bool hasDepthStencilViewFormat;

Impl();

Expand All @@ -35,6 +38,8 @@ Builder<PipelineState>::Impl::Impl()
hasBlendState = false;
hasRasterizerState = false;
hasDepthStencilState = false;
hasRenderTargetViewFormats = false;
hasDepthStencilViewFormat = false;
}
//-----------------------------------------------------------------------
std::shared_ptr<PipelineState> Builder<PipelineState>::Impl::Load()
Expand All @@ -56,6 +61,26 @@ std::shared_ptr<PipelineState> Builder<PipelineState>::Impl::Load()
hasDepthStencilState = true;
}

if (!hasRenderTargetViewFormats) {
#if defined(DEBUG) && !defined(NDEBUG)
Log::Warning(
"Pomdog",
"[Warning] Please call Builder<PipelineState>::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<PipelineState>::SetDepthStencilViewFormat() in your code.");
#endif
description.DepthStencilViewFormat = DepthFormat::None;
hasDepthStencilViewFormat = true;
}

auto pipelineState = std::make_shared<PipelineState>(graphicsDevice, description);
return std::move(pipelineState);
}
Expand Down Expand Up @@ -174,6 +199,33 @@ Builder<PipelineState> & Builder<PipelineState>::SetConstantBufferBindSlot(
return *this;
}
//-----------------------------------------------------------------------
Builder<PipelineState> & Builder<PipelineState>::SetRenderTargetViewFormats(
std::vector<SurfaceFormat> const& renderTargetViewFormats)
{
POMDOG_ASSERT(impl);
impl->description.RenderTargetViewFormats = renderTargetViewFormats;
impl->hasRenderTargetViewFormats = true;
return *this;
}
//-----------------------------------------------------------------------
Builder<PipelineState> & Builder<PipelineState>::SetRenderTargetViewFormats(
std::vector<SurfaceFormat> && renderTargetViewFormats)
{
POMDOG_ASSERT(impl);
impl->description.RenderTargetViewFormats = std::move(renderTargetViewFormats);
impl->hasRenderTargetViewFormats = true;
return *this;
}
//-----------------------------------------------------------------------
Builder<PipelineState> & Builder<PipelineState>::SetDepthStencilViewFormat(
DepthFormat depthStencilViewFormat)
{
POMDOG_ASSERT(impl);
impl->description.DepthStencilViewFormat = depthStencilViewFormat;
impl->hasDepthStencilViewFormat = true;
return *this;
}
//-----------------------------------------------------------------------
std::shared_ptr<PipelineState> Builder<PipelineState>::Build()
{
POMDOG_ASSERT(impl);
Expand Down

0 comments on commit 8690aa3

Please sign in to comment.