FacticiusVir / SharpVk

C# Bindings for the Vulkan API & SPIR-V
MIT License
147 stars 18 forks source link

SigSegV on linux #27

Closed sunkin351 closed 7 years ago

sunkin351 commented 7 years ago

Pls help, I actually cant trace the problem with the tools I have available. I keep getting a segmentation fault on Device.CreateRenderPass(). I can send you a code sample of how I am using it if needed. It worked earlier, idk why its doing this.

FacticiusVir commented 7 years ago

Sure, I'm happy to take a look - have you run the code with validation layers?

FacticiusVir commented 7 years ago

Oh, and is this running against the GLFW branch?

sunkin351 commented 7 years ago

Its running against the latest glfw library with modified C# binding. I am currently running it with validation layers too. Does nothing to solve this unfortunately.

Sry for taking so long to respond btw.

sunkin351 commented 7 years ago

I also had to add a constructor to your surface class to accomidate. But that shouldn't be relevant here.

FacticiusVir commented 7 years ago

Have you run the test harness from this branch? https://github.com/FacticiusVir/SharpVk/tree/Glfw If you have a link to your code, I'll take a look.

sunkin351 commented 7 years ago

This is basically it:

void CreateRenderPass()
{
    AttachmentDescription[] attachments = new AttachmentDescription[2];
    attachments [0].Format = format;
    attachments [0].Samples = SampleCountFlags.SampleCount1;
    attachments [0].LoadOp = AttachmentLoadOp.Clear;
    attachments [0].StoreOp = AttachmentStoreOp.Store;
    attachments [0].StencilLoadOp = AttachmentLoadOp.DontCare;
    attachments [0].StencilStoreOp = AttachmentStoreOp.DontCare;
    attachments [0].InitialLayout = ImageLayout.ColorAttachmentOptimal;
    attachments [0].FinalLayout = ImageLayout.PresentSource;
    attachments [0].Flags = 0;

    attachments [1].Format = dbuffer.format;
    attachments [1].Samples = SampleCountFlags.SampleCount1;
    attachments [1].LoadOp = AttachmentLoadOp.Clear;
    attachments [1].StoreOp = AttachmentStoreOp.DontCare;
    attachments [1].StencilLoadOp = AttachmentLoadOp.DontCare;
    attachments [1].StencilStoreOp = AttachmentStoreOp.DontCare;
    attachments [1].InitialLayout = ImageLayout.DepthStencilAttachmentOptimal;
    attachments [1].FinalLayout = ImageLayout.DepthStencilAttachmentOptimal;
    attachments [1].Flags = 0;

    AttachmentReference color_ref;
    color_ref.Attachment = 0;
    color_ref.Layout = ImageLayout.ColorAttachmentOptimal;

    AttachmentReference depth_ref;
    depth_ref.Attachment = 1;
        depth_ref.Layout = ImageLayout.DepthStencilAttachmentOptimal;

    SubpassDescription subpass = new SubpassDescription ();
    subpass.PipelineBindPoint = PipelineBindPoint.Graphics;
    subpass.Flags = 0;
    subpass.InputAttachments = null;

    subpass.ColorAttachments = new AttachmentReference[1];
    subpass.ColorAttachments [0] = color_ref;

    subpass.DepthStencilAttachment = depth_ref;
    subpass.ResolveAttachments = null;
    subpass.PreserveAttachments = null;

    RenderPassCreateInfo info = new RenderPassCreateInfo ();
    info.Attachments = attachments;
    info.Subpasses = new SubpassDescription[1];
    info.Subpasses[0] = subpass;

        rpass = device.CreateRenderPass (info);
}

Its a direct translation from the C++ Vulkan tutorial samples.

sunkin351 commented 7 years ago

Is there something wrong with the way I am using C# arrays or something? Or is it on your end?

FacticiusVir commented 7 years ago

I don't see anything immediately wrong with the snippet above, though it's hard to debug without a full runnable sample. You can send me your code to facticiusvir@gmail.com and I'll give it a run-through, and I've got some commits for Android & GLFW to push tonight which might help.

sunkin351 commented 7 years ago

Done, the code I sent is incomplete in that you will have to write out the main function yourself. Otherwise, that's all I have.