Skip to content

Commit a670782

Browse files
egdanielSkia Commit-Bot
authored andcommitted
Update GrAttachment budgeted and gpu memory size calculation.
This adds the budgeted parameter to the GrAttachment ctors. Currently we only have stencil and msaa attachments which are always budgeted but this will soon change as more things get added. Along the same lines this fixes the gpu memory size calculate on render target. The msaa attachment was getting double counted in the RT and the attachment itself. Bug: skia:10727 Change-Id: I3520de9627eadaa4074f7425df509a6c1ccbe07f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/327337 Reviewed-by: Robert Phillips <robertphillips@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
1 parent f1cd155 commit a670782

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

src/gpu/vk/GrVkAttachment.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ GrVkAttachment::GrVkAttachment(GrVkGpu* gpu,
1919
UsageFlags supportedUsages,
2020
const GrVkImageInfo& info,
2121
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState,
22-
sk_sp<const GrVkImageView> view)
22+
sk_sp<const GrVkImageView> view,
23+
SkBudgeted budgeted)
2324
: GrAttachment(gpu, dimensions, supportedUsages, info.fSampleCount, info.fProtected)
2425
, GrVkImage(gpu, info, std::move(mutableState), GrBackendObjectOwnership::kOwned)
2526
, fView(std::move(view)) {
26-
this->registerWithCache(SkBudgeted::kYes);
27+
this->registerWithCache(budgeted);
2728
}
2829

2930
sk_sp<GrVkAttachment> GrVkAttachment::MakeStencil(GrVkGpu* gpu,
@@ -33,7 +34,7 @@ sk_sp<GrVkAttachment> GrVkAttachment::MakeStencil(GrVkGpu* gpu,
3334
VkImageUsageFlags vkUsageFlags = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
3435
VK_IMAGE_USAGE_TRANSFER_DST_BIT;
3536
return GrVkAttachment::Make(gpu, dimensions, UsageFlags::kStencil, sampleCnt, format,
36-
vkUsageFlags, GrProtected::kNo);
37+
vkUsageFlags, GrProtected::kNo, SkBudgeted::kYes);
3738
}
3839

3940
sk_sp<GrVkAttachment> GrVkAttachment::MakeMSAA(GrVkGpu* gpu,
@@ -47,7 +48,7 @@ sk_sp<GrVkAttachment> GrVkAttachment::MakeMSAA(GrVkGpu* gpu,
4748
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
4849
VK_IMAGE_USAGE_TRANSFER_DST_BIT;
4950
return GrVkAttachment::Make(gpu, dimensions, UsageFlags::kMSAA, numSamples, format,
50-
vkUsageFlags, isProtected);
51+
vkUsageFlags, isProtected, SkBudgeted::kYes);
5152
}
5253

5354
sk_sp<GrVkAttachment> GrVkAttachment::Make(GrVkGpu* gpu,
@@ -56,7 +57,8 @@ sk_sp<GrVkAttachment> GrVkAttachment::Make(GrVkGpu* gpu,
5657
int sampleCnt,
5758
VkFormat format,
5859
VkImageUsageFlags vkUsageFlags,
59-
GrProtected isProtected) {
60+
GrProtected isProtected,
61+
SkBudgeted budgeted) {
6062
GrVkImage::ImageDesc imageDesc;
6163
imageDesc.fImageType = VK_IMAGE_TYPE_2D;
6264
imageDesc.fFormat = format;
@@ -92,7 +94,8 @@ sk_sp<GrVkAttachment> GrVkAttachment::Make(GrVkGpu* gpu,
9294
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState(
9395
new GrBackendSurfaceMutableStateImpl(info.fImageLayout, info.fCurrentQueueFamily));
9496
return sk_sp<GrVkAttachment>(new GrVkAttachment(gpu, dimensions, attachmentUsages, info,
95-
std::move(mutableState), std::move(imageView)));
97+
std::move(mutableState), std::move(imageView),
98+
budgeted));
9699
}
97100

98101
GrVkAttachment::~GrVkAttachment() {

src/gpu/vk/GrVkAttachment.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ class GrVkAttachment : public GrAttachment, public GrVkImage {
4646
int sampleCnt,
4747
VkFormat format,
4848
VkImageUsageFlags vkUsageFlags,
49-
GrProtected isProtected);
49+
GrProtected isProtected,
50+
SkBudgeted);
5051

5152
GrVkAttachment(GrVkGpu* gpu,
5253
SkISize dimensions,
5354
UsageFlags supportedUsages,
5455
const GrVkImageInfo&,
5556
sk_sp<GrBackendSurfaceMutableStateImpl> mutableState,
56-
sk_sp<const GrVkImageView> view);
57+
sk_sp<const GrVkImageView> view,
58+
SkBudgeted);
5759

5860
GrVkGpu* getVkGpu() const;
5961

src/gpu/vk/GrVkRenderTarget.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,21 @@ class GrVkRenderTarget: public GrRenderTarget, public virtual GrVkImage {
123123

124124
// This accounts for the texture's memory and any MSAA renderbuffer's memory.
125125
size_t onGpuMemorySize() const override {
126-
int numColorSamples = this->numSamples();
127-
if (numColorSamples > 1) {
128-
// Add one to account for the resolved VkImage.
129-
numColorSamples += 1;
126+
int numColorSamples = 0;
127+
if (this->numSamples() > 1) {
128+
// If we have an msaa attachment then its size will be handled by the attachment itself.
129+
if (!fMSAAAttachment) {
130+
numColorSamples += this->numSamples();
131+
}
132+
if (fResolveAttachmentView) {
133+
// Add one to account for the resolved VkImage.
134+
numColorSamples += 1;
135+
}
136+
} else {
137+
SkASSERT(!fResolveAttachmentView);
138+
numColorSamples = 1;
130139
}
140+
131141
return GrSurface::ComputeSize(this->backendFormat(), this->dimensions(),
132142
numColorSamples, GrMipmapped::kNo);
133143
}

tools/gpu/vk/VkTestUtils.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,12 @@ bool CreateVkBackendContext(GrVkGetProc getProc,
660660
if (0 != strncmp(deviceExtensions[i].extensionName, "VK_KHX", 6) &&
661661
0 != strncmp(deviceExtensions[i].extensionName, "VK_NVX", 6)) {
662662

663+
// This is an nvidia extension that isn't supported by the debug layers so we get lots
664+
// of warnings. We don't actually use it, so it is easiest to just not enable it.
665+
if (0 == strcmp(deviceExtensions[i].extensionName, "VK_NV_low_latency")) {
666+
continue;
667+
}
668+
663669
if (!hasKHRBufferDeviceAddress ||
664670
0 != strcmp(deviceExtensions[i].extensionName, "VK_EXT_buffer_device_address")) {
665671
deviceExtensionNames.push_back(deviceExtensions[i].extensionName);

0 commit comments

Comments
 (0)