V3D UIF texture format conversion with TFU
I have been looking at the code in Gallium/drivers/v3d related to texture conversion, specifically v3dx_tfu.c
.
I have been trying to find how to convert a texture from raster format RGBA8
to UIF
(either XOR
or NO_XOR
). I tried break-pointing the v3dX(tfu)
function, but it doesn't appear to be called in my simple textured triangle OpenGL program on a Raspberry Pi 4 (VideoCore VI v. 42).
I am looking for where this conversion takes place, as it appears the VideoCore expects textures to be in another format before they can be sampled properly.
Is there anyone here who can point me to any one of the following:
-
How
v3dX(tfu)
ends up getting used (e.g., a user-space program I can run to blit/convert a raster texture into a UIF texture) -
Any notes on the TFU interface itself (what the registers expect, beyond what can clearly infer from
v3dX(tfu)
) -
If the TFU isn't used to convert to UIF, where the conversion takes place
I may have misunderstood the texture sampler. I am sampling a texture successfully (pixels are the color I expect) but the pixels are completely "out of order", which is what hints me that they need to be in UIF instead of raster format.
Below is the program I was using to try to figure out where the texture gets converted. My apologies for its length, but as far as I know it is complete:
It requires stb_image.h and stb_image_write.h to load the texture and subsequently write the output. They can be put in the same directory as the example code, then run on a Raspberry Pi 4:
gcc -g -o shaders shaders.c -ldrm -lgbm -lEGL -lGL -lm -I/usr/include/libdrm -I/usr/include/GLES3
./shaders
This program when saved to "shaders.c" and put in a directory with stb_image.h
and stb_image_write.h
, can be compiled into shaders
. It will attempt to load maze.jpg
in the current working directory and then render it to a triangle. The output is stored in output.jpg
. It does not open a window.
And to clarify, this program does work in that it displays the texture properly. This issue is asking how/where it converts the texture so that it is displayed properly, because my understanding is this conversion must take place, but I can't seem to find where it happens.
What I really want is to be able to step-debug where the conversion takes place; if it's via the TFU, I want to see exactly what values are being given to the DRM_IOCTL_V3D_SUBMIT_TFU
. I want this because I tried writing my own call to the TFU, but it isn't converting properly; the job completes but the destination memory is empty (untouched).