Comments (5)
I looked into it and verified that sessionDesc.defaultMatrixLayout is indeed ineffective and fixed that.
Also fixed the typedef issue.
I think the buffer pointer thing is a different issue.
from slang.
Correction!
This is actually a buffer pointer bug!
When reading a float3x4 matrix from a buffer pointer by directly dereferencing it, the majorness is respected!
But when reading from the pointer array style it reads it as row major!
Example and repro:
struct Push
{
float3x4* ptr;
};
[[vk::push_constant]] Push push;
[shader("compute")]
[numthreads(1, 1, 1)]
void main(uint3 dtid : SV_DispatchThreadID)
{
// This matrix is in memry column major. Slang respects this here and load it properly!
float3x4 correctly_read_matrix = *push.ptr;
printf("(%f,%f,%f,%f)\n(%f,%f,%f,%f)\n",
correctly_read_matrix[0][0], correctly_read_matrix[0][1], correctly_read_matrix[0][2], correctly_read_matrix[0][3],
correctly_read_matrix[1][0], correctly_read_matrix[1][1], correctly_read_matrix[1][2], correctly_read_matrix[1][3]
);
printf("(%f,%f,%f,%f)\n\n",
correctly_read_matrix[2][0], correctly_read_matrix[2][1], correctly_read_matrix[2][2], correctly_read_matrix[2][3]
);
// With this syntax however, Slang ignores the column major setting and loads it as it it was row major!
float3x4 broken_matrix = push.ptr[0];
printf("(%f,%f,%f,%f)\n(%f,%f,%f,%f)\n",
broken_matrix[0][0], broken_matrix[0][1], broken_matrix[0][2], broken_matrix[0][3],
broken_matrix[1][0], broken_matrix[1][1], broken_matrix[1][2], broken_matrix[1][3]
);
printf("(%f,%f,%f,%f)\n\n",
broken_matrix[2][0], broken_matrix[2][1], broken_matrix[2][2], broken_matrix[2][3]
);
}
I wrote the following matrix to a buffer:
buffer_host_ptr = f32mat3x4{
// rc = row column
{11, 21, 31}, // col 1
{12, 22, 32}, // col 2
{13, 23, 33}, // col 3
{14, 24, 34}, // col 4
};
I get the following output from the minimal repro:
// correct matrix:
(11.000000,12.000000,13.000000,14.000000)
(21.000000,22.000000,23.000000,24.000000)
(31.000000,32.000000,33.000000,34.000000)
// broken matrix:
(11.000000,21.000000,31.000000,12.000000)
(22.000000,32.000000,13.000000,23.000000)
(33.000000,14.000000,24.000000,34.000000)
from slang.
Btw, thank you for all the quick fixes. This is very appreciated. I had much worse experience with other shading languages fixing issues.
from slang.
OK, the PR should fix this issue.
from slang.
And thank you for your patience with the compiler so far. The buffer pointer thing and the API around setting compiler options are relatively new and there are still bugs, but we are committed to address any issues quickly.
from slang.
Related Issues (20)
- Add alignment information to the ByteAddressBuffer Inst HOT 1
- Enabling debug symbol can cause compilation failure.
- VKCTS nightly runs start failing on run #38
- -emit-spirv-via-glsl is missing in slang API compilation HOT 2
- Fix autodiff test failures after enabling debug symbol.
- Fix `packSnorm2x16` and re-enable `tests/glsl-intrinsic/intrinsic-basic.slang` on direct spirv backend. HOT 1
- No debuginfo generated for buffer references HOT 4
- Warnings emitted during link time are not filtered by diagnostic settings HOT 2
- UserAttribute is missing in the reflection information for scalar variable declaration. HOT 1
- Prefer vector operations over unary operations for various GLSL/SPIRV/HLSL functions HOT 4
- Add unit testing to updated slang capabilities system
- `spReflection_getEntryPointCount` returns 0, am I using the api wrong? HOT 2
- Use SMin/UMin for SPIR-V target HOT 12
- Improve robustness of slang-test against random driver failures HOT 1
- Overload resolution prefers `int64->int` over `int64->uint64`.
- Incorrect WaveMatch result with SPIR/V
- Nested associated types with multiple possible implementations will crash the compiler. HOT 1
- Comparing unsigned and signed value yields an unexpected result
- `struct` construction using braces fails if differentiable member associations are missing.
- Crash when "uint(-1)" is used for "operator%()" or "operator/()" HOT 2
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 slang.