diff --git a/CMakeLists.txt b/CMakeLists.txt index d3075a7f1c..cc9a9ded88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,6 +273,7 @@ set(FilesMsvcNatvis ${PROJECT_SOURCE_DIR}/LLGL.natvis) # Common files file(GLOB FilesInclude ${PROJECT_INCLUDE_DIR}/LLGL/*.*) +file(GLOB FilesIncludeBackend ${PROJECT_INCLUDE_DIR}/LLGL/Backend/*.inl) file(GLOB FilesIncludeContainer ${PROJECT_INCLUDE_DIR}/LLGL/Container/*.*) file(GLOB FilesIncludeUtils ${PROJECT_INCLUDE_DIR}/LLGL/Utils/*.*) file(GLOB FilesIncludePlatformBase ${PROJECT_INCLUDE_DIR}/LLGL/Platform/*.*) @@ -507,6 +508,7 @@ set(FilesExample_HelloAndroid ${EXAMPLE_PROJECTS_DIR}/HelloAndroid/cpp/Example.c source_group("NatVis" FILES ${FilesMsvcNatvis}) source_group("Include" FILES ${FilesInclude}) +source_group("Include\\Backend" FILES ${FilesIncludeBackend}) source_group("Include\\Container" FILES ${FilesIncludeContainer}) source_group("Include\\Utils" FILES ${FilesIncludeUtils}) source_group("Sources\\Core" FILES ${FilesCore}) @@ -605,6 +607,7 @@ endif() set( FilesLLGL ${FilesInclude} + ${FilesIncludeBackend} ${FilesIncludeContainer} ${FilesIncludeUtils} ${FilesIncludePlatformBase} diff --git a/include/LLGL/Backend/CommandBuffer.Blitting.inl b/include/LLGL/Backend/CommandBuffer.Blitting.inl new file mode 100644 index 0000000000..b053297656 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Blitting.inl @@ -0,0 +1,75 @@ +/* + * CommandBuffer.Blitting.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Blitting ----- */ + +virtual void UpdateBuffer( + Buffer& dstBuffer, + std::uint64_t dstOffset, + const void* data, + std::uint16_t dataSize +) override final; + +virtual void CopyBuffer( + Buffer& dstBuffer, + std::uint64_t dstOffset, + Buffer& srcBuffer, + std::uint64_t srcOffset, + std::uint64_t size +) override final; + +virtual void CopyBufferFromTexture( + Buffer& dstBuffer, + std::uint64_t dstOffset, + Texture& srcTexture, + const TextureRegion& srcRegion, + std::uint32_t rowStride = 0, + std::uint32_t layerStride = 0 +) override final; + +virtual void FillBuffer( + Buffer& dstBuffer, + std::uint64_t dstOffset, + std::uint32_t value, + std::uint64_t fillSize = Constants::wholeSize +) override final; + +virtual void CopyTexture( + Texture& dstTexture, + const TextureLocation& dstLocation, + Texture& srcTexture, + const TextureLocation& srcLocation, + const Extent3D& extent +) override final; + +virtual void CopyTextureFromBuffer( + Texture& dstTexture, + const TextureRegion& dstRegion, + Buffer& srcBuffer, + std::uint64_t srcOffset, + std::uint32_t rowStride = 0, + std::uint32_t layerStride = 0 +) override final; + +virtual void CopyTextureFromFramebuffer( + Texture& dstTexture, + const TextureRegion& dstRegion, + const Offset2D& srcOffset +) override final; + +virtual void GenerateMips( + Texture& texture +) override final; + +virtual void GenerateMips( + Texture& texture, + const TextureSubresource& subresource +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Compute.inl b/include/LLGL/Backend/CommandBuffer.Compute.inl new file mode 100644 index 0000000000..2e7d6de7f1 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Compute.inl @@ -0,0 +1,23 @@ +/* + * CommandBuffer.Compute.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Compute ----- */ + +virtual void Dispatch( + std::uint32_t numWorkGroupsX, + std::uint32_t numWorkGroupsY, + std::uint32_t numWorkGroupsZ +) override final; + +virtual void DispatchIndirect( + Buffer& buffer, + std::uint64_t offset +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Debugging.inl b/include/LLGL/Backend/CommandBuffer.Debugging.inl new file mode 100644 index 0000000000..54f148e7f8 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Debugging.inl @@ -0,0 +1,20 @@ +/* + * CommandBuffer.Debugging.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Debugging ----- */ + +virtual void PushDebugGroup( + const char* name +) override final; + +virtual void PopDebugGroup( + void +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Drawing.inl b/include/LLGL/Backend/CommandBuffer.Drawing.inl new file mode 100644 index 0000000000..3f639e4e5a --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Drawing.inl @@ -0,0 +1,86 @@ +/* + * CommandBuffer.Drawing.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Drawing ----- */ + +virtual void Draw( + std::uint32_t numVertices, + std::uint32_t firstVertex +) override final; + +virtual void DrawIndexed( + std::uint32_t numIndices, + std::uint32_t firstIndex +) override final; + +virtual void DrawIndexed( + std::uint32_t numIndices, + std::uint32_t firstIndex, + std::int32_t vertexOffset +) override final; + +virtual void DrawInstanced( + std::uint32_t numVertices, + std::uint32_t firstVertex, + std::uint32_t numInstances +) override final; + +virtual void DrawInstanced( + std::uint32_t numVertices, + std::uint32_t firstVertex, + std::uint32_t numInstances, + std::uint32_t firstInstance +) override final; + +virtual void DrawIndexedInstanced( + std::uint32_t numIndices, + std::uint32_t numInstances, + std::uint32_t firstIndex +) override final; + +virtual void DrawIndexedInstanced( + std::uint32_t numIndices, + std::uint32_t numInstances, + std::uint32_t firstIndex, + std::int32_t vertexOffset +) override final; + +virtual void DrawIndexedInstanced( + std::uint32_t numIndices, + std::uint32_t numInstances, + std::uint32_t firstIndex, + std::int32_t vertexOffset, + std::uint32_t firstInstance +) override final; + +virtual void DrawIndirect( + Buffer& buffer, + std::uint64_t offset +) override final; + +virtual void DrawIndirect( + Buffer& buffer, + std::uint64_t offset, + std::uint32_t numCommands, + std::uint32_t stride +) override final; + +virtual void DrawIndexedIndirect( + Buffer& buffer, + std::uint64_t offset +) override final; + +virtual void DrawIndexedIndirect( + Buffer& buffer, + std::uint64_t offset, + std::uint32_t numCommands, + std::uint32_t stride +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Encoding.inl b/include/LLGL/Backend/CommandBuffer.Encoding.inl new file mode 100644 index 0000000000..7d07589235 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Encoding.inl @@ -0,0 +1,24 @@ +/* + * CommandBuffer.Encoding.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Encoding ----- */ + +virtual void Begin( + void +) override final; + +virtual void End( + void +) override final; + +virtual void Execute( + CommandBuffer& deferredCommandBuffer +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Extensions.inl b/include/LLGL/Backend/CommandBuffer.Extensions.inl new file mode 100644 index 0000000000..ddb06e1725 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Extensions.inl @@ -0,0 +1,17 @@ +/* + * CommandBuffer.Extensions.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Extensions ----- */ + +virtual void SetGraphicsAPIDependentState( + const void* stateDesc, + std::size_t stateDescSize +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.InputAssembly.inl b/include/LLGL/Backend/CommandBuffer.InputAssembly.inl new file mode 100644 index 0000000000..9254a607f1 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.InputAssembly.inl @@ -0,0 +1,30 @@ +/* + * CommandBuffer.InputAssembly.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Input Assembly ------ */ + +virtual void SetVertexBuffer( + Buffer& buffer +) override final; + +virtual void SetVertexBufferArray( + BufferArray& bufferArray +) override final; + +virtual void SetIndexBuffer( + Buffer& buffer +) override final; + +virtual void SetIndexBuffer( + Buffer& buffer, + const Format format, + std::uint64_t offset = 0 +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.PipelineStates.inl b/include/LLGL/Backend/CommandBuffer.PipelineStates.inl new file mode 100644 index 0000000000..509a271821 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.PipelineStates.inl @@ -0,0 +1,31 @@ +/* + * CommandBuffer.PipelineStates.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Pipeline States ----- */ + +virtual void SetPipelineState( + PipelineState& pipelineState +) override final; + +virtual void SetBlendFactor( + const float color[4] +) override final; + +virtual void SetStencilReference( + std::uint32_t reference, + const StencilFace stencilFace = StencilFace::FrontAndBack +) override final; + +virtual void SetUniforms( + std::uint32_t first, + const void* data, + std::uint16_t dataSize +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Queries.inl b/include/LLGL/Backend/CommandBuffer.Queries.inl new file mode 100644 index 0000000000..d5eec5094c --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Queries.inl @@ -0,0 +1,32 @@ +/* + * CommandBuffer.Queries.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Queries ----- */ + +virtual void BeginQuery( + QueryHeap& queryHeap, + std::uint32_t query +) override final; + +virtual void EndQuery( + QueryHeap& queryHeap, + std::uint32_t query +) override final; + +virtual void BeginRenderCondition( + QueryHeap& queryHeap, + std::uint32_t query, + const RenderConditionMode mode +) override final; + +virtual void EndRenderCondition( + void +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.RenderPasses.inl b/include/LLGL/Backend/CommandBuffer.RenderPasses.inl new file mode 100644 index 0000000000..b5ac5e3abe --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.RenderPasses.inl @@ -0,0 +1,34 @@ +/* + * CommandBuffer.RenderPasses.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Render Passes ----- */ + +virtual void BeginRenderPass( + RenderTarget& renderTarget, + const RenderPass* renderPass = nullptr, + std::uint32_t numClearValues = 0, + const ClearValue* clearValues = nullptr, + std::uint32_t swapBufferIndex = Constants::currentSwapIndex +) override final; + +virtual void EndRenderPass( + void +) override final; + +virtual void Clear( + long flags, + const ClearValue& clearValue = {} +) override final; + +virtual void ClearAttachments( + std::uint32_t numAttachments, + const AttachmentClear* attachments +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.Resources.inl b/include/LLGL/Backend/CommandBuffer.Resources.inl new file mode 100644 index 0000000000..e388857a8f --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.Resources.inl @@ -0,0 +1,30 @@ +/* + * CommandBuffer.Resources.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Resources ----- */ + +virtual void SetResourceHeap( + ResourceHeap& resourceHeap, + std::uint32_t descriptorSet = 0 +) override final; + +virtual void SetResource( + std::uint32_t descriptor, + Resource& resource +) override final; + +virtual void ResetResourceSlots( + const ResourceType resourceType, + std::uint32_t firstSlot, + std::uint32_t numSlots, + long bindFlags, + long stageFlags = StageFlags::AllStages +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.StreamOutput.inl b/include/LLGL/Backend/CommandBuffer.StreamOutput.inl new file mode 100644 index 0000000000..0371205664 --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.StreamOutput.inl @@ -0,0 +1,21 @@ +/* + * CommandBuffer.StreamOutput.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Stream Output ------ */ + +virtual void BeginStreamOutput( + std::uint32_t numBuffers, + Buffer* const * buffers +) override final; + +virtual void EndStreamOutput( + void +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.ViewportsAndScissors.inl b/include/LLGL/Backend/CommandBuffer.ViewportsAndScissors.inl new file mode 100644 index 0000000000..48226cc3aa --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.ViewportsAndScissors.inl @@ -0,0 +1,30 @@ +/* + * CommandBuffer.ViewportsAndScissors.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +/* ----- Viewport and Scissor ----- */ + +virtual void SetViewport( + const Viewport& viewport +) override final; + +virtual void SetViewports( + std::uint32_t numViewports, + const Viewport* viewports +) override final; + +virtual void SetScissor( + const Scissor& scissor +) override final; + +virtual void SetScissors( + std::uint32_t numScissors, + const Scissor* scissors +) override final; + + + +// ================================================================================ diff --git a/include/LLGL/Backend/CommandBuffer.inl b/include/LLGL/Backend/CommandBuffer.inl new file mode 100644 index 0000000000..9d524d967b --- /dev/null +++ b/include/LLGL/Backend/CommandBuffer.inl @@ -0,0 +1,24 @@ +/* + * CommandBuffer.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +// ================================================================================ diff --git a/sources/Renderer/DebugLayer/DbgCommandBuffer.h b/sources/Renderer/DebugLayer/DbgCommandBuffer.h index d8efd5625b..d907c8e104 100644 --- a/sources/Renderer/DebugLayer/DbgCommandBuffer.h +++ b/sources/Renderer/DebugLayer/DbgCommandBuffer.h @@ -39,7 +39,9 @@ class DbgCommandBuffer final : public CommandBuffer public: - /* ----- Common ----- */ + #include + + public: DbgCommandBuffer( RenderSystem& renderSystemInstance, @@ -51,182 +53,14 @@ class DbgCommandBuffer final : public CommandBuffer const RenderingCapabilities& caps ); - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - - /* ----- Extensions ----- */ - - void SetGraphicsAPIDependentState(const void* stateDesc, std::size_t stateDescSize) override; - public: - /* ----- Internal ----- */ - void NextProfile(FrameProfile& outputProfile); void ValidateSubmit(); public: - /* ----- Debugging members ----- */ - CommandBuffer& instance; const CommandBufferDescriptor desc; diff --git a/sources/Renderer/Direct3D11/D3D11CommandBuffer.h b/sources/Renderer/Direct3D11/D3D11CommandBuffer.h index 623901cdf2..833dafbcc5 100644 --- a/sources/Renderer/Direct3D11/D3D11CommandBuffer.h +++ b/sources/Renderer/Direct3D11/D3D11CommandBuffer.h @@ -36,7 +36,9 @@ class D3D11CommandBuffer final : public CommandBuffer public: - /* ----- Common ----- */ + #include + + public: D3D11CommandBuffer( ID3D11Device* device, @@ -45,170 +47,6 @@ class D3D11CommandBuffer final : public CommandBuffer const CommandBufferDescriptor& desc ); - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query, const RenderConditionMode mode) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - - /* ----- Extensions ----- */ - - void SetGraphicsAPIDependentState(const void* stateDesc, std::size_t stateDescSize) override; - public: /* ----- Internal ----- */ diff --git a/sources/Renderer/Direct3D12/Command/D3D12CommandBuffer.h b/sources/Renderer/Direct3D12/Command/D3D12CommandBuffer.h index 6f54716ab4..4553cc04a8 100644 --- a/sources/Renderer/Direct3D12/Command/D3D12CommandBuffer.h +++ b/sources/Renderer/Direct3D12/Command/D3D12CommandBuffer.h @@ -41,176 +41,14 @@ class D3D12CommandBuffer final : public CommandBuffer public: - /* ----- Common ----- */ + #include + + public: D3D12CommandBuffer(D3D12RenderSystem& renderSystem, const CommandBufferDescriptor& desc); void SetName(const char* name) override; - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - - /* ----- Extensions ----- */ - - void SetGraphicsAPIDependentState(const void* stateDesc, std::size_t stateDescSize) override; - public: /* ----- Extended functions ----- */ diff --git a/sources/Renderer/Metal/Command/MTCommandBuffer.inl b/sources/Renderer/Metal/Command/MTCommandBuffer.inl new file mode 100644 index 0000000000..acc5fb3a2b --- /dev/null +++ b/sources/Renderer/Metal/Command/MTCommandBuffer.inl @@ -0,0 +1,65 @@ +/* + * MTCommandBuffer.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +#include +#include +#include +/*exclude*/ +/*exclude*/ +#include +/*exclude*/ +#include +#include +#include +#include +#include +/*exclude*/ + + +/* ----- Input Assembly ------ */ + +virtual void SetVertexBuffer( + Buffer& buffer +) override final; + +virtual void SetVertexBufferArray( + BufferArray& bufferArray +) override final; + +/* ----- Resources ----- */ + +virtual void SetResourceHeap( + ResourceHeap& resourceHeap, + std::uint32_t descriptorSet = 0 +) override final; + +virtual void ResetResourceSlots( + const ResourceType resourceType, + std::uint32_t firstSlot, + std::uint32_t numSlots, + long bindFlags, + long stageFlags = StageFlags::AllStages +) override final; + +/* ----- Pipeline States ----- */ + +virtual void SetPipelineState( + PipelineState& pipelineState +) override final; + +virtual void SetBlendFactor( + const float color[4] +) override final; + +virtual void SetStencilReference( + std::uint32_t reference, + const StencilFace stencilFace = StencilFace::FrontAndBack +) override final; + + + +// ================================================================================ diff --git a/sources/Renderer/Metal/Command/MTDirectCommandBuffer.h b/sources/Renderer/Metal/Command/MTDirectCommandBuffer.h index ce0545e76c..2c2b5b439c 100644 --- a/sources/Renderer/Metal/Command/MTDirectCommandBuffer.h +++ b/sources/Renderer/Metal/Command/MTDirectCommandBuffer.h @@ -22,166 +22,13 @@ class MTDirectCommandBuffer final : public MTCommandBuffer public: - /* ----- Common ----- */ + #include "MTCommandBuffer.inl" + + public: MTDirectCommandBuffer(id device, MTCommandQueue& cmdQueue, const CommandBufferDescriptor& desc); ~MTDirectCommandBuffer(); - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - public: // Returns false. diff --git a/sources/Renderer/Metal/Command/MTMultiSubmitCommandBuffer.h b/sources/Renderer/Metal/Command/MTMultiSubmitCommandBuffer.h index 87ed94d623..47cd531084 100644 --- a/sources/Renderer/Metal/Command/MTMultiSubmitCommandBuffer.h +++ b/sources/Renderer/Metal/Command/MTMultiSubmitCommandBuffer.h @@ -25,166 +25,13 @@ class MTMultiSubmitCommandBuffer final : public MTCommandBuffer public: - /* ----- Common ----- */ + #include "MTCommandBuffer.inl" + + public: MTMultiSubmitCommandBuffer(id device, const CommandBufferDescriptor& desc); ~MTMultiSubmitCommandBuffer(); - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - public: // Returns true. diff --git a/sources/Renderer/Null/Command/NullCommandBuffer.h b/sources/Renderer/Null/Command/NullCommandBuffer.h index d7428b121c..ac3d683a3b 100644 --- a/sources/Renderer/Null/Command/NullCommandBuffer.h +++ b/sources/Renderer/Null/Command/NullCommandBuffer.h @@ -28,173 +28,11 @@ class NullCommandBuffer final : public CommandBuffer public: - /* ----- Common ----- */ + #include - NullCommandBuffer(const CommandBufferDescriptor& desc); - - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - - /* ----- Extensions ----- */ + public: - void SetGraphicsAPIDependentState(const void* stateDesc, std::size_t stateDescSize) override; + NullCommandBuffer(const CommandBufferDescriptor& desc); public: diff --git a/sources/Renderer/OpenGL/Command/GLCommandBuffer.h b/sources/Renderer/OpenGL/Command/GLCommandBuffer.h index cc5df2aae5..07eddbdf89 100644 --- a/sources/Renderer/OpenGL/Command/GLCommandBuffer.h +++ b/sources/Renderer/OpenGL/Command/GLCommandBuffer.h @@ -26,14 +26,12 @@ class GLCommandBuffer : public CommandBuffer public: - // Returns true if this is an immediate command buffer, otherwise it is a deferred command buffer. - virtual bool IsImmediateCmdBuffer() const = 0; + #include public: - /* ----- Extensions ----- */ - - void SetGraphicsAPIDependentState(const void* stateDesc, std::size_t stateDescSize) override final; + // Returns true if this is an immediate command buffer, otherwise it is a deferred command buffer. + virtual bool IsImmediateCmdBuffer() const = 0; protected: diff --git a/sources/Renderer/OpenGL/Command/GLCommandBuffer.inl b/sources/Renderer/OpenGL/Command/GLCommandBuffer.inl new file mode 100644 index 0000000000..6cb7808f68 --- /dev/null +++ b/sources/Renderer/OpenGL/Command/GLCommandBuffer.inl @@ -0,0 +1,24 @@ +/* + * GLCommandBuffer.inl + * + * Copyright (c) 2015 Lukas Hermanns. All rights reserved. + * Licensed under the terms of the BSD 3-Clause license (see LICENSE.txt). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +/*exclude */ + + + +// ================================================================================ diff --git a/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.h b/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.h index d7b23689fe..b5355f1b88 100644 --- a/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.h +++ b/sources/Renderer/OpenGL/Command/GLDeferredCommandBuffer.h @@ -44,172 +44,14 @@ class GLDeferredCommandBuffer final : public GLCommandBuffer public: - GLDeferredCommandBuffer(long flags, std::size_t initialBufferSize = 1024); - - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; + #include "GLCommandBuffer.inl" - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ + public: - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; + GLDeferredCommandBuffer(long flags, std::size_t initialBufferSize = 1024); public: - /* ----- Internal ----- */ - // Returns false. bool IsImmediateCmdBuffer() const override; diff --git a/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.h b/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.h index b31809819d..968de8ee9a 100644 --- a/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.h +++ b/sources/Renderer/OpenGL/Command/GLImmediateCommandBuffer.h @@ -27,169 +27,11 @@ class GLImmediateCommandBuffer final : public GLCommandBuffer public: - /* ----- Common ----- */ + #include "GLCommandBuffer.inl" - GLImmediateCommandBuffer(GLStateManager& stateManager); - - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ + public: - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; + GLImmediateCommandBuffer(GLStateManager& stateManager); public: diff --git a/sources/Renderer/Vulkan/VKCommandBuffer.h b/sources/Renderer/Vulkan/VKCommandBuffer.h index ac3a5ae60d..7b4c1cc7f0 100644 --- a/sources/Renderer/Vulkan/VKCommandBuffer.h +++ b/sources/Renderer/Vulkan/VKCommandBuffer.h @@ -35,7 +35,9 @@ class VKCommandBuffer final : public CommandBuffer public: - /* ----- Common ----- */ + #include + + public: VKCommandBuffer( const VKPhysicalDevice& physicalDevice, @@ -44,172 +46,8 @@ class VKCommandBuffer final : public CommandBuffer const QueueFamilyIndices& queueFamilyIndices, const CommandBufferDescriptor& desc ); - ~VKCommandBuffer(); - - /* ----- Encoding ----- */ - - void Begin() override; - void End() override; - - void Execute(CommandBuffer& deferredCommandBuffer) override; - - /* ----- Blitting ----- */ - - void UpdateBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - const void* data, - std::uint16_t dataSize - ) override; - - void CopyBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint64_t size - ) override; - - void CopyBufferFromTexture( - Buffer& dstBuffer, - std::uint64_t dstOffset, - Texture& srcTexture, - const TextureRegion& srcRegion, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void FillBuffer( - Buffer& dstBuffer, - std::uint64_t dstOffset, - std::uint32_t value, - std::uint64_t fillSize = Constants::wholeSize - ) override; - - void CopyTexture( - Texture& dstTexture, - const TextureLocation& dstLocation, - Texture& srcTexture, - const TextureLocation& srcLocation, - const Extent3D& extent - ) override; - - void CopyTextureFromBuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - Buffer& srcBuffer, - std::uint64_t srcOffset, - std::uint32_t rowStride = 0, - std::uint32_t layerStride = 0 - ) override; - - void CopyTextureFromFramebuffer( - Texture& dstTexture, - const TextureRegion& dstRegion, - const Offset2D& srcOffset - ) override; - - void GenerateMips(Texture& texture) override; - void GenerateMips(Texture& texture, const TextureSubresource& subresource) override; - - /* ----- Viewport and Scissor ----- */ - - void SetViewport(const Viewport& viewport) override; - void SetViewports(std::uint32_t numViewports, const Viewport* viewports) override; - - void SetScissor(const Scissor& scissor) override; - void SetScissors(std::uint32_t numScissors, const Scissor* scissors) override; - - /* ----- Input Assembly ------ */ - - void SetVertexBuffer(Buffer& buffer) override; - void SetVertexBufferArray(BufferArray& bufferArray) override; - - void SetIndexBuffer(Buffer& buffer) override; - void SetIndexBuffer(Buffer& buffer, const Format format, std::uint64_t offset = 0) override; - - /* ----- Resources ----- */ - - void SetResourceHeap(ResourceHeap& resourceHeap, std::uint32_t descriptorSet = 0) override; - - void SetResource(std::uint32_t descriptor, Resource& resource) override; - - void ResetResourceSlots( - const ResourceType resourceType, - std::uint32_t firstSlot, - std::uint32_t numSlots, - long bindFlags, - long stageFlags = StageFlags::AllStages - ) override; - - /* ----- Render Passes ----- */ - - void BeginRenderPass( - RenderTarget& renderTarget, - const RenderPass* renderPass = nullptr, - std::uint32_t numClearValues = 0, - const ClearValue* clearValues = nullptr, - std::uint32_t swapBufferIndex = Constants::currentSwapIndex - ) override; - void EndRenderPass() override; - - void Clear(long flags, const ClearValue& clearValue = {}) override; - void ClearAttachments(std::uint32_t numAttachments, const AttachmentClear* attachments) override; - - /* ----- Pipeline States ----- */ - - void SetPipelineState(PipelineState& pipelineState) override; - void SetBlendFactor(const float color[4]) override; - void SetStencilReference(std::uint32_t reference, const StencilFace stencilFace = StencilFace::FrontAndBack) override; - void SetUniforms(std::uint32_t first, const void* data, std::uint16_t dataSize) override; - - /* ----- Queries ----- */ - - void BeginQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - void EndQuery(QueryHeap& queryHeap, std::uint32_t query = 0) override; - - void BeginRenderCondition(QueryHeap& queryHeap, std::uint32_t query = 0, const RenderConditionMode mode = RenderConditionMode::Wait) override; - void EndRenderCondition() override; - - /* ----- Stream Output ------ */ - - void BeginStreamOutput(std::uint32_t numBuffers, Buffer* const * buffers) override; - void EndStreamOutput() override; - - /* ----- Drawing ----- */ - - void Draw(std::uint32_t numVertices, std::uint32_t firstVertex) override; - - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex) override; - void DrawIndexed(std::uint32_t numIndices, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances) override; - void DrawInstanced(std::uint32_t numVertices, std::uint32_t firstVertex, std::uint32_t numInstances, std::uint32_t firstInstance) override; - - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset) override; - void DrawIndexedInstanced(std::uint32_t numIndices, std::uint32_t numInstances, std::uint32_t firstIndex, std::int32_t vertexOffset, std::uint32_t firstInstance) override; - - void DrawIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset) override; - void DrawIndexedIndirect(Buffer& buffer, std::uint64_t offset, std::uint32_t numCommands, std::uint32_t stride) override; - - /* ----- Compute ----- */ - - void Dispatch(std::uint32_t numWorkGroupsX, std::uint32_t numWorkGroupsY, std::uint32_t numWorkGroupsZ) override; - void DispatchIndirect(Buffer& buffer, std::uint64_t offset) override; - - /* ----- Debugging ----- */ - - void PushDebugGroup(const char* name) override; - void PopDebugGroup() override; - - /* ----- Extensions ----- */ - - void SetGraphicsAPIDependentState(const void* stateDesc, std::size_t stateDescSize) override; + ~VKCommandBuffer(); public: