diff --git a/include/boo/graphicsdev/GL.hpp b/include/boo/graphicsdev/GL.hpp index 0e0ef09..b98d893 100644 --- a/include/boo/graphicsdev/GL.hpp +++ b/include/boo/graphicsdev/GL.hpp @@ -20,8 +20,8 @@ public: GLDataFactory(IGraphicsContext* parent); ~GLDataFactory() {} - Platform platform() const {return PlatformOGLES3;} - const char* platformName() const {return "OpenGL ES 3.0";} + Platform platform() const {return PlatformOGL;} + const char* platformName() const {return "OpenGL";} IGraphicsBufferS* newStaticBuffer(BufferUse use, const void* data, size_t stride, size_t count); IGraphicsBufferD* newDynamicBuffer(BufferUse use, size_t stride, size_t count); diff --git a/include/boo/graphicsdev/IGraphicsDataFactory.hpp b/include/boo/graphicsdev/IGraphicsDataFactory.hpp index 5eefa3c..4e852df 100644 --- a/include/boo/graphicsdev/IGraphicsDataFactory.hpp +++ b/include/boo/graphicsdev/IGraphicsDataFactory.hpp @@ -156,7 +156,7 @@ struct IGraphicsDataFactory enum Platform { PlatformNull, - PlatformOGLES3, + PlatformOGL, PlatformD3D11, PlatformD3D12, PlatformMetal, diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index 4586991..eab584a 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -14,12 +14,12 @@ static LogVisor::LogModule Log("boo::GL"); struct GLData : IGraphicsData { std::vector> m_SPs; - std::vector> m_SBinds; + std::vector> m_SBinds; std::vector> m_SBufs; std::vector> m_DBufs; std::vector> m_STexs; std::vector> m_DTexs; - std::vector> m_VFmts; + std::vector> m_VFmts; }; static const GLenum USE_TABLE[] = @@ -351,32 +351,32 @@ IShaderPipeline* GLDataFactory::newShaderPipeline return retval; } -struct GLES3VertexFormat : IVertexFormat +struct GLVertexFormat : IVertexFormat { GLCommandQueue* m_q; GLuint m_vao = 0; size_t m_elementCount; std::unique_ptr m_elements; - GLES3VertexFormat(GLCommandQueue* q, size_t elementCount, + GLVertexFormat(GLCommandQueue* q, size_t elementCount, const VertexElementDescriptor* elements); - ~GLES3VertexFormat(); + ~GLVertexFormat(); void bind() const {glBindVertexArray(m_vao);} }; -struct GLES3ShaderDataBinding : IShaderDataBinding +struct GLShaderDataBinding : IShaderDataBinding { const GLShaderPipeline* m_pipeline; - const GLES3VertexFormat* m_vtxFormat; + const GLVertexFormat* m_vtxFormat; size_t m_ubufCount; std::unique_ptr m_ubufs; size_t m_texCount; std::unique_ptr m_texs; - GLES3ShaderDataBinding(IShaderPipeline* pipeline, + GLShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, size_t ubufCount, IGraphicsBuffer** ubufs, size_t texCount, ITexture** texs) : m_pipeline(static_cast(pipeline)), - m_vtxFormat(static_cast(vtxFormat)), + m_vtxFormat(static_cast(vtxFormat)), m_ubufCount(ubufCount), m_ubufs(new IGraphicsBuffer*[ubufCount]), m_texCount(texCount), @@ -416,8 +416,8 @@ GLDataFactory::newShaderDataBinding(IShaderPipeline* pipeline, size_t ubufCount, IGraphicsBuffer** ubufs, size_t texCount, ITexture** texs) { - GLES3ShaderDataBinding* retval = - new GLES3ShaderDataBinding(pipeline, vtxFormat, ubufCount, ubufs, texCount, texs); + GLShaderDataBinding* retval = + new GLShaderDataBinding(pipeline, vtxFormat, ubufCount, ubufs, texCount, texs); static_cast(m_deferredData)->m_SBinds.emplace_back(retval); return retval; } @@ -436,6 +436,10 @@ IGraphicsData* GLDataFactory::commit() IGraphicsData* retval = m_deferredData; m_deferredData = new struct GLData(); m_committedData.insert(retval); + /* Let's go ahead and flush to ensure our data gets to the GPU + While this isn't strictly required, some drivers might behave + differently */ + glFlush(); return retval; } @@ -482,7 +486,7 @@ static const GLenum SEMANTIC_TYPE_TABLE[] = struct GLCommandQueue : IGraphicsCommandQueue { - Platform platform() const {return IGraphicsDataFactory::PlatformOGLES3;} + Platform platform() const {return IGraphicsDataFactory::PlatformOGL;} const char* platformName() const {return "OpenGL ES 3.0";} IGraphicsContext* m_parent = nullptr; @@ -533,12 +537,12 @@ struct GLCommandQueue : IGraphicsCommandQueue std::thread m_thr; /* These members are locked for multithreaded access */ - std::vector m_pendingFmtAdds; + std::vector m_pendingFmtAdds; std::vector m_pendingFmtDels; std::vector m_pendingFboAdds; std::vector m_pendingFboDels; - static void ConfigureVertexFormat(GLES3VertexFormat* fmt) + static void ConfigureVertexFormat(GLVertexFormat* fmt) { glGenVertexArrays(1, &fmt->m_vao); @@ -607,7 +611,7 @@ struct GLCommandQueue : IGraphicsCommandQueue self->m_drawBuf = self->m_completeBuf; if (self->m_pendingFmtAdds.size()) - for (GLES3VertexFormat* fmt : self->m_pendingFmtAdds) + for (GLVertexFormat* fmt : self->m_pendingFmtAdds) ConfigureVertexFormat(fmt); self->m_pendingFmtAdds.clear(); @@ -633,7 +637,7 @@ struct GLCommandQueue : IGraphicsCommandQueue switch (cmd.m_op) { case Command::OpSetShaderDataBinding: - static_cast(cmd.binding)->bind(); + static_cast(cmd.binding)->bind(); break; case Command::OpSetRenderTarget: { @@ -781,13 +785,13 @@ struct GLCommandQueue : IGraphicsCommandQueue cmds.emplace_back(Command::OpPresent); } - void addVertexFormat(GLES3VertexFormat* fmt) + void addVertexFormat(GLVertexFormat* fmt) { std::unique_lock lk(m_mt); m_pendingFmtAdds.push_back(fmt); } - void delVertexFormat(GLES3VertexFormat* fmt) + void delVertexFormat(GLVertexFormat* fmt) { std::unique_lock lk(m_mt); m_pendingFmtDels.push_back(fmt->m_vao); @@ -881,7 +885,7 @@ GLDataFactory::newDynamicTexture(size_t width, size_t height, TextureFormat fmt) return retval; } -GLES3VertexFormat::GLES3VertexFormat(GLCommandQueue* q, size_t elementCount, +GLVertexFormat::GLVertexFormat(GLCommandQueue* q, size_t elementCount, const VertexElementDescriptor* elements) : m_q(q), m_elementCount(elementCount), @@ -891,13 +895,13 @@ GLES3VertexFormat::GLES3VertexFormat(GLCommandQueue* q, size_t elementCount, m_elements[i] = elements[i]; m_q->addVertexFormat(this); } -GLES3VertexFormat::~GLES3VertexFormat() {m_q->delVertexFormat(this);} +GLVertexFormat::~GLVertexFormat() {m_q->delVertexFormat(this);} IVertexFormat* GLDataFactory::newVertexFormat (size_t elementCount, const VertexElementDescriptor* elements) { GLCommandQueue* q = static_cast(m_parent->getCommandQueue()); - GLES3VertexFormat* retval = new struct GLES3VertexFormat(q, elementCount, elements); + GLVertexFormat* retval = new struct GLVertexFormat(q, elementCount, elements); static_cast(m_deferredData)->m_VFmts.emplace_back(retval); return retval; } diff --git a/test/main.cpp b/test/main.cpp index c5e89da..ab0f226 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -205,7 +205,7 @@ struct TestApplicationCallback : IApplicationCallback {{-0.5,-0.5},{0.0,0.0}} }; IGraphicsBuffer* vbo = - factory->newStaticBuffer(BufferUseVertex, quad, sizeof(quad), 4); + factory->newStaticBuffer(BufferUseVertex, quad, sizeof(Vert), 4); /* Make vertex format */ VertexElementDescriptor descs[2] = @@ -289,6 +289,7 @@ struct TestApplicationCallback : IApplicationCallback size_t frameIdx = 0; size_t lastCheck = 0; + gfxQ->setViewport({{0, 0}, {640, 480}}); while (running) { mainWindow->waitForRetrace();