Closed mxy-nj closed 2 years ago
Hi,
1. Can you check if the file exists?
The working directory is changed to the 'assets' folder with this line.
There is also a helper file that can check if the file exists.
Maybe you can print the full path were the file is read.
2. Could you try running example that uses a shader in text fileformat like for instance (to check if it is not an issue of reading binary files):
$ ./wgpu_sample_launcher compute_particles_webgpu_logo
This example will load WGSL shader (shader in text fileformat ) instead of SPIR-V (shader in binary format).
3. Does any file reading work ? An example on how to read files is given in this code. Maybe this code works?
4. Do you have read permissions on the file ? On my machine the file permissions are as follows:
ls -al
totaal 36
drwxrwxr-x. 2 sdauwe sdauwe 4096 1 jan 14:09 .
drwxrwxr-x. 48 sdauwe sdauwe 4096 1 jan 14:09 ..
-rw-rw-r--. 1 sdauwe sdauwe 2404 21 jun 2021 boids.comp
-rw-rw-r--. 1 sdauwe sdauwe 5444 21 jun 2021 boids.comp.spv
-rw-rw-r--. 1 sdauwe sdauwe 97 21 jun 2021 shader.frag
-rw-rw-r--. 1 sdauwe sdauwe 336 21 jun 2021 shader.frag.spv
-rw-rw-r--. 1 sdauwe sdauwe 395 21 jun 2021 shader.vert
-rw-rw-r--. 1 sdauwe sdauwe 1684 21 jun 2021 shader.vert.spv
For instance, you can give public permissions to the file for testing.
Hope it helps debugging the issue.
Best regards, Sam
@samdauwe, Many appreciation for your reply.
uint32_t const compute_boids_frag_spirv[] = { 0x07230203,0x00010000,0x000d000a,0x0000000c, ...
@mxy-nj, thanks for quickly providing the test results, now I better understand the root cause of the issue and it indeed seems to be related to running the example(s) on web side. I never done this before.
For emsdk, you probably need to package your files as explained on this documentation page
A practical example can be found in this repo:
About 4. yes maybe it works by getting the files from a web url but I never tried this myself.
Best regards, Sam
@samdauwe, thanks for your help. The emcc linkder flags , as you mentioned, " --preload-file=...", works well for file reading. Following your guide to read the documenation page, it made great benefit. Thanks very much!
@mxy-nj, happy to hear that the emcc linker flag makes it possible to read the files!
Are you able run the examples in a web browser ? It is still on my roadmap to build for Web with Emscripten / WebAssembly.
Best regards, Sam
@samdauwe Yes, web browser works well.
在定义shader文件后, 使用 FILE API来读取shader文件失败,求大神指教 1. vertex shader 定义
2. shader 文件读取, 问题是, 读到的文件size 是0, 但是file handle也不为NULL