#include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, Texture_Create_2D) { const uint32_t width = 256; const uint32_t height = 256; const DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM; D3D12_HEAP_PROPERTIES heapProps = {}; heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; D3D12_RESOURCE_DESC resourceDesc = {}; resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; resourceDesc.Width = width; resourceDesc.Height = height; resourceDesc.DepthOrArraySize = 1; resourceDesc.MipLevels = 1; resourceDesc.Format = format; resourceDesc.SampleDesc.Count = 1; resourceDesc.SampleDesc.Quality = 0; resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; ComPtr texture; HRESULT hr = GetDevice()->CreateCommittedResource( &heapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&texture) ); ASSERT_HRESULT_SUCCEEDED(hr); ASSERT_NE(texture.Get(), nullptr); D3D12_RESOURCE_DESC desc = texture->GetDesc(); EXPECT_EQ(desc.Dimension, D3D12_RESOURCE_DIMENSION_TEXTURE2D); EXPECT_EQ(desc.Width, width); EXPECT_EQ(desc.Height, height); EXPECT_EQ(desc.Format, format); } TEST_F(D3D12TestFixture, Texture_Create_3D) { const uint32_t width = 64; const uint32_t height = 64; const uint32_t depth = 64; D3D12_HEAP_PROPERTIES heapProps = {}; heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; D3D12_RESOURCE_DESC resourceDesc = {}; resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE3D; resourceDesc.Width = width; resourceDesc.Height = height; resourceDesc.DepthOrArraySize = depth; resourceDesc.MipLevels = 1; resourceDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; resourceDesc.SampleDesc.Count = 1; resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; ComPtr texture; HRESULT hr = GetDevice()->CreateCommittedResource( &heapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&texture) ); ASSERT_HRESULT_SUCCEEDED(hr); ASSERT_NE(texture.Get(), nullptr); D3D12_RESOURCE_DESC desc = texture->GetDesc(); EXPECT_EQ(desc.Dimension, D3D12_RESOURCE_DIMENSION_TEXTURE3D); EXPECT_EQ(desc.DepthOrArraySize, depth); } TEST_F(D3D12TestFixture, Texture_Create_MultipleMips) { const uint32_t width = 512; const uint32_t height = 512; const uint32_t mipLevels = 5; D3D12_HEAP_PROPERTIES heapProps = {}; heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; D3D12_RESOURCE_DESC resourceDesc = {}; resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; resourceDesc.Width = width; resourceDesc.Height = height; resourceDesc.DepthOrArraySize = 1; resourceDesc.MipLevels = mipLevels; resourceDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; resourceDesc.SampleDesc.Count = 1; resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; ComPtr texture; HRESULT hr = GetDevice()->CreateCommittedResource( &heapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&texture) ); ASSERT_HRESULT_SUCCEEDED(hr); D3D12_RESOURCE_DESC desc = texture->GetDesc(); EXPECT_EQ(desc.MipLevels, mipLevels); } TEST_F(D3D12TestFixture, Texture_Create_Array) { const uint32_t width = 128; const uint32_t height = 128; const uint32_t arraySize = 4; D3D12_HEAP_PROPERTIES heapProps = {}; heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; D3D12_RESOURCE_DESC resourceDesc = {}; resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; resourceDesc.Width = width; resourceDesc.Height = height; resourceDesc.DepthOrArraySize = arraySize; resourceDesc.MipLevels = 1; resourceDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; resourceDesc.SampleDesc.Count = 1; resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; ComPtr texture; HRESULT hr = GetDevice()->CreateCommittedResource( &heapProps, D3D12_HEAP_FLAG_NONE, &resourceDesc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&texture) ); ASSERT_HRESULT_SUCCEEDED(hr); D3D12_RESOURCE_DESC desc = texture->GetDesc(); EXPECT_EQ(desc.DepthOrArraySize, arraySize); }