Generic Texture Copy

Reporter: RobertBColton  |  Status: open  |  Last Modified: April 12, 2019, 02:59:31 PM

This one should hopefully be very obvious. I have been wanting to clean up some of the graphics texture copying functions because they duplicate a lot of logic. The obvious idea here is to just create a new set of abstractions that are even lower level and then rewrite the duplicate graphics texture functions with them. This will ensure that all of the graphics backends have more consistent and predictable behavior when it comes to the user functions that use these abstractions.

An important distinction I should make here is that this new API is based on the semantics of OpenGL and not Direct3D. Direct3D is actually lower level, allowing you to map the texture directly to system memory while you operate on its data in situ. So the Direct3D systems will implement the new API by performing an extra copy to system memory. This means the client is responsible for deleting the allocated memory regardless of the backend. The end result should be that Direct3D and OpenGL will have pretty similar performance when calling these functions.

These new functions are now mandatory for each backend to implement.

unsigned char* graphics_copy_texture_pixels(int texture, unsigned* fullwidth, unsigned* fullheight);
unsigned char* graphics_copy_texture_pixels(int texture, int x, int y, int width, int height);
void graphics_push_texture_pixels(int texture, int x, int y, int width, int height, unsigned char* pxdata);
void graphics_push_texture_pixels(int texture, int width, int height, unsigned char* pxdata);

These old mandatory functions were moved to General/ and reimplemented with the new abstract ones.

int graphics_duplicate_texture(int tex, bool mipmap=false);
void graphics_replace_texture_alpha_from_texture(int tex, int copy_tex);
void graphics_copy_texture(int source, int destination, int x, int y);
void graphics_copy_texture_part(int source, int destination, int xoff, int yoff, int w, int h, int x, int y);
codecov[bot]  
>Codecov Report

Merging #1648 into master will decrease coverage by 0.04%.
The diff coverage is 38.04%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1648      +/-   ##
==========================================
- Coverage   18.82%   18.77%   -0.05%     
==========================================
  Files         169      169              
  Lines       16782    16757      -25     
==========================================
- Hits         3159     3146      -13     
+ Misses      13623    13611      -12
Impacted Files Coverage Δ
ENIGMAsystem/SHELL/Universal_System/fontstruct.cpp 1.17% <0%> (ø) ⬆️
...system/SHELL/Universal_System/backgroundstruct.cpp 41.72% <0%> (ø) ⬆️
...stem/SHELL/Graphics_Systems/General/GStextures.cpp 10.66% <14.28%> (+6.96%) ⬆️
...stem/SHELL/Graphics_Systems/OpenGL1/GLtextures.cpp 33.07% <67.56%> (+2.04%) ⬆️
...IGMAsystem/SHELL/Universal_System/spritestruct.cpp 72.01% <75%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fb9d867...da46b85. Read the comment docs.

Please sign in to post comments, or you can view this issue on GitHub.