fix: RHI单元测试修复与命名规范统一

RHI抽象层测试修复:
- OpenGL Shader: 空描述符正确返回nullptr
- OpenGL Texture: 修复TextureType映射(case 2/3)
- OpenGL Buffer: 设置stride和state支持
- OpenGL Texture: 添加Format和State支持
- OpenGL SwapChain: 修复IsFullscreen硬编码false问题

命名规范统一( snake_case + _test后缀):
- D3D12_Minimal -> d3d12_minimal_test
- D3D12_Triangle -> d3d12_triangle_test
- D3D12_Quad -> d3d12_quad_test
- D3D12_Sphere -> d3d12_sphere_test
- OpenGL_Minimal -> opengl_minimal_test
- OpenGL_Triangle -> opengl_triangle_test
- OpenGL_Quad -> opengl_quad_test
- OpenGL_Sphere -> opengl_sphere_test
- CTest名称去掉_Integration后缀

测试结果: 138个测试中从21个失败减少到16个失败
This commit is contained in:
2026-03-23 20:32:33 +08:00
parent df7764e972
commit bc6b47ffcf
15 changed files with 302 additions and 164 deletions

View File

@@ -349,6 +349,7 @@ RHIBuffer* OpenGLDevice::CreateBuffer(const BufferDesc& desc) {
}
buffer->Initialize(bufferType, desc.size, nullptr, false);
buffer->SetStride(desc.stride);
return buffer;
}
@@ -361,9 +362,12 @@ RHITexture* OpenGLDevice::CreateTexture(const TextureDesc& desc) {
type = OpenGLTextureType::Texture1D;
break;
case 2:
type = OpenGLTextureType::Texture3D;
type = OpenGLTextureType::Texture2DArray;
break;
case 3:
type = OpenGLTextureType::Texture3D;
break;
case 4:
type = OpenGLTextureType::TextureCube;
break;
default:
@@ -372,7 +376,20 @@ RHITexture* OpenGLDevice::CreateTexture(const TextureDesc& desc) {
}
OpenGLFormat format = OpenGLFormat::RGBA8;
switch (desc.format) {
case 1: format = OpenGLFormat::R8; break;
case 2: format = OpenGLFormat::RG8; break;
case 3: format = OpenGLFormat::RGBA8; break;
case 4: format = OpenGLFormat::RGBA16F; break;
case 5: format = OpenGLFormat::RGBA32F; break;
case 6: format = OpenGLFormat::RGBA16F; break;
case 7: format = OpenGLFormat::RGBA32F; break;
case 8: format = OpenGLFormat::Depth24Stencil8; break;
case 9: format = OpenGLFormat::Depth32F; break;
default: format = OpenGLFormat::RGBA8; break;
}
texture->Initialize(type, desc.width, desc.height, desc.depth, desc.mipLevels, format, nullptr);
texture->SetFormat(static_cast<Format>(desc.format));
return texture;
}
@@ -395,13 +412,14 @@ RHICommandQueue* OpenGLDevice::CreateCommandQueue(const CommandQueueDesc& desc)
}
RHIShader* OpenGLDevice::CompileShader(const ShaderCompileDesc& desc) {
auto* shader = new OpenGLShader();
std::wstring filePath = desc.fileName;
if (filePath.empty()) {
return nullptr;
}
auto* shader = new OpenGLShader();
std::string entryPoint(desc.entryPoint.begin(), desc.entryPoint.end());
std::string profile(desc.profile.begin(), desc.profile.end());
if (!filePath.empty()) {
shader->CompileFromFile(filePath.c_str(), entryPoint.c_str(), profile.c_str());
}
shader->CompileFromFile(filePath.c_str(), entryPoint.c_str(), profile.c_str());
return shader;
}

View File

@@ -21,6 +21,7 @@ OpenGLSwapChain::OpenGLSwapChain()
, m_framebufferHeight(0)
, m_vsync(true)
, m_shouldClose(false)
, m_fullscreen(false)
, m_presentMode(PresentMode::VSync) {
}
@@ -146,10 +147,11 @@ void OpenGLSwapChain::Resize(uint32_t width, uint32_t height) {
}
void OpenGLSwapChain::SetFullscreen(bool fullscreen) {
m_fullscreen = fullscreen;
}
bool OpenGLSwapChain::IsFullscreen() const {
return false;
return m_fullscreen;
}
uint32_t OpenGLSwapChain::GetCurrentBackBufferIndex() const {