Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 007d97d

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Allow creating SkSurfaceCharacterizations directly for vk secondary CB context.
Bug: chromium:1144921 Change-Id: I9ca905eb9f2542aafbde25e0baa5430640277699 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/331877 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
1 parent 541f2ac commit 007d97d

File tree

5 files changed

+164
-50
lines changed

5 files changed

+164
-50
lines changed

RELEASE_NOTES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Milestone 88
99

1010
* <insert new release notes here>
1111

12+
* Add support for creating SkSurfaceCharacterizations directly for use by a
13+
GrVkSecondaryCBDrawContext.
14+
https://review.skia.org/331877
15+
1216
* Removed SkSurfaceProps::kLegacyFontHost_InitType, SkFontLCDConfig, and related code.
1317
The default pixel geometry for SkSurfaceProps is now kUnknown instead of kRGB_H.
1418
The removal was guarded by the SK_LEGACY_SURFACE_PROPS build flag which was later removed.

include/gpu/GrContextThreadSafeProxy.h

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,46 @@ class SK_API GrContextThreadSafeProxy final : public SkNVRefCnt<GrContextThreadS
3636
* that created this proxy. On failure the resulting characterization will be invalid (i.e.,
3737
* "!c.isValid()").
3838
*
39-
* @param cacheMaxResourceBytes The max resource bytes limit that will be in effect when the
40-
* DDL created with this characterization is replayed.
41-
* Note: the contract here is that the DDL will be created as
42-
* if it had a full 'cacheMaxResourceBytes' to use. If replayed
43-
* into a GrContext that already has locked GPU memory, the
44-
* replay can exceed the budget. To rephrase, all resource
45-
* allocation decisions are made at record time and at playback
46-
* time the budget limits will be ignored.
47-
* @param ii The image info specifying properties of the SkSurface that
48-
* the DDL created with this characterization will be replayed
49-
* into.
50-
* Note: Ganesh doesn't make use of the SkImageInfo's alphaType
51-
* @param backendFormat Information about the format of the GPU surface that will
52-
* back the SkSurface upon replay
53-
* @param sampleCount The sample count of the SkSurface that the DDL created with
54-
* this characterization will be replayed into
55-
* @param origin The origin of the SkSurface that the DDL created with this
56-
* characterization will be replayed into
57-
* @param surfaceProps The surface properties of the SkSurface that the DDL created
58-
* with this characterization will be replayed into
59-
* @param isMipMapped Will the surface the DDL will be replayed into have space
60-
* allocated for mipmaps?
61-
* @param willUseGLFBO0 Will the surface the DDL will be replayed into be backed by GL
62-
* FBO 0. This flag is only valid if using an GL backend.
63-
* @param isTextureable Will the surface be able to act as a texture?
64-
* @param isProtected Will the (Vulkan) surface be DRM protected?
39+
* @param cacheMaxResourceBytes The max resource bytes limit that will be in effect
40+
* when the DDL created with this characterization is
41+
* replayed.
42+
* Note: the contract here is that the DDL will be
43+
* created as if it had a full 'cacheMaxResourceBytes'
44+
* to use. If replayed into a GrContext that already has
45+
* locked GPU memory, the replay can exceed the budget.
46+
* To rephrase, all resource allocation decisions are
47+
* made at record time and at playback time the budget
48+
* limits will be ignored.
49+
* @param ii The image info specifying properties of the SkSurface
50+
* that the DDL created with this characterization will
51+
* be replayed into.
52+
* Note: Ganesh doesn't make use of the SkImageInfo's
53+
* alphaType
54+
* @param backendFormat Information about the format of the GPU surface that
55+
* will back the SkSurface upon replay
56+
* @param sampleCount The sample count of the SkSurface that the DDL
57+
* created with this characterization will be replayed
58+
* into
59+
* @param origin The origin of the SkSurface that the DDL created with
60+
* this characterization will be replayed into
61+
* @param surfaceProps The surface properties of the SkSurface that the DDL
62+
* created with this characterization will be replayed into
63+
* @param isMipMapped Will the surface the DDL will be replayed into have
64+
* space allocated for mipmaps?
65+
* @param willUseGLFBO0 Will the surface the DDL will be replayed into be
66+
* backed by GL FBO 0. This flag is only valid if using
67+
* an GL backend.
68+
* @param isTextureable Will the surface be able to act as a texture?
69+
* @param isProtected Will the (Vulkan) surface be DRM protected?
70+
* @param vkRTSupportsInputAttachment Can the vulkan surface be used as in input
71+
attachment?
72+
* @param forVulkanSecondaryCommandBuffer Will the surface be wrapping a vulkan secondary
73+
* command buffer via a GrVkSecondaryCBDrawContext? If
74+
* this is true then the following is required:
75+
* isTexureable = false
76+
* isMipMapped = false
77+
* willUseGLFBO0 = false
78+
* vkRTSupportsInputAttachment = false
6579
*/
6680
SkSurfaceCharacterization createCharacterization(
6781
size_t cacheMaxResourceBytes,
@@ -74,7 +88,8 @@ class SK_API GrContextThreadSafeProxy final : public SkNVRefCnt<GrContextThreadS
7488
bool willUseGLFBO0 = false,
7589
bool isTextureable = true,
7690
GrProtected isProtected = GrProtected::kNo,
77-
bool vkRTSupportsInputAttachment = false);
91+
bool vkRTSupportsInputAttachment = false,
92+
bool forVulkanSecondaryCommandBuffer = false);
7893

7994
/*
8095
* Retrieve the default GrBackendFormat for a given SkColorType and renderability.

src/gpu/GrContextThreadSafeProxy.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
4949
int sampleCnt, GrSurfaceOrigin origin,
5050
const SkSurfaceProps& surfaceProps,
5151
bool isMipMapped, bool willUseGLFBO0, bool isTextureable,
52-
GrProtected isProtected, bool vkRTSupportsInputAttachment) {
52+
GrProtected isProtected, bool vkRTSupportsInputAttachment,
53+
bool forVulkanSecondaryCommandBuffer) {
5354
SkASSERT(fCaps);
5455
if (!backendFormat.isValid()) {
5556
return {};
@@ -62,8 +63,10 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
6263
return {};
6364
}
6465

65-
if (GrBackendApi::kVulkan != backendFormat.backend() && vkRTSupportsInputAttachment) {
66-
// The vkRTSupportsInputAttachment flags can only be used for a Vulkan backend.
66+
if (GrBackendApi::kVulkan != backendFormat.backend() &&
67+
(vkRTSupportsInputAttachment || forVulkanSecondaryCommandBuffer)) {
68+
// The vkRTSupportsInputAttachment and forVulkanSecondaryCommandBuffer flags can only be
69+
// used for a Vulkan backend.
6770
return {};
6871
}
6972

@@ -98,6 +101,11 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
98101
return {};
99102
}
100103

104+
if (forVulkanSecondaryCommandBuffer &&
105+
(isTextureable || isMipMapped || willUseGLFBO0 || vkRTSupportsInputAttachment)) {
106+
return {};
107+
}
108+
101109
if (GrBackendApi::kVulkan == backendFormat.backend()) {
102110
if (GrBackendApi::kVulkan != fBackend) {
103111
return {};
@@ -121,7 +129,7 @@ SkSurfaceCharacterization GrContextThreadSafeProxy::createCharacterization(
121129
SkSurfaceCharacterization::MipMapped(isMipMapped),
122130
SkSurfaceCharacterization::UsesGLFBO0(willUseGLFBO0),
123131
SkSurfaceCharacterization::VkRTSupportsInputAttachment(vkRTSupportsInputAttachment),
124-
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(false),
132+
SkSurfaceCharacterization::VulkanSecondaryCBCompatible(forVulkanSecondaryCommandBuffer),
125133
isProtected,
126134
surfaceProps);
127135
}

src/gpu/vk/GrVkSecondaryCBDrawContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ class SK_SPI GrVkSecondaryCBDrawContext : public SkRefCnt {
109109
bool draw(const SkDeferredDisplayList* deferredDisplayList);
110110
#endif
111111

112+
bool isCompatible(const SkSurfaceCharacterization& characterization) const;
113+
112114
private:
113115
explicit GrVkSecondaryCBDrawContext(sk_sp<SkGpuDevice>, const SkSurfaceProps*);
114116

115-
bool isCompatible(const SkSurfaceCharacterization& characterization) const;
116-
117117
sk_sp<SkGpuDevice> fDevice;
118118
std::unique_ptr<SkCanvas> fCachedCanvas;
119119
const SkSurfaceProps fProps;

0 commit comments

Comments
 (0)