Skip to content

Commit

Permalink
Updated samples for the 2210 GDK release. (#16)
Browse files Browse the repository at this point in the history
* Updated samples for the 2210 GDK release.

* Moved samples list to the wiki.

* Updated readme to use wiki links for samples list.
  • Loading branch information
scm-xbox authored Nov 3, 2022
1 parent db9c945 commit aa45b83
Show file tree
Hide file tree
Showing 757 changed files with 32,150 additions and 10,973 deletions.
14 changes: 8 additions & 6 deletions Kits/ATGTK/ControllerHelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,8 @@ void ATG::Help::RestoreDevice(ID3D11DeviceContext* context)
);
}

const DDS_LOADER_FLAGS loadFlags = m_linearColors ? DDS_LOADER_FORCE_SRGB : DDS_LOADER_DEFAULT;

#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
wchar_t buff[MAX_PATH];
DX::FindMediaFile(buff, MAX_PATH, L"SegoeUI_18.spritefont");
Expand All @@ -986,21 +988,21 @@ void ATG::Help::RestoreDevice(ID3D11DeviceContext* context)
m_spriteFonts[SEGOE_UI_36PT] = std::make_unique<SpriteFont>(device.Get(), buff);

DX::FindMediaFile(buff, MAX_PATH, L"callout_circle.dds");
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), buff, 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, m_linearColors, nullptr, m_circleTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), buff, 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, loadFlags, nullptr, m_circleTex.ReleaseAndGetAddressOf()));

DX::FindMediaFile(buff, MAX_PATH, L"gamepad.dds");
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), buff, 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, m_linearColors, nullptr, m_gamepadTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), buff, 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, loadFlags, nullptr, m_gamepadTex.ReleaseAndGetAddressOf()));

DX::FindMediaFile(buff, MAX_PATH, L"ATGSampleBackground.DDS");
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), buff, 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, m_linearColors, nullptr, m_backgroundTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), buff, 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, loadFlags, nullptr, m_backgroundTex.ReleaseAndGetAddressOf()));
#else
m_spriteFonts[SEGOE_UI_18PT] = std::make_unique<SpriteFont>(device.Get(), L"SegoeUI_18.spritefont");
m_spriteFonts[SEGOE_UI_22PT] = std::make_unique<SpriteFont>(device.Get(), L"SegoeUI_22.spritefont");
m_spriteFonts[SEGOE_UI_36PT] = std::make_unique<SpriteFont>(device.Get(), L"SegoeUI_36.spritefont");

DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), L"callout_circle.dds", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, m_linearColors, nullptr, m_circleTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), L"gamepad.dds", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, m_linearColors, nullptr, m_gamepadTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), L"ATGSampleBackground.DDS", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, m_linearColors, nullptr, m_backgroundTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), L"callout_circle.dds", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, loadFlags, nullptr, m_circleTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), L"gamepad.dds", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, loadFlags, nullptr, m_gamepadTex.ReleaseAndGetAddressOf()));
DX::ThrowIfFailed(CreateDDSTextureFromFileEx(device.Get(), L"ATGSampleBackground.DDS", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, 0, loadFlags, nullptr, m_backgroundTex.ReleaseAndGetAddressOf()));
#endif
}
#endif
Expand Down
15 changes: 7 additions & 8 deletions Kits/ATGTK/FrontPanel/FrontPanelDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ namespace

namespace DirectX
{
namespace Internal
inline namespace DX12
{
// Reuse the WIC factory function from the DirectX Tool Kit. For implementation details, see WICTextureLoader.cpp
#if defined(__d3d12_x_h__) || defined(__XBOX_D3D12_X__)
extern IWICImagingFactory2* GetWIC();
#else
extern IWICImagingFactory* GetWIC();
#endif
namespace Internal
{
// Reuse the WIC factory function from the DirectX Tool Kit. For implementation details, see WICTextureLoader.cpp
extern IWICImagingFactory2* GetWIC();
}
}
}

using namespace DirectX::Internal;
using namespace DirectX::DX12::Internal;

// --------------------------------------------------------------------------------
// FrontPanelDisplay methods
Expand Down
77 changes: 43 additions & 34 deletions Kits/ATGTK/Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <sysinfoapi.h>
#undef max
#undef min
#include "intrin.h"

#if defined(_GAMING_XBOX)
#include <xsystem.h>
Expand All @@ -41,7 +40,7 @@ namespace
std::wstring g_processorName; // The general processor name. This can be changed by the user to allow easier usage in their code
std::wstring g_trueProcessorName; // The actual name of the processor as returned by the OS
uint64_t g_processMask = 0; // In general all the cores that exist on the processor, when >64 this will be bound to the group the process is assigned to
std::vector<uint32_t> g_numLogicalCores; // How many logical cores exist, if not hyperthreaded == number of physical cores
std::vector<uint32_t> g_numLogicalCores; // How many logical cores exist, if SMT is not supported == number of physical cores
std::vector<uint64_t> g_availableCoresMask; // Which cores are actually available to the caller, for example ERA does not allow the 8th core to be used, index is groupID

#if !defined(_XBOX_ONE) // we don't use this on ERA because GetLogicalProcessorInfoEx and GetLogicalProcessorInformation is not supported
Expand All @@ -65,7 +64,7 @@ namespace

SYSTEM_INFO g_systemInfo; // Cached copy of data from GetSystemInfo
std::vector<ATG::UniqueProcessorMask> g_topLevelCacheMask; // For each top level cache the mask of cores that share id. This tends to be processors that have several internal clusters, for example Durango has two clusters
std::map<ATG::ProcessorGroupID, std::vector<std::pair<bool, uint64_t>>> g_physicalCores; // For each physical core a mask of the logical cores that map to that physical core and a flag for whether it's hyperthreaded
std::map<ATG::ProcessorGroupID, std::vector<std::pair<bool, uint64_t>>> g_physicalCores; // For each physical core a mask of the logical cores that map to that physical core and a flag for whether it has support for SMT
std::vector <ATG::CacheInformation> g_caches; // A list of each cache present on the processor, L1, L2, L3, Instruction, Data, and Trace (haven't seen this on any processor yet)
double g_rdtscpFrequencySeconds; // The frequency in seconds of the __rdtscp, measured automatically at startup

Expand Down Expand Up @@ -315,15 +314,32 @@ void ATG::GetCacheInformation(const UniqueProcessorMask& coreMask, std::vector<C
}
}

uint32_t ATG::GetProcessorFamily()
{
int CPUInfo[4] = { -1 };
#ifdef __clang__
__cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]);
#else
__cpuid(CPUInfo, 1);
#endif

return static_cast<uint32_t> (((CPUInfo[0] & 0xf00) >> 8) + ((CPUInfo[0] & 0x0ff00000) >> 20));
}

bool ATG::SetupProcessorData()
{
if (g_trueProcessorName.size())
return true;

#if !defined(_XBOX_ONE) && !defined(_GAMING_XBOX) // Xbox doesn't have this registry entry
g_osProcessorInfo.bufferSize = 0;
g_osProcessorInfo.rawData = nullptr;
wchar_t processorName[256] = {};
DWORD dataSize = sizeof(wchar_t) * 256;
RegGetValueW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", L"ProcessorNameString", RRF_RT_REG_SZ, nullptr, processorName, &dataSize);
g_trueProcessorName = processorName;
{
wchar_t processorName[256];
DWORD dataSize = sizeof(wchar_t) * 256;
RegGetValueW(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", L"ProcessorNameString", RRF_RT_REG_SZ, nullptr, processorName, &dataSize);
g_trueProcessorName = processorName;
}
#elif defined(_GAMING_XBOX)
XSystemDeviceType info;
info = XSystemGetDeviceType();
Expand Down Expand Up @@ -410,7 +426,7 @@ bool ATG::SetupProcessorData()
ParseOSProcessorInfo();

#if defined(_GAMING_XBOX)
if (ATG::IsHyperThreaded())
if (ATG::IsSMTSupported())
g_trueProcessorName += L"_SMT";
g_processorName = g_trueProcessorName;
#endif
Expand Down Expand Up @@ -500,7 +516,7 @@ void ATG::LogProcessorInfo(const std::wstring& logName)
swprintf_s(buffer, 256, L"%s_procInfo", g_trueProcessorName.c_str());
fileName = buffer;
}
ATG::FileLogger procLog(fileName, false);
ATG::FileLogger procLog(fileName, false, false, false, true, true);

#if !defined(_GAMING_XBOX)
wchar_t buffer[256];
Expand Down Expand Up @@ -531,7 +547,7 @@ void ATG::LogProcessorInfo(const std::wstring& logName)
case RelationProcessorCore:
procLog.Log(L"Processor Core");
if (procInfo->Processor.Flags == LTP_PC_SMT)
procLog.Log(L" Core is hyper threaded");
procLog.Log(L" Core supports SMT");
if (procInfo->Processor.EfficiencyClass != 0)
procLog.Log(L" Core efficiency class is set");
for (uint32_t i = 0; i < procInfo->Processor.GroupCount; i++)
Expand Down Expand Up @@ -658,7 +674,7 @@ void ATG::LogProcessorInfo(const std::wstring& logName)
case RelationProcessorCore:
procLog.Log(L"Processor Core");
if (procInfo->ProcessorCore.Flags == 1)
procLog.Log(L" Core is hyper threaded");
procLog.Log(L" Core supports SMT");
swprintf(buffer, 256, L" CoreMask - %016I64x", procInfo->ProcessorMask);
procLog.Log(buffer);
break;
Expand Down Expand Up @@ -691,7 +707,7 @@ void ATG::LogCoreTests(const std::wstring& suffix, const std::wstring& logName)
swprintf_s(buffer, 256, L"%s_coreTests_%s", g_trueProcessorName.c_str(), suffix.c_str());
fileName = buffer;
}
ATG::FileLogger testLog(fileName, false);
ATG::FileLogger testLog(fileName, false, false, false, true, true);
size_t numTests = g_representativeCoreTests.size();
for (size_t i = 0; i < numTests; i++)
{
Expand Down Expand Up @@ -776,7 +792,7 @@ namespace
testNames.push_back(L"all_cores");

// one logical per physical
if (ATG::IsHyperThreaded())
if (ATG::IsSMTSupported())
{
uint64_t oneLogicalMask = 0;
for (const auto& iter : cpuSets)
Expand Down Expand Up @@ -814,7 +830,7 @@ namespace
}

// single physical core, one per cluster
if (minLowCacheCores > 1) // this means hyperthreaded
if (minLowCacheCores > 1) // this means SMT is supported
{
for (const auto& cluster : cpuSets)
{
Expand Down Expand Up @@ -935,7 +951,7 @@ namespace
}
}

// cross cluster tests, pick one physical core even if hyperthreaded
// cross cluster tests, pick one physical core even if SMT is supported
{
for (const auto& outerCluster : cpuSets)
{
Expand Down Expand Up @@ -976,21 +992,21 @@ namespace
testNames.clear();

constexpr uint32_t s_maxSingleCores = 4u;
bool hyperThreaded = false;
bool smtSupported = false;
uint64_t allCoresMask(0);
wchar_t tempBuffer[256];
for (const auto& iter : g_physicalCores[groupID])
{
allCoresMask |= iter.second;
if (iter.first)
hyperThreaded = true;
smtSupported = true;
}
coreTests.push_back(allCoresMask); // do everything
testNames.push_back(L"all_cores");
// physical cores
{
const uint32_t numSingle = std::min(ATG::GetNumPhysicalCores(groupID), s_maxSingleCores);
const uint32_t coreDelta = std::max<uint32_t>(hyperThreaded ? 2U : 1U, static_cast<uint32_t> ((((float)ATG::GetTotalNumCores(groupID)) / numSingle) + 0.5f)); // assume hyperthreaded are only 2 cores per physical
const uint32_t coreDelta = std::max<uint32_t>(smtSupported ? 2U : 1U, static_cast<uint32_t> ((((float)ATG::GetTotalNumCores(groupID)) / numSingle) + 0.5f)); // assume SMT supported are only 2 cores per physical
uint64_t curMask = 0;
for (uint32_t i = 0; i < numSingle; i++, curMask += coreDelta)
{
Expand All @@ -999,10 +1015,10 @@ namespace
testNames.push_back(tempBuffer);
}
}
if (hyperThreaded)
if (smtSupported)
{
const uint32_t numSingle = std::min(ATG::GetNumPhysicalCores(groupID), s_maxSingleCores);
const uint32_t coreDelta = std::max<uint32_t>(2, ATG::GetTotalNumCores(groupID) / numSingle); // assume hyperthreaded are only 2 cores per physical. Code below will set the mask correctly
const uint32_t coreDelta = std::max<uint32_t>(2, ATG::GetTotalNumCores(groupID) / numSingle); // assume SMT supported are only 2 cores per physical. Code below will set the mask correctly
uint64_t curMask = 0;
for (uint32_t i = 0; i < numSingle; i++, curMask += coreDelta)
{
Expand All @@ -1015,19 +1031,16 @@ namespace
if (g_dieMask.size() > 1) // numa nodes will show up here
{
// all cores in a cluster
uint32_t curCluster = 0;
for (const auto& iter : g_dieMask)
{
if (iter.second.groupID != groupID)
continue;
coreTests.push_back(iter.second.coreMask);
swprintf_s(tempBuffer, 256, L"full_cluster_0x%llx", iter.second.coreMask);
testNames.push_back(tempBuffer);
curCluster++;
}

// two cores in a cluster
curCluster = 0;
for (const auto& iter : g_dieMask)
{
if (iter.second.groupID != groupID)
Expand All @@ -1040,14 +1053,12 @@ namespace
swprintf_s(tempBuffer, 256, L"within_cluster_physical_0x%llx", (1ULL << lowBitIndex) | (1ULL << highBitIndex));
testNames.push_back(tempBuffer);

if (hyperThreaded)
if (smtSupported)
{
coreTests.push_back(ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << lowBitIndex, groupID)) | ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << highBitIndex, groupID)));
swprintf_s(tempBuffer, 256, L"within_cluster_hyper_0x%llx", ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << lowBitIndex, groupID)) | ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << highBitIndex, groupID)));
swprintf_s(tempBuffer, 256, L"within_cluster_SMT_0x%llx", ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << lowBitIndex, groupID)) | ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << highBitIndex, groupID)));
testNames.push_back(tempBuffer);
}

curCluster++;
}

// one physical on all combinations of 2 clusters
Expand All @@ -1073,7 +1084,7 @@ namespace
_BitScanForward64(&outerBitIndex, outer->second.coreMask);
_BitScanForward64(&innerBitIndex, inner->second.coreMask);

if (hyperThreaded)
if (smtSupported)
{
coreTests.push_back(ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << outerBitIndex, groupID)) | ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << innerBitIndex, groupID)));
swprintf_s(tempBuffer, 256, L"cross_cluster_logical_0x%llx", ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << outerBitIndex, groupID)) | ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << innerBitIndex, groupID)));
Expand All @@ -1091,7 +1102,7 @@ namespace
// half the cores in a single
const uint32_t halfLogical = ATG::GetNumLogicalCores(groupID) / 2;
uint64_t lowMask(0), highMask(0);
for (uint32_t i = 0; i < halfLogical; i += hyperThreaded ? 2 : 1)
for (uint32_t i = 0; i < halfLogical; i += smtSupported ? 2 : 1)
{
lowMask |= ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << i, groupID));
highMask |= ATG::GetLogicalProcessorMask(ATG::UniqueProcessorMask(1ULL << (halfLogical + i), groupID));
Expand All @@ -1105,7 +1116,7 @@ namespace
testNames.push_back(tempBuffer);

// two physical cores
if (hyperThreaded && (ATG::GetNumPhysicalCores(groupID) >= 4)) // just assume 2 cores in a hyperthread and at least 4 physical cores
if (smtSupported && (ATG::GetNumPhysicalCores(groupID) >= 4)) // just assume 2 cores in a SMT supported and at least 4 physical cores
{
coreTests.push_back(0x05);
swprintf_s(tempBuffer, 256, L"first two physical 0x05");
Expand All @@ -1115,8 +1126,8 @@ namespace
swprintf_s(tempBuffer, 256, L"second two physical 0xA0");
testNames.push_back(tempBuffer);
}
// handle 2 physical hyperthreaded cores
if (hyperThreaded && (ATG::GetNumPhysicalCores(groupID) == 2))
// handle 2 physical SMT cores
if (smtSupported && (ATG::GetNumPhysicalCores(groupID) == 2))
{
coreTests.push_back(0x05);
swprintf_s(tempBuffer, 256, L"Two physical_0x05");
Expand Down Expand Up @@ -1309,7 +1320,6 @@ namespace
g_numLogicalCores.resize(groupCount, 0);
g_availableCoresMask.resize(groupCount, 0);

uint32_t entries = 0;
data = g_osProcessorInfo.rawData;
dataLeft = g_osProcessorInfo.bufferSize;
while (dataLeft)
Expand Down Expand Up @@ -1367,7 +1377,6 @@ namespace
}
dataLeft -= procInfo->Size;
data = data + procInfo->Size;
entries++;
}
#endif

Expand Down
5 changes: 4 additions & 1 deletion Kits/ATGTK/Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ namespace ATG

using ProcessorGroupID = uint16_t;
using ProcessorNumaNodeID = uint32_t;
constexpr uint32_t JAGUAR_PROCESSOR_FAMILY = 0x16;
constexpr uint32_t ZEN2_PROCESSOR_FAMILY = 0x17;

struct UniqueProcessorMask
{
Expand Down Expand Up @@ -86,14 +88,15 @@ namespace ATG
uint32_t GetTotalNumCores(ProcessorGroupID groupID = 0);
uint64_t GetAvailableCoresMask(ProcessorGroupID groupID = 0);

inline bool IsHyperThreaded(ProcessorGroupID groupID = 0) { return GetNumPhysicalCores(groupID) < GetNumLogicalCores(groupID); }
inline bool IsSMTSupported(ProcessorGroupID groupID = 0) { return GetNumPhysicalCores(groupID) < GetNumLogicalCores(groupID); }
double GetRDTSCPFrequencySeconds();
double GetRDTSCPFrequencyMilliseconds();
double GetRDTSCPFrequencyMicroseconds();

const std::wstring& GetProcessorName(); // will be the override value which is initially the true name
const std::wstring& GetTrueProcessorName();
void SetProcessorName(const std::wstring& overrideName);
uint32_t GetProcessorFamily();

uint64_t GetLogicalProcessorMask(uint64_t coreMask); // adjusts the mask to cover all logical processors

Expand Down
Loading

0 comments on commit aa45b83

Please sign in to comment.