Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opengles2 & batching = conjoined lines #4964

Closed
AntTheAlchemist opened this issue Nov 15, 2021 · 6 comments
Closed

opengles2 & batching = conjoined lines #4964

AntTheAlchemist opened this issue Nov 15, 2021 · 6 comments

Comments

@AntTheAlchemist
Copy link
Contributor

I know I've been reporting some non-bugs recently, but I think I finally found one that's not a feature :-)

I'm getting 2 separate lines joined together in opengles2 when using batching. Reproduces on Android and Win10. Also happens if you try to draw each line using 2 points each with SDL_RenderDrawLinesF().

Simple code to repro:

#include <SDL.h>
int main(int argc, char** argv) {
	SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles2");
	SDL_SetHint(SDL_HINT_RENDER_BATCHING, "1");
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Window* w; SDL_Renderer* r;
	SDL_CreateWindowAndRenderer(640, 480, 0, &w, &r);
	SDL_RendererInfo info;
	SDL_GetRendererInfo(r, &info);
	SDL_SetWindowTitle(w, info.name);
	for (;;) {
		SDL_PumpEvents();
		SDL_Event event;
		while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, 0, SDL_LASTEVENT) == 1) {
			switch (event.type) {
			case SDL_QUIT:
				SDL_Quit();
				return 0;
			}
		}
		SDL_SetRenderDrawColor(r, 0, 0, 0, 0xFF);
		SDL_RenderClear(r);
		SDL_SetRenderDrawColor(r, 0, 0xFF, 0, 0xFF);
		// these two lines are conjoined:
		SDL_RenderDrawLineF(r, 20, 20, 20, 460);
		SDL_RenderDrawLineF(r, 100, 20, 100, 460);
		SDL_RenderPresent(r);
	}
}

image

@1bsyl
Copy link
Contributor

1bsyl commented Nov 15, 2021

@AntTheAlchemist thanks good catch ! that was while optimizing batching

1bsyl added a commit that referenced this issue Nov 15, 2021
put back the initial switch case because groups of joined lines cannot be batched.
@1bsyl
Copy link
Contributor

1bsyl commented Nov 15, 2021

@AntTheAlchemist
I put back the original switch case, because there is not batch with groups with at least a joined lines.
but eventually we could batch if we detect groups of singles lines...

1bsyl added a commit that referenced this issue Nov 15, 2021
@1bsyl
Copy link
Contributor

1bsyl commented Nov 15, 2021

@AntTheAlchemist
ok, now gles2 batchs group of single lines ...
tested with "testdraw2" by only activating "DrawLines" in the code.
SDL_RENDER_DRIVER=opengles2 SDL_RENDER_BATCHING=1 ./testdraw2 --info render 50000
goes to 90fps
and 15fps before.

@icculus
Copy link
Collaborator

icculus commented Nov 16, 2021

Okay to close this bug, then?

@icculus
Copy link
Collaborator

icculus commented Nov 16, 2021

(I'd just to say how grateful I was to see a bug report about line drawing that wasn't about how it was one pixel off, lol)

@1bsyl
Copy link
Contributor

1bsyl commented Nov 16, 2021

yes, hope it didn't interfere with all the line + ending pixel issues ... which look quite un-resolvables ..
I think it's ok to close the bug!

@1bsyl 1bsyl closed this as completed Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants