simias / rustation

Playstation emulator in the Rust programing language
Other
552 stars 21 forks source link

Use functions available in OpenGL 3.3 #9

Closed tikhomirov closed 8 years ago

tikhomirov commented 8 years ago

Using functions which are available in OpenGL 3.3 will allow to build project on OS X

simias commented 8 years ago

That does severely gimp the debug/error reporting, doesn't it?

The reasons I didn't really mind using extensions from OpenGL 4.x were that 1/ I'm a clueless OpenGL noob and 2/ I think down the line in order to accurately emulate certain features of the PlayStation GPU I might end up needing some extensions like GL_ARB_texture_barrier to implement custom blending in the fragment shader.

I didn't think it would be an issue since this extension and GL_KHR_debug seemed well supported even on 3.x cards.

Since you seem much more knowledgeable than me on this subjects, what do you think would be the right course of action here?

For the record here are the blending modes used by the PlayStation (taken from the No$ specs):

  B=Back  (the old pixel read from the image in the frame buffer)
  F=Front (the new halftransparent pixel)
  * 0.5 x B + 0.5 x F    ;aka B/2+F/2
  * 1.0 x B + 1.0 x F    ;aka B+F
  * 1.0 x B - 1.0 x F    ;aka B-F
  * 1.0 x B +0.25 x F    ;aka B+F/4

As far as I know some of those are incompatible with the fixed function OpenGL blending.

There's also the problem of the "mask" bit: the GPU draws using 1555 RGB but and the MSB is used as a kind of stencil/read only bit: in certain modes the GPU won't write to any framebuffer pixels whose MSB is set. And of course any triangle being drawn can potentially set it depending on the configuration, so it's not like a static stencil buffer.

For simplicity I thought if I performed the blending in the fragment shader I could handle this mask bit there as well.

tikhomirov commented 8 years ago

...GL_KHR_debug seemed well supported even on 3.x cards...

but it isn't supported on OS X (what a shame)

...I might end up needing some extensions like GL_ARB_texture_barrier...

OS X doesn't support this extension but it supports GL_NV_texture_barrier, but I believe it can be fixed with conditional compilation. Also using conditional compilation we can have functionality which uses KHR_debug for all systems except OS X

To be honest I didn't expect this patch to be merged at the first attempt :) I just wanted to get feedback ASAP

tikhomirov commented 8 years ago

Here is OpenGL capabilities table of OS X: https://developer.apple.com/opengl/capabilities/

simias commented 8 years ago

Your work is definitely appreciated!

I think I'm going to create a new issue where I outline my current understanding of the PlayStation GPU and how I think it can be emulated in OpenGL while also allowing improvements like increased internal resolution, filtering, texture replacements etc... I think it would help to start with the big picture to figure out how to deal with hardware that doesn't support some extensions. Also I would be interested to have some feedback on that given my lack of experience with OpenGL, maybe some of the things I have in mind are silly or would perform extremely badly.

simias commented 8 years ago

Okay I made a mega-issue in #10, I hope it's not too difficult to follow. I think it represents well what I currently understand of the PlayStation GPU and how it could be implemented in OpenGL.

ADormant commented 8 years ago

I think there is no point in limiting accuracy and features just to support systems with very bad OpenGL support like OSX and accurate PSX emulation may require OpenGL higher than 3.3 anyway however it should be doable with some hacks or a separate codepath. Dolphin OpenGL extension 4.0-4.5. Looks like Apple itself uses some hacks on OSX. https://github.com/dolphin-emu/dolphin/pull/1185

Yamakaky commented 8 years ago

Can you try master with the glium migration? @tikhomirov