mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 04:50:35 +00:00
Use bytebuf to serialise default library data
This commit is contained in:
committed by
Baldur Karlsson
parent
00e8c31255
commit
247e2d7d0b
@@ -50,21 +50,14 @@ WrappedMTLDevice *WrappedMTLDevice::MTLCreateSystemDefaultDevice(MTL::Device *re
|
||||
template <typename SerialiserType>
|
||||
bool WrappedMTLDevice::Serialise_newDefaultLibrary(SerialiserType &ser, WrappedMTLLibrary *library)
|
||||
{
|
||||
void *pData;
|
||||
uint32_t bytesCount;
|
||||
bytebuf buffer;
|
||||
if(ser.IsWriting())
|
||||
{
|
||||
ObjC::Get_defaultLibraryData(pData, bytesCount);
|
||||
ObjC::Get_defaultLibraryData(buffer);
|
||||
}
|
||||
|
||||
SERIALISE_ELEMENT_LOCAL(Library, GetResID(library)).TypedAs("MTLLibrary"_lit);
|
||||
SERIALISE_ELEMENT(bytesCount);
|
||||
SERIALISE_ELEMENT_ARRAY(pData, bytesCount);
|
||||
|
||||
if(ser.IsWriting())
|
||||
{
|
||||
free(pData);
|
||||
}
|
||||
SERIALISE_ELEMENT(buffer);
|
||||
|
||||
SERIALISE_CHECK_READ_ERRORS();
|
||||
|
||||
|
||||
@@ -28,5 +28,5 @@
|
||||
|
||||
namespace ObjC
|
||||
{
|
||||
void Get_defaultLibraryData(void *&pData, uint32_t &bytesCount);
|
||||
void Get_defaultLibraryData(bytebuf &buffer);
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Foundation/NSStream.h>
|
||||
|
||||
void ObjC::Get_defaultLibraryData(void *&pData, uint32_t &bytesCount)
|
||||
void ObjC::Get_defaultLibraryData(bytebuf &buffer)
|
||||
{
|
||||
NSBundle *mainAppBundle = [NSBundle mainBundle];
|
||||
NSString *defaultLibaryPath = [mainAppBundle pathForResource:@"default" ofType:@"metallib"];
|
||||
@@ -34,8 +34,7 @@ void ObjC::Get_defaultLibraryData(void *&pData, uint32_t &bytesCount)
|
||||
dispatch_data_t data = dispatch_data_create(
|
||||
myData.bytes, myData.length, dispatch_get_main_queue(), DISPATCH_DATA_DESTRUCTOR_DEFAULT);
|
||||
NSData *nsData = (NSData *)data;
|
||||
pData = malloc(nsData.length);
|
||||
memcpy(pData, nsData.bytes, nsData.length);
|
||||
bytesCount = (uint32_t)nsData.length;
|
||||
buffer.resize(nsData.length);
|
||||
memcpy(buffer.data(), nsData.bytes, buffer.size());
|
||||
dispatch_release(data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user