Skip to content

Conversation

@jayathirthrao
Copy link
Member

@jayathirthrao jayathirthrao commented Dec 12, 2025

Currently we don't set any texture filtering & addressing modes for 3D textures in Metal pipeline.
Default 3D texture filtering is "nearest" for Metal textures, but we use "linear" filtering by default for 3D textures in case of OpenGL.
Default addressing mode is "clamp_to_edge" in Metal textures, but we use "repeat" addressing mode for 3D textures in OpenGL.

Metal should use same default filtering & addressing modes for 3D textures as in OpenGL pipeline.
Under this issue we are trying only to match defaults of Metal to OpenGL pipeline.

We don't update the filters/addressing modes for 3D textures once created.
We have open enhancements like https://bugs.openjdk.org/browse/JDK-8324594 where we might provide API's to set sampler states for 3D textures in future.

Functional and performance testing is green with this update.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Integration blocker

 ⚠️ Title mismatch between PR and JBS for issue JDK-8373232

Issue

  • JDK-8373232: Pass default filters and addressing modes for 3D metal textures (Bug - P4) ⚠️ Title mismatch between PR and JBS.

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2005/head:pull/2005
$ git checkout pull/2005

Update a local copy of the PR:
$ git checkout pull/2005
$ git pull https://git.openjdk.org/jfx.git pull/2005/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2005

View PR using the GUI difftool:
$ git pr show -t 2005

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2005.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 12, 2025

👋 Welcome back jdv! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

hTexture = mtlTex.getNativeHandle();
}
context.setMap(nativeHandle, map.getType().ordinal(), hTexture);
context.setMap(nativeHandle, map.getType().ordinal(), hTexture, useMipmap);
Copy link
Member Author

Choose a reason for hiding this comment

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

We use mipmapping only when (!PlatformUtil.isEmbedded()) && (i == PhongMaterial.DIFFUSE || i == PhongMaterial.SELF_ILLUM);. We need to pass mipmap information, so that we can pick appropriate sampler state in native code.

@openjdk
Copy link

openjdk bot commented Dec 12, 2025

@jayathirthrao This change is no longer ready for integration - check the PR body for details.

@openjdk openjdk bot added the rfr Ready for review label Dec 12, 2025
@mlbridge
Copy link

mlbridge bot commented Dec 12, 2025

Webrevs

Copy link
Contributor

@lukostyra lukostyra left a comment

Choose a reason for hiding this comment

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

In general looks good, but I have one question to double-check something I couldn't find.

The sampler is chosen based on whether we use mipmaps or not. In cases where mipmaps are not used, are we still generating them?

@jayathirthrao
Copy link
Member Author

In general looks good, but I have one question to double-check something I couldn't find.

The sampler is chosen based on whether we use mipmaps or not. In cases where mipmaps are not used, are we still generating them?

@lukostyra Thanks for the review.
We use mipmap only for diffuse and self illumination maps : https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/java/com/sun/prism/mtl/MTLPhongMaterial.java#L100

We pass this mipmap flag to the native code when texture is getting created. And we use this flag and generate mipmaps only for the textures where this flag is true : https://github.com/openjdk/jfx/blob/master/modules/javafx.graphics/src/main/native-prism-mtl/MetalTexture.m#L203

So for non-mipmapped 3D textures we don't generate mipmaps.

Copy link
Contributor

@lukostyra lukostyra left a comment

Choose a reason for hiding this comment

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

Thanks for responding. I found one thing that could be improved, will run some tests on this later on.

Copy link
Contributor

@lukostyra lukostyra left a comment

Choose a reason for hiding this comment

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

LGTM

@openjdk openjdk bot added the ready Ready to be integrated label Dec 16, 2025
@lukostyra
Copy link
Contributor

I just noticed the ready label, but I think this requires two reviewers.

/reviewers 2

@openjdk
Copy link

openjdk bot commented Dec 16, 2025

@lukostyra
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot removed the ready Ready to be integrated label Dec 16, 2025
Copy link
Member

@arapte arapte left a comment

Choose a reason for hiding this comment

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

Leaving a few queries regarding the changes.
I expect there should not be any behavior changes, correct ?

/*
* Class: com_sun_prism_mtl_MTLContext
* Method: nSetDeviceParametersFor3D
* Signature: (J)J
Copy link
Member

Choose a reason for hiding this comment

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

minor : (J)J should be changed to (J)V

Comment on lines +231 to +244
[phongEncoder setFragmentSamplerState:[material getSamplerState:DIFFUSE]
atIndex:0];
[phongEncoder setFragmentTexture:[material getMap:SPECULAR]
atIndex:1];
[phongEncoder setFragmentSamplerState:[material getSamplerState:SPECULAR]
atIndex:0];
[phongEncoder setFragmentTexture:[material getMap:BUMP]
atIndex:2];
[phongEncoder setFragmentSamplerState:[material getSamplerState:BUMP]
atIndex:0];
[phongEncoder setFragmentTexture:[material getMap:SELFILLUMINATION]
atIndex:3];
[phongEncoder setFragmentSamplerState:[material getSamplerState:SELFILLUMINATION]
atIndex:0];
Copy link
Member

Choose a reason for hiding this comment

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

  1. All setFragmentSamplerState are setting at index 0, should it not be 0,1,2,3?
  2. Does this not require any changes to PhongPS.metal, The shader functions in PhongPS.metal do not have a sampler parameter.
  3. Currently the PhongPS.metal file creates two samplers in shader file itself and uses those for sampling. May be that should be modified to use these samplers that are set using setFragmentSamplerState

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the observations @arapte .
Yes these changes are needed and it also has to be tested properly. So moving this PR back to draft stage.

@jayathirthrao jayathirthrao marked this pull request as draft December 17, 2025 08:53
@openjdk openjdk bot removed the rfr Ready for review label Dec 17, 2025
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 11, 2026

@jayathirthrao This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants