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

Fix/pointer object #2

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

djfos
Copy link

@djfos djfos commented Mar 14, 2023

This PR makes two major changes:

The first change is the fix of Deno.PointerValue. Deno.PointerValue becomes PointerObject | null since Deno v1.31.1. Basically, we still store pointers as UBigInt64 in struct buffers, but convert them into Deno.PointerValues when passing to ffi.

The second change is to split big vk.ts into multiple files. This is aggressive. The main reason is that every time I open vk.ts my vscode become very lag and the code completion is freeze. Besides, if I write something like import * as vk from "mod.ts", the same thing will happen. Even worse, the debugger won't hit any breakpoint if I use the namespace import. Something I can not understand. But if I import symbols from individual files, everything works smoothly, even the debugger.

@DjDeveloperr
Copy link
Member

DjDeveloperr commented Mar 14, 2023

Thanks for the contribution! Looks really good to me.

VS code lag is real, though previously completions worked fine for me if I did not open vk.ts but just imported namespace.

So now, after splitting into multiple files, do completions not work with namespace import anymore? Did they work before for you? Given the API surface of Vulkan, writing individual imports would be massive pain.

@djfos
Copy link
Author

djfos commented Mar 15, 2023

After splitting into multiple files, completion still works. Using namespace import now still will cause some lag but far more better than before. Using namespace import won't cause problems in running modules (except making first run wait longer), but will stop debugger to hit breakpoints. After playing around, I found that it is not caused by using namespace import, but by loading too many modules!!! If I remove a lot of unused struct re-exports, the debugger works fine with namespace import.

I don't know if this is a problem happens only on my laptop. Maybe we could maintain a commonly used re-exports for structs. Users could do the same way if they encounter the same problem.

Edit:
BTW, using chrome to debug with the complete re-exports works fine. So the limitaion might from vscode or Deno vscode exteinson.

@DjDeveloperr
Copy link
Member

It must be a performance problem in Deno LSP, probably worth reporting, though I'm not sure because in most cases it's unlikely one needs that much modules.

About the common struct exports, that sounds good to me. Let's keep structs/mod.ts and add structs/common.ts and re-export structs/common.ts from main mod.ts.

djfos added 4 commits March 17, 2023 18:06
Problem found in the miss-alignment of `stage` in
`VkComputePipelineCreateInfo`. Struct which has a field
aligned with 8 should also be aligned with 8 as a field
in other struct. Its alignment should be the largest alignment
of its field's alignments, so that its fields could have
correct alignments.
@djfos
Copy link
Author

djfos commented Mar 20, 2023

I put all the structs without vendor suffix and structs about debugs and swapchain in the common.ts. They are all the structs required by the two examples for now. I improved the compute example by adding a simple compute shader and a debug layer. The triangle example is also working now.

But the compute example has a wired bug that sometimes might crash without any error messages. I doute it is caused by the incorrect struct size in a struct array which accessing the address out of the buffer. VkPhysicalDeviceProperties has a VkPhysicalDeviceLimits member limits which have some float array, but this situation is not covered in typeToFFI. So the size of PhysicalDeviceProperties is smaller than the actual size.

I think this PR has done what it says, and other fix should makes new PRs.

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.

2 participants