OpenVG- baremetal VG

Anything and everything about programming graphics with Ultibo
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

OpenVG- baremetal VG

Postby Gavinmc42 » Sun Jul 02, 2017 1:02 pm

Not really OpenVG but more of how to do baremetal 2D VG on the VC4.
Putting this in a separate post from this one.
viewtopic.php?f=9&t=584&p=4419&hilit=openvg#p4419

This is the sort of thing I want to be able to do in Ultibo
https://www.youtube.com/watch?v=kR9jrwVGI58
Explanation of it
http://www.embedded.com/print/4410726

It started with page 12 of the manual which indicates anti aliasing was done in hardware.
allows 4x multisample antialiasing to be used with little penalty in
performance or memory consumption.

Anyone doing GUI, diagonal line drawing etc this would be really useful.

Came across something that said the rendering 3D stuff did not go via mailbox.
Section 8 of the VC manual explains the CLE ( Control List Executer) which takes the primitive draw command lists put into memory by the ARM.
These lists then are executed by the VC4.

No OpenVG or EGL commands, just commands lists that draw the primitives.
Page 63
Each pipeline can operate in one of three major modes:
• GL mode, in which vertex shading is employed
• NV mode, without vertex shading, using pre-shaded vertices stored in memory
• VG mode, where vertices are supplied directly from the input primitive list as XY coordinates only.

The VG mode, looks to be quite simple, just a list of x,y coordinates.

Page 65
A special VG primitive list format is also supported, consisting of immediate XY coordinate data,
either as an indirect list or as an in-line escape-terminated list. There is also a compressed format for primitives
embedded in-line within tile lists, which is the format produced by the PTB. This format has escapes to
terminate the list, and branches to allow lists to be efficiently chained from several memory blocks.


VG is Control code 41 - page 68. tiny more detail on page 72.

This is the Raspbian VC4 OpenVG example, is it of use?
https://github.com/raspberrypi/firmware ... ello_tiger
Is understanding the OpenVG/EGL stuff going to be of any use if there is another layer buried in the start.elf?
Disassemble egl.so?

Has anyone done baremetal VG on the VC4?
Harder to do 3D but it would use the same CLE method? Anyone done that either?
Google time, pretty sure bandaids will be needed.
That old Symbian source code is hard to figure out, got 500MB+ and I think it is in a folder in there somewhere.

Reverse engineering the VC4 VG instructions?
Is this bit of the Videocore 4 propriety?
With the Control List Executer/Command codes etc in the manual I would think this part has no secrets.

Does not seem to be much out there
https://www.raspberrypi.org/forums/viewtopic.php?t=7090
https://www.raspberrypi.org/forums/view ... 67&t=66313

Back to the sticky now that i know what to look for.
https://www.raspberrypi.org/forums/view ... 72&t=72260
Looks like Peter Lemon has a clue
https://github.com/PeterLemon/Raspberry ... master/V3D

Or maybe not, this has VG as code 42/43, not 41/42 as in the manual, which is correct?
https://github.com/PeterLemon/Raspberry ... L_LIST.INC

A lot of this is setting up the VC4/V3D which had been done in Ultibo
https://github.com/PeterLemon/Raspberry ... _Color/LIB
CLE is setup with this? This is already done in Ultibo?
https://github.com/PeterLemon/Raspberry ... IB/V3D.INC

Looks like this is the place to start and maybe finish for clues to msaa vg graphics in Ultibo :P
Time to fire a Pi with Raspbian and start Fasmarming, see if it works then post to pascal.


RHT(curves?) and triangles
https://github.com/PeterLemon/Raspberry ... nate_Array
Hey, if Peter's code is assembler then inline in Ultibo?
Is it my imagination, does this look simple?
Setting the list up and then just ldi tlbc?
Those nop's are just pipeline flushing according to the video.

a

Code: Select all

lign 16 ; 128-Bit Align
FRAGMENT_SHADER_CODE:
  ; Fill Color Shader
  dw $009E7000 ;
  dw $100009E7 ; nop; nop; nop

  dw $FFFFFFFF ; RGBA White
  dw $E0020BA7 ; ldi tlbc, $FFFFFFFF
  dw $009E7000 ;
  dw $500009E7 ; nop; nop; sbdone
  dw $009E7000 ;
  dw $300009E7 ; nop; nop; thrend

  dw $009E7000 ;
  dw $100009E7 ; nop; nop; nop
  dw $009E7000 ;
  dw $100009E7 ; nop; nop; nop


Peter stuff has link to Dex
https://github.com/PeterLemon/RaspberryPi
http://dex-os.github.io/DexBasic/DexBasic.htm
Dex-OS with Dexbasic on a Pi one day?
Still only got serial and GPIO at the moment, but now Basic baremetal for Pi's?

Brain hurt's, try another day.
Hang on, there are kernel.bins, ok maybe tomorrow :lol:
USB boot testing on a Zero of Peter's asm kernels :ugeek:
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Jul 03, 2017 2:40 am

You want to be impressed try this.
https://github.com/PeterLemon/Raspberry ... st/Refresh

Someone who know how, should be able to get ControlList stuff working in Ultibo.
How hard to add this to Ultibo?

More info if you search for "krom" on the Pi forums.
Time to read everything he has posted.
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Jul 03, 2017 3:12 am

Baremetal Video :shock:
https://github.com/PeterLemon/Raspberry ... GRBLZVideo
Put it in another post?
Only 320 x 240 but still, it is video.
Not sure but I think it takes a compressed file and decompresses to memory and then just changes the framebuffer pointer.
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Jul 03, 2017 8:37 am

Garry, the V3D registers, page 82-84 are they in Ultibo anywhere?
Best place for them, in the VC4.pas RTL unit?
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Jul 03, 2017 8:40 am

Peter's V3Dinit example dumps these V3D registers.
Probably the first thing that needs porting after the register names and addresses.
User avatar
Ultibo
Site Admin
Posts: 1476
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Mon Jul 03, 2017 10:27 am

Gavinmc42 wrote:the V3D registers, page 82-84 are they in Ultibo anywhere?

No, not there yet but they are incredibly easy to port over.

The ASM syntax Peter uses is very close to Pascal, you just need to add a const keyword at the top of the list and add a // at the start of each comment.

Gavinmc42 wrote:Best place for them, in the VC4.pas RTL unit?

I think by the time all of the Userland interfaces are done the VC4 file will be pretty well full, I'd say the V3D material would be best in a new VC4V3D.pas file instead.

Many of Peter's examples should port to Ultibo quite well since he doesn't rely on any specific features, the actual code in the Refresh example is less than 100 lines.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Jul 03, 2017 10:48 am

Ok, I will have a play, I think even I might figure out 100 lines.
The VG stuff looks the easiest, as more gets figured out it can be expanded.

All the registers in a VC4V3D.pas file as that won't change.
ControlList in another, then VG/NV above that?
Or just stick with Peter's file conventions and convert.

Which assembler does Ultibo use?
Will Peter's FASMARM code used inline just assemble?
I have no idea.

Only need to get one example working to prove the concept.
Gavinmc42
Posts: 1003
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: OpenVG- baremetal VG

Postby Gavinmc42 » Mon Jul 03, 2017 1:32 pm

The V3D.inc with all the register constants is easy to port.
Global search replace does most of it.

The asm macros in the fasmarm.inc are a pain.
Looks like I am going to need to learn assembler :(
Might even have to look at pik33 code for clues ;)

How to write assembler code that works in ARM6/7/8?
Better off learning how to do this in Pascal?
The Pascal equivalent of this.

Code: Select all

macro imm32 reg,immediate {
  mov reg,(immediate) and $FF
  orr reg,(immediate) and $FF00
  orr reg,(immediate) and $FF0000
  orr reg,(immediate) and $FF000000
}

; Run Tags To Initialize V3D
imm32 r0,PERIPHERAL_BASE + MAIL_BASE
imm32 r1,TAGS_STRUCT
orr r1,MAIL_TAGS
str r1,[r0,MAIL_WRITE] ; Mail Box Write


pik33
Posts: 576
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: OpenVG- baremetal VG

Postby pik33 » Mon Jul 03, 2017 5:47 pm

These macros are something like procedure in Pascal. The difference is: it is not called. It is inserted there. The pascal equivalent is inline

The macro in the example loads arbitrary immediate 32 bit value into a register. The ARM cannot load any imm32, this problem has to be worked around. One way is using this kind of macro. Another is

Code: Select all


                 ldr r0, the_value
                 b        next_instructon

the_value: .long a_value

next_instruction:   // here is the rest of code


To avoid many jumps over these constants, place them at the end of the code.

You can find examples of this method of declaring constants in assembly fragments of SimpleAudio module.
User avatar
Ultibo
Site Admin
Posts: 1476
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: OpenVG- baremetal VG

Postby Ultibo » Tue Jul 04, 2017 12:38 am

Gavinmc42 wrote:Better off learning how to do this in Pascal?

Yes, I don't see any reason why this is done in Assembler except that is what Peter uses for all his work.

Probably best to start with something like the V3DINIT example in order to learn how to read from the V3D registers and make sure that you get the same results.

So to read from the V3D_IDENT0 register would look like this in Pascal:

Code: Select all

var
 Value:LongWord;
 
begin
  Value:=PLongWord(PERIPHERALS_BASE + V3D_BASE + V3D_IDENT0)^;
 


Taking the Refresh example, only the code from Refresh: to b Refresh needs to be ported, all of mailbox and framebuffer handling has to go through the Ultibo mailbox functions in order to get the correct type of memory allocated. This post contains a version of the Enable QPU request that works and setting of the V3D clock shouldn't be needed because it is already enabled by default.

The trickiest bit will be converting CONTROL_LIST_BIN_STRUCT and CONTROL_LIST_RENDER_STRUCT which are generating VC4 code using FASM macros, it might even be better to start by compiling those bits using FASM and turn them into Pascal records using Bin2Type.
Ultibo.org | Make something amazing
https://ultibo.org

Return to “Graphics”

Who is online

Users browsing this forum: No registered users and 1 guest