PS3 opengl library(linux)

I'd like to share opengl library.

Don't want to use it a lone.
I assume there are some people who use ps3 linux for some purpose.

if wanted , please let me now.
plan to place here next time.

It is built from Mesa-21.3.9. modified it to my need.
It is not complete , but it is enough to do a basic opengl programming.

Features:
1) an old API to a new API can use.
2) fix pipe line for auto generate the mesa shader program.
3) ARB shader assembler
4) glsl shader compiler

see attached file for examples.
 

Attachments

Hi,

I think no one interesting. but still like to tell.

Last time try to upload, it causes trouble to psxplace.

so if some likes to have please let me know.

ps3_opengl.tar.gz about 4MB

contents:
ps3_glut/include
GL/freeglut.h
GL/freeglut_std.h
GL/freeglut_ucall.h
GL/gl.h
GL/fakeglutEXT.h (simple custom glut)
MesaLib.h (support opengl extention header)

ps3_glut/lib
libMesa.so 9.2MB
(Mesa core:
src/mesa/main
src/mesa/program
src/masa/math
src/mesa/vbo
src/util
src/compiler)
libNV.a 464.8 KB (interface and emit fuctions between Mesa core and RSX)
libRSX.a 146.9 KB (the same function as libgcm in GameOS)
libInput.a 33.7KB (mouse and keyboard codes from libSDL )
libGLU 122KB (from old ps3dev/mesa-7.10.2-PS3)

ps3_glut
MesaLib.c (custom build mipmaps instead of gluBuild2DMipmaps)

requirements
OtherOS++ support
my ps3fb patches
powerpc linux 32bits support
(t2SDE able to run,
but not sure may need libudev 32bits for libInput )
config ps3fb:16M (default 9MB)

by the way,
perhaps some want to know about
Mesa opengl ps3 port(OtherOs++ 355) for linux(on my ps3 slim).

I can say now in the applicable for general.

here are the features not implement.
1) accummulate buffer (libgcm not support)
2) rasterPos2d (libgcm not support)
3) edge flag
(libgcm support for each vertex but not in vertex buffer)
4) color index (libgcm not support)

5) 1D/2D texture with border
not support border in texture image (plan for future)
but now only for const color border by default

6) 3D texture ( plan to do in the future)

here my testing the real example source code

reference to the book "Beginning OpenGL Game"
Autur Kewin Hawkins
(for me is the best one of a classic opengl book).

I choose two(chapther9 and 10).
chapter 9: Combiner, EnvironmentMapping and MultitexTerrain
chapter 10: FrustumCulling and marbles

the results are almost the same (a bit different).
the frame rate is OK
comparing my pc linux core5(16 GB RAM) with Radeon RX 470 (4GB).

see the result snap shot pic in attached files.
 

Attachments

  • env_20231130_170025.png
    env_20231130_170025.png
    220.1 KB · Views: 95
  • cull_20231206_140904.png
    cull_20231206_140904.png
    234.9 KB · Views: 99
Hello,

update what ps3 mesa opengl can do now.
The test source code code from www.paulsprojects.net( [email protected] )
I think. this site is very good old classic opengl tutorial.
For now, just two. may be next "octagon engine".
1) shadow map, use depth texture comparision.
2) quake3 bsp.
 

Attachments

Hey cool thread!
I've never done any OpenGL/graphics programming. But I'm still very interested in your project. I run Gentoo & Fedora on my PS3 (CECHP-01) but mine is downgraded to Sony Firmware 3.15 (the last FW with native OtherOS). My main reason for running Linux on PS3 is so I can study the Cell CPU and learn to leverage the power of the SPUs. My Fedora install is an old release (12) but I keep it installed because it runs great on the hardware, and also because all of the Cell development/profiling tools are available as RPMs and easily install via the package manager. I've got the full suite of IBM's Cell SDK on my PS3 and it works great :)

Unfortunately I don't think I can use your project with my current setup as I'm not on custom firmware (CFW), which kinda sucks :-(
I'm not planning to alter the firmware on my current PS3 anytime soon cuz I'm happy with it the way it is. I do however 100% intend to pick up another console as soon as I can and use that one with CFW/Linux. I'm interested in messing around with some of the "features" (hv calls, etc) that have been made available. Also it would be fun to get into developing GameOS homebrew packages and such. I see you use T2 on your setup :) Herr Rebe (the T2 guy) has been a huge inspiration for me this past year or so, and I have installed binary releases of his OS on my PS3 in the past. Will probably be installing it again soon to see what the newest release looks like. T2 is weird and I could never figure out how package management worked in that distro. Maybe if I re-install it you can explain it to me!

Some questions: have you tried out Herr Rebe's latest kernel patch for the PS3's frame buffer driver? If I'm not mistaken, he has removed Sony's double-buffering implementation which was supposed to compensate for very slow write (or read?) speeds between the Cell and the RSX (XDRAM?). I could be totally wrong about that but it sounds like he's recovered some RAM to use and even improved performance a bit. Was thinking about trying the patch on a kernel for my machine (i don't think it requires any CFW hacks). Also, was wondering if you are using the xf86-video-ps3 xorg driver for the RSX and if so, how much of a difference does it make? Like, can you display/scale video better in apps like mplayer and such?

Also (last question), have you seen my video showcasing a Mesa/OpenGL release that was ported for the Cell? I don't think the implementation was ever completed but the Mesa release that I compiled (using the Cell SDK) included:
MesaLib-7.8.2.tar.bz2
MesaGLUT-7.8.2.tar.bz2
MesaDemos-7.8.2.tar.bz2
You may be interested to check out the code for that release because it actually uses the PS3's SPU cores, which I find super interesting!
Here's a video:
And another one...

Let me know if u have like a github or something so I can follow your project. Will definately try it out when I finally do pick up a 2nd PS3 I can put CFW on.
Keep up the good work!
btw my github is here - https://github.com/ModelCitizenPS3
 
Hello,

I also see yours quite interesting
on SPU (multi-core simd processing).

but this is a direct render based on old ps3freebsd_test project.
use almost RSX features that exposed by otheros++.

my system (slim 25xxx)
Gentoo ppc 355 otheros++, not T2.

I choose ppc not ppc64. Gentoo, don't have mixed model for latest.
the main reason is the small foot print, speed and fit for SPU.

first let start with to the main point,
ps3freebsd_test project
is lack of shader compiler.

as my learning, I find the Mesa GLSL is suitable(open source, no any hidding).
the only thing to do is shader translation for Mesa assembly program
to shader instruction for RSX.

after can translation, so then everything is easy.
fifo command supports partial Opengl in low level.

By the way,
Gentoo can run CellSDK3.x, Mars and Freezer in an old fashion with a trick.

anyway, i can give my modified source if you like.
almost all,
only one source file(fifo.c) that i cannot give.
but it almost the same as libgcm as present in psl1light sdk.

Finally, i finish at my target and done for it.

possibly if you can create github so for any one can help to optimize or recoding.

there are many code is not used and some features not supported.

my code is just simply code, no safty and ugly.

I write it without any plan. Just do as my think.

Hope some one to continue.
 
  • Like
Reactions: sbp
Hi,

after stop for long, fix some of my mistakes.
so then start testing vertex texture sampling. it is working as expect.

here's my own specification defined to tell the low level driver.
1) textures in fragment
unit0-7 map to hardware unit0-7

2) textures in vertex
unit8-11 map to hardware unit0-3

see sample code in the attached file.

the library will be given only if interested.
you can build and do your testing and there is a lot of things to be customized.
 

Attachments

Hi,

update Hero city testing with my Opengl library for fun

pure generic Opengl configuring as original source

1) worldviewrange=30
peopleviewrange=20
frame rate: min 6

2) worldviewrange=10
peopleviewrange=20
frame rate: min 29

the problem is drawing the tile world.
a lot of small tiles, vertex count (min 6 and max 18) per draw call.
the other, the vertex sets are non-interleave.

what should do to improve as my thinking.
1) classify and separate in each flock set.
for example,
building (maybe one building at location).
road
sidewalk

2) convert the vertex sets to interleave(better performance).


see the picture,
1) player, people, sky, water and collision
2) all

please if any, suggestion.
IMG_20241102_000036_1.jpg IMG_20241102_145758_1.jpg
 
Hi,

my update testing Hero City.
just try with a simple generic Opengl.

let say be able to play now.

comparing with my first test in the past using pure libgcm.
the frame rate is almost the same at 30fps.

surely, slower than pure libgcm. but not much.

the implementation of the two is difference.

1) pure libgcm
place vertex buffer on GART(part of PPU memory),
GPU can access directly. the cost is the latency access time.

every draw call,
alloc GART buffer, prepare copy and then draw.

2) opengl library
place vertex buffer on VRAM, GPU can access faster than GART.
the cost is DMA transfering time from PPU memory to VRAM.

every draw call,
alloc VRAM buffer, prepare copy and DMA transfer, then draw.

here's below issue and what done.

if a lot of Big monsters, people and zombi around the player. the frame rate is drop to around 20.
if try to get out of that place to another, the frame rate back to normal 30 again.

so if limit the People population to 100 from 500, then overall at 30 fps. see the pic at frame rate.

what done is simple.
transform all vertices to world coordinate. format them to interleave.
put them all inside glBegin and glEnd. and let Mesa VBO do self manage.

run on linux kernel <= 6.6.x OK
>= 6.11.x, 6.12-rc (slower can see and feel)

IMG_20241106_201746.jpg
 
wish I could test this, but I don't have a cfw ps3. I think I've gotten quite good at linux, but I often forget commands and stuff (I know where to find them usually). my next pc may be a linux machine in fact, but I'm not sure yet. I've been using wsl v2 currently, which seems to satisfy most needs except it doesn't seem to have controller drivers from what I've read.
 
wish I could test this, but I don't have a cfw ps3. I think I've gotten quite good at linux, but I often forget commands and stuff (I know where to find them usually). my next pc may be a linux machine in fact, but I'm not sure yet. I've been using wsl v2 currently, which seems to satisfy most needs except it doesn't seem to have controller drivers from what I've read.
dual boot mint and windows you will have both running on the same hardware, running bare metal linux is always the best option
 
Hi,

starting to do somethings new never hurt at all.

to be clear, for Opengl library requirements below.

to run on real ps3(not rcps3)
1) otheros++ support(not the same as otheros).
2) be able to boot linux from
2.1 usb
with USB linux, never test it. but should work.
2.2 internal hard disk
depends up yours need or convenience.

to build on PC
1) any linux destro or emulator(such as wsl v2)
if having powerpc cross compile tools, i think it should work
with gcc version >= 5.5.0. just set library path to compile and link.

I think this my information will may be useful.
especially, to develop cell sdk with new gcc version(now 13).

let talk about trivial things.

my first linux destro is ubuntu. it is very nice.
later, find myself need more to learn about how to build linux.

Gentoo is the most fit to me. normal people don't like it.
because it's not ready. it gives only basic things to boot and develop.

every year, my pc linux and favorite ps3 are built.

1) pc linux takes a full day long to get all my need a lot software).

2) ps3 linux takes about not over two or three hours(just tools need to develop, no X)
dhcpcd wpa_supplicant alsa-utils numa (for libmars) libpng
libjpeg-turbo mpg123 libvorfile ffmpeg
for linux kernel cross compile on PC linux and ps3 will be boot.

for cell sdk tools, I use my own last update copy.
gcc 5.5.0 for both PPU and SPU simdmath libmars

by the way, i find something myth to me.
for ppu, I build libmars and cellsdk with gcc 13.
i don't know good or bad but it works fine.

what i do simply.
1) make symlink to gcc version 13 by prefix (ppu-) one times only
see my attached file for example.

2) gcc-config to set default to 5.5.0
[1] powerpc-unknown-linux-gnu-5.5.0 *
[2] powerpc-unknown-linux-gnu-13
3) compile by prefix ppu-

my own copy cell tools on Gentoo both PC or PS3, this is working with the latest tarball up to now,
if you need, let me know. I will place it in a free cloud host.

I will stop for this Opengl library temporarily.

Now busy with Lua (normally use only C or C++).
it is now very interesting for me, especially for table.
for example,
it can add, remove and query. the language seem having mechanism for human brain.
state = {}
---add
state["feeling"] = "happy"
state["action"] = "run"
---remove
state["feeling"] = nil
---query
if state["feeling"] ~= nil then ...
 

Attachments

IMG_20241113_204818_1.jpg IMG_20241113_204949_1.jpg
Hi,

another testing with otherdev projectv02.

the result is done OK. even, it is not my expect to see.

for this, almost everything(frame by frame) ready in VRAM with buffer object and draw
the world with two lights and the player animation(ms3d).

with view range 10
only light shading, playable at around 30fps.
if enable texture, the frame rate drop to around half(~14fps).
do trying decrease the view range, playable at 4 around 30fps.

by the way, i think some will question why i do this for.

want to show? no.

frankly, there are a lot of challenge things waiting for.
I want to have video or music station or any games that run stand a lone.
 
Hi,

my first information about this Library.
hope be useful, but not sure.
there will be either some right or wrong.

if feed, it will be help to add or remove.

there are three issues, color, mipmap and cubemap.
these make this lib be different from opengl standard.

see "opengl_issue.txt" for details.
 

Attachments

Hi,

test rendering to texture or render buffer in float.
working now after adding and fixing some.

note: see detail in "render_depth_infloat".

having some issue,
not sure about the way properly to encode and decode of
e8.m16 and e4.m12 floating point for depth buffer.
there are some point that be confused.

for simple think,
e4.m12
0xffff = 511.9375 for clear depth

e8.m16
0xffffff = 6.80564733841e+38 for clear depth
(not 6.80564733842e+38)

see more detail in "float_to_custom".

if any know about how to encode and decode properly,
do please give advice.

Thanks in advance.
 

Attachments

Hi,

update about 3D texture.

all surface and texture formats are tested.
and worked well.

so this is the last feature by simple test, two images and specify depth 2.
it works as expectation. select the first by z = 0.0 and the second z=1.0.

for 3D texture mipmap, there are some point that not be useful for.
for example,
512x512x4 lod0 1st 2nd 3rd 4th
256x256x2 lod1 1st 2nd 128x128x1 LOD2 1st
128x128x1 lod2 1st
....
2x2x1 lod8 1st
1x1x1 lod9 1st

lod2-9, only the first image(lost half in LOD increasing).

for dxt in 3D texture, still be in question.

any suggestions, please.
 
Hi,

update a simple of 3d texture DTX volume compression helper.
adding in mesa "src/util/format/u_format_s3tc.c" on my local copy.
it works but don't know whether properly or not.

hope this be helpful .
 

Attachments

Hi,

for my util helper, using the dtx encode/decode block4x4 of mesa source.
it is in "src/mesa/main/texcompress_s3tc_tmp.h".

if you'd like to add to your ps1light.
my suggestion is looking at it and cut and paste what is needed.

another about 3d swizzle format, it is also special handle in 3d way.
apply 2d swizzle is also not working.
you need to find the routine linear to swizzle in 3d.

for my real purpose, just to tell "3d texture is working".
 
Hi,

as my search at Z-order curve wiki.
ps3 3D texture swizzle is

transformation of multi-dimensional to one.

my test image(512x512x2)
input: x,y z, width, height and depth
output: one address space.

it is slow. there must be the way to do in linear way
to speed up (to swizzle and the reverse).

hope things faster.
 
Hi,

update testing more on some intereting point.

1) YUV texture,
see in tiny3D ( ps1light project), but don't know how.
so trying to do the same in this opengl library.

texture format R8B8_R8G8 and B8R8_G8R8,
the yu420p is work well in RGB restoration in fragment.

here is a test fragment program.

R"GLSL( #version 460
layout(location = 4) in vec2 vTexCoord0;
layout(location = 0) out vec4 oColor;
uniform sampler2D uSampler1;
void main() {
vec4 C0 = vec4(-0.0625,-0.5, -0.5, 1);
vec4 C1 = vec4(1.164,-0.213, 1, 0);
vec4 C2 = vec4( 1.793 ,-0.534, 2.115, 0);
vec4 color = texture(uSampler1, vTexCoord0);
vec3 V0 = color.xyz + C0.xyz;
vec3 Y = V0.xxx * C1.xxx;
Y.y = V0.z * C1.y + Y.y;
Y = V0.yyz * C2.xyz + Y;
oColor = vec4(Y, C0.w);
})GLSL";

2) frame buffer only color buffer( no depth buffer)
GL_R8
source format: GL_RED
source type: GL_UNSIGNED_BYTE

3) frame buffer only depth buffer(no any color buffers)
GL_DEPTH24_STENCIL8
source format: GL_DEPTH_STENCIL
source type: GL_UNSIGNED_INT_24_8
GL_FLOAT_32_UNSIGNED_INT_24_8_REV
note: there is no stencil for floating point depth format.

4) texture swizzle and mipmap in 2D and 3D.
these are special for zigzag and faster than linear.

on Linux, there are a lot of things interesting to do.

next plan,
running two or more rsx contexts in threads to speed up.
one is a job for display and another are for background rendering(rendering only to frame buffer) .

anyway, hope it help some.
 
Back
Top