// File: rossy[P]crossc/SPIRV-Cross/spirv_cpp.cpp
// Function: spirv_cross::CompilerCPP::emit_buffer_block(spirv_cross::SPIRVariable const&)
void CompilerCPP::emit_buffer_block(const SPIRVariable &var)
{
	add_resource_name(var.self);

	auto &type = get<SPIRType>(var.basetype);
	auto instance_name = to_name(var.self);

	uint32_t descriptor_set = ir.meta[var.self].decoration.set;
	uint32_t binding = ir.meta[var.self].decoration.binding;

	emit_block_struct(type);
	auto buffer_name = to_name(type.self);

	statement("internal::Resource<", buffer_name, type_to_array_glsl(type), "> ", instance_name, "__;");
	statement_no_indent("#define ", instance_name, " __res->", instance_name, "__.get()");
	resource_registrations.push_back(
	    join("s.register_resource(", instance_name, "__", ", ", descriptor_set, ", ", binding, ");"));
	statement("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
movq -0xb8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0xb8(%rbp), %rsi
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x38(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
movq -0xb8(%rbp), %rdi
addq $0x38, %rdi
movq %rdi, -0xc0(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq -0xc0(%rbp), %rdi
movl 0xac(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0xead0
movq -0xb8(%rbp), %rdi
movl 0xb0(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rsi
callq 0xc1d0
jmp 0xc00a
movq -0xb8(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x70(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0xc02c
movq -0xb8(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x61340
jmp 0xc045
movq -0xb8(%rbp), %rdi
leaq 0x132184(%rip), %rcx    # 0x13e1d7
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0x132160(%rip), %rsi    # 0x13e1c0
leaq 0x13216d(%rip), %r8     # 0x13e1d4
leaq -0x70(%rbp), %rdx
leaq -0x90(%rbp), %rcx
leaq -0x38(%rbp), %r9
callq 0xeaf0
jmp 0xc07d
leaq -0x90(%rbp), %rdi
callq 0x7708
movq -0xb8(%rbp), %rdi
leaq 0x132144(%rip), %rsi    # 0x13e1db
leaq 0x132146(%rip), %rcx    # 0x13e1e4
leaq 0x132148(%rip), %r9     # 0x13e1ed
leaq -0x38(%rbp), %r8
movq %r8, %rdx
callq 0xec60
jmp 0xc0b3
movq -0xb8(%rbp), %rax
addq $0x788, %rax            # imm = 0x788
movq %rax, -0xc8(%rbp)
leaq 0x13cfd7(%rip), %rcx    # 0x1490a5
movq %rsp, %rax
movq %rcx, 0x10(%rax)
leaq -0x40(%rbp), %rcx
movq %rcx, 0x8(%rax)
leaq 0x1384ab(%rip), %r8     # 0x14458f
movq %r8, (%rax)
leaq 0x132108(%rip), %rsi    # 0x13e1f6
leaq 0x132116(%rip), %rcx    # 0x13e20b
leaq -0xb0(%rbp), %rdi
leaq -0x38(%rbp), %rdx
leaq -0x3c(%rbp), %r9
callq 0xed00
jmp 0xc10b
movq -0xc8(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xecd0
jmp 0xc120
leaq -0xb0(%rbp), %rdi
callq 0x7708
movq -0xb8(%rbp), %rdi
leaq 0x132764(%rip), %rsi    # 0x13e89e
callq 0xedf0
jmp 0xc141
leaq -0x70(%rbp), %rdi
callq 0x7708
leaq -0x38(%rbp), %rdi
callq 0x7708
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xc1b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0xc1aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7708
jmp 0xc1aa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7708
leaq -0x70(%rbp), %rdi
callq 0x7708
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x48(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)