Remove kZeroCopy_GrSurfaceFlag
Change-Id: I2869f97a14f3a1363ebfef5d657bd6468fc991f7 Reviewed-on: https://skia-review.googlesource.com/17491 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
112565e3e7
commit
7128fdd82d
@ -522,10 +522,6 @@ enum GrSurfaceFlags {
|
||||
* GrTexture::asRenderTarget() to access.
|
||||
*/
|
||||
kRenderTarget_GrSurfaceFlag = 0x1,
|
||||
/**
|
||||
* Placeholder for managing zero-copy textures
|
||||
*/
|
||||
kZeroCopy_GrSurfaceFlag = 0x2,
|
||||
};
|
||||
|
||||
GR_MAKE_BITFIELD_OPS(GrSurfaceFlags)
|
||||
|
@ -696,21 +696,6 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool linearTiling = false;
|
||||
if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) {
|
||||
// we can't have a linear texture with a mipmap
|
||||
if (texels.count() > 1) {
|
||||
SkDebugf("Trying to create linear tiled texture with mipmap");
|
||||
return nullptr;
|
||||
}
|
||||
if (fVkCaps->isConfigTexturableLinearly(desc.fConfig) &&
|
||||
(!renderTarget || fVkCaps->isConfigRenderableLinearly(desc.fConfig, false))) {
|
||||
linearTiling = true;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
if (renderTarget) {
|
||||
usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
@ -724,9 +709,6 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
|
||||
// texture.
|
||||
usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
VkFlags memProps = (!texels.empty() && linearTiling) ? VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT :
|
||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
|
||||
// This ImageDesc refers to the texture that will be read by the client. Thus even if msaa is
|
||||
// requested, this ImageDesc describes the resolved texture. Therefore we always have samples set
|
||||
// to 1.
|
||||
@ -736,11 +718,11 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
|
||||
imageDesc.fFormat = pixelFormat;
|
||||
imageDesc.fWidth = desc.fWidth;
|
||||
imageDesc.fHeight = desc.fHeight;
|
||||
imageDesc.fLevels = linearTiling ? 1 : mipLevels;
|
||||
imageDesc.fLevels = mipLevels;
|
||||
imageDesc.fSamples = 1;
|
||||
imageDesc.fImageTiling = linearTiling ? VK_IMAGE_TILING_LINEAR : VK_IMAGE_TILING_OPTIMAL;
|
||||
imageDesc.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
|
||||
imageDesc.fUsageFlags = usageFlags;
|
||||
imageDesc.fMemProps = memProps;
|
||||
imageDesc.fMemProps = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
|
||||
|
||||
GrVkTexture* tex;
|
||||
if (renderTarget) {
|
||||
@ -756,15 +738,8 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
|
||||
|
||||
if (!texels.empty()) {
|
||||
SkASSERT(texels.begin()->fPixels);
|
||||
bool success;
|
||||
if (linearTiling) {
|
||||
success = this->uploadTexDataLinear(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
|
||||
texels.begin()->fPixels, texels.begin()->fRowBytes);
|
||||
} else {
|
||||
success = this->uploadTexDataOptimal(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
|
||||
texels);
|
||||
}
|
||||
if (!success) {
|
||||
if (!this->uploadTexDataOptimal(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fConfig,
|
||||
texels)) {
|
||||
tex->unref();
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ bool does_full_buffer_contain_correct_color(GrColor* srcBuffer,
|
||||
}
|
||||
|
||||
void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixelConfig config,
|
||||
bool renderTarget, bool linearTiling) {
|
||||
bool renderTarget) {
|
||||
const int kWidth = 16;
|
||||
const int kHeight = 16;
|
||||
SkAutoTMalloc<GrColor> srcBuffer(kWidth*kHeight);
|
||||
@ -60,23 +60,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
|
||||
|
||||
fill_pixel_data(kWidth, kHeight, srcBuffer.get());
|
||||
|
||||
const GrVkCaps* caps = reinterpret_cast<const GrVkCaps*>(context->caps());
|
||||
|
||||
bool canCreate = true;
|
||||
// the expectation is that the given config is texturable/renderable with optimal tiling
|
||||
// but may not be with linear tiling
|
||||
if (linearTiling) {
|
||||
if (!caps->isConfigTexturableLinearly(config) ||
|
||||
(renderTarget && !caps->isConfigRenderableLinearly(config, false))) {
|
||||
canCreate = false;
|
||||
}
|
||||
}
|
||||
|
||||
GrSurfaceDesc surfDesc;
|
||||
surfDesc.fFlags = renderTarget ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags;
|
||||
if (linearTiling) {
|
||||
surfDesc.fFlags |= kZeroCopy_GrSurfaceFlag;
|
||||
}
|
||||
surfDesc.fOrigin = kTopLeft_GrSurfaceOrigin;
|
||||
surfDesc.fWidth = kWidth;
|
||||
surfDesc.fHeight = kHeight;
|
||||
@ -89,10 +74,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
|
||||
sk_sp<GrTextureProxy> proxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
|
||||
surfDesc, SkBudgeted::kNo,
|
||||
srcBuffer, 0);
|
||||
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (proxy) {
|
||||
REPORTER_ASSERT(reporter, canCreate);
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
|
||||
proxy, nullptr);
|
||||
|
||||
@ -118,8 +101,6 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
|
||||
dstBuffer,
|
||||
10,
|
||||
2));
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, !canCreate);
|
||||
}
|
||||
|
||||
surfDesc.fOrigin = kBottomLeft_GrSurfaceOrigin;
|
||||
@ -127,9 +108,8 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
|
||||
proxy = GrSurfaceProxy::MakeDeferred(context->resourceProvider(),
|
||||
surfDesc, SkBudgeted::kNo,
|
||||
srcBuffer, 0);
|
||||
REPORTER_ASSERT(reporter, proxy);
|
||||
if (proxy) {
|
||||
REPORTER_ASSERT(reporter, canCreate);
|
||||
|
||||
sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext(
|
||||
proxy, nullptr);
|
||||
|
||||
@ -156,23 +136,17 @@ void basic_texture_test(skiatest::Reporter* reporter, GrContext* context, GrPixe
|
||||
4,
|
||||
5));
|
||||
|
||||
} else {
|
||||
REPORTER_ASSERT(reporter, !canCreate);
|
||||
}
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkUploadPixelsTests, reporter, ctxInfo) {
|
||||
// RGBA
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false, false);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true, false);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false, true);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true, true);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, false);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kRGBA_8888_GrPixelConfig, true);
|
||||
|
||||
// BGRA
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false, false);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true, false);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false, true);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true, true);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, false);
|
||||
basic_texture_test(reporter, ctxInfo.grContext(), kBGRA_8888_GrPixelConfig, true);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user