Skip to content

Commit

Permalink
February 2017
Browse files Browse the repository at this point in the history
  • Loading branch information
walbourn committed Feb 15, 2017
1 parent 46a3295 commit 5ecf2d4
Show file tree
Hide file tree
Showing 35 changed files with 2,788 additions and 321 deletions.
8 changes: 4 additions & 4 deletions Kits/Telemetry/Telemetry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
namespace ATG
{
// Must register the event provider before writing any events
ATG_TELEMETRY_API uint32_t EventRegisterATGSampleTelemetry();
ATG_TELEMETRY_API uint32_t EventUnregisterATGSampleTelemetry();
ATG_TELEMETRY_API uint32_t __cdecl EventRegisterATGSampleTelemetry();
ATG_TELEMETRY_API uint32_t __cdecl EventUnregisterATGSampleTelemetry();

// Returns true if you've called EventRegisterATGSampleTelemetry()
ATG_TELEMETRY_API bool EventEnabledSampleLoaded();
ATG_TELEMETRY_API bool __cdecl EventEnabledSampleLoaded();

// Log the SampleLoaded event
// requires that you call EventRegisterATGSampleTelemetry() first
ATG_TELEMETRY_API uint32_t EventWriteSampleLoaded(const wchar_t* exeName);
ATG_TELEMETRY_API uint32_t __cdecl EventWriteSampleLoaded(const wchar_t* exeName);
}
114 changes: 71 additions & 43 deletions Samples/Graphics/SimplePBR12/UWP/d3dx12.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE
BytecodeLength = pShaderBlob->GetBufferSize();
}
CD3DX12_SHADER_BYTECODE(
const void* _pShaderBytecode,
_In_reads_(bytecodeLength) const void* _pShaderBytecode,
SIZE_T bytecodeLength )
{
pShaderBytecode = _pShaderBytecode;
Expand Down Expand Up @@ -1922,6 +1922,11 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(
_Outptr_ ID3DBlob** ppBlob,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob)
{
if (ppErrorBlob != NULL)
{
*ppErrorBlob = NULL;
}

switch (MaxVersion)
{
case D3D_ROOT_SIGNATURE_VERSION_1_0:
Expand All @@ -1932,65 +1937,88 @@ inline HRESULT D3DX12SerializeVersionedRootSignature(

case D3D_ROOT_SIGNATURE_VERSION_1_1:
{
HRESULT hr = S_OK;
const D3D12_ROOT_SIGNATURE_DESC1& desc_1_1 = pRootSignatureDesc->Desc_1_1;

SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters;
const SIZE_T ParametersSize = sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters;
void* pParameters = (ParametersSize > 0) ? HeapAlloc(GetProcessHeap(), 0, ParametersSize) : NULL;
if (ParametersSize > 0 && pParameters == NULL)
{
hr = E_OUTOFMEMORY;
}
D3D12_ROOT_PARAMETER* pParameters_1_0 = reinterpret_cast<D3D12_ROOT_PARAMETER*>(pParameters);

for (UINT n = 0; n < desc_1_1.NumParameters; n++)
if (SUCCEEDED(hr))
{
pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType;
pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility;

switch (desc_1_1.pParameters[n].ParameterType)
for (UINT n = 0; n < desc_1_1.NumParameters; n++)
{
case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
pParameters_1_0[n].Constants.Num32BitValues = desc_1_1.pParameters[n].Constants.Num32BitValues;
pParameters_1_0[n].Constants.RegisterSpace = desc_1_1.pParameters[n].Constants.RegisterSpace;
pParameters_1_0[n].Constants.ShaderRegister = desc_1_1.pParameters[n].Constants.ShaderRegister;
break;

case D3D12_ROOT_PARAMETER_TYPE_CBV:
case D3D12_ROOT_PARAMETER_TYPE_SRV:
case D3D12_ROOT_PARAMETER_TYPE_UAV:
pParameters_1_0[n].Descriptor.RegisterSpace = desc_1_1.pParameters[n].Descriptor.RegisterSpace;
pParameters_1_0[n].Descriptor.ShaderRegister = desc_1_1.pParameters[n].Descriptor.ShaderRegister;
break;

case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable;

SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges;
void* pDescriptorRanges = (DescriptorRangesSize > 0) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : NULL;
D3D12_DESCRIPTOR_RANGE* pDescriptorRanges_1_0 = reinterpret_cast<D3D12_DESCRIPTOR_RANGE*>(pDescriptorRanges);

for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++)
__analysis_assume(ParametersSize == sizeof(D3D12_ROOT_PARAMETER) * desc_1_1.NumParameters);
pParameters_1_0[n].ParameterType = desc_1_1.pParameters[n].ParameterType;
pParameters_1_0[n].ShaderVisibility = desc_1_1.pParameters[n].ShaderVisibility;

switch (desc_1_1.pParameters[n].ParameterType)
{
pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister;
pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors;
pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart;
pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType;
pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace;
case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS:
pParameters_1_0[n].Constants.Num32BitValues = desc_1_1.pParameters[n].Constants.Num32BitValues;
pParameters_1_0[n].Constants.RegisterSpace = desc_1_1.pParameters[n].Constants.RegisterSpace;
pParameters_1_0[n].Constants.ShaderRegister = desc_1_1.pParameters[n].Constants.ShaderRegister;
break;

case D3D12_ROOT_PARAMETER_TYPE_CBV:
case D3D12_ROOT_PARAMETER_TYPE_SRV:
case D3D12_ROOT_PARAMETER_TYPE_UAV:
pParameters_1_0[n].Descriptor.RegisterSpace = desc_1_1.pParameters[n].Descriptor.RegisterSpace;
pParameters_1_0[n].Descriptor.ShaderRegister = desc_1_1.pParameters[n].Descriptor.ShaderRegister;
break;

case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE:
const D3D12_ROOT_DESCRIPTOR_TABLE1& table_1_1 = desc_1_1.pParameters[n].DescriptorTable;

const SIZE_T DescriptorRangesSize = sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges;
void* pDescriptorRanges = (DescriptorRangesSize > 0 && SUCCEEDED(hr)) ? HeapAlloc(GetProcessHeap(), 0, DescriptorRangesSize) : NULL;
if (DescriptorRangesSize > 0 && pDescriptorRanges == NULL)
{
hr = E_OUTOFMEMORY;
}
D3D12_DESCRIPTOR_RANGE* pDescriptorRanges_1_0 = reinterpret_cast<D3D12_DESCRIPTOR_RANGE*>(pDescriptorRanges);

if (SUCCEEDED(hr))
{
for (UINT x = 0; x < table_1_1.NumDescriptorRanges; x++)
{
__analysis_assume(DescriptorRangesSize == sizeof(D3D12_DESCRIPTOR_RANGE) * table_1_1.NumDescriptorRanges);
pDescriptorRanges_1_0[x].BaseShaderRegister = table_1_1.pDescriptorRanges[x].BaseShaderRegister;
pDescriptorRanges_1_0[x].NumDescriptors = table_1_1.pDescriptorRanges[x].NumDescriptors;
pDescriptorRanges_1_0[x].OffsetInDescriptorsFromTableStart = table_1_1.pDescriptorRanges[x].OffsetInDescriptorsFromTableStart;
pDescriptorRanges_1_0[x].RangeType = table_1_1.pDescriptorRanges[x].RangeType;
pDescriptorRanges_1_0[x].RegisterSpace = table_1_1.pDescriptorRanges[x].RegisterSpace;
}
}

D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable;
table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges;
table_1_0.pDescriptorRanges = pDescriptorRanges_1_0;
}

D3D12_ROOT_DESCRIPTOR_TABLE& table_1_0 = pParameters_1_0[n].DescriptorTable;
table_1_0.NumDescriptorRanges = table_1_1.NumDescriptorRanges;
table_1_0.pDescriptorRanges = pDescriptorRanges_1_0;
}
}

CD3DX12_ROOT_SIGNATURE_DESC desc_1_0(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, desc_1_1.pStaticSamplers, desc_1_1.Flags);
HRESULT hr = D3D12SerializeRootSignature(&desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob);
if (SUCCEEDED(hr))
{
CD3DX12_ROOT_SIGNATURE_DESC desc_1_0(desc_1_1.NumParameters, pParameters_1_0, desc_1_1.NumStaticSamplers, desc_1_1.pStaticSamplers, desc_1_1.Flags);
hr = D3D12SerializeRootSignature(&desc_1_0, D3D_ROOT_SIGNATURE_VERSION_1, ppBlob, ppErrorBlob);
}

for (UINT n = 0; n < desc_1_0.NumParameters; n++)
if (pParameters)
{
if (desc_1_0.pParameters[n].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
for (UINT n = 0; n < desc_1_1.NumParameters; n++)
{
HeapFree(GetProcessHeap(), 0, reinterpret_cast<void*>(const_cast<D3D12_DESCRIPTOR_RANGE*>(pParameters_1_0[n].DescriptorTable.pDescriptorRanges)));
if (desc_1_1.pParameters[n].ParameterType == D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE)
{
HeapFree(GetProcessHeap(), 0, reinterpret_cast<void*>(const_cast<D3D12_DESCRIPTOR_RANGE*>(pParameters_1_0[n].DescriptorTable.pDescriptorRanges)));
}
}
HeapFree(GetProcessHeap(), 0, pParameters);
}
HeapFree(GetProcessHeap(), 0, pParameters);
return hr;
}
}
Expand Down
Loading

0 comments on commit 5ecf2d4

Please sign in to comment.