diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index 829f31f..87c4cd7 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -544,15 +544,16 @@ struct D3D11ShaderDataBinding : IShaderDataBinding IGraphicsBuffer* m_ibuf; size_t m_ubufCount; std::unique_ptr m_ubufs; - std::vector m_ubufFirstConsts; - std::vector m_ubufNumConsts; + std::unique_ptr m_ubufFirstConsts; + std::unique_ptr m_ubufNumConsts; + std::unique_ptr m_pubufs; size_t m_texCount; std::unique_ptr m_texs; D3D11ShaderDataBinding(D3D11Context* ctx, IShaderPipeline* pipeline, IGraphicsBuffer* vbuf, IGraphicsBuffer* instVbuf, 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)), @@ -564,18 +565,24 @@ struct D3D11ShaderDataBinding : IShaderDataBinding m_texCount(texCount), m_texs(new ITexture*[texCount]) { + if (ubufStages) + { + m_pubufs.reset(new bool[ubufCount]); + for (size_t i=0 ; idynamic()) { D3D11GraphicsBufferD* cbuf = static_cast(m_ubufs[i]); @@ -670,13 +679,36 @@ struct D3D11ShaderDataBinding : IShaderDataBinding constBufs[i] = cbuf->m_buf.Get(); } } - ctx->VSSetConstantBuffers1(0, m_ubufCount, constBufs, m_ubufFirstConsts.data(), m_ubufNumConsts.data()); + ctx->VSSetConstantBuffers1(0, m_ubufCount, constBufs, m_ubufFirstConsts.get(), m_ubufNumConsts.get()); + + if (m_pubufs) + { + ID3D11Buffer* constBufs[8] = {}; + for (int i=0 ; i<8 && idynamic()) + { + D3D11GraphicsBufferD* cbuf = static_cast(m_ubufs[i]); + constBufs[i] = cbuf->m_bufs[b].Get(); + } + else + { + D3D11GraphicsBufferS* cbuf = static_cast(m_ubufs[i]); + constBufs[i] = cbuf->m_buf.Get(); + } + } + ctx->PSSetConstantBuffers1(0, m_ubufCount, constBufs, m_ubufFirstConsts.get(), m_ubufNumConsts.get()); + } } else { - ID3D11Buffer* constBufs[8]; + ID3D11Buffer* constBufs[8] = {}; for (int i=0 ; i<8 && idynamic()) { D3D11GraphicsBufferD* cbuf = static_cast(m_ubufs[i]); @@ -689,6 +721,27 @@ struct D3D11ShaderDataBinding : IShaderDataBinding } } ctx->VSSetConstantBuffers(0, m_ubufCount, constBufs); + + if (m_pubufs) + { + ID3D11Buffer* constBufs[8] = {}; + for (int i=0 ; i<8 && idynamic()) + { + D3D11GraphicsBufferD* cbuf = static_cast(m_ubufs[i]); + constBufs[i] = cbuf->m_bufs[b].Get(); + } + else + { + D3D11GraphicsBufferS* cbuf = static_cast(m_ubufs[i]); + constBufs[i] = cbuf->m_buf.Get(); + } + } + ctx->PSSetConstantBuffers(0, m_ubufCount, constBufs); + } } } @@ -1205,13 +1258,13 @@ public: IShaderDataBinding* newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, 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) { D3D11ShaderDataBinding* retval = new D3D11ShaderDataBinding(m_parent.m_ctx, pipeline, vbuf, instVbo, ibuf, - ubufCount, ubufs, ubufOffs, ubufSizes, texCount, texs); + ubufCount, ubufs, ubufStages, ubufOffs, ubufSizes, texCount, texs); static_cast(m_deferredData)->m_SBinds.emplace_back(retval); return retval; } diff --git a/lib/graphicsdev/D3D12.cpp b/lib/graphicsdev/D3D12.cpp index b8afa43..4cd3475 100644 --- a/lib/graphicsdev/D3D12.cpp +++ b/lib/graphicsdev/D3D12.cpp @@ -1634,7 +1634,7 @@ public: IShaderDataBinding* newShaderDataBinding(IShaderPipeline* pipeline, IVertexFormat* vtxFormat, IGraphicsBuffer* vbuf, IGraphicsBuffer* instVbuf, 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) {