Skip to content

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

Open
ukari wants to merge 17 commits into
expipiplus1:mainfrom
ukari:vulkan-reflect
Open

WIP: Add SPIR-V reflect to vulkan-utils#270
ukari wants to merge 17 commits into
expipiplus1:mainfrom
ukari:vulkan-reflect

Conversation

@ukari

@ukari ukari commented Mar 19, 2021

Copy link
Copy Markdown
Contributor

relate #260

@expipiplus1

Copy link
Copy Markdown
Owner

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

@ukari

ukari commented Mar 19, 2021

Copy link
Copy Markdown
Contributor Author

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

Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
@dpwiz

dpwiz commented Mar 29, 2021

Copy link
Copy Markdown
Collaborator

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

@expipiplus1

Copy link
Copy Markdown
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 :)

Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated

@dpwiz dpwiz left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
@dpwiz dpwiz changed the title WIP add reflect for uitls WIP: Add SPIR-V reflect to vulkan-utils Apr 9, 2021
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
Comment thread utils/src/Vulkan/Utils/Reflect.hs Outdated
@dpwiz

dpwiz commented Apr 17, 2021

Copy link
Copy Markdown
Collaborator

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

@ukari

ukari commented Apr 18, 2021

Copy link
Copy Markdown
Contributor Author

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

dpwiz commented Apr 18, 2021

Copy link
Copy Markdown
Collaborator

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

@ukari

ukari commented Jan 9, 2022

Copy link
Copy Markdown
Contributor Author

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.

3 participants