Does draw_sprite_ext break vertex batches if you use a colour?

P

ph101

Guest
The manual says:

"Texture batches, are basically bundles of data that are sent all at once to the GPU for rendering. The batch is "broken" when you change a font, a colour, a blend mode, or any other draw status that affects how things are drawn on a global scale, so you should try to limit these things to as few objects"

if you use this:

draw_sprite_ext(s_index,di_index,xx,yy,1,1,0,col,alpha)

Say if you change col from c_white (i.e. draw sprite as is normal) to say c_red does that break the batch? Or does manual mean only draw_set_colour.

Is there a list of functions that break the texture batch?

Thanks

.edit - for typos.
 
Last edited by a moderator:

jo-thijs

Member
I'm pretty certain draw_sprite_ext doesn't break batches like that.
I remember HTML5 was very slow if you performed draw_set_colour a lot in combination with draw_text,
but was very fast when using draw_text_colour because of this reason.
The same should apply to sprites I think.
 
A

Aura

Guest
You can test it yourself.

Either way, as the Manual states:

The Manual said:
The batch is "broken" when you change a font, a colour, a blend mode, or any other draw status that affects how things are drawn on a global scale, so you should try to limit these things to as few objects as possible since a high number of batches will adversely affect your games performance.
...and using draw_sprite_ext() to change the blend colour is not the same as changing how things are drawn on a global scale, you shouldn't worry too much.
 
P

ph101

Guest
Thanks folks. Are there any other things I need to look out for aside from blend mode and set draw colour that you know of? Slightly off topic, drawing text per se is pretty slow as I understand, but not sure if that is because it affects vertex. I read in the past from an old Nocturne post, ideally you should use a sprite of a word rather text for utmost speed (not possible in text heavy games of course..)
 
A

Aura

Guest
Drawing text using draw_text() should be faster than drawing a sprite. Fonts are internally stored as images as well and you basically draw those in an order, so I might be wrong though. But you should listen to the profiler in this case:

http://docs.yoyogames.com/source/dadiospice/001_advanced use/profiling.html

Either way, I don't see why using sprites for text would be a better idea. You get an extra work of texture memory mamagement. Simply use draw_text() and do not worry about micro-optimisations; there're better ways to optimise the draw pipeline:

http://www.yoyogames.com/blog/49
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
To those whom it may concern (as people seem to find this topic using search), draw_set_color and draw_set_alpha do not break the batch - this was an oversight in the manual and is said to be corrected in the upcoming release. Color/alpha become part of the vertex buffer (along with vertex positions and texture coordinates where appropriate) and as such are "free"

You can test this with following after calling show_debug_overlay(true):
GML:
    var c = keyboard_check(vk_space);
    if (!c) {
        draw_set_color(c_white);
        draw_set_alpha(1);
    }
    for (var i = 0; i < 100; i++) {
        if (c) {
            draw_set_color(make_color_hsv((i*3)%256,220,250));
            draw_set_alpha(0.6 + 0.4 * sin(i / 5 * pi));
        }
        draw_circle(32 + (i mod 10) * 20, 32 + (i div 10) * 20, 10, false);
    }
What does break the batch, however, is changing the shader or uniform values - e.g. if you are drawing a lot of images with custom parameters, it can be worthwhile to draw these using a vertex buffer and replace the uniforms with attributes instead.
 
Top