Posted April 28, 20214 yr Hello! I am unable to load the texture from the IntBuffer. Sequencing: I create a texture with a certain size and write it to the IntBuffer. Then I load it into GL using the method: GL11.glTexSubImage2D() At certain points, the texture size changes... Then, I recreate the IntBuffer, re-bind the texture and load it again. static int offset; static int size; // offset changes at some point // after that I call prepareImage() public static void prepareImage() { size = (offset * 2 + 1) << 4; buf = BufferUtils.createIntBuffer(size * size); TextureUtil.prepareImage(textureId, size, size); ... // create a texture again and write to the buffer upload(0, 0, size, size); } private static void upload(int xOffset, int yOffset, int width, int height) { if (RenderSystem.isOnRenderThreadOrInit()) uploadImage(xOffset, yOffset, width, height); else RenderSystem.recordRenderCall(() -> uploadImage(xOffset, yOffset, width, height)); } private static void uploadImage(int xOffset, int yOffset, int width, int height) { bindTexture(); boolean offset = xOffset > 0 || yOffset > 0; if (offset) { setPosition(xOffset, yOffset); GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, size); } GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE); GL11.glTexSubImage2D(GL11.GL_TEXTURE_2D, 0, xOffset, yOffset, width, height, GL11.GL_RGBA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buf); // crash here if (offset) { setPosition(0, 0); GL11.glPixelStorei(GL11.GL_UNPACK_ROW_LENGTH, 0); } } private static void setPosition(int x, int y) { buf.position(y * size + x); } Crash doesn't always happen. Sometimes it works and sometimes it doesn't. Also, if I load only a part of the texture with an offset, the loaded piece eventually jumps and turns out to be in a different position each time. As if the parameter GL11.GL_UNPACK_ROW_LENGTH changes every time. A very strange message is displayed in the console: # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005f4749e0, pid=7740, tid=0x0000000000001c38 # # JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [nvoglv64.DLL+0xaf49e0] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # An error report file with more information is saved as: # E:\Mod\1.16.5\run\hs_err_pid7740.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # This is what is in this file: # # A fatal error has been detected by the Java Runtime Environment: # # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005f4749e0, pid=7740, tid=0x0000000000001c38 # # JRE version: Java(TM) SE Runtime Environment (8.0_131-b11) (build 1.8.0_131-b11) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.131-b11 mixed mode windows-amd64 compressed oops) # Problematic frame: # C [nvoglv64.DLL+0xaf49e0] # # Failed to write core dump. Minidumps are not enabled by default on client versions of Windows # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in native code. # See problematic frame for where to report the bug. # --------------- T H R E A D --------------- Current thread (0x00000000021ec000): JavaThread "Render thread" [_thread_in_native, id=7224, stack(0x0000000002440000,0x0000000002540000)] siginfo: ExceptionCode=0xc0000005, reading address 0x000000003d5b1000 Registers: RAX=0x000000003d5b1020, RBX=0x000000003d5b0c80, RCX=0x000000003d6cbd60, RDX=0x000000003d5b0c80 RSP=0x000000000253d0d8, RBP=0x0000000000000840, RSI=0x0000000000000000, RDI=0x000000003d6cb9c0 R8 =0x0000000000000013, R9 =0x0000000000000000, R10=0x0000000026a7ee94, R11=0x0000000000000002 R12=0x0000000000000000, R13=0x0000000000000000, R14=0x000000000253d330, R15=0x0000000000000000 RIP=0x000000005f4749e0, EFLAGS=0x0000000000010202 Top of Stack: (sp=0x000000000253d0d8) 0x000000000253d0d8: 000000005f474650 000000000000001e 0x000000000253d0e8: 0000000400000000 0000000000000000 0x000000000253d0f8: 0000021000000800 0000000000000001 0x000000000253d108: 000000005f0bbf00 000000003d6cb9c0 0x000000000253d118: 0000000000000210 000000003d5b0c80 0x000000000253d128: 000000005efc2b83 000000001c620000 0x000000000253d138: 0000000000000000 0000000000000000 0x000000000253d148: 000000005efc2953 000000005f48b040 0x000000000253d158: 0000000000000000 000000005efc2b00 0x000000000253d168: 000000005efcc6d4 00000000242f24d0 0x000000000253d178: 000000005ee45c22 000000000253d330 0x000000000253d188: 0000000000000009 000000005efcc680 0x000000000253d198: 000000001c620000 0000000000000001 0x000000000253d1a8: 000000005efcec7d 000000000253d330 0x000000000253d1b8: 0000000000000001 00000000241392e0 0x000000000253d1c8: 0000000000000004 0000005200000052 Instructions: (pc=0x000000005f4749e0) 0x000000005f4749c0: 11 49 c0 0f 11 41 d0 49 83 e8 01 75 d3 c3 4d 85 0x000000005f4749d0: c0 74 3a 48 83 c1 20 48 8d 42 20 0f 1f 44 00 00 0x000000005f4749e0: 0f 10 58 e0 48 8d 49 40 0f 10 50 f0 0f 10 08 0f 0x000000005f4749f0: 10 40 10 48 8d 40 40 0f 11 59 a0 0f 11 51 b0 0f Register to memory mapping: RAX=0x000000003d5b1020 is an unknown value RBX=0x000000003d5b0c80 is an unknown value RCX=0x000000003d6cbd60 is an unknown value RDX=0x000000003d5b0c80 is an unknown value RSP=0x000000000253d0d8 is pointing into the stack for thread: 0x00000000021ec000 RBP=0x0000000000000840 is an unknown value RSI=0x0000000000000000 is an unknown value RDI=0x000000003d6cb9c0 is an unknown value R8 =0x0000000000000013 is an unknown value R9 =0x0000000000000000 is an unknown value R10=0x0000000026a7ee94 is an unknown value R11=0x0000000000000002 is an unknown value R12=0x0000000000000000 is an unknown value R13=0x0000000000000000 is an unknown value R14=0x000000000253d330 is pointing into the stack for thread: 0x00000000021ec000 R15=0x0000000000000000 is an unknown value Stack: [0x0000000002440000,0x0000000002540000], sp=0x000000000253d0d8, free space=1012k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [nvoglv64.DLL+0xaf49e0] Java frames: (J=compiled Java code, j=interpreted, Vv=VM code) J 12933 org.lwjgl.opengl.GL11C.nglTexSubImage2D(IIIIIIIIJ)V (0 bytes) @ 0x0000000003d749bc [0x0000000003d74940+0x7c] J 22607 C1 ru.liahim.mist.client.shader.FogTexture.uploadImage(IIII)V (99 bytes) @ 0x0000000003c5eb94 [0x0000000003c5e760+0x434] j ru.liahim.mist.client.shader.FogTexture.upload(IIII)V+10 j ru.liahim.mist.client.shader.FogTexture.createFogTexture(Lnet/minecraft/world/World;II)V+74 J 24664 C1 ru.liahim.mist.handlers.Fog.prepareFogParameters(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/util/math/vector/Matrix4f;F)V (435 bytes) @ 0x0000000005ff1404 [0x0000000005ff0860+0xba4] J 24343 C1 ru.liahim.mist.handlers.Fog.prepare(Lcom/mojang/blaze3d/matrix/MatrixStack;Lnet/minecraft/util/math/vector/Matrix4f;F)V (43 bytes) @ 0x0000000005c6c2bc [0x0000000005c6bba0+0x71c] J 24241 C2 net.minecraft.client.renderer.WorldRenderer.renderLevel(Lcom/mojang/blaze3d/matrix/MatrixStack;FJZLnet/minecraft/client/renderer/ActiveRenderInfo;Lnet/minecraft/client/renderer/GameRenderer;Lnet/minecraft/client/renderer/LightTexture;Lnet/minecraft/util/math/vector/Matrix4f;)V (2872 bytes) @ 0x0000000006259f84 [0x0000000006259f20+0x64] J 24416 C1 net.minecraft.client.renderer.GameRenderer.renderLevel(FJLcom/mojang/blaze3d/matrix/MatrixStack;)V (614 bytes) @ 0x000000000630762c [0x0000000006302040+0x55ec] J 13341 C1 net.minecraft.client.renderer.GameRenderer.render(FJZ)V (856 bytes) @ 0x000000000495d52c [0x000000000495bfa0+0x158c] J 25014 C2 net.minecraft.client.Minecraft.runTick(Z)V (994 bytes) @ 0x000000000658c314 [0x000000000658aa60+0x18b4] j net.minecraft.client.Minecraft.run()V+68 j net.minecraft.client.main.Main.main([Ljava/lang/String;)V+1379 v ~StubRoutines::call_stub j sun.reflect.NativeMethodAccessorImpl.invoke0(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+0 j sun.reflect.NativeMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;+100 J 1863 C1 sun.reflect.DelegatingMethodAccessorImpl.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (10 bytes) @ 0x0000000002e25c0c [0x0000000002e25b00+0x10c] J 1862 C1 java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; (62 bytes) @ 0x0000000002e26874 [0x0000000002e26480+0x3f4] j net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(Lcpw/mods/modlauncher/api/ITransformingClassLoader;[Ljava/lang/String;)Ljava/lang/Void;+65 j net.minecraftforge.userdev.FMLUserdevClientLaunchProvider$$Lambda$453.call()Ljava/lang/Object;+12 j cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch([Ljava/lang/String;Lcpw/mods/modlauncher/api/ITransformingClassLoader;)V+11 j cpw.mods.modlauncher.LaunchServiceHandler.launch(Ljava/lang/String;[Ljava/lang/String;Lcpw/mods/modlauncher/TransformingClassLoader;Lcpw/mods/modlauncher/LaunchPluginHandler;)V+57 j cpw.mods.modlauncher.LaunchServiceHandler.launch(Lcpw/mods/modlauncher/ArgumentHandler;Lcpw/mods/modlauncher/TransformingClassLoader;Lcpw/mods/modlauncher/LaunchPluginHandler;)V+19 j cpw.mods.modlauncher.Launcher.run([Ljava/lang/String;)V+116 j cpw.mods.modlauncher.Launcher.main([Ljava/lang/String;)V+37 j net.minecraftforge.userdev.LaunchTesting.main([Ljava/lang/String;)V+422 v ~StubRoutines::call_stub Sorry, I don't speak English very well...
April 29, 20214 yr Author Fixed! On version 1.16.5, before loading the image, you must reset the following parameters: GlStateManager._pixelStore(GL11.GL_UNPACK_SKIP_PIXELS, 0); GlStateManager._pixelStore(GL11.GL_UNPACK_SKIP_ROWS, 0); Sorry, I don't speak English very well...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.