diff --git a/docs/RHI抽象层设计与实现.md b/docs/RHI抽象层设计与实现.md new file mode 100644 index 00000000..e69de29b diff --git a/engine/include/XCEngine/RHI/OpenGL/OpenGLCommandList.h b/engine/include/XCEngine/RHI/OpenGL/OpenGLCommandList.h index d52eaa32..26a931be 100644 --- a/engine/include/XCEngine/RHI/OpenGL/OpenGLCommandList.h +++ b/engine/include/XCEngine/RHI/OpenGL/OpenGLCommandList.h @@ -2,6 +2,7 @@ #include #include +#include namespace XCEngine { namespace RHI { @@ -17,27 +18,131 @@ enum class PrimitiveType { LineStrip, Triangles, TriangleStrip, - TriangleFan + TriangleFan, + LineListAdj, + TriangleListAdj, + Patch }; +enum class ClearFlag { + Color = 1, + Depth = 2, + Stencil = 4 +}; + +inline ClearFlag operator|(ClearFlag a, ClearFlag b) { + return static_cast(static_cast(a) | static_cast(b)); +} + class OpenGLCommandList { public: OpenGLCommandList(); ~OpenGLCommandList(); void Clear(float r, float g, float b, float a, unsigned int buffers); + void ClearColor(float r, float g, float b, float a); + void ClearDepth(float depth); + void ClearStencil(int stencil); + void ClearDepthStencil(float depth, int stencil); void SetPipelineState(void* pipelineState); void SetVertexBuffer(unsigned int buffer, size_t offset, size_t stride); + void SetVertexBuffers(unsigned int startSlot, unsigned int count, const unsigned int* buffers, const size_t* offsets, const size_t* strides); void SetIndexBuffer(unsigned int buffer, unsigned int type); - - void Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex); - void DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex); + void SetIndexBuffer(unsigned int buffer, unsigned int type, size_t offset); void BindVertexArray(unsigned int vao); + void BindVertexArray(unsigned int vao, unsigned int indexBuffer, unsigned int indexType); void UseShader(unsigned int program); void SetViewport(int x, int y, int width, int height); + void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth); + void SetViewports(unsigned int count, const float* viewports); + void SetScissor(int x, int y, int width, int height); + void SetScissorRects(unsigned int count, const int* rects); + void EnableScissorTest(bool enable); + + void EnableDepthTest(bool enable); + void EnableDepthWrite(bool enable); + void SetDepthFunc(unsigned int func); + void EnableStencilTest(bool enable); + void SetStencilFunc(unsigned int func, int ref, unsigned int mask); + void SetStencilOp(unsigned int fail, unsigned int zfail, unsigned int zpass); + void EnableBlending(bool enable); + void SetBlendFunc(unsigned int src, unsigned int dst); + void SetBlendFuncSeparate(unsigned int srcRGB, unsigned int dstRGB, unsigned int srcAlpha, unsigned int dstAlpha); + void SetBlendEquation(unsigned int mode); + void SetBlendColor(float r, float g, float b, float a); + + void EnableCulling(bool enable); + void SetCullFace(unsigned int face); + void SetFrontFace(unsigned int face); + void SetPolygonMode(unsigned int mode); + void SetPolygonOffset(float factor, float units); + + void SetPrimitiveType(PrimitiveType type); + + void Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex); + void DrawInstanced(PrimitiveType type, unsigned int vertexCount, unsigned int instanceCount, unsigned int startVertex, unsigned int startInstance); + void DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex); + void DrawIndexedInstanced(PrimitiveType type, unsigned int indexCount, unsigned int instanceCount, unsigned int startIndex, int baseVertex, unsigned int startInstance); + void DrawIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride); + void DrawIndexedIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride); + + void MultiDrawArrays(PrimitiveType type, const int* first, const int* count, unsigned int drawCount); + void MultiDrawElements(PrimitiveType type, const int* count, unsigned int type_, const void* const* indices, unsigned int drawCount); + + void Dispatch(unsigned int x, unsigned int y, unsigned int z); + void DispatchIndirect(unsigned int buffer, size_t offset); + void DispatchCompute(unsigned int x, unsigned int y, unsigned int z, unsigned int groupX, unsigned int groupY, unsigned int groupZ); + + void MemoryBarrier(unsigned int barriers); + void TextureBarrier(); + + void BindTexture(unsigned int target, unsigned int unit, unsigned int texture); + void BindTextures(unsigned int first, unsigned int count, const unsigned int* textures); + void BindSampler(unsigned int unit, unsigned int sampler); + void BindSamplers(unsigned int first, unsigned int count, const unsigned int* samplers); + void BindImageTexture(unsigned int unit, unsigned int texture, int level, bool layered, int layer, unsigned int access, unsigned int format); + + void BindBufferBase(unsigned int target, unsigned int index, unsigned int buffer); + void BindBufferRange(unsigned int target, unsigned int index, unsigned int buffer, size_t offset, size_t size); + + void Enable(unsigned int cap); + void Disable(unsigned int cap); + void Enablei(unsigned int cap, unsigned int index); + void Disablei(unsigned int cap, unsigned int index); + + void SetUniform1i(int location, int v); + void SetUniform1f(int location, float v); + void SetUniform2f(int location, float x, float y); + void SetUniform3f(int location, float x, float y, float z); + void SetUniform4f(int location, float x, float y, float z, float w); + void SetUniform1fv(int location, int count, const float* v); + void SetUniform2fv(int location, int count, const float* v); + void SetUniform3fv(int location, int count, const float* v); + void SetUniform4fv(int location, int count, const float* v); + void SetUniformMatrix4fv(int location, int count, bool transpose, const float* v); + + void UseProgram(unsigned int program); + void BindFragDataLocation(unsigned int program, unsigned int colorNumber, const char* name); + void BindFragDataLocationIndexed(unsigned int program, unsigned int colorNumber, unsigned int index, const char* name); + + void BeginQuery(unsigned int target, unsigned int id); + void EndQuery(unsigned int target); + void GetQueryObjectiv(unsigned int id, unsigned int pname, int* params); + void GetQueryObjectuiv(unsigned int id, unsigned int pname, unsigned int* params); + + void ReadPixels(int x, int y, int width, int height, unsigned int format, unsigned int type, void* data); + void BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, unsigned int mask, unsigned int filter); + + void CopyImageSubData(unsigned int srcName, unsigned int srcTarget, int srcLevel, int srcX, int srcY, int srcZ, unsigned int dstName, unsigned int dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int width, int height, int depth); + + void InvalidateFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments); + void InvalidateSubFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments, int x, int y, int width, int height); + + void PushDebugGroup(unsigned int source, unsigned int id, int length, const char* message); + void PopDebugGroup(); private: unsigned int m_primitiveType; diff --git a/engine/src/RHI/OpenGL/OpenGLCommandList.cpp b/engine/src/RHI/OpenGL/OpenGLCommandList.cpp index a4a5be1a..60235cbb 100644 --- a/engine/src/RHI/OpenGL/OpenGLCommandList.cpp +++ b/engine/src/RHI/OpenGL/OpenGLCommandList.cpp @@ -6,34 +6,6 @@ namespace XCEngine { namespace RHI { -OpenGLCommandList::OpenGLCommandList() - : m_primitiveType(GL_TRIANGLES) - , m_currentVAO(0) - , m_currentProgram(0) -{ -} - -OpenGLCommandList::~OpenGLCommandList() { -} - -void OpenGLCommandList::Clear(float r, float g, float b, float a, unsigned int buffers) { - glClearColor(r, g, b, a); - unsigned int glBuffers = 0; - if (buffers & 0x1) glBuffers |= GL_COLOR_BUFFER_BIT; - if (buffers & 0x2) glBuffers |= GL_DEPTH_BUFFER_BIT; - if (buffers & 0x4) glBuffers |= GL_STENCIL_BUFFER_BIT; - glClear(glBuffers); -} - -void OpenGLCommandList::SetPipelineState(void* pipelineState) { -} - -void OpenGLCommandList::SetVertexBuffer(unsigned int buffer, size_t offset, size_t stride) { -} - -void OpenGLCommandList::SetIndexBuffer(unsigned int buffer, unsigned int type) { -} - static unsigned int ToGLPrimitiveType(PrimitiveType type) { switch (type) { case PrimitiveType::Points: return GL_POINTS; @@ -42,18 +14,77 @@ static unsigned int ToGLPrimitiveType(PrimitiveType type) { case PrimitiveType::Triangles: return GL_TRIANGLES; case PrimitiveType::TriangleStrip: return GL_TRIANGLE_STRIP; case PrimitiveType::TriangleFan: return GL_TRIANGLE_FAN; + case PrimitiveType::LineListAdj: return GL_LINES_ADJACENCY; + case PrimitiveType::TriangleListAdj: return GL_TRIANGLES_ADJACENCY; + case PrimitiveType::Patch: return GL_PATCHES; default: return GL_TRIANGLES; } } -void OpenGLCommandList::Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex) { - m_primitiveType = ToGLPrimitiveType(type); - glDrawArrays(m_primitiveType, startVertex, vertexCount); +OpenGLCommandList::OpenGLCommandList() + : m_primitiveType(GL_TRIANGLES) + , m_currentVAO(0) + , m_currentProgram(0) { } -void OpenGLCommandList::DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex) { - m_primitiveType = ToGLPrimitiveType(type); - glDrawElements(m_primitiveType, indexCount, GL_UNSIGNED_INT, (void*)(startIndex * sizeof(unsigned int))); +OpenGLCommandList::~OpenGLCommandList() { +} + +void OpenGLCommandList::Clear(float r, float g, float b, float a, unsigned int buffers) { + glClearColor(r, g, b, a); + unsigned int glBuffers = 0; + if (buffers & 1) glBuffers |= GL_COLOR_BUFFER_BIT; + if (buffers & 2) glBuffers |= GL_DEPTH_BUFFER_BIT; + if (buffers & 4) glBuffers |= GL_STENCIL_BUFFER_BIT; + glClear(glBuffers); +} + +void OpenGLCommandList::ClearColor(float r, float g, float b, float a) { + glClearColor(r, g, b, a); + glClear(GL_COLOR_BUFFER_BIT); +} + +void OpenGLCommandList::ClearDepth(float depth) { + glClearDepth(depth); + glClear(GL_DEPTH_BUFFER_BIT); +} + +void OpenGLCommandList::ClearStencil(int stencil) { + glClearStencil(stencil); + glClear(GL_STENCIL_BUFFER_BIT); +} + +void OpenGLCommandList::ClearDepthStencil(float depth, int stencil) { + glClearDepth(depth); + glClearStencil(stencil); + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); +} + +void OpenGLCommandList::SetPipelineState(void* pipelineState) { +} + +void OpenGLCommandList::SetVertexBuffer(unsigned int buffer, size_t offset, size_t stride) { + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glVertexAttribPointer(0, stride / sizeof(float), GL_FLOAT, GL_FALSE, stride, (void*)offset); + glEnableVertexAttribArray(0); +} + +void OpenGLCommandList::SetVertexBuffers(unsigned int startSlot, unsigned int count, const unsigned int* buffers, const size_t* offsets, const size_t* strides) { + for (unsigned int i = 0; i < count; i++) { + glBindBuffer(GL_ARRAY_BUFFER, buffers[i]); + glEnableVertexAttribArray(startSlot + i); + glVertexAttribPointer(startSlot + i, strides[i] / sizeof(float), GL_FLOAT, GL_FALSE, strides[i], (void*)offsets[i]); + } + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +void OpenGLCommandList::SetIndexBuffer(unsigned int buffer, unsigned int type) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer); +} + +void OpenGLCommandList::SetIndexBuffer(unsigned int buffer, unsigned int type, size_t offset) { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer); + (void)offset; } void OpenGLCommandList::BindVertexArray(unsigned int vao) { @@ -61,6 +92,13 @@ void OpenGLCommandList::BindVertexArray(unsigned int vao) { glBindVertexArray(vao); } +void OpenGLCommandList::BindVertexArray(unsigned int vao, unsigned int indexBuffer, unsigned int indexType) { + m_currentVAO = vao; + glBindVertexArray(vao); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); + (void)indexType; +} + void OpenGLCommandList::UseShader(unsigned int program) { m_currentProgram = program; glUseProgram(program); @@ -70,5 +108,322 @@ void OpenGLCommandList::SetViewport(int x, int y, int width, int height) { glViewport(x, y, width, height); } +void OpenGLCommandList::SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) { + glViewportIndexedf(0, x, y, width, height); + glDepthRange(minDepth, maxDepth); +} + +void OpenGLCommandList::SetViewports(unsigned int count, const float* viewports) { + for (unsigned int i = 0; i < count; i++) { + glViewportIndexedf(i, viewports[i * 6 + 0], viewports[i * 6 + 1], viewports[i * 6 + 2], viewports[i * 6 + 3]); + glDepthRangeIndexed(i, viewports[i * 6 + 4], viewports[i * 6 + 5]); + } +} + +void OpenGLCommandList::SetScissor(int x, int y, int width, int height) { + glScissor(x, y, width, height); +} + +void OpenGLCommandList::SetScissorRects(unsigned int count, const int* rects) { + for (unsigned int i = 0; i < count; i++) { + glScissorIndexed(i, rects[i * 4 + 0], rects[i * 4 + 1], rects[i * 4 + 2], rects[i * 4 + 3]); + } +} + +void OpenGLCommandList::EnableScissorTest(bool enable) { + if (enable) glEnable(GL_SCISSOR_TEST); + else glDisable(GL_SCISSOR_TEST); +} + +void OpenGLCommandList::EnableDepthTest(bool enable) { + if (enable) glEnable(GL_DEPTH_TEST); + else glDisable(GL_DEPTH_TEST); +} + +void OpenGLCommandList::EnableDepthWrite(bool enable) { + glDepthMask(enable ? GL_TRUE : GL_FALSE); +} + +void OpenGLCommandList::SetDepthFunc(unsigned int func) { + glDepthFunc(func); +} + +void OpenGLCommandList::EnableStencilTest(bool enable) { + if (enable) glEnable(GL_STENCIL_TEST); + else glDisable(GL_STENCIL_TEST); +} + +void OpenGLCommandList::SetStencilFunc(unsigned int func, int ref, unsigned int mask) { + glStencilFunc(func, ref, mask); +} + +void OpenGLCommandList::SetStencilOp(unsigned int fail, unsigned int zfail, unsigned int zpass) { + glStencilOp(fail, zfail, zpass); +} + +void OpenGLCommandList::EnableBlending(bool enable) { + if (enable) glEnable(GL_BLEND); + else glDisable(GL_BLEND); +} + +void OpenGLCommandList::SetBlendFunc(unsigned int src, unsigned int dst) { + glBlendFunc(src, dst); +} + +void OpenGLCommandList::SetBlendFuncSeparate(unsigned int srcRGB, unsigned int dstRGB, unsigned int srcAlpha, unsigned int dstAlpha) { + glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void OpenGLCommandList::SetBlendEquation(unsigned int mode) { + glBlendEquation(mode); +} + +void OpenGLCommandList::SetBlendColor(float r, float g, float b, float a) { + glBlendColor(r, g, b, a); +} + +void OpenGLCommandList::EnableCulling(bool enable) { + if (enable) glEnable(GL_CULL_FACE); + else glDisable(GL_CULL_FACE); +} + +void OpenGLCommandList::SetCullFace(unsigned int face) { + glCullFace(face); +} + +void OpenGLCommandList::SetFrontFace(unsigned int face) { + glFrontFace(face); +} + +void OpenGLCommandList::SetPolygonMode(unsigned int mode) { + glPolygonMode(GL_FRONT_AND_BACK, mode); +} + +void OpenGLCommandList::SetPolygonOffset(float factor, float units) { + glPolygonOffset(factor, units); +} + +void OpenGLCommandList::SetPrimitiveType(PrimitiveType type) { + m_primitiveType = ToGLPrimitiveType(type); +} + +void OpenGLCommandList::Draw(PrimitiveType type, unsigned int vertexCount, unsigned int startVertex) { + m_primitiveType = ToGLPrimitiveType(type); + glDrawArrays(m_primitiveType, startVertex, vertexCount); +} + +void OpenGLCommandList::DrawInstanced(PrimitiveType type, unsigned int vertexCount, unsigned int instanceCount, unsigned int startVertex, unsigned int startInstance) { + m_primitiveType = ToGLPrimitiveType(type); + glDrawArraysInstanced(m_primitiveType, startVertex, vertexCount, instanceCount); + (void)startInstance; +} + +void OpenGLCommandList::DrawIndexed(PrimitiveType type, unsigned int indexCount, unsigned int startIndex, int baseVertex) { + m_primitiveType = ToGLPrimitiveType(type); + glDrawElements(m_primitiveType, indexCount, GL_UNSIGNED_INT, (void*)(startIndex * sizeof(unsigned int))); + (void)baseVertex; +} + +void OpenGLCommandList::DrawIndexedInstanced(PrimitiveType type, unsigned int indexCount, unsigned int instanceCount, unsigned int startIndex, int baseVertex, unsigned int startInstance) { + m_primitiveType = ToGLPrimitiveType(type); + glDrawElementsInstanced(m_primitiveType, indexCount, GL_UNSIGNED_INT, (void*)(startIndex * sizeof(unsigned int)), instanceCount); + (void)baseVertex; + (void)startInstance; +} + +void OpenGLCommandList::DrawIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride) { + m_primitiveType = ToGLPrimitiveType(type); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer); + glDrawArraysIndirect(m_primitiveType, (void*)offset); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0); + (void)drawCount; + (void)stride; +} + +void OpenGLCommandList::DrawIndexedIndirect(PrimitiveType type, unsigned int buffer, size_t offset, unsigned int drawCount, unsigned int stride) { + m_primitiveType = ToGLPrimitiveType(type); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer); + glDrawElementsIndirect(m_primitiveType, GL_UNSIGNED_INT, (void*)offset); + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0); + (void)drawCount; + (void)stride; +} + +void OpenGLCommandList::MultiDrawArrays(PrimitiveType type, const int* first, const int* count, unsigned int drawCount) { + m_primitiveType = ToGLPrimitiveType(type); + glMultiDrawArrays(m_primitiveType, first, count, drawCount); +} + +void OpenGLCommandList::MultiDrawElements(PrimitiveType type, const int* count, unsigned int type_, const void* const* indices, unsigned int drawCount) { + m_primitiveType = ToGLPrimitiveType(type); + glMultiDrawElements(m_primitiveType, count, type_, indices, drawCount); +} + +void OpenGLCommandList::Dispatch(unsigned int x, unsigned int y, unsigned int z) { + glDispatchCompute(x, y, z); +} + +void OpenGLCommandList::DispatchIndirect(unsigned int buffer, size_t offset) { + glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, buffer); + glDispatchComputeIndirect((GLintptr)offset); + glBindBuffer(GL_DISPATCH_INDIRECT_BUFFER, 0); +} + +void OpenGLCommandList::DispatchCompute(unsigned int x, unsigned int y, unsigned int z, unsigned int groupX, unsigned int groupY, unsigned int groupZ) { + glDispatchCompute(groupX, groupY, groupZ); + (void)x; + (void)y; + (void)z; +} + +void OpenGLCommandList::MemoryBarrier(unsigned int barriers) { + glMemoryBarrier(barriers); +} + +void OpenGLCommandList::TextureBarrier() { + glTextureBarrier(); +} + +void OpenGLCommandList::BindTexture(unsigned int target, unsigned int unit, unsigned int texture) { + glActiveTexture(GL_TEXTURE0 + unit); + glBindTexture(target, texture); +} + +void OpenGLCommandList::BindTextures(unsigned int first, unsigned int count, const unsigned int* textures) { + glBindTextures(first, count, textures); +} + +void OpenGLCommandList::BindSampler(unsigned int unit, unsigned int sampler) { + glBindSampler(unit, sampler); +} + +void OpenGLCommandList::BindSamplers(unsigned int first, unsigned int count, const unsigned int* samplers) { + glBindSamplers(first, count, samplers); +} + +void OpenGLCommandList::BindImageTexture(unsigned int unit, unsigned int texture, int level, bool layered, int layer, unsigned int access, unsigned int format) { + glBindImageTexture(unit, texture, level, layered ? GL_TRUE : GL_FALSE, layer, access, format); +} + +void OpenGLCommandList::BindBufferBase(unsigned int target, unsigned int index, unsigned int buffer) { + glBindBufferBase(target, index, buffer); +} + +void OpenGLCommandList::BindBufferRange(unsigned int target, unsigned int index, unsigned int buffer, size_t offset, size_t size) { + glBindBufferRange(target, index, buffer, offset, size); +} + +void OpenGLCommandList::Enable(unsigned int cap) { + glEnable(cap); +} + +void OpenGLCommandList::Disable(unsigned int cap) { + glDisable(cap); +} + +void OpenGLCommandList::Enablei(unsigned int cap, unsigned int index) { + glEnablei(cap, index); +} + +void OpenGLCommandList::Disablei(unsigned int cap, unsigned int index) { + glDisablei(cap, index); +} + +void OpenGLCommandList::SetUniform1i(int location, int v) { + glUniform1i(location, v); +} + +void OpenGLCommandList::SetUniform1f(int location, float v) { + glUniform1f(location, v); +} + +void OpenGLCommandList::SetUniform2f(int location, float x, float y) { + glUniform2f(location, x, y); +} + +void OpenGLCommandList::SetUniform3f(int location, float x, float y, float z) { + glUniform3f(location, x, y, z); +} + +void OpenGLCommandList::SetUniform4f(int location, float x, float y, float z, float w) { + glUniform4f(location, x, y, z, w); +} + +void OpenGLCommandList::SetUniform1fv(int location, int count, const float* v) { + glUniform1fv(location, count, v); +} + +void OpenGLCommandList::SetUniform2fv(int location, int count, const float* v) { + glUniform2fv(location, count, v); +} + +void OpenGLCommandList::SetUniform3fv(int location, int count, const float* v) { + glUniform3fv(location, count, v); +} + +void OpenGLCommandList::SetUniform4fv(int location, int count, const float* v) { + glUniform4fv(location, count, v); +} + +void OpenGLCommandList::SetUniformMatrix4fv(int location, int count, bool transpose, const float* v) { + glUniformMatrix4fv(location, count, transpose ? GL_TRUE : GL_FALSE, v); +} + +void OpenGLCommandList::UseProgram(unsigned int program) { + glUseProgram(program); +} + +void OpenGLCommandList::BindFragDataLocation(unsigned int program, unsigned int colorNumber, const char* name) { + glBindFragDataLocation(program, colorNumber, name); +} + +void OpenGLCommandList::BindFragDataLocationIndexed(unsigned int program, unsigned int colorNumber, unsigned int index, const char* name) { + glBindFragDataLocationIndexed(program, colorNumber, index, name); +} + +void OpenGLCommandList::BeginQuery(unsigned int target, unsigned int id) { + glBeginQuery(target, id); +} + +void OpenGLCommandList::EndQuery(unsigned int target) { + glEndQuery(target); +} + +void OpenGLCommandList::GetQueryObjectiv(unsigned int id, unsigned int pname, int* params) { + glGetQueryObjectiv(id, pname, params); +} + +void OpenGLCommandList::GetQueryObjectuiv(unsigned int id, unsigned int pname, unsigned int* params) { + glGetQueryObjectuiv(id, pname, params); +} + +void OpenGLCommandList::ReadPixels(int x, int y, int width, int height, unsigned int format, unsigned int type, void* data) { + glReadPixels(x, y, width, height, format, type, data); +} + +void OpenGLCommandList::BlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, unsigned int mask, unsigned int filter) { + glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); +} + +void OpenGLCommandList::CopyImageSubData(unsigned int srcName, unsigned int srcTarget, int srcLevel, int srcX, int srcY, int srcZ, unsigned int dstName, unsigned int dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int width, int height, int depth) { + glCopyImageSubData(srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, width, height, depth); +} + +void OpenGLCommandList::InvalidateFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments) { + glInvalidateFramebuffer(target, count, attachments); +} + +void OpenGLCommandList::InvalidateSubFramebuffer(unsigned int target, unsigned int count, const unsigned int* attachments, int x, int y, int width, int height) { + glInvalidateSubFramebuffer(target, count, attachments, x, y, width, height); +} + +void OpenGLCommandList::PushDebugGroup(unsigned int source, unsigned int id, int length, const char* message) { + glPushDebugGroup(source, id, length, message); +} + +void OpenGLCommandList::PopDebugGroup() { + glPopDebugGroup(); +} + } // namespace RHI } // namespace XCEngine