Skip to content

Commit

Permalink
Change graphics command APIs to use RenderPass instead
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Aug 15, 2016
1 parent 01b66c8 commit 7d374fb
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 301 deletions.
16 changes: 1 addition & 15 deletions include/Pomdog/Graphics/GraphicsCommandList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ class POMDOG_EXPORT GraphicsCommandList final {

std::size_t GetCount() const noexcept;

void Clear(const Color& color);

void Clear(ClearOptions options, const Color& color, float depth, std::uint8_t stencil);

void Draw(std::size_t vertexCount);

void DrawIndexed(
Expand All @@ -47,9 +43,7 @@ class POMDOG_EXPORT GraphicsCommandList final {
std::size_t indexCount,
std::size_t instanceCount);

void SetViewport(const Viewport& viewport);

void SetScissorRectangle(const Rectangle& rectangle);
void SetRenderPass(RenderPass && renderPass);

void SetPrimitiveTopology(PrimitiveTopology primitiveTopology);

Expand Down Expand Up @@ -77,14 +71,6 @@ class POMDOG_EXPORT GraphicsCommandList final {

void SetSamplerState(int index, const std::shared_ptr<SamplerState>& samplerState);

void SetRenderTarget();

void SetRenderTarget(const std::shared_ptr<RenderTarget2D>& renderTarget);

void SetRenderTargets(const std::vector<std::shared_ptr<RenderTarget2D>>& renderTargets);

void SetRenderTargets(std::vector<std::shared_ptr<RenderTarget2D>> && renderTargets);

Detail::NativeGraphicsCommandList* GetNativeGraphicsCommandList();

private:
Expand Down
78 changes: 13 additions & 65 deletions src/Graphics/GraphicsCommandList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Pomdog/Graphics/ConstantBuffer.hpp"
#include "Pomdog/Graphics/GraphicsDevice.hpp"
#include "Pomdog/Graphics/PipelineState.hpp"
#include "Pomdog/Graphics/RenderPass.hpp"
#include "Pomdog/Graphics/SamplerState.hpp"
#include "Pomdog/Graphics/VertexBufferBinding.hpp"
#include "Pomdog/Graphics/Viewport.hpp"
Expand Down Expand Up @@ -47,23 +48,6 @@ std::size_t GraphicsCommandList::GetCount() const noexcept
return nativeCommandList->GetCount();
}

void GraphicsCommandList::Clear(const Color& color)
{
///@todo badcode
ClearOptions options = ClearOptions::RenderTarget
| ClearOptions::DepthBuffer
| ClearOptions::Stencil;

POMDOG_ASSERT(nativeCommandList);
nativeCommandList->Clear(options, color, 1.f, 0);
}

void GraphicsCommandList::Clear(ClearOptions options, const Color& color, float depth, std::uint8_t stencil)
{
POMDOG_ASSERT(nativeCommandList);
nativeCommandList->Clear(options, color, depth, stencil);
}

void GraphicsCommandList::Draw(std::size_t vertexCount)
{
POMDOG_ASSERT(nativeCommandList);
Expand Down Expand Up @@ -99,19 +83,22 @@ void GraphicsCommandList::DrawIndexedInstanced(
nativeCommandList->DrawIndexedInstanced(indexCount, instanceCount);
}

void GraphicsCommandList::SetViewport(const Viewport& viewport)
void GraphicsCommandList::SetRenderPass(RenderPass && renderPass)
{
POMDOG_ASSERT(nativeCommandList);
POMDOG_ASSERT(viewport.Width > 0);
POMDOG_ASSERT(viewport.Height > 0);

nativeCommandList->SetViewport(viewport);
}
#if defined(DEBUG) && !defined(NDEBUG)
if (renderPass.Viewport) {
POMDOG_ASSERT(renderPass.Viewport->Width > 0);
POMDOG_ASSERT(renderPass.Viewport->Height > 0);
}
if (renderPass.ScissorRect) {
POMDOG_ASSERT(renderPass.Viewport->Width > 0);
POMDOG_ASSERT(renderPass.Viewport->Height > 0);
}
#endif

void GraphicsCommandList::SetScissorRectangle(const Rectangle& rectangle)
{
POMDOG_ASSERT(nativeCommandList);
nativeCommandList->SetScissorRectangle(rectangle);
nativeCommandList->SetRenderPass(std::move(renderPass));
}

void GraphicsCommandList::SetPrimitiveTopology(PrimitiveTopology primitiveTopology)
Expand Down Expand Up @@ -217,45 +204,6 @@ void GraphicsCommandList::SetSamplerState(int index, const std::shared_ptr<Sampl
nativeCommandList->SetSampler(index, std::move(nativeSamplerState));
}

void GraphicsCommandList::SetRenderTarget()
{
POMDOG_ASSERT(nativeCommandList);
nativeCommandList->SetRenderTarget();
}

void GraphicsCommandList::SetRenderTarget(const std::shared_ptr<RenderTarget2D>& renderTarget)
{
POMDOG_ASSERT(renderTarget);
POMDOG_ASSERT(nativeCommandList);
nativeCommandList->SetRenderTargets({renderTarget});
}

void GraphicsCommandList::SetRenderTargets(const std::vector<std::shared_ptr<RenderTarget2D>>& renderTargets)
{
POMDOG_ASSERT(!renderTargets.empty());
POMDOG_ASSERT(nativeCommandList);

if (renderTargets.empty()) {
nativeCommandList->SetRenderTarget();
return;
}

nativeCommandList->SetRenderTargets(renderTargets);
}

void GraphicsCommandList::SetRenderTargets(std::vector<std::shared_ptr<RenderTarget2D>> && renderTargets)
{
POMDOG_ASSERT(!renderTargets.empty());
POMDOG_ASSERT(nativeCommandList);

if (renderTargets.empty()) {
nativeCommandList->SetRenderTarget();
return;
}

nativeCommandList->SetRenderTargets(std::move(renderTargets));
}

Detail::NativeGraphicsCommandList* GraphicsCommandList::GetNativeGraphicsCommandList()
{
POMDOG_ASSERT(nativeCommandList);
Expand Down
Loading

0 comments on commit 7d374fb

Please sign in to comment.