Open FoxMaccloud opened 1 year ago
vulkan works for me so i guess you didn't force the game to use vulkan ("-force-vulkan", in the launch parameters) and it falls back to directx11
I played around with it some more and found that when attempting to uninject, the allocated console doesn't disappear, but hangs around. ReinitializeGraphicalHooks appears to be working fine (before unloading).
I'm not sure what's wrong. I tried using the -force-vulkan launch parameter, reinstalling the game and setting imgui window to the middle of the screen in case it rendered off-screen. When using DX11 everything appears to work perfectly.
It looks like you don't have issues on your end, so I guess the issue lies with me.
are vulkan hooks being called? (simply place a breakpoint)
The Vulkan hooks appears to be called just fine.
I don't see the window size being set anywhere. This is the 3rd time this func is called. The comment implies that 4K will be overwritten at some point?
Everything appears to be in order expect the menu not showing up...
what version of valheim are you playing and also what gpu do you have.
what you have posted is normal behaviour. but i still have no idea why the menu is not showing up
I'm running version 2022-12-15 0.212.9 of the game and my GPU is an AMD Radeon Vega 64
I'm running version 2022-12-15 0.212.9 of the game and my GPU is an AMD Radeon Vega 64
put this code right here and then paste the output between "start detailed log" and "end detailed log"
LOG("start detailed log:\n");
LOG("g_Device: %p\n", g_Device);
LOG("called hkQueuePresentKHR() with queue: %p\n", queue);
if (g_Device) {
uint32_t count;
vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, NULL);
VkQueueFamilyProperties* queues = new VkQueueFamilyProperties[sizeof(VkQueueFamilyProperties) * count];
vkGetPhysicalDeviceQueueFamilyProperties(g_PhysicalDevice, &count, queues);
for (uint32_t i = 0; i < count; ++i) {
for (uint32_t j = 0; j < queues[i].queueCount; ++j) {
VkQueue pQueue = VK_NULL_HANDLE;
vkGetDeviceQueue(g_Device, i, j, &pQueue);
LOG("\tqueue[%u][%u]: %p\n", i, j, pQueue);
}
}
delete[] queues;
}
LOG("end detailed log.\n");
better post the whole log after injecting for the first time. (the console should be spammed with that log thing ive written)
[+] Rendering backend: VULKAN
[+] Got window with name: 'Valheim'
[+] Vulkan: g_Instance: 0x000002839B37E7D0
[+] Vulkan: g_PhysicalDevice: 0x0000028372CE5A50
[+] Vulkan: g_QueueFamily: 0
[+] Vulkan: g_FakeDevice: 0x00000283B1089E30
[+] Vulkan: fnAcquireNextImageKHR: 0x00007FF9C160CB70
[+] Vulkan: fnAcquireNextImage2KHR: 0x00007FF9C160CBD0
[+] Vulkan: fnQueuePresentKHR: 0x00007FFA90B3AE60
[+] Vulkan: fnCreateSwapchainKHR: 0x00007FFA90B3A350
start detailed log:
g_Device: 00000282D81A94F0
called hkQueuePresentKHR() with queue: 00000282D81B15C0
queue[0][0]: 00000282D81B15C0
queue[1][0]: 0000000000000000
queue[1][1]: 0000000000000000
queue[2][0]: 0000000000000000
queue[2][1]: 0000000000000000
end detailed log.
Calling Menu Render
start detailed log:
g_Device: 00000282D81A94F0
called hkQueuePresentKHR() with queue: 00000282D81B15C0
queue[0][0]: 00000282D81B15C0
queue[1][0]: 0000000000000000
queue[1][1]: 0000000000000000
queue[2][0]: 0000000000000000
queue[2][1]: 0000000000000000
end detailed log.
Calling Menu Render
start detailed log:
g_Device: 00000282D81A94F0
called hkQueuePresentKHR() with queue: 00000282D81B15C0
queue[0][0]: 00000282D81B15C0
queue[1][0]: 0000000000000000
queue[1][1]: 0000000000000000
queue[2][0]: 0000000000000000
queue[2][1]: 0000000000000000
i have no clue why it;s not working i guess you will have to stick to directx11 (disable all overlays maybe like discord or msi afterburner if you have any)
Might be important to the issue. On exit the dll seems to freeze the game after a few seconds. Trying to step through to figure out why, I don't reach anything after vkDestroyInstance(g_Instance, g_Allocator); in CleanupDeviceVulkan.
if you can u could try to test this on someones else pc to see if its just you. menu shows up on my screen and i have changed only the renderingbackend to vulkan thats it
Well this is how it looks for me. I'll see if I can find another PC to test on.
i think the game hung because you have selected text in the console. do you have the overlay like geforce experience but for amd? (i forgot how its called)
you could even try to disable steams overlay which is here
i think the game hung because you have selected text in the console.
No this happens always.
As for overlays. AMD has "AMD Adrenaline". I disabled both steam and adrenaline overlays but still all the same.
are you running the latest drivers and the latest win10 because i don t have a clue whats going on
Latest everything.
do you own any titles like portal 2 or half life 2 ? if you own them use -vulkan in the launch paramters and inject to see if they work (compile in x86) also if you can paste whatever the console outputs if you type "vulkaninfo" in cmd
Exactly the same behavoir, also still freezes on exit with same problem.
is overwolf overlay loaded? are these 2 files loaded automatically in your games? "ow-vulkan-overlay64.dll" or "ow-vulkan-vulkan64.dll"
ERROR: [Loader Message] Code 0 : loader_get_json: Failed to open JSON file E:\Programfiler (x86)\Overwolf\0.187.1.13\ow-vulkan-overlay64.json
ERROR: [Loader Message] Code 0 : loader_get_json: Failed to open JSON file E:\Programfiler (x86)\Overwolf\0.187.1.13\ow-graphics-vulkan64.json
The overwolf overlay is not loaded. The E:\ driver is not even in my computer 😅
still have no idea other than to use another machine
The issue is caused by this QueueSubmit I'm not entirely sure but my guess is it's related to fences.
Would it make sens to assume the issue could be related to Amd card/drivers? i just noticed many users of a mod i'm working on that uses this framework are having the same issue. Side note, If anyone here with vulkan knowledge would be willing to have a look, would really appreciate it: https://www.nexusmods.com/doometernal/mods/1255 https://github.com/SteamKaibz/DE_AdvancedOptionsModPublic
Just gonna copy and past my answer from the other thread.
I have found two issues with the Vulkan hook: First there is an issue with the semaphores of vkQueueSubmit. This leads to the application hanging.
VkSubmitInfo info = { };
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
info.pWaitDstStageMask = stages_wait.data( );
info.waitSemaphoreCount = waitSemaphoresCount;
info.pWaitSemaphores = pPresentInfo->pWaitSemaphores;
info.signalSemaphoreCount = 1;
info.pSignalSemaphores = &fsd->ImageAcquiredSemaphore;
The queue waits for the wait semaphores of vkQueuePresentKHR pPresentInfo->pWaitSemaphores
but doesn't signal them again, so the original call of vkQueuePresentKHR just gets stuck on waiting for its original wait semaphores.
I have fixed this by just setting the signal semaphores of vkQueueSubmit to the wait semaphores. This way it first waits then executes its bit and then signals them so vkQueuePresentKHR can do its part when the hook command buffer was executed.
VkSubmitInfo info = { };
info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
info.commandBufferCount = 1;
info.pCommandBuffers = &fd->CommandBuffer;
info.pWaitDstStageMask = stages_wait.data( );
info.waitSemaphoreCount = waitSemaphoresCount;
info.pWaitSemaphores = pPresentInfo->pWaitSemaphores;
info.signalSemaphoreCount = waitSemaphoresCount;
info.pSignalSemaphores = pPresentInfo->pWaitSemaphores;
I think there is really no need for the ImageAcquiredSemaphore and RenderCompleteSemaphore in the hook. They are only necessary for a stand alone ImGui application.
The second issue is that the dimensions of the frame buffer are not set at all. Strangely for me it still worked on NVIDIA cards but not on AMD cards. So the issue seems more like NVIDIA drivers/Vulkan runtimes are a bit more forgiving, dunno...
I have fixed this by calling GetClientRect
if g_ImageExtent
is still 0 and then setting the correct width and height in the VkFramebufferCreateInfo
.
static void RenderImGui_Vulkan(VkQueue queue, const VkPresentInfoKHR* pPresentInfo) {
if (!g_Device || H::bShuttingDown)
return;
if (g_ImageExtent.width == 0 || g_ImageExtent.height == 0) {
// We don't know the window size the first time so we just query the window handle.
RECT rect{};
GetClientRect(g_Hwnd, &rect);
g_ImageExtent.width = rect.right - rect.left;
g_ImageExtent.height = rect.bottom - rect.top;
}
VkQueue graphicQueue = VK_NULL_HANDLE;
const bool queueSupportsGraphic = DoesQueueSupportGraphic(queue, &graphicQueue);
Menu::InitializeContext(g_Hwnd);
for (uint32_t i = 0; i < pPresentInfo->swapchainCount; ++i) {
...
and
VkFramebufferCreateInfo info = { };
info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
info.renderPass = g_RenderPass;
info.attachmentCount = 1;
info.pAttachments = attachment;
info.width = g_ImageExtent.width;
info.height = g_ImageExtent.height;
info.layers = 1;
I have addressed this and other issues in my repository where I wrote everything from scratch and without ImGu if you are looking for an alternative implementation:
https://github.com/belazr/EasyWinHax
Hope this helps!
Awesome to see an imgui hook example for Vulkan. This is the only example I could find! 😄
When injecting for Valheim, it appears to inject fine. However the imgui menu is not showing.
Steps to reproduce
Download Vulkan SDK. Un-comment
#define ENABLE_BACKEND_VULKAN
in backend.hpp. Open project in Visual Studio 2022. Re-includeimgui_impl_vulkan
files. Compile project. Start Valheim using Vulkan. Inject dll.