Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardware tessellation #9210

Closed
wants to merge 49 commits into from
Closed

Hardware tessellation #9210

wants to merge 49 commits into from

Conversation

xebra
Copy link
Contributor

@xebra xebra commented Jan 8, 2017

I implemented hardware tessellation, currently only on OpenGL.
This is using technique called "instanced tessellation". That is using basic method "instanced rendering". And you can find a simple bezier sample implementation here (http://developer.download.nvidia.com/SDK/10.5/opengl/screenshots/samples/instanced_tessellation.html).
Of course, I know NVIDIA's sample code is licensed under the proprietary license, so I rewrited alsmost everything.
Anyway, this implementation doesn't use so modern API like "tessellation shader", so I think I can implement it to DX9 or other backend.
Well, I think this codes needs to fix compatibility with GLES or other glsl version because I only tested with Win7 64 and I don't implement any compatible code yet.

Here's the some performance test.
Tested with FF4CC in DEBUG mode
Thundaga
Software tessellation is FPS 6
ulus10560_00000

Hardware tessellation is FPS 60
ulus10560_00006

Mist dragon morphing
Software tessellation is FPS 21
ulus10560_00001

Hardware tessellation is FPS 60
ulus10560_00007

You can find the option here!
menu_00000

@Orphis
Copy link
Collaborator

Orphis commented Jan 8, 2017

Sweet!
Yes, it needs some fixes for OpenGLES, doesn't seem to be too bad though.

@zminhquanz
Copy link
Contributor

@Orphis does OpenGLES 2.0 to support this ?

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 9, 2017

For GLES problems I think it will be enough to define all the texture 1D stuff as 2D(with 1 height) and GL_CLAMP defined as GL_CLAMP_TO_EDGE. Imo this will not be usable on mobiles through, this sure can be faster on desktops with powerful dedicated gpus, but that shader is actually extremely heavy and will tank fps down harder than software implementation in less optimal situations. Certain gpu's like those older mali's might just fail to compile it.

~

Would be good to also gray out "Spline/Bezier curves quality" setting when Hardware Tesselation is activated since it doesn't affect it in any way. Either way, nice work:3.

@zminhquanz
Copy link
Contributor

That look good , and it's very nice to support other backend and older like DX 9 , OpenGLES 2.0

@xebra
Copy link
Contributor Author

xebra commented Jan 9, 2017

@LunaMoo Thanks for advice and fix them.

@xebra
Copy link
Contributor Author

xebra commented Jan 9, 2017

Note: Information about to fix compatibility with GLES 2.0 or older glsl version.

Using new APIs

  • Instanced rendering
    glDrawElementsInstanced()
    gl_InstanceID in glsl
    If version 130, it needs code below for gl_InstanceID.
    if (gl_extensions.EXT_gpu_shader4) {
    WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n");

  • Vertex texture fetch
    glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &maxVertexTextureImageUnits);
    if maxVertexTextureImageUnits > 0, enable

  • Floating point texture
    if OES_texture_float is enabled??

@hrydgard
Copy link
Owner

hrydgard commented Jan 9, 2017

Really nice work!

I'll be able to review it in detail soon. Only concerns are if the additional shader bits would impose any performance hit somehow (probably very little), and obviously possible compatibility issues on mobile hardware, as commented.

@zminhquanz
Copy link
Contributor

I will going to review that

@LunaMoo
Copy link
Collaborator

LunaMoo commented Jan 9, 2017

When saying about defining 1D to 2D on GLES I was thinking about something like this.

Didn't really tested that code on GLES device ~ hopefully works;p, but we definitely want to keep 1D where possible(aka OGL) - from a quick test Thundaga in FF4 the performance of the shader drops to 50% with 2D compared to 1D.:|

@i30817
Copy link

i30817 commented Jan 9, 2017

This is only for spline curves right?

@xebra
Copy link
Contributor Author

xebra commented Jan 10, 2017

@LunaMoo Oh, I see thanks again:)

@i30817 No, it supports both of spline and bezier. It is compatible code with spline and bezier.

@zminhquanz
Copy link
Contributor

zminhquanz commented Jan 10, 2017

@xebra tested on my PC , using GTX 950 , OpenGL Backend , that look good and compability well and didn't have isssues , and perfomance for me seem not different too much at all

@xebra
Copy link
Contributor Author

xebra commented Jan 10, 2017

@zminhquanz Thank you for testing:)
I hope to effective in a situation like using powerless cpu and low fps gameplay with spline/bezier.
I think if you use powerful cpu, it doesn't any benefits unfortunately. And software tessellation is not so slow because of @unknownbrackets 's SIMD optimaization. However, our codes can more optimize for software tessellation.

@DonelBueno
Copy link

Does any other game benefit from this change or just FF4?

@zminhquanz
Copy link
Contributor

@DonelBueno here is the list of game using spline / bezier
BEZIER:

Puzzle Bobble
SSX On Tour
Jeanne d'Arc

SPLINE:

Loco Roco 1 , 2
Idolmaster
Hexyz Force

BOTH:
Final Fantasy IV

@xebra
Copy link
Contributor Author

xebra commented Jan 22, 2017

@hrydgard I tried rebase and fix your request and push them.
Is this right?
I don't know how to use git well yet.

Brand new commits are just last 4 commits.

@hrydgard
Copy link
Owner

Hm, looks like you rebased on an earlier commit than master because some of my stuff is in there that shouldn't be (like the >> to << change).

So probably the master in your client that you rebased on wasn't updated to the upstream master.

Still, looks like it's free of conflict.

@xebra
Copy link
Contributor Author

xebra commented Jan 23, 2017

I was wrong something...
Of course, I resolved conflicts, but many commits duplicated.
But if this commits(pull request) is no problem, I don't mind.
If it has critical issue, what do I need to do?
Anyway, I need to study git more.

@zminhquanz
Copy link
Contributor

@xebra you can go to the wiki to see how to keep pull request up to date
https://github.com/hrydgard/ppsspp/wiki/How-to-keep-a-pull-request-up-to-date

@xebra
Copy link
Contributor Author

xebra commented Jan 23, 2017

@zminhquanz Thanks! Hmm, I'm using Tortoisegit on Windows but I think my way is almost same as the guide.

  1. clone xebra/ppsspp as origin
  2. add hrydgard/ppsspp as upstream
  3. fetch&rebase upstream
  4. fix conflict if needed
  5. pull upstream
  6. pull origin
  7. commit my changes
  8. push origin

Maybe, I think my mistake is "pull origin"...
Usually, I don't do that way but some errors occured when I push to origin, so I pulled from origin and merged and push them.
Also, "pull upstream" may be not necessary too...

@hrydgard
Copy link
Owner

5 should be done before 3...

Or in cmdline git, on your branch:

git fetch upstream
git rebase upstream/master

@hrydgard
Copy link
Owner

So apart from the rebase, what remains now? I'd like to merge this soon so I can do other changes and cleanup.

@xebra
Copy link
Contributor Author

xebra commented Jan 23, 2017

Remains are other backends implementation, but it's not done and need more time.
However, OpenGL implementation is almost done. Also, GLES(for mobile?) compatibility is now researching.
Please merge these if you approved.
I'll try to commit the other backends implementation in another pull request.
Thanks.

@hrydgard
Copy link
Owner

hrydgard commented Jan 23, 2017

OK, let's do it that way. I will do a rebase before merge to avoid duplicate commits in the history.

@hrydgard
Copy link
Owner

I cherry-picked your commits to a new branch, #9226 . I think I'm gonna merge that instead, once the buildbot is happy, for a cleaner history.

@iOS4all
Copy link

iOS4all commented Jan 23, 2017

I didn't find this option in iOS version of ppsspp any idea please?
I guess it's not merge yet?

@hrydgard
Copy link
Owner

Take it easy, it has not even been merged yet. Soon, though can't guarantee it'll work on iOS right away, this is still work-in-progress.

@xebra
Copy link
Contributor Author

xebra commented Jan 23, 2017

@hrydgard That sounds great! I appreciate your help.

@iOS4all
Copy link

iOS4all commented Jan 23, 2017

@hrydgard I edited my comment above before you reply. Yeah it seems not merged yet.
Anyway take your time and I hope it could work on iOS as well. We really need this option.
BTW all later versions of ppsspp on iOS are crashing when we select roms even the last one which is (1.3-299) and Last working version was (1.3-191) but beyond that are always crashes when we selected roms.
Thanks...

@hrydgard
Copy link
Owner

I merged #9226, so please base your future work on the current master @xebra :) Closing this.

@hrydgard hrydgard closed this Jan 23, 2017
@xebra
Copy link
Contributor Author

xebra commented Jan 23, 2017

@hrydgard Thank you :)

@iOS4all

I hope it could work on iOS as well.

I hope too!

@iOS4all
Copy link

iOS4all commented Jan 23, 2017

@xebra nice work. It's really appreciate a lot.
Waiting for your next work.
Cheers....

@xebra
Copy link
Contributor Author

xebra commented Jan 23, 2017

@iOS4all Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants