Skip to content

Commit

Permalink
DirectX Tool Kit, DirectXTex updated for June 2021 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn authored Jun 19, 2021
1 parent 5b20a8e commit f044c27
Show file tree
Hide file tree
Showing 312 changed files with 4,893 additions and 2,545 deletions.
5 changes: 4 additions & 1 deletion Kits/ATGTK/CSVReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
//
// Simple parser for .csv (Comma-Separated Values) files.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------

#pragma once

#include <cassert>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <memory>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion Kits/ATGTK/CommandLineHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//--------------------------------------------------------------------------------------
#pragma once

#include <cstddef>
#include <vector>

namespace ATG
Expand Down Expand Up @@ -52,7 +53,7 @@ namespace ATG
{
wprintf(L"Invalid value specified with -%ls (%ls)\n", LookupByValue(option, ::g_Options), name);
wprintf(pleaseUseMsg);
PrintTable(_countof(pleaseUseMsg) - 1, table);
PrintTable(std::size(pleaseUseMsg) - 1, table);
wprintf(L"\n\n");
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/ControllerFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Class for compositing text with Xbox controller font button sprites
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------

Expand Down
16 changes: 10 additions & 6 deletions Kits/ATGTK/ControllerHelp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ const ATG::Help::CalloutBox ATG::Help::CalloutBox::s_CalloutTemplates[] =
HELP_CALLOUT_COLOR,
ANCHOR_DPAD_ALL,
nullptr,
CALLOUT_LINE_DPAD_ALL
CALLOUT_LINE_DPAD_ALL,
{ 0, 0 }
},
// DPAD_DOWN
{
Expand All @@ -427,7 +428,8 @@ const ATG::Help::CalloutBox ATG::Help::CalloutBox::s_CalloutTemplates[] =
HELP_CALLOUT_COLOR,
ANCHOR_DPAD_ALL,
nullptr,
CALLOUT_LINE_DPAD_ALL
CALLOUT_LINE_DPAD_ALL,
{ 0, 0 }
},
// DPAD_LEFT
{
Expand All @@ -441,7 +443,8 @@ const ATG::Help::CalloutBox ATG::Help::CalloutBox::s_CalloutTemplates[] =
HELP_CALLOUT_COLOR,
ANCHOR_DPAD_ALL,
nullptr,
CALLOUT_LINE_DPAD_ALL
CALLOUT_LINE_DPAD_ALL,
{ 0, 0 }
},
// DPAD_RIGHT
{
Expand All @@ -455,7 +458,8 @@ const ATG::Help::CalloutBox ATG::Help::CalloutBox::s_CalloutTemplates[] =
HELP_CALLOUT_COLOR,
ANCHOR_DPAD_ALL,
nullptr,
CALLOUT_LINE_DPAD_ALL
CALLOUT_LINE_DPAD_ALL,
{ 0, 0 }
},
// DPAD_ALL
{
Expand Down Expand Up @@ -763,7 +767,7 @@ void ATG::Help::Render(ID3D12GraphicsCommandList* commandList)
{
m_descriptorHeap->Heap()
};
commandList->SetDescriptorHeaps(_countof(descriptorHeaps), descriptorHeaps);
commandList->SetDescriptorHeaps(static_cast<UINT>(std::size(descriptorHeaps)), descriptorHeaps);

D3D12_VIEWPORT vp1{ 0.0f, 0.0f, static_cast<float>(m_screenSize.right), static_cast<float>(m_screenSize.bottom),
D3D12_MIN_DEPTH, D3D12_MAX_DEPTH };
Expand Down Expand Up @@ -859,7 +863,7 @@ void ATG::Help::ReleaseDevice()
m_primBatch.reset();
m_lineEffect.reset();

for (size_t i = 0; i < _countof(m_spriteFonts); ++i)
for (size_t i = 0; i < std::size(m_spriteFonts); ++i)
{
m_spriteFonts[i].reset();
}
Expand Down
10 changes: 6 additions & 4 deletions Kits/ATGTK/DebugDraw.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
//--------------------------------------------------------------------------------------
// File: DebugDraw.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------

#include "pch.h"
#include "DebugDraw.h"

#include <algorithm>

using namespace DirectX;

namespace
Expand Down Expand Up @@ -52,7 +54,7 @@ namespace
XMStoreFloat4(&verts[i].color, color);
}

batch->DrawIndexed(D3D_PRIMITIVE_TOPOLOGY_LINELIST, s_indices, _countof(s_indices), verts, 8);
batch->DrawIndexed(D3D_PRIMITIVE_TOPOLOGY_LINELIST, s_indices, static_cast<UINT>(std::size(s_indices)), verts, 8);
}
}

Expand Down Expand Up @@ -132,12 +134,12 @@ void XM_CALLCONV DX::Draw(PrimitiveBatch<VertexPositionColor>* batch,
verts[22].position = corners[7];
verts[23].position = corners[4];

for (size_t j = 0; j < _countof(verts); ++j)
for (size_t j = 0; j < std::size(verts); ++j)
{
XMStoreFloat4(&verts[j].color, color);
}

batch->Draw(D3D_PRIMITIVE_TOPOLOGY_LINELIST, verts, _countof(verts));
batch->Draw(D3D_PRIMITIVE_TOPOLOGY_LINELIST, verts, static_cast<UINT>(std::size(verts)));
}

void XM_CALLCONV DX::DrawGrid(PrimitiveBatch<VertexPositionColor>* batch,
Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/DebugDraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Helpers for drawing various debug shapes using PrimitiveBatch
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------

Expand Down
9 changes: 5 additions & 4 deletions Kits/ATGTK/FileHelpers.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//--------------------------------------------------------------------------------------
// FileHelpers.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once

#include <fileapi.h>
#include <assert.h>
#include <stdio.h>

#include <cassert>
#include <cstdio>

#include <wrl/client.h>

Expand Down Expand Up @@ -74,4 +75,4 @@ namespace DX
Microsoft::WRL::ComPtr<IWICStream>& m_handle;
};
#endif
}
}
9 changes: 6 additions & 3 deletions Kits/ATGTK/FindMedia.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
// Helper function to find the location of a media file for Windows desktop apps
// since they lack appx packaging support.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------

#pragma once

#include <cstddef>
#include <cstring>
#include <exception>
#include <string.h>


namespace DX
Expand All @@ -34,6 +35,8 @@ namespace DX
static const wchar_t* s_defSearchFolders[] =
{
L"Assets",
L"Assets\\Fonts",
L"Assets\\Textures",
L"Media",
L"Media\\Textures",
L"Media\\Fonts",
Expand Down Expand Up @@ -103,4 +106,4 @@ namespace DX

throw std::exception("File not found");
}
}
}
3 changes: 2 additions & 1 deletion Kits/ATGTK/FrontPanel/BufferDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
//--------------------------------------------------------------------------------------
#pragma once

#include <stdint.h>
#include <cstddef>
#include <cstdint>


namespace ATG
Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/FrontPanel/CPUShapes.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//--------------------------------------------------------------------------------------
#pragma once

#include <stdint.h>
#include <cstdint>


namespace ATG
Expand Down
6 changes: 4 additions & 2 deletions Kits/ATGTK/FrontPanel/RasterFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
#include "Serialization.h"
#include "BufferDescriptor.h"

#include <fstream>
#include <algorithm>
#include <io.h>
#include <cstdarg>
#include <fstream>
#include <new>

#include <io.h>

using namespace ATG;
using namespace DX;
Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/FrontPanel/RasterFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once

#include <memory>
#include <stdint.h>
#include <string>
#include <vector>

Expand Down
4 changes: 2 additions & 2 deletions Kits/ATGTK/FullScreenQuad/FullScreenQuad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Class to draw a full-screen quad
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

Expand Down Expand Up @@ -61,7 +61,7 @@ void FullScreenQuad::Initialize(_In_ ID3D12Device* d3dDevice)
rootParameters[RootParameterIndex::TextureSRV_2].InitAsDescriptorTable(1, &textureSRVs_2, D3D12_SHADER_VISIBILITY_PIXEL);

CD3DX12_ROOT_SIGNATURE_DESC rootSignatureDesc;
rootSignatureDesc.Init(_countof(rootParameters), rootParameters, 1, &sampler, rootSignatureFlags);
rootSignatureDesc.Init(static_cast<UINT>(std::size(rootParameters)), rootParameters, 1, &sampler, rootSignatureFlags);

ComPtr<ID3DBlob> signature;
ComPtr<ID3DBlob> error;
Expand Down
15 changes: 12 additions & 3 deletions Kits/ATGTK/FullScreenQuad/FullScreenQuad.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Class to draw a full-screen quad
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

Expand All @@ -21,8 +21,17 @@ namespace DX
{
public:
void Initialize(_In_ ID3D12Device* d3dDevice);
void Draw(_In_ ID3D12GraphicsCommandList* d3dCommandList, _In_ ID3D12PipelineState* d3dPSO, D3D12_GPU_DESCRIPTOR_HANDLE texture, D3D12_GPU_VIRTUAL_ADDRESS constantBuffer = 0);
void Draw(_In_ ID3D12GraphicsCommandList* d3dCommandList, _In_ ID3D12PipelineState* d3dPSO, D3D12_GPU_DESCRIPTOR_HANDLE texture, D3D12_GPU_DESCRIPTOR_HANDLE texture2, D3D12_GPU_VIRTUAL_ADDRESS constantBuffer = 0);
void Draw(
_In_ ID3D12GraphicsCommandList* d3dCommandList,
_In_ ID3D12PipelineState* d3dPSO,
D3D12_GPU_DESCRIPTOR_HANDLE texture,
D3D12_GPU_VIRTUAL_ADDRESS constantBuffer = 0);
void Draw(
_In_ ID3D12GraphicsCommandList* d3dCommandList,
_In_ ID3D12PipelineState* d3dPSO,
D3D12_GPU_DESCRIPTOR_HANDLE texture,
D3D12_GPU_DESCRIPTOR_HANDLE texture2,
D3D12_GPU_VIRTUAL_ADDRESS constantBuffer = 0);

void ReleaseDevice();

Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/FullScreenQuad/FullScreenQuad.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Common shader code to draw a full-screen quad
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/FullScreenQuad/FullScreenQuadPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// A simple pixel shader to render a texture
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/FullScreenQuad/FullScreenQuadVS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Simple vertex shader to draw a full-screen quad
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

Expand Down
11 changes: 5 additions & 6 deletions Kits/ATGTK/HDR/HDRCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
//
// Simple helper functions for HDR
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

#pragma once

#include <stdlib.h>
#include <math.h>
#include <cstdlib>
#include <cmath>

namespace DX
Expand All @@ -21,14 +20,14 @@ namespace DX
// Apply the ST.2084 curve to normalized linear values and outputs normalized non-linear values
inline float LinearToST2084(float normalizedLinearValue)
{
float ST2084 = pow((0.8359375f + 18.8515625f * pow(abs(normalizedLinearValue), 0.1593017578f)) / (1.0f + 18.6875f * pow(abs(normalizedLinearValue), 0.1593017578f)), 78.84375f);
float ST2084 = powf((0.8359375f + 18.8515625f * powf(abs(normalizedLinearValue), 0.1593017578f)) / (1.0f + 18.6875f * powf(abs(normalizedLinearValue), 0.1593017578f)), 78.84375f);
return ST2084; // Don't clamp between [0..1], so we can still perform operations on scene values higher than 10,000 nits
}

// ST.2084 to linear, resulting in a linear normalized value
inline float ST2084ToLinear(float ST2084)
{
float normalizedLinear = pow(std::max(pow(abs(ST2084), 1.0f / 78.84375f) - 0.8359375f, 0.0f) / (18.8515625f - 18.6875f * pow(abs(ST2084), 1.0f / 78.84375f)), 1.0f / 0.1593017578f);
float normalizedLinear = powf(std::max(powf(abs(ST2084), 1.0f / 78.84375f) - 0.8359375f, 0.0f) / (18.8515625f - 18.6875f * powf(abs(ST2084), 1.0f / 78.84375f)), 1.0f / 0.1593017578f);
return normalizedLinear;
}

Expand Down Expand Up @@ -82,4 +81,4 @@ namespace DX
float hdrSceneValue = normalizedLinearValue * c_MaxNitsFor2084 / paperWhiteNits;
return hdrSceneValue;
}
}
}
2 changes: 1 addition & 1 deletion Kits/ATGTK/HDR/HDRCommon.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//
// Shader code helper functions for HDR, such as color rotation, ST.2084, etc.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Kits/ATGTK/OSHelpers.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//--------------------------------------------------------------------------------------
// OSHelpers.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
//--------------------------------------------------------------------------------------
#pragma once
Expand Down
Loading

0 comments on commit f044c27

Please sign in to comment.