Giter VIP home page Giter VIP logo

Comments (13)

expipiplus1 avatar expipiplus1 commented on August 21, 2024 1

I suppose the type could become something like

Either ("descriptorCount" ::: Word32) (Vector Sampler)

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024 1

I've gone with 0 because in these cases (where the length is non-optional) 0 is a disallowed value. Additionally it makes zero { stencils = [a, b, c] } still work :)

from vulkan.

dpwiz avatar dpwiz commented on August 21, 2024

Given the lack of next/flags and being a standalone type I think a pack of smart constructors would be preferred way to prevent such an issue.

Either that (heh), or moving to a sum type with more descriptive constructor names. That damned "descriptorCount" has to be referenced somewhere in Haskell code.

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

There's probably something which could be done with RecordDotSyntax, one could have a virtual descriptorCount member (would need some thinking regarding overlap though). (RDS is exciting in general for this library, may be it could be made ergonomic to switch over to storing structs as ByteArray and keeping them always in their C representation (whether this is actually a performance/usability benefit remains to be seen)).

What did you mean by smart constructors?

I don't think that it would be much of a problem to have a separate type data OptionalArray a = JustLength Word32 | Contents (Vector a) (Better name suggestions appreciated!).

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

In fact, there are probably plenty of places where documentation on the Haskell->C translation would be useful.

from vulkan.

dpwiz avatar dpwiz commented on August 21, 2024

What did you mean by smart constructors?

One function per descriptorType encoding its valid usage. Perhaps that's the proposal of a higher level library. 🤔

from vulkan.

dpwiz avatar dpwiz commented on August 21, 2024

It appears that making descriptorCount mutually exclusive with immutableSamplers makes combined image sampler unavailable:

If descriptorType is DESCRIPTOR_TYPE_SAMPLER or DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, and descriptorCount is not 0 and pImmutableSamplers is not NULL,

Maybe the less surprising way to encode is to add descriptorCount field and allow setting it explicitly. At least the docs are there to cover its usage.

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

What did you mean by smart constructors?

One function per descriptorType encoding its valid usage. Perhaps that's the proposal of a higher level library. thinking

Yeah, sounds like something for vulkan-utils or similar.

It appears that making descriptorCount mutually exclusive with immutableSamplers makes combined image sampler unavailable:

It's not exclusive though, if immutableSamplers is Right v then descriptorCount is set to length v.

Agree that the currently formulation is confusing. I want to avoid having to burden the programmer with having to set descriptorCount = length immutableSamplers, perhaps a custom sum type as mentioned above, along with documentation along the lines of the following would be best.

data DescriptorSetLayoutBinding = DescriptorSetLayoutBinding
  { blah blah
  , -- | <regular documentation for immutableSamplers, if any>
    --
    -- If 'immutableSamplers' is @'JustLength' l@ then @descriptorCount@ is set 
    -- to the specified length @l@ and @immutableSamplers@ is set to @NULL@. 
    -- If instead it is @'Contents' v@ then @descriptorCount@ is set to @length v@
    -- and the members of @v@ are passed as @immutableSamplers@
    immutableSamplers :: OptionalArray Sampler
  }

There are currently 16 places in the spec where a length can be set, but the array with that length can be NULL.

I think it's particularly confusing in this case as descriptorCount is the "primary" member and immutableSamplers is the "additional" info the programmer may wish to set. Most of the time it's the other way round, the contents are important, and the length is some uninteresting automatable value

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

Actually, looking through all the other Either Word32 (Vector _) values in the bindings I think the current behaviour is confusing in most cases.

Maybe the less surprising way to encode is to add descriptorCount field and allow setting it explicitly. At least the docs are there to cover its usage

I think this is the correct thing to do.

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

Lol, I can't believe how small that patch was 1ae3c30

from vulkan.

expipiplus1 avatar expipiplus1 commented on August 21, 2024

It would be nice to not have to specify lengths if the vector is specified, adb538a this seems like an accident waiting to happen.

Would it be so bad to: if the length is 0, infer it from the length of the vector? If it's non-zero and and doesn't match the non-zero length of the vector, then error.

from vulkan.

dpwiz avatar dpwiz commented on August 21, 2024

I'd go with maxBound value under a pattern instead. It is so outrageously wrong, everyone should complain loudly or explode if code somehow misses its length-detection turn.
But, again, maybe it's too early for such concerns and a simplest dumbest implementation would make a more solid foundation.

from vulkan.

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.