Renderer/CommandBuffer: Add support for texture blit/copy
This commit is contained in:
@@ -41,9 +41,11 @@ namespace Nz
|
||||
inline void BindPipeline(const OpenGLRenderPipeline* pipeline);
|
||||
inline void BindShaderBinding(const OpenGLRenderPipelineLayout& pipelineLayout, UInt32 set, const OpenGLShaderBinding* binding);
|
||||
inline void BindVertexBuffer(UInt32 binding, GLuint vertexBuffer, UInt64 offset = 0);
|
||||
inline void BlitTexture(const GL::Texture& source, const Boxui& sourceBox, const GL::Texture& target, const Boxui& targetBox, SamplerFilter filter = SamplerFilter::Nearest);
|
||||
|
||||
inline void CopyBuffer(GLuint source, GLuint target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0);
|
||||
inline void CopyBuffer(const UploadPool::Allocation& allocation, GLuint target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0);
|
||||
inline void CopyTexture(const GL::Texture& source, const Boxui& sourceBox, const GL::Texture& target, const Vector3ui& targetPoint);
|
||||
|
||||
inline void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0);
|
||||
inline void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstIndex = 0, UInt32 firstInstance = 0);
|
||||
@@ -75,6 +77,15 @@ namespace Nz
|
||||
Color color;
|
||||
};
|
||||
|
||||
struct BlitTextureData
|
||||
{
|
||||
const GL::Texture* source;
|
||||
const GL::Texture* target;
|
||||
Boxui sourceBox;
|
||||
Boxui targetBox;
|
||||
SamplerFilter filter;
|
||||
};
|
||||
|
||||
struct CopyBufferData
|
||||
{
|
||||
GLuint source;
|
||||
@@ -84,6 +95,14 @@ namespace Nz
|
||||
UInt64 targetOffset;
|
||||
};
|
||||
|
||||
struct CopyTextureData
|
||||
{
|
||||
const GL::Texture* source;
|
||||
const GL::Texture* target;
|
||||
Boxui sourceBox;
|
||||
Vector3ui targetPoint;
|
||||
};
|
||||
|
||||
struct CopyBufferFromMemoryData
|
||||
{
|
||||
const void* memory;
|
||||
@@ -141,8 +160,10 @@ namespace Nz
|
||||
|
||||
using CommandData = std::variant<
|
||||
BeginDebugRegionData,
|
||||
BlitTextureData,
|
||||
CopyBufferData,
|
||||
CopyBufferFromMemoryData,
|
||||
CopyTextureData,
|
||||
DrawData,
|
||||
DrawIndexedData,
|
||||
EndDebugRegionData,
|
||||
|
||||
@@ -62,6 +62,19 @@ namespace Nz
|
||||
vertexBufferData.vertexBuffer = vertexBuffer;
|
||||
}
|
||||
|
||||
inline void OpenGLCommandBuffer::BlitTexture(const GL::Texture& source, const Boxui& sourceBox, const GL::Texture& target, const Boxui& targetBox, SamplerFilter filter)
|
||||
{
|
||||
BlitTextureData blitTexture = {
|
||||
&source,
|
||||
&target,
|
||||
sourceBox,
|
||||
targetBox,
|
||||
filter
|
||||
};
|
||||
|
||||
m_commands.emplace_back(std::move(blitTexture));
|
||||
}
|
||||
|
||||
inline void OpenGLCommandBuffer::CopyBuffer(GLuint source, GLuint target, UInt64 size, UInt64 sourceOffset, UInt64 targetOffset)
|
||||
{
|
||||
CopyBufferData copyBuffer = {
|
||||
@@ -87,6 +100,18 @@ namespace Nz
|
||||
m_commands.emplace_back(std::move(copyBuffer));
|
||||
}
|
||||
|
||||
inline void OpenGLCommandBuffer::CopyTexture(const GL::Texture& source, const Boxui& sourceBox, const GL::Texture& target, const Vector3ui& targetPoint)
|
||||
{
|
||||
CopyTextureData copyTexture = {
|
||||
&source,
|
||||
&target,
|
||||
sourceBox,
|
||||
targetPoint
|
||||
};
|
||||
|
||||
m_commands.emplace_back(std::move(copyTexture));
|
||||
}
|
||||
|
||||
inline void OpenGLCommandBuffer::Draw(UInt32 vertexCount, UInt32 instanceCount, UInt32 firstVertex, UInt32 firstInstance)
|
||||
{
|
||||
if (!m_currentStates.pipeline)
|
||||
|
||||
@@ -32,8 +32,11 @@ namespace Nz
|
||||
void BindShaderBinding(const RenderPipelineLayout& pipelineLayout, UInt32 set, const ShaderBinding& binding) override;
|
||||
void BindVertexBuffer(UInt32 binding, const AbstractBuffer& vertexBuffer, UInt64 offset = 0) override;
|
||||
|
||||
void BlitTexture(const Texture& fromTexture, const Boxui& fromBox, TextureLayout fromLayout, const Texture& toTexture, const Boxui& toBox, TextureLayout toLayout, SamplerFilter filter) override;
|
||||
|
||||
void CopyBuffer(const RenderBufferView& source, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override;
|
||||
void CopyBuffer(const UploadPool::Allocation& allocation, const RenderBufferView& target, UInt64 size, UInt64 sourceOffset = 0, UInt64 targetOffset = 0) override;
|
||||
void CopyTexture(const Texture& fromTexture, const Boxui& fromBox, TextureLayout fromLayout, const Texture& toTexture, const Vector3ui& toPos, TextureLayout toLayout) override;
|
||||
|
||||
void Draw(UInt32 vertexCount, UInt32 instanceCount = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) override;
|
||||
void DrawIndexed(UInt32 indexCount, UInt32 instanceCount = 1, UInt32 firstIndex = 0, UInt32 firstInstance = 0) override;
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Nz::GL
|
||||
void BindUniformBuffer(UInt32 uboUnit, GLuint buffer, GLintptr offset, GLsizeiptr size) const;
|
||||
void BindVertexArray(GLuint vertexArray, bool force = false) const;
|
||||
|
||||
bool BlitTexture(const Texture& source, const Texture& destination, const Boxui& srcBox, const Vector3ui& dstPos, SamplerFilter filter) const;
|
||||
bool BlitTexture(const Texture& source, const Texture& destination, const Boxui& srcBox, const Boxui& dstBox, SamplerFilter filter) const;
|
||||
|
||||
bool ClearErrorStack() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user