Big buffer refactor
Replaced RenderBuffer class, replaced AbstractBuffer by Buffer
This commit is contained in:
@@ -50,14 +50,14 @@ namespace Nz
|
||||
|
||||
SparsePtr& operator=(const SparsePtr& ptr) = default;
|
||||
|
||||
SparsePtr operator+(int count) const;
|
||||
SparsePtr operator+(unsigned int count) const;
|
||||
SparsePtr operator-(int count) const;
|
||||
SparsePtr operator-(unsigned int count) const;
|
||||
SparsePtr operator+(Int64 count) const;
|
||||
SparsePtr operator+(UInt64 count) const;
|
||||
SparsePtr operator-(Int64 count) const;
|
||||
SparsePtr operator-(UInt64 count) const;
|
||||
std::ptrdiff_t operator-(const SparsePtr& ptr) const;
|
||||
|
||||
SparsePtr& operator+=(int count);
|
||||
SparsePtr& operator-=(int count);
|
||||
SparsePtr& operator+=(Int64 count);
|
||||
SparsePtr& operator-=(Int64 count);
|
||||
|
||||
SparsePtr& operator++();
|
||||
SparsePtr operator++(int);
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T> SparsePtr<T>::operator+(int count) const
|
||||
SparsePtr<T> SparsePtr<T>::operator+(Int64 count) const
|
||||
{
|
||||
return SparsePtr(m_ptr + count * m_stride, m_stride);
|
||||
}
|
||||
@@ -273,7 +273,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T> SparsePtr<T>::operator+(unsigned int count) const
|
||||
SparsePtr<T> SparsePtr<T>::operator+(UInt64 count) const
|
||||
{
|
||||
return SparsePtr(m_ptr + count * m_stride, m_stride);
|
||||
}
|
||||
@@ -286,7 +286,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T> SparsePtr<T>::operator-(int count) const
|
||||
SparsePtr<T> SparsePtr<T>::operator-(Int64 count) const
|
||||
{
|
||||
return SparsePtr(m_ptr - count * m_stride, m_stride);
|
||||
}
|
||||
@@ -299,7 +299,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T> SparsePtr<T>::operator-(unsigned int count) const
|
||||
SparsePtr<T> SparsePtr<T>::operator-(UInt64 count) const
|
||||
{
|
||||
return SparsePtr(m_ptr - count * m_stride, m_stride);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T>& SparsePtr<T>::operator+=(int count)
|
||||
SparsePtr<T>& SparsePtr<T>::operator+=(Int64 count)
|
||||
{
|
||||
m_ptr += count * m_stride;
|
||||
|
||||
@@ -340,7 +340,7 @@ namespace Nz
|
||||
*/
|
||||
|
||||
template<typename T>
|
||||
SparsePtr<T>& SparsePtr<T>::operator-=(int count)
|
||||
SparsePtr<T>& SparsePtr<T>::operator-=(Int64 count)
|
||||
{
|
||||
m_ptr -= count * m_stride;
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <Nazara/Graphics/Graphics.hpp>
|
||||
#include <Nazara/Graphics/GuillotineTextureAtlas.hpp>
|
||||
#include <Nazara/Graphics/InstancedRenderable.hpp>
|
||||
#include <Nazara/Graphics/Light.hpp>
|
||||
#include <Nazara/Graphics/Material.hpp>
|
||||
#include <Nazara/Graphics/MaterialPass.hpp>
|
||||
#include <Nazara/Graphics/MaterialPassRegistry.hpp>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Utility/Mesh.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
#include <memory>
|
||||
@@ -23,9 +24,9 @@ namespace Nz
|
||||
GraphicalMesh(GraphicalMesh&&) noexcept = default;
|
||||
~GraphicalMesh() = default;
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMesh) const;
|
||||
inline const std::shared_ptr<RenderBuffer>& GetIndexBuffer(std::size_t subMesh) const;
|
||||
inline std::size_t GetIndexCount(std::size_t subMesh) const;
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetVertexBuffer(std::size_t subMesh) const;
|
||||
inline const std::shared_ptr<RenderBuffer>& GetVertexBuffer(std::size_t subMesh) const;
|
||||
inline const std::shared_ptr<const VertexDeclaration>& GetVertexDeclaration(std::size_t subMesh) const;
|
||||
inline std::size_t GetSubMeshCount() const;
|
||||
|
||||
@@ -35,8 +36,8 @@ namespace Nz
|
||||
private:
|
||||
struct GraphicalSubMesh
|
||||
{
|
||||
std::shared_ptr<AbstractBuffer> indexBuffer;
|
||||
std::shared_ptr<AbstractBuffer> vertexBuffer;
|
||||
std::shared_ptr<RenderBuffer> indexBuffer;
|
||||
std::shared_ptr<RenderBuffer> vertexBuffer;
|
||||
std::size_t indexCount;
|
||||
std::shared_ptr<const VertexDeclaration> vertexDeclaration;
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline const std::shared_ptr<AbstractBuffer>& GraphicalMesh::GetIndexBuffer(std::size_t subMesh) const
|
||||
inline const std::shared_ptr<RenderBuffer>& GraphicalMesh::GetIndexBuffer(std::size_t subMesh) const
|
||||
{
|
||||
assert(subMesh < m_subMeshes.size());
|
||||
return m_subMeshes[subMesh].indexBuffer;
|
||||
@@ -20,7 +20,7 @@ namespace Nz
|
||||
return m_subMeshes[subMesh].indexCount;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& GraphicalMesh::GetVertexBuffer(std::size_t subMesh) const
|
||||
inline const std::shared_ptr<RenderBuffer>& GraphicalMesh::GetVertexBuffer(std::size_t subMesh) const
|
||||
{
|
||||
assert(subMesh < m_subMeshes.size());
|
||||
return m_subMeshes[subMesh].vertexBuffer;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Nz
|
||||
inline const std::shared_ptr<RenderPipeline>& GetBlitPipeline(bool transparent) const;
|
||||
inline const std::shared_ptr<RenderPipelineLayout>& GetBlitPipelineLayout() const;
|
||||
inline const DefaultTextures& GetDefaultTextures() const;
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetFullscreenVertexBuffer() const;
|
||||
inline const std::shared_ptr<RenderBuffer>& GetFullscreenVertexBuffer() const;
|
||||
inline const std::shared_ptr<VertexDeclaration>& GetFullscreenVertexDeclaration() const;
|
||||
inline MaterialPassRegistry& GetMaterialPassRegistry();
|
||||
inline const MaterialPassRegistry& GetMaterialPassRegistry() const;
|
||||
@@ -70,7 +70,7 @@ namespace Nz
|
||||
|
||||
std::optional<RenderPassCache> m_renderPassCache;
|
||||
std::optional<TextureSamplerCache> m_samplerCache;
|
||||
std::shared_ptr<AbstractBuffer> m_fullscreenVertexBuffer;
|
||||
std::shared_ptr<RenderBuffer> m_fullscreenVertexBuffer;
|
||||
std::shared_ptr<RenderDevice> m_renderDevice;
|
||||
std::shared_ptr<RenderPipeline> m_blitPipeline;
|
||||
std::shared_ptr<RenderPipeline> m_blitPipelineTransparent;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Nz
|
||||
return m_defaultTextures;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& Graphics::GetFullscreenVertexBuffer() const
|
||||
inline const std::shared_ptr<RenderBuffer>& Graphics::GetFullscreenVertexBuffer() const
|
||||
{
|
||||
return m_fullscreenVertexBuffer;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Nz
|
||||
inline const std::shared_ptr<UberShader>& GetShader(ShaderStageType shaderStage) const;
|
||||
inline const std::shared_ptr<Texture>& GetTexture(std::size_t textureIndex) const;
|
||||
inline const TextureSamplerInfo& GetTextureSampler(std::size_t textureIndex) const;
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetUniformBuffer(std::size_t bufferIndex) const;
|
||||
inline const std::shared_ptr<RenderBuffer>& GetUniformBuffer(std::size_t bufferIndex) const;
|
||||
inline const std::vector<UInt8>& GetUniformBufferConstData(std::size_t bufferIndex);
|
||||
inline std::vector<UInt8>& GetUniformBufferData(std::size_t bufferIndex);
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Nz
|
||||
inline void SetPrimitiveMode(PrimitiveMode mode);
|
||||
inline void SetTexture(std::size_t textureIndex, std::shared_ptr<Texture> texture);
|
||||
inline void SetTextureSampler(std::size_t textureIndex, TextureSamplerInfo samplerInfo);
|
||||
inline void SetUniformBuffer(std::size_t bufferIndex, std::shared_ptr<AbstractBuffer> uniformBuffer);
|
||||
inline void SetUniformBuffer(std::size_t bufferIndex, std::shared_ptr<RenderBuffer> uniformBuffer);
|
||||
|
||||
bool Update(RenderFrame& renderFrame, CommandBufferBuilder& builder);
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace Nz
|
||||
|
||||
struct UniformBuffer
|
||||
{
|
||||
std::shared_ptr<AbstractBuffer> buffer;
|
||||
std::shared_ptr<RenderBuffer> buffer;
|
||||
std::vector<UInt8> data;
|
||||
bool dataInvalidated = true;
|
||||
};
|
||||
|
||||
@@ -385,7 +385,7 @@ namespace Nz
|
||||
return m_textures[textureIndex].samplerInfo;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& MaterialPass::GetUniformBuffer(std::size_t bufferIndex) const
|
||||
inline const std::shared_ptr<RenderBuffer>& MaterialPass::GetUniformBuffer(std::size_t bufferIndex) const
|
||||
{
|
||||
NazaraAssert(bufferIndex < m_uniformBuffers.size(), "Invalid uniform buffer index");
|
||||
return m_uniformBuffers[bufferIndex].buffer;
|
||||
@@ -624,7 +624,7 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
inline void MaterialPass::SetUniformBuffer(std::size_t bufferIndex, std::shared_ptr<AbstractBuffer> uniformBuffer)
|
||||
inline void MaterialPass::SetUniformBuffer(std::size_t bufferIndex, std::shared_ptr<RenderBuffer> uniformBuffer)
|
||||
{
|
||||
NazaraAssert(bufferIndex < m_uniformBuffers.size(), "Invalid shared uniform buffer index");
|
||||
if (m_uniformBuffers[bufferIndex].buffer != uniformBuffer)
|
||||
|
||||
@@ -30,13 +30,13 @@ namespace Nz
|
||||
|
||||
void BuildElement(std::size_t passIndex, const WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const override;
|
||||
|
||||
const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const;
|
||||
const std::shared_ptr<RenderBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const;
|
||||
std::size_t GetIndexCount(std::size_t subMeshIndex) const;
|
||||
const std::shared_ptr<Material>& GetMaterial(std::size_t subMeshIndex) const override;
|
||||
std::size_t GetMaterialCount() const override;
|
||||
inline std::size_t GetSubMeshCount() const;
|
||||
const std::vector<RenderPipelineInfo::VertexBufferData>& GetVertexBufferData(std::size_t subMeshIndex) const;
|
||||
const std::shared_ptr<AbstractBuffer>& GetVertexBuffer(std::size_t subMeshIndex) const;
|
||||
const std::shared_ptr<RenderBuffer>& GetVertexBuffer(std::size_t subMeshIndex) const;
|
||||
|
||||
inline void SetMaterial(std::size_t subMeshIndex, std::shared_ptr<Material> material);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
inline std::size_t FetchLayerIndex(int renderLayer) const;
|
||||
inline std::size_t FetchMaterialPassIndex(const MaterialPass* materialPass) const;
|
||||
inline std::size_t FetchPipelineIndex(const RenderPipeline* pipeline) const;
|
||||
inline std::size_t FetchVertexBuffer(const AbstractBuffer* vertexBuffer) const;
|
||||
inline std::size_t FetchVertexBuffer(const RenderBuffer* vertexBuffer) const;
|
||||
inline std::size_t FetchVertexDeclaration(const VertexDeclaration* vertexDeclaration) const;
|
||||
|
||||
inline void Finalize();
|
||||
@@ -37,7 +37,7 @@ namespace Nz
|
||||
inline void RegisterLayer(int renderLayer);
|
||||
inline void RegisterMaterialPass(const MaterialPass* materialPass);
|
||||
inline void RegisterPipeline(const RenderPipeline* pipeline);
|
||||
inline void RegisterVertexBuffer(const AbstractBuffer* vertexBuffer);
|
||||
inline void RegisterVertexBuffer(const RenderBuffer* vertexBuffer);
|
||||
inline void RegisterVertexDeclaration(const VertexDeclaration* vertexDeclaration);
|
||||
|
||||
private:
|
||||
@@ -45,7 +45,7 @@ namespace Nz
|
||||
robin_hood::unordered_map<int, std::size_t> m_renderLayerRegistry;
|
||||
robin_hood::unordered_map<const MaterialPass*, std::size_t> m_materialPassRegistry;
|
||||
robin_hood::unordered_map<const RenderPipeline*, std::size_t> m_pipelineRegistry;
|
||||
robin_hood::unordered_map<const AbstractBuffer*, std::size_t> m_vertexBufferRegistry;
|
||||
robin_hood::unordered_map<const RenderBuffer*, std::size_t> m_vertexBufferRegistry;
|
||||
robin_hood::unordered_map<const VertexDeclaration*, std::size_t> m_vertexDeclarationRegistry;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Nz
|
||||
return it->second;
|
||||
}
|
||||
|
||||
inline std::size_t RenderQueueRegistry::FetchVertexBuffer(const AbstractBuffer* vertexBuffer) const
|
||||
inline std::size_t RenderQueueRegistry::FetchVertexBuffer(const RenderBuffer* vertexBuffer) const
|
||||
{
|
||||
auto it = m_vertexBufferRegistry.find(vertexBuffer);
|
||||
assert(it != m_vertexBufferRegistry.end());
|
||||
@@ -80,7 +80,7 @@ namespace Nz
|
||||
m_pipelineRegistry.try_emplace(pipeline, m_pipelineRegistry.size());
|
||||
}
|
||||
|
||||
inline void RenderQueueRegistry::RegisterVertexBuffer(const AbstractBuffer* vertexBuffer)
|
||||
inline void RenderQueueRegistry::RegisterVertexBuffer(const RenderBuffer* vertexBuffer)
|
||||
{
|
||||
m_vertexBufferRegistry.try_emplace(vertexBuffer, m_vertexBufferRegistry.size());
|
||||
}
|
||||
|
||||
@@ -24,24 +24,24 @@ namespace Nz
|
||||
class RenderSubmesh : public RenderElement
|
||||
{
|
||||
public:
|
||||
inline RenderSubmesh(int renderLayer, std::shared_ptr<MaterialPass> materialPass, std::shared_ptr<RenderPipeline> renderPipeline, const WorldInstance& worldInstance, std::size_t indexCount, std::shared_ptr<AbstractBuffer> indexBuffer, std::shared_ptr<AbstractBuffer> vertexBuffer, const Recti& scissorBox);
|
||||
inline RenderSubmesh(int renderLayer, std::shared_ptr<MaterialPass> materialPass, std::shared_ptr<RenderPipeline> renderPipeline, const WorldInstance& worldInstance, std::size_t indexCount, std::shared_ptr<RenderBuffer> indexBuffer, std::shared_ptr<RenderBuffer> vertexBuffer, const Recti& scissorBox);
|
||||
~RenderSubmesh() = default;
|
||||
|
||||
inline UInt64 ComputeSortingScore(const Frustumf& frustum, const RenderQueueRegistry& registry) const override;
|
||||
|
||||
inline const AbstractBuffer* GetIndexBuffer() const;
|
||||
inline const RenderBuffer* GetIndexBuffer() const;
|
||||
inline std::size_t GetIndexCount() const;
|
||||
inline const MaterialPass& GetMaterialPass() const;
|
||||
inline const RenderPipeline* GetRenderPipeline() const;
|
||||
inline const Recti& GetScissorBox() const;
|
||||
inline const AbstractBuffer* GetVertexBuffer() const;
|
||||
inline const RenderBuffer* GetVertexBuffer() const;
|
||||
inline const WorldInstance& GetWorldInstance() const;
|
||||
|
||||
inline void Register(RenderQueueRegistry& registry) const override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbstractBuffer> m_indexBuffer;
|
||||
std::shared_ptr<AbstractBuffer> m_vertexBuffer;
|
||||
std::shared_ptr<RenderBuffer> m_indexBuffer;
|
||||
std::shared_ptr<RenderBuffer> m_vertexBuffer;
|
||||
std::shared_ptr<MaterialPass> m_materialPass;
|
||||
std::shared_ptr<RenderPipeline> m_renderPipeline;
|
||||
std::size_t m_indexCount;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline RenderSubmesh::RenderSubmesh(int renderLayer, std::shared_ptr<MaterialPass> materialPass, std::shared_ptr<RenderPipeline> renderPipeline, const WorldInstance& worldInstance, std::size_t indexCount, std::shared_ptr<AbstractBuffer> indexBuffer, std::shared_ptr<AbstractBuffer> vertexBuffer, const Recti& scissorBox) :
|
||||
inline RenderSubmesh::RenderSubmesh(int renderLayer, std::shared_ptr<MaterialPass> materialPass, std::shared_ptr<RenderPipeline> renderPipeline, const WorldInstance& worldInstance, std::size_t indexCount, std::shared_ptr<RenderBuffer> indexBuffer, std::shared_ptr<RenderBuffer> vertexBuffer, const Recti& scissorBox) :
|
||||
RenderElement(BasicRenderElement::Submesh),
|
||||
m_indexBuffer(std::move(indexBuffer)),
|
||||
m_vertexBuffer(std::move(vertexBuffer)),
|
||||
@@ -70,7 +70,7 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
inline const AbstractBuffer* RenderSubmesh::GetIndexBuffer() const
|
||||
inline const RenderBuffer* RenderSubmesh::GetIndexBuffer() const
|
||||
{
|
||||
return m_indexBuffer.get();
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Nz
|
||||
return m_scissorBox;
|
||||
}
|
||||
|
||||
inline const AbstractBuffer* RenderSubmesh::GetVertexBuffer() const
|
||||
inline const RenderBuffer* RenderSubmesh::GetVertexBuffer() const
|
||||
{
|
||||
return m_vertexBuffer.get();
|
||||
}
|
||||
|
||||
@@ -38,17 +38,17 @@ namespace Nz
|
||||
private:
|
||||
struct BufferCopy
|
||||
{
|
||||
AbstractBuffer* targetBuffer;
|
||||
RenderBuffer* targetBuffer;
|
||||
UploadPool::Allocation* allocation;
|
||||
std::size_t size;
|
||||
};
|
||||
|
||||
struct VertexBufferPool
|
||||
{
|
||||
std::vector<std::shared_ptr<AbstractBuffer>> vertexBuffers;
|
||||
std::vector<std::shared_ptr<RenderBuffer>> vertexBuffers;
|
||||
};
|
||||
|
||||
std::shared_ptr<AbstractBuffer> m_indexBuffer;
|
||||
std::shared_ptr<RenderBuffer> m_indexBuffer;
|
||||
std::shared_ptr<VertexBufferPool> m_vertexBufferPool;
|
||||
std::size_t m_maxVertexBufferSize;
|
||||
std::size_t m_maxVertexCount;
|
||||
@@ -61,7 +61,7 @@ namespace Nz
|
||||
{
|
||||
struct DrawCall
|
||||
{
|
||||
const AbstractBuffer* vertexBuffer;
|
||||
const RenderBuffer* vertexBuffer;
|
||||
const RenderPipeline* renderPipeline;
|
||||
const ShaderBinding* shaderBinding;
|
||||
std::size_t firstIndex;
|
||||
@@ -77,7 +77,7 @@ namespace Nz
|
||||
|
||||
std::unordered_map<const RenderSpriteChain*, DrawCallIndices> drawCallPerElement;
|
||||
std::vector<DrawCall> drawCalls;
|
||||
std::vector<std::shared_ptr<AbstractBuffer>> vertexBuffers;
|
||||
std::vector<std::shared_ptr<RenderBuffer>> vertexBuffers;
|
||||
std::vector<ShaderBindingPtr> shaderBindings;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Nz
|
||||
{
|
||||
struct DrawCall
|
||||
{
|
||||
const AbstractBuffer* indexBuffer;
|
||||
const AbstractBuffer* vertexBuffer;
|
||||
const RenderBuffer* indexBuffer;
|
||||
const RenderBuffer* vertexBuffer;
|
||||
const RenderPipeline* renderPipeline;
|
||||
const ShaderBinding* shaderBinding;
|
||||
std::size_t indexCount;
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace Nz
|
||||
inline const Vector2f& GetTargetSize() const;
|
||||
inline const Matrix4f& GetViewMatrix() const;
|
||||
inline const Matrix4f& GetViewProjMatrix() const;
|
||||
inline std::shared_ptr<AbstractBuffer>& GetViewerBuffer();
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetViewerBuffer() const;
|
||||
inline std::shared_ptr<RenderBuffer>& GetViewerBuffer();
|
||||
inline const std::shared_ptr<RenderBuffer>& GetViewerBuffer() const;
|
||||
|
||||
void UpdateBuffers(UploadPool& uploadPool, CommandBufferBuilder& builder);
|
||||
inline void UpdateProjectionMatrix(const Matrix4f& projectionMatrix);
|
||||
@@ -52,7 +52,7 @@ namespace Nz
|
||||
ViewerInstance& operator=(ViewerInstance&&) noexcept = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbstractBuffer> m_viewerDataBuffer;
|
||||
std::shared_ptr<RenderBuffer> m_viewerDataBuffer;
|
||||
Matrix4f m_invProjectionMatrix;
|
||||
Matrix4f m_invViewProjMatrix;
|
||||
Matrix4f m_invViewMatrix;
|
||||
|
||||
@@ -43,12 +43,12 @@ namespace Nz
|
||||
return m_viewProjMatrix;
|
||||
}
|
||||
|
||||
inline std::shared_ptr<AbstractBuffer>& ViewerInstance::GetViewerBuffer()
|
||||
inline std::shared_ptr<RenderBuffer>& ViewerInstance::GetViewerBuffer()
|
||||
{
|
||||
return m_viewerDataBuffer;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& ViewerInstance::GetViewerBuffer() const
|
||||
inline const std::shared_ptr<RenderBuffer>& ViewerInstance::GetViewerBuffer() const
|
||||
{
|
||||
return m_viewerDataBuffer;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace Nz
|
||||
WorldInstance(WorldInstance&&) noexcept = default;
|
||||
~WorldInstance() = default;
|
||||
|
||||
inline std::shared_ptr<AbstractBuffer>& GetInstanceBuffer();
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetInstanceBuffer() const;
|
||||
inline std::shared_ptr<RenderBuffer>& GetInstanceBuffer();
|
||||
inline const std::shared_ptr<RenderBuffer>& GetInstanceBuffer() const;
|
||||
inline const Matrix4f& GetInvWorldMatrix() const;
|
||||
inline const Matrix4f& GetWorldMatrix() const;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Nz
|
||||
WorldInstance& operator=(WorldInstance&&) noexcept = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbstractBuffer> m_instanceDataBuffer;
|
||||
std::shared_ptr<RenderBuffer> m_instanceDataBuffer;
|
||||
Matrix4f m_invWorldMatrix;
|
||||
Matrix4f m_worldMatrix;
|
||||
bool m_dataInvalided;
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline std::shared_ptr<AbstractBuffer>& WorldInstance::GetInstanceBuffer()
|
||||
inline std::shared_ptr<RenderBuffer>& WorldInstance::GetInstanceBuffer()
|
||||
{
|
||||
return m_instanceDataBuffer;
|
||||
}
|
||||
|
||||
inline const std::shared_ptr<AbstractBuffer>& WorldInstance::GetInstanceBuffer() const
|
||||
inline const std::shared_ptr<RenderBuffer>& WorldInstance::GetInstanceBuffer() const
|
||||
{
|
||||
return m_instanceDataBuffer;
|
||||
}
|
||||
|
||||
@@ -11,30 +11,25 @@
|
||||
#include <Nazara/OpenGLRenderer/Config.hpp>
|
||||
#include <Nazara/OpenGLRenderer/OpenGLDevice.hpp>
|
||||
#include <Nazara/OpenGLRenderer/Wrapper/Buffer.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_OPENGLRENDERER_API OpenGLBuffer : public AbstractBuffer
|
||||
class NAZARA_OPENGLRENDERER_API OpenGLBuffer : public RenderBuffer
|
||||
{
|
||||
public:
|
||||
OpenGLBuffer(OpenGLDevice& device, BufferType type);
|
||||
OpenGLBuffer(OpenGLDevice& device, BufferType type, UInt64 size, BufferUsageFlags usage, const void* initialData = nullptr);
|
||||
OpenGLBuffer(const OpenGLBuffer&) = delete;
|
||||
OpenGLBuffer(OpenGLBuffer&&) = delete;
|
||||
~OpenGLBuffer() = default;
|
||||
|
||||
bool Fill(const void* data, UInt64 offset, UInt64 size) override;
|
||||
|
||||
bool Initialize(UInt64 size, BufferUsageFlags usage) override;
|
||||
|
||||
inline const GL::Buffer& GetBuffer() const;
|
||||
UInt64 GetSize() const override;
|
||||
DataStorage GetStorage() const override;
|
||||
inline BufferType GetType() const;
|
||||
|
||||
void* Map(BufferAccess access, UInt64 offset, UInt64 size) override;
|
||||
void* Map(UInt64 offset, UInt64 size) override;
|
||||
bool Unmap() override;
|
||||
|
||||
OpenGLBuffer& operator=(const OpenGLBuffer&) = delete;
|
||||
@@ -42,9 +37,6 @@ namespace Nz
|
||||
|
||||
private:
|
||||
GL::Buffer m_buffer;
|
||||
BufferType m_type;
|
||||
BufferUsageFlags m_usage;
|
||||
UInt64 m_size;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,6 @@ namespace Nz
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline BufferType OpenGLBuffer::GetType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/OpenGLRenderer/DebugOff.hpp>
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace Nz
|
||||
void BeginDebugRegion(const std::string_view& regionName, const Color& color) override;
|
||||
void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override;
|
||||
|
||||
void BindIndexBuffer(const AbstractBuffer& indexBuffer, UInt64 offset = 0) override;
|
||||
void BindIndexBuffer(const RenderBuffer& indexBuffer, UInt64 offset = 0) override;
|
||||
void BindPipeline(const RenderPipeline& pipeline) override;
|
||||
void BindShaderBinding(UInt32 set, const ShaderBinding& binding) override;
|
||||
void BindShaderBinding(const RenderPipelineLayout& pipelineLayout, UInt32 set, const ShaderBinding& binding) override;
|
||||
void BindVertexBuffer(UInt32 binding, const AbstractBuffer& vertexBuffer, UInt64 offset = 0) override;
|
||||
void BindVertexBuffer(UInt32 binding, const RenderBuffer& 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;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Nz
|
||||
const RenderDeviceFeatures& GetEnabledFeatures() const override;
|
||||
inline const GL::Context& GetReferenceContext() const;
|
||||
|
||||
std::shared_ptr<AbstractBuffer> InstantiateBuffer(BufferType type) override;
|
||||
std::shared_ptr<RenderBuffer> InstantiateBuffer(BufferType type, UInt64 size, BufferUsageFlags usageFlags, const void* initialData = nullptr) override;
|
||||
std::shared_ptr<CommandPool> InstantiateCommandPool(QueueType queueType) override;
|
||||
std::shared_ptr<Framebuffer> InstantiateFramebuffer(unsigned int width, unsigned int height, const std::shared_ptr<RenderPass>& renderPass, const std::vector<std::shared_ptr<Texture>>& attachments) override;
|
||||
std::shared_ptr<RenderPass> InstantiateRenderPass(std::vector<RenderPass::Attachment> attachments, std::vector<RenderPass::SubpassDescription> subpassDescriptions, std::vector<RenderPass::SubpassDependency> subpassDependencies) override;
|
||||
|
||||
@@ -42,11 +42,11 @@ namespace Nz
|
||||
inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect);
|
||||
inline void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, std::initializer_list<ClearValues> clearValues);
|
||||
|
||||
virtual void BindIndexBuffer(const AbstractBuffer& indexBuffer, UInt64 offset = 0) = 0;
|
||||
virtual void BindIndexBuffer(const RenderBuffer& indexBuffer, UInt64 offset = 0) = 0;
|
||||
virtual void BindPipeline(const RenderPipeline& pipeline) = 0;
|
||||
virtual void BindShaderBinding(UInt32 set, const ShaderBinding& binding) = 0;
|
||||
virtual void BindShaderBinding(const RenderPipelineLayout& pipelineLayout, UInt32 set, const ShaderBinding& binding) = 0;
|
||||
virtual void BindVertexBuffer(UInt32 binding, const AbstractBuffer& vertexBuffer, UInt64 offset = 0) = 0;
|
||||
virtual void BindVertexBuffer(UInt32 binding, const RenderBuffer& vertexBuffer, UInt64 offset = 0) = 0;
|
||||
|
||||
virtual void BlitTexture(const Texture& fromTexture, const Boxui& fromBox, TextureLayout fromLayout, const Texture& toTexture, const Boxui& toBox, TextureLayout toLayout, SamplerFilter filter) = 0;
|
||||
|
||||
|
||||
@@ -7,61 +7,34 @@
|
||||
#ifndef NAZARA_RENDERER_RENDERBUFFER_HPP
|
||||
#define NAZARA_RENDERER_RENDERBUFFER_HPP
|
||||
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/RenderDevice.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Utility/SoftwareBuffer.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RenderDevice;
|
||||
|
||||
class NAZARA_RENDERER_API RenderBuffer : public AbstractBuffer
|
||||
class NAZARA_RENDERER_API RenderBuffer : public Buffer
|
||||
{
|
||||
public:
|
||||
inline RenderBuffer(Buffer* parent, BufferType type);
|
||||
inline RenderBuffer(RenderDevice& renderDevice, BufferType type, UInt64 size, BufferUsageFlags usage);
|
||||
RenderBuffer(const RenderBuffer&) = delete;
|
||||
RenderBuffer(RenderBuffer&&) = default;
|
||||
~RenderBuffer() = default;
|
||||
RenderBuffer(RenderBuffer&&) = delete;
|
||||
~RenderBuffer();
|
||||
|
||||
bool Fill(const void* data, UInt64 offset, UInt64 size) final;
|
||||
|
||||
bool Initialize(UInt64 size, BufferUsageFlags usage) override;
|
||||
|
||||
AbstractBuffer* GetHardwareBuffer(RenderDevice* device);
|
||||
UInt64 GetSize() const override;
|
||||
DataStorage GetStorage() const override;
|
||||
|
||||
void* Map(BufferAccess access, UInt64 offset = 0, UInt64 size = 0) final;
|
||||
bool Unmap() final;
|
||||
inline RenderDevice& GetRenderDevice();
|
||||
inline const RenderDevice& GetRenderDevice() const;
|
||||
|
||||
RenderBuffer& operator=(const RenderBuffer&) = delete;
|
||||
RenderBuffer& operator=(RenderBuffer&&) = default;
|
||||
|
||||
public: //< temp
|
||||
bool Synchronize(RenderDevice* device);
|
||||
RenderBuffer& operator=(RenderBuffer&&) = delete;
|
||||
|
||||
private:
|
||||
struct HardwareBuffer;
|
||||
|
||||
HardwareBuffer* GetHardwareBufferData(RenderDevice* device);
|
||||
|
||||
struct HardwareBuffer
|
||||
{
|
||||
std::shared_ptr<AbstractBuffer> buffer;
|
||||
bool synchronized = false;
|
||||
};
|
||||
|
||||
BufferUsageFlags m_usage;
|
||||
SoftwareBuffer m_softwareBuffer;
|
||||
Buffer* m_parent;
|
||||
BufferType m_type;
|
||||
std::size_t m_size;
|
||||
std::unordered_map<RenderDevice*, HardwareBuffer> m_hardwareBuffers;
|
||||
RenderDevice& m_renderDevice;
|
||||
};
|
||||
|
||||
NAZARA_RENDERER_API BufferFactory GetRenderBufferFactory(std::shared_ptr<RenderDevice> device);
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderBuffer.inl>
|
||||
|
||||
@@ -3,17 +3,25 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline RenderBuffer::RenderBuffer(Buffer* parent, BufferType type) :
|
||||
m_softwareBuffer(parent, type),
|
||||
m_parent(parent),
|
||||
m_type(type)
|
||||
inline RenderBuffer::RenderBuffer(RenderDevice& renderDevice, BufferType type, UInt64 size, BufferUsageFlags usage) :
|
||||
Buffer(DataStorage::Hardware, type, size, usage),
|
||||
m_renderDevice(renderDevice)
|
||||
{
|
||||
}
|
||||
|
||||
inline RenderDevice& RenderBuffer::GetRenderDevice()
|
||||
{
|
||||
return m_renderDevice;
|
||||
}
|
||||
|
||||
inline const RenderDevice& RenderBuffer::GetRenderDevice() const
|
||||
{
|
||||
return m_renderDevice;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
@@ -9,20 +9,20 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Core/MovablePtr.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class RenderBufferView
|
||||
{
|
||||
public:
|
||||
inline RenderBufferView(AbstractBuffer* buffer);
|
||||
inline RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size);
|
||||
inline RenderBufferView(RenderBuffer* buffer);
|
||||
inline RenderBufferView(RenderBuffer* buffer, UInt64 offset, UInt64 size);
|
||||
RenderBufferView(const RenderBufferView&) = default;
|
||||
RenderBufferView(RenderBufferView&&) = default;
|
||||
~RenderBufferView() = default;
|
||||
|
||||
inline AbstractBuffer* GetBuffer() const;
|
||||
inline RenderBuffer* GetBuffer() const;
|
||||
inline UInt64 GetOffset() const;
|
||||
inline UInt64 GetSize() const;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Nz
|
||||
private:
|
||||
UInt64 m_offset;
|
||||
UInt64 m_size;
|
||||
AbstractBuffer* m_buffer;
|
||||
RenderBuffer* m_buffer;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,19 +8,19 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline RenderBufferView::RenderBufferView(AbstractBuffer* buffer) :
|
||||
inline RenderBufferView::RenderBufferView(RenderBuffer* buffer) :
|
||||
RenderBufferView(buffer, 0, buffer->GetSize())
|
||||
{
|
||||
}
|
||||
|
||||
inline RenderBufferView::RenderBufferView(AbstractBuffer* buffer, UInt64 offset, UInt64 size) :
|
||||
inline RenderBufferView::RenderBufferView(RenderBuffer* buffer, UInt64 offset, UInt64 size) :
|
||||
m_offset(offset),
|
||||
m_size(size),
|
||||
m_buffer(buffer)
|
||||
{
|
||||
}
|
||||
|
||||
inline AbstractBuffer* RenderBufferView::GetBuffer() const
|
||||
inline RenderBuffer* RenderBufferView::GetBuffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/Framebuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderDeviceInfo.hpp>
|
||||
#include <Nazara/Renderer/RenderPass.hpp>
|
||||
#include <Nazara/Renderer/RenderPipeline.hpp>
|
||||
@@ -19,7 +20,6 @@
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Shader/ShaderWriter.hpp>
|
||||
#include <Nazara/Shader/Ast/Nodes.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Utility/PixelFormat.hpp>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
virtual const RenderDeviceInfo& GetDeviceInfo() const = 0;
|
||||
virtual const RenderDeviceFeatures& GetEnabledFeatures() const = 0;
|
||||
|
||||
virtual std::shared_ptr<AbstractBuffer> InstantiateBuffer(BufferType type) = 0;
|
||||
virtual std::shared_ptr<RenderBuffer> InstantiateBuffer(BufferType type, UInt64 size, BufferUsageFlags usageFlags, const void* initialData = nullptr) = 0;
|
||||
virtual std::shared_ptr<CommandPool> InstantiateCommandPool(QueueType queueType) = 0;
|
||||
virtual std::shared_ptr<Framebuffer> InstantiateFramebuffer(unsigned int width, unsigned int height, const std::shared_ptr<RenderPass>& renderPass, const std::vector<std::shared_ptr<Texture>>& attachments) = 0;
|
||||
virtual std::shared_ptr<RenderPass> InstantiateRenderPass(std::vector<RenderPass::Attachment> attachments, std::vector<RenderPass::SubpassDescription> subpassDescriptions, std::vector<RenderPass::SubpassDependency> subpassDependencies) = 0;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderDeviceInfo.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractBuffer;
|
||||
class RenderBuffer;
|
||||
class ShaderBinding;
|
||||
class ShaderBindingDeleter;
|
||||
class Texture;
|
||||
@@ -48,7 +48,7 @@ namespace Nz
|
||||
|
||||
struct UniformBufferBinding
|
||||
{
|
||||
AbstractBuffer* buffer;
|
||||
RenderBuffer* buffer;
|
||||
UInt64 offset;
|
||||
UInt64 range;
|
||||
};
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#define NAZARA_GLOBAL_UTILITY_HPP
|
||||
|
||||
#include <Nazara/Utility/AbstractAtlas.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Utility/AbstractImage.hpp>
|
||||
#include <Nazara/Utility/AbstractTextDrawer.hpp>
|
||||
#include <Nazara/Utility/Algorithm.hpp>
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// Copyright (C) 2022 Jérôme "Lynix" Leclercq (lynix680@gmail.com)
|
||||
// This file is part of the "Nazara Engine - Utility module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_UTILITY_ABSTRACTBUFFER_HPP
|
||||
#define NAZARA_UTILITY_ABSTRACTBUFFER_HPP
|
||||
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_UTILITY_API AbstractBuffer
|
||||
{
|
||||
public:
|
||||
AbstractBuffer() = default;
|
||||
virtual ~AbstractBuffer();
|
||||
|
||||
virtual bool Fill(const void* data, UInt64 offset, UInt64 size) = 0;
|
||||
|
||||
virtual bool Initialize(UInt64 size, BufferUsageFlags usage) = 0;
|
||||
|
||||
virtual UInt64 GetSize() const = 0;
|
||||
virtual DataStorage GetStorage() const = 0;
|
||||
|
||||
virtual void* Map(BufferAccess access, UInt64 offset = 0, UInt64 size = 0) = 0;
|
||||
virtual bool Unmap() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_UTILITY_ABSTRACTBUFFER_HPP
|
||||
@@ -44,7 +44,7 @@ namespace Nz
|
||||
|
||||
NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr<const Vector3f> positionPtr, std::size_t vertexCount);
|
||||
NAZARA_UTILITY_API void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, std::size_t* indexCount, std::size_t* vertexCount);
|
||||
NAZARA_UTILITY_API unsigned int ComputeCacheMissCount(IndexIterator indices, std::size_t indexCount);
|
||||
NAZARA_UTILITY_API UInt64 ComputeCacheMissCount(IndexIterator indices, std::size_t indexCount);
|
||||
NAZARA_UTILITY_API void ComputeConeIndexVertexCount(unsigned int subdivision, std::size_t* indexCount, std::size_t* vertexCount);
|
||||
NAZARA_UTILITY_API void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, std::size_t* indexCount, std::size_t* vertexCount);
|
||||
NAZARA_UTILITY_API void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, std::size_t* indexCount, std::size_t* vertexCount);
|
||||
|
||||
@@ -8,68 +8,45 @@
|
||||
#define NAZARA_UTILITY_BUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Buffer;
|
||||
|
||||
using BufferFactory = std::function<std::shared_ptr<Buffer>(BufferType type, UInt64 size, BufferUsageFlags usage, const void* initialData)>;
|
||||
|
||||
class NAZARA_UTILITY_API Buffer
|
||||
{
|
||||
friend class Utility;
|
||||
|
||||
public:
|
||||
using BufferFactory = std::function<std::unique_ptr<AbstractBuffer>(Buffer* parent, BufferType type)>;
|
||||
|
||||
Buffer(BufferType type);
|
||||
Buffer(BufferType type, UInt32 size, DataStorage storage = DataStorage::Software, BufferUsageFlags usage = 0);
|
||||
inline Buffer(DataStorage storage, BufferType type, UInt64 size, BufferUsageFlags usage);
|
||||
Buffer(const Buffer&) = delete;
|
||||
Buffer(Buffer&&) = delete;
|
||||
~Buffer() = default;
|
||||
virtual ~Buffer();
|
||||
|
||||
bool CopyContent(const Buffer& buffer);
|
||||
std::shared_ptr<Buffer> CopyContent(const BufferFactory& bufferFactory);
|
||||
|
||||
bool Create(UInt32 size, DataStorage storage = DataStorage::Software, BufferUsageFlags usage = 0);
|
||||
void Destroy();
|
||||
virtual bool Fill(const void* data, UInt64 offset, UInt64 size) = 0;
|
||||
|
||||
bool Fill(const void* data, UInt32 offset, UInt32 size);
|
||||
|
||||
inline AbstractBuffer* GetImpl() const;
|
||||
inline UInt32 GetSize() const;
|
||||
inline UInt64 GetSize() const;
|
||||
inline DataStorage GetStorage() const;
|
||||
inline BufferType GetType() const;
|
||||
inline BufferUsageFlags GetUsage() const;
|
||||
inline BufferUsageFlags GetUsageFlags() const;
|
||||
|
||||
inline bool HasStorage(DataStorage storage) const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0);
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const;
|
||||
|
||||
bool SetStorage(DataStorage storage);
|
||||
|
||||
void Unmap() const;
|
||||
virtual void* Map(UInt64 offset, UInt64 size) = 0;
|
||||
virtual bool Unmap() = 0;
|
||||
|
||||
Buffer& operator=(const Buffer&) = delete;
|
||||
Buffer& operator=(Buffer&&) = delete;
|
||||
|
||||
static bool IsStorageSupported(DataStorage storage);
|
||||
static void SetBufferFactory(DataStorage storage, BufferFactory func);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
std::unique_ptr<AbstractBuffer> m_impl;
|
||||
BufferType m_type;
|
||||
BufferUsageFlags m_usage;
|
||||
UInt32 m_size;
|
||||
|
||||
static std::array<BufferFactory, DataStorageCount> s_bufferFactories;
|
||||
DataStorage m_storage;
|
||||
UInt64 m_size;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -8,19 +8,22 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline AbstractBuffer* Buffer::GetImpl() const
|
||||
inline Buffer::Buffer(DataStorage storage, BufferType type, UInt64 size, BufferUsageFlags usage) :
|
||||
m_type(type),
|
||||
m_usage(usage),
|
||||
m_storage(storage),
|
||||
m_size(size)
|
||||
{
|
||||
return m_impl.get();
|
||||
}
|
||||
|
||||
inline UInt32 Buffer::GetSize() const
|
||||
inline UInt64 Nz::Buffer::GetSize() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
inline DataStorage Buffer::GetStorage() const
|
||||
{
|
||||
return m_impl->GetStorage();
|
||||
return m_storage;
|
||||
}
|
||||
|
||||
inline BufferType Buffer::GetType() const
|
||||
@@ -28,20 +31,10 @@ namespace Nz
|
||||
return m_type;
|
||||
}
|
||||
|
||||
inline BufferUsageFlags Buffer::GetUsage() const
|
||||
inline BufferUsageFlags Buffer::GetUsageFlags() const
|
||||
{
|
||||
return m_usage;
|
||||
}
|
||||
|
||||
inline bool Buffer::HasStorage(DataStorage storage) const
|
||||
{
|
||||
return GetStorage() == storage;
|
||||
}
|
||||
|
||||
inline bool Buffer::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
||||
@@ -16,16 +16,10 @@ namespace Nz
|
||||
{
|
||||
public:
|
||||
BufferMapper();
|
||||
BufferMapper(T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
BufferMapper(T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
BufferMapper(const T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
BufferMapper(const T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
BufferMapper(T& buffer, UInt64 offset, UInt64 length);
|
||||
~BufferMapper();
|
||||
|
||||
bool Map(T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Map(T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Map(const T* buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Map(const T& buffer, BufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Map(T& buffer, UInt64 offset, UInt64 length);
|
||||
|
||||
const T* GetBuffer() const;
|
||||
void* GetPointer() const;
|
||||
@@ -33,7 +27,7 @@ namespace Nz
|
||||
void Unmap();
|
||||
|
||||
private:
|
||||
const T* m_buffer;
|
||||
T* m_buffer;
|
||||
void* m_ptr;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,33 +17,13 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BufferMapper<T>::BufferMapper(T* buffer, BufferAccess access, unsigned int offset, unsigned int length) :
|
||||
BufferMapper<T>::BufferMapper(T& buffer, UInt64 offset, UInt64 length) :
|
||||
m_buffer(nullptr)
|
||||
{
|
||||
if (!Map(buffer, access, offset, length))
|
||||
if (!Map(buffer, offset, length))
|
||||
NazaraError("Failed to map buffer"); ///TODO: Unexpected
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BufferMapper<T>::BufferMapper(T& buffer, BufferAccess access, unsigned int offset, unsigned int length) :
|
||||
BufferMapper(&buffer, access, offset, length)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BufferMapper<T>::BufferMapper(const T* buffer, BufferAccess access, unsigned int offset, unsigned int length) :
|
||||
m_buffer(nullptr)
|
||||
{
|
||||
if (!Map(buffer, access, offset, length))
|
||||
NazaraError("Failed to map buffer"); ///TODO: Unexpected
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BufferMapper<T>::BufferMapper(const T& buffer, BufferAccess access, unsigned int offset, unsigned int length) :
|
||||
BufferMapper(&buffer, access, offset, length)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BufferMapper<T>::~BufferMapper()
|
||||
{
|
||||
@@ -64,63 +44,21 @@ namespace Nz
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool BufferMapper<T>::Map(T* buffer, BufferAccess access, unsigned int offset, unsigned int length)
|
||||
bool BufferMapper<T>::Map(T& buffer, UInt64 offset, UInt64 length)
|
||||
{
|
||||
Unmap();
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!buffer)
|
||||
m_buffer = &buffer;
|
||||
m_ptr = buffer.Map(offset, length);
|
||||
if (!m_ptr)
|
||||
{
|
||||
NazaraError("Buffer must be valid");
|
||||
m_ptr = nullptr;
|
||||
|
||||
NazaraError("Failed to map buffer"); ///TODO: Unexpected
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_buffer = buffer;
|
||||
m_ptr = buffer->Map(access, offset, length);
|
||||
if (!m_ptr)
|
||||
NazaraError("Failed to map buffer"); ///TODO: Unexpected
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool BufferMapper<T>::Map(T& buffer, BufferAccess access, unsigned int offset, unsigned int length)
|
||||
{
|
||||
return Map(&buffer, access, offset, length);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool BufferMapper<T>::Map(const T* buffer, BufferAccess access, unsigned int offset, unsigned int length)
|
||||
{
|
||||
Unmap();
|
||||
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (!buffer)
|
||||
{
|
||||
NazaraError("Buffer must be valid");
|
||||
m_ptr = nullptr;
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
m_buffer = buffer;
|
||||
m_ptr = buffer->Map(access, offset, length);
|
||||
if (!m_ptr)
|
||||
NazaraError("Failed to map buffer"); ///TODO: Unexpected
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
bool BufferMapper<T>::Map(const T& buffer, BufferAccess access, unsigned int offset, unsigned int length)
|
||||
{
|
||||
return Map(&buffer, access, offset, length);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void BufferMapper<T>::Unmap()
|
||||
{
|
||||
|
||||
@@ -70,7 +70,9 @@ namespace Nz
|
||||
DeviceLocal,
|
||||
DirectMapping,
|
||||
Dynamic,
|
||||
Read,
|
||||
PersistentMapping,
|
||||
Write,
|
||||
|
||||
Max = DirectMapping
|
||||
};
|
||||
|
||||
@@ -17,40 +17,34 @@ namespace Nz
|
||||
public:
|
||||
IndexBuffer() = default;
|
||||
IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer);
|
||||
IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer, std::size_t offset, std::size_t size);
|
||||
IndexBuffer(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage);
|
||||
IndexBuffer(bool largeIndices, std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
|
||||
IndexBuffer(bool largeIndices, UInt64 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
|
||||
IndexBuffer(const IndexBuffer&) = default;
|
||||
IndexBuffer(IndexBuffer&&) noexcept = default;
|
||||
~IndexBuffer() = default;
|
||||
|
||||
unsigned int ComputeCacheMissCount() const;
|
||||
unsigned int ComputeCacheMissCount();
|
||||
|
||||
bool Fill(const void* data, std::size_t startIndex, std::size_t length);
|
||||
bool FillRaw(const void* data, std::size_t offset, std::size_t size);
|
||||
bool Fill(const void* data, UInt64 startIndex, UInt64 length);
|
||||
bool FillRaw(const void* data, UInt64 offset, UInt64 size);
|
||||
|
||||
inline const std::shared_ptr<Buffer>& GetBuffer() const;
|
||||
inline std::size_t GetEndOffset() const;
|
||||
inline std::size_t GetIndexCount() const;
|
||||
inline std::size_t GetStride() const;
|
||||
inline std::size_t GetStartOffset() const;
|
||||
inline UInt64 GetEndOffset() const;
|
||||
inline UInt64 GetIndexCount() const;
|
||||
inline UInt64 GetStride() const;
|
||||
inline UInt64 GetStartOffset() const;
|
||||
|
||||
inline bool HasLargeIndices() const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
inline void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0);
|
||||
inline void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0) const;
|
||||
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0);
|
||||
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0) const;
|
||||
inline void* Map(UInt64 startIndex, UInt64 length);
|
||||
inline void* Map(UInt64 startIndex, UInt64 length) const;
|
||||
void* MapRaw(UInt64 offset, UInt64 size);
|
||||
void* MapRaw(UInt64 offset, UInt64 size) const;
|
||||
|
||||
void Optimize();
|
||||
|
||||
void Reset();
|
||||
void Reset(bool largeIndices, std::shared_ptr<Buffer> buffer);
|
||||
void Reset(bool largeIndices, std::shared_ptr<Buffer> buffer, std::size_t offset, std::size_t size);
|
||||
void Reset(bool largeIndices, std::size_t length, DataStorage storage, BufferUsageFlags usage);
|
||||
void Reset(const IndexBuffer& indexBuffer);
|
||||
|
||||
void Unmap() const;
|
||||
|
||||
IndexBuffer& operator=(const IndexBuffer&) = default;
|
||||
@@ -58,9 +52,9 @@ namespace Nz
|
||||
|
||||
private:
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
std::size_t m_endOffset;
|
||||
std::size_t m_indexCount;
|
||||
std::size_t m_startOffset;
|
||||
UInt64 m_endOffset;
|
||||
UInt64 m_indexCount;
|
||||
UInt64 m_startOffset;
|
||||
bool m_largeIndices;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -13,22 +13,22 @@ namespace Nz
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline std::size_t IndexBuffer::GetEndOffset() const
|
||||
inline UInt64 IndexBuffer::GetEndOffset() const
|
||||
{
|
||||
return m_endOffset;
|
||||
}
|
||||
|
||||
inline std::size_t IndexBuffer::GetIndexCount() const
|
||||
inline UInt64 IndexBuffer::GetIndexCount() const
|
||||
{
|
||||
return m_indexCount;
|
||||
}
|
||||
|
||||
inline std::size_t IndexBuffer::GetStride() const
|
||||
inline UInt64 IndexBuffer::GetStride() const
|
||||
{
|
||||
return static_cast<std::size_t>((m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16));
|
||||
return (m_largeIndices) ? sizeof(UInt32) : sizeof(UInt16);
|
||||
}
|
||||
|
||||
inline std::size_t IndexBuffer::GetStartOffset() const
|
||||
inline UInt64 IndexBuffer::GetStartOffset() const
|
||||
{
|
||||
return m_startOffset;
|
||||
}
|
||||
@@ -43,16 +43,16 @@ namespace Nz
|
||||
return m_buffer != nullptr;
|
||||
}
|
||||
|
||||
inline void* IndexBuffer::Map(BufferAccess access, std::size_t startIndex, std::size_t length)
|
||||
inline void* IndexBuffer::Map(UInt64 startIndex, UInt64 length)
|
||||
{
|
||||
std::size_t stride = GetStride();
|
||||
return MapRaw(access, startIndex*stride, length*stride);
|
||||
UInt64 stride = GetStride();
|
||||
return MapRaw(startIndex * stride, length * stride);
|
||||
}
|
||||
|
||||
inline void* IndexBuffer::Map(BufferAccess access, std::size_t startIndex, std::size_t length) const
|
||||
inline void* IndexBuffer::Map(UInt64 startIndex, UInt64 length) const
|
||||
{
|
||||
std::size_t stride = GetStride();
|
||||
return MapRaw(access, startIndex*stride, length*stride);
|
||||
UInt64 stride = GetStride();
|
||||
return MapRaw(startIndex * stride, length * stride);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,8 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API IndexMapper
|
||||
{
|
||||
public:
|
||||
IndexMapper(IndexBuffer& indexBuffer, BufferAccess access = BufferAccess::ReadWrite, std::size_t indexCount = 0);
|
||||
IndexMapper(SubMesh& subMesh, BufferAccess access = BufferAccess::ReadWrite);
|
||||
IndexMapper(const IndexBuffer& indexBuffer, BufferAccess access = BufferAccess::ReadOnly, std::size_t indexCount = 0);
|
||||
IndexMapper(const SubMesh& subMesh, BufferAccess access = BufferAccess::ReadOnly);
|
||||
IndexMapper(IndexBuffer& indexBuffer, std::size_t indexCount = 0);
|
||||
IndexMapper(SubMesh& subMes);
|
||||
~IndexMapper() = default;
|
||||
|
||||
UInt32 Get(std::size_t i) const;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/Skeleton.hpp>
|
||||
#include <Nazara/Utility/SoftwareBuffer.hpp>
|
||||
#include <Nazara/Utility/SubMesh.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
#include <Nazara/Utility/VertexStruct.hpp>
|
||||
@@ -28,20 +29,35 @@ namespace Nz
|
||||
{
|
||||
struct NAZARA_UTILITY_API MeshParams : ResourceParameters
|
||||
{
|
||||
MeshParams();
|
||||
// How buffer will be allocated (by default in RAM)
|
||||
BufferFactory bufferFactory = &SoftwareBufferFactory;
|
||||
|
||||
BufferUsageFlags indexBufferFlags = 0; ///< Buffer usage flags used to build the index buffers
|
||||
BufferUsageFlags vertexBufferFlags = 0; ///< Buffer usage flags used to build the vertex buffers
|
||||
Matrix4f matrix = Matrix4f::Identity(); ///< A matrix which will transform every vertex position
|
||||
DataStorage storage = DataStorage::Hardware; ///< The place where the buffers will be allocated
|
||||
Vector2f texCoordOffset = {0.f, 0.f}; ///< Offset to apply on the texture coordinates (not scaled)
|
||||
Vector2f texCoordScale = {1.f, 1.f}; ///< Scale to apply on the texture coordinates
|
||||
bool animated = true; ///< If true, will load an animated version of the model if possible
|
||||
bool center = false; ///< If true, will center the mesh vertices around the origin
|
||||
// Buffer usage flags used to build the index buffers
|
||||
BufferUsageFlags indexBufferFlags = BufferUsage::DirectMapping | BufferUsage::Read | BufferUsage::Write;
|
||||
|
||||
// Buffer usage flags used to build the vertex buffers
|
||||
BufferUsageFlags vertexBufferFlags = BufferUsage::DirectMapping | BufferUsage::Read | BufferUsage::Write;
|
||||
|
||||
// A matrix which will transform every vertex position
|
||||
Matrix4f matrix = Matrix4f::Identity();
|
||||
|
||||
// Offset to apply on the texture coordinates (not scaled)
|
||||
Vector2f texCoordOffset = {0.f, 0.f};
|
||||
|
||||
// Scale to apply on the texture coordinates
|
||||
Vector2f texCoordScale = {1.f, 1.f};
|
||||
|
||||
// If true, will load an animated version of the model if possible
|
||||
bool animated = true;
|
||||
|
||||
// If true, will center the mesh vertices around the origin
|
||||
bool center = false;
|
||||
|
||||
// Optimize the index buffers after loading, improve cache locality (and thus rendering speed) but increase loading time.
|
||||
#ifndef NAZARA_DEBUG
|
||||
bool optimizeIndexBuffers = true; ///< Optimize the index buffers after loading, improve cache locality (and thus rendering speed) but increase loading time.
|
||||
bool optimizeIndexBuffers = true;
|
||||
#else
|
||||
bool optimizeIndexBuffers = false; ///< Since this optimization take a lot of time, especially in debug mode, don't enable it by default in debug.
|
||||
bool optimizeIndexBuffers = false;
|
||||
#endif
|
||||
|
||||
/* The declaration must have a Vector3f position component enabled
|
||||
|
||||
@@ -17,12 +17,12 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API SkeletalMesh final : public SubMesh
|
||||
{
|
||||
public:
|
||||
SkeletalMesh(std::shared_ptr<VertexBuffer> vertexBuffer, std::shared_ptr<const IndexBuffer> indexBuffer);
|
||||
SkeletalMesh(std::shared_ptr<VertexBuffer> vertexBuffer, std::shared_ptr<IndexBuffer> indexBuffer);
|
||||
~SkeletalMesh() = default;
|
||||
|
||||
const Boxf& GetAABB() const override;
|
||||
AnimationType GetAnimationType() const final;
|
||||
const std::shared_ptr<const IndexBuffer>& GetIndexBuffer() const override;
|
||||
const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const override;
|
||||
const std::shared_ptr<VertexBuffer>& GetVertexBuffer() const;
|
||||
std::size_t GetVertexCount() const override;
|
||||
|
||||
@@ -30,11 +30,11 @@ namespace Nz
|
||||
bool IsValid() const;
|
||||
|
||||
void SetAABB(const Boxf& aabb);
|
||||
void SetIndexBuffer(std::shared_ptr<const IndexBuffer> indexBuffer);
|
||||
void SetIndexBuffer(std::shared_ptr<IndexBuffer> indexBuffer);
|
||||
|
||||
private:
|
||||
Boxf m_aabb;
|
||||
std::shared_ptr<const IndexBuffer> m_indexBuffer;
|
||||
std::shared_ptr<IndexBuffer> m_indexBuffer;
|
||||
std::shared_ptr<VertexBuffer> m_vertexBuffer;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,34 +8,30 @@
|
||||
#define NAZARA_UTILITY_SOFTWAREBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class Buffer;
|
||||
|
||||
class NAZARA_UTILITY_API SoftwareBuffer : public AbstractBuffer
|
||||
class NAZARA_UTILITY_API SoftwareBuffer : public Buffer
|
||||
{
|
||||
public:
|
||||
SoftwareBuffer(Buffer* parent, BufferType type);
|
||||
SoftwareBuffer(BufferType type, UInt64 size, BufferUsageFlags usage, const void* initialData);
|
||||
~SoftwareBuffer() = default;
|
||||
|
||||
bool Fill(const void* data, UInt64 offset, UInt64 size) override;
|
||||
|
||||
bool Initialize(UInt64 size, BufferUsageFlags usage) override;
|
||||
|
||||
const UInt8* GetData() const;
|
||||
UInt64 GetSize() const override;
|
||||
DataStorage GetStorage() const override;
|
||||
|
||||
void* Map(BufferAccess access, UInt64 offset = 0, UInt64 size = 0) override;
|
||||
void* Map(UInt64 offset = 0, UInt64 size = 0) override;
|
||||
bool Unmap() override;
|
||||
|
||||
private:
|
||||
std::vector<UInt8> m_buffer;
|
||||
std::unique_ptr<UInt8[]> m_buffer;
|
||||
bool m_mapped;
|
||||
};
|
||||
|
||||
NAZARA_UTILITY_API std::shared_ptr<Buffer> SoftwareBufferFactory(BufferType type, UInt64 size, BufferUsageFlags usage, const void* initialData = nullptr);
|
||||
}
|
||||
|
||||
#endif // NAZARA_UTILITY_SOFTWAREBUFFER_HPP
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API StaticMesh final : public SubMesh
|
||||
{
|
||||
public:
|
||||
StaticMesh(std::shared_ptr<VertexBuffer> vertexBuffer, std::shared_ptr<const IndexBuffer> indexBuffer);
|
||||
StaticMesh(std::shared_ptr<VertexBuffer> vertexBuffer, std::shared_ptr<IndexBuffer> indexBuffer);
|
||||
~StaticMesh() = default;
|
||||
|
||||
void Center();
|
||||
@@ -24,7 +24,7 @@ namespace Nz
|
||||
|
||||
const Boxf& GetAABB() const override;
|
||||
AnimationType GetAnimationType() const final;
|
||||
const std::shared_ptr<const IndexBuffer>& GetIndexBuffer() const override;
|
||||
const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const override;
|
||||
const std::shared_ptr<VertexBuffer>& GetVertexBuffer() const;
|
||||
std::size_t GetVertexCount() const override;
|
||||
|
||||
@@ -32,11 +32,11 @@ namespace Nz
|
||||
bool IsValid() const;
|
||||
|
||||
void SetAABB(const Boxf& aabb);
|
||||
void SetIndexBuffer(std::shared_ptr<const IndexBuffer> indexBuffer);
|
||||
void SetIndexBuffer(std::shared_ptr<IndexBuffer> indexBuffer);
|
||||
|
||||
private:
|
||||
Boxf m_aabb;
|
||||
std::shared_ptr<const IndexBuffer> m_indexBuffer;
|
||||
std::shared_ptr<IndexBuffer> m_indexBuffer;
|
||||
std::shared_ptr<VertexBuffer> m_vertexBuffer;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Nz
|
||||
|
||||
virtual const Boxf& GetAABB() const = 0;
|
||||
virtual AnimationType GetAnimationType() const = 0;
|
||||
virtual const std::shared_ptr<const IndexBuffer>& GetIndexBuffer() const = 0;
|
||||
virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const = 0;
|
||||
std::size_t GetMaterialIndex() const;
|
||||
PrimitiveMode GetPrimitiveMode() const;
|
||||
std::size_t GetTriangleCount() const;
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API TriangleIterator
|
||||
{
|
||||
public:
|
||||
TriangleIterator(PrimitiveMode primitiveMode, const IndexBuffer& indexBuffer);
|
||||
TriangleIterator(const SubMesh& subMesh);
|
||||
TriangleIterator(PrimitiveMode primitiveMode, IndexBuffer& indexBuffer);
|
||||
TriangleIterator(SubMesh& subMesh);
|
||||
~TriangleIterator() = default;
|
||||
|
||||
bool Advance();
|
||||
|
||||
@@ -15,30 +15,21 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API UniformBuffer
|
||||
{
|
||||
public:
|
||||
UniformBuffer() = default;
|
||||
UniformBuffer(std::shared_ptr<Buffer> buffer);
|
||||
UniformBuffer(std::shared_ptr<Buffer> buffer, UInt32 offset, UInt32 size);
|
||||
UniformBuffer(UInt32 length, DataStorage storage, BufferUsageFlags usage);
|
||||
UniformBuffer(std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
|
||||
UniformBuffer(UInt64 size, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
|
||||
UniformBuffer(const UniformBuffer&) = default;
|
||||
UniformBuffer(UniformBuffer&&) noexcept = default;
|
||||
~UniformBuffer() = default;
|
||||
|
||||
bool Fill(const void* data, UInt32 offset, UInt32 size);
|
||||
bool Fill(const void* data, UInt64 offset, UInt64 size);
|
||||
|
||||
inline const std::shared_ptr<Buffer>& GetBuffer() const;
|
||||
inline UInt32 GetEndOffset() const;
|
||||
inline UInt32 GetStartOffset() const;
|
||||
inline UInt64 GetEndOffset() const;
|
||||
inline UInt64 GetStartOffset() const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0);
|
||||
void* Map(BufferAccess access, UInt32 offset = 0, UInt32 size = 0) const;
|
||||
|
||||
void Reset();
|
||||
void Reset(std::shared_ptr<Buffer> buffer);
|
||||
void Reset(std::shared_ptr<Buffer> buffer, UInt32 offset, UInt32 size);
|
||||
void Reset(UInt32 size, DataStorage storage, BufferUsageFlags usage);
|
||||
void Reset(const UniformBuffer& uniformBuffer);
|
||||
void* Map(UInt64 offset = 0, UInt64 size = 0);
|
||||
void* Map(UInt64 offset = 0, UInt64 size = 0) const;
|
||||
|
||||
void Unmap() const;
|
||||
|
||||
@@ -47,8 +38,8 @@ namespace Nz
|
||||
|
||||
private:
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
UInt32 m_endOffset;
|
||||
UInt32 m_startOffset;
|
||||
UInt64 m_endOffset;
|
||||
UInt64 m_startOffset;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,20 +13,15 @@ namespace Nz
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline UInt32 UniformBuffer::GetEndOffset() const
|
||||
inline UInt64 UniformBuffer::GetEndOffset() const
|
||||
{
|
||||
return m_endOffset;
|
||||
}
|
||||
|
||||
inline UInt32 UniformBuffer::GetStartOffset() const
|
||||
inline UInt64 UniformBuffer::GetStartOffset() const
|
||||
{
|
||||
return m_startOffset;
|
||||
}
|
||||
|
||||
inline bool UniformBuffer::IsValid() const
|
||||
{
|
||||
return m_buffer != nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Utility/DebugOff.hpp>
|
||||
|
||||
@@ -18,34 +18,28 @@ namespace Nz
|
||||
public:
|
||||
VertexBuffer() = default;
|
||||
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer);
|
||||
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer, std::size_t offset, std::size_t size);
|
||||
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage);
|
||||
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
|
||||
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, UInt64 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
|
||||
VertexBuffer(const VertexBuffer&) = default;
|
||||
VertexBuffer(VertexBuffer&&) noexcept = default;
|
||||
~VertexBuffer() = default;
|
||||
|
||||
bool Fill(const void* data, std::size_t startVertex, std::size_t length);
|
||||
bool FillRaw(const void* data, std::size_t offset, std::size_t size);
|
||||
bool Fill(const void* data, UInt64 startVertex, UInt64 length);
|
||||
bool FillRaw(const void* data, UInt64 offset, UInt64 size);
|
||||
|
||||
inline const std::shared_ptr<Buffer>& GetBuffer() const;
|
||||
inline std::size_t GetEndOffset() const;
|
||||
inline std::size_t GetStartOffset() const;
|
||||
inline std::size_t GetStride() const;
|
||||
inline std::size_t GetVertexCount() const;
|
||||
inline UInt64 GetEndOffset() const;
|
||||
inline UInt64 GetStartOffset() const;
|
||||
inline UInt64 GetStride() const;
|
||||
inline UInt64 GetVertexCount() const;
|
||||
inline const std::shared_ptr<const VertexDeclaration>& GetVertexDeclaration() const;
|
||||
|
||||
inline bool IsValid() const;
|
||||
|
||||
void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0);
|
||||
void* Map(BufferAccess access, std::size_t startVertex = 0, std::size_t length = 0) const;
|
||||
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0);
|
||||
void* MapRaw(BufferAccess access, std::size_t offset = 0, std::size_t size = 0) const;
|
||||
|
||||
void Reset();
|
||||
void Reset(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer);
|
||||
void Reset(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer, std::size_t offset, std::size_t size);
|
||||
void Reset(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::size_t length, DataStorage storage, BufferUsageFlags usage);
|
||||
void Reset(const VertexBuffer& vertexBuffer);
|
||||
void* Map(UInt64 startVertex, UInt64 length);
|
||||
void* Map(UInt64 startVertex, UInt64 length) const;
|
||||
void* MapRaw(UInt64 offset, UInt64 size);
|
||||
void* MapRaw(UInt64 offset, UInt64 size) const;
|
||||
|
||||
void SetVertexDeclaration(std::shared_ptr<const VertexDeclaration> vertexDeclaration);
|
||||
|
||||
@@ -57,9 +51,9 @@ namespace Nz
|
||||
private:
|
||||
std::shared_ptr<Buffer> m_buffer;
|
||||
std::shared_ptr<const VertexDeclaration> m_vertexDeclaration;
|
||||
std::size_t m_endOffset;
|
||||
std::size_t m_startOffset;
|
||||
std::size_t m_vertexCount;
|
||||
UInt64 m_endOffset;
|
||||
UInt64 m_startOffset;
|
||||
UInt64 m_vertexCount;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,22 +13,22 @@ namespace Nz
|
||||
return m_buffer;
|
||||
}
|
||||
|
||||
inline std::size_t VertexBuffer::GetEndOffset() const
|
||||
inline UInt64 VertexBuffer::GetEndOffset() const
|
||||
{
|
||||
return m_endOffset;
|
||||
}
|
||||
|
||||
inline std::size_t VertexBuffer::GetStride() const
|
||||
inline UInt64 VertexBuffer::GetStride() const
|
||||
{
|
||||
return static_cast<std::size_t>(m_vertexDeclaration->GetStride());
|
||||
return static_cast<UInt64>(m_vertexDeclaration->GetStride());
|
||||
}
|
||||
|
||||
inline std::size_t VertexBuffer::GetStartOffset() const
|
||||
inline UInt64 VertexBuffer::GetStartOffset() const
|
||||
{
|
||||
return m_startOffset;
|
||||
}
|
||||
|
||||
inline std::size_t VertexBuffer::GetVertexCount() const
|
||||
inline UInt64 VertexBuffer::GetVertexCount() const
|
||||
{
|
||||
return m_vertexCount;
|
||||
}
|
||||
|
||||
@@ -20,10 +20,8 @@ namespace Nz
|
||||
class NAZARA_UTILITY_API VertexMapper
|
||||
{
|
||||
public:
|
||||
VertexMapper(SubMesh& subMesh, BufferAccess access = BufferAccess::ReadWrite);
|
||||
VertexMapper(VertexBuffer& vertexBuffer, BufferAccess access = BufferAccess::ReadWrite);
|
||||
VertexMapper(const SubMesh& subMesh, BufferAccess access = BufferAccess::ReadOnly);
|
||||
VertexMapper(const VertexBuffer& vertexBuffer, BufferAccess access = BufferAccess::ReadOnly);
|
||||
VertexMapper(SubMesh& subMesh);
|
||||
VertexMapper(VertexBuffer& vertexBuffer);
|
||||
~VertexMapper();
|
||||
|
||||
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component, std::size_t componentIndex = 0);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#define NAZARA_VULKANRENDERER_VULKANBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/AbstractBuffer.hpp>
|
||||
#include <Nazara/Renderer/RenderBuffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Config.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/Buffer.hpp>
|
||||
#include <Nazara/VulkanRenderer/Wrapper/DeviceMemory.hpp>
|
||||
@@ -18,36 +18,30 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class NAZARA_VULKANRENDERER_API VulkanBuffer : public AbstractBuffer
|
||||
class NAZARA_VULKANRENDERER_API VulkanBuffer : public RenderBuffer
|
||||
{
|
||||
public:
|
||||
inline VulkanBuffer(Vk::Device& device, BufferType type);
|
||||
inline VulkanBuffer(VulkanDevice& device, BufferType type, UInt64 size, BufferUsageFlags usage, const void* initialData = nullptr);
|
||||
VulkanBuffer(const VulkanBuffer&) = delete;
|
||||
VulkanBuffer(VulkanBuffer&&) = delete; ///TODO
|
||||
virtual ~VulkanBuffer();
|
||||
|
||||
bool Fill(const void* data, UInt64 offset, UInt64 size) override;
|
||||
|
||||
bool Initialize(UInt64 size, BufferUsageFlags usage) override;
|
||||
|
||||
inline VkBuffer GetBuffer() const;
|
||||
UInt64 GetSize() const override;
|
||||
DataStorage GetStorage() const override;
|
||||
|
||||
void* Map(BufferAccess access, UInt64 offset, UInt64 size) override;
|
||||
void* Map(UInt64 offset, UInt64 size) override;
|
||||
bool Unmap() override;
|
||||
|
||||
VulkanBuffer& operator=(const VulkanBuffer&) = delete;
|
||||
VulkanBuffer& operator=(VulkanBuffer&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
BufferType m_type;
|
||||
BufferUsageFlags m_usage;
|
||||
UInt64 m_size;
|
||||
VkBuffer m_buffer;
|
||||
VkBuffer m_stagingBuffer;
|
||||
VmaAllocation m_allocation;
|
||||
VmaAllocation m_stagingAllocation;
|
||||
UInt64 m_stagingBufferSize;
|
||||
Vk::Device& m_device;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline VulkanBuffer::VulkanBuffer(Vk::Device& device, BufferType type) :
|
||||
m_type(type),
|
||||
m_device(device)
|
||||
{
|
||||
}
|
||||
|
||||
inline VkBuffer VulkanBuffer::GetBuffer() const
|
||||
{
|
||||
return m_buffer;
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace Nz
|
||||
void BeginDebugRegion(const std::string_view& regionName, const Color& color) override;
|
||||
void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override;
|
||||
|
||||
void BindIndexBuffer(const AbstractBuffer& indexBuffer, UInt64 offset = 0) override;
|
||||
void BindIndexBuffer(const RenderBuffer& indexBuffer, UInt64 offset = 0) override;
|
||||
void BindPipeline(const RenderPipeline& pipeline) override;
|
||||
void BindShaderBinding(UInt32 set, const ShaderBinding& binding) override;
|
||||
void BindShaderBinding(const RenderPipelineLayout& pipelineLayout, UInt32 set, const ShaderBinding& binding) override;
|
||||
void BindVertexBuffer(UInt32 binding, const AbstractBuffer& vertexBuffer, UInt64 offset = 0) override;
|
||||
void BindVertexBuffer(UInt32 binding, const RenderBuffer& 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;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
const RenderDeviceInfo& GetDeviceInfo() const override;
|
||||
const RenderDeviceFeatures& GetEnabledFeatures() const override;
|
||||
|
||||
std::shared_ptr<AbstractBuffer> InstantiateBuffer(BufferType type) override;
|
||||
std::shared_ptr<RenderBuffer> InstantiateBuffer(BufferType type, UInt64 size, BufferUsageFlags usageFlags, const void* initialData = nullptr) override;
|
||||
std::shared_ptr<CommandPool> InstantiateCommandPool(QueueType queueType) override;
|
||||
std::shared_ptr<Framebuffer> InstantiateFramebuffer(unsigned int width, unsigned int height, const std::shared_ptr<RenderPass>& renderPass, const std::vector<std::shared_ptr<Texture>>& attachments) override;
|
||||
std::shared_ptr<RenderPass> InstantiateRenderPass(std::vector<RenderPass::Attachment> attachments, std::vector<RenderPass::SubpassDescription> subpassDescriptions, std::vector<RenderPass::SubpassDependency> subpassDependencies) override;
|
||||
|
||||
Reference in New Issue
Block a user