BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: CMD_LOAGIMAGE has undocumented side effects? or not?  (Read 1909 times)

Rudolph

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
CMD_LOAGIMAGE has undocumented side effects? or not?
« on: June 25, 2024, 06:19:32 PM »

Ok, that this is supposed to actually display an Image surprised me:
Code: [Select]
Gpu_CoCmd_LoadImage(phost, 0, OPT_FLASH );
//Start drawing bitmap
App_WrCoCmd_Buffer(phost, BEGIN(BITMAPS));
App_WrCoCmd_Buffer(phost, VERTEX2II(0, 0, 0, 0));
App_WrCoCmd_Buffer(phost, END());

This made me wonder if Riverdi implemented the command with some extra lines.

But I found this in the BRT_AN_033_BT81X_Series_Programming_Guide V2.4:
Code: [Select]
cmd_loadimage(0, 0);
... // JPEG file data follows
cmd(BEGIN(BITMAPS));
cmd(VERTEX2II(10, 20, 0, 0)); // draw bitmap at (10,20)
cmd(VERTEX2II(100, 20, 0, 0));

This suggests that this is somehow supposed to work like this.

Next I did this in EVE Screen Editor:
Code: [Select]
CLEAR(1, 1, 1)
CMD_LOADIMAGE(0, 0, "someimage.png")
BEGIN(BITMAPS)
VERTEX2F(0)
END

And ESE was indeed displaying the image.

The generated display list is:
Offset
(decimal)          Raw      Text
0          0x26000007      CLEAR(1, 1, 1)
1          0x01000000      BITMAP_SOURCE(0)
2          0x28000000      BITMAP_LAYOUT_H(0, 0)
3          0x07310040      BITMAP_LAYOUT(ARGB4, 128, 64)
4          0x29000000      BITMAP_SIZE_H(0, 0)
5          0x08008040      BITMAP_SIZE(NEAREST, BORDER, BORDER, 64, 64)
6          0x1f000001       BEGIN(BITMAPS)
7          0x40000000      VERTEX2F(0, 0)
8          0x21000000      END()
9          0x00000000      DISPLAY()

Wait a second, CMD_LOADIMAGE is not supposed to have that effect.
But at least in ESE this works for FT81x, BT81x and BT88x.

I downloaded the sources from https://github.com/riverdi/riverdi-eve/tree/master and CoPro_Cmds.c has the implementation:

Code: [Select]
void Gpu_CoCmd_LoadImage(Gpu_Hal_Context_t *phost,uint32_t ptr, uint32_t options)
{
  Gpu_CoCmd_StartFunc(phost,CMD_SIZE*3);
  Gpu_Copro_SendCmd(phost, CMD_LOADIMAGE);
  Gpu_Copro_SendCmd(phost, ptr);
  Gpu_Copro_SendCmd(phost, options);
  Gpu_CoCmd_EndFunc(phost,(CMD_SIZE*3));
}

Nothing extra, just the command.
But somehow this still displays images? How?


So I tried to reproduce this on a display with BT817 with my library.
And I can not reprocuce this behaviour.
REG_CMD_DL does not change when I am issuing a CMD_LOADIMAGE.
And reading 20 bytes anyways from where REG_CMD_DL is pointing does not return BITMAP_SOURCE and so on.
Manually writing a different offset to REG_CMD_DL and reading it back afterwards shows no change either.

Code: [Select]
My last test code is this:
EVE_memWrite16(REG_CMD_DL, 0);
EVE_cmd_dl(0xdeadbeef);
EVE_cmd_loadimage(MEM_PIC1, EVE_OPT_NODL, pic, sizeof(pic));
EVE_cmd_dl(0xcafecafe);
EVE_execute_cmd();

for(uint8_t index = 0; index < 5; index++)
{
  array_test[index] = EVE_memRead32(EVE_RAM_DL + (4 * index));
}

array_test[5] = EVE_memRead16(REG_CMD_DL);

The EVE_cmd_loadimage() is working just fine, that image is loaded into memory and displayed with my regular display list.
But displaying the values from the array on screen only shows this:
DEADBEEF
CAFECAFE
30000000
30000000
27000000
8

And seeing that there is nothing in the CMD_LOADIMAGE doku that suggests that display list commands are generated, this result is to be expected.

What is going on then with ESE and especially the Riverdi / Bridgtek library?
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 776
    • View Profile
Re: CMD_LOAGIMAGE has undocumented side effects? or not?
« Reply #1 on: June 25, 2024, 09:34:43 PM »

Hi Rudolph,

There is an option OPT_NODL which inhibits the generation of the DL commands for CMD_LOADIMAGE. Could you check if you had that enabled on the earlier tests? It looks like your last case had this option enabled.

Please see chapter 5.23 of this programming guide for the comment on OPT_NODL.
https://brtchip.com/wp-content/uploads/2023/12/BT81X-Series-Programming-Guide.pdf

Best Regards, BRT Community
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 419
    • View Profile
Re: CMD_LOAGIMAGE has undocumented side effects? or not?
« Reply #2 on: June 25, 2024, 10:14:37 PM »

Oh dear, that was stupid.
Of course. OPT_NODL did exactly what it is supposed to do.
That happens when you never used a command without that option, I did not even register it was there. :-)
Thanks for pointing that out!

With this:
Code: [Select]
EVE_memWrite16(REG_CMD_DL, 0);
EVE_cmd_loadimage(MEM_PIC1, 0, pic, sizeof(pic));

for(uint8_t index = 0; index < 5; index++)
{
  array_test[index] = EVE_memRead32(EVE_RAM_DL + (4 * index));
}

array_test[5] = EVE_memRead16(REG_CMD_DL);

I now get displayed:
0x010FA000
0x28000000
0x07399064
0x29000000
0x0800c864
0x14

Which should be pretty much on point, at least it is in regards of the commands and
the target address is correct.

To my defense, this is very vaguely documented:
"To minimize the programming effort to render the loaded image, there are a set of display list
commands generated and appended to the current display list, unless OPT_NODL is given."

It would have been helpfull to know what these display list commands are.
Now we have CMD_GETIMAGE with the BT817.
But like this the same information would be as easily accessible with a FT81x.
I am not loading random images but getting the format and the sizes like this was something that came up a while ago with no solution.
Logged