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

SDL/X11 Vulkan init #10413

Merged
merged 5 commits into from Dec 21, 2017
Merged

SDL/X11 Vulkan init #10413

merged 5 commits into from Dec 21, 2017

Conversation

hrydgard
Copy link
Owner

@hrydgard hrydgard commented Dec 15, 2017

This isn't too pretty, just hacking and slashing until I got it going on my laptop. Window resize not yet working. Feedback appreciated :)

Also it seems that FIFO vsync limiting is not working, it draws like crazy. So does GL on the same laptop though, maybe some issue with the screen being managed by the Intel integrated GPU and rendering happening on the nVidia.

Will fix #9031 .

@davidbepo
Copy link

davidbepo commented Dec 16, 2017

why not use the sdl support?
that would also support wayland

set(ANDROID ON)
endif()

# Of the CMake platforms, we only support Vulkan on Android and Windows.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment is now out of date.

I suppose we could support it on BSD too, right? Seems like we could just do if(NOT APPLE)?

-[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.

Yeah, probably. Would be good to have someone to test it ... not running BSD on any of my boxes.

@@ -20,8 +20,10 @@
#elif defined(__ANDROID__) // _WIN32
#include <android/native_window_jni.h>
#define VK_USE_PLATFORM_ANDROID_KHR
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
#include <X11/Xlib.h>
#include <X11/Xutil.h>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it at all possible for us to use typedefs to avoid these headers in VulkanContext.h? Even if xcb_window_t has to be a pointer that's simply new/deleted?

Just trying to avoid more unexpected issues with those headers...

-[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.

Yeah, that's probably a good idea..

lastT = t;
}
#endif
graphicsContext->SwapBuffers();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this mean we no longer allow unthrottle properly, or does it work now even without skipping the swapping above?

-[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.

This unthrottle was bad because it ignored control mapping and sat here as a strange hack. If we want that kind of unthrottle we should do it properly, until then we can use frameskip unthrottle on Linux. Though, I should of course make sure that works....

@@ -191,7 +191,7 @@ void GameSettingsScreen::CreateViews() {
}
#endif
bool vulkanAvailable = false;
#if PPSSPP_PLATFORM(WINDOWS) || PPSSPP_PLATFORM(ANDROID)
#ifndef IOS
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also here?

if (VulkanMayBeAvailable()) {

-[Unknown]

CMakeLists.txt Outdated
if(LINUX)
message("Using direct to display extension...")
if(LINUX AND VULKAN)
message("Using XCB extension...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Err?

-[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.

This stuff went through a few iterations very quickly, oops :) (had strange issues so I tried switching to the xcb stuff but then found out what the problem with the x11 stuff was and fixed that and went back...).

I'll clean things up soon.

@hrydgard
Copy link
Owner Author

@davidbepo because I installed the latest ubuntu and the provided version of SDL did not yet support it, so I don't want to require it yet.

@mrcmunir
Copy link
Contributor

WOW nice advance with mesa3d vulkan intel driver only work the UI this detected 1.0.57 version and these extensions

captura de 2017-12-18 12-13-30
captura de 2017-12-18 12-14-38
captura de 2017-12-18 12-15-27
captura de 2017-12-18 12-16-01
captura de 2017-12-18 12-16-18

But when load any game said DrawEngineVulkan.cpp:297: INIT : Creating null texture and report segment fault

Also add vulkaninfo for more information
vulkaninfo.txt

I debuging too from gdb but not much information crash from libvulkan_intel.so

Thread 1 "PPSSPPSDL" received signal SIGSEGV, Segmentation fault.
0x00007fffdd80045d in ?? () from /usr/lib/libvulkan_intel.so

@hrydgard
Copy link
Owner Author

hrydgard commented Dec 18, 2017

"Creating null texture" is normal, we create a small black texture to use as a replacement if texture creation fails or similar. Our code passes Vulkan validation fine so the crash is likely some kind of driver bug that should be reported to Intel..

Is that everything you could get from the call stack in gdb? (type bt to get the full stack if available)

@mrcmunir
Copy link
Contributor

@hrydgard Sure with bt returned

#0  0x00007fffdd80045d in ?? () from /usr/lib/libvulkan_intel.so
#1  0x00007fffdd821094 in ?? () from /usr/lib/libvulkan_intel.so
#2  0x00007fffdd8228b5 in ?? () from /usr/lib/libvulkan_intel.so
#3  0x00007fffdd94706c in ?? () from /usr/lib/libvulkan_intel.so
#4  0x00007fffdd8054bc in ?? () from /usr/lib/libvulkan_intel.so
#5  0x00007fffdd823ede in ?? () from /usr/lib/libvulkan_intel.so
#6  0x00007fffdd825c44 in ?? () from /usr/lib/libvulkan_intel.so
#7  0x00005555559387ec in TransitionImageLayout2(VkCommandBuffer_T*, VkImage_T*, int, int, unsigned int, VkImageLayout, VkImageLayout, unsigned int, unsigned int, unsigned int, unsigned int) ()
#8  0x000055555593aa7d in VulkanTexture::CreateDirect(VkCommandBuffer_T*, int, int, int, VkFormat, VkImageLayout, unsigned int, VkComponentMapping const*) ()
#9  0x000055555590c123 in DrawEngineVulkan::BeginFrame() ()
#10 0x00005555558751ab in GPU_Vulkan::BeginHostFrame() ()
#11 0x000055555564bea9 in EmuScreen::render() ()
#12 0x0000555555993e9d in ScreenManager::render() ()
#13 0x000055555562ae62 in NativeRender(GraphicsContext*) ()
#14 0x0000555555955cf3 in main ()

@hrydgard
Copy link
Owner Author

Thanks. Very likely a driver bug, we don't do anything strange there..

@mrcmunir
Copy link
Contributor

mrcmunir commented Dec 18, 2017

Compiled mesa3d from source returned more extra info is stoped by anv :-(

Thread 1 "PPSSPPSDL" received signal SIGSEGV, Segmentation fault.
anv_reloc_list_add (list=list@entry=0x555556d6da18, alloc=<optimized out>, 
    offset=36900, target_bo=0x0, delta=0) at vulkan/anv_batch_chain.c:159
159	   entry->target_handle = target_bo->gem_handle;

https://cgit.freedesktop.org/mesa/mesa/tree/src/intel/vulkan/anv_batch_chain.c?id=3be382cd7cb637f463a4618dc19d87d66a644b0e#n159

Edit : Fully stack with bt

(gdb) bt
#0  anv_reloc_list_add (list=list@entry=0x555556d62338, alloc=<optimized out>, 
    offset=16420, target_bo=0x0, delta=0) at vulkan/anv_batch_chain.c:159
#1  0x00007fffddaf9f6c in blorp_surface_reloc (batch=0x7fffffffc860, delta=0, 
    ss_offset=<optimized out>, address=...) at vulkan/genX_blorp_exec.c:60
#2  blorp_emit_surface_state (batch=batch@entry=0x7fffffffc860, 
    surface=surface@entry=0x7fffffffc5c8, state=state@entry=0x7fffdd647020, 
    state_offset=16416, is_render_target=true, 
    color_write_disables=0x7fffffffc73c) at ./blorp/blorp_genX_exec.h:1286
#3  0x00007fffddafcbd9 in blorp_emit_surface_states (
    batch=batch@entry=0x7fffffffc860, params=params@entry=0x7fffffffc170)
    at ./blorp/blorp_genX_exec.h:1368
#4  0x00007fffddb0dda3 in blorp_exec (params=0x7fffffffc170, 
    batch=0x7fffffffc860) at ./blorp/blorp_genX_exec.h:1619
#5  gen7_blorp_exec (batch=0x7fffffffc860, params=0x7fffffffc170)
    at vulkan/genX_blorp_exec.c:219
#6  0x00007fffdddf288a in blorp_ccs_resolve (batch=batch@entry=0x7fffffffc860, 
    surf=surf@entry=0x7fffffffc880, level=level@entry=0, 
    start_layer=start_layer@entry=0, num_layers=num_layers@entry=1, 
    format=ISL_FORMAT_R8G8B8A8_UNORM, 
    resolve_op=BLORP_FAST_CLEAR_OP_RESOLVE_FULL) at blorp/blorp_clear.c:780
#7  0x00007fffddad0d6a in anv_ccs_resolve (
    cmd_buffer=cmd_buffer@entry=0x555556d62280, 
    image=image@entry=0x555557c1b4e0, 
---Type <return> to continue, or q <return> to quit---
    aspect=aspect@entry=VK_IMAGE_ASPECT_COLOR_BIT, level=level@entry=0 '\000', 
    start_layer=start_layer@entry=0, layer_count=layer_count@entry=1, 
    op=BLORP_FAST_CLEAR_OP_RESOLVE_FULL) at vulkan/anv_blorp.c:1712
#8  0x00007fffddb128dd in transition_color_buffer (
    cmd_buffer=cmd_buffer@entry=0x555556d62280, 
    image=image@entry=0x555557c1b4e0, 
    aspect=aspect@entry=VK_IMAGE_ASPECT_COLOR_BIT, base_level=0, 
    level_count=1, base_layer=0, layer_count=1, 
    initial_layout=VK_IMAGE_LAYOUT_UNDEFINED, 
    final_layout=VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
    at vulkan/genX_cmd_buffer.c:763
#9  0x00007fffddb17a14 in transition_color_buffer (
    final_layout=<optimized out>, initial_layout=<optimized out>, 
    layer_count=<optimized out>, base_layer=<optimized out>, 
    level_count=<optimized out>, base_level=<optimized out>, 
    aspect=VK_IMAGE_ASPECT_COLOR_BIT, image=0x555557c1b4e0, 
    cmd_buffer=0x555556d62280) at vulkan/genX_cmd_buffer.c:1353
#10 gen7_CmdPipelineBarrier (commandBuffer=0x555556d62280, 
    srcStageMask=<optimized out>, destStageMask=<optimized out>, 
    byRegion=<optimized out>, memoryBarrierCount=<optimized out>, 
    pMemoryBarriers=<optimized out>, bufferMemoryBarrierCount=0, 
    pBufferMemoryBarriers=0x0, imageMemoryBarrierCount=1, 
    pImageMemoryBarriers=0x7fffffffcdd0) at vulkan/genX_cmd_buffer.c:1353
---Type <return> to continue, or q <return> to quit---
#11 0x00005555559f1391 in TransitionImageLayout2(VkCommandBuffer_T*, VkImage_T*, int, int, unsigned int, VkImageLayout, VkImageLayout, unsigned int, unsigned int, unsigned int, unsigned int) ()
#12 0x00005555559f686e in VulkanTexture::CreateDirect(VkCommandBuffer_T*, int, int, int, VkFormat, VkImageLayout, unsigned int, VkComponentMapping const*) ()
#13 0x00005555559c00f8 in DrawEngineVulkan::BeginFrame() ()
#14 0x00005555558ebb76 in GPU_Vulkan::BeginHostFrame() ()
#15 0x000055555563d677 in EmuScreen::render() ()
#16 0x0000555555a74b92 in ScreenManager::render() ()
#17 0x0000555555624d14 in NativeRender(GraphicsContext*) ()
#18 0x000055555561c952 in main ()
´´´

@hrydgard
Copy link
Owner Author

I went ahead and created a bug report upstream:

https://bugs.freedesktop.org/show_bug.cgi?id=104346

Please add any missing information that might be relevant, and I suggest you subscribe to that bug in case there are updates.

hrydgard added a commit that referenced this pull request Dec 20, 2017
…age before binding memory to it. Should help the issue uncovered in #10413
@hrydgard
Copy link
Owner Author

hrydgard commented Dec 20, 2017

@mrcmunir Alright, turns out this was likely my fault :) I'm gonna push a fix to this branch shortly, stay tuned (through rebasing it on master, where I pushed a fix, so you'll need to reset --hard after fetching this branch again). Thank you so much for the good stack traces.

@hrydgard
Copy link
Owner Author

hrydgard commented Dec 20, 2017

OK, rebase done. Please re-test @mrcmunir :)

@mrcmunir
Copy link
Contributor

@hrydgard Woah no crash anymore

Testing some game with 5x resolution with vulkan and no crash detected
captura de 2017-12-20 17-46-58
captura de 2017-12-20 17-45-48
captura de 2017-12-20 17-43-00
captura de 2017-12-20 17-37-04

In Tales of eternia detected some colours are wrong but fully playable Thanks you.

@davidbepo
Copy link

@mrcmunir thanks for the testing, can you share performance improvements number please

@mrcmunir
Copy link
Contributor

@davidbepo I'm only tested with Gen7 (HD4000 mobile) With Big resolution than 4-5x will be unstable fps than OpenGL backend in some games i detected some slowdown like 30fps to 20fps for some seconds or will be little helped with autoframeskip 1

In the next days will try it on a skylake HD 520 GPU.is another notebook that I have and compared too the perfomance.

@hrydgard
Copy link
Owner Author

hrydgard commented Dec 20, 2017

That's curious with the wrong colors, probably one of the 16-bit texture formats is backwards, so now I might have two external bug reports to file heh. Thanks for testing!

Filed:

https://bugs.freedesktop.org/show_bug.cgi?id=104355
KhronosGroup/Vulkan-LoaderAndValidationLayers#2289

@hrydgard
Copy link
Owner Author

Turns out that the wrong colors are a shortcoming of that generation of Intel GPUs. The drivers could work around it but they don't, yet. https://bugs.freedesktop.org/show_bug.cgi?id=104355

Might do a workaround in PPSSPP someday but it won't be a high priority.

@mrcmunir
Copy link
Contributor

mrcmunir commented Dec 20, 2017

@hrydgard oh I see I Suspected it would be something like that, also does not support stencil texture yet and that's why it is also limited to Opengl 4.2 core by default due limitations changes in SIMD work compared with later intel generations and they needed rewrite some parts for some functions in Gen7.

Anyway thanks to you at least fixed to the possibilities of the HW driver :)

Let's see if I can try it on the other laptop that has GPU skylake
I'm going to compile the latest mesa3d + ppsspp vulkan changes so it will take a few days in other laptop.

@hrydgard
Copy link
Owner Author

hrydgard commented Dec 21, 2017

Rebased again. Will merge once it's building everywhere, and leave the final polish (resize, etc) for later.

@mrcmunir
Copy link
Contributor

mrcmunir commented Dec 21, 2017

Well testing under GPU skylake running fine and the perfomance running about ~3-6fps avg faster than OpenGL in the same conditions limited by gpu i.e in the map final fantasy crisis core with 9x resolution with vulkan running 24-26fps when OpenGL running about 20fps.

Also the colours confirmed tale of eternia working in that hw without problem so is confirmed limitation for now in gen7 .

captura de pantalla_2017-12-21_13-14-53
captura de pantalla_2017-12-21_13-12-44
captura de pantalla_2017-12-21_12-50-02

no detected any new crash in these games are tested
also tested with latest rebase changes 9007abd no detected news errors :)

@hrydgard
Copy link
Owner Author

hrydgard commented Dec 21, 2017

That's good news, thanks again for testing.

Just for fun I tried to install mesa vulkan drivers on my laptop with nvidia, in order to have a choice to run on the on-board Intel. Unfortunately with both drivers installed it crashes somewhere in X11 when trying to create the surface, so I'm stuck with nVidia for now.

@hrydgard hrydgard merged commit 99f8c19 into master Dec 21, 2017
@hrydgard hrydgard deleted the x11-vulkan-init branch December 21, 2017 13:52
@neuromancer
Copy link

I just compiled and tested PPSSPP from the last git revision and it fails to start in NVIDIA (issue #10424). Maybe it is related with this pull request?

@davidbepo
Copy link

davidbepo commented Dec 22, 2017

just tested on linux, it works fine and there is a performance boost from 1600%/60fps to 2000%/80fps
on kingdom hearts bbs on hd 5500 👍

@valpackett
Copy link
Contributor

@davidbepo @unknownbrackets re: Wayland and BSD: #10449

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

Successfully merging this pull request may close these issues.

Missing Vulkan support on Linux
6 participants