	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_surface_load_fb_texture        ## -- Begin function surface_load_fb_texture
	.p2align	4, 0x90
_surface_load_fb_texture:               ## @surface_load_fb_texture
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdx, %r15
	movl	%esi, -52(%rbp)                 ## 4-byte Spill
	movq	%rdi, %r13
	callq	_surface_get_sub_resource_idx
	movl	%eax, %ebx
	movq	(%r13), %r14
	leaq	8(%r14), %rax
	movq	%rax, -80(%rbp)                 ## 8-byte Spill
	movq	8(%r14), %r12
	movq	%r15, %rdi
	callq	_context_get_rt_surface
	cmpq	%r13, %rax
	movl	%ebx, -48(%rbp)                 ## 4-byte Spill
	je	LBB0_1
## %bb.2:
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	movq	%r14, %rsi
	movl	%ebx, %edx
	callq	_context_acquire
	movq	%rax, %r15
	jmp	LBB0_3
LBB0_1:
	xorl	%eax, %eax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
LBB0_3:
	movq	(%r15), %rax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
	movq	_STATE_FRAMEBUFFER@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	callq	_device_invalidate_state
	movq	%r14, %rdi
	movq	%r15, %rsi
	movl	-52(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %edx
	callq	_wined3d_texture_prepare_texture
	movq	%r14, %rdi
	movq	%r15, %rsi
	movl	%ebx, %edx
	callq	_wined3d_texture_bind_and_dirtify
	leaq	L_.str(%rip), %rdi
	movq	%r13, %rsi
	movq	-72(%rbp), %r13                 ## 8-byte Reload
	callq	_TRACE
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	callq	_wined3d_resource_is_offscreen
	movq	8(%r13), %rbx
	testq	%rax, %rax
	je	LBB0_5
## %bb.4:
	movq	%r15, %rdi
	callq	_context_get_offscreen_gl_buffer
	jmp	LBB0_6
LBB0_5:
	movq	%r14, %rdi
	callq	_wined3d_texture_get_gl_buffer
LBB0_6:
	movl	-48(%rbp), %r12d                ## 4-byte Reload
	movl	%eax, %edi
	callq	*%rbx
	leaq	L_.str.1(%rip), %rdi
	callq	_checkGLcall
	movl	%r12d, %eax
	xorl	%edx, %edx
	divl	(%r14)
	movl	%edx, %ebx
	movq	%r14, %rdi
	movl	%r12d, %esi
	callq	_wined3d_texture_get_sub_resource_target
	movl	%eax, %r12d
	movq	(%r13), %rax
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_wined3d_texture_get_level_width
	movl	%eax, %r13d
	movq	%r14, %rdi
	movl	%ebx, %esi
	callq	_wined3d_texture_get_level_height
                                        ## kill: def $eax killed $eax def $rax
	movl	%r12d, %edi
	movl	%ebx, %esi
	xorl	%edx, %edx
	xorl	%ecx, %ecx
	xorl	%r8d, %r8d
	xorl	%r9d, %r9d
	pushq	%rax
	pushq	%r13
	callq	*-48(%rbp)                      ## 8-byte Folded Reload
	addq	$16, %rsp
	leaq	L_.str.2(%rip), %rdi
	callq	_checkGLcall
	movq	-64(%rbp), %rsi                 ## 8-byte Reload
	testq	%rsi, %rsi
	je	LBB0_7
## %bb.8:
	movq	%r15, %rdi
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_context_restore                ## TAILCALL
LBB0_7:
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_STATE_FRAMEBUFFER,4,2          ## @STATE_FRAMEBUFFER
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Reading back offscreen render target %p.\n"

L_.str.1:                               ## @.str.1
	.asciz	"glReadBuffer"

L_.str.2:                               ## @.str.2
	.asciz	"glCopyTexSubImage2D"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_surface_load_fb_texture        ; -- Begin function surface_load_fb_texture
	.p2align	2
_surface_load_fb_texture:               ; @surface_load_fb_texture
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x19, x2
	mov	x24, x1
	mov	x23, x0
	bl	_surface_get_sub_resource_idx
	mov	x22, x0
	ldr	x21, [x23]
	mov	x25, x21
	ldr	x26, [x25, #8]!
	mov	x0, x19
	bl	_context_get_rt_surface
	cmp	x0, x23
	b.eq	LBB0_2
; %bb.1:
	mov	x20, x0
	mov	x0, x26
	mov	x1, x21
	mov	x2, x22
	bl	_context_acquire
	mov	x19, x0
	b	LBB0_3
LBB0_2:
	mov	x20, #0
LBB0_3:
	ldr	x27, [x19]
Lloh0:
	adrp	x8, _STATE_FRAMEBUFFER@GOTPAGE
Lloh1:
	ldr	x8, [x8, _STATE_FRAMEBUFFER@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x26
	bl	_device_invalidate_state
	mov	x0, x21
	mov	x1, x19
	mov	x2, x24
	bl	_wined3d_texture_prepare_texture
	mov	x0, x21
	mov	x1, x19
	mov	x2, x24
	bl	_wined3d_texture_bind_and_dirtify
Lloh3:
	adrp	x0, l_.str@PAGE
Lloh4:
	add	x0, x0, l_.str@PAGEOFF
	mov	x1, x23
	bl	_TRACE
	mov	x0, x25
	bl	_wined3d_resource_is_offscreen
	ldr	x23, [x27, #8]
	cbz	x0, LBB0_5
; %bb.4:
	mov	x0, x19
	bl	_context_get_offscreen_gl_buffer
	b	LBB0_6
LBB0_5:
	mov	x0, x21
	bl	_wined3d_texture_get_gl_buffer
LBB0_6:
	blr	x23
Lloh5:
	adrp	x0, l_.str.1@PAGE
Lloh6:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_checkGLcall
	ldr	w8, [x21]
	udiv	w9, w22, w8
	msub	w23, w9, w8, w22
	mov	x0, x21
	mov	x1, x22
	bl	_wined3d_texture_get_sub_resource_target
	mov	x22, x0
	ldr	x25, [x27]
	mov	x0, x21
	mov	x1, x23
	bl	_wined3d_texture_get_level_width
	mov	x24, x0
	mov	x0, x21
	mov	x1, x23
	bl	_wined3d_texture_get_level_height
	mov	x7, x0
	mov	x0, x22
	mov	x1, x23
	mov	w2, #0
	mov	w3, #0
	mov	w4, #0
	mov	w5, #0
	mov	x6, x24
	blr	x25
Lloh7:
	adrp	x0, l_.str.2@PAGE
Lloh8:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_checkGLcall
	cbz	x20, LBB0_8
; %bb.7:
	mov	x0, x19
	mov	x1, x20
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	b	_context_restore
LBB0_8:
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpAdd	Lloh5, Lloh6
	.cfi_endproc
                                        ; -- End function
	.comm	_STATE_FRAMEBUFFER,4,2          ; @STATE_FRAMEBUFFER
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Reading back offscreen render target %p.\n"

l_.str.1:                               ; @.str.1
	.asciz	"glReadBuffer"

l_.str.2:                               ; @.str.2
	.asciz	"glCopyTexSubImage2D"

.subsections_via_symbols
