diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2018-05-29 04:16:33 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2018-05-29 04:16:33 +0000 |
| commit | 60e2802464102539b3e0302aa899e22b43b97c0b (patch) | |
| tree | 5a7f854bdcc4ac9d2da616060d33d60816e99965 /Graphics | |
| parent | Fixed issue with storage buffer not being bound through UAV in Vulkan; fixed ... (diff) | |
| download | DiligentCore-60e2802464102539b3e0302aa899e22b43b97c0b.tar.gz DiligentCore-60e2802464102539b3e0302aa899e22b43b97c0b.zip | |
Moved vertex buffer stride definition from IDeviceContext::SetVertexBuffers() to vertex layout description
Diffstat (limited to 'Graphics')
16 files changed, 85 insertions, 54 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 29bd2398..8e238bc7 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -49,12 +49,7 @@ struct VertexStreamInfo { /// Strong reference to the buffer object RefCntAutoPtr<IBuffer> pBuffer; - Uint32 Stride; ///< Stride in bytes - Uint32 Offset; ///< Offset in bytes - VertexStreamInfo() : - Stride( 0 ), - Offset( 0 ) - {} + Uint32 Offset = 0; ///< Offset in bytes }; /// Base implementation of the device context. @@ -89,7 +84,7 @@ public: /// Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and /// caches references to the buffers. - inline virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override = 0; + inline virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags )override = 0; inline virtual void InvalidateState()override = 0; @@ -204,7 +199,7 @@ protected: template<typename BaseInterface> -inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags ) +inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) { if( StartSlot >= MaxBufferSlots ) { @@ -230,7 +225,6 @@ inline void DeviceContextBase<BaseInterface> :: SetVertexBuffers( Uint32 StartSl { auto &CurrStream = m_VertexStreams[StartSlot + Buff]; CurrStream.pBuffer = RefCntAutoPtr<IBuffer>( ppBuffers ? ppBuffers[Buff] : nullptr ); - CurrStream.Stride = pStrides ? pStrides[Buff] : 0; CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0; #ifdef DEBUG_CHECKS if( CurrStream.pBuffer ) @@ -558,7 +552,6 @@ inline void DeviceContextBase<BaseInterface> :: ClearStateCache() { VERIFY(m_VertexStreams[stream].pBuffer == nullptr, "Unexpected non-null buffer"); VERIFY(m_VertexStreams[stream].Offset == 0, "Unexpected non-zero offset"); - VERIFY(m_VertexStreams[stream].Stride == 0, "Unexpected non-zero stride"); } #endif m_NumVertexStreams = 0; diff --git a/Graphics/GraphicsEngine/include/PipelineStateBase.h b/Graphics/GraphicsEngine/include/PipelineStateBase.h index 7348c32c..22c805f3 100644 --- a/Graphics/GraphicsEngine/include/PipelineStateBase.h +++ b/Graphics/GraphicsEngine/include/PipelineStateBase.h @@ -26,6 +26,7 @@ /// \file /// Implementation of the Diligent::PipelineStateBase template class +#include <array> #include "PipelineState.h" #include "DeviceObjectBase.h" #include "STDAllocator.h" @@ -110,19 +111,21 @@ public: this->m_Desc.GraphicsPipeline.InputLayout.LayoutElements = m_LayoutElements.data(); // Correct description and compute offsets and tight strides + decltype(m_Strides) TightStrides = {}; for( auto It = m_LayoutElements.begin(); It != m_LayoutElements.end(); ++It ) { if( It->ValueType == VT_FLOAT32 || It->ValueType == VT_FLOAT16 ) It->IsNormalized = false; // Floating point values cannot be normalized auto BuffSlot = It->BufferSlot; - if( BuffSlot >= _countof(m_TightStrides) ) + if( BuffSlot >= m_Strides.size() ) { - UNEXPECTED("Buffer slot (", BuffSlot, ") exceeds the limit (", _countof(m_TightStrides), ")"); + UNEXPECTED("Buffer slot (", BuffSlot, ") exceeds the limit (", m_Strides.size(), ")"); continue; } + m_BufferSlotsUsed = std::max(m_BufferSlotsUsed, BuffSlot + 1); - auto &CurrStride = m_TightStrides[BuffSlot]; + auto &CurrStride = TightStrides[BuffSlot]; if( It->RelativeOffset < CurrStride ) { if( It->RelativeOffset == 0 ) @@ -131,8 +134,31 @@ public: UNEXPECTED( "Overlapping layout elements" ); } + if(It->Stride != 0) + { + if(m_Strides[BuffSlot] != 0) + { + VERIFY(m_Strides[BuffSlot] == It->Stride, "Inconsistent strides specified for buffer slot ", BuffSlot, + ". Current value: ", m_Strides[BuffSlot], ". New value: ", It->Stride); + } + m_Strides[BuffSlot] = It->Stride; + } + CurrStride += It->NumComponents * GetValueSize( It->ValueType ); } + + for( auto It = m_LayoutElements.begin(); It != m_LayoutElements.end(); ++It ) + { + auto BuffSlot = It->BufferSlot; + if(m_Strides[BuffSlot] == 0) + { + m_Strides[BuffSlot] = TightStrides[BuffSlot]; + } + else + { + VERIFY(m_Strides[BuffSlot] >= TightStrides[BuffSlot], "Stride (", m_Strides[BuffSlot], ") explicitly specified for slot ", BuffSlot, " is smaller than the total element size (", TightStrides[BuffSlot], ")"); + } + } } ~PipelineStateBase() @@ -158,9 +184,14 @@ public: IMPLEMENT_QUERY_INTERFACE_IN_PLACE( IID_PipelineState, TDeviceObjectBase ) - virtual const Uint32* GetTightStrides()const + virtual const Uint32* GetBufferStrides()const { - return m_TightStrides; + return m_Strides.data(); + } + + Uint32 GetNumBufferSlotsUsed()const + { + return m_BufferSlotsUsed; } IShader* GetVS(){return m_pVS;} @@ -183,10 +214,11 @@ public: protected: std::vector<LayoutElement, STDAllocatorRawMem<LayoutElement> > m_LayoutElements; + Uint32 m_BufferSlotsUsed = 0; // The size of this array must be equal to the // maximum number of buffer slots, because a layout // element can refer to any input slot - Uint32 m_TightStrides[MaxBufferSlots] = {}; + std::array<Uint32, MaxBufferSlots> m_Strides = {}; RefCntAutoPtr<IShader> m_pVS; ///< Strong reference to the vertex shader RefCntAutoPtr<IShader> m_pPS; ///< Strong reference to the pixel shader diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 0e45b598..460291a5 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -341,11 +341,6 @@ public: /// \param [in] NumBuffersSet - The number of vertex buffers in the array. /// \param [in] ppBuffers - A pointer to an array of vertex buffers. // The vertex buffers must have been created with the Diligent::BIND_VERTEX_BUFFER flag. - /// \param [in] pStrides - Pointer to an array of stride values; one stride value for each buffer - /// in the vertex-buffer array. Each stride is the size (in bytes) of the - /// elements that are to be used from that vertex buffer. - /// If this parameter is nullptr, tight strides from the input layout - /// will be used for each buffer. See IPipelineState::GetTightStrides(). /// \param [in] pOffsets - Pointer to an array of offset values; one offset value for each buffer /// in the vertex-buffer array. Each offset is the number of bytes between /// the first element of a vertex buffer and the first element that will be @@ -360,7 +355,6 @@ public: virtual void SetVertexBuffers(Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, - Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags) = 0; diff --git a/Graphics/GraphicsEngine/interface/InputLayout.h b/Graphics/GraphicsEngine/interface/InputLayout.h index 598cedd4..7900fa74 100644 --- a/Graphics/GraphicsEngine/interface/InputLayout.h +++ b/Graphics/GraphicsEngine/interface/InputLayout.h @@ -56,11 +56,18 @@ struct LayoutElement Bool IsNormalized; /// Relative offset, in bytes, to the element bits. - /// If this value is zero, the offset will be computed automatically - /// assuming that all previous elements in the same buffer slot a tightly packed. + /// If this value is zero, the offset will be computed automatically assuming + /// that all previous elements in the same buffer slot are tightly packed. /// Overlapping elements are not allowed. Uint32 RelativeOffset; + /// Stride, in bytes, between two elements, for this buffer slot. + /// If this value is zero, stride will be computed automatically assuming + /// that all elements in the same buffer slot are tightly packed. + /// If buffer slot contains multiple layout elements, they all must use + /// the same stride or zero. + Uint32 Stride; + /// Input frequency enum FREQUENCY : Int32 { @@ -82,20 +89,22 @@ struct LayoutElement Uint32 InstanceDataStepRate; /// Initializes the structure - LayoutElement(Uint32 _InputIndex = 0, - Uint32 _BufferSlot = 0, - Uint32 _NumComponents = 0, - VALUE_TYPE _ValueType = VT_FLOAT32, - Bool _IsNormalized = True, - Uint32 _RelativeOffset = 0, - FREQUENCY _Frequency = FREQUENCY_PER_VERTEX, - Uint32 _InstanceDataStepRate = 1) : + LayoutElement(Uint32 _InputIndex = 0, + Uint32 _BufferSlot = 0, + Uint32 _NumComponents = 0, + VALUE_TYPE _ValueType = VT_FLOAT32, + Bool _IsNormalized = True, + Uint32 _RelativeOffset = 0, + Uint32 _Stride = 0, + FREQUENCY _Frequency = FREQUENCY_PER_VERTEX, + Uint32 _InstanceDataStepRate = 1) : InputIndex(_InputIndex), BufferSlot(_BufferSlot), NumComponents(_NumComponents), ValueType(_ValueType), IsNormalized(_IsNormalized), RelativeOffset(_RelativeOffset), + Stride(_Stride), Frequency(_Frequency), InstanceDataStepRate(_InstanceDataStepRate) {} diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index d35edc82..fb876a49 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -56,7 +56,7 @@ public: virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override final; + virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags )override final; virtual void InvalidateState()override final; diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index f9b59ede..77b70ea2 100644 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -616,14 +616,14 @@ namespace Diligent bool BindVBs = m_NumVertexStreams != m_NumCommittedD3D11VBs; - const auto *TightStrides = pPipelineStateD3D11->GetTightStrides(); + const auto *Strides = pPipelineStateD3D11->GetBufferStrides(); for( UINT Slot = 0; Slot < m_NumVertexStreams; ++Slot ) { auto &CurrStream = m_VertexStreams[Slot]; VERIFY( CurrStream.pBuffer, "Attempting to bind a null buffer for rendering" ); auto *pBuffD3D11Impl = CurrStream.pBuffer.RawPtr<BufferD3D11Impl>(); ID3D11Buffer *pd3d11Buffer = pBuffD3D11Impl->m_pd3d11Buffer; - auto Stride = CurrStream.Stride ? CurrStream.Stride : TightStrides[Slot]; + auto Stride = Strides[Slot]; auto Offset = CurrStream.Offset; if(pBuffD3D11Impl->CheckState( D3D11BufferState::UnorderedAccess )) @@ -688,6 +688,7 @@ namespace Diligent auto *pd3d11InputLayout = pPipelineStateD3D11->GetD3D11InputLayout(); if( pd3d11InputLayout != nullptr && !m_bCommittedD3D11VBsUpToDate ) { + VERIFY( m_NumVertexStreams >= pPipelineStateD3D11->GetNumBufferSlotsUsed(), "Currently bound pipeline state \"", pPipelineStateD3D11->GetDesc().Name, "\" expects ", pPipelineStateD3D11->GetNumBufferSlotsUsed(), " input buffer slots, but only ", m_NumVertexStreams, " is bound"); CommitD3D11VertexBuffers(pPipelineStateD3D11); } @@ -851,9 +852,9 @@ namespace Diligent m_pd3d11DeviceContext->Flush(); } - void DeviceContextD3D11Impl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags ) + void DeviceContextD3D11Impl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) { - TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pStrides, pOffsets, Flags ); + TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, Flags ); m_bCommittedD3D11VBsUpToDate = false; } diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index c5f757bd..b4ae5de5 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -58,7 +58,7 @@ public: virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override final; + virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags )override final; virtual void InvalidateState()override final; diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 63444a17..8b10da01 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -262,7 +262,8 @@ namespace Diligent // Do not initialize array with zeroes for performance reasons D3D12_VERTEX_BUFFER_VIEW VBViews[MaxBufferSlots];// = {} VERIFY( m_NumVertexStreams <= MaxBufferSlots, "Too many buffers are being set" ); - const auto *TightStrides = pPipelineStateD3D12->GetTightStrides(); + const auto *Strides = pPipelineStateD3D12->GetBufferStrides(); + VERIFY( m_NumVertexStreams >= pPipelineStateD3D12->GetNumBufferSlotsUsed(), "Currently bound pipeline state \"", pPipelineStateD3D12->GetDesc().Name, "\" expects ", pPipelineStateD3D12->GetNumBufferSlotsUsed(), " input buffer slots, but only ", m_NumVertexStreams, " is bound"); bool DynamicBufferPresent = false; for( UINT Buff = 0; Buff < m_NumVertexStreams; ++Buff ) { @@ -287,7 +288,7 @@ namespace Diligent //GraphicsCtx.AddReferencedObject(pd3d12Resource); VBView.BufferLocation = pBufferD3D12->GetGPUAddress(m_ContextId) + CurrStream.Offset; - VBView.StrideInBytes = CurrStream.Stride ? CurrStream.Stride : TightStrides[Buff]; + VBView.StrideInBytes = Strides[Buff]; // Note that for a dynamic buffer, what we use here is the size of the buffer itself, not the upload heap buffer! VBView.SizeInBytes = pBufferD3D12->GetDesc().uiSizeInBytes - CurrStream.Offset; } @@ -537,9 +538,9 @@ namespace Diligent Flush(true); } - void DeviceContextD3D12Impl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags ) + void DeviceContextD3D12Impl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) { - TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pStrides, pOffsets, Flags ); + TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, Flags ); m_bCommittedD3D12VBsUpToDate = false; } diff --git a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h index 5a4a80fc..3a28312a 100644 --- a/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h +++ b/Graphics/GraphicsEngineOpenGL/include/DeviceContextGLImpl.h @@ -53,7 +53,7 @@ public: virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override final; + virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags )override final; virtual void InvalidateState()override final; diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index 41592b37..3618354b 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -159,9 +159,9 @@ namespace Diligent } } - void DeviceContextGLImpl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags ) + void DeviceContextGLImpl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) { - TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pStrides, pOffsets, Flags ); + TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, Flags ); m_bVAOIsUpToDate = false; } diff --git a/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp b/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp index 13fbdc4c..18ad1ff8 100644 --- a/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp @@ -90,7 +90,7 @@ const GLObjectWrappers::GLVertexArrayObj& VAOCache::GetVAO( IPipelineState *pPSO const auto &InputLayout = pPSOGL->GetDesc().GraphicsPipeline.InputLayout; const LayoutElement *LayoutElems = InputLayout.LayoutElements; Uint32 NumElems = InputLayout.NumElements; - const Uint32 *TightStrides = pPSOGL->GetTightStrides(); + const Uint32 *Strides = pPSOGL->GetBufferStrides(); // Construct the key VAOCacheKey Key(pPSO, pIndexBuffer); @@ -115,7 +115,7 @@ const GLObjectWrappers::GLVertexArrayObj& VAOCache::GetVAO( IPipelineState *pPSO Key.NumUsedSlots = MaxUsedSlot; auto &CurrStream = VertexStreams[BuffSlot]; - auto Stride = CurrStream.Stride ? CurrStream.Stride : TightStrides[BuffSlot]; + auto Stride = Strides[BuffSlot]; auto &pCurrBuf = VertexBuffers[BuffSlot]; auto &CurrStreamKey = Key.Streams[BuffSlot]; if (pCurrBuf == nullptr) @@ -179,7 +179,7 @@ const GLObjectWrappers::GLVertexArrayObj& VAOCache::GetVAO( IPipelineState *pPSO // Get buffer through the strong reference. Note that we are not // using pointers stored in the key for safety auto &CurrStream = VertexStreams[BuffSlot]; - auto Stride = CurrStream.Stride ? CurrStream.Stride : TightStrides[BuffSlot]; + auto Stride = Strides[BuffSlot]; auto *pBuff = VertexBuffers[BuffSlot]; VERIFY( pBuff != nullptr, "Vertex buffer is null" ); const BufferGLImpl *pBufferOGL = static_cast<const BufferGLImpl*>( pBuff ); diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index ea889332..4b04ead8 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -60,7 +60,7 @@ public: virtual void SetBlendFactors(const float* pBlendFactors = nullptr)override final; - virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )override final; + virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags )override final; virtual void InvalidateState()override final; diff --git a/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h b/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h index cc2f794a..10dec2a7 100644 --- a/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h +++ b/Graphics/GraphicsEngineVulkan/include/VulkanTypeConversions.h @@ -44,6 +44,7 @@ void BlendStateDesc_To_VkBlendStateCI(const BlendStateDesc &BSDesc, std::vector<VkPipelineColorBlendAttachmentState> &ColorBlendAttachments); void InputLayoutDesc_To_VkVertexInputStateCI(const InputLayoutDesc& LayoutDesc, + const std::array<Uint32, MaxBufferSlots>& Strides, VkPipelineVertexInputStateCreateInfo &VertexInputStateCI, std::array<VkVertexInputBindingDescription, iMaxLayoutElements>& BindingDescriptions, std::array<VkVertexInputAttributeDescription, iMaxLayoutElements>& AttributeDescription); diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index f739b794..474abd27 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -829,9 +829,9 @@ namespace Diligent m_pPipelineState.Release(); } - void DeviceContextVkImpl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags ) + void DeviceContextVkImpl::SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, Uint32 Flags ) { - TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pStrides, pOffsets, Flags ); + TDeviceContextBase::SetVertexBuffers( StartSlot, NumBuffersSet, ppBuffers, pOffsets, Flags ); m_State.CommittedVBsUpToDate = false; } diff --git a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp index 288892d2..ad575083 100644 --- a/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/PipelineStateVkImpl.cpp @@ -247,7 +247,7 @@ PipelineStateVkImpl :: PipelineStateVkImpl(IReferenceCounters *pRefCounters, Ren VkPipelineVertexInputStateCreateInfo VertexInputStateCI = {}; std::array<VkVertexInputBindingDescription, iMaxLayoutElements> BindingDescriptions; std::array<VkVertexInputAttributeDescription, iMaxLayoutElements> AttributeDescription; - InputLayoutDesc_To_VkVertexInputStateCI(GraphicsPipeline.InputLayout, VertexInputStateCI, BindingDescriptions, AttributeDescription); + InputLayoutDesc_To_VkVertexInputStateCI(GraphicsPipeline.InputLayout, m_Strides, VertexInputStateCI, BindingDescriptions, AttributeDescription); PipelineCI.pVertexInputState = &VertexInputStateCI; diff --git a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp index 971d9c39..ac04ec7c 100644 --- a/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp +++ b/Graphics/GraphicsEngineVulkan/src/VulkanTypeConversions.cpp @@ -927,6 +927,7 @@ VkVertexInputRate LayoutElemFrequencyToVkInputRate(LayoutElement::FREQUENCY freq } void InputLayoutDesc_To_VkVertexInputStateCI(const InputLayoutDesc& LayoutDesc, + const std::array<Uint32, MaxBufferSlots>& Strides, VkPipelineVertexInputStateCreateInfo &VertexInputStateCI, std::array<VkVertexInputBindingDescription, iMaxLayoutElements>& BindingDescriptions, std::array<VkVertexInputAttributeDescription, iMaxLayoutElements>& AttributeDescription) @@ -950,7 +951,7 @@ void InputLayoutDesc_To_VkVertexInputStateCI(const InputLayoutDesc& LayoutDesc, BindingDescInd = VertexInputStateCI.vertexBindingDescriptionCount++; auto &BindingDesc = BindingDescriptions[BindingDescInd]; BindingDesc.binding = LayoutElem.BufferSlot; - BindingDesc.stride = 4*3;//LayoutElem. + BindingDesc.stride = Strides[LayoutElem.BufferSlot]; BindingDesc.inputRate = LayoutElemFrequencyToVkInputRate(LayoutElem.Frequency); } @@ -964,7 +965,6 @@ void InputLayoutDesc_To_VkVertexInputStateCI(const InputLayoutDesc& LayoutDesc, AttribDesc.format = TypeToVkFormat(LayoutElem.ValueType, LayoutElem.NumComponents, LayoutElem.IsNormalized); AttribDesc.offset = LayoutElem.RelativeOffset; } - } void PrimitiveTopology_To_VkPrimitiveTopologyAndPatchCPCount(PRIMITIVE_TOPOLOGY PrimTopology, |
