I have an OpenGL application, programmed in Lazarus 1.8.4 64 bit (compiled as Win32GUI -WG),
where I skip creation of Lazarus main form. Instead, I create my own OpenGL window via Win API calls.
But, in the program I also use Lazarus built-in dialogs, like Color picker dialog, Font dialog etc.
When I use these dialogs (but still rendering main OpenGL window in some slow rate, like 1-10 fps via timer),
it RANDOMLY fails in rendering preparation phase (mostly after closing dialog).
I use rendering via FBO to texture + few render buffers for mouse picking. It fails on
clearing of buffer, where I store ID of rendered triangle.
glBindFramebuffer(GL_FRAMEBUFFER, FFrameBuffer);
finalQuadTextureDest.bind(true); // bind some destination texture to get rid of: "Texture state usage warning: Texture 0 is base level inconsistent. Check texture size"
glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
col := 0;
glClearBufferuiv( GL_COLOR, FRenderbufferId.RenderbufferId, @col); // IT FAILS HERE -> Project raised exception class 'External: SIGFPE'. / Invalid floating point operation
finalQuadTextureDest.bind(false);
Here is assembler debug dump:
000000005A540CB0 f30f10642428 movss 0x28(%rsp),%xmm4
000000005A540CB6 0f57c0 xorps %xmm0,%xmm0
000000005A540CB9 0f2fc8 comiss %xmm0,%xmm1
000000005A540CBC f30f102d1c6ece00 movss 0xce6e1c(%rip),%xmm5 # 0x5b227ae0 <vkCreateInstance+7878384>
000000005A540CC4 f30f118928010000 movss %xmm1,0x128(%rcx)
000000005A540CCC f30f11912c010000 movss %xmm2,0x12c(%rcx)
000000005A540CD4 f30f119930010000 movss %xmm3,0x130(%rcx)
000000005A540CDC f30f11a134010000 movss %xmm4,0x134(%rcx)
000000005A540CE4 7206 jb 0x5a540cec
000000005A540CE6 f30f5dcd minss %xmm5,%xmm1
000000005A540CEA eb03 jmp 0x5a540cef
000000005A540CEC 0f28c8 movaps %xmm0,%xmm1
000000005A540CEF 0f2fd0 comiss %xmm0,%xmm2 // FAILS ON THIS LINE -> Project raised exception class 'External: SIGFPE'. / Invalid floating point operation
000000005A540CF2 f30f1189b8010000 movss %xmm1,0x1b8(%rcx)
000000005A540CFA 7206 jb 0x5a540d02
000000005A540CFC f30f5dd5 minss %xmm5,%xmm2
000000005A540D00 eb03 jmp 0x5a540d05
xmm0 is :
{v4_float = {0, 0, 0, 0}, v2_double = {0, 0}, v16_int8 = {0 <repeats 16 times>}, v8_int16 = {0, 0, 0, 0, 0, 0, 0, 0}, v4_int32 = {0, 0, 0, 0}, v2_int64 = {0, 0}, uint128 = 0}
xmm2 is:
{v4_float = {-nan(0x7fffff), -nan(0x7fffff), -nan(0x7fffff), -nan(0x7fffff)}, v2_double = {-nan(0xfffffffffffff), -nan(0xfffffffffffff)}, v16_int8 = {-1 <repeats 16 times>}, v8_int16 = {-1, -1, -1, -1, -1, -1, -1, -1}, v4_int32 = {-1, -1, -1, -1}, v2_int64 = {-1, -1}, uint128 = 0xffffffffffffffffffffffffffffffff}
card: NVidia GeForce 710
driver version: 21.21.13.7866
driver creation date: 9.2.2017
app is written for OpenGL 4.3
My guess is, that something in those dialog windows leaves fpu/mmx in some inconsistent state and probably OpenGL driver can not handle it. I know this description is rather poor, but the project is quite big. I recently fixed all OpenGL debug output warnings, including change of ID render buffer from integer to float (using glClearBufferfv and uintBitsToFloat in shader) with no avail. The bug happens on Lazarus 64 bit, I could not replicate this on 32 bit.
I'm posting this in hope, that someone can give me a clue, which way to run investigation. Thanks.