@Hans
As Karlos said, the -8 return code corresponds to W3D_NOGFXMEM. See the header file.
Yes, yes, that's what I did, it was me not Karlos who mentioned this define

Anyway, the docs should be extended accordingly.
If only things were so simple. Picasso96 doesn't like to share VRAM with anything else, so Warp3D has to pull a few tricks. Without going into too much detail, Warp3D usually allocates blocks of VRAM at a time, and then stores multiple smaller textures in one block. Due to the way that things are set up, it has to lock these allocations in place, or the texture base pointers will become invalid if Picasso96 chooses to perform paging/defragging (which could happen at any time). Unfortunately, this also means that Picasso96's defragging becomes less effective, because there are large blocks of VRAM locked in place.
This issue happens any time. I'd not expect 128 MB VRAM / 2GB RAM to be fragmented that much, especially right after boot, that this allocation wouldn't be possible anymore. As further tests revealed it even happens with 16bit textures too. There are some interesting test results below that reveal that it sometimes happens even if only about 4 MB tex-data is used for a texture. That's such a low amount compared to what's available, it just shouldn't fail.
@Karlos
Calculating the size of the bitmap to allocate is a non trivial function that starts with the square root of the requested size in bytes and then tries to find the nearest hardware aligned width and adjust the height to compensate for the difference.
I don't get it why perfectly 32bit-pot texture size calculations shouldn't be trivial. Under certain conditions (unsupported texture format, non-pot-texture, conversions) I'd understand that, but not in such a case where the conditions are optimal.
Even if the required alignment would be 512 bytes internally it should be no problem to find such a memory area (at least not until you threw tons of textures at the driver and it probably
really gets fragmented) and to get away without any size modifications in that scenario.
However, due to the nature of the allocator it is unlikely even in the exact 2048x2048 case that the requested BitMap will be the same physical dimension. It won't be wider than that, but it might end up taller.
Taller? Weird algorithm. Anyway: apparently the allocator can do it - at least sometimes. It sometimes can create something the GPU likes, which would be 2048x2048, not wider not taller. "The nature of the allocator": smeels like the root of evil, that allocator.
In theory your 16 bit texture will need 8MB. This should result in a 32 bit BitMap allocation of something like 1536x1376 (128 byte width aligned). That shouldn't fail, so your 2048x2048 texture will get allocated.
A 16 or 32 bit 2048x2048 texture data is already perfectly 128 byte alignable. It is even 4096 byte alignable. Why would the driver do such funny resizing? He should happily take and swallow it. Anyway, see tests below: same issue, probably a bit less often.
It is likely this that results in the failure to allocate VRAM because you can't allocate a BitMap bigger than 2048x2048 either.
So on the one hand the allocater sometimes tries to create something taller than 2048 you say? But at the same time it knows that this would be useless anyway, since you can't allocate such a bitmap. And besides that it makes no sense to resize anything at all in that case in the first place. Interesting strategy.
Luckily sometimes it apparenty doesn't do something that weird and simply delivers what the GPU wants, namely a 2048x2048 texture (we know that because it's displayed correctly and, as you said, it cannot handle something larger - so it has to be 2048x2048). Now if that driver would just do so always.
@thread
I did some more tests:
1. it happens with both 32bit RGBA format W3D_R8G8B8A8 and W3D_A8R8G8B8.
2. it happens with W3D_R8G8B8 too.
3a. it works with the 16bit format W3D_R5G6B5, W3D_A4R4G4B4 and W3D_A1R5G5B5...
3b. ... but not always and not under real world conditions with some more textures - sometimes it also fails after boot and with the mini test-app. So all in all those are not better than their 32bit brothers: just like those it's sometimes go and sometimes not. Maybe the chances are somewhat higher that it works, but that may be just my imagination.
4. it also happens with 2048x1024 and 1024x2048 at both 32bit and 16bit (! so it fails even at about low 4 MB tex-data).
5. it works with 2048x512 and 512x2048 at both 16bit and 32bit (! so it
can also work if about 4 MB tex-data).
6. just for completeness: it happens independent of the screen's format / window size.
7. I disabled W3D_AUTOTEXMANAGEMENT. Then we get W3D_NOGFXMEM when calling W3D_UploadTexture.
8. interesting: if I call W3D_DrawArray a second time right after it failed then it tells me success. And actually draws something. But it apparently uses an incomplete texture (or none at all). It also behaves this way if I rebind the texture beforehand.
9. interesting: sometimes (randomly, behaves that way quite often though in the small test-prog) only the
first W3D_DrawArray call fails, the second and all others simply work. So if you create that 2048x2048x32 texture in frame X then W3D_DrawArray fails in frame X but works in X+1, X+2, X+n. If it worked that way during a test session you can create / delete that or other textures without issues, whenever you create a 2048x2048x32 again it continues to behave that same way (btw. tested again: it doesn't even have to be spread over frames, if you simply issue that second call immediately after the failed one, then it works - sometimes, of course

)
Okay, so at the bottom line we got the following:
Although Warp3D reports that it can handle 2048x2048 textures here the truth is that it sometimes can and sometimes cannot. Since the cause doesn't seem to be related (only) to the amount of textures in use or the texture-format or the size (at least not always), because sometimes it works / sometimes it doesn't, whatever information (max-texture-size, texture-creation-status) you maybe got is pretty useless, it's a matter of luck.
The tests seem to indicate the follwing rule of thumb:
it usually fails in real life if either the width or the height of the texture is 2048 and the other edge's size is at least 1024. The amount of bytes required to store the texture data doesn't seem to matter that much (because even 16bit 2048x1024 / 1024x2048 fails).
Anyway, the worst part isn't the issue itself - the worst part is that the texture's creation and everything works just fine (at least you're told so by Warp3D). So you have no chance to correct this issue until it's too late.
If Warp3D tells me that my texture creation succeeded then that information should be reliable.
If it is a memory issue of whatever kind then the memory handler is obviously seriously broken. The amount (low compared to VRAM size) of textures in use etc. simply don't really justify such failures on the test system.
Luckily I found a work-around for that latter problem that works for me:
after I successfully (?) created such a texture I temporarily disable auto-tex-management and call W3D_UploadTexture. If that one tells me W3D_NOGFXMEM I know that this texture, although created successfully, is not worth a dime.
So I could at least "move" that failure-information to where it belongs.
If that's reliable? Don't really know, it seems to work so far...
Really a pity, this whole bug: the GPU/card can do it, but the driver is so unreliable that your best bet seems to be to always divide Warp3D's max-texture-size info by 2 to be on the safe side
