FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
skia-python/src/skia/GrContext.cpp at main · skia-python/skia-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
skia-python
/
skia-python
Public
Notifications
You must be signed in to change notification settings
Fork
52
Star
322
Code
Issues
44
Pull requests
6
Discussions
Actions
Projects
Security and quality
1
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
skia-python
/
src
/
skia
/
GrContext.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
1341 lines (1245 loc) · 61.2 KB
Breadcrumbs
skia-python
/
src
/
skia
/
GrContext.cpp
Copy path
File metadata and controls
1341 lines (1245 loc) · 61.2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
include
"
common.h
"
#
include
<
include/core/SkTextureCompressionType.h
>
#
include
<
include/gpu/ganesh/GrBackendSemaphore.h
>
#
include
<
include/gpu/ganesh/GrBackendSurface.h
>
#
include
<
include/gpu/ganesh/GrContextThreadSafeProxy.h
>
#
include
<
include/gpu/GpuTypes.h
>
#
include
<
include/gpu/ganesh/mock/GrMockTypes.h
>
#
include
<
include/gpu/ganesh/gl/GrGLInterface.h
>
#
include
<
include/gpu/ganesh/gl/GrGLBackendSurface.h
>
#
include
<
include/gpu/ganesh/gl/GrGLDirectContext.h
>
#
include
<
include/gpu/ganesh/vk/GrVkTypes.h
>
#
include
<
include/gpu/ganesh/vk/GrVkBackendSemaphore.h
>
#
include
<
include/gpu/ganesh/vk/GrVkBackendSurface.h
>
#
include
<
include/gpu/ganesh/vk/GrVkDirectContext.h
>
#
ifdef
SK_METAL
#
include
<
include/gpu/ganesh/mtl/GrMtlBackendContext.h
>
#
include
<
include/gpu/ganesh/mtl/GrMtlBackendSemaphore.h
>
#
include
<
include/gpu/ganesh/mtl/GrMtlBackendSurface.h
>
#
include
<
include/gpu/ganesh/mtl/GrMtlDirectContext.h
>
#
endif
#
include
<
include/gpu/vk/VulkanBackendContext.h
>
#
include
<
include/gpu/MutableTextureState.h
>
#
include
<
pybind11/chrono.h
>
#
include
<
pybind11/stl.h
>
#
include
<
pybind11/cast.h
>
void
initGrContext_gl
(py::
module
&);
void
initGrContext_mock
(py::
module
&);
void
initGrContext_vk
(py::
module
&);
void
initGrContext
(py::
module
&m) {
py::enum_<GrBackendApi>(m,
"
GrBackendApi
"
,
R"docstring(
Possible 3D APIs that may be used by Ganesh.
)docstring"
,
py::arithmetic
())
.
value
(
"
kOpenGL
"
, GrBackendApi::
kOpenGL
)
.
value
(
"
kVulkan
"
, GrBackendApi::
kVulkan
)
.
value
(
"
kMetal
"
, GrBackendApi::
kMetal
)
.
value
(
"
kDirect3D
"
, GrBackendApi::
kDirect3D
)
/*
m118: Remove GrBackendApi::kDawn
*/
/*
.value("kDawn", GrBackendApi::kDawn)
*/
.
value
(
"
kMock
"
, GrBackendApi::
kMock
,
R"docstring(
Mock is a backend that does not draw anything. It is used for unit tests
and to measure CPU overhead.
)docstring"
)
.
value
(
"
kOpenGL_GrBackend
"
, GrBackendApi::
kOpenGL_GrBackend
,
R"docstring(
Added here to support the legacy GrBackend enum value and clients who
referenced it using :py:attr:`~skia.GrBackend.kOpenGL_GrBackend`.
)docstring"
)
.
export_values
();
py::enum_<skgpu::BackendApi>(m,
"
gpuBackendApi
"
,
R"docstring(
Possible 3D APIs that may be used by Graphite.
)docstring"
,
py::arithmetic
())
.
value
(
"
kDawn
"
, skgpu::BackendApi::
kDawn
)
.
value
(
"
kMetal
"
, skgpu::BackendApi::
kMetal
)
.
value
(
"
kVulkan
"
, skgpu::BackendApi::
kVulkan
)
.
value
(
"
kMock
"
, skgpu::BackendApi::
kMock
)
.
export_values
();
py::enum_<skgpu::Mipmapped>(m,
"
GrMipmapped
"
,
R"docstring(
Used to say whether a texture has mip levels allocated or not.
)docstring"
,
py::arithmetic
())
.
value
(
"
kNo
"
, skgpu::Mipmapped::
kNo
)
.
value
(
"
kYes
"
, skgpu::Mipmapped::
kYes
)
.
export_values
();
py::enum_<GrRenderable>(m,
"
GrRenderable
"
,
py::arithmetic
())
.
value
(
"
kNo
"
, GrRenderable::
kNo
)
.
value
(
"
kYes
"
, GrRenderable::
kYes
)
.
export_values
();
py::enum_<GrProtected>(m,
"
GrProtected
"
,
py::arithmetic
())
.
value
(
"
kNo
"
, GrProtected::
kNo
)
.
value
(
"
kYes
"
, GrProtected::
kYes
)
.
export_values
();
py::enum_<GrSurfaceOrigin>(m,
"
GrSurfaceOrigin
"
,
R"docstring(
GPU :py:class:`Image` and :py:class:`Surfaces` can be stored such that
(0, 0) in texture space may correspond to either the top-left or bottom-left
content pixel.
)docstring"
,
py::arithmetic
())
.
value
(
"
kTopLeft_GrSurfaceOrigin
"
,
GrSurfaceOrigin::
kTopLeft_GrSurfaceOrigin
)
.
value
(
"
kBottomLeft_GrSurfaceOrigin
"
,
GrSurfaceOrigin::
kBottomLeft_GrSurfaceOrigin
)
.
export_values
();
py::enum_<GrGLBackendState>(m,
"
GrGLBackendState
"
,
R"docstring(
A GrContext's cache of backend context state can be partially invalidated.
These enums are specific to the GL backend and we'd add a new set for an
alternative backend.
)docstring"
)
.
value
(
"
kRenderTarget_GrGLBackendState
"
,
GrGLBackendState::
kRenderTarget_GrGLBackendState
)
.
value
(
"
kTextureBinding_GrGLBackendState
"
,
GrGLBackendState::
kTextureBinding_GrGLBackendState
)
.
value
(
"
kView_GrGLBackendState
"
,
GrGLBackendState::
kView_GrGLBackendState
)
.
value
(
"
kBlend_GrGLBackendState
"
,
GrGLBackendState::
kBlend_GrGLBackendState
)
.
value
(
"
kMSAAEnable_GrGLBackendState
"
,
GrGLBackendState::
kMSAAEnable_GrGLBackendState
)
.
value
(
"
kVertex_GrGLBackendState
"
,
GrGLBackendState::
kVertex_GrGLBackendState
)
.
value
(
"
kStencil_GrGLBackendState
"
,
GrGLBackendState::
kStencil_GrGLBackendState
)
.
value
(
"
kPixelStore_GrGLBackendState
"
,
GrGLBackendState::
kPixelStore_GrGLBackendState
)
.
value
(
"
kProgram_GrGLBackendState
"
,
GrGLBackendState::
kProgram_GrGLBackendState
)
.
value
(
"
kFixedFunction_GrGLBackendState
"
,
GrGLBackendState::
kFixedFunction_GrGLBackendState
)
.
value
(
"
kMisc_GrGLBackendState
"
,
GrGLBackendState::
kMisc_GrGLBackendState
)
/*
.value("kPathRendering_GrGLBackendState",
GrGLBackendState::kPathRendering_GrGLBackendState)
*/
.
value
(
"
kALL_GrGLBackendState
"
,
GrGLBackendState::
kALL_GrGLBackendState
)
.
export_values
();
py::class_<GrFlushInfo>(m,
"
GrFlushInfo
"
,
R"docstring(
Struct to supply options to flush calls.
After issuing all commands, fNumSemaphore semaphores will be signaled by the
gpu. The client passes in an array of fNumSemaphores GrBackendSemaphores. In
general these :py:class:`GrBackendSemaphore`'s can be either initialized or
not. If they are initialized, the backend uses the passed in semaphore. If
it is not initialized, a new semaphore is created and the
:py:class:`GrBackendSemaphore` object is initialized with that semaphore.
The client will own and be responsible for deleting the underlying
semaphores that are stored and returned in initialized
:py:class:`GrBackendSemaphore` objects. The :py:class:`GrBackendSemaphore`
objects themselves can be deleted as soon as this function returns.
If a finishedProc is provided, the finishedProc will be called when all work
submitted to the gpu from this flush call and all previous flush calls has
finished on the GPU. If the flush call fails due to an error and nothing
ends up getting sent to the GPU, the finished proc is called immediately.
If a submittedProc is provided, the submittedProc will be called when all
work from this flush call is submitted to the GPU. If the flush call fails
due to an error and nothing will get sent to the GPU, the submitted proc is
called immediately. It is possibly that when work is finally submitted, that
the submission actual fails. In this case we will not reattempt to do the
submission. Skia notifies the client of these via the success bool passed
into the submittedProc. The submittedProc is useful to the client to know
when semaphores that were sent with the flush have actually been submitted
to the GPU so that they can be waited on (or deleted if the submit fails).
Note about GL: In GL work gets sent to the driver immediately during the
flush call, but we don't really know when the driver sends the work to the
GPU. Therefore, we treat the submitted proc as we do in other backends. It
will be called when the next GrDirectContext::submit is called after the flush (or
possibly during the flush if there is no work to be done for the flush). The
main use case for the submittedProc is to know when semaphores have been
sent to the GPU and even in GL it is required to call GrDirectContext::submit to
flush them. So a client should be able to treat all backend APIs the same in
terms of how the submitted procs are treated.
)docstring"
)
.
def
(py::init<>())
.
def_readonly
(
"
fNumSemaphores
"
, &GrFlushInfo::
fNumSemaphores
)
.
def_property
(
"
semaphores
"
,
[] (
const
GrFlushInfo& info) -> py::object {
auto
begin = info.
fSignalSemaphores
;
if
(!begin)
return
py::none
();
return
py::cast
(std::vector<GrBackendSemaphore>(
begin, begin + info.
fNumSemaphores
));
},
[] (GrFlushInfo& info,
std::vector<GrBackendSemaphore>& semaphores) {
info.
fNumSemaphores
= semaphores.
size
();
info.
fSignalSemaphores
= (semaphores.
size
()) ?
&semaphores[
0
] : (GrBackendSemaphore*)
nullptr
;
})
//
.def_readwrite("fFinishedProc", &GrFlushInfo::fFinishedProc)
//
.def_readwrite("fFinishedContext", &GrFlushInfo::fFinishedContext)
//
.def_readwrite("fSubmittedProc", &GrFlushInfo::fSubmittedProc)
//
.def_readwrite("fSubmittedContext", &GrFlushInfo::fSubmittedContext)
;
py::enum_<GrSemaphoresSubmitted>(m,
"
GrSemaphoresSubmitted
"
)
.
value
(
"
kNo
"
, GrSemaphoresSubmitted::
kNo
)
.
value
(
"
kYes
"
, GrSemaphoresSubmitted::
kYes
)
.
export_values
();
py::enum_<GrColorType>(m,
"
GrColorType
"
)
.
value
(
"
kUnknown
"
, GrColorType::
kUnknown
)
.
value
(
"
kAlpha_8
"
, GrColorType::
kAlpha_8
)
.
value
(
"
kBGR_565
"
, GrColorType::
kBGR_565
)
.
value
(
"
kABGR_4444
"
, GrColorType::
kABGR_4444
)
.
value
(
"
kRGBA_8888
"
, GrColorType::
kRGBA_8888
)
.
value
(
"
kRGBA_8888_SRGB
"
, GrColorType::
kRGBA_8888_SRGB
)
.
value
(
"
kRGB_888x
"
, GrColorType::
kRGB_888x
)
.
value
(
"
kRG_88
"
, GrColorType::
kRG_88
)
.
value
(
"
kBGRA_8888
"
, GrColorType::
kBGRA_8888
)
.
value
(
"
kRGBA_1010102
"
, GrColorType::
kRGBA_1010102
)
.
value
(
"
kGray_8
"
, GrColorType::
kGray_8
)
.
value
(
"
kAlpha_F16
"
, GrColorType::
kAlpha_F16
)
.
value
(
"
kRGBA_F16
"
, GrColorType::
kRGBA_F16
)
.
value
(
"
kRGBA_F16_Clamped
"
, GrColorType::
kRGBA_F16_Clamped
)
.
value
(
"
kRGBA_F32
"
, GrColorType::
kRGBA_F32
)
.
value
(
"
kAlpha_16
"
, GrColorType::
kAlpha_16
)
.
value
(
"
kRG_1616
"
, GrColorType::
kRG_1616
)
.
value
(
"
kRG_F16
"
, GrColorType::
kRG_F16
)
.
value
(
"
kRGBA_16161616
"
, GrColorType::
kRGBA_16161616
)
.
value
(
"
kAlpha_8xxx
"
, GrColorType::
kAlpha_8xxx
)
.
value
(
"
kAlpha_F32xxx
"
, GrColorType::
kAlpha_F32xxx
)
.
value
(
"
kGray_8xxx
"
, GrColorType::
kGray_8xxx
)
.
value
(
"
kRGB_888
"
, GrColorType::
kRGB_888
)
.
value
(
"
kR_8
"
, GrColorType::
kR_8
)
.
value
(
"
kR_16
"
, GrColorType::
kR_16
)
.
value
(
"
kR_F16
"
, GrColorType::
kR_F16
)
.
value
(
"
kGray_F16
"
, GrColorType::
kGray_F16
)
.
value
(
"
kLast
"
, GrColorType::
kLast
)
.
export_values
();
py::enum_<GrTextureType>(m,
"
GrTextureType
"
)
.
value
(
"
kNone
"
, GrTextureType::
kNone
)
.
value
(
"
k2D
"
, GrTextureType::k2D)
.
value
(
"
kRectangle
"
, GrTextureType::
kRectangle
)
.
value
(
"
kExternal
"
, GrTextureType::
kExternal
)
.
export_values
();
py::class_<GrBackendSemaphore>(m,
"
GrBackendSemaphore
"
)
.
def
(
py::init
())
/*
.def("initGL",
[] (GrBackendSemaphore& semaphore, void* glsync) {
semaphore.initGL(reinterpret_cast<GrGLsync>(glsync));
},
py::arg("glsync"))
*/
#
ifdef
SK_VULKAN
.
def_static
(
"
MakeVk
"
,
[] (
void
* vksemaphore) {
return
GrBackendSemaphores::MakeVk
(
reinterpret_cast
<VkSemaphore>(vksemaphore));
},
py::arg
(
"
semaphore
"
))
/*
.def("initVulkan",
[] (GrBackendSemaphore& semaphore, void* vksemaphore) {
semaphore.initVulkan(reinterpret_cast<VkSemaphore>(vksemaphore));
},
py::arg("semaphore"))
*/
#
endif
#
ifdef
SK_METAL
.
def_static
(
"
MakeMtl
"
,
[] (GrMTLHandle event,
uint64_t
value) {
return
GrBackendSemaphores::MakeMtl
(event, value);
},
py::arg
(
"
event
"
),
py::arg
(
"
value
"
))
//
.def("initMetal", &GrBackendSemaphore::initMetal)
#
endif
.
def
(
"
isInitialized
"
, &GrBackendSemaphore::isInitialized)
/*
.def("glSync",
[] (GrBackendSemaphore& semaphore) {
return reinterpret_cast<void*>(semaphore.glSync());
})
*/
#
ifdef
SK_VULKAN
.
def
(
"
vkSemaphore
"
,
[] (GrBackendSemaphore& semaphore) {
return
reinterpret_cast
<
void
*>(
GrBackendSemaphores::GetVkSemaphore
(semaphore));
})
#
endif
#
ifdef
SK_METAL
.
def
(
"
mtlSemaphore
"
,
[] (GrBackendSemaphore& semaphore) {
return
GrBackendSemaphores::GetMtlHandle
(semaphore);
})
.
def
(
"
mtlValue
"
,
[] (GrBackendSemaphore& semaphore) {
return
GrBackendSemaphores::GetMtlValue
(semaphore);
})
//
.def("mtlSemaphore", &GrBackendSemaphore::mtlSemaphore)
//
.def("mtlValue", &GrBackendSemaphore::mtlValue)
#
endif
;
py::class_<GrBackendFormat>(m,
"
GrBackendFormat
"
)
.
def
(py::init<>())
.
def
(py::init<
const
GrBackendFormat&>())
.
def_static
(
"
MakeGL
"
, py::overload_cast<GrGLenum, GrGLenum>(&GrBackendFormats::MakeGL),
py::arg
(
"
format
"
),
py::arg
(
"
target
"
))
#
ifdef
SK_VULKAN
.
def_static
(
"
MakeVk
"
, py::overload_cast<VkFormat,
bool
>(&GrBackendFormats::MakeVk),
py::arg
(
"
format
"
),
py::arg
(
"
willUseDRMFormatModifiers
"
) =
false
)
.
def_static
(
"
MakeVk
"
,
py::overload_cast<
const
skgpu::VulkanYcbcrConversionInfo&,
bool
>(
&GrBackendFormats::MakeVk),
py::arg
(
"
ycbcrInfo
"
),
py::arg
(
"
willUseDRMFormatModifiers
"
) =
false
)
#
endif
#
ifdef
SK_METAL
.
def_static
(
"
MakeMtl
"
, &GrBackendFormats::MakeMtl,
py::arg
(
"
format
"
))
#
endif
.
def_static
(
"
MakeMock
"
, &GrBackendFormat::MakeMock,
py::arg
(
"
colorType
"
),
py::arg
(
"
compression
"
),
py::arg
(
"
isStencilFormat
"
) =
false
)
.
def
(
"
__eq__
"
, &GrBackendFormat::
operator
==,
py::arg
(
"
other
"
),
py::is_operator
())
.
def
(
"
__ne__
"
, &GrBackendFormat::
operator
!=,
py::arg
(
"
other
"
),
py::is_operator
())
.
def
(
"
backend
"
, &GrBackendFormat::backend)
.
def
(
"
textureType
"
, &GrBackendFormat::textureType)
.
def
(
"
channelMask
"
, &GrBackendFormat::channelMask)
.
def
(
"
asGLFormat
"
, &GrBackendFormats::AsGLFormat)
#
ifdef
SK_VULKAN
.
def
(
"
asVkFormat
"
, &GrBackendFormats::AsVkFormat,
py::arg
(
"
format
"
))
.
def
(
"
getVkYcbcrConversionInfo
"
,
&GrBackendFormats::GetVkYcbcrConversionInfo)
#
endif
#
ifdef
SK_METAL
.
def
(
"
asMtlFormat
"
, &GrBackendFormats::AsMtlFormat)
#
endif
.
def
(
"
asMockColorType
"
, &GrBackendFormat::asMockColorType)
.
def
(
"
asMockCompressionType
"
, &GrBackendFormat::asMockCompressionType)
.
def
(
"
makeTexture2D
"
, &GrBackendFormat::makeTexture2D)
.
def
(
"
isValid
"
, &GrBackendFormat::isValid)
;
py::class_<GrBackendTexture>(m,
"
GrBackendTexture
"
)
.
def
(py::init<>())
.
def
(
py::init
(
[] (
int
width,
int
height, skgpu::Mipmapped mipMapped,
const
GrGLTextureInfo& glInfo) {
return
GrBackendTextures::MakeGL
(width, height,
mipMapped, glInfo);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
mipMapped
"
),
py::arg
(
"
glInfo
"
))
#
ifdef
SK_VULKAN
.
def
(
py::init
(
[] (
int
width,
int
height,
const
GrVkImageInfo& vkInfo) {
return
GrBackendTextures::MakeVk
(width, height, vkInfo);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
vkInfo
"
))
#
endif
#
ifdef
SK_METAL
.
def
(
py::init
(
[] (
int
width,
int
height, skgpu::Mipmapped mipmapped,
const
GrMtlTextureInfo& mtlInfo, std::string_view label) {
return
GrBackendTextures::MakeMtl
(width, height, mipmapped, mtlInfo, label);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
mipmapped
"
),
py::arg
(
"
mtlInfo
"
),
py::arg
(
"
label
"
) = std::string_view{})
#
endif
.
def
(py::init<
int
,
int
, skgpu::Mipmapped,
const
GrMockTextureInfo&>(),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
mipMapped
"
),
py::arg
(
"
mockInfo
"
))
.
def
(py::init<
const
GrBackendTexture&>(),
py::arg
(
"
that
"
))
.
def
(
"
dimensions
"
, &GrBackendTexture::dimensions)
.
def
(
"
width
"
, &GrBackendTexture::width)
.
def
(
"
height
"
, &GrBackendTexture::height)
.
def
(
"
hasMipmaps
"
, &GrBackendTexture::hasMipmaps)
.
def
(
"
backend
"
, &GrBackendTexture::backend)
.
def
(
"
getGLTextureInfo
"
, &GrBackendTextures::GetGLTextureInfo,
py::arg
(
"
info
"
))
.
def
(
"
glTextureParametersModified
"
,
&GrBackendTextures::GLTextureParametersModified)
#
ifdef
SK_VULKAN
.
def
(
"
getVkImageInfo
"
, &GrBackendTextures::GetVkImageInfo,
py::arg
(
"
info
"
))
.
def
(
"
setVkImageLayout
"
, &GrBackendTextures::SetVkImageLayout,
py::arg
(
"
layout
"
))
#
endif
#
ifdef
SK_METAL
.
def
(
"
getMtlTextureInfo
"
, &GrBackendTextures::GetMtlTextureInfo,
py::arg
(
"
info
"
))
#
endif
.
def
(
"
getBackendFormat
"
, &GrBackendTexture::getBackendFormat)
.
def
(
"
getMockTextureInfo
"
, &GrBackendTexture::getMockTextureInfo,
py::arg
(
"
info
"
))
.
def
(
"
setMutableState
"
, &GrBackendTexture::setMutableState,
py::arg
(
"
state
"
))
.
def
(
"
isProtected
"
, &GrBackendTexture::isProtected)
.
def
(
"
isValid
"
, &GrBackendTexture::isValid)
.
def
(
"
isSameTexture
"
, &GrBackendTexture::isSameTexture,
py::arg
(
"
texture
"
))
;
py::class_<GrContextOptions>(m,
"
GrContextOptions
"
)
.
def
(py::init<>())
//
TODO: Implement me!
;
/*
m118: Remove GrBackendSurfaceMutableState
*/
/*
py::class_<GrBackendSurfaceMutableState>(m, "GrBackendSurfaceMutableState",
R"docstring(
Since Skia and clients can both modify gpu textures and their connected
state, Skia needs a way for clients to inform us if they have modifiend any
of this state.
In order to not need setters for every single API and state, we use this
class to be a generic wrapper around all the mutable state. This class is
used for calls that inform Skia of these texture/image state changes by the
client as well as for requesting state changes to be done by Skia. The
backend specific state that is wrapped by this class are:
Vulkan: VkImageLayout and QueueFamilyIndex
)docstring")
.def(py::init<>())
#ifdef SK_VULKAN
.def(py::init<VkImageLayout, uint32_t>(),
py::arg("layout"), py::arg("queueFamilyIndex"))
.def("getVkImageLayout",
&GrBackendSurfaceMutableState::getVkImageLayout,
R"docstring(
If this class is not Vulkan backed it will return value of
VK_IMAGE_LAYOUT_UNDEFINED. Otherwise it will return the VkImageLayout.
)docstring")
.def("getQueueFamilyIndex",
&GrBackendSurfaceMutableState::getQueueFamilyIndex,
R"docstring(
If this class is not Vulkan backed it will return value of
VK_QUEUE_FAMILY_IGNORED. Otherwise it will return the VkImageLayout.
)docstring")
#endif
.def("isValid", &GrBackendSurfaceMutableState::isValid)
.def("backend", &GrBackendSurfaceMutableState::backend)
;
*/
py::class_<GrBackendRenderTarget>(m,
"
GrBackendRenderTarget
"
)
.
def
(py::init<>())
.
def
(
py::init
(
[] (
int
width,
int
height,
int
sampleCnt,
int
stencilBits,
const
GrGLFramebufferInfo& glInfo) {
return
GrBackendRenderTargets::MakeGL
(width, height,
sampleCnt, stencilBits, glInfo);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
sampleCnt
"
),
py::arg
(
"
stencilBits
"
),
py::arg
(
"
glInfo
"
))
.
def_static
(
"
MakeGL
"
, &GrBackendRenderTargets::MakeGL,
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
sampleCnt
"
),
py::arg
(
"
stencilBits
"
),
py::arg
(
"
glInfo
"
))
#
ifdef
SK_VULKAN
.
def
(
py::init
(
[] (
int
width,
int
height,
const
GrVkImageInfo& vkInfo) {
return
GrBackendRenderTargets::MakeVk
(width, height, vkInfo);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
vkInfo
"
))
.
def
(
py::init
(
[] (
int
width,
int
height,
int
sampleCnt,
const
GrVkImageInfo& vkInfo) {
/*
* m87's include/gpu/GrBackendSurface.h has this line:
* "Deprecated. Samplecount is now part of GrVkImageInfo."
* up to m117, until this was moved.
*
* So it is appropriate to ignore sampleCnt in this emulation.
*/
return
GrBackendRenderTargets::MakeVk
(width, height, vkInfo);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
sampleCnt
"
),
py::arg
(
"
vkInfo
"
))
#
endif
#
ifdef
SK_METAL
.
def
(
py::init
(
[] (
int
width,
int
height,
const
GrMtlTextureInfo& mtlInfo) {
return
GrBackendRenderTargets::MakeMtl
(width, height, mtlInfo);
}),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
mtlInfo
"
))
#
endif
.
def
(py::init<
int
,
int
,
int
,
int
,
const
GrMockRenderTargetInfo&>(),
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
sampleCnt
"
),
py::arg
(
"
stencilBits
"
),
py::arg
(
"
mockInfo
"
))
.
def
(
"
dimensions
"
, &GrBackendRenderTarget::dimensions)
.
def
(
"
width
"
, &GrBackendRenderTarget::width)
.
def
(
"
height
"
, &GrBackendRenderTarget::height)
.
def
(
"
sampleCnt
"
, &GrBackendRenderTarget::sampleCnt)
.
def
(
"
stencilBits
"
, &GrBackendRenderTarget::stencilBits)
.
def
(
"
backend
"
, &GrBackendRenderTarget::backend)
.
def
(
"
isFramebufferOnly
"
, &GrBackendRenderTarget::isFramebufferOnly)
.
def
(
"
getGLFramebufferInfo
"
, &GrBackendRenderTargets::GetGLFramebufferInfo,
R"docstring(
If the backend API is GL, copies a snapshot of the GrGLFramebufferInfo
struct into the passed in pointer and returns true. Otherwise returns
false if the backend API is not GL.
)docstring"
,
py::arg
(
"
info
"
))
#
ifdef
SK_VULKAN
.
def
(
"
getVkImageInfo
"
, &GrBackendRenderTargets::GetVkImageInfo,
R"docstring(
If the backend API is Vulkan, copies a snapshot of the GrVkImageInfo
struct into the passed in pointer and returns true. This snapshot will
set the fImageLayout to the current layout state. Otherwise returns
false if the backend API is not Vulkan.
)docstring"
,
py::arg
(
"
info
"
))
.
def
(
"
setVkImageLayout
"
, &GrBackendRenderTargets::SetVkImageLayout,
R"docstring(
Anytime the client changes the VkImageLayout of the VkImage captured by
this GrBackendRenderTarget, they must call this function to notify Skia
of the changed layout.
)docstring"
,
py::arg
(
"
layout
"
))
#
endif
#
ifdef
SK_METAL
.
def
(
"
getMtlTextureInfo
"
, &GrBackendRenderTargets::GetMtlTextureInfo,
py::arg
(
"
info
"
))
#
endif
.
def
(
"
getBackendFormat
"
, &GrBackendRenderTarget::getBackendFormat,
R"docstring(
Get the GrBackendFormat for this render target (or an invalid format if
this is not valid).
)docstring"
)
.
def
(
"
getMockRenderTargetInfo
"
,
&GrBackendRenderTarget::getMockRenderTargetInfo,
R"docstring(
If the backend API is Mock, copies a snapshot of the GrMockTextureInfo
struct into the passed in pointer and returns true. Otherwise returns
false if the backend API is not Mock.
)docstring"
,
py::arg
(
"
info
"
))
//
.def("setMutableState", &GrBackendRenderTarget::setMutableState)
.
def
(
"
isProtected
"
, &GrBackendRenderTarget::isProtected)
.
def
(
"
isValid
"
, &GrBackendRenderTarget::isValid)
;
py::class_<GrContext_Base, sk_sp<GrContext_Base>, SkRefCnt>(m,
"
GrContext_Base
"
)
.
def
(
"
asDirectContext
"
, &GrContext_Base::asDirectContext,
R"docstring(
Safely downcast to a :py:class:`GrDirectContext`.
)docstring"
)
.
def
(
"
backend
"
, &GrContext_Base::backend,
R"docstring(
The 3D API backing this context.
)docstring"
)
.
def
(
"
defaultBackendFormat
"
, &GrContext_Base::defaultBackendFormat,
R"docstring(
Retrieve the default :py:class:`GrBackendFormat` for a given
:py:class:`ColorType` and renderability. It is guaranteed that this
backend format will be the one used by the :py:class:`GrContext`
:py:class:`ColorType` and SurfaceCharacterization-based
:py:meth:`createBackendTexture` methods.
The caller should check that the returned format is valid.
)docstring"
)
.
def
(
"
compressedBackendFormat
"
, &GrContext_Base::compressedBackendFormat)
.
def
(
"
threadSafeProxy
"
, &GrContext_Base::threadSafeProxy)
//
.def("priv", py::overload_cast<>(&GrContext_Base::priv))
//
.def("priv", py::overload_cast<>(&GrContext_Base::priv, py::const_))
;
py::class_<GrImageContext, sk_sp<GrImageContext>, GrContext_Base>(
m,
"
GrImageContext
"
)
;
py::class_<GrRecordingContext, sk_sp<GrRecordingContext>, GrImageContext>(
m,
"
GrRecordingContext
"
)
.
def
(
"
defaultBackendFormat
"
, &GrRecordingContext::defaultBackendFormat,
R"docstring(
Retrieve the default :py:class:`GrBackendFormat` for a given
:py:class:`ColorType` and renderability.
It is guaranteed that this backend format will be the one used by the
following :py:class:`ColorType` and SurfaceCharacterization-based
:py:meth:`createBackendTexture` methods.
The caller should check that the returned format is valid.
)docstring"
,
py::arg
(
"
colorType
"
),
py::arg_v
(
"
renderable
"
, GrRenderable::
kNo
,
"
skia.GrRenderable.kNo
"
))
.
def
(
"
abandoned
"
, &GrRecordingContext::abandoned,
R"docstring(
Reports whether the :py:class:`GrDirectContext` associated with this
:py:class:`GrRecordingContext` is abandoned.
When called on a :py:class:`GrDirectContext` it may actively check
whether the underlying 3D API device/context has been disconnected
before reporting the status. If so, calling this method will transition
the :py:class:`GrDirectContext` to the abandoned state.
)docstring"
)
.
def
(
"
colorTypeSupportedAsSurface
"
,
&GrRecordingContext::colorTypeSupportedAsSurface,
R"docstring(
Can a :py:class:`Surface` be created with the given color type. To check
whether MSAA is supported use
:py:meth:`~GrRecordingContext.maxSurfaceSampleCountForColorType`.
)docstring"
,
py::arg
(
"
colorType
"
))
.
def
(
"
maxTextureSize
"
, &GrRecordingContext::maxTextureSize,
R"docstring(
Gets the maximum supported texture size.
)docstring"
)
.
def
(
"
maxRenderTargetSize
"
, &GrRecordingContext::maxRenderTargetSize,
R"docstring(
Gets the maximum supported render target size.
)docstring"
)
.
def
(
"
colorTypeSupportedAsImage
"
,
&GrRecordingContext::colorTypeSupportedAsImage,
R"docstring(
Can a :py:class:`Image` be created with the given color type.
)docstring"
)
.
def
(
"
maxSurfaceSampleCountForColorType
"
,
&GrRecordingContext::maxSurfaceSampleCountForColorType,
R"docstring(
Gets the maximum supported sample count for a color type.
1 is returned if only non-MSAA rendering is supported for the color
type. 0 is returned if rendering to this color type is not supported at
all.
)docstring"
)
//
.def("priv",
//
py::overload_cast<>(&GrRecordingContext::priv))
//
.def("priv",
//
py::overload_cast<>(&GrRecordingContext::priv, py::const_))
;
py::enum_<GrSyncCpu>(m,
"
GrSyncCpu
"
,
R"docstring(
)docstring"
,
py::arithmetic
())
.
value
(
"
kNo
"
, GrSyncCpu::
kNo
)
.
value
(
"
kYes
"
, GrSyncCpu::
kYes
)
.
export_values
();
py::enum_<GrPurgeResourceOptions>(m,
"
GrPurgeResourceOptions
"
,
R"docstring(
)docstring"
,
py::arithmetic
())
.
value
(
"
kAllResources
"
, GrPurgeResourceOptions::
kAllResources
)
.
value
(
"
kScratchResourcesOnly
"
, GrPurgeResourceOptions::
kScratchResourcesOnly
)
.
export_values
();
py::class_<GrDirectContext, sk_sp<GrDirectContext>, GrRecordingContext>(m,
"
GrDirectContext
"
)
.
def
(
"
resetContext
"
, &GrDirectContext::resetContext,
R"docstring(
The :py:class:`GrContext` normally assumes that no outsider is setting
state within the underlying 3D API's context/device/whatever.
This call informs the context that the state was modified and it should
resend. Shouldn't be called frequently for good performance. The flag
bits, state, is dependent on which backend is used by the context,
either GL or D3D (possible in future).
)docstring"
,
py::arg
(
"
state
"
) =
kAll_GrBackendState
)
.
def
(
"
resetGLTextureBindings
"
, &GrDirectContext::resetGLTextureBindings,
R"docstring(
If the backend is :py:attr:`~GrBackendApi.kOpenGL`, then all texture
unit/target combinations for which the GrContext has modified the bound
texture will have texture id 0 bound.
This does not flush the :py:class:`GrContext`. Calling
:py:meth:`resetContext` does not change the set that will be bound to
texture id 0 on the next call to :py:meth:`resetGLTextureBindings`.
After this is called all unit/target combinations are considered to have
unmodified bindings until the :py:class:`GrContext` subsequently
modifies them (meaning if this is called twice in a row with no
intervening :py:class:`GrContext` usage then the second call is a
no-op.)
)docstring"
)
.
def
(
"
abandonContext
"
, &GrDirectContext::abandonContext,
R"docstring(
Abandons all GPU resources and assumes the underlying backend 3D API
context is no longer usable.
Call this if you have lost the associated GPU context, and thus internal
texture, buffer, etc. references/IDs are now invalid. Calling this
ensures that the destructors of the :py:class:`GrContext` and any of its
created resource objects will not make backend 3D API calls. Content
rendered but not previously flushed may be lost. After this function is
called all subsequent calls on the GrContext will fail or be no-ops.
The typical use case for this function is that the underlying 3D context
was lost and further API calls may crash.
For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or
VkInstance used to create the GrContext must be alive before calling
abandonContext.
)docstring"
)
.
def
(
"
abandoned
"
, &GrDirectContext::abandoned,
R"docstring(
Returns true if the context was abandoned or if the if the backend
specific context has gotten into an unrecoverarble, lost state (e.g.
in Vulkan backend if we've gotten a VK_ERROR_DEVICE_LOST). If the
backend context is lost, this call will also abandon the GrContext.
)docstring"
)
.
def
(
"
oomed
"
, &GrDirectContext::oomed,
R"docstring(
Checks if the underlying 3D API reported an out-of-memory error.
If this returns true it is reset and will return false until another
out-of-memory error is reported by the 3D API. If the context is
abandoned then this will report false.
Currently this is implemented for:
OpenGL [ES] - Note that client calls to glGetError() may swallow
GL_OUT_OF_MEMORY errors and therefore hide the error from Skia. Also, it
is not advised to use this in combination with enabling
GrContextOptions::fSkipGLErrorChecks. That option may prevent GrContext
from ever checking the GL context for OOM.
Vulkan - Reports true if VK_ERROR_OUT_OF_HOST_MEMORY or
VK_ERROR_OUT_OF_DEVICE_MEMORY has occurred.
)docstring"
)
.
def
(
"
releaseResourcesAndAbandonContext
"
,
&GrDirectContext::releaseResourcesAndAbandonContext,
R"docstring(
This is similar to :py:meth:`abandonContext` however the underlying 3D
context is not yet lost and the :py:class:`GrContext` will cleanup all
allocated resources before returning.
After returning it will assume that the underlying context may no longer
be valid.
The typical use case for this function is that the client is going to
destroy the 3D context but can't guarantee that :py:class:`GrContext`
will be destroyed first (perhaps because it may be ref'ed elsewhere by
either the client or Skia objects).
For Vulkan, even if the device becomes lost, the VkQueue, VkDevice, or
VkInstance used to create the GrContext must be alive before calling
:py:meth:`releaseResourcesAndAbandonContext`.
)docstring"
)
.
def
(
"
getResourceCacheLimit
"
, &GrDirectContext::getResourceCacheLimit,
R"docstring(
Return the current GPU resource cache limit in bytes.
)docstring"
)
.
def
(
"
getResourceCacheUsage
"
, &GrDirectContext::getResourceCacheUsage,
R"docstring(
Gets the current GPU resource cache usage.
:param int resourceCount: If non-null, returns the number of resources
that are held in the cache.
:param int maxResourceBytes: If non-null, returns the total number of
bytes of video memory held in the cache.
)docstring"
,
py::arg
(
"
resourceCount
"
) =
nullptr
,
py::arg
(
"
maxResourceBytes
"
) =
nullptr
)
.
def
(
"
getResourceCachePurgeableBytes
"
,
&GrDirectContext::getResourceCachePurgeableBytes,
R"docstring(
Gets the number of bytes in the cache consumed by purgeable (e.g.
unlocked) resources.
)docstring"
)
.
def
(
"
setResourceCacheLimit
"
, &GrDirectContext::setResourceCacheLimit,
R"docstring(
Specify the GPU resource cache limit.
If the cache currently exceeds this limit, it will be purged (LRU) to
keep the cache within the limit.
:param maxResourceBytes: The maximum number of bytes of video memory
that can be held in the cache.
)docstring"
,
py::arg
(
"
maxResourceBytes
"
))
.
def
(
"
freeGpuResources
"
, &GrDirectContext::freeGpuResources,
R"docstring(
Frees GPU created by the context.
Can be called to reduce GPU memory pressure.
)docstring"
)
/*
.def("performDeferredCleanup", &GrDirectContext::performDeferredCleanup,
R"docstring(
Purge GPU resources that haven't been used in the past 'msNotUsed'
milliseconds or are otherwise marked for deletion, regardless of whether
the context is under budget.
)docstring",
py::arg("msNotUsed"))
*/
.
def
(
"
purgeResourcesNotUsedInMs
"
, &GrDirectContext::purgeResourcesNotUsedInMs,
py::arg
(
"
msNotUsed
"
))
.
def
(
"
purgeUnlockedResources
"
,
py::overload_cast<
size_t
,
bool
>(&GrDirectContext::purgeUnlockedResources),
R"docstring(
Purge unlocked resources from the cache until the the provided byte
count has been reached or we have purged all unlocked resources.
The default policy is to purge in LRU order, but can be overridden to
prefer purging scratch resources (in LRU order) prior to purging other
resource types.
:maxBytesToPurge: the desired number of bytes to be purged.
:preferScratchResources: If true scratch resources will be purged prior
to other resource types.
)docstring"
,
py::arg
(
"
maxBytesToPurge
"
),
py::arg
(
"
preferScratchResources
"
))
.
def
(
"
purgeUnlockedResources
"
,
py::overload_cast<GrPurgeResourceOptions>(&GrDirectContext::purgeUnlockedResources),
R"docstring(
This entry point is intended for instances where an app has been
backgrounded or suspended.
:opts: If kScratchResourcesOnly only unlocked scratch resources will be purged prior
enforcing the budget requirements.
)docstring"
,
py::arg
(
"
opts
"
))
.
def
(
"
maxTextureSize
"
, &GrDirectContext::maxTextureSize,
R"docstring(
Gets the maximum supported texture size.
)docstring"
)
.
def
(
"
maxRenderTargetSize
"
, &GrDirectContext::maxRenderTargetSize,
R"docstring(
Gets the maximum supported render target size.
)docstring"
)
.
def
(
"
colorTypeSupportedAsImage
"
, &GrDirectContext::colorTypeSupportedAsImage,
R"docstring(
Can a :py:class:`Image` be created with the given color type.
)docstring"
,
py::arg
(
"
colorType
"
))
.
def
(
"
colorTypeSupportedAsSurface
"
, &GrDirectContext::colorTypeSupportedAsSurface,
R"docstring(
Can a SkSurface be created with the given color type.
To check whether MSAA is supported use
:py:meth:`maxSurfaceSampleCountForColorType`.
)docstring"
,
py::arg
(
"
colorType
"
))
.
def
(
"
maxSurfaceSampleCountForColorType
"
,
&GrDirectContext::maxSurfaceSampleCountForColorType,
R"docstring(
Gets the maximum supported sample count for a color type.
1 is returned if only non-MSAA rendering is supported for the color
type. 0 is returned if rendering to this color type is not supported at
all.
)docstring"
,
py::arg
(
"
colorType
"
))
.
def
(
"
wait
"
,
[] (GrDirectContext& context,
const
std::vector<GrBackendSemaphore>& semaphores,
bool
deleteSemaphoresAfterWait) {
return
context.
wait
(
semaphores.
size
(), &semaphores[
0
], deleteSemaphoresAfterWait);
},
R"docstring(
Inserts a list of GPU semaphores that the current GPU-backed API must
wait on before executing any more commands on the GPU.
Skia will take ownership of the underlying semaphores and delete them
once they have been signaled and waited on. If this call returns false,
then the GPU back-end will not wait on any passed in semaphores, and the
client will still own the semaphores.
)docstring"
,
py::arg
(
"
semaphores
"
),
py::arg
(
"
deleteSemaphoresAfterWait
"
) =
true
)
.
def
(
"
flushAndSubmit
"
, py::overload_cast<GrSyncCpu>(&GrDirectContext::flushAndSubmit),
R"docstring(
Call to ensure all drawing to the context has been flushed and submitted
to the underlying 3D API. This is equivalent to calling :py:meth:`flush`
with a default :py:class:`GrFlushInfo` followed by :py:meth:`submit`.
)docstring"
,
py::arg_v
(
"
sync
"
, GrSyncCpu::
kNo
,
"
skia.GrSyncCpu.kNo
"
))
.
def
(
"
flush
"
, py::overload_cast<
const
GrFlushInfo&>(&GrDirectContext::flush),
R"docstring(
Call to ensure all drawing to the context has been flushed to underlying
3D API specific objects. A call to :py:meth:`GrContext.submit` is always
required to ensure work is actually sent to the gpu. Some specific API
details:
:GL: Commands are actually sent to the driver, but glFlush is never
called. Thus some sync objects from the flush will not be valid
until a submission occurs.
:Vulkan/Metal/D3D/Dawn: Commands are recorded to the backend APIs
corresponding command buffer or encoder objects. However, these
objects are not sent to the gpu until a submission occurs.
If the return is GrSemaphoresSubmitted::kYes, only initialized
GrBackendSemaphores will be submitted to the gpu during the next submit
call (it is possible Skia failed to create a subset of the semaphores).
The client should not wait on these semaphores until after submit has
been called, but must keep them alive until then. If a submit flag was
passed in with the flush these valid semaphores can we waited on
immediately. If this call returns GrSemaphoresSubmitted::kNo, the GPU
backend will not submit any semaphores to be signaled on the GPU. Thus
the client should not have the GPU wait on any of the semaphores passed
in with the GrFlushInfo. Regardless of whether semaphores were submitted
to the GPU or not, the client is still responsible for deleting any
initialized semaphores.
Regardleess of semaphore submission the context will still be flushed.
It should be emphasized that a return value of
GrSemaphoresSubmitted::kNo does not mean the flush did not happen. It
simply means there were no semaphores submitted to the GPU. A caller
should only take this as a failure if they passed in semaphores to be
submitted.
)docstring"
,
py::arg
(
"
info
"
))
.
def
(
"
flush
"
, py::overload_cast<>(&GrDirectContext::flush))
.
def
(
"
submit
"
, py::overload_cast<GrSyncCpu>(&GrDirectContext::submit),
R"docstring(
Submit outstanding work to the gpu from all previously un-submitted
flushes. The return value of the submit will indicate whether or not the
submission to the GPU was successful.
If the call returns true, all previously passed in semaphores in flush
calls will have been submitted to the GPU and they can safely be waited
on. The caller should wait on those semaphores or perform some other
global synchronization before deleting the semaphores.
If it returns false, then those same semaphores will not have been
submitted and we will not try to submit them again. The caller is free
to delete the semaphores at any time.
If the syncCpu flag is true this function will return once the gpu has
finished with all submitted work.
)docstring"
,
py::arg_v
(
"
sync
"
, GrSyncCpu::
kNo
,
"
skia.GrSyncCpu.kNo
"
))
.
def
(
"
checkAsyncWorkCompletion
"
, &GrDirectContext::checkAsyncWorkCompletion,
R"docstring(
Checks whether any asynchronous work is complete and if so calls related
callbacks.
)docstring"
)
//
.def("priv", (GrContextPriv (GrDirectContext::*)()) &GrContext::priv)
//
.def("priv", (const GrContextPriv (GrDirectContext::*)() const) &GrContext::priv)
//
.def("dumpMemoryStatistics", &GrDirectContext::dumpMemoryStatistics,
//
"Enumerates all cached GPU resources and dumps their memory to "
//
"traceMemoryDump.")
.
def
(
"
supportsDistanceFieldText
"
, &GrDirectContext::supportsDistanceFieldText)
.
def
(
"
storeVkPipelineCacheData
"
, py::overload_cast<>(&GrDirectContext::storeVkPipelineCacheData))
.
def_static
(
"
ComputeImageSize
"
,
[] (sk_sp<SkImage> image, skgpu::Mipmapped mapped,
bool
useNextPow2) {
//
REVISIT: process skgpu::Mipmapped and useNextPow2 = true
return
image->
textureSize
();
},
py::arg
(
"
image
"
),
py::arg
(
"
mipMapped
"
),
py::arg
(
"
useNextPow2
"
) =
false
)
.
def
(
"
defaultBackendFormat
"
, &GrDirectContext::defaultBackendFormat,
R"docstring(
Retrieve the default :py:class:`GrBackendFormat` for a given
:py:class:`ColorType` and renderability.
It is guaranteed that this backend format will be the one used by the
following :py:class:`ColorType` and SurfaceCharacterization-based
:py:meth:`createBackendTexture` methods.
The caller should check that the returned format is valid.
)docstring"
,
py::arg
(
"
colorType
"
),
py::arg_v
(
"
renderable
"
, GrRenderable::
kNo
,
"
skia.GrRenderable.kNo
"
))
.
def
(
"
createBackendTexture
"
,
py::overload_cast<
int
,
int
,
const
GrBackendFormat&, skgpu::Mipmapped,
GrRenderable, GrProtected, std::string_view>(&GrDirectContext::createBackendTexture),
R"docstring(
If possible, create an uninitialized backend texture.
The client should ensure that the returned backend texture is valid.
For the Vulkan backend the layout of the created VkImage will be:
VK_IMAGE_LAYOUT_UNDEFINED .
)docstring"
,
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
backendFormat
"
),
py::arg
(
"
mipMapped
"
),
py::arg
(
"
renderable
"
),
py::arg_v
(
"
isProtected
"
, GrProtected::
kNo
,
"
skia.GrProtected.kNo
"
),
py::arg
(
"
label
"
) = std::string_view{})
.
def
(
"
createBackendTexture
"
,
py::overload_cast<
int
,
int
, SkColorType, skgpu::Mipmapped,
GrRenderable, GrProtected, std::string_view>(&GrDirectContext::createBackendTexture),
R"docstring(
If possible, create an uninitialized backend texture.
The client should ensure that the returned backend texture is valid. If
successful, the created backend texture will be compatible with the
provided :py:class:`ColorType`. For the Vulkan backend the layout of the
created VkImage will be: VK_IMAGE_LAYOUT_UNDEFINED.
)docstring"
,
py::arg
(
"
width
"
),
py::arg
(
"
height
"
),
py::arg
(
"
colorType
"
),
py::arg
(
"
mipMapped
"
),
py::arg
(
"
renderable
"
),
py::arg_v
(
"
isProtected
"
, GrProtected::
kNo
,
"
skia.GrProtected.kNo
"
),
py::arg
(
"
label
"
) = std::string_view{})
.
def
(
"
createBackendTexture
"
,
[] (GrDirectContext& context,
int
width,
int
height,
const
GrBackendFormat& backendFormat,
const
SkColor4f& color,
skgpu::Mipmapped mipMapped, GrRenderable renderable,
GrProtected isProtected) {
return
context.
createBackendTexture
(
width, height, backendFormat, color, mipMapped, renderable,
isProtected);
},
R"docstring(
If possible, create a backend texture initialized to a particular color.
The client should ensure that the returned backend texture is valid. The
client can pass in a finishedProc to be notified when the data has been
uploaded by the gpu and the texture can be deleted. The client is
required to call GrDirectContext::submit to send the upload work to the gpu.
The finishedProc will always get called even if we failed to create the
GrBackendTexture.
For the Vulkan backend the layout of the created VkImage will be:
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL .
)docstring"
,
View remainder of file in raw view
Back
|
FazBrowse Home
|
New Git URL