PixelFarm icon indicating copy to clipboard operation
PixelFarm copied to clipboard

CosmosOS RenderSurface Developing

Open prepare opened this issue 6 years ago • 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 :)

prepare avatar Jul 04 '18 22:07 prepare

some issues on Cosmos that relate to this eg...

https://github.com/CosmosOS/Cosmos/pull/913

https://github.com/CosmosOS/Cosmos/issues/514

https://github.com/CosmosOS/Cosmos/pull/628

https://github.com/CosmosOS/Cosmos/issues/601

https://github.com/CosmosOS/Cosmos/issues/684

https://github.com/CosmosOS/Cosmos/issues/936

https://github.com/aura-systems/Aura-Operating-System/issues/24

prepare avatar Jul 04 '18 22:07 prepare

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),

prepare avatar Jul 06 '18 19:07 prepare

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.

prepare avatar Jul 06 '18 22:07 prepare

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


prepare avatar Jul 06 '18 22:07 prepare

Our pure C# Software renderer (PixelFarm's MiniAgg) is ported from @larsbrubaker 's agg-sharp. :+1:

prepare avatar Jul 06 '18 23:07 prepare

Excellent work!

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

fanoI avatar Jul 07 '18 09:07 fanoI

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.

:)


prepare avatar Jul 07 '18 09:07 prepare

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

prepare avatar Jul 07 '18 09:07 prepare

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

fanoI avatar Jul 07 '18 11:07 fanoI

Wow great work @prepare!

valentinbreiz avatar Jul 07 '18 11:07 valentinbreiz

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

  1. CosmosOS=> use this dev branch => https://github.com/prepare/Cosmos/commit/6d945eefe9c0b865764ac13aac65eed56ed8474b. 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

prepare avatar Jul 08 '18 13:07 prepare

Is it fast?

valentinbreiz avatar Jul 08 '18 14:07 valentinbreiz

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)


prepare avatar Jul 08 '18 22:07 prepare

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

prepare avatar Jul 08 '18 22:07 prepare

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 ?

prepare avatar Jul 08 '18 22:07 prepare

Access vmware-svga framebuffer

new doc => http://vmware-svga.sourceforge.net/index.html

(I have a clone of old doc) vmware-svga doc =>https://github.com/prepare/vmware-svga


see also:

https://github.com/mesa3d/mesa/tree/master/src/gallium/drivers/svga

https://cgit.freedesktop.org/xorg/driver/xf86-video-vmware/

(fork https://github.com/prepare/xf86-video-vmware)

https://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/svga/

prepare avatar Jul 09 '18 01:07 prepare

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 avatar Jul 09 '18 07:07 fanoI

@fanoI , I sent the pull request => https://github.com/CosmosOS/Cosmos/pull/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.

prepare avatar Jul 09 '18 09:07 prepare

IL2CPU can't compile Typography.

(not about Plug missing).

I will report error later.

prepare avatar Jul 10 '18 02:07 prepare

Any news about your work on Cosmos ? :)

valentinbreiz avatar Sep 03 '18 11:09 valentinbreiz

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 :)

prepare avatar Sep 03 '18 17:09 prepare

Cool :)

valentinbreiz avatar Sep 03 '18 20:09 valentinbreiz

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...

fanoI avatar Sep 04 '18 10:09 fanoI

Any update on this?

MishaTy avatar Dec 01 '20 14:12 MishaTy