Skip to content

Commit

Permalink
[Vulkan] fixed ComputeShader problem
Browse files Browse the repository at this point in the history
  • Loading branch information
krauthaufen committed Dec 2, 2021
1 parent c8ac8fc commit 9c2df2c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 5.1.21
- fixed ComputeShader problem in Vulkan

### 5.1.20
- deterministic Id for instanced-effects

Expand Down
35 changes: 20 additions & 15 deletions src/Aardvark.Rendering.Vulkan/Resources/ShaderModule.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,26 @@ module ShaderModule =
}

let ofGLSL (stage : ShaderStage) (info : FShade.GLSL.GLSLShader) (device : Device) =
match info.iface.shaders with
| FShade.GLSL.GLSLProgramShaders.Graphics { stages = shaders } ->
let siface = shaders.[ShaderStage.toFShade stage]
match GLSLang.GLSLang.tryCompile (glslangStage stage) siface.shaderEntry [string stage] info.code with
| Some binary, _ ->
let binary = GLSLang.GLSLang.optimizeDefault binary
let iface = Map.ofList [stage, siface]
let handle = device |> createRaw binary
let result = new ShaderModule(device, handle, stage, iface, binary)
result
| None, err ->
Log.error "[Vulkan] %A shader compilation failed: %A" stage err
failf "%A shader compilation failed: %A" stage err
| _ ->
failf "not a graphics shader: %A" info
let siface =
match info.iface.shaders with
| FShade.GLSL.GLSLProgramShaders.Graphics { stages = shaders } ->
shaders.[ShaderStage.toFShade stage]
| FShade.GLSL.GLSLProgramShaders.Compute c when stage = ShaderStage.Compute ->
c
| _ ->
failf "unsupported ShaderStage: %A" stage

match GLSLang.GLSLang.tryCompile (glslangStage stage) siface.shaderEntry [string stage] info.code with
| Some binary, _ ->
let binary = GLSLang.GLSLang.optimizeDefault binary
let iface = Map.ofList [stage, siface]
let handle = device |> createRaw binary
let result = new ShaderModule(device, handle, stage, iface, binary)
result
| None, err ->
Log.error "[Vulkan] %A shader compilation failed: %A" stage err
failf "%A shader compilation failed: %A" stage err



let ofBinaryWithInfo (stage : ShaderStage) (info : FShade.GLSL.GLSLShaderInterface) (binary : byte[]) (device : Device) =
Expand Down

0 comments on commit 9c2df2c

Please sign in to comment.