From 58371f37455e121804c569c3eccf42a20b26600a Mon Sep 17 00:00:00 2001 From: mogemimi Date: Fri, 18 Dec 2020 05:25:42 +0900 Subject: [PATCH] Add SetIndexBuffer() to GraphicsCommandList --- .../Pomdog/Graphics/GraphicsCommandList.hpp | 5 ++-- .../GraphicsCommandListImmediate.cpp | 27 +++++++------------ .../GraphicsCommandListImmediate.hpp | 5 ++-- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/include/Pomdog/Graphics/GraphicsCommandList.hpp b/include/Pomdog/Graphics/GraphicsCommandList.hpp index e7ec6a5f4..26afb4aad 100644 --- a/include/Pomdog/Graphics/GraphicsCommandList.hpp +++ b/include/Pomdog/Graphics/GraphicsCommandList.hpp @@ -37,7 +37,6 @@ class POMDOG_EXPORT GraphicsCommandList { /// Draws the specified indexed primitives. virtual void DrawIndexed( - const std::shared_ptr& indexBuffer, std::size_t indexCount, std::size_t startIndexLocation) = 0; @@ -50,7 +49,6 @@ class POMDOG_EXPORT GraphicsCommandList { /// Draws the specified indexed, instanced primitives. virtual void DrawIndexedInstanced( - const std::shared_ptr& indexBuffer, std::size_t indexCountPerInstance, std::size_t instanceCount, std::size_t startIndexLocation, @@ -77,6 +75,9 @@ class POMDOG_EXPORT GraphicsCommandList { const std::shared_ptr& vertexBuffer, std::size_t offset) = 0; + /// Sets an index buffer. + virtual void SetIndexBuffer(const std::shared_ptr& indexBuffer) = 0; + /// Sets a pipeline state. virtual void SetPipelineState(const std::shared_ptr& pipelineState) = 0; diff --git a/src/Graphics.Backends/GraphicsCommandListImmediate.cpp b/src/Graphics.Backends/GraphicsCommandListImmediate.cpp index 8c505dad5..d7fee1e56 100644 --- a/src/Graphics.Backends/GraphicsCommandListImmediate.cpp +++ b/src/Graphics.Backends/GraphicsCommandListImmediate.cpp @@ -232,18 +232,9 @@ void GraphicsCommandListImmediate::Draw( } void GraphicsCommandListImmediate::DrawIndexed( - const std::shared_ptr& indexBuffer, std::size_t indexCount, std::size_t startIndexLocation) { - { - POMDOG_ASSERT(indexBuffer); - auto command = std::make_unique(); - command->commandType = GraphicsCommandType::SetIndexBufferCommand; - command->indexBuffer = indexBuffer; - commands.push_back(std::move(command)); - } - POMDOG_ASSERT(indexCount >= 1); auto command = std::make_unique(); command->commandType = GraphicsCommandType::DrawIndexedCommand; @@ -269,20 +260,11 @@ void GraphicsCommandListImmediate::DrawInstanced( } void GraphicsCommandListImmediate::DrawIndexedInstanced( - const std::shared_ptr& indexBuffer, std::size_t indexCountPerInstance, std::size_t instanceCount, std::size_t startIndexLocation, std::size_t startInstanceLocation) { - { - POMDOG_ASSERT(indexBuffer); - auto command = std::make_unique(); - command->commandType = GraphicsCommandType::SetIndexBufferCommand; - command->indexBuffer = indexBuffer; - commands.push_back(std::move(command)); - } - POMDOG_ASSERT(indexCountPerInstance >= 1); auto command = std::make_unique(); command->commandType = GraphicsCommandType::DrawIndexedInstancedCommand; @@ -352,6 +334,15 @@ void GraphicsCommandListImmediate::SetVertexBuffer( commands.push_back(std::move(command)); } +void GraphicsCommandListImmediate::SetIndexBuffer(const std::shared_ptr& indexBuffer) +{ + POMDOG_ASSERT(indexBuffer != nullptr); + auto command = std::make_unique(); + command->commandType = GraphicsCommandType::SetIndexBufferCommand; + command->indexBuffer = indexBuffer; + commands.push_back(std::move(command)); +} + void GraphicsCommandListImmediate::SetPipelineState(const std::shared_ptr& pipelineState) { POMDOG_ASSERT(pipelineState); diff --git a/src/Graphics.Backends/GraphicsCommandListImmediate.hpp b/src/Graphics.Backends/GraphicsCommandListImmediate.hpp index 8dac44da8..bf69ab823 100644 --- a/src/Graphics.Backends/GraphicsCommandListImmediate.hpp +++ b/src/Graphics.Backends/GraphicsCommandListImmediate.hpp @@ -67,7 +67,6 @@ class GraphicsCommandListImmediate final : public GraphicsCommandList { /// Draws the specified indexed primitives. void DrawIndexed( - const std::shared_ptr& indexBuffer, std::size_t indexCount, std::size_t startIndexLocation) override; @@ -80,7 +79,6 @@ class GraphicsCommandListImmediate final : public GraphicsCommandList { /// Draws the specified indexed, instanced primitives. void DrawIndexedInstanced( - const std::shared_ptr& indexBuffer, std::size_t indexCountPerInstance, std::size_t instanceCount, std::size_t startIndexLocation, @@ -107,6 +105,9 @@ class GraphicsCommandListImmediate final : public GraphicsCommandList { const std::shared_ptr& vertexBuffer, std::size_t offset) override; + /// Sets an index buffer. + void SetIndexBuffer(const std::shared_ptr& indexBuffer) override; + /// Sets a pipeline state. void SetPipelineState(const std::shared_ptr& pipelineState) override;