0

I'm sitting with an OpenGL 3.2 application in Delphi 2009. When using FastMM 4.97 with FullDebugMode defined the UBOs does not get their data properly. With FullDebugMode undefined everything works like a charm.

Example: Setting the viewport dimensions pointing to two private integer fields, FWidth and FHeight, in our render frame class.

glBufferSubData(GL_UNIFORM_BUFFER, VUniform.Offset, VUniform.Size, @FWidth);

I've been pulling my hair over this issue for a few days now and I really don't know how to proceed. I'm not expecting full OpenGL support here but hopefully someone can come with some suggestion based on known differences between running in FullDebugMode and not.

Project settings:

[Compiling]
Optimization    False
Stack frames    True
Use debug .dcus True
[Linking]
Debug info      True
Map file        Detailed

OS is Windows 7 64 bit.

Edit: Found it! It had nothing at all to do with OpenGL. Elsewhere in our codebase a function returned a PAnsiChar using Result := @AnsiString(Object.Name)[1]; This worked most of the time running normally since the memory was only released but unchanged. In FullDebugMode the data was overwritten with $80 sequence when freed.

DelphiDabber
  • 295
  • 2
  • 13

1 Answers1

0

You are probably looking at memory that has been freed prematurely (by your own application).

Normally, you'd still be able to access the old values until they are overwritten by a new allocation + writes. This could very well allow your application to run properly, even though you are accessing stale (freed) parts of memory.

However, in FullDebugMode, deallocated memory is filled with a byte $80 sequence. You can easily check for this if you know the exact call to glBufferSubData that breaks, simply take a look at the memory at that point.

Paul-Jan
  • 16,746
  • 1
  • 63
  • 95
  • The data sent to the videmo memory, FWidth in my example, is set on the line before the call to glBufferSubData. `FWidth := 400; glBufferSubData(GL_UNIFORM_BUFFER, VUniform.Offset, VUniform.Size, @FWidth);` One possible explanation is that the data is cleared by FastMM in FullDebugMode between my setting of it and OpenGL's transfer from the memory to the video memory. Also, when checking the uploaded value in the UBO inside the fragment shader with `if (UViewDimensionX == 0)` it evaluates to true. An integer filled with $80 sequence shouldn't be zero. – DelphiDabber Apr 12 '11 at 20:58
  • I've only been looking at the setting of the data in the buffer on the GPU side. Your theory with stale memory seems plausible but for the parts of the code where the buffer is bound and used. The behaviour would be the same from inside the fragment shader for wrong set data in the buffer and a buffer setting gone wrong. I'll investigate further. – DelphiDabber Apr 13 '11 at 05:38