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

WIP: Add SPIR-V reflect to vulkan-utils #270

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

Conversation

ukari
Copy link
Contributor

@ukari ukari commented Mar 19, 2021

relate #260

@expipiplus1
Copy link
Owner

I haven't kept up with the other issue, I'll take a look at it this weekend!

@ukari
Copy link
Contributor Author

ukari commented Mar 19, 2021

@expipiplus1 it's still work in progress and not ready for merge

@dpwiz
Copy link
Collaborator

dpwiz commented Mar 29, 2021

@expipiplus1 do you use code formatters by any means? You could commit its config for the rest of us to follow.

@expipiplus1
Copy link
Owner

@expipiplus1 do you use code formatters by any means? You could commit its config for the rest of us to follow.

I use Brittany with the default settings, good idea. I guess I could add an empty .brittany.json or whatever it uses :)

Copy link
Collaborator

@dpwiz dpwiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there... 😅

Other than a few minor things to polish the only big one remaining is usage of Applicative instance of pure functions. I, too, use them for quick experiments, but usually I forget what I've meant the very next day.

utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
@dpwiz dpwiz changed the title WIP add reflect for uitls WIP: Add SPIR-V reflect to vulkan-utils Apr 9, 2021
utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
utils/src/Vulkan/Utils/Reflect.hs Outdated Show resolved Hide resolved
@dpwiz
Copy link
Collaborator

dpwiz commented Apr 17, 2021

With all the code set in place it is the time to add more shiny reflected things? 😄

@ukari
Copy link
Contributor Author

ukari commented Apr 18, 2021

nice.

  1. Should we add some tests? Currently the repo use doctest. But the shader example seems too long to be put into haddock document.

  2. Here is a function makeDescriptorPoolCreateInfo :: Word32 -> V.Vector (DescriptorSetLayoutCreateInfo '[]) -> DescriptorPoolCreateInfo '[] which not based on the reflection directly. I used it to help create a simple descriptor pool locally, while I am not sure is this suitable to be add to Reflect.hs. And it can't fit some other descriptor pool strategies.

makeDescriptorPoolCreateInfo :: Word32 -> V.Vector (DescriptorSetLayoutCreateInfo '[]) -> DescriptorPoolCreateInfo '[]
makeDescriptorPoolCreateInfo maxSets infos = zero
  { poolSizes = V.fromList
    [ zero
      { type' = t
      , descriptorCount = fromIntegral n
      }
    | (t, n) <- analyse infos ]
  , maxSets = maxSets
  , flags = DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT -- VUID-vkFreeDescriptorSets-descriptorPool-00312: descriptorPool must have been created with the VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT flag
  }
  where
    analyse :: V.Vector (DescriptorSetLayoutCreateInfo '[]) -> [(DescriptorType, Int)]
    analyse = map calculate . groupBy ((==) `on` fst) . sortOn fst . extract
    extract :: V.Vector (DescriptorSetLayoutCreateInfo '[]) -> [(DescriptorType, Int)]
    extract = map (liftA2 (,) tname (fromIntegral . dcount)) . V.toList . (bindings =<<)
    calculate :: [(DescriptorType, Int)] -> (DescriptorType, Int)
    calculate = liftA2 (,) (fst . head) (sum . (snd <$>))
    tname = descriptorType :: DescriptorSetLayoutBinding -> DescriptorType
    dcount = descriptorCount :: DescriptorSetLayoutBinding -> Word32
  1. now the reflect stuff in Reflect.hs exhausted all my knowledge about vulkan. I will add some new stuff after I realize some new knowledge about vulkan

@dpwiz
Copy link
Collaborator

dpwiz commented Apr 18, 2021

If makeDescriptorPoolCreateInfo is not used in Reflect itself, it can be extracted to example app.

@ukari
Copy link
Contributor Author

ukari commented Jan 9, 2022

support more descriptor types.(I thought these has been all)

here comes the SeparateImage from separate_images in reflect result, like this

layout(set = 0, binding = 1) uniform textureBuffer texBuf;
...
  "separate_images" : [
    {
      "type" : "samplerBuffer",
      "name" : "texBuf",
      "set" : 0,
      "binding" : 1
    }
...

now the separate_images is just parsed and not generating any DescriptorSetLayoutBindings, due to the lack of the knowledge about how to make textureBuffer/itextureBuffer/utextureBuffer works in vulkan.

ssbos is not correctly support now.

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.

None yet

3 participants