Git Product home page Git Product logo

Comments (6)

zeux avatar zeux commented on August 16, 2024

Yeah I considered doing that but wasn't sure how important this is given that large portions are generated - that is, I wasn't sure if I should really be using preprocessor for something that's automatically generated. Definitely easier to set breakpoints without using X-macros but not sure how important that is either.

from volk.

zeux avatar zeux commented on August 16, 2024

Oh, right... One issue with this request is the conditional availability of many functions. generator.py currently has to insert checks like this:

#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
extern PFN_vkAcquireNextImage2KHR vkAcquireNextImage2KHR;
#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */

This might be possible to express inside an X-Macro with something like

#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
#define VOLK_XMACRO_GROUP_17(X) X(vkAcquireNextImage2KHR)
#else
#define VOLK_XMACRO_GROUP_17(X)
#endif

and then have the actual X-Macro refer to these but at this point this becomes more unwieldy than the current solution.

from volk.

rubycon avatar rubycon commented on August 16, 2024

I was thinking of this kind of X-Macro, where you can keep all your check in one place.

// volk_device.h
#if defined(VK_VERSION_1_0)
  DEFINE_VKDEVICE(AllocateCommandBuffers)
  DEFINE_VKDEVICE(AllocateDescriptorSets)
  DEFINE_VKDEVICE(AllocateMemory)
  DEFINE_VKDEVICE(BeginCommandBuffer)
  DEFINE_VKDEVICE(BindBufferMemory)
  /* ... */
#if (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
  DEFINE_VKDEVICE(GetDeviceGroupPresentCapabilitiesKHR)
  DEFINE_VKDEVICE(GetDeviceGroupSurfacePresentModesKHR)
#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_surface)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
#if (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1))
  DEFINE_VKDEVICE(AcquireNextImage2KHR)
#endif /* (defined(VK_KHR_device_group) && defined(VK_KHR_swapchain)) || (defined(VK_KHR_swapchain) && defined(VK_VERSION_1_1)) */
// volk.h
struct VolkDeviceTable
{
  /* VOLK_GENERATE_DEVICE_TABLE */
  #define DEFINE_VKDEVICE(name) PFN_vk##name vk##name,
  #include "volk_device.h"
  #undef DEFINE_VKDEVICE
  /* ... */
}

/* VOLK_GENERATE_PROTOTYPES_H */
#define DEFINE_VKDEVICE(name) extern PFN_vk##name vk##name;
#include "volk_device.h"
#undef DEFINE_VKDEVICE
/* ... */
// volk.c

static void volkGenLoadDevice(void* context, PFN_vkVoidFunction (*load)(void*, const char*))
{
  /* VOLK_GENERATE_LOAD_DEVICE */
  #define DEFINE_VKDEVICE(name) vk##name = (PFN_vk##name) load(context, "vk" #name);
  #include "volk_device.h"
  #undef DEFINE_VKDEVICE
}

from volk.

zeux avatar zeux commented on August 16, 2024

I see. That would work but it would require 3 extra headers. I'll experiment with this a bit but not sure yet this is a good idea.

from volk.

zeux avatar zeux commented on August 16, 2024

I've added a branch xmacro: https://github.com/zeux/volk/tree/xmacro that implements the suggested technique. Overall I like this a lot and am leaning towards merging this (if anybody has thoughts on this, please comment).

One thing I still haven't done is a thorough look at navigation/autocomplete behavior across different IDEs. I'd like to be able to maintain that. So far it seems that in VS2017 autocomplete still works fine; there's a regression with navigation usability where before you could F12 to vkCmdDraw and then F12 to PFN_vkCmdDraw to see the list of arguments, which now doesn't work since first F12 takes you to the volkgen_device.h - but I plan to fix this by adding function signatures to the generated files. Still need to see how the behavior changes in other IDEs/editors.

from volk.

zeux avatar zeux commented on August 16, 2024

I didn't really find a way to work around issues with Intellisense; additionally, trying to generate function signatures was met with significant issues wrt compatibility with multiple versions of Vulkan SDK - because of Vulkan 1.1 and various EXT->KHR promotions, it's non-trivial to generate a correct function signature with correct types that work for any version. So I decided to shelve this for now.

from volk.

Related Issues (20)

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.