62 for (VkVertexInputAttributeDescription attribute :
attributes) {
63 if (visited_bindings[attribute.binding]) {
66 visited_bindings[attribute.binding].set(
true);
69 VkDeviceSize offset = 0;
71 if (attribute.binding <
buffers.size()) {
72 buffer =
buffers[attribute.binding].buffer;
73 offset =
buffers[attribute.binding].offset;
76 r_vertex_buffer_bindings.
buffer[attribute.binding] = buffer;
77 r_vertex_buffer_bindings.
offset[attribute.binding] = offset;
79 attribute.binding + 1);
102 if (occupied_attributes !=
interface.enabled_attr_mask_) {
103 fill_unused_bindings(interface, occupied_attributes);
158void VKVertexAttributeObject::fill_unused_bindings(
const VKShaderInterface &
interface,
164 if (occupied_attributes & location_mask) {
168 if ((
interface.enabled_attr_mask_ & location_mask) == 0) {
175 for (
const uint32_t location_offset : IndexRange(num_locations)) {
177 VkVertexInputAttributeDescription attribute_description = {};
178 attribute_description.binding = binding;
179 attribute_description.location = location + location_offset;
180 attribute_description.offset = 0;
181 attribute_description.format =
to_vk_format(attribute_type);
184 VkVertexInputBindingDescription vk_binding_descriptor = {};
185 vk_binding_descriptor.binding = binding;
186 vk_binding_descriptor.stride = 0;
187 vk_binding_descriptor.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
188 bindings.append(vk_binding_descriptor);
205 occupied_attributes);
217 BLI_assert(vertex_buffer || immediate_vertex_buffer);
218 BLI_assert(!(vertex_buffer && immediate_vertex_buffer));
226 uint32_t buffer_offset = 0;
227 uint32_t attribute_offset = 0;
228 uint32_t stride = vertex_format.
stride;
230 bool add_vbo =
false;
232 for (uint32_t attribute_index = 0; attribute_index < vertex_format.
attr_len; attribute_index++) {
235 buffer_offset += ((attribute_index == 0) ?
242 attribute_offset = attribute.
offset;
245 for (uint32_t name_index = 0; name_index < attribute.
name_len; name_index++) {
248 if (shader_input ==
nullptr || shader_input->location == -1) {
254 if (r_occupied_attributes & attribute_mask) {
257 r_occupied_attributes |= attribute_mask;
259 for (
const uint32_t location_offset : IndexRange(num_locations)) {
261 VkVertexInputAttributeDescription attribute_description = {};
262 attribute_description.binding = binding;
263 attribute_description.location = shader_input->location + location_offset;
264 attribute_description.offset = attribute_offset + location_offset *
sizeof(
float4);
269 VkVertexInputBindingDescription vk_binding_descriptor = {};
270 vk_binding_descriptor.binding = binding;
271 vk_binding_descriptor.stride = stride;
272 vk_binding_descriptor.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
273 bindings.append(vk_binding_descriptor);
279 if (immediate_vertex_buffer) {
280 buffers.append(*immediate_vertex_buffer);
288 vbos.append(vertex_buffer);
300 std::cout << __FILE__ <<
"::" << __func__ <<
"\n";
303 for (VkVertexInputAttributeDescription attribute :
attributes) {
304 std::cout <<
" - attribute(binding=" << attribute.binding
305 <<
", location=" << attribute.location <<
")";
307 if (visited_bindings[attribute.binding]) {
308 std::cout <<
" WARNING: Already bound\n";
311 visited_bindings[attribute.binding].set(
true);
313 if (attribute.binding <
vbos.size()) {
314 std::cout <<
" Attach to Buffer\n";
317 std::cout <<
" WARNING: Attach to dummy\n";
MINLINE int max_ii(int a, int b)
static constexpr int GPU_BATCH_VBO_MAX_LEN
ATTR_WARN_UNUSED_RESULT const BMVert * v
VkBuffer vk_handle() const
Vector< VKBufferWithOffset > buffers
VKVertexAttributeObject()
VKVertexAttributeObject & operator=(const VKVertexAttributeObject &other)
Vector< VkVertexInputAttributeDescription > attributes
void update_bindings(const VKContext &context, VKBatch &batch)
VkPipelineVertexInputStateCreateInfo info
Vector< VkVertexInputBindingDescription > bindings
void bind(render_graph::VKVertexBufferBindings &r_vertex_buffer_bindings) const
Vector< VKVertexBuffer * > vbos
VkBuffer vk_handle() const
struct @021025263243242147216143265077100330027142264337::@225245033123204053237120173316075113304004012000 batch
#define interface_get(create_info, _res)
static Context * unwrap(GPUContext *ctx)
VkFormat to_vk_format(const TextureFormat format)
static uint32_t to_binding_location_len(const GPUVertAttr &attribute)
VecBase< float, 4 > float4
constexpr IntT ceil_division(const IntT x, const IntT y)
GPUVertFetchMode fetch_mode() const
GPUVertCompType comp_type() const
struct GPUVertAttr::Type type