mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 00:58:30 -05:00
Added AttribType::Uint10 encoding/decoding.
This commit is contained in:
parent
f54ffcca42
commit
4ce0c5703e
2 changed files with 90 additions and 7 deletions
|
@ -590,15 +590,32 @@ namespace bgfx { namespace d3d12
|
|||
g_caps.vendorId = (uint16_t)m_adapterDesc.VendorId;
|
||||
g_caps.deviceId = (uint16_t)m_adapterDesc.DeviceId;
|
||||
|
||||
m_architecture.NodeIndex = 0;
|
||||
DX_CHECK(m_device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &m_architecture, sizeof(m_architecture) ) );
|
||||
BX_TRACE("GPU Architecture, TileBasedRenderer %d, UMA %d, CacheCoherentUMA %d"
|
||||
, m_architecture.TileBasedRenderer
|
||||
, m_architecture.UMA
|
||||
, m_architecture.CacheCoherentUMA
|
||||
);
|
||||
uint32_t numNodes = m_device->GetNodeCount();
|
||||
BX_TRACE("D3D12 GPU Architecture (num nodes: %d):", numNodes);
|
||||
for (uint32_t ii = 0; ii < numNodes; ++ii)
|
||||
{
|
||||
D3D12_FEATURE_DATA_ARCHITECTURE architecture;
|
||||
architecture.NodeIndex = ii;
|
||||
DX_CHECK(m_device->CheckFeatureSupport(D3D12_FEATURE_ARCHITECTURE, &architecture, sizeof(architecture) ) );
|
||||
BX_TRACE("\tNode % 2d: TileBasedRenderer %d, UMA %d, CacheCoherentUMA %d"
|
||||
, ii
|
||||
, architecture.TileBasedRenderer
|
||||
, architecture.UMA
|
||||
, architecture.CacheCoherentUMA
|
||||
);
|
||||
if (0 == ii)
|
||||
{
|
||||
memcpy(&m_architecture, &architecture, sizeof(architecture) );
|
||||
}
|
||||
}
|
||||
|
||||
DX_CHECK(m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_options, sizeof(m_options) ) );
|
||||
BX_TRACE("D3D12 options:")
|
||||
BX_TRACE("\tTiledResourcesTier %d", m_options.TiledResourcesTier);
|
||||
BX_TRACE("\tResourceBindingTier %d", m_options.ResourceBindingTier);
|
||||
BX_TRACE("\tConservativeRasterizationTier %d", m_options.ConservativeRasterizationTier);
|
||||
BX_TRACE("\tCrossNodeSharingTier %d", m_options.CrossNodeSharingTier);
|
||||
BX_TRACE("\tResourceHeapTier %d", m_options.ResourceHeapTier);
|
||||
|
||||
m_cmd.init(m_device);
|
||||
|
||||
|
|
|
@ -425,6 +425,46 @@ namespace bgfx
|
|||
}
|
||||
break;
|
||||
|
||||
case AttribType::Uint10:
|
||||
{
|
||||
uint32_t packed = 0;
|
||||
if (_inputNormalized)
|
||||
{
|
||||
if (asInt)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default:
|
||||
case 3: packed |= uint32_t(*_input++ * 511.0f + 512.0f);
|
||||
case 2: packed <<= 10; packed |= uint32_t(*_input++ * 511.0f + 512.0f);
|
||||
case 1: packed <<= 10; packed |= uint32_t(*_input++ * 511.0f + 512.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default:
|
||||
case 3: packed |= uint32_t(*_input++ * 1023.0f);
|
||||
case 2: packed <<= 10; packed |= uint32_t(*_input++ * 1023.0f);
|
||||
case 1: packed <<= 10; packed |= uint32_t(*_input++ * 1023.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default:
|
||||
case 3: packed |= uint32_t(*_input++);
|
||||
case 2: packed <<= 10; packed |= uint32_t(*_input++);
|
||||
case 1: packed <<= 10; packed |= uint32_t(*_input++);
|
||||
}
|
||||
}
|
||||
*(uint32_t*)data = packed;
|
||||
}
|
||||
break;
|
||||
|
||||
case AttribType::Int16:
|
||||
{
|
||||
int16_t* packed = (int16_t*)data;
|
||||
|
@ -529,6 +569,32 @@ namespace bgfx
|
|||
}
|
||||
break;
|
||||
|
||||
case AttribType::Uint10:
|
||||
{
|
||||
uint32_t packed = *(uint32_t*)data;
|
||||
if (asInt)
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default:
|
||||
case 3: *_output++ = (float(packed & 0x3ff) - 512.0f)*1.0f/511.0f; packed >>= 10;
|
||||
case 2: *_output++ = (float(packed & 0x3ff) - 512.0f)*1.0f/511.0f; packed >>= 10;
|
||||
case 1: *_output++ = (float(packed & 0x3ff) - 512.0f)*1.0f/511.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (num)
|
||||
{
|
||||
default:
|
||||
case 3: *_output++ = float(packed & 0x3ff)*1.0f/1023.0f; packed >>= 10;
|
||||
case 2: *_output++ = float(packed & 0x3ff)*1.0f/1023.0f; packed >>= 10;
|
||||
case 1: *_output++ = float(packed & 0x3ff)*1.0f/1023.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AttribType::Int16:
|
||||
{
|
||||
int16_t* packed = (int16_t*)data;
|
||||
|
|
Loading…
Reference in a new issue