• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Vector Sprites Causing Hundreds of Texture Swaps

RyanC

Member
Hi everyone,

I'm getting hundreds if not thousands of texture swaps while using SWF vector sprites!

This project is 10 months on the way and all the backgrounds have been completed after many months of hard work.

Today I found this bug report online which states that in GMStudio SWFs use one texture page for each gradient:
http://bugs.yoyogames.com/view.php?id=15676

If this is true then this project could be over!

Someone please tell me there's a way around this?
 
R

Robert

Guest
PS: How are you tracking the texture swaps? How did you find out it was doing that?
 

RangerX

Member
It true that you will get a load of texture pages. You will need to manage them more closely, grouping them, flushing them, etc. Look at the whole section of the manual about it.

And Robert, to see the number of texture swaps you need to display the debug info on screen. I don't remember what's the function or drawn command to have it displayed though. I'd have to look in the manual
 

RyanC

Member
What an absolute disaster, the level backgrounds have taken months to complete, if I have to replace them all with sprites now we're talking over 250 of them at around 1024 and some even 2048 in size, that's why vectors were chosen in the first place.

This should have been stated in the manual, there must be some way to make GM render them directly?

Flipping heck this project could end up being abandoned after nearly a whole year of hard work, I can't even sleep right now!
 
I

icuurd12b42

Guest
You should add another report. this is unacceptable. and the guy who replied in the bug report, his reasoning is total BS. I remap my uvs in my shaders all the time its like 2 lines of code.
 
J

jackhigh24

Guest
ye mate add another bug report as that one you linked to says there not going to do much about it unless they get more reports.
 

RyanC

Member
You should add another report. this is unacceptable. and the guy who replied in the bug report, his reasoning is total BS. I remap my uvs in my shaders all the time its like 2 lines of code.
Are you saying I maybe able to fix the issue with a shader then?
There are approximately 6 background vectors per level, and I'm considering drawing them to surfaces so that hopefully each of them will require only 1 texture swap instead of 1 for each gradient in the SWF vector image.
 

Rushad

Member
I have a similar problem with vector sprites and filed this bug.
http://help.yoyogames.com/hc/en-us/requests/107794

I have a large number of swf animations I wanted to import into the project, but whats happening is each frame of the animation is being placed on its own texture page. Worst I cant even flush these textures using draw_texture_flush.

The GM Vector Art article doesnt mention any of these huge limitations, quite misleading. Hope theres a fix :/
 
I

icuurd12b42

Guest
Are you saying I maybe able to fix the issue with a shader then?
There are approximately 6 background vectors per level, and I'm considering drawing them to surfaces so that hopefully each of them will require only 1 texture swap instead of 1 for each gradient in the SWF vector image.
I dont see how, the uv realigning has to be done on the image they use... and only possible if that image was to be placed in the texture page much like they do with sprites. the code is simple. where it need to be done relies on the structure of their image system. There is no workaround for this, even if you made a shader to remap to a surface onto which every required images was tiled on, this applies also to spine animations, the system still would request a draw with the original image (causing a swap) so even if the shader would ignore using the source image and use your tiled on surface images, the problem would still be there...
 

RyanC

Member
I think this really needs to be added to the manual, I've now got to re-license the software for the vector art and export them all again as sprites which I'm not going to do because this will take months.
How about drawing each vector to a surface on room_start and then just flushing them at room_end?
 
I

icuurd12b42

Guest
If they are not animated the I guess it's doable. you need to tile the images on a surface big enough to hold them all, remember the coords and use draw_surface_part.
 

RyanC

Member
The background scripts are fairly complex already due to vectors manually being tiled horizontally and scaled dynamically when reacting constantly to the zoom function on the view so I think I may need to use one texture page per vector so I can just switch draw_sprite_ext for draw_surface_stretched
There will be 5 or 6 texture swaps instead of 1 but that's still better than 800+

Just seen there's a draw_surface_part_ext so that might be an option, hope it's not too intensive though, as I'll be using it 25 times per tick!
 
Last edited:

RyanC

Member
Anyone know what the maximum recommended surface size is for performance? would drawing and swapping 5 surfaces of 2048 by 2048 be faster than having one massive surface of 8192 and using draw_surface_part_ext?
 
I

icuurd12b42

Guest
no swaps is better than some. 4k is the optimum size for swap performance vs size. and since there is no getting around swap from the normal operation out of your control then 4k is my recommendation
 
K

KriLL

Guest
Hey guys. I also use vectors for my whole game but no gradients at all so I guess that is why it works ok :(
I guess you are not able to remove the gradients without a lot of work...

I guess the only way to get gradients working is to do a fake gradient yourself made up of a few colours but i guess thats not much help.
 
Only one work around if you want your game to run fine on mobile, don't use them!
Game maker is so disappointing. Swf system is totally flawed and spriter is not supported for mobile. The only thing that could work is spine which is super expensive and also not easy to do animations unlike in spriter. Even i would have purchased spriter for the sake of my games only if there is a way to import spriter animations in spine but sadly there is none. I am completely doomed now. My game features high resolution graphics and if i begin to use png images then mobile devices will crash due to lack of ram. Another big flaw of gamemaker is that there is no control over vram. There should be an option to remove textures from ram dynamically and keep what we want in real time. There is an option "draw_texture_flush()" which is not very helpful because it completely erases all the textures from vram and cause a big lag so can't use it in real time. There should be a way to manually delete a texture page from vram and add to it and this will take mobile optimizations to the next level.
 
I

icuurd12b42

Guest
Game maker is so disappointing. Swf system is totally flawed and spriter is not supported for mobile. The only thing that could work is spine which is super expensive and also not easy to do animations unlike in spriter. Even i would have purchased spriter for the sake of my games only if there is a way to import spriter animations in spine but sadly there is none. I am completely doomed now. My game features high resolution graphics and if i begin to use png images then mobile devices will crash due to lack of ram. Another big flaw of gamemaker is that there is no control over vram. There should be an option to remove textures from ram dynamically and keep what we want in real time. There is an option "draw_texture_flush()" which is not very helpful because it completely erases all the textures from vram and cause a big lag so can't use it in real time. There should be a way to manually delete a texture page from vram and add to it and this will take mobile optimizations to the next level.
It not that the image is NOT in vram, it's that the texture in not in the active slot. vector graphics come with a texture that defines the character... every time that character is drawn and the texture it needs to draw with is not in the active slot, it is put in the slot (causing a swap) to then be drawn...

There is no way to combine the texture for the characters into one texture page... so the only possible remedy is to make sure you draw every (same) character one after the other.
 

RyanC

Member
Game maker is so disappointing. Swf system is totally flawed and spriter is not supported for mobile. The only thing that could work is spine which is super expensive and also not easy to do animations unlike in spriter. Even i would have purchased spriter for the sake of my games only if there is a way to import spriter animations in spine but sadly there is none. I am completely doomed now. My game features high resolution graphics and if i begin to use png images then mobile devices will crash due to lack of ram. Another big flaw of gamemaker is that there is no control over vram. There should be an option to remove textures from ram dynamically and keep what we want in real time. There is an option "draw_texture_flush()" which is not very helpful because it completely erases all the textures from vram and cause a big lag so can't use it in real time. There should be a way to manually delete a texture page from vram and add to it and this will take mobile optimizations to the next level.
I went down this road a few months ago, exploring every possible way and even talk to some founders of GMS about all this, even if you make a system that captures vectors on the fly and coverts them into sprites of the appropriate size, there is still no way to flush them from the RAM, only the texture memory, you can draw lots of the vectors to a big surface and then use draw_surface_part() to save on texture swaps but if you're using animations this could get complicated.
After 2 or 3 months of messing around with the SWF vectors and conversion systems I pulled the lot out and just used sprites. Now my game doesn't crash anymore on mobile.
 
Top