Comments (2)
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.
ok, that makes sense, thank you for your detailed reply.
from hlslpp.
Related Issues (20)
- Memory packing difference C++ <-> HLSL HOT 16
- Integer vector division is working incorrectly on Macs with Apple M1 (ARM) HOT 7
- Integer vector comparison is working incorrectly on Intel based Macs with MacOS >= 11 HOT 3
- Improve HLSL++ unit tests by using full-featured testing framework HOT 2
- Matrix accessor operator HOT 6
- operator / (float1, float3) looks inverted HOT 8
- How well does this cover HLSL202x? HOT 11
- * operator brake mult function in quaternion HOT 7
- Quaternion slerp returning nan values HOT 2
- Clang error: unused variable 't4' in hlsl++_quaternion.h HOT 6
- Upgrade warnings to errors HOT 2
- round() on ARM Neon uses wrong rounding mode HOT 2
- mul() intrinsic is missing some overloads. HOT 2
- clamp() intrinsic is missing overloads for intN HOT 1
- Some non square matrix definitions are incorrect HOT 6
- Missing matrix constructors HOT 2
- Some vector double functions missing HOT 5
- Undefined behavior when accessing vector elements with operator[] HOT 10
- internal::round_float gives incorrect results HOT 4
- Build failure on G++13.2 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hlslpp.