Have gpu createTestingOlyBackendTexture know if it is a render target or not
In Vulkan we need to know at create time of a texture whether or not we will use it as a render target. BUG=skia:5458 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2093943002 Review-Url: https://codereview.chromium.org/2093943002
This commit is contained in:
parent
e074d1fa6a
commit
0a3a7f7303
@ -423,7 +423,8 @@ public:
|
|||||||
only to be used for testing (particularly for testing the methods that import an externally
|
only to be used for testing (particularly for testing the methods that import an externally
|
||||||
created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */
|
created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */
|
||||||
virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
||||||
GrPixelConfig config) = 0;
|
GrPixelConfig config,
|
||||||
|
bool isRenderTarget = false) = 0;
|
||||||
/** Check a handle represents an actual texture in the backend API that has not been freed. */
|
/** Check a handle represents an actual texture in the backend API that has not been freed. */
|
||||||
virtual bool isTestingOnlyBackendTexture(GrBackendObject) const = 0;
|
virtual bool isTestingOnlyBackendTexture(GrBackendObject) const = 0;
|
||||||
/** If ownership of the backend texture has been transferred pass true for abandonTexture. This
|
/** If ownership of the backend texture has been transferred pass true for abandonTexture. This
|
||||||
|
@ -4532,7 +4532,7 @@ void GrGLGpu::xferBarrier(GrRenderTarget* rt, GrXferBarrierType type) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
GrBackendObject GrGLGpu::createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
||||||
GrPixelConfig config) {
|
GrPixelConfig config, bool /*isRT*/) {
|
||||||
if (!this->caps()->isConfigTexturable(config)) {
|
if (!this->caps()->isConfigTexturable(config)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,8 @@ public:
|
|||||||
int height) override;
|
int height) override;
|
||||||
|
|
||||||
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
||||||
GrPixelConfig config) override;
|
GrPixelConfig config,
|
||||||
|
bool isRenderTarget = false) override;
|
||||||
bool isTestingOnlyBackendTexture(GrBackendObject) const override;
|
bool isTestingOnlyBackendTexture(GrBackendObject) const override;
|
||||||
void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) override;
|
void deleteTestingOnlyBackendTexture(GrBackendObject, bool abandonTexture) override;
|
||||||
|
|
||||||
|
@ -540,6 +540,10 @@ GrTexture* GrVkGpu::onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budget
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (renderTarget && !fVkCaps->isConfigRenderable(desc.fConfig, false)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool linearTiling = false;
|
bool linearTiling = false;
|
||||||
if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) {
|
if (SkToBool(desc.fFlags & kZeroCopy_GrSurfaceFlag)) {
|
||||||
// we can't have a linear texture with a mipmap
|
// we can't have a linear texture with a mipmap
|
||||||
@ -842,7 +846,8 @@ GrStencilAttachment* GrVkGpu::createStencilAttachmentForRenderTarget(const GrRen
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, int h,
|
GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, int h,
|
||||||
GrPixelConfig config) {
|
GrPixelConfig config,
|
||||||
|
bool isRenderTarget) {
|
||||||
|
|
||||||
VkFormat pixelFormat;
|
VkFormat pixelFormat;
|
||||||
if (!GrPixelConfigToVkFormat(config, &pixelFormat)) {
|
if (!GrPixelConfigToVkFormat(config, &pixelFormat)) {
|
||||||
@ -854,7 +859,12 @@ GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fVkCaps->isConfigTexurableLinearly(config)) {
|
if (isRenderTarget && !fVkCaps->isConfigRenderable(config, false)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fVkCaps->isConfigTexurableLinearly(config) &&
|
||||||
|
(!isRenderTarget || fVkCaps->isConfigRenderableLinearly(config, false))) {
|
||||||
linearTiling = true;
|
linearTiling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,6 +876,9 @@ GrBackendObject GrVkGpu::createTestingOnlyBackendTexture(void* srcData, int w, i
|
|||||||
VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
|
VkImageUsageFlags usageFlags = VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||||
usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
usageFlags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||||
usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
usageFlags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||||
|
if (isRenderTarget) {
|
||||||
|
usageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
VkImage image = VK_NULL_HANDLE;
|
VkImage image = VK_NULL_HANDLE;
|
||||||
GrVkAlloc alloc = { VK_NULL_HANDLE, 0, 0 };
|
GrVkAlloc alloc = { VK_NULL_HANDLE, 0, 0 };
|
||||||
|
@ -80,7 +80,8 @@ public:
|
|||||||
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
|
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
|
||||||
|
|
||||||
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
||||||
GrPixelConfig config) override;
|
GrPixelConfig config,
|
||||||
|
bool isRenderTarget) override;
|
||||||
bool isTestingOnlyBackendTexture(GrBackendObject id) const override;
|
bool isTestingOnlyBackendTexture(GrBackendObject id) const override;
|
||||||
void deleteTestingOnlyBackendTexture(GrBackendObject id, bool abandonTexture) override;
|
void deleteTestingOnlyBackendTexture(GrBackendObject id, bool abandonTexture) override;
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
|
|||||||
|
|
||||||
// Test again with a "direct" render target;
|
// Test again with a "direct" render target;
|
||||||
GrBackendObject textureObject = context->getGpu()->createTestingOnlyBackendTexture(nullptr,
|
GrBackendObject textureObject = context->getGpu()->createTestingOnlyBackendTexture(nullptr,
|
||||||
10, 10, kRGBA_8888_GrPixelConfig);
|
10, 10, kRGBA_8888_GrPixelConfig, true);
|
||||||
GrBackendTextureDesc desc;
|
GrBackendTextureDesc desc;
|
||||||
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
||||||
desc.fWidth = 10;
|
desc.fWidth = 10;
|
||||||
@ -764,7 +764,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture(
|
|||||||
desc.fHeight = kHeight;
|
desc.fHeight = kHeight;
|
||||||
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
||||||
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
||||||
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig);
|
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true);
|
||||||
desc.fSampleCnt = sampleCnt;
|
desc.fSampleCnt = sampleCnt;
|
||||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr);
|
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr);
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
@ -787,7 +787,7 @@ static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
|
|||||||
desc.fHeight = kHeight;
|
desc.fHeight = kHeight;
|
||||||
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
||||||
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
||||||
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig);
|
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true);
|
||||||
desc.fSampleCnt = sampleCnt;
|
desc.fSampleCnt = sampleCnt;
|
||||||
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc,
|
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
@ -29,7 +29,8 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
|
|
||||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
|
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
|
||||||
|
|
||||||
GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig);
|
GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig,
|
||||||
|
false);
|
||||||
const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
|
const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
|
||||||
|
|
||||||
// check basic borrowed creation
|
// check basic borrowed creation
|
||||||
@ -71,7 +72,8 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
|
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
|
||||||
|
|
||||||
GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig);
|
GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig,
|
||||||
|
true);
|
||||||
const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
|
const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
|
||||||
|
|
||||||
// check basic borrowed creation
|
// check basic borrowed creation
|
||||||
@ -118,7 +120,8 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
|
|||||||
void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
|
||||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
|
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->getGpu());
|
||||||
|
|
||||||
GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig);
|
GrBackendObject backendObj = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH, kPixelConfig,
|
||||||
|
true);
|
||||||
const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
|
const GrVkImageInfo* backendTex = reinterpret_cast<const GrVkImageInfo*>(backendObj);
|
||||||
|
|
||||||
// check basic borrowed creation
|
// check basic borrowed creation
|
||||||
|
@ -376,7 +376,7 @@ private:
|
|||||||
void clearStencil(GrRenderTarget* target) override {}
|
void clearStencil(GrRenderTarget* target) override {}
|
||||||
|
|
||||||
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h,
|
||||||
GrPixelConfig config) override {
|
GrPixelConfig config, bool isRT) override {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return false; }
|
bool isTestingOnlyBackendTexture(GrBackendObject ) const override { return false; }
|
||||||
|
Loading…
Reference in New Issue
Block a user