@@ -62,29 +62,31 @@ inline core::smart_refctd_ptr<ICPUShader> nbl::asset::IShaderCompiler::compileTo
6262 auto * spirvBuffer = retVal->getContent ();
6363 size_t propsSize = LZMA_PROPS_SIZE;
6464 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);
6667
6768 CLzmaEncProps props;
6869 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 ;
7172
7273 ISzAlloc alloc = { SzAlloc, SzFree };
7374 int res = LzmaEncode (
74- reinterpret_cast < unsigned char *>(compressedSpirvBuffer-> getPointer () ) + LZMA_PROPS_SIZE, &destLen,
75+ compressedSpirv. data ( ) + LZMA_PROPS_SIZE, &destLen,
7576 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 ,
7778 nullptr , &alloc, &alloc);
7879
7980 assert (propsSize == LZMA_PROPS_SIZE);
8081 assert (res == SZ_OK);
8182
83+ auto compressedSpirvBuffer = core::make_smart_refctd_ptr<ICPUBuffer>(propsSize + destLen);
84+ memcpy (compressedSpirvBuffer->getPointer (), compressedSpirv.data (), compressedSpirvBuffer->getSize ());
85+
8286 entry.dependencies = std::move (dependencies);
8387 entry.spirv = std::move (compressedSpirvBuffer);
8488 entry.uncompressedSize = spirvBuffer->getSize ();
8589
86- std::cout << " original: " << spirvBuffer->getSize () << " , compressed: " << compressedSpirvBuffer->getSize () << " \n " ;
87-
8890 options.writeCache ->insert (std::move (entry));
8991 }
9092 return retVal;
@@ -398,7 +400,6 @@ core::smart_refctd_ptr<IShaderCompiler::CCache> IShaderCompiler::CCache::deseria
398400 return nullptr ;
399401 }
400402 }
401-
402403
403404 // Now retrieve two vectors, one with the entries and one with the extra data to recreate the CPUShaders
404405 std::vector<SEntry> entries;
0 commit comments