@@ -62,29 +62,31 @@ inline core::smart_refctd_ptr<ICPUShader> nbl::asset::IShaderCompiler::compileTo
62
62
auto * spirvBuffer = retVal->getContent ();
63
63
size_t propsSize = LZMA_PROPS_SIZE;
64
64
size_t destLen = spirvBuffer->getSize () + spirvBuffer->getSize () / 3 + 128 ;
65
- auto compressedSpirvBuffer = core::make_smart_refctd_ptr<ICPUBuffer>(propsSize + destLen);
65
+ std::vector<unsigned char > compressedSpirv = {};
66
+ compressedSpirv.resize (propsSize + destLen);
66
67
67
68
CLzmaEncProps props;
68
69
LzmaEncProps_Init (&props);
69
- props.dictSize = 1 << 16 ; // 64 KB
70
- props.writeEndMark = 1 ; // 0 or 1
70
+ props.dictSize = 1 << 16 ; // 64KB
71
+ props.writeEndMark = 1 ;
71
72
72
73
ISzAlloc alloc = { SzAlloc, SzFree };
73
74
int res = LzmaEncode (
74
- reinterpret_cast < unsigned char *>(compressedSpirvBuffer-> getPointer () ) + LZMA_PROPS_SIZE, &destLen,
75
+ compressedSpirv. data ( ) + LZMA_PROPS_SIZE, &destLen,
75
76
reinterpret_cast <const unsigned char *>(spirvBuffer->getPointer ()), spirvBuffer->getSize (),
76
- &props, reinterpret_cast < unsigned char *>(compressedSpirvBuffer-> getPointer () ), &propsSize, props.writeEndMark ,
77
+ &props, compressedSpirv. data ( ), &propsSize, props.writeEndMark ,
77
78
nullptr , &alloc, &alloc);
78
79
79
80
assert (propsSize == LZMA_PROPS_SIZE);
80
81
assert (res == SZ_OK);
81
82
83
+ auto compressedSpirvBuffer = core::make_smart_refctd_ptr<ICPUBuffer>(propsSize + destLen);
84
+ memcpy (compressedSpirvBuffer->getPointer (), compressedSpirv.data (), compressedSpirvBuffer->getSize ());
85
+
82
86
entry.dependencies = std::move (dependencies);
83
87
entry.spirv = std::move (compressedSpirvBuffer);
84
88
entry.uncompressedSize = spirvBuffer->getSize ();
85
89
86
- std::cout << " original: " << spirvBuffer->getSize () << " , compressed: " << compressedSpirvBuffer->getSize () << " \n " ;
87
-
88
90
options.writeCache ->insert (std::move (entry));
89
91
}
90
92
return retVal;
@@ -398,7 +400,6 @@ core::smart_refctd_ptr<IShaderCompiler::CCache> IShaderCompiler::CCache::deseria
398
400
return nullptr ;
399
401
}
400
402
}
401
-
402
403
403
404
// Now retrieve two vectors, one with the entries and one with the extra data to recreate the CPUShaders
404
405
std::vector<SEntry> entries;
0 commit comments