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

[gles] Fix tex_sub_image_* calls not always adjusting to target texture #3641

Merged
merged 2 commits into from
Apr 4, 2023

Conversation

daxpedda
Copy link
Contributor

@daxpedda daxpedda commented Apr 3, 2023

Connections
Fixes #3197.

Description
In GLES different arguments have to be passed into tex_sub_image_* calls depending on the target texture. Specifically cube maps, 2D texture arrays and cube map arrays. This was done correctly in some calls, specifically write_texture, but not in others.

This fixes it.

Testing
There was a test actually testing copy_external_image_to_texture for texture array, which was expected to fail, it succeeds now.


Details

The following functions now take the array index into account (only listing changes):

  • copy_external_image_to_texture when targeting cube maps, 2D texture arrays and cube map arrays.
  • copy_texture_to_texture when targeting 2D texture arrays and cube map arrays.
  • copy_buffer_to_texture when targeting uncompressed cube map arrays.
  • copy_buffer_to_texture when targeting compressed 2D texture arrays and cube map arrays.

Basically the change is to make sure that all calls to tex_sub_image_* take into account the following:

  • If the target texture is a 2D texture array or cube map array, pass the array layer in the offset_z parameter.
  • If the target texture is a cube map, pass the array layer in the target parameter.

@daxpedda daxpedda changed the title Fix tex_sub_image calls not always adjusting to target type Fix tex_sub_image_* calls not always adjusting to target type Apr 3, 2023
@daxpedda daxpedda changed the title Fix tex_sub_image_* calls not always adjusting to target type [gles] Fix tex_sub_image_* calls not always adjusting to target type Apr 3, 2023
@daxpedda daxpedda changed the title [gles] Fix tex_sub_image_* calls not always adjusting to target type [gles] Fix tex_sub_image_* calls not always adjusting to target texture Apr 3, 2023
@daxpedda daxpedda force-pushed the gl-2d-array branch 2 times, most recently from 38cefab to c6b6e14 Compare April 3, 2023 02:47
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

Looks good but I think we should also handle TEXTURE_CUBE_MAP_ARRAY.

wgpu/tests/external_texture.rs Outdated Show resolved Hide resolved
@daxpedda
Copy link
Contributor Author

daxpedda commented Apr 3, 2023

Looks good but I think we should also handle TEXTURE_CUBE_MAP_ARRAY.

Done! I also simplified the code a bit.

I updated OP with some details, would be great if you could confirm my assumptions.

@daxpedda daxpedda requested a review from teoxoy April 3, 2023 14:00
Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

This looks great; thank you!

@teoxoy teoxoy merged commit 9fa7186 into gfx-rs:master Apr 4, 2023
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.

copy_texture_to_texture does not work correct in webGL2 with array textures.
2 participants