Giter VIP home page Giter VIP logo

erupted's People

Contributors

colonelthirtytwo avatar kubo39 avatar particlepeter avatar rtbo avatar swoorup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

erupted's Issues

Allocating Vulkan handles fails with DMD -profile=gc

This simple line is enough to reproduce the bug when building a project with DMD on Windows with -profile=gc :
VkPhysicalDevice[] devices = new VkPhysicalDevice[1];

Produces the following:
core.exception.OutOfMemoryError@src/core/exception.d(700): Memory allocation failed

This seems to be a bug in DMD itself, but it can be worked around by changing the 40th line in erupted/types.d from:
enum VK_DEFINE_HANDLE( string name ) = "struct " ~ name ~ "_handle; alias " ~ name ~ " = " ~ name ~ "_handle*;";
to:
enum VK_DEFINE_HANDLE( string name ) = "struct " ~ name ~ "_handle {}; alias " ~ name ~ " = " ~ name ~ "_handle*;";
... by declaring the structure with empty brackets, but I'm not sure if this causes any side effects. Building and running a simple Vulkan program which displays a triangle did run succesfully with this change.

Could not find a valid dependency tree configuration: [BLANK]

When I attempted to compile an app with v.1.3.4, I immediately get a "Could not find a valid dependency tree configuration:" error message without anything after the semicolon. Removing everything else non-critical (i.e. the "name" field) as well as the dub.selections.json, .dub, and cache files. The error persists.

Windows support

Not sure if you can help. But I am trying to get VulkanTriangle which is based on ErupteD to run in Windows. I can run just fine in linux but in windows, it is failing to find the surface extension functions. I have set the version VK_USE_PLATFORM_WIN32_KHR. But that seem to do nothing :(

Any ideas? The repo is available at here: https://github.com/Swoorup/VulkanTriangleD

-*- mode: compilation; default-directory: "~/git/VulkanTriangleD/" -*-
Compilation started at Mon Dec 26 15:04:17

time dub 
Performing "debug" build using dmd for x86.
vulkantriangled ~master: building configuration "windows"...
source\app.d(124,9): Error: cannot implicitly convert expression (& MyDebugReportCallback) of type extern (Windows) uint function(uint flags, VkDebugReportObjectTypeEXT objectType, ulong object, uint location, int messageCode, const(char*) pLayerPrefix, const(char*) pMessage, void* pUserData) nothrow @nogc to extern (Windows) uint function(uint flags, VkDebugReportObjectTypeEXT objectType, ulong object, uint location, int messageCode, const(char)* pLayerPrefix, const(char)* pMessage, void* pUserData) nothrow @nogc
source\app.d(130,21): Error: undefined identifier 'VkWin32SurfaceCreateInfoKHR'
source\app.d(137,15): Error: undefined identifier 'vkCreateWin32SurfaceKHR'
source\app.d(301,40): Error: cannot implicitly convert expression (null) of type typeof(null) to ulong
source\app.d(573,34): Error: cannot implicitly convert expression (vertFile.size()) of type ulong to uint
source\app.d(576,34): Error: cannot implicitly convert expression (fragFile.size()) of type ulong to uint
source\app.d(744,45): Error: cannot implicitly convert expression (null) of type typeof(null) to ulong
source\app.d(747,40): Error: function pointer vkCreateGraphicsPipelines (VkDevice_handle* device, ulong pipelineCache, uint createInfoCount, const(VkGraphicsPipelineCreateInfo)* pCreateInfos, const(VkAllocationCallbacks)* pAllocator, ulong* pPipelines) is not callable using argument types (VkDevice_handle*, typeof(null), int, VkGraphicsPipelineCreateInfo*, typeof(null), ulong*)
source\app.d(764,30): Error: function pointer vkAcquireNextImageKHR (VkDevice_handle* device, ulong swapchain, ulong timeout, ulong semaphore, ulong fence, uint* pImageIndex) is not callable using argument types (VkDevice_handle*, ulong, ulong, ulong, typeof(null), uint*)
source\app.d(863,22): Error: function pointer vkQueueSubmit (VkQueue_handle* queue, uint submitCount, const(VkSubmitInfo)* pSubmits, ulong fence) is not callable using argument types (VkQueue_handle*, int, VkSubmitInfo*, typeof(null))
dmd failed with exit code 1.
Command exited with non-zero status 2
0.00user 0.00system 0:01.03elapsed 0%CPU (0avgtext+0avgdata 221952maxresident)k
0inputs+0outputs (914major+0minor)pagefaults 0swaps

Compilation exited abnormally with code 2 at Mon Dec 26 15:04:18

All uses of `const type*` should be replaced with `const(type)*`

I think you already know this (judging from erupt.py code I saw), in C const type* means pointer to constant type, in D it means constant pointer to constant type. The parentheses are needed to match the C semantics.

There's at least one function which is defined as:

alias PFN_vkDebugReportCallbackEXT = VkBool32 function(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData);

Notice the const char*.

In fact I think it's the only one left to fix? :)

Examples do not build

They use DerelictErupted, which does not exist.

$ git clone https://github.com/ParticlePeter/ErupteD.git
Cloning into 'ErupteD'...
remote: Enumerating objects: 754, done.
remote: Total 754 (delta 0), reused 0 (delta 0), pack-reused 754 eceiving objects:  94% (709/754), 644.01 KiB | 1.17 M
Receiving objects: 100% (754/754), 784.57 KiB | 1.36 MiB/s, done.
Resolving deltas: 100% (363/363), done.
$ dub run erupted:layers
Building package erupted:layers in C:\Users\peter\AppData\Local\dub\packages\erupted-2.0.11_v1.1.85\erupted\
Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86.
erupted:layers 2.0.11+v1.1.85: building configuration "application"...
..\..\AppData\Local\dub\packages\erupted-2.0.11_v1.1.85\erupted\examples\layers.d(17,2): Error: undefined identifier DerelictErupted
C:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.

_module not module_?

Isn't the standard for name clashes to add an _ to the end? The _ at the beginning is confusing because of some languages (e.g. Python) standard to use that for private variables.

(Like in VkPipelineShaderStageCreateInfo.)

Maybe not a big deal, and maybe that is D's standard. I just thought it was weird and had to look it up when module_ did not work.

Can't compile any code

Hello. I can't compile code with this package.
For first I fetched this package, add dependencies to my dub.json and it was successful. Then I tried to build or run that, but I got the error:
Main package must not have target type "sourceLibrary".
Okay, so then I copied sources to import folder (on the compile folder). And now I see autocompletion, but I can't compile my code. I tried ldc2 and DMD compilers.
Other dub packages work fine, My code:

import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.exception;
import std.conv;
import std.string;
import erupted;
import erupted.vulkan_lib_loader;


void main() {

	// load global level functions	// not part of erupted package, as not part of original vulkan
	loadGlobalLevelFunctions;
	VkInstanceCreateInfo info = {};
	VkInstance instance;
	if (vkCreateInstance(&info,null, &instance) == VK_SUCCESS) {
		writeln("Test");
	}
}

Via ldc2 I get the error:

lld-link: error: undefined symbol: lld-link: error: undefined symbol: _D7erupted17vulkan_lib_loader24loadGlobalLevelFunctionsFNbNiPOS4core4stdc5stdio6_iobufZb
>>> referenced by app.obj:(_Dmain)

lld-link: error: undefined symbol: _D7erupted9functions16vkCreateInstancePWNbNiPxSQBt5types20VkInstanceCreateInfoPxSQDbQBi21VkAllocationCallbacksPPSQEhQCo17VkInstance_handleZEQFiQDp8VkResult
>>> referenced by app.obj:(_Dmain)
Error: linking with LLD failed

Via DMD I get the error:

import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

I also tried to run examples from this package but I just get same errors in several times more.

Friendly Array Usage

This may be too complicated / over-verbose for your simple bindings, but using C's norm of array length being separate from the pointer is inconvenient, and allows for some unnecessarily, unsafe code (by D standards).

A helpful (compile-time only) addition would be to union a special Vulkan Array (with uint length) within the structs.

struct VkArray(T) {
    uint length;
    T* ptr;
}
VkArray!T vkArray(T)(T[] vs) {
    return VkArray!T(
        cast(uint) vs.length,
        vs.ptr,
    );
}

Then, as an example:

struct VkInstanceCreateInfo {
    VkStructureType              sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
    const( void )*               pNext;
    VkInstanceCreateFlags        flags;
    const( VkApplicationInfo )*  pApplicationInfo;
    union {
        struct {
            uint32_t                     enabledLayerCount;
            const( char* )*              ppEnabledLayerNames;
        }
        VkArray!(char*) enabledLayers;
    }
    union {
        struct {
            uint32_t                     enabledExtensionCount;
            const( char* )*              ppEnabledExtensionNames;
        }
        VkArray!(char*) enabledExtensions;
    }
}

This would allow for usage like this:

VkInstanceCreateInfo createInfo = {
    pApplicationInfo: &appInfo,
    enabledExtensions: vkArray(extensions),
    enabledLayerCount: 0,
    pNext: null,
};

DispatchDevice is private to the erupted.functions module.

Hi there, thanks for creating this library, I've found it really helpful in my University work. Unfortunately there's an issue with one of your proposed device-level function loading mechanisms.

If I want to create a "Renderer" class/struct which works a given logical device, directly calls device-level functions but doesn't override the global functon poiners, I have to use "createDispatchDeviceLevelFunctions()". It returns a struct of function pointers which is fine, the issue is if I want to keep that struct as a member of a class/struct I need to either selectively import it or use a workaround to account for the fact that DispatchDevice has actually been marked private to the module!

Some example code:

import erupted.functions;
import std.traits;

struct BrokenSingleDeviceRenderer
{
    DispatchDevice deviceFuncs; // Fails to compile, DispatchDevice is marked as private.
}

struct WorkingSingleDeviceRenderer
{
    auto deviceFuncs = ReturnType!(createDispatchDeviceLevelFunctions)(); // Compiles.

    // The deviceFuncs member is an instance of DispatchDevice.
    pragma (msg, typeof (deviceFuncs)); 
}

struct AnotherWorkingSingleDeviceRenderer
{
    import erupted.functions : DispatchDevice;
    DispatchDevice deviceFuncs; // Compiles thanks to selective importing.
}

Would it be possible to remove the private access modifier as I'm not sure what benefit there is to having it marked as private? Is there a use-case I'm missing that requires the private modifier?

Thanks.

Property helpers for array

There's a lot of "array" elements in the structs that could use helper functions to set from d arrays.

uint32_t xCount; // Usually have this form where "x" is some common name between the two
void* pXs;

// helps to convert to and from
void[] xs() { return pXs[0 .. xCount]; }
void xs( void[] value ) { pXs = value.ptr; xCount = value.length32; }

Could not find a valid dependency tree configuration with version 1.3.x

This is in my current dub.sdl

dependency "erupted" version="~>1.3.0"

Could not find a valid dependency tree configuration

There is no problem if I change the line to

dependency "erupted" version="~>1.1.0"

I sometimes get

Package xlib-d contains invalid dependency xcb-d (ci=7) So I assume it might be the problem of xlib-d.

Compiler error when attempting to use platform extensions

Using the example code provided in examples/platform/vulkan_windows.d, the compiler is unable to link the mixin.

The Platform_Extensions mixin incorrectly declares both versions of loadDeviceLevelFunctions to be extern(System). The names do not get mangled, and so collide in the linker.

I attempted to find a fix, but could not identify where the file is generated in erupt.py.

The simplest solution apparent to me would be to move extern(System) into the static foreach where the extensions are enumerated.

A typo

There is a typo on line 38 of types.d "derectated". I have tried to do a PR twice but github is making the commit as if I rewrote the entire file.

xcb

Regarding your post

    {
        "name"          :   "dub-platform-xcb",
        "versions"      :   [ "VK_USE_PLATFORM_XCB_KHR" ],
        "dependencies"  :   {
            "xcb-d"     : "~>2.1.0+1.11.1"
    },

In your project dub.json add:

"subConfigurations" : {
"erupted" : "dub-platform-xcb",
},

I am not sure if that works. Is it possible to combine configurations in dub? For example I would need with-derelict-loader and dub-platform-xcb.

Temporarily I just hacked it to this

{
            "name"          :   "dub-platform-xcb",
            "versions"      :   [ "VK_USE_PLATFORM_XCB_KHR", "ERUPTED_FROM_DERELICT" ],
            "dependencies"  :   {
                "xcb-d"     : "~>2.1.0",
                "derelict-util" : "~>2.0.4"
            },
},

Importing erupted.vulkan_lib_loader and import erupted.platform_extensions with mixin causes error.

Hello.
Is there a recommended way to do this, because on the outer scope level I import a package that's

module window;
public import core.sys.windows.windows;
import erupted.platform_extensions;
mixin Platform_Extensions!USE_PLATFORM_WIN32_KHR;

and

erupted.vulkan_lib_loader
spits out this error about functions using same name
source\app.d(127,28): Error: function window.Platform_Extensions!(KHR_win32_surface, KHR_external_memory_win32, KHR_win32_keyed_mutex, KHR_external_semaphore_win32, KHR_external_fence_win32, NV_external_memory_win32, NV_win32_keyed_mutex, EXT_full_screen_exclusive).loadInstanceLevelFunctions at C:\Users\Vasilia\AppData\Local\dub\packages\erupted-2.0.70_v1.2.150\erupted\source\erupted\platform_extensions.d(1084,10) conflicts with function erupted.functions.loadInstanceLevelFunctions at C:\Users\Vasilia\AppData\Local\dub\packages\erupted-2.0.70_v1.2.150\erupted\source\erupted\functions.d(1001,6)
source\app.d(184,26): Error: function window.Platform_Extensions!(KHR_win32_surface, KHR_external_memory_win32, KHR_win32_keyed_mutex, KHR_external_semaphore_win32, KHR_external_fence_win32, NV_external_memory_win32, NV_win32_keyed_mutex, EXT_full_screen_exclusive).loadDeviceLevelFunctions at C:\Users\Vasilia\AppData\Local\dub\packages\erupted-2.0.70_v1.2.150\erupted\source\erupted\platform_extensions.d(1253,10) conflicts with function erupted.functions.loadDeviceLevelFunctions at C:\Users\Vasilia\AppData\Local\dub\packages\erupted-2.0.70_v1.2.150\erupted\source\erupted\functions.d(1464,6) `

My solution was to have them have different import names aka "import foo = file.module;" and even still that throws the error.
saun-vk-examples.obj : fatal error LNK1179: invalid or corrupt file: duplicate COMDAT 'loadDeviceLevelFunctions' Error: linker exited with status 1179 dmd failed with exit code 1.

What's behind this? am I supposed to import these in different places and not on the outer scope?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.