Improve texture view support

This commit is contained in:
SirLynix
2022-12-01 18:06:20 +01:00
committed by Jérôme Leclercq
parent 42f8cdb151
commit 08ea4c87a7
17 changed files with 128 additions and 75 deletions

View File

@@ -25,6 +25,7 @@ namespace Nz
class OpenGLCommandPool;
class OpenGLFramebuffer;
class OpenGLRenderPass;
class OpenGLTexture;
class NAZARA_OPENGLRENDERER_API OpenGLCommandBuffer final : public CommandBuffer
{
@@ -41,11 +42,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 BlitTexture(const OpenGLTexture& source, const Boxui& sourceBox, const OpenGLTexture& 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 CopyTexture(const OpenGLTexture& source, const Boxui& sourceBox, const OpenGLTexture& 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);
@@ -81,8 +82,8 @@ namespace Nz
struct BlitTextureData
{
const GL::Texture* source;
const GL::Texture* target;
const OpenGLTexture* source;
const OpenGLTexture* target;
Boxui sourceBox;
Boxui targetBox;
SamplerFilter filter;
@@ -99,8 +100,8 @@ namespace Nz
struct CopyTextureData
{
const GL::Texture* source;
const GL::Texture* target;
const OpenGLTexture* source;
const OpenGLTexture* target;
Boxui sourceBox;
Vector3ui targetPoint;
};

View File

@@ -63,7 +63,7 @@ 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)
inline void OpenGLCommandBuffer::BlitTexture(const OpenGLTexture& source, const Boxui& sourceBox, const OpenGLTexture& target, const Boxui& targetBox, SamplerFilter filter)
{
BlitTextureData blitTexture = {
&source,
@@ -101,7 +101,7 @@ 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)
inline void OpenGLCommandBuffer::CopyTexture(const OpenGLTexture& source, const Boxui& sourceBox, const OpenGLTexture& target, const Vector3ui& targetPoint)
{
CopyTextureData copyTexture = {
&source,

View File

@@ -14,6 +14,7 @@
namespace Nz
{
class OpenGLCommandBuffer;
class OpenGLTexture;
class NAZARA_OPENGLRENDERER_API OpenGLCommandBufferBuilder final : public CommandBufferBuilder
{

View File

@@ -33,9 +33,10 @@ namespace Nz
OpenGLTexture* GetParentTexture() const override;
Vector3ui GetSize(UInt8 level = 0) const override;
inline const GL::Texture& GetTexture() const;
inline const TextureViewInfo& GetTextureViewInfo() const;
ImageType GetType() const override;
inline bool RequireTextureViewEmulation() const;
inline bool RequiresTextureViewEmulation() const;
using Texture::Update;
bool Update(const void* ptr, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0) override;

View File

@@ -13,7 +13,13 @@ namespace Nz
return m_texture;
}
inline bool OpenGLTexture::RequireTextureViewEmulation() const
inline const TextureViewInfo& OpenGLTexture::GetTextureViewInfo() const
{
assert(m_viewInfo);
return *m_viewInfo;
}
inline bool OpenGLTexture::RequiresTextureViewEmulation() const
{
return m_viewInfo.has_value() && !m_texture.IsValid();
}

View File

@@ -23,6 +23,7 @@
namespace Nz
{
class OpenGLDevice;
class OpenGLTexture;
}
namespace Nz::GL
@@ -134,11 +135,11 @@ 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 Boxui& dstBox, SamplerFilter filter) const;
bool BlitTexture(const OpenGLTexture& source, const OpenGLTexture& destination, const Boxui& srcBox, const Boxui& dstBox, SamplerFilter filter) const;
bool ClearErrorStack() const;
bool CopyTexture(const Texture& source, const Texture& destination, const Boxui& srcBox, const Vector3ui& dstPos) const;
bool CopyTexture(const OpenGLTexture& source, const OpenGLTexture& destination, const Boxui& srcBox, const Vector3ui& dstPos) const;
inline bool DidLastCallSucceed() const;