- Fix D3D12Texture::GetTextureType() to return correct type based on D3D12 resource dimension - Fix OpenGL CommandQueue::Signal() to properly call fence->Signal() - Fix OpenGL CommandQueue::GetTimestampFrequency() using GL_TIMESTAMP - Fix OpenGL Device::GetNativeDevice() to return m_hglrc - Fix OpenGL Fence::Signal() to create GL sync object and update completedValue - Fix OpenGL Fence::Wait() to properly wait for fence - Fix OpenGL Fence::GetNativeHandle() to create sync on first call - Fix OpenGL SwapChain::GetCurrentBackBuffer() to return backbuffer texture - Fix OpenGL SwapChain::Initialize() to create backbuffer texture - Fix OpenGL SwapChain::Shutdown() to cleanup backbuffer texture - Fix RHI unit tests: add missing sampleCount/sampleQuality/depth/arraySize fields - Fix RHI unit tests: add complete TextureDesc fields where needed
124 lines
3.5 KiB
C++
124 lines
3.5 KiB
C++
#include "fixtures/RHITestFixture.h"
|
|
#include "XCEngine/RHI/RHITexture.h"
|
|
|
|
using namespace XCEngine::RHI;
|
|
|
|
TEST_P(RHITestFixture, Texture_Create_Texture2D) {
|
|
TextureDesc desc = {};
|
|
desc.width = 512;
|
|
desc.height = 512;
|
|
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(), 512u);
|
|
EXPECT_EQ(texture->GetHeight(), 512u);
|
|
EXPECT_EQ(texture->GetDepth(), 1u);
|
|
EXPECT_EQ(texture->GetMipLevels(), 1u);
|
|
EXPECT_EQ(texture->GetFormat(), Format::R8G8B8A8_UNorm);
|
|
EXPECT_EQ(texture->GetTextureType(), TextureType::Texture2D);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, Texture_Create_Texture3D) {
|
|
TextureDesc desc = {};
|
|
desc.width = 64;
|
|
desc.height = 64;
|
|
desc.depth = 64;
|
|
desc.mipLevels = 1;
|
|
desc.format = static_cast<uint32_t>(Format::R16_Float);
|
|
desc.textureType = static_cast<uint32_t>(TextureType::Texture3D);
|
|
desc.sampleCount = 1;
|
|
desc.sampleQuality = 0;
|
|
|
|
RHITexture* texture = GetDevice()->CreateTexture(desc);
|
|
ASSERT_NE(texture, nullptr);
|
|
|
|
EXPECT_EQ(texture->GetWidth(), 64u);
|
|
EXPECT_EQ(texture->GetHeight(), 64u);
|
|
EXPECT_EQ(texture->GetDepth(), 64u);
|
|
EXPECT_EQ(texture->GetTextureType(), TextureType::Texture3D);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, Texture_StateManagement) {
|
|
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->GetState(), ResourceStates::Common);
|
|
texture->SetState(ResourceStates::RenderTarget);
|
|
EXPECT_EQ(texture->GetState(), ResourceStates::RenderTarget);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, Texture_Naming) {
|
|
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);
|
|
|
|
texture->SetName("TestTexture");
|
|
EXPECT_EQ(texture->GetName(), "TestTexture");
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|
|
|
|
TEST_P(RHITestFixture, Texture_GetNativeHandle) {
|
|
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_NE(texture->GetNativeHandle(), nullptr);
|
|
|
|
texture->Shutdown();
|
|
delete texture;
|
|
}
|