Add stride to GPUVertexLayout
This commit is contained in:
@@ -152,11 +152,10 @@ GPUVertexLayoutDX11::GPUVertexLayoutDX11(GPUDeviceDX11* device, const Elements&
|
||||
: GPUResourceBase<GPUDeviceDX11, GPUVertexLayout>(device, StringView::Empty)
|
||||
, InputElementsCount(elements.Count())
|
||||
{
|
||||
_elements = elements;
|
||||
uint32 offsets[GPU_MAX_VB_BINDED] = {};
|
||||
for (int32 i = 0; i < _elements.Count(); i++)
|
||||
for (int32 i = 0; i < elements.Count(); i++)
|
||||
{
|
||||
const VertexElement& src = _elements.Get()[i];
|
||||
const VertexElement& src = elements.Get()[i];
|
||||
D3D11_INPUT_ELEMENT_DESC& dst = InputElements[i];
|
||||
uint32& offset = offsets[src.Slot];
|
||||
if (src.Offset != 0)
|
||||
@@ -169,6 +168,7 @@ GPUVertexLayoutDX11::GPUVertexLayoutDX11(GPUDeviceDX11* device, const Elements&
|
||||
dst.InstanceDataStepRate = src.PerInstance ? 1 : 0;
|
||||
offset += PixelFormatExtensions::SizeInBytes(src.Format);
|
||||
}
|
||||
SetElements(elements, offsets);
|
||||
}
|
||||
|
||||
GPUDevice* GPUDeviceDX11::Create()
|
||||
|
||||
@@ -40,11 +40,10 @@ GPUVertexLayoutDX12::GPUVertexLayoutDX12(GPUDeviceDX12* device, const Elements&
|
||||
: GPUResourceDX12<GPUVertexLayout>(device, StringView::Empty)
|
||||
, InputElementsCount(elements.Count())
|
||||
{
|
||||
_elements = elements;
|
||||
uint32 offsets[GPU_MAX_VB_BINDED] = {};
|
||||
for (int32 i = 0; i < _elements.Count(); i++)
|
||||
for (int32 i = 0; i < elements.Count(); i++)
|
||||
{
|
||||
const VertexElement& src = _elements.Get()[i];
|
||||
const VertexElement& src = elements.Get()[i];
|
||||
D3D12_INPUT_ELEMENT_DESC& dst = InputElements[i];
|
||||
uint32& offset = offsets[src.Slot];
|
||||
if (src.Offset != 0)
|
||||
@@ -57,6 +56,7 @@ GPUVertexLayoutDX12::GPUVertexLayoutDX12(GPUDeviceDX12* device, const Elements&
|
||||
dst.InstanceDataStepRate = src.PerInstance ? 1 : 0;
|
||||
offset += PixelFormatExtensions::SizeInBytes(src.Format);
|
||||
}
|
||||
SetElements(elements, offsets);
|
||||
}
|
||||
|
||||
GPUDevice* GPUDeviceDX12::Create()
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
GPUVertexLayoutNull(const Elements& elements)
|
||||
: GPUVertexLayout()
|
||||
{
|
||||
_elements = elements;
|
||||
SetElements(elements, {});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -452,7 +452,6 @@ uint32 GetHash(const FramebufferVulkan::Key& key)
|
||||
GPUVertexLayoutVulkan::GPUVertexLayoutVulkan(GPUDeviceVulkan* device, const Elements& elements)
|
||||
: GPUResourceVulkan<GPUVertexLayout>(device, StringView::Empty)
|
||||
{
|
||||
_elements = elements;
|
||||
uint32 offsets[GPU_MAX_VB_BINDED] = {};
|
||||
for (int32 i = 0; i < GPU_MAX_VB_BINDED; i++)
|
||||
{
|
||||
@@ -462,9 +461,9 @@ GPUVertexLayoutVulkan::GPUVertexLayoutVulkan(GPUDeviceVulkan* device, const Elem
|
||||
binding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
}
|
||||
uint32 bindingsCount = 0;
|
||||
for (int32 i = 0; i < _elements.Count(); i++)
|
||||
for (int32 i = 0; i < elements.Count(); i++)
|
||||
{
|
||||
const VertexElement& src = _elements.Get()[i];
|
||||
const VertexElement& src = elements.Get()[i];
|
||||
uint32& offset = offsets[src.Slot];
|
||||
if (src.Offset != 0)
|
||||
offset = src.Offset;
|
||||
@@ -485,11 +484,12 @@ GPUVertexLayoutVulkan::GPUVertexLayoutVulkan(GPUDeviceVulkan* device, const Elem
|
||||
bindingsCount = Math::Max(bindingsCount, (uint32)src.Slot + 1);
|
||||
offset += size;
|
||||
}
|
||||
SetElements(elements, offsets);
|
||||
|
||||
RenderToolsVulkan::ZeroStruct(CreateInfo, VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO);
|
||||
CreateInfo.vertexBindingDescriptionCount = bindingsCount;
|
||||
CreateInfo.pVertexBindingDescriptions = Bindings;
|
||||
CreateInfo.vertexAttributeDescriptionCount = _elements.Count();
|
||||
CreateInfo.vertexAttributeDescriptionCount = elements.Count();
|
||||
CreateInfo.pVertexAttributeDescriptions = Attributes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user