diff --git a/tests/RHI/D3D12/test_descriptor_heap.cpp b/tests/RHI/D3D12/test_descriptor_heap.cpp index 4c3edc7a..7b9ee304 100644 --- a/tests/RHI/D3D12/test_descriptor_heap.cpp +++ b/tests/RHI/D3D12/test_descriptor_heap.cpp @@ -1,5 +1,75 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, DescriptorHeap_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetDevice(), nullptr); +} + +TEST_F(D3D12TestFixture, DescriptorHeap_CreateCBV_SRV_UAV) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + heapDesc.NumDescriptors = 10; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + ASSERT_NE(descriptorHeap.Get(), nullptr); + + D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc(); + EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + EXPECT_EQ(desc.NumDescriptors, 10); +} + +TEST_F(D3D12TestFixture, DescriptorHeap_CreateSampler) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER; + heapDesc.NumDescriptors = 5; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc(); + EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); +} + +TEST_F(D3D12TestFixture, DescriptorHeap_CreateRTV) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + heapDesc.NumDescriptors = 4; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc(); + EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_RTV); +} + +TEST_F(D3D12TestFixture, DescriptorHeap_CreateDSV) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; + heapDesc.NumDescriptors = 2; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_DESCRIPTOR_HEAP_DESC desc = descriptorHeap->GetDesc(); + EXPECT_EQ(desc.Type, D3D12_DESCRIPTOR_HEAP_TYPE_DSV); +} + +TEST_F(D3D12TestFixture, DescriptorHeap_GetHandleIncrementSize) { + UINT cbvSrvUavSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + UINT samplerSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER); + UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); + UINT dsvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_DSV); + + EXPECT_GT(cbvSrvUavSize, 0); + EXPECT_GT(samplerSize, 0); + EXPECT_GT(rtvSize, 0); + EXPECT_GT(dsvSize, 0); } diff --git a/tests/RHI/D3D12/test_pipeline_state.cpp b/tests/RHI/D3D12/test_pipeline_state.cpp index 9a33299c..6af582a7 100644 --- a/tests/RHI/D3D12/test_pipeline_state.cpp +++ b/tests/RHI/D3D12/test_pipeline_state.cpp @@ -1,5 +1,42 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, PipelineState_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetDevice(), nullptr); +} + +TEST_F(D3D12TestFixture, PipelineState_GraphicsPipelineDescDefaults) { + D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {}; + psoDesc.InputLayout = {}; + psoDesc.pRootSignature = nullptr; + psoDesc.VS = {}; + psoDesc.PS = {}; + psoDesc.DS = {}; + psoDesc.HS = {}; + psoDesc.GS = {}; + psoDesc.StreamOutput = {}; + psoDesc.BlendState = {}; + psoDesc.SampleMask = UINT_MAX; + psoDesc.RasterizerState = {}; + psoDesc.DepthStencilState = {}; + psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; + psoDesc.NumRenderTargets = 1; + psoDesc.RTVFormats[0] = DXGI_FORMAT_R8G8B8A8_UNORM; + psoDesc.DSVFormat = DXGI_FORMAT_D32_FLOAT; + psoDesc.SampleDesc.Count = 1; + psoDesc.SampleDesc.Quality = 0; + + EXPECT_EQ(psoDesc.PrimitiveTopologyType, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE); + EXPECT_EQ(psoDesc.NumRenderTargets, 1); +} + +TEST_F(D3D12TestFixture, PipelineState_ComputePipelineDescDefaults) { + D3D12_COMPUTE_PIPELINE_STATE_DESC psoDesc = {}; + psoDesc.pRootSignature = nullptr; + psoDesc.CS = {}; + psoDesc.NodeMask = 0; + psoDesc.CachedPSO = {}; + psoDesc.Flags = D3D12_PIPELINE_STATE_FLAG_NONE; + + EXPECT_EQ(psoDesc.NodeMask, 0); + EXPECT_EQ(psoDesc.Flags, D3D12_PIPELINE_STATE_FLAG_NONE); } diff --git a/tests/RHI/D3D12/test_root_signature.cpp b/tests/RHI/D3D12/test_root_signature.cpp index 236c6419..77443214 100644 --- a/tests/RHI/D3D12/test_root_signature.cpp +++ b/tests/RHI/D3D12/test_root_signature.cpp @@ -1,5 +1,42 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, RootSignature_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetDevice(), nullptr); +} + +TEST_F(D3D12TestFixture, RootSignature_CreateEmptyRootSignature) { + D3D12_ROOT_SIGNATURE_DESC rootSigDesc = {}; + rootSigDesc.NumParameters = 0; + rootSigDesc.NumStaticSamplers = 0; + rootSigDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE; + + ComPtr blob; + ComPtr errorBlob; + HRESULT hr = D3D12SerializeRootSignature(&rootSigDesc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, &errorBlob); + ASSERT_HRESULT_SUCCEEDED(hr); + ASSERT_NE(blob.Get(), nullptr); +} + +TEST_F(D3D12TestFixture, RootSignature_CreateRootSignatureWithCBV) { + D3D12_ROOT_PARAMETER param = {}; + param.ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV; + param.Descriptor.ShaderRegister = 0; + param.Descriptor.RegisterSpace = 0; + param.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL; + + D3D12_ROOT_SIGNATURE_DESC rootSigDesc = {}; + rootSigDesc.NumParameters = 1; + rootSigDesc.pParameters = ¶m; + rootSigDesc.NumStaticSamplers = 0; + rootSigDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_NONE; + + ComPtr blob; + ComPtr errorBlob; + HRESULT hr = D3D12SerializeRootSignature(&rootSigDesc, D3D_ROOT_SIGNATURE_VERSION_1, &blob, &errorBlob); + ASSERT_HRESULT_SUCCEEDED(hr); + + ComPtr rootSig; + hr = GetDevice()->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(&rootSig)); + ASSERT_HRESULT_SUCCEEDED(hr); + ASSERT_NE(rootSig.Get(), nullptr); } diff --git a/tests/RHI/D3D12/test_shader.cpp b/tests/RHI/D3D12/test_shader.cpp index ad663760..3ac77401 100644 --- a/tests/RHI/D3D12/test_shader.cpp +++ b/tests/RHI/D3D12/test_shader.cpp @@ -1,5 +1,20 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, Shader_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetDevice(), nullptr); +} + +TEST_F(D3D12TestFixture, Shader_GetVertexShaderProfile) { + const char* profile = "vs_6_0"; + EXPECT_STREQ(profile, "vs_6_0"); +} + +TEST_F(D3D12TestFixture, Shader_GetPixelShaderProfile) { + const char* profile = "ps_6_0"; + EXPECT_STREQ(profile, "ps_6_0"); +} + +TEST_F(D3D12TestFixture, Shader_GetComputeShaderProfile) { + const char* profile = "cs_6_0"; + EXPECT_STREQ(profile, "cs_6_0"); } diff --git a/tests/RHI/D3D12/test_views.cpp b/tests/RHI/D3D12/test_views.cpp index 7bb5755b..63972ba0 100644 --- a/tests/RHI/D3D12/test_views.cpp +++ b/tests/RHI/D3D12/test_views.cpp @@ -1,5 +1,66 @@ #include "fixtures/D3D12TestFixture.h" TEST_F(D3D12TestFixture, Views_Placeholder) { - ASSERT_TRUE(true); + ASSERT_NE(GetDevice(), nullptr); +} + +TEST_F(D3D12TestFixture, Views_CreateRTVDescriptorHeap) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + heapDesc.NumDescriptors = 1; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart(); + EXPECT_NE(handle.ptr, 0); +} + +TEST_F(D3D12TestFixture, Views_CreateDSVDescriptorHeap) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_DSV; + heapDesc.NumDescriptors = 1; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart(); + EXPECT_NE(handle.ptr, 0); +} + +TEST_F(D3D12TestFixture, Views_CreateCBVDescriptorHeap) { + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV; + heapDesc.NumDescriptors = 1; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_CPU_DESCRIPTOR_HANDLE handle = descriptorHeap->GetCPUDescriptorHandleForHeapStart(); + EXPECT_NE(handle.ptr, 0); +} + +TEST_F(D3D12TestFixture, Views_RTVDescriptorHandleIncrement) { + UINT rtvSize = GetDevice()->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); + + D3D12_DESCRIPTOR_HEAP_DESC heapDesc = {}; + heapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; + heapDesc.NumDescriptors = 4; + heapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; + + ComPtr descriptorHeap; + HRESULT hr = GetDevice()->CreateDescriptorHeap(&heapDesc, IID_PPV_ARGS(&descriptorHeap)); + ASSERT_HRESULT_SUCCEEDED(hr); + + D3D12_CPU_DESCRIPTOR_HANDLE handle1 = descriptorHeap->GetCPUDescriptorHandleForHeapStart(); + D3D12_CPU_DESCRIPTOR_HANDLE handle2 = handle1; + handle2.ptr += rtvSize; + + EXPECT_NE(handle1.ptr, handle2.ptr); }