Comments (6)
Hi, @swfly
Thanks for reporting this. I tried to fix the alignment issue with vector3 arrays in the DX backend in 38abe63, which should now pass the test code you provided.
For other alignment issues with structures,
Actually I think it's not only a problem of using array in this structure. In my actual code I have a camera struct to pass to kernels and it apparently has alignment problem even without arrays.
Would you please provide the struct that causes the problem? Thanks!
from luisacompute.
Hi @Mike-Leo-Smith, great work yes it solves the problem!
For another case I just tested and still buggy... In the following code I just use the a similar struct with an extra bool variable instead, and it breaks the alignment immediately. When I saw the generated hlsl with ":8" I can feel the risk there (maybe I was wrong tho)!
#include <luisa-compute.h>
#include <dsl/sugar.h>
using namespace luisa;
using namespace luisa::compute;
struct foo
{
bool bar = false;
luisa::float3 test1 = { 0,0,0 };
};
LUISA_STRUCT(foo, bar, test1) {};
int main(int args, char* argv[])
{
std::vector<std::array<uint8_t, 4u>> download_image(1280 * 720);
{
Context context{ argv[0] };
auto device = context.create_device("dx");
auto stream = device.create_stream();
auto device_image = device.create_image<float>(PixelStorage::BYTE4, 1280, 720, 0u);
Kernel2D fill_image_kernel = [&](Var<foo> bar) noexcept
{
Var coord = dispatch_id().xy();
device_image.write(coord, make_float4(bar.test1, 1.f));
};
auto fill_image = device.compile(fill_image_kernel);
foo b;
b.test1 = { 0,1,0 };
stream
<< fill_image(b).dispatch(1280, 720)
<< device_image.copy_to(download_image.data())
<< synchronize();// Step 5: Synchronize the stream
}
Window window{ "Display", uint2{ 1280,720 } };
window.set_key_callback([&](int key, int action) noexcept
{
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
{
window.set_should_close();
}
});
auto frame_count = 0u;
window.run([&]
{
window.set_background(download_image.data(), uint2{ 1280,720 });
});
}
I think by looking at your mentioned commit I should be able to fix this myself since the problems look similar. But you are a lot more familiar with luisa, so if you happen to have time to fix, it'll be the best.
from luisacompute.
so if you happen to have time to fix, it'll be the best.
OK! I'll look into this.
from luisacompute.
Hi, @swfly
I think I've fixed the struct padding bug with bool
members in 35b8ef6. Would you please verify if it now works with your structures?
from luisacompute.
Thanks @Mike-Leo-Smith
Now my camera struct finally works and I don't need to use any workaround anymore. Let's close this issue.
from luisacompute.
Great!
from luisacompute.
Related Issues (20)
- Open Shading Language to LuisaCompute AST translator HOT 1
- CPU backend shared memory emulation via LLVM coroutine
- Build (linking) error on macOS Ventura 13.5.2 Apple M2 HOT 10
- Support offset and size in texture copy commands
- test_denoiser crash with DX backend HOT 2
- Vulkan / HIP backend(s) HOT 5
- Minimal cross platform example for blit to screen HOT 2
- Not building with msc HOT 9
- Export `luisa-config.h` for other build systems than CMake
- Better error handling when RTX support is not supported
- Simple lambda causes LESBAR HOT 2
- default variable initialization codegen wrong in loop scope HOT 1
- Motion Blur Support HOT 1
- ImageView.copy_from() crashes with specific resolution HOT 1
- Should TLAS accept primitives only? HOT 1
- Incorrect Buffer copy_from and copy_to on CPU/DX and possibly Metal backends
- 当采用cmake作为构建工具,且依赖的 “Windows 10 SDK” 为 “10.0.19041.0” 时,关于DirectML的部分会编译失败 HOT 2
- 当采用xmake构建,启用cpu后端来运行时,会出现 'swapchain context is not initialized' 错误 HOT 2
- python confusing behavior due to implicit casting HOT 2
- Pass values between RT shaders with OptiX's built-in registers rather than local memory
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 luisacompute.