A ready to use Vulkan triangle example for D

maik klein via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sat May 28 12:32:58 PDT 2016


On Saturday, 28 May 2016 at 17:50:30 UTC, Alex Parrill wrote:
> On Saturday, 28 May 2016 at 10:58:05 UTC, maik klein wrote:
>>
>> derelict-vulcan only works on windows, dvulkan doesn't have 
>> the platform dependend surface extensions for xlib, xcb, w32 
>> and wayland. Without them Vulkan is unusable for me.
>>
>> I really don't care what I use, I just wanted something that 
>> works.
>
> Platform extension support will be in the next release of 
> d-vulkan. It doesn't include platform extensions now because I 
> wanted to find a way to implement it without tying d-vulkan to 
> a specific set of bindings, though I can't seem to find a good 
> solution unfortunately... I personally use the git version of 
> GLFW, which handles the platform-dependent surface handling for 
> me.
>
> As for the demo itself... It might help explain things more if 
> the separate stages (instance creation, device creation, 
> setting up shaders, etc) were split into their own functions, 
> instead of stuffing everything into `main`.
>
> Struct initializers are also useful when dealing with Vulkan 
> info structs, since you don't have to repeat the variable name 
> each time. Ex this:
>
> VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo 
> = {};
> vertexInputStateCreateInfo.sType = 
> VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
> vertexInputStateCreateInfo.vertexBindingDescriptionCount = 1;
> vertexInputStateCreateInfo.pVertexBindingDescriptions = 
> &vertexBindingDescription;
> vertexInputStateCreateInfo.vertexAttributeDescriptionCount = 1;
> vertexInputStateCreateInfo.pVertexAttributeDescriptions = 
> &vertexAttributeDescritpion;
>
> Can become:
>
> VkPipelineVertexInputStateCreateInfo vertexInputStateCreateInfo 
> = {
>     sType = 
> VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, // 
> also sType is pre-set with erupted or d-derelict
>     vertexBindingDescriptionCount = 1,
>     pVertexBindingDescriptions = &vertexBindingDescription,
>     vertexAttributeDescriptionCount = 1,
>     pVertexAttributeDescriptions = &vertexAttributeDescritpion,
> };

I think its personal preference, I like tutorials more if 
everything I just in the main instead of creating their own 
"architecture". Though I could probably group  with comments.

I saw that sType was a default value after a few hours and that 
is when I started using it. But at the end I was so annoyed by 
typing all the enums by hand that I mostly copied stuff from 
other people and translated it to D.

This was mostly caused by my current vim D setup with vim-dutyl 
and dcd, it is really unreliable and I didn't get any sane 
autocompletion. (I have to investigate that at some point).

Btw does this even work? I think the struct initializers have to 
be

Foo foo = { someVar: 1 };

`:` instead of a `=`

I didn't do this because I actually got autocompletion for  
`vertexInputStateCreateInfo.` and that meant less typing for me.


More information about the Digitalmars-d-announce mailing list