Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIR-V assembler and disassembler #119

Merged
merged 50 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
63fd803
Disassembler init
PENGUINLIONG Dec 16, 2023
bd76319
Tokenizer
PENGUINLIONG Dec 16, 2023
347bcb4
More tests
PENGUINLIONG Dec 16, 2023
853fdf5
More tests
PENGUINLIONG Dec 16, 2023
92b5d63
IdRef parsing
PENGUINLIONG Dec 18, 2023
175500e
Create a file for tokenizer
PENGUINLIONG Dec 18, 2023
e321638
Specification based assembling
PENGUINLIONG Dec 18, 2023
40fe74a
Fixed infinite loop
PENGUINLIONG Dec 18, 2023
01d6d39
Reorganize
PENGUINLIONG Dec 18, 2023
f3e059d
Disassembler
PENGUINLIONG Dec 19, 2023
950a988
Suppress warnings
PENGUINLIONG Dec 19, 2023
1265b0f
Suppress warnings
PENGUINLIONG Dec 19, 2023
bd8824e
Test OpNop
PENGUINLIONG Dec 19, 2023
89dacdc
Fixed disassembler
PENGUINLIONG Dec 20, 2023
06ce335
Print ID with name
PENGUINLIONG Dec 20, 2023
563ba8f
Modular reflection process
PENGUINLIONG Dec 20, 2023
c0e4b37
Approaching perfect match with spirv-dis
PENGUINLIONG Dec 20, 2023
a208094
Align with spirv-dis output
PENGUINLIONG Dec 20, 2023
e883099
Simple roundtrip
PENGUINLIONG Dec 20, 2023
5cae0eb
Relax physical layout requirement
PENGUINLIONG Dec 20, 2023
0a61b5c
Gallery roundtrip
PENGUINLIONG Dec 20, 2023
ad7a8f5
Perfect gallery roundtrip
PENGUINLIONG Dec 20, 2023
1816071
More types
PENGUINLIONG Dec 20, 2023
ee6791e
Support 64-bit types
PENGUINLIONG Dec 21, 2023
39bb80f
Properly deal with hexadecimal floating point numbers
PENGUINLIONG Dec 21, 2023
d2a82ec
Remove file
PENGUINLIONG Dec 21, 2023
eb2fdae
spirq-as and spirq-dis
PENGUINLIONG Dec 21, 2023
daabb86
Indented output as in spirv-dis
PENGUINLIONG Dec 21, 2023
2202e78
Tweak
PENGUINLIONG Dec 21, 2023
c535aaf
Tweak
PENGUINLIONG Dec 21, 2023
13a7bd7
Format code
PENGUINLIONG Dec 21, 2023
34bb796
spirq-as/dis Roundtrip test
PENGUINLIONG Dec 21, 2023
17b87e3
Fix tests
PENGUINLIONG Dec 21, 2023
064bcc2
Default no indent
PENGUINLIONG Dec 21, 2023
b3aabbc
Fix tests
PENGUINLIONG Dec 21, 2023
0d38d9c
Update example logs
PENGUINLIONG Dec 24, 2023
035a0a9
Fixed test
PENGUINLIONG Dec 24, 2023
7ed56be
Binary diff
PENGUINLIONG Dec 25, 2023
45f12e3
Fix cache
PENGUINLIONG Dec 25, 2023
10cdeac
Faster script
PENGUINLIONG Dec 25, 2023
4ead5d0
step
PENGUINLIONG Dec 25, 2023
eec77f1
Don't build release (too slow)
PENGUINLIONG Dec 25, 2023
ed7e808
x
PENGUINLIONG Dec 25, 2023
8c96abe
x
PENGUINLIONG Dec 25, 2023
239d664
x
PENGUINLIONG Dec 25, 2023
9a1da05
x
PENGUINLIONG Dec 25, 2023
a97551e
Ensure the SPIR-V strings are properly padded
PENGUINLIONG Dec 25, 2023
ce2f554
Avoid unsafe code
PENGUINLIONG Dec 25, 2023
20ba132
Format
PENGUINLIONG Dec 25, 2023
213e4b0
Remove unused import
PENGUINLIONG Dec 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,49 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Cargo build and test
id: cargo_build_and_test
workspaces: |
shader-reflect
spirq-as
spirq-core
spirq-dis
spirq-spvasm

- name: Cargo Format
id: cargo_format
run: |
cargo fmt -- --check
cargo build --release --verbose

- name: Cargo Build
id: cargo_build
run: |
cargo build --verbose

- name: Cargo Test
id: cargo_test
run: |
cargo test --verbose

- name: Run SPIR-Q Examples
id: spirq_examples
run: |
cargo run --example gallery > spirq/examples/gallery/main.log
cargo run --example inspect > spirq/examples/inspect/main.log
cargo run --example walk > spirq/examples/walk/main.log
cargo install --path shader-reflect
shader-reflect assets/gallery.frag -o assets/gallery.frag.json --reference-all-resources
shader-reflect assets/gallery.frag.spv -o assets/gallery.frag.spv.json --reference-all-resources

- name: Run shader-reflect
id: shader_reflect
run: |
cargo run -p shader-reflect assets/gallery.frag -o assets/gallery.frag.json --reference-all-resources
cargo run -p shader-reflect assets/gallery.frag.spv -o assets/gallery.frag.spv.json --reference-all-resources
diff assets/gallery.frag.json assets/gallery.frag.spv.json
shader-reflect assets/spirv-spec.frag -o assets/spirv-spec.frag.json
shader-reflect assets/spirv-spec.frag.spv -o assets/spirv-spec.frag.spv.json
cargo run -p shader-reflect assets/spirv-spec.frag -o assets/spirv-spec.frag.json
cargo run -p shader-reflect assets/spirv-spec.frag.spv -o assets/spirv-spec.frag.spv.json
diff assets/spirv-spec.frag.json assets/spirv-spec.frag.spv.json
shader-reflect assets/moon.spv -o assets/moon.spv.json --reference-all-resources
git diff --exit-code
cargo run -p shader-reflect assets/moon.spv -o assets/moon.spv.json --reference-all-resources

- name: Assemble Disassemble Roundtrip
id: cargo_build_and_test
run: |
cargo run -p spirq-as assets/gallery.frag.spvasm -o assets/gallery.frag.spv
cargo run -p spirq-dis assets/gallery.frag.spv -o assets/gallery.frag.spvasm --no-indent
echo git diff --exit-code --binary
90 changes: 90 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
members = [
"spirq",
"spirq-core",
"spirq-spvasm",
"spirq-dis",
"spirq-as",
"shader-reflect",
]
26 changes: 25 additions & 1 deletion assets/gallery.frag
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#version 460 core
#extension GL_EXT_ray_tracing : enable
#extension GL_EXT_ray_query : enable
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require
#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require
#extension GL_EXT_shader_explicit_arithmetic_types_int32 : require
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : require
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
#extension GL_EXT_shader_explicit_arithmetic_types_float32 : require
#extension GL_EXT_shader_explicit_arithmetic_types_float64 : require

struct Data {
// Signed integer scalar and vector types.
Expand Down Expand Up @@ -181,7 +188,7 @@ layout(set=12, binding=0) uniform Ubo {

// Storage buffer block with dynamic size.
layout(set=13, binding=0) buffer Ssbo {
Data ds[];
int ds[];
} ssbo;

layout(set=14, binding=0, input_attachment_index=0) uniform isubpassInput iAttm;
Expand All @@ -194,6 +201,23 @@ layout(set=14, binding=5, input_attachment_index=5) uniform subpassInputMS fAtt
// Acceleration structure (for ray-tracing).
layout(set=15, binding=0) uniform accelerationStructureEXT acc;

const int8_t INT8 = int8_t(1);
const int16_t INT16 = int16_t(1);
const int32_t INT32 = int32_t(1);
const int64_t INT64 = int64_t(1);

const uint8_t UINT8 = uint8_t(1);
const uint16_t UINT16 = uint16_t(1);
const uint32_t UINT32 = uint32_t(1);
const uint64_t UINT64 = uint64_t(1);

// (penguinliong) Don't know why but SPIR-V Tools disassemble fp16 values to
// mantissa and exponent bias which is pretty much a special case I don't wanna
// work with atm.
const float16_t FLOAT16 = float16_t(0.25);
const float32_t FLOAT32 = float32_t(1.0);
const float64_t FLOAT64 = float64_t(1.0);

void main() {
rayQueryEXT ray_query;
rayQueryProceedEXT(ray_query);
Expand Down
Loading