<commit_before>//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

#include "stdafx.h"
#include "PSOLibrary.h"

using namespace Microsoft::WRL::Wrappers;

PSOLibrary::PSOLibrary(UINT frameCount, UINT cbvRootSignatureIndex) :
	m_cbvRootSignatureIndex(cbvRootSignatureIndex),
	m_maxDrawsPerFrame(256),
	m_dynamicCB(sizeof(UberShaderConstantBuffer), m_maxDrawsPerFrame, frameCount),
	m_flagsMutex(),
	m_useUberShaders(true),
	m_useDiskLibraries(true),
	m_drawIndex(0)
{
	ZeroMemory(m_compiledPSOFlags, sizeof(m_compiledPSOFlags));
	ZeroMemory(m_inflightPSOFlags, sizeof(m_inflightPSOFlags));
	ZeroMemory(m_workerThreads, sizeof(m_workerThreads));

	WCHAR path[512];
	GetAssetsPath(path, _countof(path));
	m_assetsPath = path;

	m_flagsMutex = CreateMutex(nullptr, FALSE, nullptr);
}

PSOLibrary::~PSOLibrary()
{
	WaitForThreads();

	for (UINT i = 0; i < EffectPipelineTypeCount; i++)
	{
		m_diskCaches[i].Destroy(false);
	}
}

void PSOLibrary::WaitForThreads()
{
	for (auto& thread : m_workerThreads)
	{
		if (thread.threadHandle)
		{
			WaitForSingleObject(thread.threadHandle, INFINITE);
			CloseHandle(thread.threadHandle);
		}
		thread.threadHandle = nullptr;<commit_msg>The UWP pipeline state cache sample must use a storage location accessible to UWP apps in order to successfully create the cache files.<commit_after>//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************

#include "stdafx.h"
#include "PSOLibrary.h"

using namespace Microsoft::WRL::Wrappers;

PSOLibrary::PSOLibrary(UINT frameCount, UINT cbvRootSignatureIndex) :
	m_cbvRootSignatureIndex(cbvRootSignatureIndex),
	m_maxDrawsPerFrame(256),
	m_dynamicCB(sizeof(UberShaderConstantBuffer), m_maxDrawsPerFrame, frameCount),
	m_flagsMutex(),
	m_useUberShaders(true),
	m_useDiskLibraries(true),
	m_drawIndex(0)
{
	ZeroMemory(m_compiledPSOFlags, sizeof(m_compiledPSOFlags));
	ZeroMemory(m_inflightPSOFlags, sizeof(m_inflightPSOFlags));
	ZeroMemory(m_workerThreads, sizeof(m_workerThreads));

	m_assetsPath = Windows::Storage::ApplicationData::Current->LocalCacheFolder->Path->Data();
	m_assetsPath += L"\\";

	m_flagsMutex = CreateMutex(nullptr, FALSE, nullptr);
}

PSOLibrary::~PSOLibrary()
{
	WaitForThreads();

	for (UINT i = 0; i < EffectPipelineTypeCount; i++)
	{
		m_diskCaches[i].Destroy(false);
	}
}

void PSOLibrary::WaitForThreads()
{
	for (auto& thread : m_workerThreads)
	{
		if (thread.threadHandle)
		{
			WaitForSingleObject(thread.threadHandle, INFINITE);
			CloseHandle(thread.threadHandle);
		}
		thread.threadHandle = nullptr;
{'fraction_non_alphanumeric': 0.17806963958460598, 'fraction_numerical': 0.003970678069639585, 'mean_word_length': 6.528735632183908, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '368558', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1036, 'n_words': 225}