Skip to content

Commit

Permalink
Add SetIndexBuffer() to GraphicsCommandList
Browse files Browse the repository at this point in the history
  • Loading branch information
mogemimi committed Dec 17, 2020
1 parent c733c9d commit 58371f3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
5 changes: 3 additions & 2 deletions include/Pomdog/Graphics/GraphicsCommandList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class POMDOG_EXPORT GraphicsCommandList {

/// Draws the specified indexed primitives.
virtual void DrawIndexed(
const std::shared_ptr<IndexBuffer>& indexBuffer,
std::size_t indexCount,
std::size_t startIndexLocation) = 0;

Expand All @@ -50,7 +49,6 @@ class POMDOG_EXPORT GraphicsCommandList {

/// Draws the specified indexed, instanced primitives.
virtual void DrawIndexedInstanced(
const std::shared_ptr<IndexBuffer>& indexBuffer,
std::size_t indexCountPerInstance,
std::size_t instanceCount,
std::size_t startIndexLocation,
Expand All @@ -77,6 +75,9 @@ class POMDOG_EXPORT GraphicsCommandList {
const std::shared_ptr<VertexBuffer>& vertexBuffer,
std::size_t offset) = 0;

/// Sets an index buffer.
virtual void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer) = 0;

/// Sets a pipeline state.
virtual void SetPipelineState(const std::shared_ptr<PipelineState>& pipelineState) = 0;

Expand Down
27 changes: 9 additions & 18 deletions src/Graphics.Backends/GraphicsCommandListImmediate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,9 @@ void GraphicsCommandListImmediate::Draw(
}

void GraphicsCommandListImmediate::DrawIndexed(
const std::shared_ptr<IndexBuffer>& indexBuffer,
std::size_t indexCount,
std::size_t startIndexLocation)
{
{
POMDOG_ASSERT(indexBuffer);
auto command = std::make_unique<SetIndexBufferCommand>();
command->commandType = GraphicsCommandType::SetIndexBufferCommand;
command->indexBuffer = indexBuffer;
commands.push_back(std::move(command));
}

POMDOG_ASSERT(indexCount >= 1);
auto command = std::make_unique<DrawIndexedCommand>();
command->commandType = GraphicsCommandType::DrawIndexedCommand;
Expand All @@ -269,20 +260,11 @@ void GraphicsCommandListImmediate::DrawInstanced(
}

void GraphicsCommandListImmediate::DrawIndexedInstanced(
const std::shared_ptr<IndexBuffer>& 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<SetIndexBufferCommand>();
command->commandType = GraphicsCommandType::SetIndexBufferCommand;
command->indexBuffer = indexBuffer;
commands.push_back(std::move(command));
}

POMDOG_ASSERT(indexCountPerInstance >= 1);
auto command = std::make_unique<DrawIndexedInstancedCommand>();
command->commandType = GraphicsCommandType::DrawIndexedInstancedCommand;
Expand Down Expand Up @@ -352,6 +334,15 @@ void GraphicsCommandListImmediate::SetVertexBuffer(
commands.push_back(std::move(command));
}

void GraphicsCommandListImmediate::SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer)
{
POMDOG_ASSERT(indexBuffer != nullptr);
auto command = std::make_unique<SetIndexBufferCommand>();
command->commandType = GraphicsCommandType::SetIndexBufferCommand;
command->indexBuffer = indexBuffer;
commands.push_back(std::move(command));
}

void GraphicsCommandListImmediate::SetPipelineState(const std::shared_ptr<PipelineState>& pipelineState)
{
POMDOG_ASSERT(pipelineState);
Expand Down
5 changes: 3 additions & 2 deletions src/Graphics.Backends/GraphicsCommandListImmediate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class GraphicsCommandListImmediate final : public GraphicsCommandList {

/// Draws the specified indexed primitives.
void DrawIndexed(
const std::shared_ptr<IndexBuffer>& indexBuffer,
std::size_t indexCount,
std::size_t startIndexLocation) override;

Expand All @@ -80,7 +79,6 @@ class GraphicsCommandListImmediate final : public GraphicsCommandList {

/// Draws the specified indexed, instanced primitives.
void DrawIndexedInstanced(
const std::shared_ptr<IndexBuffer>& indexBuffer,
std::size_t indexCountPerInstance,
std::size_t instanceCount,
std::size_t startIndexLocation,
Expand All @@ -107,6 +105,9 @@ class GraphicsCommandListImmediate final : public GraphicsCommandList {
const std::shared_ptr<VertexBuffer>& vertexBuffer,
std::size_t offset) override;

/// Sets an index buffer.
void SetIndexBuffer(const std::shared_ptr<IndexBuffer>& indexBuffer) override;

/// Sets a pipeline state.
void SetPipelineState(const std::shared_ptr<PipelineState>& pipelineState) override;

Expand Down

0 comments on commit 58371f3

Please sign in to comment.