diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index cd2dc6ddf..91c26e0b5 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -4138,11 +4138,11 @@ std::mutex queue_locker; } stream.stream1.BD = bd; - wi::vector elements; + StackVector elements; D3D12_INPUT_LAYOUT_DESC il = {}; if (pso->desc.il != nullptr) { - il.NumElements = (uint32_t)pso->desc.il->elements.size(); + il.NumElements = std::min((uint32_t)pso->desc.il->elements.size(), (uint32_t)D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT); elements.resize(il.NumElements); for (uint32_t i = 0; i < il.NumElements; ++i) { @@ -4160,8 +4160,8 @@ std::mutex queue_locker; elements[i].InstanceDataStepRate = 1; } } + il.pInputElementDescs = elements.data(); } - il.pInputElementDescs = elements.data(); stream.stream1.IL = il; stream.stream1.SampleMask = pso->desc.sample_mask; diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index c9c4a3f86..2b20f27e1 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -5193,47 +5193,48 @@ using namespace vulkan_internal; // Input layout: VkPipelineVertexInputStateCreateInfo vertexInputInfo = {}; vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; - wi::vector bindings; - wi::vector attributes; + static constexpr uint32_t max_il_elemet_count = 32; + StackVector bindings; + StackVector attributes; if (pso->desc.il != nullptr) { uint32_t lastBinding = 0xFFFFFFFF; - for (auto& x : pso->desc.il->elements) + const uint32_t element_count = std::min((uint32_t)pso->desc.il->elements.size(), max_il_elemet_count); + for (uint32_t i = 0; i < element_count; ++i) { - if (x.input_slot == lastBinding) + auto& element = pso->desc.il->elements[i]; + if (element.input_slot == lastBinding) continue; - lastBinding = x.input_slot; + lastBinding = element.input_slot; VkVertexInputBindingDescription& bind = bindings.emplace_back(); - bind.binding = x.input_slot; - bind.inputRate = x.input_slot_class == InputClassification::PER_VERTEX_DATA ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE; - bind.stride = GetFormatStride(x.format); + bind.binding = element.input_slot; + bind.inputRate = element.input_slot_class == InputClassification::PER_VERTEX_DATA ? VK_VERTEX_INPUT_RATE_VERTEX : VK_VERTEX_INPUT_RATE_INSTANCE; + bind.stride = GetFormatStride(element.format); } uint32_t offset = 0; - uint32_t i = 0; lastBinding = 0xFFFFFFFF; - for (auto& x : pso->desc.il->elements) + for (uint32_t i = 0; i < element_count; ++i) { + auto& element = pso->desc.il->elements[i]; VkVertexInputAttributeDescription attr = {}; - attr.binding = x.input_slot; + attr.binding = element.input_slot; if (attr.binding != lastBinding) { lastBinding = attr.binding; offset = 0; } - attr.format = _ConvertFormat(x.format); + attr.format = _ConvertFormat(element.format); attr.location = i; - attr.offset = x.aligned_byte_offset; + attr.offset = element.aligned_byte_offset; if (attr.offset == InputLayout::APPEND_ALIGNED_ELEMENT) { // need to manually resolve this from the format spec. attr.offset = offset; - offset += GetFormatStride(x.format); + offset += GetFormatStride(element.format); } attributes.push_back(attr); - - i++; } vertexInputInfo.vertexBindingDescriptionCount = static_cast(bindings.size()); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 49f4036cb..4570e10e3 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wi::version // minor features, major updates, breaking compatibility changes const int minor = 72; // minor bug fixes, alterations, refactors, updates - const int revision = 27; + const int revision = 28; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);