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

WIP: tr_image: downscale image against hardware limits using GL_PROXY feature #1131

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

illwieckz
Copy link
Member

Cherry picked from that old branch:

I haven't touched this code in 4 years so I'm flagging at draft because I need to refresh my mind on this to begin with.

@illwieckz illwieckz marked this pull request as draft May 11, 2024 10:43
@DolceTriade
Copy link
Contributor

Once you remember what this is for, it would be nice to explain it in the commit message 😄

@illwieckz
Copy link
Member Author

	/* From https://www.khronos.org/opengl/wiki/GLAPI/glTexImage3D

	> If target is GL_PROXY_TEXTURE_3D, no data is read from data,
	> but all of the texture image state is recalculated, checked
	> for consistency, and checked against the implementation's
	> capabilities. If the implementation cannot handle a texture
	> of the requested texture size, it sets all of the image state
	> to 0, but does not generate an error (see glGetError).
	> To query for an entire mipmap array, use an image array level
	> greater than or equal to 1.

	From https://www.khronos.org/opengl/wiki/GLAPI/glTexImage3D
	> To then query this state, call glGetTexLevelParameter. */

The idea is to attempt a fake upload of the image with the size expected to be uploaded, and get the exact answer from the driver itself if an image with such format and size is accepted or not, before doing the image upload for real.

If the driver answers an image of this size for this format is not accepted, reduce the size and retry until the driver accepts. Once an acceptable size is found, upload the image with that smaller size.

@illwieckz
Copy link
Member Author

illwieckz commented May 11, 2024

I haven't forgotten what is this for and did not forgot I had this patch for this exact purpose. 😃️

It's just I have to refresh my mind on how it works and to reacquire confidence or not about its status.

I have some intention to implement new features about image resizing, but I know I had already had a dozen of commits sleeping for years with things I already implemented for other features I evaluated before. So I thought it was a good idea to start cherry-picking them from their old branch.

After 4 years rebasing the branch is not an option anymore, all I can do is to cherry-pick specific commits and port them to the actual code. I'm afraid other ideas I have for other things may introduce more merge conflict with those sleeping commits.

@slipher
Copy link
Member

slipher commented May 11, 2024

My recollection is that it turned out that vendors didn't bother to implement GL_PROXY correctly, so using it was a bad idea.

@illwieckz
Copy link
Member Author

My recollection is that it turned out that vendors didn't bother to implement GL_PROXY correctly, so using it was a bad idea.

The doubt about vendor implementation was about GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB (glConfig2.maxCubeMapTextureSize) and it is what motivated this alternate implementation.

That patch was considered by me as ready to merge at the time but this just never happened and it just fall behind other priorities like doing some releases. I never forgot about it and it always had been on my TODO list. Some patches from that branch were already merged at the time, merging the next ones on the line always had ben planned.

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

Successfully merging this pull request may close these issues.

3 participants