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);
110 if (occupied_attributes !=
interface.enabled_attr_mask_) {
111 fill_unused_bindings(interface, occupied_attributes);
166void VKVertexAttributeObject::fill_unused_bindings(
const VKShaderInterface &
interface,
172 if (occupied_attributes & location_mask) {
176 if ((
interface.enabled_attr_mask_ & location_mask) == 0) {
183 for (
const uint32_t location_offset : IndexRange(num_locations)) {
185 VkVertexInputAttributeDescription attribute_description = {};
186 attribute_description.binding = binding;
187 attribute_description.location = location + location_offset;
188 attribute_description.offset = 0;
189 attribute_description.format =
to_vk_format(attribute_type);
192 VkVertexInputBindingDescription vk_binding_descriptor = {};
193 vk_binding_descriptor.binding = binding;
194 vk_binding_descriptor.stride = 0;
195 vk_binding_descriptor.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE;
196 bindings.append(vk_binding_descriptor);
225 const bool use_instancing)
227 BLI_assert(vertex_buffer || immediate_vertex_buffer);
228 BLI_assert(!(vertex_buffer && immediate_vertex_buffer));
236 uint32_t buffer_offset = 0;
237 uint32_t attribute_offset = 0;
238 uint32_t stride = vertex_format.
stride;
240 bool add_vbo =
false;
242 for (uint32_t attribute_index = 0; attribute_index < vertex_format.
attr_len; attribute_index++) {
245 buffer_offset += ((attribute_index == 0) ? 0 :
246 vertex_format.
attrs[attribute_index - 1].
size) *
248 stride = attribute.
size;
251 attribute_offset = attribute.
offset;
254 for (uint32_t name_index = 0; name_index < attribute.
name_len; name_index++) {
256 const ShaderInput *shader_input =
interface.attr_get(name);
257 if (shader_input ==
nullptr || shader_input->location == -1) {
263 if (r_occupied_attributes & attribute_mask) {
266 r_occupied_attributes |= attribute_mask;
268 for (
const uint32_t location_offset : IndexRange(num_locations)) {
270 VkVertexInputAttributeDescription attribute_description = {};
271 attribute_description.binding = binding;
272 attribute_description.location = shader_input->location + location_offset;
273 attribute_description.offset = attribute_offset + location_offset *
sizeof(
float4);
280 VkVertexInputBindingDescription vk_binding_descriptor = {};
281 vk_binding_descriptor.binding = binding;
282 vk_binding_descriptor.stride = stride;
283 vk_binding_descriptor.inputRate = use_instancing ? VK_VERTEX_INPUT_RATE_INSTANCE :
284 VK_VERTEX_INPUT_RATE_VERTEX;
285 bindings.append(vk_binding_descriptor);
291 if (immediate_vertex_buffer) {
292 buffers.append(*immediate_vertex_buffer);
300 vbos.append(vertex_buffer);
312 std::cout << __FILE__ <<
"::" << __func__ <<
"\n";
315 for (VkVertexInputAttributeDescription attribute :
attributes) {
316 std::cout <<
" - attribute(binding=" << attribute.binding
317 <<
", location=" << attribute.location <<
")";
319 if (visited_bindings[attribute.binding]) {
320 std::cout <<
" WARNING: Already bound\n";
323 visited_bindings[attribute.binding].set(
true);
325 if (attribute.binding <
vbos.size()) {
326 std::cout <<
" Attach to Buffer\n";
329 std::cout <<
" WARNING: Attach to dummy\n";
MINLINE int max_ii(int a, int b)
static constexpr int GPU_BATCH_VBO_MAX_LEN
static constexpr int GPU_BATCH_INST_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 @242053044010324116347033273112253060004051364061::@051143074301336237271216303350234260141112266062 batch
static Context * unwrap(GPUContext *ctx)
VkFormat to_vk_format(const eGPUTextureFormat 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)