From 4ce0c5703ea98e97195f563720ce11b18cedbdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 4 Aug 2015 21:55:47 -0700 Subject: [PATCH] Added AttribType::Uint10 encoding/decoding. --- src/renderer_d3d12.cpp | 31 +++++++++++++++----- src/vertexdecl.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 7 deletions(-) diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 11b0413e..896e588c 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -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); diff --git a/src/vertexdecl.cpp b/src/vertexdecl.cpp index 1ef4a1e9..6c15368d 100644 --- a/src/vertexdecl.cpp +++ b/src/vertexdecl.cpp @@ -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;