Integrating latest 47acbe8
This commit is contained in:
@@ -60,7 +60,7 @@ AZRequestReadStream* AZRequestReadStream::Allocate(const EStreamTaskType tSource
|
||||
//REMARK: if params->pBuffer is NOT NULL, then retReq->m_buffer
|
||||
//should become params->pBuffer, this is called stream-in-place.
|
||||
//The only reason we are not doing this here is because
|
||||
//platforms like Xenia support stream-in-place to WRITE ONLY buffers.
|
||||
//some platforms support stream-in-place to WRITE ONLY buffers.
|
||||
//Because there are no guarantees that low level streaming and decompression apis
|
||||
//would treat the output buffer as WRITE ONLY, we still allocate the buffer and memcpy
|
||||
//to params->pBuffer upon the completion callback being called.
|
||||
@@ -351,8 +351,8 @@ void AZRequestReadStream::OnRequestComplete(AZ::IO::SizeType numBytesRead, [[may
|
||||
m_isError = false;
|
||||
if (m_params.pBuffer)
|
||||
{
|
||||
//In some systems like Xenia, streaming-in-place is supported. The caveat
|
||||
//is that in Xenia's case, the destination buffer is write-only. This is why
|
||||
//In some systems, streaming-in-place is supported. The caveat
|
||||
//is that in some cases, the destination buffer is write-only. This is why
|
||||
//a final memcpy must be done here until support is added to AZ::IO::Streamer API
|
||||
//to decompress/load data into write-only buffers. SEE: LY-98089
|
||||
AZ_Assert(m_params.pBuffer != m_buffer, "Streaming-In-Place requires destination and source buffers to be different");
|
||||
|
||||
@@ -22,11 +22,6 @@
|
||||
#include <CryPath.h>
|
||||
#include <AzFramework/Archive/Archive.h>
|
||||
|
||||
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
#include "../ZipEncrypt.h"
|
||||
#endif
|
||||
|
||||
extern CMTSafeHeap* g_pPakHeap;
|
||||
|
||||
#if defined(STREAMENGINE_ENABLE_STATS)
|
||||
@@ -146,12 +141,8 @@ uint32 CAsyncIOFileRequest::ConfigureRead(AZ::IO::CCachedFileData* pFileData)
|
||||
m_crc32FromHeader = pFileEntry->desc.lCRC32;
|
||||
}
|
||||
|
||||
m_bEncryptedBuffer = false;
|
||||
|
||||
m_nPageReadCurrent = 0;
|
||||
|
||||
// FIXME later - see FIXME in DecryptBlockEntry if changing how m_bStreamInPlace is inited
|
||||
|
||||
m_bStreamInPlace = !m_bCompressedBuffer || ((!m_pExternalMemoryBuffer || !m_bWriteOnlyExternal) && (m_nFileSize > m_nFileSizeCompressed));
|
||||
m_bReadBegun = 1;
|
||||
|
||||
@@ -267,17 +258,6 @@ uint32 CAsyncIOFileRequest::AllocateOutput([[maybe_unused]] AZ::IO::CCachedFileD
|
||||
m_pDecompQueue = new SStreamJobQueue;
|
||||
}
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
if (m_bEncryptedBuffer)
|
||||
{
|
||||
m_pDecryptQueue = new SStreamJobQueue;
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
m_pDecryptionCTR = new symmetric_CTR;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
// Doesn't need to be atomic, as there's no concurrency yet.
|
||||
int nMemoryBufferUsers = 0;
|
||||
if (nReadAllocSize > 0)
|
||||
@@ -288,10 +268,6 @@ uint32 CAsyncIOFileRequest::AllocateOutput([[maybe_unused]] AZ::IO::CCachedFileD
|
||||
{
|
||||
++nMemoryBufferUsers;
|
||||
}
|
||||
if (m_bEncryptedBuffer)
|
||||
{
|
||||
++nMemoryBufferUsers;
|
||||
}
|
||||
m_nMemoryBufferUsers = nMemoryBufferUsers;
|
||||
|
||||
m_bOutputAllocated = 1;
|
||||
@@ -321,21 +297,11 @@ void CAsyncIOFileRequest::Cancel()
|
||||
{
|
||||
CryOptionalAutoLock<CryCriticalSection> readLock(m_externalBufferLockRead, m_pExternalMemoryBuffer != NULL);
|
||||
CryOptionalAutoLock<CryCriticalSection> decompLock(m_externalBufferLockDecompress, m_pExternalMemoryBuffer != NULL);
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
CryOptionalAutoLock<CryCriticalSection> decryptLock(m_externalBufferLockDecrypt, m_pExternalMemoryBuffer != NULL);
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
Failed(ERROR_USER_ABORT);
|
||||
}
|
||||
}
|
||||
|
||||
void CAsyncIOFileRequest::SyncWithDecrypt()
|
||||
{
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
m_decryptJobExecutor.reset(); // destructor waits on job completion
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
}
|
||||
|
||||
void CAsyncIOFileRequest::SyncWithDecompress()
|
||||
{
|
||||
m_decompJobExecutor.reset(); // destructor waits on job completion
|
||||
@@ -358,14 +324,6 @@ bool CAsyncIOFileRequest::TryCancel()
|
||||
m_externalBufferLockRead.Unlock();
|
||||
return false;
|
||||
}
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
if (!m_externalBufferLockDecrypt.TryLock())
|
||||
{
|
||||
m_externalBufferLockDecompress.Unlock();
|
||||
m_externalBufferLockRead.Unlock();
|
||||
return false;
|
||||
}
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
bExt = true;
|
||||
}
|
||||
|
||||
@@ -373,9 +331,6 @@ bool CAsyncIOFileRequest::TryCancel()
|
||||
|
||||
if (bExt)
|
||||
{
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
m_externalBufferLockDecrypt.Unlock();
|
||||
#endif
|
||||
m_externalBufferLockDecompress.Unlock();
|
||||
m_externalBufferLockRead.Unlock();
|
||||
}
|
||||
@@ -409,25 +364,6 @@ void CAsyncIOFileRequest::FreeBuffer()
|
||||
m_pDecompQueue = NULL;
|
||||
}
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
if (m_pDecryptQueue)
|
||||
{
|
||||
m_pDecryptQueue->Flush(tms);
|
||||
delete m_pDecryptQueue;
|
||||
m_pDecryptQueue = NULL;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
if (m_pDecryptionCTR)
|
||||
{
|
||||
ZipEncrypt::FinishStreamCipher(m_pDecryptionCTR);
|
||||
delete m_pDecryptionCTR;
|
||||
m_pDecryptionCTR = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
if (m_pMemoryBuffer)
|
||||
{
|
||||
CStreamEngine* pStreamEngine = GetStreamEngine();
|
||||
@@ -474,9 +410,6 @@ void CAsyncIOFileRequest::Flush()
|
||||
|
||||
void CAsyncIOFileRequest::Reset()
|
||||
{
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
m_decryptJobExecutor.reset(); // destructor waits on job completion
|
||||
#endif
|
||||
m_decompJobExecutor.reset(); // destructor waits on job completion
|
||||
|
||||
#ifndef _RELEASE
|
||||
@@ -490,10 +423,6 @@ void CAsyncIOFileRequest::Reset()
|
||||
m_strFileName.resize(0);
|
||||
m_pakFile.resize(0);
|
||||
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
m_decryptionCTRInitialisedAgainst = m_pakFile;
|
||||
#endif
|
||||
|
||||
// Reset POD members of the structure
|
||||
memset(&m_nSortKey, 0, ((char*)(this + 1) - (char*)&m_nSortKey));
|
||||
}
|
||||
@@ -696,7 +625,6 @@ uint32 CAsyncIOFileRequest::ReadFileInPages(CStreamingIOThread* pIOThread, CCryF
|
||||
uint32 nPageReadLen = (m_nPageReadEnd - m_nPageReadStart);
|
||||
|
||||
bool const bCompressed = m_bCompressedBuffer;
|
||||
bool const bEncrypted = m_bEncryptedBuffer;
|
||||
bool const bInPlace = m_bStreamInPlace;
|
||||
bool const bIgnoreOutOfTmp = IgnoreOutofTmpMem();
|
||||
|
||||
@@ -811,14 +739,7 @@ uint32 CAsyncIOFileRequest::ReadFileInPages(CStreamingIOThread* pIOThread, CCryF
|
||||
|
||||
bool bLastBlock = (m_nPageReadCurrent + nPageSize) == nPageReadLen;
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
if (bEncrypted)
|
||||
{
|
||||
PushDecryptPage(pStreamEngine->GetJobEngineState(), pReadTarget, pTemporaryPageHdr, nPageSize, bLastBlock);
|
||||
}
|
||||
else
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
if (bCompressed) //Spawn the decompression jobs here only if the file isn't encrypted. Encryption and Decompression are strictly linear, the decryption jobs will spawn decompression jobs as they complete.
|
||||
if (bCompressed)
|
||||
{
|
||||
PushDecompressPage(pStreamEngine->GetJobEngineState(), pReadTarget, pTemporaryPageHdr, nPageSize, bLastBlock);
|
||||
}
|
||||
|
||||
@@ -38,10 +38,6 @@ class CMTSafeHeap;
|
||||
class CAsyncIOFileRequest_TransferPtr;
|
||||
struct SStreamEngineTempMemStats;
|
||||
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION //Could check for INCLUDE_LIBTOMCRYPT here, but only decryption is implemented here, not signing
|
||||
#include "CryTomcrypt.h"
|
||||
#endif
|
||||
|
||||
#if !defined(USE_EDGE_ZLIB)
|
||||
// Prevent compilation conflicts - zconf.h (included by zlib.h) defines WINDOWS and WIN32 - those
|
||||
// definitions conflict with CryEngine's definitions.
|
||||
@@ -209,16 +205,8 @@ public:
|
||||
static void JobStart_Decompress(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState, int nSlot);
|
||||
void DecompressBlockEntry(SStreamJobEngineState engineState, int nJob);
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
uint32 PushDecryptPage(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nBytes, bool bLast);
|
||||
uint32 PushDecryptBlock(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nOffs, uint32 nBytes, bool bLast);
|
||||
static void JobStart_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState, int nSlot);
|
||||
void DecryptBlockEntry(SStreamJobEngineState engineState, int nJob);
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
void Cancel();
|
||||
bool TryCancel();
|
||||
void SyncWithDecrypt();
|
||||
void SyncWithDecompress();
|
||||
void ComputeSortKey(uint64 nCurrentKeyInProgress);
|
||||
void SetPriority(EStreamTaskPriority estp);
|
||||
@@ -237,7 +225,6 @@ private:
|
||||
|
||||
private:
|
||||
static void JobFinalize_Decompress(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState);
|
||||
static void JobFinalize_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState);
|
||||
static void JobFinalize_Transfer(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState);
|
||||
|
||||
private:
|
||||
@@ -264,23 +251,13 @@ public:
|
||||
// Cancel() must acquire both
|
||||
CryCriticalSection m_externalBufferLockRead;
|
||||
CryCriticalSection m_externalBufferLockDecompress;
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
CryCriticalSection m_externalBufferLockDecrypt;
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
CryStringLocal m_strFileName;
|
||||
string m_pakFile;
|
||||
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
string m_decryptionCTRInitialisedAgainst;
|
||||
#endif //SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
|
||||
// If request come from stream, it will be not 0.
|
||||
IReadStreamPtr m_pReadStream;
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
AZStd::unique_ptr<AZ::LegacyJobExecutor> m_decryptJobExecutor;
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
AZStd::unique_ptr<AZ::LegacyJobExecutor> m_decompJobExecutor;
|
||||
|
||||
// Only POD data should exist beyond this point - will be memsetted to 0 on Reset !
|
||||
@@ -311,7 +288,6 @@ public:
|
||||
uint32 m_nReadMemoryBufferSize;
|
||||
|
||||
uint32 m_bCompressedBuffer : 1;
|
||||
uint32 m_bEncryptedBuffer : 1;
|
||||
uint32 m_bStatsUpdated : 1;
|
||||
uint32 m_bStreamInPlace : 1;
|
||||
uint32 m_bWriteOnlyExternal : 1;
|
||||
@@ -338,7 +314,6 @@ public:
|
||||
uint32 m_nPageReadEnd;
|
||||
|
||||
volatile uint32 m_nBytesDecompressed;
|
||||
volatile uint32 m_nBytesDecrypted;
|
||||
|
||||
uint32 m_crc32FromHeader;
|
||||
|
||||
@@ -347,19 +322,12 @@ public:
|
||||
z_stream_s* m_pZlibStream;
|
||||
AZ::IO::ZipDir::UncompressLookahead* m_pLookahead;
|
||||
SStreamJobQueue* m_pDecompQueue;
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
SStreamJobQueue* m_pDecryptQueue;
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
symmetric_CTR* m_pDecryptionCTR;
|
||||
#endif //SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
|
||||
#ifdef STREAMENGINE_ENABLE_STATS
|
||||
// Time that read operation took.
|
||||
CTimeValue m_readTime;
|
||||
CTimeValue m_unzipTime;
|
||||
CTimeValue m_verifyTime;
|
||||
CTimeValue m_decryptTime;
|
||||
CTimeValue m_startTime;
|
||||
CTimeValue m_completionTime;
|
||||
|
||||
@@ -395,15 +363,11 @@ struct SStreamEngineDecompressStats
|
||||
{
|
||||
uint64 m_nTotalBytesUnziped;
|
||||
uint64 m_nTempBytesUnziped;
|
||||
uint64 m_nTotalBytesDecrypted;
|
||||
uint64 m_nTempBytesDecrypted;
|
||||
uint64 m_nTotalBytesVerified;
|
||||
uint64 m_nTempBytesVerified;
|
||||
|
||||
CTimeValue m_totalUnzipTime;
|
||||
CTimeValue m_tempUnzipTime;
|
||||
CTimeValue m_totalDecryptTime;
|
||||
CTimeValue m_tempDecryptTime;
|
||||
CTimeValue m_totalVerifyTime;
|
||||
CTimeValue m_tempVerifyTime;
|
||||
};
|
||||
|
||||
@@ -17,11 +17,6 @@
|
||||
#include <CryPath.h>
|
||||
#include "StreamAsyncFileRequest.h"
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
#include "ZipEncrypt.h"
|
||||
#include "StreamEngine.h"
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
#include "MTSafeAllocator.h"
|
||||
|
||||
namespace AZ::IO::ZipDir::ZipDirStructuresInternal
|
||||
@@ -73,32 +68,6 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
class NotifyListenerDecrypt
|
||||
: NotifyListener
|
||||
{
|
||||
public:
|
||||
NotifyListenerDecrypt(IStreamEngineListener* pL, CAsyncIOFileRequest* pReq)
|
||||
: NotifyListener(pL, pReq)
|
||||
{
|
||||
if (m_pL)
|
||||
{
|
||||
m_pL->OnStreamBeginDecrypt(m_pReq);
|
||||
m_bInProgress = true;
|
||||
}
|
||||
}
|
||||
~NotifyListenerDecrypt()
|
||||
{
|
||||
End();
|
||||
}
|
||||
void End()
|
||||
{
|
||||
if (m_bInProgress)
|
||||
{
|
||||
m_pL->OnStreamEndDecrypt(m_pReq);
|
||||
m_bInProgress = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined(STREAMENGINE_ENABLE_STATS)
|
||||
@@ -294,153 +263,6 @@ void CAsyncIOFileRequest::DecompressBlockEntry(SStreamJobEngineState engineState
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CAsyncIOFileRequest::DecryptBlockEntry(SStreamJobEngineState engineState, int nJob)
|
||||
{
|
||||
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::System);
|
||||
|
||||
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],DecryptBlockEntry,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), m_strFileName.c_str(), this, nJob);
|
||||
|
||||
SStreamJobQueue::Job& job = m_pDecryptQueue->m_jobs[nJob];
|
||||
|
||||
void* const pSrc = job.pSrc;
|
||||
SStreamPageHdr* const pSrcHdr = job.pSrcHdr;
|
||||
const uint32 nOffs = job.nOffs;
|
||||
const uint32 nBytes = job.nBytes;
|
||||
const bool bLast = job.bLast;
|
||||
const bool bFailed = HasFailed();
|
||||
const bool bCompressed = m_bCompressedBuffer;
|
||||
|
||||
CAsyncIOFileRequest_TransferPtr pSelf(this);
|
||||
|
||||
bool decryptOK = false;
|
||||
|
||||
if (!bFailed)
|
||||
{
|
||||
#if defined(STREAMENGINE_ENABLE_TIMING)
|
||||
LARGE_INTEGER liStart;
|
||||
QueryPerformanceCounter(&liStart);
|
||||
#endif
|
||||
|
||||
//printf("Inflate: %s Avail in: %d, Avail Out: %d, Next In: 0x%p, Next Out: 0x%p\n", m_strFileName.c_str(), m_pZlibStream->avail_in, m_pZlibStream->avail_out, m_pZlibStream->next_in, m_pZlibStream->next_out);
|
||||
|
||||
#ifdef STREAMENGINE_ENABLE_LISTENER
|
||||
NotifyListenerDecrypt decryptListener(gEnv->pSystem->GetStreamEngine()->GetListener(), this);
|
||||
#endif
|
||||
|
||||
unsigned long nBytesDecrypted = m_nBytesDecrypted;
|
||||
uint8_t* pData = (uint8_t*)pSrc + nOffs;
|
||||
|
||||
//if (reinterpret_cast<UINT_PTR>(m_pExternalMemoryBuffer) < 0xc0000000 || reinterpret_cast<UINT_PTR>(m_pExternalMemoryBuffer) >= 0xd0000000)
|
||||
{
|
||||
CryOptionalAutoLock<CryCriticalSection> decryptLock(m_externalBufferLockDecrypt, m_pExternalMemoryBuffer != NULL);
|
||||
|
||||
if (0)
|
||||
{
|
||||
//Intentionally empty
|
||||
}
|
||||
#ifdef SUPPORT_RSA_AND_STREAMCIPHER_PAK_ENCRYPTION
|
||||
else if (m_pDecryptionCTR)
|
||||
{
|
||||
STREAM_DECOMPRESS_TRACE ("[StreamDecrypt],ZipEncrypt::DecryptBufferWithStreamCipher,0x%x,%s,0x%p,%i,0x%p,%i,%i\n",
|
||||
CryGetCurrentThreadId(),
|
||||
m_strFileName.c_str(),
|
||||
pData,
|
||||
m_nFileSize - nBytesDecrypted,
|
||||
(uint8_t*)pSrc + nOffs,
|
||||
nBytes,
|
||||
nBytesDecrypted);
|
||||
|
||||
decryptOK = ZipEncrypt::DecryptBufferWithStreamCipher(
|
||||
pData, //In
|
||||
pData, //Out - same = decrypt in place
|
||||
nBytes,
|
||||
m_pDecryptionCTR);
|
||||
nBytesDecrypted += decryptOK ? nBytes : 0;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
//Should never get here, this should have been checked in the prep functions
|
||||
CryFatalError("Invalid encryption technique in streaming engine");
|
||||
}
|
||||
}
|
||||
|
||||
m_nBytesDecrypted = nBytesDecrypted;
|
||||
|
||||
//inform listen, so aysnc callback does not overlap
|
||||
#ifdef STREAMENGINE_ENABLE_LISTENER
|
||||
decryptListener.End();
|
||||
#endif
|
||||
|
||||
if (decryptOK)
|
||||
{
|
||||
#if defined(STREAMENGINE_ENABLE_TIMING)
|
||||
LARGE_INTEGER liEnd, liFreq;
|
||||
QueryPerformanceCounter(&liEnd);
|
||||
QueryPerformanceFrequency(&liFreq);
|
||||
|
||||
m_decryptTime += CTimeValue((int64)((liEnd.QuadPart - liStart.QuadPart) * CTimeValue::TIMEVALUE_PRECISION / liFreq.QuadPart));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CryWarning(VALIDATOR_MODULE_SYSTEM, VALIDATOR_ERROR_DBGBRK, "Decrypt Error: %s\n", m_strFileName.c_str());
|
||||
Failed(ERROR_DECRYPTION_FAIL);
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME later - if we end up here with a uncompressed request, that is not in-place, this won't copy
|
||||
// to the output. Not currently an issue given how ConfigureRead sets up m_bStreamInPlace, but may be in
|
||||
// future.
|
||||
|
||||
if (!decryptOK || !bCompressed) // Inverse of push condition below
|
||||
{
|
||||
if (pSrcHdr)
|
||||
{
|
||||
if (CryInterlockedDecrement(&pSrcHdr->nRefs) == 0)
|
||||
{
|
||||
engineState.pTempMem->TempFree(engineState.pHeap, pSrc, pSrcHdr->nSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int nPopSlot = m_pDecryptQueue->Pop();
|
||||
|
||||
// job is no longer valid
|
||||
|
||||
if (decryptOK && bCompressed)
|
||||
{
|
||||
PushDecompressBlock(engineState, pSrc, pSrcHdr, nOffs, nBytes, bLast);
|
||||
|
||||
if (pSrcHdr)
|
||||
{
|
||||
if (CryInterlockedDecrement(&pSrcHdr->nRefs) == 0)
|
||||
{
|
||||
engineState.pTempMem->TempFree(engineState.pHeap, pSrc, pSrcHdr->nSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (HasFailed() || bLast)
|
||||
{
|
||||
JobFinalize_Decrypt(pSelf, engineState);
|
||||
}
|
||||
else if (nPopSlot >= 0)
|
||||
{
|
||||
// Chain start the next job, we're responsible for it.
|
||||
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],Chaining,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), m_strFileName.c_str(), this, nPopSlot);
|
||||
|
||||
JobStart_Decrypt(pSelf, engineState, nPopSlot);
|
||||
}
|
||||
|
||||
#if defined(STREAMENGINE_ENABLE_STATS)
|
||||
CryInterlockedDecrement(&engineState.pStats->nCurrentDecryptCount);
|
||||
#endif
|
||||
}
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint32 CAsyncIOFileRequest::PushDecompressPage(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nBytes, bool bLast)
|
||||
@@ -502,71 +324,10 @@ void CAsyncIOFileRequest::JobStart_Decompress(CAsyncIOFileRequest_TransferPtr& p
|
||||
}); // Legacy JobManager priority: eStreamPriority
|
||||
}
|
||||
|
||||
#if defined(STREAMENGINE_SUPPORT_DECRYPT)
|
||||
uint32 CAsyncIOFileRequest::PushDecryptPage(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nBytes, bool bLast)
|
||||
{
|
||||
uint32 nError = 0;
|
||||
|
||||
for (uint32 nBlockPos = 0; !nError && (nBlockPos < nBytes); nBlockPos += STREAMING_BLOCK_SIZE)
|
||||
{
|
||||
bool bLastBlock = (nBlockPos + STREAMING_BLOCK_SIZE) >= nBytes;
|
||||
uint32 nBlockSize = min(nBytes - nBlockPos, (uint32)STREAMING_BLOCK_SIZE);
|
||||
|
||||
nError = PushDecryptBlock(engineState, pSrc, pSrcHdr, nBlockPos, nBlockSize, bLast && bLastBlock);
|
||||
}
|
||||
|
||||
return nError;
|
||||
}
|
||||
|
||||
uint32 CAsyncIOFileRequest::PushDecryptBlock(const SStreamJobEngineState& engineState, void* pSrc, SStreamPageHdr* pSrcHdr, uint32 nOffs, uint32 nBytes, bool bLast)
|
||||
{
|
||||
uint32 nError = m_nError;
|
||||
|
||||
if (!nError)
|
||||
{
|
||||
if (pSrcHdr)
|
||||
{
|
||||
CryInterlockedIncrement(&pSrcHdr->nRefs);
|
||||
}
|
||||
|
||||
int nPushJob = m_pDecryptQueue->Push(pSrc, pSrcHdr, nOffs, nBytes, bLast);
|
||||
if (nPushJob >= 0)
|
||||
{
|
||||
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],PushDecryptBlock,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), m_strFileName.c_str(), this, nPushJob);
|
||||
|
||||
AddRef();
|
||||
CAsyncIOFileRequest_TransferPtr pSelf(this);
|
||||
JobStart_Decrypt(pSelf, engineState, nPushJob);
|
||||
}
|
||||
}
|
||||
|
||||
return nError;
|
||||
}
|
||||
|
||||
void CAsyncIOFileRequest::JobStart_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState, int nJob)
|
||||
{
|
||||
STREAM_DECOMPRESS_TRACE("[StreamDecrypt],QueueDecryptBlockAppend,0x%x,%s,0x%p,%i\n", CryGetCurrentThreadId(), pSelf->m_strFileName.c_str(), &pSelf, nJob);
|
||||
|
||||
#if defined(STREAMENGINE_ENABLE_STATS)
|
||||
CryInterlockedIncrement(&engineState.pStats->nCurrentDecryptCount);
|
||||
#endif
|
||||
|
||||
CAsyncIOFileRequest* request = pSelf.Relinquish();
|
||||
if (!request->m_decryptJobExecutor)
|
||||
{
|
||||
request->m_decryptJobExecutor = AZStd::make_unique<AZ::LegacyJobExecutor>();
|
||||
}
|
||||
request->m_decryptJobExecutor->StartJob([request, engineState, nJob]()
|
||||
{
|
||||
request->DecryptBlockEntry(engineState, nJob);
|
||||
}); // Legacy JobManager priority: eStreamPriority
|
||||
}
|
||||
#endif //STREAMENGINE_SUPPORT_DECRYPT
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CAsyncIOFileRequest::JobFinalize_Read(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState)
|
||||
{
|
||||
if ((!pSelf->m_bCompressedBuffer && !pSelf->m_bEncryptedBuffer) || pSelf->HasFailed())
|
||||
if (!pSelf->m_bCompressedBuffer || pSelf->HasFailed())
|
||||
{
|
||||
JobFinalize_Transfer(pSelf, engineState);
|
||||
}
|
||||
@@ -608,39 +369,6 @@ void CAsyncIOFileRequest::JobFinalize_Decompress(CAsyncIOFileRequest_TransferPtr
|
||||
JobFinalize_Transfer(pSelf, engineState);
|
||||
}
|
||||
|
||||
void CAsyncIOFileRequest::JobFinalize_Decrypt(CAsyncIOFileRequest_TransferPtr& pSelf, const SStreamJobEngineState& engineState)
|
||||
{
|
||||
STREAM_DECOMPRESS_TRACE("[StreamDecompress],FinalizeDecompress,0x%x,%s,0x%p,0x%p,0x%p,0x%p\n", CryGetCurrentThreadId(), pSelf->m_strFileName.c_str(), &pSelf, &engineState, engineState.pStats, engineState.pDecompressStats);
|
||||
|
||||
CAsyncIOFileRequest* pReq = &*pSelf;
|
||||
|
||||
const bool bCompressed = pReq->m_bCompressedBuffer;
|
||||
const bool bFailed = pReq->HasFailed();
|
||||
|
||||
if (!bCompressed && !bFailed)
|
||||
{
|
||||
pReq->JobFinalize_Validate(engineState);
|
||||
}
|
||||
|
||||
pReq->JobFinalize_Buffer(engineState);
|
||||
|
||||
#if defined(STREAMENGINE_ENABLE_STATS) && defined(STREAMENGINE_ENABLE_TIMING)
|
||||
if (pReq->m_decryptTime.GetValue() != 0)
|
||||
{
|
||||
engineState.pDecompressStats->m_nTotalBytesDecrypted += pReq->m_nFileSize;
|
||||
engineState.pDecompressStats->m_totalDecryptTime += pReq->m_decryptTime;
|
||||
|
||||
engineState.pDecompressStats->m_nTempBytesDecrypted += pReq->m_nFileSize;
|
||||
engineState.pDecompressStats->m_tempDecryptTime += pReq->m_decryptTime;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!bCompressed || pReq->HasFailed())
|
||||
{
|
||||
JobFinalize_Transfer(pSelf, engineState);
|
||||
}
|
||||
}
|
||||
|
||||
void CAsyncIOFileRequest::JobFinalize_Buffer(const SStreamJobEngineState& engineState)
|
||||
{
|
||||
if (CryInterlockedDecrement(&m_nMemoryBufferUsers) == 0)
|
||||
|
||||
@@ -58,7 +58,6 @@ CStreamEngine::CStreamEngine()
|
||||
m_Statistics.nPendingReadBytes = 0;
|
||||
|
||||
m_Statistics.nCurrentAsyncCount = 0;
|
||||
m_Statistics.nCurrentDecryptCount = 0;
|
||||
m_Statistics.nCurrentDecompressCount = 0;
|
||||
m_Statistics.nCurrentFinishedCount = 0;
|
||||
|
||||
@@ -548,13 +547,10 @@ void CStreamEngine::Update()
|
||||
{
|
||||
// Repeat every second.
|
||||
m_nUnzipBandwidth = m_decompressStats.m_tempUnzipTime.GetValue() == 0 ? 0 : (uint32)(m_decompressStats.m_nTempBytesUnziped / m_decompressStats.m_tempUnzipTime.GetSeconds());
|
||||
m_nDecryptBandwidth = m_decompressStats.m_tempDecryptTime.GetValue() == 0 ? 0 : (uint32)(m_decompressStats.m_nTempBytesDecrypted / m_decompressStats.m_tempDecryptTime.GetSeconds());
|
||||
m_nVerifyBandwidth = m_decompressStats.m_tempVerifyTime.GetValue() == 0 ? 0 : (uint32)(m_decompressStats.m_nTempBytesVerified / m_decompressStats.m_tempVerifyTime.GetSeconds());
|
||||
|
||||
m_decompressStats.m_tempUnzipTime.SetValue(0);
|
||||
m_decompressStats.m_nTempBytesUnziped = 0;
|
||||
m_decompressStats.m_tempDecryptTime.SetValue(0);
|
||||
m_decompressStats.m_nTempBytesDecrypted = 0;
|
||||
m_decompressStats.m_tempVerifyTime.SetValue(0);
|
||||
m_decompressStats.m_nTempBytesVerified = 0;
|
||||
|
||||
@@ -564,20 +560,14 @@ void CStreamEngine::Update()
|
||||
{
|
||||
m_nUnzipBandwidthAverage = (uint32)(m_decompressStats.m_nTotalBytesUnziped / m_decompressStats.m_totalUnzipTime.GetSeconds());
|
||||
}
|
||||
if (m_decompressStats.m_totalDecryptTime.GetValue() != 0)
|
||||
{
|
||||
m_nDecryptBandwidthAverage = (uint32)(m_decompressStats.m_nTotalBytesDecrypted / m_decompressStats.m_totalDecryptTime.GetSeconds());
|
||||
}
|
||||
if (m_decompressStats.m_totalVerifyTime.GetValue() != 0)
|
||||
{
|
||||
m_nVerifyBandwidthAverage = (uint32)(m_decompressStats.m_nTotalBytesVerified / m_decompressStats.m_totalVerifyTime.GetSeconds());
|
||||
}
|
||||
|
||||
m_Statistics.nDecompressBandwidth = m_nUnzipBandwidth;
|
||||
m_Statistics.nDecryptBandwidth = m_nDecryptBandwidth;
|
||||
m_Statistics.nVerifyBandwidth = m_nVerifyBandwidth;
|
||||
m_Statistics.nDecompressBandwidthAverage = m_nUnzipBandwidthAverage;
|
||||
m_Statistics.nDecryptBandwidthAverage = m_nDecryptBandwidthAverage;
|
||||
m_Statistics.nVerifyBandwidthAverage = m_nVerifyBandwidthAverage;
|
||||
|
||||
CTimeValue currentTime = gEnv->pTimer->GetAsyncTime();
|
||||
@@ -1388,14 +1378,14 @@ void CStreamEngine::DrawStatistics()
|
||||
|
||||
const char* sMediaType = m_bStreamDataOnHDD ? "HDD" : "DVD";
|
||||
const char* sStatus = (m_bStreamingStatsPaused) ? "Paused" : "";
|
||||
DrawText(tx, ty += ystep, clText, "Streaming IO: %.2f|%.2fMB/s, ACT: %3dmsec, Unzip: %.2fMB/s, Decrypt: %.2fMB/s, Verify: %.2fMB/s, Jobs:%5d (%4d) %s %s",
|
||||
DrawText(tx, ty += ystep, clText, "Streaming IO: %.2f|%.2fMB/s, ACT: %3dmsec, Unzip: %.2fMB/s, Verify: %.2fMB/s, Jobs:%5d (%4d) %s %s",
|
||||
(float)stats.nTotalCurrentReadBandwidth / (1024 * 1024), (float)stats.nTotalSessionReadBandwidth / (1024 * 1024),
|
||||
(uint32)stats.fAverageCompletionTime, (float)stats.nDecompressBandwidth / (1024 * 1024), (float)stats.nDecryptBandwidth / (1024 * 1024), (float)stats.nVerifyBandwidth / (1024 * 1024),
|
||||
(uint32)stats.fAverageCompletionTime, (float)stats.nDecompressBandwidth / (1024 * 1024), (float)stats.nVerifyBandwidth / (1024 * 1024),
|
||||
(uint32)stats.nTotalStreamingRequestCount, (uint32)(stats.nTotalRequestCount - stats.nTotalStreamingRequestCount),
|
||||
sMediaType, sStatus);
|
||||
|
||||
DrawText(tx, ty += ystep, clText, "\t Request: Active:%2d (%2.1fMB) Live:%2d Decrypt:%2d Decompress:%2d Async:%2d Finished:%2d Temp Pool Max:%2.1fMB", openStats.nOpenRequestCount,
|
||||
(float)stats.nPendingReadBytes / (1024 * 1024), CAsyncIOFileRequest::s_nLiveRequests, stats.nCurrentDecryptCount, stats.nCurrentDecompressCount, stats.nCurrentAsyncCount, stats.nCurrentFinishedCount,
|
||||
DrawText(tx, ty += ystep, clText, "\t Request: Active:%2d (%2.1fMB) Live:%2d Decompress:%2d Async:%2d Finished:%2d Temp Pool Max:%2.1fMB", openStats.nOpenRequestCount,
|
||||
(float)stats.nPendingReadBytes / (1024 * 1024), CAsyncIOFileRequest::s_nLiveRequests, stats.nCurrentDecompressCount, stats.nCurrentAsyncCount, stats.nCurrentFinishedCount,
|
||||
(float)stats.nMaxTempMemory / (1024 * 1024));
|
||||
|
||||
ty += ystep;
|
||||
@@ -1577,10 +1567,8 @@ void CStreamEngine::ClearStatistics()
|
||||
m_PerExtensionInfo.clear();
|
||||
|
||||
m_Statistics.nDecompressBandwidth = 0;
|
||||
m_Statistics.nDecryptBandwidth = 0;
|
||||
m_Statistics.nVerifyBandwidth = 0;
|
||||
m_Statistics.nDecompressBandwidthAverage = 0;
|
||||
m_Statistics.nDecryptBandwidthAverage = 0;
|
||||
m_Statistics.nVerifyBandwidthAverage = 0;
|
||||
|
||||
m_Statistics.nTotalBytesRead = 0;
|
||||
|
||||
@@ -213,11 +213,9 @@ private:
|
||||
TExtensionInfoMap m_PerExtensionInfo;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Used to calculate unzip/decrypt/verify bandwidth for statistics.
|
||||
// Used to calculate unzip/verify bandwidth for statistics.
|
||||
uint32 m_nUnzipBandwidth;
|
||||
uint32 m_nUnzipBandwidthAverage;
|
||||
uint32 m_nDecryptBandwidth;
|
||||
uint32 m_nDecryptBandwidthAverage;
|
||||
uint32 m_nVerifyBandwidth;
|
||||
uint32 m_nVerifyBandwidthAverage;
|
||||
CTimeValue m_nLastBandwidthUpdateTime;
|
||||
|
||||
@@ -343,7 +343,6 @@ void CStreamingIOThread::Run()
|
||||
break;
|
||||
|
||||
default:
|
||||
pFileRequest->SyncWithDecrypt();
|
||||
pFileRequest->SyncWithDecompress();
|
||||
pFileRequest->Failed(nError);
|
||||
|
||||
|
||||
@@ -433,7 +433,6 @@ void CReadStream::FreeTemporaryMemory()
|
||||
if (m_pFileRequest)
|
||||
{
|
||||
m_pFileRequest->SyncWithDecompress();
|
||||
m_pFileRequest->SyncWithDecrypt();
|
||||
m_pFileRequest->FreeBuffer();
|
||||
}
|
||||
m_pBuffer = 0;
|
||||
|
||||
Reference in New Issue
Block a user