feat(RHI): 实现 RHICommandList 抽象基类
This commit is contained in:
@@ -425,5 +425,90 @@ void OpenGLCommandList::PopDebugGroup() {
|
||||
glPopDebugGroup();
|
||||
}
|
||||
|
||||
void OpenGLCommandList::Shutdown() {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::Reset() {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::Close() {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::TransitionBarrier(void* resource, ResourceStates stateBefore, ResourceStates stateAfter) {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetViewport(const Viewport& viewport) {
|
||||
glViewport(static_cast<int>(viewport.topLeftX), static_cast<int>(viewport.topLeftY),
|
||||
static_cast<int>(viewport.width), static_cast<int>(viewport.height));
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetViewports(uint32_t count, const Viewport* viewports) {
|
||||
std::vector<float> viewportsGL(count * 6);
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
viewportsGL[i * 6 + 0] = viewports[i].topLeftX;
|
||||
viewportsGL[i * 6 + 1] = viewports[i].topLeftY;
|
||||
viewportsGL[i * 6 + 2] = viewports[i].width;
|
||||
viewportsGL[i * 6 + 3] = viewports[i].height;
|
||||
viewportsGL[i * 6 + 4] = viewports[i].minDepth;
|
||||
viewportsGL[i * 6 + 5] = viewports[i].maxDepth;
|
||||
}
|
||||
glViewportArrayv(0, count, viewportsGL.data());
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetScissorRect(const Rect& rect) {
|
||||
glScissor(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetScissorRects(uint32_t count, const Rect* rects) {
|
||||
std::vector<int> scissorGL(count * 4);
|
||||
for (uint32_t i = 0; i < count; ++i) {
|
||||
scissorGL[i * 4 + 0] = rects[i].left;
|
||||
scissorGL[i * 4 + 1] = rects[i].top;
|
||||
scissorGL[i * 4 + 2] = rects[i].right - rects[i].left;
|
||||
scissorGL[i * 4 + 3] = rects[i].bottom - rects[i].top;
|
||||
}
|
||||
glScissorArrayv(0, count, scissorGL.data());
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetRenderTargets(uint32_t count, void** renderTargets, void* depthStencil) {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::ClearRenderTarget(void* renderTarget, const float color[4]) {
|
||||
glClearColor(color[0], color[1], color[2], color[3]);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void OpenGLCommandList::ClearDepthStencil(void* depthStencil, float depth, uint8_t stencil) {
|
||||
glClearDepth(depth);
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetPipelineState(void* pipelineState) {
|
||||
if (pipelineState) {
|
||||
UseShader(reinterpret_cast<uintptr_t>(pipelineState));
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetVertexBuffer(uint32_t slot, void* buffer, uint64_t offset, uint32_t stride) {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetVertexBuffers(uint32_t startSlot, uint32_t count, const uint64_t* buffers, const uint64_t* offsets, const uint32_t* strides) {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::SetIndexBuffer(void* buffer, uint64_t offset, Format format) {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::CopyResource(void* dst, void* src) {
|
||||
}
|
||||
|
||||
void OpenGLCommandList::Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t startVertex, uint32_t startInstance) {
|
||||
glDrawArraysInstanced(GL_TRIANGLES, static_cast<GLint>(startVertex), static_cast<GLsizei>(vertexCount), static_cast<GLsizei>(instanceCount));
|
||||
}
|
||||
|
||||
void OpenGLCommandList::DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t startIndex, int32_t baseVertex, uint32_t startInstance) {
|
||||
glDrawElementsInstanced(GL_TRIANGLES, static_cast<GLsizei>(indexCount), GL_UNSIGNED_INT,
|
||||
reinterpret_cast<const void*>(startIndex * sizeof(GLuint)), static_cast<GLsizei>(instanceCount));
|
||||
}
|
||||
|
||||
} // namespace RHI
|
||||
} // namespace XCEngine
|
||||
|
||||
Reference in New Issue
Block a user