@@ -335,6 +335,37 @@ void ResourceManager::LoadTexture(const uint8_t* pData, DWORD dwDataSize, ID3D12
335335 ThrowIfFailed (FC->Initialize (frame.Get (), convertGUID, WICBitmapDitherTypeErrorDiffusion, nullptr , 0 , WICBitmapPaletteTypeMedianCut));
336336 ThrowIfFailed (FC->CopyPixels (nullptr , static_cast <UINT>(rowPitch), static_cast <UINT>(imageSize), decodedData.get ()));
337337 }
338+
339+ /* Count the number of mips */
340+ const uint32_t mipCount = 1u ; // TODO: Calculate.
341+
342+ D3D12_RESOURCE_DESC resDesc = { };
343+ resDesc.Width = width;
344+ resDesc.Height = height;
345+ resDesc.MipLevels = static_cast <UINT16>(mipCount);
346+ resDesc.DepthOrArraySize = 1 ;
347+ resDesc.Format = format;
348+ resDesc.SampleDesc .Count = 1 ;
349+ resDesc.Flags = D3D12_RESOURCE_FLAG_NONE;
350+ resDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
351+
352+ D3D12_HEAP_PROPERTIES heapProps = { };
353+ heapProps.Type = D3D12_HEAP_TYPE_DEFAULT;
354+
355+ ComPtr<ID3D12Resource> tex;
356+ ThrowIfFailed (this ->m_dev ->CreateCommittedResource (
357+ &heapProps, D3D12_HEAP_FLAG_NONE,
358+ &resDesc,
359+ D3D12_RESOURCE_STATE_COPY_DEST,
360+ nullptr ,
361+ IID_PPV_ARGS (tex.GetAddressOf ())
362+ ));
363+
364+ initData.pData = decodedData.get ();
365+ initData.RowPitch = static_cast <LONG>(rowPitch);
366+ initData.SlicePitch = static_cast <LONG>(imageSize);
367+
368+ *resource = tex.Get ();
338369}
339370
340371ResourceManager* ResourceManager::GetInstance () {
0 commit comments