Skip to content

Commit

Permalink
2403 release update (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmartinms authored Apr 1, 2024
1 parent 5ae67dc commit 41b5942
Show file tree
Hide file tree
Showing 806 changed files with 26,155 additions and 16,167 deletions.
125 changes: 125 additions & 0 deletions Kits/ATGTK/DXRHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#pragma warning(push)
#pragma warning(disable : 4316 4324) // We don't care that ShaderRecord (or derived types) are potentially unaligned or padded. They won't be in the Upload Heap

#include <iomanip>
#include <sstream>
#include <string>

__declspec(align(D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT))
struct ShaderRecord
{
Expand Down Expand Up @@ -142,4 +146,125 @@ class ShaderBindingTable
T* m_missShaderRecords;
T* m_hitGroupRecords;
};

// Pretty-print a state object tree.
inline void PrintStateObjectDesc(const D3D12_STATE_OBJECT_DESC* pDesc)
{
std::wstringstream wstr;
wstr << L"\n";
wstr << L"--------------------------------------------------------------------\n";
wstr << L"| D3D12 State Object 0x" << static_cast<const void*>(pDesc) << L": ";
if (pDesc->Type == D3D12_STATE_OBJECT_TYPE_COLLECTION) wstr << L"Collection\n";
if (pDesc->Type == D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE) wstr << L"Raytracing Pipeline\n";

auto ExportTree = [](uint32_t depth, uint32_t numExports, const D3D12_EXPORT_DESC* exports)
{
std::wostringstream woss;
for (uint32_t i = 0; i < numExports; i++)
{
woss << L"|";
if (depth > 0)
{
for (uint32_t j = 0; j < 2 * depth - 1; j++) woss << L" ";
}
woss << L" [" << i << L"]: ";
if (exports[i].ExportToRename) woss << exports[i].ExportToRename << L" --> ";
woss << exports[i].Name << L"\n";
}
return woss.str();
};

for (uint32_t i = 0; i < pDesc->NumSubobjects; i++)
{
wstr << L"| [" << i << L"]: ";
switch (pDesc->pSubobjects[i].Type)
{
case D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE:
wstr << L"Global Root Signature 0x" << pDesc->pSubobjects[i].pDesc << L"\n";
break;
case D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE:
wstr << L"Local Root Signature 0x" << pDesc->pSubobjects[i].pDesc << L"\n";
break;
case D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK:
wstr << L"Node Mask: 0x" << std::hex << std::setfill(L'0') << std::setw(8) << *static_cast<const uint32_t*>(pDesc->pSubobjects[i].pDesc) << std::setw(0) << std::dec << L"\n";
break;
#ifdef _GAMING_XBOX_SCARLETT
case D3D12XBOX_STATE_SUBOBJECT_TYPE_RAYTRACING_OPTIONS:
break;
#endif
case D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY:
{
wstr << L"DXIL Library 0x";
auto lib = static_cast<const D3D12_DXIL_LIBRARY_DESC*>(pDesc->pSubobjects[i].pDesc);
wstr << lib->DXILLibrary.pShaderBytecode << L", " << lib->DXILLibrary.BytecodeLength << L" bytes\n";
wstr << ExportTree(1, lib->NumExports, lib->pExports);
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION:
{
wstr << L"Existing Library 0x";
auto collection = static_cast<const D3D12_EXISTING_COLLECTION_DESC*>(pDesc->pSubobjects[i].pDesc);
wstr << collection->pExistingCollection << L"\n";
wstr << ExportTree(1, collection->NumExports, collection->pExports);
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION:
{
wstr << L"Subobject to Exports Association (Subobject [";
auto association = static_cast<const D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION*>(pDesc->pSubobjects[i].pDesc);
uint32_t index = static_cast<uint32_t>(association->pSubobjectToAssociate - pDesc->pSubobjects);
wstr << index << L"])\n";
for (size_t j = 0; j < association->NumExports; j++)
{
wstr << L"| [" << j << L"]: " << association->pExports[j] << L"\n";
}
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION:
{
wstr << L"DXIL Subobjects to Exports Association (";
auto association = static_cast<const D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION*>(pDesc->pSubobjects[i].pDesc);
wstr << association->SubobjectToAssociate << L")\n";
for (size_t j = 0; j < association->NumExports; j++)
{
wstr << L"| [" << j << L"]: " << association->pExports[j] << L"\n";
}
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG:
{
wstr << L"Raytracing Shader Config\n";
auto config = static_cast<const D3D12_RAYTRACING_SHADER_CONFIG*>(pDesc->pSubobjects[i].pDesc);
wstr << L"| [0]: Max Payload Size: " << config->MaxPayloadSizeInBytes << L" bytes\n";
wstr << L"| [1]: Max Attribute Size: " << config->MaxAttributeSizeInBytes << L" bytes\n";
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG:
{
wstr << L"Raytracing Pipeline Config\n";
auto config = static_cast<const D3D12_RAYTRACING_PIPELINE_CONFIG*>(pDesc->pSubobjects[i].pDesc);
wstr << L"| [0]: Max Recursion Depth: " << config->MaxTraceRecursionDepth << L"\n";
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP:
{
wstr << L"Hit Group (";
auto hitGroup = static_cast<const D3D12_HIT_GROUP_DESC*>(pDesc->pSubobjects[i].pDesc);
wstr << (hitGroup->HitGroupExport ? hitGroup->HitGroupExport : L"[none]") << L")\n";
wstr << L"| [0]: Any Hit Import: " << (hitGroup->AnyHitShaderImport ? hitGroup->AnyHitShaderImport : L"[none]") << L"\n";
wstr << L"| [1]: Closest Hit Import: " << (hitGroup->ClosestHitShaderImport ? hitGroup->ClosestHitShaderImport : L"[none]") << L"\n";
wstr << L"| [2]: Intersection Import: " << (hitGroup->IntersectionShaderImport ? hitGroup->IntersectionShaderImport : L"[none]") << L"\n";
break;
}
case D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG:
case D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1:
case D3D12_STATE_SUBOBJECT_TYPE_MAX_VALID:
break;
}
wstr << L"|--------------------------------------------------------------------\n";
}
wstr << L"\n";
OutputDebugStringW(wstr.str().c_str());
}

#pragma warning(pop)
65 changes: 60 additions & 5 deletions Kits/ATGTK/Meshlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,66 @@ void MeshletSet::CreateResources(ID3D12Device* device, DirectX::ResourceUploadBa
auto const meshInfoDesc = CD3DX12_RESOURCE_DESC::Buffer(GetAlignedSize(sizeof(MeshInfo)));

auto const heapProps = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT);
device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &meshletDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_GRAPHICS_PPV_ARGS(m_meshletResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &cullDataDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_GRAPHICS_PPV_ARGS(m_cullDataResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &indexDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_GRAPHICS_PPV_ARGS(m_uniqueIndexResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &primitiveDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_GRAPHICS_PPV_ARGS(m_primitiveResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(&heapProps, D3D12_HEAP_FLAG_NONE, &meshInfoDesc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_GRAPHICS_PPV_ARGS(m_meshInfoResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_NONE,
&meshletDesc,
#ifdef _GAMING_XBOX
D3D12_RESOURCE_STATE_COPY_DEST,
#else
// on PC buffers are created in the common state and can be promoted without a barrier to COPY_DEST on first access
D3D12_RESOURCE_STATE_COMMON,
#endif
nullptr,
IID_GRAPHICS_PPV_ARGS(m_meshletResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_NONE,
&cullDataDesc,
#ifdef _GAMING_XBOX
D3D12_RESOURCE_STATE_COPY_DEST,
#else
// on PC buffers are created in the common state and can be promoted without a barrier to COPY_DEST on first access
D3D12_RESOURCE_STATE_COMMON,
#endif
nullptr,
IID_GRAPHICS_PPV_ARGS(m_cullDataResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_NONE,
&indexDesc,
#ifdef _GAMING_XBOX
D3D12_RESOURCE_STATE_COPY_DEST,
#else
// on PC buffers are created in the common state and can be promoted without a barrier to COPY_DEST on first access
D3D12_RESOURCE_STATE_COMMON,
#endif
nullptr,
IID_GRAPHICS_PPV_ARGS(m_uniqueIndexResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_NONE,
&primitiveDesc,
#ifdef _GAMING_XBOX
D3D12_RESOURCE_STATE_COPY_DEST,
#else
// on PC buffers are created in the common state and can be promoted without a barrier to COPY_DEST on first access
D3D12_RESOURCE_STATE_COMMON,
#endif
nullptr,
IID_GRAPHICS_PPV_ARGS(m_primitiveResource.ReleaseAndGetAddressOf()));
device->CreateCommittedResource(
&heapProps,
D3D12_HEAP_FLAG_NONE,
&meshInfoDesc,
#ifdef _GAMING_XBOX
D3D12_RESOURCE_STATE_COPY_DEST,
#else
// on PC buffers are created in the common state and can be promoted without a barrier to COPY_DEST on first access
D3D12_RESOURCE_STATE_COMMON,
#endif
nullptr,
IID_GRAPHICS_PPV_ARGS(m_meshInfoResource.ReleaseAndGetAddressOf()));

// Upload to D3D resources
auto meshletMem = GraphicsMemory::Get().Allocate(meshletDesc.Width);
Expand Down
Loading

0 comments on commit 41b5942

Please sign in to comment.