PaintLab/PixelFarm

CosmosOS RenderSurface Developing

prepare opened this issue ยท 24 comments

CosmosOS Render Surface

1st thing, Thank you to all developers of the CosmosOS for their C# OS.

2nd , It would be 'another way' to help its GUI system with our 'Rendering Tech'.

AIMS :

To Bring the PixelFarm (pure C# software part) + Typography + HtmlRenderer to the CosmosOS.


I create a project that track some problems to visit it again =>here


Hello @jp2masa, @fanoI

since I'm very new to the CosmosOS,

I may ask you something that look easy to you, but please help me too.

I create an issue here since this is in early development stage.
=> so this will not interrupt your Github issue panel.


(I have to modify some parts of current PixelFarm)

This is a snapshot with bugs

This is a red polygon that is 'painted' with a MiniAggPainter (pure C# software renderer).
(a blue rect is painted with original cosmos)

cosmos_02

pic 1: a MiniAggPainter paints a red polygon on left-upper corner, Cosmos, SVGAII


Yes with Antialias side and another side still has bug (no AA)

cosmos_03

pic 2: Zoom in,with AA and Bugs


Compare with PixelFarm on Win7

This is a reference img.

cosmos_px_ref1

pic 3: same code, on Win7, and zoom pic

2 pictures (pic 1 and 3) are generated with the 'same' PixelFarm code.

I will analyze the bug later.


I think it may not too long way :)

Today, I've fixed that bug in my lib.

And This is the result :)

cosmos_04

pic 4: Anti-alias polygon! , MiniAgg painting on Cosmos Render Surface

On the 'same' .netstd code =>
The same rendering quality when compare with MiniAgg on Win7 (pic 3),

32 bits color blending

cosmos_06

pic 5: Yellow polygon with alpha channel = 180, Cosmos OS, SVGAII


cosmos_07

pic 5: Yellow polygon with alpha channel = 180, Cosmos OS, SVGAII


What Next ? =>
Text Rendering with Typography.

Hello @valentinbreiz,

I invite you to visit here :)

This may help your Aura-Operating-System.


I may ask some help from you too, about how to generate SSE from IL2CPU


Our pure C# Software renderer (PixelFarm's MiniAgg)
is ported from @larsbrubaker 's agg-sharp. ๐Ÿ‘

fanoI commented

Excellent work!

But are you using CGS (Cosmos Graphic Subsystem) as backend to do this?

Yes, I will contribute back.

Very Simple=> I just modify your code , and add another method called 'Blit(srcX,srcY,srcW,srcH, destX,destY).

I use 32 bits int[] Bitmap buffer internally
and I just 'Blit' it to the screen buffer surface.

:)


The PixelFarm render everything independently from the Host platform.

so It render as it run on Win7.

Then I just blits the output to screen buffer

fanoI commented

Excellent! It was exactly how I imagined this should have been done.

Wow great work @prepare!

I push the code of the example above to the github in 2 repo

  1. CosmosOS=> use this dev branch => prepare/Cosmos@6d945ee. You will see I modify some parts of the original.

  2. PixelFarm => use this cosmos_01 branch => https://github.com/PaintLab/PixelFarm/tree/cosmos_01


Solution Explorer View

cosmos_px_sln

pic 1: I add a reference to PixelFarm.Cosmos.One project (red boxes)


Test with (latest) fresh build again. This is a result.

Red and yellow polygons on left upper corner on black bg, 100x100px, is blitted from PixelFarm.

The blue and green rects are render with original CGS.

cosmos_08

pic 2: red and yellow polygon on left upper corner, 100x100px, is blitted from PixelFarm

Is it fast?

In this version. It is not fast as I think.

Below gif image shows my screen recording.

Render each image (800 x 600 px) frame every 10 ms => I found some flickers...

(the gif format lowers that actual image quality, but you can see color blend and antialias)

test01

pic 1: some flickers between each frame


I think the bottle neck may be in 'Blit' step (from internal int[] buffer to screen buffer).

I need to do some investigation about how can it be done faster.

(eg. how to swap screen buffer by switching screen's frame-buffer memory pointer)


I will add FPS info (text) on-screen soon

A software-rendering part of the PixelFarm (MiniAgg) is not slow.

The following gif is on Win7

This is a reference images

reference_on_win7

pic 1: software-only, MiniAgg, win7, 800 x 600px

(Each frame, starts from: Vectex list => scanline => internal-32-img-buffer =>Blit to Win7 Hdc)

I think Cosmos render surface should be in the same speed level ?

fanoI commented

I ask you to create a Pull Request so we can comment your modifications on the official Cosmos repository.
I've looked fast to what you had done and I think the Blit method should be part of the Canvas Abstract Class on the System ring not of the SVGA driver in the HAL ring.
This work should be - obviously - usable by Bochs and any GPU we want to support.

We had already predisposed a method similar to "blit" in Canvas:

https://github.com/CosmosOS/Cosmos/blob/master/source/Cosmos.System2/Graphics/Canvas.cs#103

and this from that you have to start.

You will have to overwrite this method in SVGAScreen and VBEScreen (Bochs GPU not real VBE), so if SVGA has hardware acceleration for this you can optimize for it... for VBE you surely have to use some sort of "memcpy" you can try to follow what I've done for Fill (memset) to optimize it with SSE.

@fanoI , I sent the pull request => CosmosOS/Cosmos#1005


Thank you, I'm very new to the Cosmos and SVGA.

so Feel free to edit/ comment until it fit what you need.

Then I will pull it back.

IL2CPU can't compile Typography.

(not about Plug missing).

I will report error later.

Any news about your work on Cosmos ? :)

Running on Cosmos is my dream!

But these next 2-3 weeks are too busy.

Then I will revisit this ...

IL2CPU can't compile Typography.

again :)

Cool :)

fanoI commented

OK in some way I've worked for you too these summer holidays, I've added a very fast MemoryOperation.Copy now VBE is able to show Bitmap very fast! DrawFilledRectangle has been optimized too...

Any update on this?