-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
Awesome 👍 |
D3D11 backend WIP too? |
@gamelaster D3D11? only vague plans, nothing concrete. Just made space in the enum, heh. Might remove it from the list. |
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. |
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? |
https://en.wikipedia.org/wiki/Vulkan_(API) |
@@ -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; } |
There was a problem hiding this comment.
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]
Where is the graphicsContext supposed to be populated? I had to add Well, now I'm crashing in vkCmdClearAttachments, but it's progress. -[Unknown] |
@unknownbrackets Remember to turn off buffered rendering, it will crash :) Don't recall having problems with graphicsContext... hm |
@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 |
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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.
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 To clarify, -[Unknown] |
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent nitpick.
-[Unknown]
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] |
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. |
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); |
There was a problem hiding this comment.
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]
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.
…ing optimization.
…ot waste space (nVidia needs 256-byte alignment)
Vulkan rendering backend. Early Work-In-Progress
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.