Add proper support for IndexType and uint32 indices

This commit is contained in:
SirLynix
2022-04-04 09:02:00 +02:00
parent 66ff6cfa81
commit 9d526741b9
34 changed files with 188 additions and 57 deletions

View File

@@ -37,7 +37,7 @@ namespace Nz
inline void BeginDebugRegion(const std::string_view& regionName, const Color& color);
inline void BindIndexBuffer(GLuint indexBuffer, UInt64 offset = 0);
inline void BindIndexBuffer(GLuint indexBuffer, IndexType indexType, UInt64 offset = 0);
inline void BindPipeline(const OpenGLRenderPipeline* pipeline);
inline void BindShaderBinding(const OpenGLRenderPipelineLayout& pipelineLayout, UInt32 set, const OpenGLShaderBinding* binding);
inline void BindVertexBuffer(UInt32 binding, GLuint vertexBuffer, UInt64 offset = 0);
@@ -122,6 +122,7 @@ namespace Nz
GLuint indexBuffer = 0;
const OpenGLRenderPipeline* pipeline = nullptr;
UInt64 indexBufferOffset;
IndexType indexBufferType;
std::optional<Recti> scissorRegion;
std::optional<Recti> viewportRegion;
std::vector<std::pair<const OpenGLRenderPipelineLayout*, const OpenGLShaderBinding*>> shaderBindings;

View File

@@ -33,10 +33,11 @@ namespace Nz
m_commands.emplace_back(std::move(beginDebugRegion));
}
inline void OpenGLCommandBuffer::BindIndexBuffer(GLuint indexBuffer, UInt64 offset)
inline void OpenGLCommandBuffer::BindIndexBuffer(GLuint indexBuffer, IndexType indexType, UInt64 offset)
{
m_currentStates.indexBuffer = indexBuffer;
m_currentStates.indexBufferOffset = offset;
m_currentStates.indexBufferType = indexType;
}
inline void OpenGLCommandBuffer::BindPipeline(const OpenGLRenderPipeline* pipeline)

View File

@@ -26,7 +26,7 @@ namespace Nz
void BeginDebugRegion(const std::string_view& regionName, const Color& color) override;
void BeginRenderPass(const Framebuffer& framebuffer, const RenderPass& renderPass, const Recti& renderRect, const ClearValues* clearValues, std::size_t clearValueCount) override;
void BindIndexBuffer(const RenderBuffer& indexBuffer, UInt64 offset = 0) override;
void BindIndexBuffer(const RenderBuffer& indexBuffer, IndexType indexType, UInt64 offset = 0) override;
void BindPipeline(const RenderPipeline& pipeline) override;
void BindShaderBinding(UInt32 set, const ShaderBinding& binding) override;
void BindShaderBinding(const RenderPipelineLayout& pipelineLayout, UInt32 set, const ShaderBinding& binding) override;

View File

@@ -34,6 +34,7 @@ namespace Nz
inline GLenum ToOpenGL(FaceFilling filling);
inline GLenum ToOpenGL(FaceSide side);
inline GLenum ToOpenGL(FrontFace face);
inline GLenum ToOpenGL(IndexType indexType);
inline GLenum ToOpenGL(PrimitiveMode primitiveMode);
inline GLenum ToOpenGL(SamplerFilter filter);
inline GLenum ToOpenGL(SamplerFilter minFilter, SamplerMipmapMode mipmapFilter);

View File

@@ -120,6 +120,19 @@ namespace Nz
return {};
}
inline GLenum ToOpenGL(IndexType indexType)
{
switch (indexType)
{
case IndexType::U8: return GL_UNSIGNED_BYTE;
case IndexType::U16: return GL_UNSIGNED_SHORT;
case IndexType::U32: return GL_UNSIGNED_INT;
}
NazaraError("Unhandled IndexType 0x" + NumberToString(UnderlyingCast(indexType), 16));
return {};
}
inline GLenum ToOpenGL(PrimitiveMode primitiveMode)
{
switch (primitiveMode)