Giter Club home page Giter Club logo

Comments (2)

redorav avatar redorav commented on May 11, 2024

Hi @zhaijialong, thanks for your question. Hlslpp is developed to use SIMD, and it tries very hard to stay in "SIMD-land" as much as possible. The consequences of these decisions are:

a) All vectors and matrices use hardware vectors. float1, float2, float3, and float4 are always 16 bytes. Making these float would undermine the goal of keeping everything SIMD
b) Different SIMD implementations can have different alignments. For instance, the 4x4 matrix could be 16 byte aligned if in SSE 2, or 32 bytes in AVX, etc.

I have my own toy engine and came across this problem. What I created is another set of hlsl-like structures that are only data types. This has several advantages:

a) There are no alignment issues
b) There are no functions to modify the data. If you're not careful you can accidentally read or mess with the sequentiality of writing to write-combine memory (typical for uploading data to GPU) and having no functions can help prevent that
c) You can easily access components (x, y, z, w) without SIMD-like penalties

You can create conversion functions such that it is seamless to go from hlsl++ to your custom structures. Use the store_* family of functions to safely convert.

Ultimately, this library is not for interfacing/sharing with hlsl, but rather to have math that you can portably copy-paste between GPU and CPU and have it work as seamlessly as possible.

from hlslpp.

zhaijialong avatar zhaijialong commented on May 11, 2024

ok, that makes sense, thank you for your detailed reply.

from hlslpp.

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.