Page 1 of 1

persistent buffers not 32-bit

Posted: Sun Jun 01, 2025 21:15
by dtristram
when buffers are marked PERSISTENT, they no longer respect the FLOAT designation, that is, they become 8-bit per component buffers even when FLOAT: true is specified.

In this patch normalized fragment coordinates are stored in a buffer. If they are stored at 32-bit floats, there is sufficient precision to use them to index image pixels. But if they are 8-bit, then when used to index an image, the image looks blocky because multiple image coordinates are rounded to particular 8-bit values.

The patch has two buffers, both designated as FLOAT. However, the second one is designated PERSISTENT and is unexpectedly limited to 8-bit. The final pass alternately uses the two buffers to index the input image.

Code: Select all



/*{
    "CREDIT": "dtristram",
    "DESCRIPTION": "demonstrates bug where persistent buffers do not respect FLOAT designation, note that when reading from persistent buffer, texture coordinates do not have sufficient precision to address image resolution",
    "CATEGORIES": [ "generator" ],
    "INPUTS": [
        {
            "TYPE": "image",
            "NAME": "inputImage",
            "LABEL": "Image",
        }
    ],
    "PASSES": [
        {
	    "TARGET": "store1",
	    "FLOAT": true,
	    "PERSISTENT": false,
	},
        {
	    "TARGET": "store2",
	    "FLOAT": true,
	    "PERSISTENT": true,
	},
	{
	}
    ]
}*/

float delay = 1;

void main() {
  vec2 uv = isf_FragNormCoord.xy;
  vec4 c = vec4(0,0,1,1);
  
  switch (PASSINDEX) {

  case 0:
  case 1:
    c = vec4(uv, 0, 1);
    break;

  case 2:
    if (fract(TIME/(2*delay)) < 0.5) {
      uv = IMG_THIS_PIXEL(store1).xy;
    } else {
      uv = IMG_THIS_PIXEL(store2).xy;
    }
    
    c = IMG_NORM_PIXEL(inputImage, uv.xy);
    break;
  }
  
  gl_FragColor = c;
}


Re: persistent buffers not 32-bit

Posted: Tue Jun 03, 2025 17:40
by Zoltán
Thanks for letting us know, made a ticket.

Re: persistent buffers not 32-bit

Posted: Mon Jun 16, 2025 18:07
by dtristram
This would be great to get fixed.

Because of viewtopic.php?p=103010 I do not have a workaround. This second problem makes it impossible to use more than one persistent buffer in multiple passes. I found a nice trick for saving high precision floats in a four component int buffer, but with only one buffer that doesn't get me very far.

Can you tell me whether this bug is near the top of the backlog?

Thanks,
David