Code Monkey home page Code Monkey logo

Comments (3)

xoofx avatar xoofx commented on July 27, 2024

I doubt you can create a VertexBufferBinding with a stride of 0. Doesn't make sense. Either you don't have any vertex buffer, so you should not set a binding and if you have one, you have necessarily a stride > 0

from sharpdx.

Gavin-Williams avatar Gavin-Williams commented on July 27, 2024

Sure, it's not valid. But it's possible to make the mistake as I did when I copied in some code from another project. And in that case, would it be better if an exception was thrown if stride <=0. I guess I'd like to see some better error detection there. Because with stride = 0, the program will run, not render the geometry, and prevent graphics diagnostics from catching data.

You guys know a lot more about the situation than I do, so if you think it's not a problem, no worries.

from sharpdx.

xoofx avatar xoofx commented on July 27, 2024

I see. Well, the original rule in SharpDX was to expose the native API almost as-is in order to get maximum performance and not to expose a sanitized native API. As you know, the native runtime - Direct3D11 for example - is already making lots of checks of parameters consistency and SharpDX rely almost exclusively on this. What is unfortunate in your case is that the native runtime is not checking this.

Should we provide such a check? Personally, I'm not really inclined for several reasons. We would have to go through all signatures, check if a parameter is already checked by the native runtime, if not we would have to add a check and throw an exception. In the case of the stride, the parameter to check is even an indirect parameter, as for the native API, the stride is stored in a int array.How much we would have to follow indirect references like this to check parameters? I would argue that the API to blame is Direct3D11 for not checking this one. Performance wise also, I wouldn't want the API to be bloated by checks that are most of the time irrelevant for regular usage.

Though there are some places in the code where we can perform this kind of checks, I agree that it is not always consistent, but again, I'm fine to make some sacrifice of safety over performance.

from sharpdx.

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.