openImplicit

Michael Hall mik3hall at gmail.com
Fri Apr 21 18:36:33 UTC 2023


Thanks

> On Apr 21, 2023, at 1:14 PM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> 
> Yes. The semantics of `SegmentScope.auto()` is the same as that of `MemorySession.openImplicit`.
> 
> Maurizio
> 
> On 21/04/2023 19:08, Michael Hall wrote:
>> Would this be the correct jdk20 change?
>> 
>> //textureBufferIds = MemorySegment.allocateNative(1 * 4 * 3, SegmentScope.openImplicit());
>>     textureBufferIds = MemorySegment.allocateNative(1 * 4 * 3, SegmentScope.auto());

I thought this is all I did that would affect this code. Except for pointing at different OS/X dylib’s. 
But on...

   gl.glGenTextures(1, textureBufferIds);
    idTexture = (int) textureBufferIds.get(ValueLayout.JAVA_INT, 0);

    Debug.debug(debug, "FBO: Got texture ID : " + idTexture);


    // Check errors
    if (idTexture == 0) {
      diagnoseError(gl, "texture");
    }

I get this error…

FBO: texture handle=0 but get no OpenGL error. This may happen if the call was not issued from main thread on macOS

This appears to come down to…

    public static MethodHandle glGenTextures$MH() {
        return RuntimeHelper.requireNonNull(constants$86.glGenTextures$MH,"glGenTextures");
    }
    /**
     * {@snippet :
     * void glGenTextures(GLsizei n, GLuint* textures);
     * }
     */
    public static void glGenTextures(int n, MemorySegment textures) {
        var mh$ = glGenTextures$MH();
        try {
        	System.out.println("glut_h_3: glGenTextures n = " + n + " textures = " + textures + " mh$ = " + mh$);
            mh$.invokeExact(n, textures);
        } catch (Throwable ex$) {
            throw new AssertionError("should not reach here", ex$);
        }
    }
    public static MethodHandle glGetBooleanv$MH() {
        return RuntimeHelper.requireNonNull(constants$86.glGetBooleanv$MH,"glGetBooleanv");
    }

Where the println shows…
glut_h_3: glGenTextures n = 1 textures = MemorySegment{ array: Optional.empty address:105553149374912 limit: 12 } mh$ = MethodHandle(int,MemorySegment)void

Does the empty address indicate a problem or does this still appear correct and my replaced native code is the probable problem?



More information about the panama-dev mailing list