mirror of https://github.com/AxioDL/boo.git
Metal extension shader support
This commit is contained in:
parent
54ae8c2b1a
commit
4a2c32c2a9
|
@ -63,7 +63,7 @@ public:
|
||||||
newShaderDataBinding(IShaderPipeline* pipeline,
|
newShaderDataBinding(IShaderPipeline* pipeline,
|
||||||
IVertexFormat* vtxFormat,
|
IVertexFormat* vtxFormat,
|
||||||
IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo,
|
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,
|
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||||
size_t texCount, ITexture** texs);
|
size_t texCount, ITexture** texs);
|
||||||
};
|
};
|
||||||
|
|
|
@ -152,6 +152,13 @@ struct IShaderDataBinding {};
|
||||||
struct IGraphicsData {};
|
struct IGraphicsData {};
|
||||||
class GraphicsDataToken;
|
class GraphicsDataToken;
|
||||||
|
|
||||||
|
/** Used wherever distinction of pipeline stages is needed */
|
||||||
|
enum class PipelineStage
|
||||||
|
{
|
||||||
|
Vertex,
|
||||||
|
Fragment
|
||||||
|
};
|
||||||
|
|
||||||
/** Used by platform shader pipeline constructors */
|
/** Used by platform shader pipeline constructors */
|
||||||
enum class Primitive
|
enum class Primitive
|
||||||
{
|
{
|
||||||
|
@ -225,7 +232,7 @@ struct IGraphicsDataFactory
|
||||||
newShaderDataBinding(IShaderPipeline* pipeline,
|
newShaderDataBinding(IShaderPipeline* pipeline,
|
||||||
IVertexFormat* vtxFormat,
|
IVertexFormat* vtxFormat,
|
||||||
IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo,
|
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,
|
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||||
size_t texCount, ITexture** texs)=0;
|
size_t texCount, ITexture** texs)=0;
|
||||||
|
|
||||||
|
@ -233,11 +240,11 @@ struct IGraphicsDataFactory
|
||||||
newShaderDataBinding(IShaderPipeline* pipeline,
|
newShaderDataBinding(IShaderPipeline* pipeline,
|
||||||
IVertexFormat* vtxFormat,
|
IVertexFormat* vtxFormat,
|
||||||
IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo,
|
IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo,
|
||||||
size_t ubufCount, IGraphicsBuffer** ubufs,
|
size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages,
|
||||||
size_t texCount, ITexture** texs)
|
size_t texCount, ITexture** texs)
|
||||||
{
|
{
|
||||||
return newShaderDataBinding(pipeline, vtxFormat, vbo, instVbo, ibo,
|
return newShaderDataBinding(pipeline, vtxFormat, vbo, instVbo, ibo,
|
||||||
ubufCount, ubufs, nullptr, nullptr, texCount, texs);
|
ubufCount, ubufs, ubufStages, nullptr, nullptr, texCount, texs);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
newShaderDataBinding(IShaderPipeline* pipeline,
|
newShaderDataBinding(IShaderPipeline* pipeline,
|
||||||
IVertexFormat* vtxFormat,
|
IVertexFormat* vtxFormat,
|
||||||
IGraphicsBuffer* vbo, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibo,
|
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,
|
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||||
size_t texCount, ITexture** texs);
|
size_t texCount, ITexture** texs);
|
||||||
};
|
};
|
||||||
|
|
|
@ -655,7 +655,7 @@ IShaderDataBinding*
|
||||||
GLDataFactory::Context::newShaderDataBinding(IShaderPipeline* pipeline,
|
GLDataFactory::Context::newShaderDataBinding(IShaderPipeline* pipeline,
|
||||||
IVertexFormat* vtxFormat,
|
IVertexFormat* vtxFormat,
|
||||||
IGraphicsBuffer*, IGraphicsBuffer*, IGraphicsBuffer*,
|
IGraphicsBuffer*, IGraphicsBuffer*, IGraphicsBuffer*,
|
||||||
size_t ubufCount, IGraphicsBuffer** ubufs,
|
size_t ubufCount, IGraphicsBuffer** ubufs, const PipelineStage* ubufStages,
|
||||||
const size_t* ubufOffs, const size_t* ubufSizes,
|
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||||
size_t texCount, ITexture** texs)
|
size_t texCount, ITexture** texs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -573,13 +573,13 @@ struct MetalShaderDataBinding : IShaderDataBinding
|
||||||
IGraphicsBuffer* m_ibuf;
|
IGraphicsBuffer* m_ibuf;
|
||||||
size_t m_ubufCount;
|
size_t m_ubufCount;
|
||||||
std::unique_ptr<IGraphicsBuffer*[]> m_ubufs;
|
std::unique_ptr<IGraphicsBuffer*[]> m_ubufs;
|
||||||
std::vector<size_t> m_ubufOffs;
|
std::vector<std::pair<size_t, bool>> m_ubufOffs;
|
||||||
size_t m_texCount;
|
size_t m_texCount;
|
||||||
std::unique_ptr<ITexture*[]> m_texs;
|
std::unique_ptr<ITexture*[]> m_texs;
|
||||||
MetalShaderDataBinding(MetalContext* ctx,
|
MetalShaderDataBinding(MetalContext* ctx,
|
||||||
IShaderPipeline* pipeline,
|
IShaderPipeline* pipeline,
|
||||||
IGraphicsBuffer* vbuf, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibuf,
|
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,
|
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||||
size_t texCount, ITexture** texs)
|
size_t texCount, ITexture** texs)
|
||||||
: m_pipeline(static_cast<MetalShaderPipeline*>(pipeline)),
|
: m_pipeline(static_cast<MetalShaderPipeline*>(pipeline)),
|
||||||
|
@ -600,7 +600,7 @@ struct MetalShaderDataBinding : IShaderDataBinding
|
||||||
if (ubufOffs[i] % 256)
|
if (ubufOffs[i] % 256)
|
||||||
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding", int(i));
|
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding", int(i));
|
||||||
#endif
|
#endif
|
||||||
m_ubufOffs.push_back(ubufOffs[i]);
|
m_ubufOffs.push_back({ubufOffs[i], ubufStages && ubufStages[i] == PipelineStage::Fragment});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i=0 ; i<ubufCount ; ++i)
|
for (size_t i=0 ; i<ubufCount ; ++i)
|
||||||
|
@ -630,7 +630,10 @@ struct MetalShaderDataBinding : IShaderDataBinding
|
||||||
[enc setVertexBuffer:GetBufferGPUResource(m_instVbo, b) offset:0 atIndex:1];
|
[enc setVertexBuffer:GetBufferGPUResource(m_instVbo, b) offset:0 atIndex:1];
|
||||||
if (m_ubufOffs.size())
|
if (m_ubufOffs.size())
|
||||||
for (size_t i=0 ; i<m_ubufCount ; ++i)
|
for (size_t i=0 ; i<m_ubufCount ; ++i)
|
||||||
[enc setVertexBuffer:GetBufferGPUResource(m_ubufs[i], b) offset:m_ubufOffs[i] atIndex:i+2];
|
if (m_ubufOffs[i].second)
|
||||||
|
[enc setFragmentBuffer:GetBufferGPUResource(m_ubufs[i], b) offset:m_ubufOffs[i].first atIndex:i+2];
|
||||||
|
else
|
||||||
|
[enc setVertexBuffer:GetBufferGPUResource(m_ubufs[i], b) offset:m_ubufOffs[i].first atIndex:i+2];
|
||||||
else
|
else
|
||||||
for (size_t i=0 ; i<m_ubufCount ; ++i)
|
for (size_t i=0 ; i<m_ubufCount ; ++i)
|
||||||
[enc setVertexBuffer:GetBufferGPUResource(m_ubufs[i], b) offset:0 atIndex:i+2];
|
[enc setVertexBuffer:GetBufferGPUResource(m_ubufs[i], b) offset:0 atIndex:i+2];
|
||||||
|
@ -1056,13 +1059,13 @@ IShaderDataBinding*
|
||||||
MetalDataFactory::Context::newShaderDataBinding(IShaderPipeline* pipeline,
|
MetalDataFactory::Context::newShaderDataBinding(IShaderPipeline* pipeline,
|
||||||
IVertexFormat* vtxFormat,
|
IVertexFormat* vtxFormat,
|
||||||
IGraphicsBuffer* vbuf, IGraphicsBuffer* instVbo, IGraphicsBuffer* ibuf,
|
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,
|
const size_t* ubufOffs, const size_t* ubufSizes,
|
||||||
size_t texCount, ITexture** texs)
|
size_t texCount, ITexture** texs)
|
||||||
{
|
{
|
||||||
MetalShaderDataBinding* retval =
|
MetalShaderDataBinding* retval =
|
||||||
new MetalShaderDataBinding(m_parent.m_ctx, pipeline, vbuf, instVbo, ibuf,
|
new MetalShaderDataBinding(m_parent.m_ctx, pipeline, vbuf, instVbo, ibuf,
|
||||||
ubufCount, ubufs, ubufOffs, ubufSizes, texCount, texs);
|
ubufCount, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs);
|
||||||
m_deferredData->m_SBinds.emplace_back(retval);
|
m_deferredData->m_SBinds.emplace_back(retval);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,7 +375,7 @@ struct TestApplicationCallback : IApplicationCallback
|
||||||
|
|
||||||
/* Make shader data binding */
|
/* Make shader data binding */
|
||||||
self->m_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;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue