drawImageRect not working with SkImages::BorrowTextureFrom / GrBackendTextures::MakeVk

31 views
Skip to first unread message

Kalen White

unread,
Jun 29, 2025, 5:35:49 AMJun 29
to skia-discuss
I am drawing this VkImage already on my app, its already transitioned to SHADER_READ_ONLY, and so its ready to be used by skia. 100% the case, its a valid texture, and it works already.  It's in the correct transition state of SHADER_READ_ONLY. 

I am giving it the proper coordinates (replaced with a fill box, which paints perfectly)



none sk_draw_fill_preserve(sk a) {
SkCanvas* sk = (SkCanvas*)a->sk_canvas;
draw_state ds = (draw_state)last(a->state);
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);

if (ds->blur_radius > 0.0f)
paint.setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, ds->blur_radius));
paint.setColor(ds->fill_color);
paint.setAntiAlias(true);

if (ds->tx) {
GrDirectContext* direct_ctx = a->skia->ctx.get();
texture tx = ds->tx;

GrVkImageInfo vk_info = {};
vk_info.fImage = tx->vk_image; // 0x0000510000000051 (same one used successfully given to a frosted blur shader, which works
vk_info.fImageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
vk_info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
vk_info.fFormat = tx->vk_format; // VK_FORMAT_B8G8R8A8_UNORM
vk_info.fLevelCount = 1;

GrBackendTexture backendTex = GrBackendTextures::MakeVk(tx->width, tx->height, vk_info);
sk_sp<SkImage> sk_image = SkImages::BorrowTextureFrom(
direct_ctx,
backendTex,
kTopLeft_GrSurfaceOrigin,
kRGBA_8888_SkColorType,
kPremul_SkAlphaType,
nullptr
);

SkRect dst = SkRect::MakeXYWH(ds->x, ds->y, ds->w, ds->h);
SkSamplingOptions sampling(SkFilterMode::kLinear, SkMipmapMode::kNone);

//paint.setColor(SK_ColorWHITE); // <-- this works
//sk->drawRect(dst, paint); // below, we get zero result.

sk->drawImageRect(sk_image, dst, sampling, &paint);
sk_sync(); // <-- ensuring a flush here right away

} else
sk->drawPath(*(SkPath*)a->sk_path, paint);
}


Theres no Vk Validation errors to this, either. (they are enabled) 

It just doesnt paint on my window like the White rectangle does in the same transform. 

Regards,
Kalen Novis White





Logan Welty

unread,
Jul 5, 2025, 11:17:53 PMJul 5
to skia-discuss

This doesn't answer your question sadly, but I have a question. Do you need to have a vkImage at all or not? Having trouble drawing a white square to my GTK-Application, because I am not feeding it into cairo at all.
Reply all
Reply to author
Forward
0 new messages