Skip to content

Commit

Permalink
initial spirv experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
arhik committed Nov 11, 2022
1 parent 9e4441e commit fc98403
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions exp/computeShader.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using SPIRV
using Test

function test(gIndex, y, x)
sin(x[gIndex.x])
end

interp = SPIRVInterpreter([INTRINSICS_GLSL_METHOD_TABLE])

target = @target interp test(::Vec{3, UInt32}, ::Vec{4, Float32}, ::Vec{4, Float32})

ir = compile(target, AllSupported())

interface = ShaderInterface(
SPIRV.ExecutionModelGLCompute,
# [SPIRV.StorageClassFunction, SPIRV.StorageClassInput],
[SPIRV.StorageClassInput, SPIRV.StorageClassOutput, SPIRV.StorageClassInput,],
SPIRV.dictionary([
# 1 => Decorations(SPIRV.DecorationBuiltIn, SPIRV.BuiltInWorkgroupSize),
1 => Decorations(SPIRV.DecorationBuiltIn, SPIRV.BuiltInGlobalInvocationId),
2 => Decorations(SPIRV.DecorationLocation, 0 |> UInt32),
3 => Decorations(SPIRV.DecorationLocation, 1 |> UInt32)
])
)

shader = Shader(target, interface)

@test unwrap(validate(shader))

validate(shader)

0 comments on commit fc98403

Please sign in to comment.