ImageSharp thing
(Sorry for butting in) So I'm trying to load a texture from path, but I get this error:
35 Replies
will check this in a sec
ok ty
GitHub
Silk.NET/Texture.cs at f07a7d8e3f61c63a9dfa78adc3eaad74b280955d · d...
The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, and DirectX bindings library your mother warned you about. - Silk.NET/Texture.cs at f07a7d8e3f61c63a9dfa78adc3eaad74b280955...
don't you need to call .AsSpan() or something similar on the return of DangerousGetPixelRowMemory?
I'll check
created a new error
and windows snipping tool just crashed
try this:
lol just realised @thomasmiz you were pinged onto this haha https://github.com/SixLabors/ImageSharp/issues/1739
AsSpan()
doesn't exist btw, just Span
well then
Span
😛😛
Btw it works now thanks
np
The examples should be updated at some point, since ImageSharp 2.0 changed some stuff.
I would also recommend reading this: https://docs.sixlabors.com/articles/imagesharp/memorymanagement.html
And note that images larger than 4MB currently do not work, it is fixed for the next release: https://github.com/SixLabors/ImageSharp/issues/1983
ah ok
I'll probably use jpg to get around that for now then if I need to
To my understanding that will not help, since 4MB limit is regarding raw image data. So at 4bytes/pixel => ~1000x1000 image is the limit.
Oh I see
But I would still recommend going with Imagesharp 2, since updating later will bring some extra work 😄
And I would expect that they will release a bugfix patch soon-ish.
Yeah, I don't want to rewrite code that's taken like 8 hours
I'm writing a game engine and making everything very modular and simple as possible to use for the user
Well just simple the old design was modular but it would take just too long to write
it's a shame that's a dangerous method now (well, i suppose it always was, but you know what i mean)
Yeah, does it affect anything or is it just a rename really?
well it just conveys that it's an unsafe method if you don't know what you're doing
Oh ok
@jbsp is there any non-dangerous method you know of to get row memory? i.e. one that copies if necessary.
or perhaps a way to iterate through the pixel memory in use for an image? (this would be cool and if that's possible and not already in there i'd look into it!)
oh excellent (sorry for the ping james)
Yeah, I've been checking in on those guys because I use them for loading images
They want to make changes that could make images not be stored fully sequentially, which is a bit of a problem for us who want to use it to load textures
yeah sounds like it
but hey, at least the think roey linked looks pretty nice. could either be used to flatten the buffer and do one textimage or do a bunch of subimage calls.
I think this is actually a good thing - you really should not be flushing the whole image to GPU at once anyways. Forcing you to tell the driver which part you are uploading, uploading that, and letting it do the invalidation etc improves perf and memory usage.
Really? I thought it was better to do it all at once
why?
Less GL calls, so it only needs to do any checks once
the driver will likely divvy it up internally for bus reasons anyways
[an uninformed guess]
GL I have no idea, but in vulkan it's for sure better.
Not very informed about GL, but there needs to be some range of host-gpu shared memory that the texture is first loaded into, and then copied into GPU-only memory.
There is usually only a small amount of host-gpu shared memory, so flushing a large texture all at once is not possible in the first place
now in GL maybe it's best to give it all the data at once cause you don't get to know what these pieces should be sized, but from a driver & VK perspective you can't really flush the whole texture at once
Why would it be more efficient for the user to send the texture in parts then? Wouldn't the driver be able to better optimize the sending if it knew everything from the start?
with opengl perhaps, with vulkan the idea is the driver doesn't need to know anything because it trusts the user
^ this, you are the only one who can ever know how much host memory your program is going to need and what size of upload buffer you can "afford" the driver can just make some guesses
if you upload a huge texture and the driver has decided to send it over 4mb at a time, then those 4mb are dedicated to this task for some time
if you now are trying to also stream mesh info to the GPU and are requesting some some visible memory for that, the driver has already taken those 4mb out of it's budget
plus it has to do some complicated logic to try and reduce fragementation, as there is no way for it to know for how long each bit is taken up, and compacting is hardly possible