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

Vulkan rendering backend. Early Work-In-Progress #8601

Merged
merged 116 commits into from
Mar 20, 2016
Merged

Vulkan rendering backend. Early Work-In-Progress #8601

merged 116 commits into from
Mar 20, 2016

Conversation

hrydgard
Copy link
Owner

Please note - this is not for general use, it's only an early preview. It's very rough, only works in non-buffered (crashes in buffered) and is missing many features and optimizations, so it's not even fast yet.

EDIT: At this point, it already beats OpenGL in nearly everything I've tried, though is not feature complete of course.

But, it's a start, and this will hopefully let us take performance to the next level on Android, eventually - once drivers supporting Vulkan are released, and present on devices. Some devices will get Vulkan with a Marshmallow update (nVidia Shield/TV) while others will have to wait longer or won't get it at all.

@Anuskuss
Copy link
Contributor

Awesome 👍

@gamelaster
Copy link

D3D11 backend WIP too?

@hrydgard
Copy link
Owner Author

@gamelaster D3D11? only vague plans, nothing concrete. Just made space in the enum, heh. Might remove it from the list.

@VIRGINKLM
Copy link
Contributor

Just a small note. Samsung Galaxy A6 (2016) supports Vulkan straight out of the box and NVidia Shield devices began recieving Dev buils supporting Vulkan. Also I bet Galaxy S7 variants will have straight out of the box support for it.

@RinMaru
Copy link

RinMaru commented Feb 20, 2016

So will this work on ogl backend in the future and can this hold potential for better performance on damanding games on hardware that couldnt run at full speed previously?

@zminhquanz
Copy link
Contributor

https://en.wikipedia.org/wiki/Vulkan_(API)
Here is the list for the GPU from NVIDIA , AMD and PowerVR , Mali , Adreno , Intel to support Vulkan API
Device can be update to Android 6.0 to support it

@@ -22,6 +22,9 @@ class GraphicsContext {

virtual void Resize() = 0;

// Needs casting to the appropriate type, unfortunately. Should find a better solution..
virtual void *GetAPIContext() { return nullptr; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is no longer used?

-[Unknown]

@unknownbrackets
Copy link
Collaborator

Where is the graphicsContext supposed to be populated? I had to add PSP_CoreParameter().graphicsContext = graphicsContext; to NativeRender() to fix some crashes.

Well, now I'm crashing in vkCmdClearAttachments, but it's progress.

-[Unknown]

@hrydgard
Copy link
Owner Author

@unknownbrackets Remember to turn off buffered rendering, it will crash :)

Don't recall having problems with graphicsContext... hm

@hrydgard
Copy link
Owner Author

@unknownbrackets turns out I broke depth buffer init, too, when messing with the shield

Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release CRT DLL|Win32 = Release CRT DLL|Win32
Release CRT DLL|x64 = Release CRT DLL|x64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add these, or were they just added by something else?

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, they were probably added when I tried to import the CMake-generated project for glslang, before I made my own instead.

@@ -123,7 +122,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>Ws2_32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;dsound.lib;glu32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;comctl32.lib;d3d9.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>..\Windows\x64\Debug\glslang.lib;..\ext\vulkan\vulkan-1.lib;Ws2_32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;opengl32.lib;dsound.lib;glu32.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib;comctl32.lib;d3d9.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason only this one gets the glslang lib?

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not supposed to be there, it's linked through "References". this was an old thing that slipped through some cleanup.

@unknownbrackets
Copy link
Collaborator

@hrydgard

Refactor away nextTexture_. Not needed on Vulkan.

Do you mean because you plan to remove the hardware transform -> software fallback and move vertex decoding earlier so that it can be done before SetTexture()? Because that is the reason nextTexture_ exists. We don't really need it for D3D9 either, technically, I suppose.

To clarify, ApplyTexture() MUST be called AFTER the vertices have been decoded. I'm not sure, but right now this isn't happening, and this could be contributing to rendering bugs. At the very least, it's ignoring the output of the vertex decode (texture bounds.)

-[Unknown]

@hrydgard
Copy link
Owner Author

Yeah, I intend to move things around a bit, I've just been swamped. And yes, UV scale/offset seems a bit broken, among other things, as expected...

@@ -50,10 +50,14 @@ enum BufferFilter {
enum class GPUBackend {
OPENGL = 0,
DIRECT3D9 = 1,
DIRECT3D11 = 2,
VULKAN = 3,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent nitpick.

-[Unknown]

@unknownbrackets
Copy link
Collaborator

Personally, I would prefer this convention:

  VkFramebufferCreateInfo fb_info = { VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO };
  fb_info.renderPass = surface_render_pass_;

Instead of:

  VkFramebufferCreateInfo fb_info = {};
  fb_info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
  fb_info.pNext = NULL;
  fb_info.renderPass = surface_render_pass_;

What do you think?

-[Unknown]

@hrydgard
Copy link
Owner Author

Hm, not bad. I guess the compiler will eliminate the extra stores (first zeroing the struct, then filling it out) anyway. Let's do that.

@unknownbrackets
Copy link
Collaborator

Do you think it would be a good idea to decode directly onto the push buffer (from the jit), and then if we're caching, issue a cmd to copy that to the cache buffer (which would then be used for subsequent draws?)

By the way, I'm seeing something funny with vertex coords in FF4, seems to be why only the first letter is drawing in some places. Still debugging, but this area has me thinking about vertex decode is all.

-[Unknown]

@@ -162,7 +162,7 @@ static void ConvertProjMatrixToVulkan(Matrix4x4 &in, bool invertedX, bool invert
if (invertedY)
yoff = -yoff;

const Vec3 trans(xoff, yoff, gstate_c.vpZOffset + 0.5f);
const Vec3 trans(xoff, yoff, gstate_c.vpZOffset * 0.5f + 0.5f);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait wait wait, does Vulkan use the half-pixel offset insanity that Direct3D9 does? It doesn't right?

-[Unknown]

hrydgard and others added 23 commits March 20, 2016 19:31
Optimizing this number (by avoiding redundant UBO uploads etc) will probably help performance.
We have to clear both at the same time.  I think it makes sense to
consider this part of the "separate alpha" flag, since alpha has to match
both color and depth.
It's definitely not a float, oops.
Otherwise we get wrong colors - also we are still converting colors.
Some places were not handling it as a power of two.
…g directly into the pushbuffers easier, plus other benefits later.

(For example, we'll often be able to avoid rebinding the vertex and
index buffers at new offsets by just keep counting upwards between draws,
if the vertex format is the same but other state changed)
Turns out it's only OK to leave out if rendering only to color,
otherwise behaviour is undefined - which means it may still be enabled.
hrydgard added a commit that referenced this pull request Mar 20, 2016
Vulkan rendering backend. Early Work-In-Progress
@hrydgard hrydgard merged commit 2b46ae5 into master Mar 20, 2016
@hrydgard hrydgard deleted the vulkan branch March 20, 2016 20:09
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.

9 participants