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

Performance boost for SDL ASCII drawing using color modulated textures #27566

Merged
merged 8 commits into from
Jan 20, 2019

Conversation

ZhilkinSerg
Copy link
Contributor

@ZhilkinSerg ZhilkinSerg commented Jan 12, 2019

Summary

SUMMARY: Performance "Performance boost for SDL drawing using color modulated textures"

Purpose of change

  • increase performance of SDL ASCII drawing;
  • allow selection of different renderers (some renderers can increase performance on a given system);
  • allow using of ZoomIt (and possibly other similar software) with proper renderer.

Describe the solution

  • replaced SDL_RenderFillRect with SDL_RenderCopy of a color modulated texture (fallback to SDL_RenderFillRect when color modulation is unsupported);
  • added USE_COLOR_MODULATED_TEXTURES graphic option which will enable usage of color modulated texture of color modulation (if it is supported);
  • added RENDERER graphic option which allows selecting which render driver to use (direct3d, opengl, opengles or software);
  • added output of draw benchmark to debug.log and allowed selection of benchmark length.

Additional context

image

Also see #19165 and #21748.

@ZhilkinSerg ZhilkinSerg added Code: Performance Performance boosting code (CPU, memory, etc.) SDL: Tiles / Sound Tiles visual interface and sounds. [C++] Changes (can be) made in C++. Previously named `Code` labels Jan 12, 2019
src/options.cpp Outdated Show resolved Hide resolved
src/sdltiles.cpp Outdated Show resolved Hide resolved
},
#endif
"software", COPT_NO_HIDE );

add( "SOFTWARE_RENDERING", "graphics", translate_marker( "Software rendering" ),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get rid of this option since it's redundant with renderer=software

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

- removed SOFTWARE_RENDERING option for non-Android builds;
- removed RENDERER option for non-TILES builds.
@kevingranade
Copy link
Member

Removing the software rendering option made things unhappy:

#0  0x00007ffff756ad7f in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7555672 in abort () from /usr/lib/libc.so.6
#2  0x00005555558ffe50 in realDebugmsg (filename=<optimized out>, filename@entry=0x555555f054d5 "src/options.cpp", line=<optimized out>, line@entry=0x555555f05692 "362", funcname=<optimized out>, 
    funcname@entry=0x555555f09660 <options_manager::cOpt::setPrerequisite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::__PRETTY_FUNCTION__> "void options_manager::cOpt::setPrerequisite(const string&)", text="setPrerequisite: unknown option bool") at src/debug.cpp:99
#3  0x0000555555824aa7 in realDebugmsg<char const*> (filename=0x555555f054d5 "src/options.cpp", line=0x555555f05692 "362", 
    funcname=0x555555f09660 <options_manager::cOpt::setPrerequisite(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)::__PRETTY_FUNCTION__> "void options_manager::cOpt::setPrerequisite(const string&)", mes=<optimized out>, args#0=@0x7fffffffddb0: 0x5555562c8068 "bool") at /usr/include/c++/8.2.1/ext/new_allocator.h:86
#4  0x0000555555cab2b1 in options_manager::cOpt::setPrerequisite (this=this@entry=0x5555562c7fd8, sOption="SOFTWARE_RENDERING") at /usr/include/c++/8.2.1/bits/basic_string.h:2281
#5  0x0000555555cb1b4c in options_manager::add_options_graphics (this=this@entry=0x5555562365a0 <get_options()::single_instance>) at /usr/include/c++/8.2.1/ext/new_allocator.h:79
#6  0x0000555555cbaa75 in options_manager::init (this=0x5555562365a0 <get_options()::single_instance>) at src/options.cpp:926
#7  0x00005555557dcad7 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:567

@ZhilkinSerg
Copy link
Contributor Author

Yes, I forgot to handle:

get_option( "FRAMEBUFFER_ACCEL" ).setPrerequisite( "SOFTWARE_RENDERING" );

Should I just remove the prerequisite here or should I expand setPrerequisite function to handle non-boolean values?

E.g.:

get_option( "FRAMEBUFFER_ACCEL" ).setPrerequisite( "RENDERER", "software" );

and/or

get_option( "FRAMEBUFFER_ACCEL" ).setPrerequisite( "RENDERER", { "software", "directx" } );

@kevingranade kevingranade merged commit 5ec2a25 into CleverRaven:master Jan 20, 2019
@ZhilkinSerg ZhilkinSerg deleted the sdl-color-mod-tex branch January 20, 2019 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) SDL: Tiles / Sound Tiles visual interface and sounds.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants