textureSize cannot be used?

89 views
Skip to first unread message

Nicolas Duval

unread,
Aug 22, 2022, 2:37:19 PM8/22/22
to skia-discuss
Hi all,

I'm trying to get a texture size (width/height) in SkSL, but it doesn't seem to work:

error: unknown identifier 'textureSize' vec2 size = textureSize(iImage1);

I know I can pass the dimensions via uniforms, but I'm curious if there's a way to do it directly in SkSL.

Thank you,

Nicolas

Brian Salomon

unread,
Aug 22, 2022, 2:46:57 PM8/22/22
to skia-d...@googlegroups.com
There are two issues:

1) Skia's public facing SkSL is designed to work across all of our GPU backends on all the GPUs we support. Effectively that means "compatible with OpenGL ES2" which doesn't offer textureSize. We are thinking about how to offer higher level functionality that may not work on some GPUs or on the CPU backend.

2) SkSL doesn't really have a concept of textures, but rather other shaders that you sample. Textures are plumbed through this abstraction by turning SkImages into image shaders that also include sampling information (filter, tile modes). Shaders as a class don't all have the same notion of size. That doesn't mean we could never offer a way to access the size of a texture, it just requires some thoughts of how to integrate that idea with the more generic idea of child shaders.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/1cf56015-252f-43d0-9d68-3e3b809ed239n%40googlegroups.com.


--

Brian Salomon | Office Hours: go/bsalomon-office | bsal...@google.com

Nicolas Duval

unread,
Aug 22, 2022, 3:06:17 PM8/22/22
to skia-discuss
Thank you Brian for the clarification!
Reply all
Reply to author
Forward
0 new messages