RHI: Add explicit RenderPass abstraction (BeginRenderPass/EndRenderPass)
New abstractions: - RHIFramebuffer: Framebuffer interface with Initialize/Bind/GetHandle - RHIRenderPass: RenderPass interface with AttachmentDesc for load/store actions - D3D12Framebuffer/D3D12RenderPass: D3D12 implementation - OpenGLFramebuffer/OpenGLRenderPass: OpenGL implementation (adapted from existing) RHICommandList changes: - Added BeginRenderPass(RHIRenderPass*, RHIFramebuffer*, Rect, clearValues...) - Added EndRenderPass() Implementation notes: - D3D12: Uses OMSetRenderTargets + ClearRenderTargetView (fallback from native RenderPass API) - OpenGL: Uses glBindFramebuffer + glClearBufferfv for LoadOp handling - Old SetRenderTargets/ClearRenderTarget retained for backward compatibility All 845 tests pass.
This commit is contained in:
38
engine/src/RHI/OpenGL/OpenGLRenderPass.cpp
Normal file
38
engine/src/RHI/OpenGL/OpenGLRenderPass.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "XCEngine/RHI/OpenGL/OpenGLRenderPass.h"
|
||||
|
||||
namespace XCEngine {
|
||||
namespace RHI {
|
||||
|
||||
OpenGLRenderPass::OpenGLRenderPass() {
|
||||
}
|
||||
|
||||
OpenGLRenderPass::~OpenGLRenderPass() {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
void OpenGLRenderPass::Shutdown() {
|
||||
m_colorAttachments.clear();
|
||||
m_colorAttachmentCount = 0;
|
||||
m_hasDepthStencil = false;
|
||||
}
|
||||
|
||||
bool OpenGLRenderPass::Initialize(uint32_t colorAttachmentCount, const AttachmentDesc* colorAttachments,
|
||||
const AttachmentDesc* depthStencilAttachment) {
|
||||
m_colorAttachmentCount = colorAttachmentCount;
|
||||
m_colorAttachments.resize(colorAttachmentCount);
|
||||
for (uint32_t i = 0; i < colorAttachmentCount; ++i) {
|
||||
m_colorAttachments[i] = colorAttachments[i];
|
||||
}
|
||||
|
||||
if (depthStencilAttachment != nullptr) {
|
||||
m_hasDepthStencil = true;
|
||||
m_depthStencilAttachment = *depthStencilAttachment;
|
||||
} else {
|
||||
m_hasDepthStencil = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user