	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_wined3d_fence_wait             ## -- Begin function wined3d_fence_wait
	.p2align	4, 0x90
_wined3d_fence_wait:                    ## @wined3d_fence_wait
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %rbx
	movq	%rdi, %r15
	leaq	L_.str(%rip), %rdi
	movq	%r15, %rsi
	movq	%rbx, %rdx
	xorl	%eax, %eax
	callq	_TRACE
	movq	8(%r15), %rsi
	testq	%rsi, %rsi
	je	LBB0_7
## %bb.1:
	movq	(%rsi), %r12
	movq	%rbx, %rdi
	callq	_context_reacquire
	movq	%rax, %r14
	testq	%rax, %rax
	jne	LBB0_4
## %bb.2:
	movq	(%r12), %rax
	movq	_ARB_SYNC@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	$0, (%rax,%rcx,8)
	je	LBB0_12
## %bb.3:
	movq	%rbx, %rdi
	xorl	%esi, %esi
	xorl	%edx, %edx
	callq	_context_acquire
	movq	%rax, %r14
LBB0_4:
	movq	(%r14), %rax
	movq	(%rax), %rax
	movq	_ARB_SYNC@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	$0, (%rax,%rcx,8)
	je	LBB0_8
## %bb.5:
	movl	4(%r15), %edi
	movq	_GL_SYNC_FLUSH_COMMANDS_BIT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	$-1, %edx
	callq	_glClientWaitSync
	movl	%eax, %edi
	callq	_GL_EXTCALL
	movl	%eax, %ebx
	leaq	L_.str.3(%rip), %rdi
	callq	_checkGLcall
	movl	%ebx, %eax
	andl	$-2, %eax
	cmpl	$128, %eax
	je	LBB0_16
## %bb.10:
	leaq	L_.str.4(%rip), %rdi
	movl	%ebx, %esi
	xorl	%eax, %eax
	callq	_ERR
LBB0_11:
	movq	_WINED3D_FENCE_ERROR@GOTPCREL(%rip), %rax
	jmp	LBB0_17
LBB0_7:
	leaq	L_.str.1(%rip), %rdi
	xorl	%eax, %eax
	callq	_TRACE
	movq	_WINED3D_FENCE_NOT_STARTED@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_18
LBB0_8:
	movq	_APPLE_FENCE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	$0, (%rax,%rcx,8)
	je	LBB0_13
## %bb.9:
	movl	(%r15), %edi
	callq	_glFinishFenceAPPLE
	movl	%eax, %edi
	callq	_GL_EXTCALL
	leaq	L_.str.5(%rip), %rdi
	jmp	LBB0_15
LBB0_12:
	leaq	L_.str.2(%rip), %rdi
	callq	_WARN
	movq	_WINED3D_FENCE_WRONG_THREAD@GOTPCREL(%rip), %rax
	movl	(%rax), %ebx
	jmp	LBB0_18
LBB0_13:
	movq	_NV_FENCE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	cmpq	$0, (%rax,%rcx,8)
	je	LBB0_19
## %bb.14:
	movl	(%r15), %edi
	callq	_glFinishFenceNV
	movl	%eax, %edi
	callq	_GL_EXTCALL
	leaq	L_.str.6(%rip), %rdi
LBB0_15:
	callq	_checkGLcall
LBB0_16:
	movq	_WINED3D_FENCE_OK@GOTPCREL(%rip), %rax
LBB0_17:
	movl	(%rax), %ebx
	movq	%r14, %rdi
	callq	_context_release
LBB0_18:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_19:
	leaq	L_.str.7(%rip), %rdi
	xorl	%eax, %eax
	callq	_ERR
	jmp	LBB0_11
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"fence %p, device %p.\n"

L_.str.1:                               ## @.str.1
	.asciz	"Fence not issued.\n"

	.comm	_WINED3D_FENCE_NOT_STARTED,4,2  ## @WINED3D_FENCE_NOT_STARTED
	.comm	_ARB_SYNC,8,3                   ## @ARB_SYNC
L_.str.2:                               ## @.str.2
	.asciz	"Fence finished from wrong thread.\n"

	.comm	_WINED3D_FENCE_WRONG_THREAD,4,2 ## @WINED3D_FENCE_WRONG_THREAD
	.comm	_GL_SYNC_FLUSH_COMMANDS_BIT,4,2 ## @GL_SYNC_FLUSH_COMMANDS_BIT
L_.str.3:                               ## @.str.3
	.asciz	"glClientWaitSync"

	.comm	_WINED3D_FENCE_OK,4,2           ## @WINED3D_FENCE_OK
L_.str.4:                               ## @.str.4
	.asciz	"glClientWaitSync returned %#x.\n"

	.comm	_WINED3D_FENCE_ERROR,4,2        ## @WINED3D_FENCE_ERROR
	.comm	_APPLE_FENCE,8,3                ## @APPLE_FENCE
L_.str.5:                               ## @.str.5
	.asciz	"glFinishFenceAPPLE"

	.comm	_NV_FENCE,8,3                   ## @NV_FENCE
L_.str.6:                               ## @.str.6
	.asciz	"glFinishFenceNV"

L_.str.7:                               ## @.str.7
	.asciz	"Fence created without GL support.\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_wined3d_fence_wait             ; -- Begin function wined3d_fence_wait
	.p2align	2
_wined3d_fence_wait:                    ; @wined3d_fence_wait
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	mov	x21, x1
	mov	x20, x0
	stp	x0, x1, [sp]
Lloh0:
	adrp	x0, l_.str@PAGE
Lloh1:
	add	x0, x0, l_.str@PAGEOFF
	bl	_TRACE
	ldr	x1, [x20, #8]
	cbz	x1, LBB0_8
; %bb.1:
	ldr	x23, [x1]
	mov	x0, x21
	bl	_context_reacquire
	mov	x19, x0
Lloh2:
	adrp	x22, _ARB_SYNC@GOTPAGE
Lloh3:
	ldr	x22, [x22, _ARB_SYNC@GOTPAGEOFF]
	cbnz	x0, LBB0_4
; %bb.2:
	ldr	x8, [x23]
	ldr	x9, [x22]
	ldr	x8, [x8, x9, lsl #3]
	cbz	x8, LBB0_11
; %bb.3:
	mov	x0, x21
	mov	x1, #0
	mov	w2, #0
	bl	_context_acquire
	mov	x19, x0
LBB0_4:
	ldr	x8, [x19]
	ldr	x8, [x8]
	ldr	x9, [x22]
	ldr	x9, [x8, x9, lsl #3]
	cbz	x9, LBB0_9
; %bb.5:
	ldr	w0, [x20, #4]
Lloh4:
	adrp	x8, _GL_SYNC_FLUSH_COMMANDS_BIT@GOTPAGE
Lloh5:
	ldr	x8, [x8, _GL_SYNC_FLUSH_COMMANDS_BIT@GOTPAGEOFF]
Lloh6:
	ldr	w1, [x8]
	mov	w2, #-1
	bl	_glClientWaitSync
	bl	_GL_EXTCALL
	mov	x20, x0
Lloh7:
	adrp	x0, l_.str.3@PAGE
Lloh8:
	add	x0, x0, l_.str.3@PAGEOFF
	bl	_checkGLcall
	and	w8, w20, #0xfffffffe
	cmp	w8, #128
	b.eq	LBB0_15
; %bb.6:
	str	x20, [sp]
Lloh9:
	adrp	x0, l_.str.4@PAGE
Lloh10:
	add	x0, x0, l_.str.4@PAGEOFF
LBB0_7:
	bl	_ERR
Lloh11:
	adrp	x8, _WINED3D_FENCE_ERROR@GOTPAGE
Lloh12:
	ldr	x8, [x8, _WINED3D_FENCE_ERROR@GOTPAGEOFF]
	b	LBB0_16
LBB0_8:
Lloh13:
	adrp	x0, l_.str.1@PAGE
Lloh14:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_TRACE
Lloh15:
	adrp	x8, _WINED3D_FENCE_NOT_STARTED@GOTPAGE
Lloh16:
	ldr	x8, [x8, _WINED3D_FENCE_NOT_STARTED@GOTPAGEOFF]
Lloh17:
	ldr	w20, [x8]
	b	LBB0_17
LBB0_9:
Lloh18:
	adrp	x9, _APPLE_FENCE@GOTPAGE
Lloh19:
	ldr	x9, [x9, _APPLE_FENCE@GOTPAGEOFF]
Lloh20:
	ldr	x9, [x9]
	ldr	x9, [x8, x9, lsl #3]
	cbz	x9, LBB0_12
; %bb.10:
	ldr	w0, [x20]
	bl	_glFinishFenceAPPLE
	bl	_GL_EXTCALL
Lloh21:
	adrp	x0, l_.str.5@PAGE
Lloh22:
	add	x0, x0, l_.str.5@PAGEOFF
	b	LBB0_14
LBB0_11:
Lloh23:
	adrp	x0, l_.str.2@PAGE
Lloh24:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_WARN
Lloh25:
	adrp	x8, _WINED3D_FENCE_WRONG_THREAD@GOTPAGE
Lloh26:
	ldr	x8, [x8, _WINED3D_FENCE_WRONG_THREAD@GOTPAGEOFF]
Lloh27:
	ldr	w20, [x8]
	b	LBB0_17
LBB0_12:
Lloh28:
	adrp	x9, _NV_FENCE@GOTPAGE
Lloh29:
	ldr	x9, [x9, _NV_FENCE@GOTPAGEOFF]
Lloh30:
	ldr	x9, [x9]
	ldr	x8, [x8, x9, lsl #3]
	cbz	x8, LBB0_18
; %bb.13:
	ldr	w0, [x20]
	bl	_glFinishFenceNV
	bl	_GL_EXTCALL
Lloh31:
	adrp	x0, l_.str.6@PAGE
Lloh32:
	add	x0, x0, l_.str.6@PAGEOFF
LBB0_14:
	bl	_checkGLcall
LBB0_15:
Lloh33:
	adrp	x8, _WINED3D_FENCE_OK@GOTPAGE
Lloh34:
	ldr	x8, [x8, _WINED3D_FENCE_OK@GOTPAGEOFF]
LBB0_16:
	ldr	w20, [x8]
	mov	x0, x19
	bl	_context_release
LBB0_17:
	mov	x0, x20
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
LBB0_18:
Lloh35:
	adrp	x0, l_.str.7@PAGE
Lloh36:
	add	x0, x0, l_.str.7@PAGEOFF
	b	LBB0_7
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpAdd	Lloh9, Lloh10
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpAdd	Lloh31, Lloh32
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpAdd	Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"fence %p, device %p.\n"

l_.str.1:                               ; @.str.1
	.asciz	"Fence not issued.\n"

	.comm	_WINED3D_FENCE_NOT_STARTED,4,2  ; @WINED3D_FENCE_NOT_STARTED
	.comm	_ARB_SYNC,8,3                   ; @ARB_SYNC
l_.str.2:                               ; @.str.2
	.asciz	"Fence finished from wrong thread.\n"

	.comm	_WINED3D_FENCE_WRONG_THREAD,4,2 ; @WINED3D_FENCE_WRONG_THREAD
	.comm	_GL_SYNC_FLUSH_COMMANDS_BIT,4,2 ; @GL_SYNC_FLUSH_COMMANDS_BIT
l_.str.3:                               ; @.str.3
	.asciz	"glClientWaitSync"

	.comm	_WINED3D_FENCE_OK,4,2           ; @WINED3D_FENCE_OK
l_.str.4:                               ; @.str.4
	.asciz	"glClientWaitSync returned %#x.\n"

	.comm	_WINED3D_FENCE_ERROR,4,2        ; @WINED3D_FENCE_ERROR
	.comm	_APPLE_FENCE,8,3                ; @APPLE_FENCE
l_.str.5:                               ; @.str.5
	.asciz	"glFinishFenceAPPLE"

	.comm	_NV_FENCE,8,3                   ; @NV_FENCE
l_.str.6:                               ; @.str.6
	.asciz	"glFinishFenceNV"

l_.str.7:                               ; @.str.7
	.asciz	"Fence created without GL support.\n"

.subsections_via_symbols
