mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-16 08:27:10 +00:00
Move xxhash to boo; cached shader components
This commit is contained in:
@@ -5,39 +5,16 @@
|
||||
#include "IGraphicsCommandQueue.hpp"
|
||||
#include "boo/IGraphicsContext.hpp"
|
||||
#include "GLSLMacros.hpp"
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
|
||||
namespace boo
|
||||
{
|
||||
|
||||
class GLDataFactory : public IGraphicsDataFactory
|
||||
{
|
||||
friend struct GLCommandQueue;
|
||||
IGraphicsContext* m_parent;
|
||||
uint32_t m_drawSamples;
|
||||
static ThreadLocalPtr<struct GLData> m_deferredData;
|
||||
std::unordered_set<struct GLData*> m_committedData;
|
||||
std::unordered_set<struct GLPool*> m_committedPools;
|
||||
std::mutex m_committedMutex;
|
||||
void destroyData(IGraphicsData*);
|
||||
void destroyAllData();
|
||||
void destroyPool(IGraphicsBufferPool*);
|
||||
IGraphicsBufferD* newPoolBuffer(IGraphicsBufferPool* pool, BufferUse use,
|
||||
size_t stride, size_t count);
|
||||
void deletePoolBuffer(IGraphicsBufferPool* p, IGraphicsBufferD* buf);
|
||||
public:
|
||||
GLDataFactory(IGraphicsContext* parent, uint32_t drawSamples);
|
||||
~GLDataFactory() {destroyAllData();}
|
||||
|
||||
Platform platform() const {return Platform::OpenGL;}
|
||||
const SystemChar* platformName() const {return _S("OpenGL");}
|
||||
|
||||
class Context : public IGraphicsDataFactory::Context
|
||||
{
|
||||
friend class GLDataFactory;
|
||||
friend class GLDataFactoryImpl;
|
||||
GLDataFactory& m_parent;
|
||||
Context(GLDataFactory& parent) : m_parent(parent) {}
|
||||
public:
|
||||
@@ -73,9 +50,6 @@ public:
|
||||
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||
size_t texCount, ITexture** texs, size_t baseVert = 0, size_t baseInst = 0);
|
||||
};
|
||||
|
||||
GraphicsDataToken commitTransaction(const FactoryCommitFunc&);
|
||||
GraphicsBufferPoolToken newBufferPool();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace boo
|
||||
|
||||
struct IGraphicsCommandQueue
|
||||
{
|
||||
virtual ~IGraphicsCommandQueue() {}
|
||||
virtual ~IGraphicsCommandQueue() = default;
|
||||
|
||||
using Platform = IGraphicsDataFactory::Platform;
|
||||
virtual Platform platform() const=0;
|
||||
|
||||
@@ -17,7 +17,7 @@ struct IGraphicsBuffer
|
||||
protected:
|
||||
bool m_dynamic;
|
||||
IGraphicsBuffer(bool dynamic) : m_dynamic(dynamic) {}
|
||||
virtual ~IGraphicsBuffer() {}
|
||||
virtual ~IGraphicsBuffer() = default;
|
||||
};
|
||||
|
||||
/** Static resource buffer for verts, indices, uniform constants */
|
||||
@@ -190,7 +190,7 @@ enum class BlendFactor
|
||||
/** Factory object for creating batches of resources as an IGraphicsData token */
|
||||
struct IGraphicsDataFactory
|
||||
{
|
||||
virtual ~IGraphicsDataFactory() {}
|
||||
virtual ~IGraphicsDataFactory() = default;
|
||||
|
||||
enum class Platform
|
||||
{
|
||||
@@ -276,10 +276,10 @@ using FactoryCommitFunc = std::function<bool(IGraphicsDataFactory::Context& ctx)
|
||||
* IGraphicsData (please don't delete and draw contained resources in the same frame). */
|
||||
class GraphicsDataToken
|
||||
{
|
||||
friend class GLDataFactory;
|
||||
friend class GLDataFactoryImpl;
|
||||
friend class D3D12DataFactory;
|
||||
friend class D3D11DataFactory;
|
||||
friend class MetalDataFactory;
|
||||
friend class MetalDataFactoryImpl;
|
||||
friend class VulkanDataFactory;
|
||||
IGraphicsDataFactory* m_factory = nullptr;
|
||||
IGraphicsData* m_data = nullptr;
|
||||
@@ -323,10 +323,10 @@ public:
|
||||
* (please don't delete and draw contained resources in the same frame). */
|
||||
class GraphicsBufferPoolToken
|
||||
{
|
||||
friend class GLDataFactory;
|
||||
friend class GLDataFactoryImpl;
|
||||
friend class D3D12DataFactory;
|
||||
friend class D3D11DataFactory;
|
||||
friend class MetalDataFactory;
|
||||
friend class MetalDataFactoryImpl;
|
||||
friend class VulkanDataFactory;
|
||||
IGraphicsDataFactory* m_factory = nullptr;
|
||||
IGraphicsBufferPool* m_pool = nullptr;
|
||||
|
||||
@@ -6,42 +6,16 @@
|
||||
#include "IGraphicsDataFactory.hpp"
|
||||
#include "IGraphicsCommandQueue.hpp"
|
||||
#include "boo/IGraphicsContext.hpp"
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace boo
|
||||
{
|
||||
struct MetalContext;
|
||||
|
||||
class MetalDataFactory : public IGraphicsDataFactory
|
||||
{
|
||||
friend struct MetalCommandQueue;
|
||||
IGraphicsContext* m_parent;
|
||||
static ThreadLocalPtr<struct MetalData> m_deferredData;
|
||||
std::unordered_set<struct MetalData*> m_committedData;
|
||||
std::unordered_set<struct MetalPool*> m_committedPools;
|
||||
std::mutex m_committedMutex;
|
||||
struct MetalContext* m_ctx;
|
||||
uint32_t m_sampleCount;
|
||||
|
||||
void destroyData(IGraphicsData*);
|
||||
void destroyAllData();
|
||||
void destroyPool(IGraphicsBufferPool*);
|
||||
IGraphicsBufferD* newPoolBuffer(IGraphicsBufferPool* pool, BufferUse use,
|
||||
size_t stride, size_t count);
|
||||
void deletePoolBuffer(IGraphicsBufferPool* p, IGraphicsBufferD* buf);
|
||||
public:
|
||||
MetalDataFactory(IGraphicsContext* parent, MetalContext* ctx, uint32_t sampleCount);
|
||||
~MetalDataFactory() {}
|
||||
|
||||
Platform platform() const {return Platform::Metal;}
|
||||
const char* platformName() const {return "Metal";}
|
||||
|
||||
class Context : public IGraphicsDataFactory::Context
|
||||
{
|
||||
friend class MetalDataFactory;
|
||||
friend class MetalDataFactoryImpl;
|
||||
MetalDataFactory& m_parent;
|
||||
Context(MetalDataFactory& parent) : m_parent(parent) {}
|
||||
public:
|
||||
@@ -76,9 +50,6 @@ public:
|
||||
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||
size_t texCount, ITexture** texs, size_t baseVert = 0, size_t baseInst = 0);
|
||||
};
|
||||
|
||||
GraphicsDataToken commitTransaction(const std::function<bool(IGraphicsDataFactory::Context& ctx)>&);
|
||||
GraphicsBufferPoolToken newBufferPool();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user