diff --git a/include/boo/graphicsdev/GL.hpp b/include/boo/graphicsdev/GL.hpp index 42e5582..9bb6faa 100644 --- a/include/boo/graphicsdev/GL.hpp +++ b/include/boo/graphicsdev/GL.hpp @@ -63,7 +63,7 @@ public: newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo, - size_t ubufCount, IGraphicsBuffer** ubufs, + size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, ITexture** texs); }; diff --git a/include/boo/graphicsdev/IGraphicsDataFactory.hpp b/include/boo/graphicsdev/IGraphicsDataFactory.hpp index 32fa28a..33ec7b1 100644 --- a/include/boo/graphicsdev/IGraphicsDataFactory.hpp +++ b/include/boo/graphicsdev/IGraphicsDataFactory.hpp @@ -152,6 +152,13 @@ struct IShaderDataBinding {}; struct IGraphicsData {}; class GraphicsDataToken; +/** Used wherever distinction of pipeline stages is needed */ +enum class PipelineStage +{ + Vertex, + Fragment +}; + /** Used by platform shader pipeline constructors */ enum class Primitive { @@ -225,7 +232,7 @@ struct IGraphicsDataFactory newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo, - size_t ubufCount, IGraphicsBuffer** ubufs, + size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, ITexture** texs)=0; @@ -233,11 +240,11 @@ struct IGraphicsDataFactory newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo, - size_t ubufCount, IGraphicsBuffer** ubufs, + size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages, size_t texCount, ITexture** texs) { return newShaderDataBinding(pipeline, vtxFormat, vbo, instVbo, ibo, - ubufCount, ubufs, nullptr, nullptr, texCount, texs); + ubufCount, ubufs, ubufStages, nullptr, nullptr, texCount, texs); } }; diff --git a/include/boo/graphicsdev/Metal.hpp b/include/boo/graphicsdev/Metal.hpp index 8ba6543..60a6fb0 100644 --- a/include/boo/graphicsdev/Metal.hpp +++ b/include/boo/graphicsdev/Metal.hpp @@ -70,7 +70,7 @@ public: newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo, - size_t ubufCount, IGraphicsBuffer** ubufs, + size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, ITexture** texs); }; diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index d9840c9..292bca0 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -655,7 +655,7 @@ IShaderDataBinding* GLDataFactory::Context::newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, IGraphicsBuffer*, IGraphicsBuffer*, IGraphicsBuffer*, - size_t ubufCount, IGraphicsBuffer** ubufs, + size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, ITexture** texs) { diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index 45cf3e2..f9ac89c 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -573,13 +573,13 @@ struct MetalShaderDataBinding : IShaderDataBinding IGraphicsBuffer* m_ibuf; size_t m_ubufCount; std::unique_ptr m_ubufs; - std::vector m_ubufOffs; + std::vector> m_ubufOffs; size_t m_texCount; std::unique_ptr m_texs; MetalShaderDataBinding(MetalContext* ctx, IShaderPipeline* pipeline, IGraphicsBuffer* vbuf, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibuf, - size_t ubufCount, IGraphicsBuffer** ubufs, + size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages, const size_t* ubufOffs, const size_t* ubufSizes, size_t texCount, ITexture** texs) : m_pipeline(static_cast(pipeline)), @@ -600,7 +600,7 @@ struct MetalShaderDataBinding : IShaderDataBinding if (ubufOffs[i] % 256) Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding", int(i)); #endif - m_ubufOffs.push_back(ubufOffs[i]); + m_ubufOffs.push_back({ubufOffs[i], ubufStages && ubufStages[i] == PipelineStage::Fragment}); } } for (size_t i=0 ; im_SBinds.emplace_back(retval); return retval; } diff --git a/test/main.cpp b/test/main.cpp index e2fe60c..e97696f 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -375,7 +375,7 @@ struct TestApplicationCallback : IApplicationCallback /* Make shader data binding */ self->m_binding = - ctx.newShaderDataBinding(pipeline, vfmt, vbo, nullptr, nullptr, 0, nullptr, 1, &texture); + ctx.newShaderDataBinding(pipeline, vfmt, vbo, nullptr, nullptr, 0, nullptr, nullptr, 1, &texture); return true; });