- Rename D3D12Enum.h to D3D12Enums.h for naming consistency - Fix OpenGL unit test GLAD initialization by using gladLoadGL() instead of gladLoadGLLoader(wglGetProcAddress) for fallback support - Migrate remaining tests to use gtest_discover_tests for granular test discovery (math, core, containers, memory, threading, debug, components, scene, resources, input, opengl) - Remove obsolete TEST_RESOURCES_DIR and copy_directory commands from OpenGL unit test CMakeLists (minimal/Res doesn't exist) - Update TEST_SPEC.md with performance metrics and per-module build/test commands for faster development workflow - Update CMake path references to use lowercase paths
93 lines
2.5 KiB
C++
93 lines
2.5 KiB
C++
#include "fixtures/D3D12TestFixture.h"
|
|
#include "XCEngine/RHI/RHIEnums.h"
|
|
#include "XCEngine/RHI/RHITexture.h"
|
|
|
|
using namespace XCEngine::RHI;
|
|
|
|
TEST_F(D3D12TestFixture, Texture_Create_2D) {
|
|
TextureDesc desc = {};
|
|
desc.width = 256;
|
|
desc.height = 256;
|
|
desc.depth = 1;
|
|
desc.mipLevels = 1;
|
|
desc.arraySize = 1;
|
|
desc.format = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
|
desc.textureType = static_cast<uint32_t>(TextureType::Texture2D);
|
|
desc.sampleCount = 1;
|
|
desc.sampleQuality = 0;
|
|
desc.flags = 0;
|
|
|
|
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
|
ASSERT_NE(texture, nullptr);
|
|
|
|
EXPECT_EQ(texture->GetWidth(), 256);
|
|
EXPECT_EQ(texture->GetHeight(), 256);
|
|
EXPECT_EQ(texture->GetFormat(), Format::R8G8B8A8_UNorm);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_F(D3D12TestFixture, Texture_Create_3D) {
|
|
TextureDesc desc = {};
|
|
desc.width = 64;
|
|
desc.height = 64;
|
|
desc.depth = 64;
|
|
desc.mipLevels = 1;
|
|
desc.arraySize = 1;
|
|
desc.format = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
|
desc.textureType = static_cast<uint32_t>(TextureType::Texture3D);
|
|
desc.sampleCount = 1;
|
|
desc.sampleQuality = 0;
|
|
desc.flags = 0;
|
|
|
|
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
|
ASSERT_NE(texture, nullptr);
|
|
|
|
EXPECT_EQ(texture->GetDepth(), 64);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_F(D3D12TestFixture, Texture_Create_MultipleMips) {
|
|
TextureDesc desc = {};
|
|
desc.width = 512;
|
|
desc.height = 512;
|
|
desc.depth = 1;
|
|
desc.mipLevels = 5;
|
|
desc.arraySize = 1;
|
|
desc.format = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
|
desc.textureType = static_cast<uint32_t>(TextureType::Texture2D);
|
|
desc.sampleCount = 1;
|
|
desc.sampleQuality = 0;
|
|
desc.flags = 0;
|
|
|
|
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
|
ASSERT_NE(texture, nullptr);
|
|
|
|
EXPECT_EQ(texture->GetMipLevels(), 5);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_F(D3D12TestFixture, Texture_Create_Array) {
|
|
TextureDesc desc = {};
|
|
desc.width = 128;
|
|
desc.height = 128;
|
|
desc.depth = 1;
|
|
desc.mipLevels = 1;
|
|
desc.arraySize = 4;
|
|
desc.format = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
|
desc.textureType = static_cast<uint32_t>(TextureType::Texture2DArray);
|
|
desc.sampleCount = 1;
|
|
desc.sampleQuality = 0;
|
|
desc.flags = 0;
|
|
|
|
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
|
ASSERT_NE(texture, nullptr);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
} |