Skip to content

Commit f3bf2b6

Browse files
MikhailGorobetsTheMostDiligent
authored andcommitted
IEngineFactory: Added CreateDataBlob method (close #391)
1 parent 9d5fd45 commit f3bf2b6

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Graphics/GraphicsEngine/include/EngineFactoryBase.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "Object.h"
3434
#include "EngineFactory.h"
35+
#include "DataBlobImpl.hpp"
3536
#include "DefaultShaderSourceStreamFactory.h"
3637
#include "Dearchiver.h"
3738
#include "DummyReferenceCounters.hpp"
@@ -98,6 +99,12 @@ class EngineFactoryBase : public BaseInterface
9899
return Diligent::GetAPIInfo();
99100
}
100101

102+
virtual void DILIGENT_CALL_TYPE CreateDataBlob(size_t InitialSize, const void* pData, IDataBlob** ppDataBlob) const override final
103+
{
104+
if (auto pDataBlob = DataBlobImpl::Create(InitialSize, pData))
105+
pDataBlob->QueryInterface(IID_DataBlob, reinterpret_cast<IObject**>(ppDataBlob));
106+
}
107+
101108
virtual void DILIGENT_CALL_TYPE CreateDefaultShaderSourceStreamFactory(const Char* SearchDirectories,
102109
IShaderSourceInputStreamFactory** ppShaderSourceFactory) const override final
103110
{

Graphics/GraphicsEngine/interface/EngineFactory.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "../../../Primitives/interface/Object.h"
3434
#include "../../../Primitives/interface/DebugOutput.h"
35+
#include "../../../Primitives/interface/DataBlob.h"
3536
#include "GraphicsTypes.h"
3637

3738

@@ -82,6 +83,17 @@ DILIGENT_BEGIN_INTERFACE(IEngineFactory, IObject)
8283
const Char* SearchDirectories,
8384
struct IShaderSourceInputStreamFactory** ppShaderSourceFactory) CONST PURE;
8485

86+
/// Creates a data blob.
87+
88+
/// \param [in] InitialSize - The size of the internal data buffer.
89+
/// \param [in] pData - Pointer to the data to write to the internal buffer.
90+
/// If null, no data will be written.
91+
/// \param [out] ppDataBlob - Memory address where the pointer to the data blob will be written.
92+
VIRTUAL void METHOD(CreateDataBlob)(THIS_
93+
size_t InitialSize,
94+
const void* pData,
95+
IDataBlob** ppDataBlob) CONST PURE;
96+
8597
/// Enumerates adapters available on this machine.
8698

8799
/// \param [in] MinVersion - Minimum required API version (feature level for Direct3D).
@@ -147,6 +159,7 @@ DILIGENT_END_INTERFACE
147159

148160
# define IEngineFactory_GetAPIInfo(This) CALL_IFACE_METHOD(EngineFactory, GetAPIInfo, This)
149161
# define IEngineFactory_CreateDefaultShaderSourceStreamFactory(This, ...) CALL_IFACE_METHOD(EngineFactory, CreateDefaultShaderSourceStreamFactory, This, __VA_ARGS__)
162+
# define IEngineFactory_CreateDataBlob(This, ...) CALL_IFACE_METHOD(EngineFactory, CreateDataBlob, This, __VA_ARGS__)
150163
# define IEngineFactory_EnumerateAdapters(This, ...) CALL_IFACE_METHOD(EngineFactory, EnumerateAdapters, This, __VA_ARGS__)
151164
# define IEngineFactory_InitAndroidFileSystem(This, ...) CALL_IFACE_METHOD(EngineFactory, InitAndroidFileSystem, This, __VA_ARGS__)
152165
# define IEngineFactory_CreateDearchiver(This, ...) CALL_IFACE_METHOD(EngineFactory, CreateDearchiver, This, __VA_ARGS__)

Tests/IncludeTest/GraphicsEngine/EngineFactoryH_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ void TestEngineFactortCInterface(struct IEngineFactory* pFactory)
3535
struct IShaderSourceInputStreamFactory* pShaderFactory = NULL;
3636
IEngineFactory_CreateDefaultShaderSourceStreamFactory(pFactory, "directories", &pShaderFactory);
3737

38+
struct IDataBlob* pDataBlob = NULL;
39+
IEngineFactory_CreateDataBlob(pFactory, 1024, NULL, &pDataBlob);
40+
3841
struct Version MinVersion = {0, 0};
3942
IEngineFactory_EnumerateAdapters(pFactory, MinVersion, (Uint32*)NULL, (struct GraphicsAdapterInfo*)NULL);
4043

0 commit comments

Comments
 (0)