test: Add RHI integration tests and update unit tests
- Add CommandQueue unit tests for WaitForIdle and synchronization - Add SwapChain unit tests for Present and buffer operations - Add Texture unit tests for various texture types and mipmaps - Fix RHIIntegrationFixture with proper logging and debug output - Update minimal integration test with RHI abstraction layer - Add GT reference image for minimal test - Update TEST_SPEC.md documentation
This commit is contained in:
@@ -121,3 +121,215 @@ TEST_P(RHITestFixture, Texture_GetNativeHandle) {
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_Texture1D) {
|
||||
TextureDesc desc = {};
|
||||
desc.width = 512;
|
||||
desc.height = 1;
|
||||
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::Texture1D);
|
||||
desc.sampleCount = 1;
|
||||
desc.sampleQuality = 0;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
EXPECT_EQ(texture->GetWidth(), 512u);
|
||||
EXPECT_EQ(texture->GetHeight(), 1u);
|
||||
EXPECT_EQ(texture->GetTextureType(), TextureType::Texture1D);
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_Texture2DArray) {
|
||||
TextureDesc desc = {};
|
||||
desc.width = 256;
|
||||
desc.height = 256;
|
||||
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;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
EXPECT_EQ(texture->GetWidth(), 256u);
|
||||
EXPECT_EQ(texture->GetHeight(), 256u);
|
||||
EXPECT_EQ(texture->GetTextureType(), TextureType::Texture2DArray);
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_TextureCube) {
|
||||
TextureDesc desc = {};
|
||||
desc.width = 256;
|
||||
desc.height = 256;
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 1;
|
||||
desc.arraySize = 6;
|
||||
desc.format = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
||||
desc.textureType = static_cast<uint32_t>(TextureType::TextureCube);
|
||||
desc.sampleCount = 1;
|
||||
desc.sampleQuality = 0;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
EXPECT_EQ(texture->GetWidth(), 256u);
|
||||
EXPECT_EQ(texture->GetHeight(), 256u);
|
||||
EXPECT_EQ(texture->GetTextureType(), TextureType::TextureCube);
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_TextureCubeArray) {
|
||||
TextureDesc desc = {};
|
||||
desc.width = 256;
|
||||
desc.height = 256;
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 1;
|
||||
desc.arraySize = 12;
|
||||
desc.format = static_cast<uint32_t>(Format::R8G8B8A8_UNorm);
|
||||
desc.textureType = static_cast<uint32_t>(TextureType::TextureCubeArray);
|
||||
desc.sampleCount = 1;
|
||||
desc.sampleQuality = 0;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
EXPECT_EQ(texture->GetWidth(), 256u);
|
||||
EXPECT_EQ(texture->GetHeight(), 256u);
|
||||
EXPECT_EQ(texture->GetTextureType(), TextureType::TextureCubeArray);
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_WithMipMaps) {
|
||||
TextureDesc desc = {};
|
||||
desc.width = 512;
|
||||
desc.height = 512;
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 9;
|
||||
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;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
EXPECT_EQ(texture->GetMipLevels(), 9u);
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_MultipleSamples) {
|
||||
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 = 4;
|
||||
desc.sampleQuality = 0;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Create_DifferentFormats) {
|
||||
Format formats[] = {
|
||||
Format::R8G8B8A8_UNorm,
|
||||
Format::R16G16B16A16_Float,
|
||||
Format::R32_Float,
|
||||
Format::D24_UNorm_S8_UInt,
|
||||
Format::D32_Float
|
||||
};
|
||||
|
||||
for (auto fmt : formats) {
|
||||
TextureDesc desc = {};
|
||||
desc.width = 256;
|
||||
desc.height = 256;
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 1;
|
||||
desc.arraySize = 1;
|
||||
desc.format = static_cast<uint32_t>(fmt);
|
||||
desc.textureType = static_cast<uint32_t>(TextureType::Texture2D);
|
||||
desc.sampleCount = 1;
|
||||
desc.sampleQuality = 0;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
EXPECT_EQ(texture->GetFormat(), fmt);
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_StateTransitions) {
|
||||
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;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
EXPECT_EQ(texture->GetState(), ResourceStates::Common);
|
||||
|
||||
texture->SetState(ResourceStates::RenderTarget);
|
||||
EXPECT_EQ(texture->GetState(), ResourceStates::RenderTarget);
|
||||
|
||||
texture->SetState(ResourceStates::PixelShaderResource);
|
||||
EXPECT_EQ(texture->GetState(), ResourceStates::PixelShaderResource);
|
||||
|
||||
texture->SetState(ResourceStates::CopyDst);
|
||||
EXPECT_EQ(texture->GetState(), ResourceStates::CopyDst);
|
||||
|
||||
texture->SetState(ResourceStates::Common);
|
||||
EXPECT_EQ(texture->GetState(), ResourceStates::Common);
|
||||
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
|
||||
TEST_P(RHITestFixture, Texture_Shutdown_MultipleTimes) {
|
||||
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;
|
||||
|
||||
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
||||
if (texture != nullptr) {
|
||||
texture->Shutdown();
|
||||
texture->Shutdown();
|
||||
delete texture;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user