Created
November 29, 2019 13:31
-
-
Save HansKristian-Work/df272ad97dc879514fdd494798b5296d to your computer and use it in GitHub Desktop.
DXIL-to-SPIRV sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // HLSL | |
| Texture2D<float4> Tex : register(t2, space1); | |
| SamplerState Samp : register(s1, space3); | |
| cbuffer Buf : register(b1) | |
| { | |
| float4 constant_data; | |
| int iterations; | |
| float4 values[16]; | |
| }; | |
| float4 main(float2 UV : TEXCOORD, float4 color : COLOR) : SV_Target | |
| { | |
| float4 result = 0.0.xxxx; | |
| for (int i = 0; i < iterations; i++) | |
| { | |
| result += Tex.Sample(Samp, UV + constant_data.xy * float(i)) * values[i]; | |
| } | |
| return result; | |
| } | |
| // SPIR-V | |
| ; SPIR-V | |
| ; Version: 1.3 | |
| ; Generator: Unknown(30017); 21022 | |
| ; Bound: 107 | |
| ; Schema: 0 | |
| OpCapability Shader | |
| OpMemoryModel Logical GLSL450 | |
| OpEntryPoint Fragment %3 "main" %21 %23 %25 | |
| OpExecutionMode %3 OriginUpperLeft | |
| OpName %3 "main" | |
| OpName %8 "Tex" | |
| OpName %13 "Buf" | |
| OpName %15 "Buf" | |
| OpName %18 "Samp" | |
| OpName %21 "TEXCOORD" | |
| OpName %23 "COLOR" | |
| OpName %25 "SV_Target" | |
| OpDecorate %8 DescriptorSet 1 | |
| OpDecorate %8 Binding 2 | |
| OpDecorate %12 ArrayStride 16 | |
| OpMemberDecorate %13 0 Offset 0 | |
| OpDecorate %13 Block | |
| OpDecorate %15 DescriptorSet 0 | |
| OpDecorate %15 Binding 1 | |
| OpDecorate %18 DescriptorSet 3 | |
| OpDecorate %18 Binding 1 | |
| OpDecorate %21 Location 0 | |
| OpDecorate %23 Location 1 | |
| OpDecorate %25 Location 0 | |
| %1 = OpTypeVoid | |
| %2 = OpTypeFunction %1 | |
| %5 = OpTypeFloat 32 | |
| %6 = OpTypeImage %5 2D 0 0 0 1 Unknown | |
| %7 = OpTypePointer UniformConstant %6 | |
| %8 = OpVariable %7 UniformConstant | |
| %9 = OpTypeInt 32 0 | |
| %10 = OpConstant %9 18 | |
| %11 = OpTypeVector %5 4 | |
| %12 = OpTypeArray %11 %10 | |
| %13 = OpTypeStruct %12 | |
| %14 = OpTypePointer Uniform %13 | |
| %15 = OpVariable %14 Uniform | |
| %16 = OpTypeSampler | |
| %17 = OpTypePointer UniformConstant %16 | |
| %18 = OpVariable %17 UniformConstant | |
| %19 = OpTypeVector %5 2 | |
| %20 = OpTypePointer Input %19 | |
| %21 = OpVariable %20 Input | |
| %22 = OpTypePointer Input %11 | |
| %23 = OpVariable %22 Input | |
| %24 = OpTypePointer Output %11 | |
| %25 = OpVariable %24 Output | |
| %29 = OpTypePointer Input %5 | |
| %30 = OpConstant %9 0 | |
| %33 = OpConstant %9 1 | |
| %36 = OpTypePointer Uniform %11 | |
| %39 = OpTypeVector %9 4 | |
| %42 = OpTypeBool | |
| %44 = OpConstant %5 0 | |
| %53 = OpTypePointer Output %5 | |
| %56 = OpConstant %9 2 | |
| %58 = OpConstant %9 3 | |
| %74 = OpTypeImage %5 2D 0 0 0 2 Unknown | |
| %76 = OpTypeSampledImage %74 | |
| %77 = OpTypeInt 32 1 | |
| %78 = OpConstant %77 0 | |
| %3 = OpFunction %1 None %2 | |
| %4 = OpLabel | |
| OpBranch %101 | |
| %101 = OpLabel | |
| %26 = OpLoad %6 %8 | |
| %27 = OpLoad %16 %18 | |
| %28 = OpInBoundsAccessChain %29 %21 %30 | |
| %31 = OpLoad %5 %28 | |
| %32 = OpInBoundsAccessChain %29 %21 %33 | |
| %34 = OpLoad %5 %32 | |
| %35 = OpInBoundsAccessChain %36 %15 %30 %33 | |
| %37 = OpLoad %11 %35 | |
| %38 = OpBitcast %39 %37 | |
| %40 = OpCompositeExtract %9 %38 0 | |
| %41 = OpSGreaterThan %42 %40 %30 | |
| OpSelectionMerge %105 None | |
| OpBranchConditional %41 %102 %105 | |
| %102 = OpLabel | |
| OpBranch %103 | |
| %103 = OpLabel | |
| %59 = OpPhi %5 %44 %102 %45 %103 | |
| %60 = OpPhi %5 %44 %102 %47 %103 | |
| %61 = OpPhi %5 %44 %102 %49 %103 | |
| %62 = OpPhi %5 %44 %102 %51 %103 | |
| %63 = OpPhi %9 %30 %102 %64 %103 | |
| %65 = OpInBoundsAccessChain %36 %15 %30 %30 | |
| %66 = OpLoad %11 %65 | |
| %67 = OpCompositeExtract %5 %66 0 | |
| %68 = OpCompositeExtract %5 %66 1 | |
| %69 = OpConvertSToF %5 %63 | |
| %70 = OpFMul %5 %67 %69 | |
| %71 = OpFMul %5 %68 %69 | |
| %72 = OpFAdd %5 %70 %31 | |
| %73 = OpFAdd %5 %71 %34 | |
| %75 = OpSampledImage %76 %26 %27 | |
| %80 = OpCompositeConstruct %19 %72 %73 | |
| %79 = OpImageSampleImplicitLod %11 %75 %80 None | |
| %81 = OpCompositeExtract %5 %79 0 | |
| %82 = OpCompositeExtract %5 %79 1 | |
| %83 = OpCompositeExtract %5 %79 2 | |
| %84 = OpCompositeExtract %5 %79 3 | |
| %85 = OpIAdd %9 %63 %56 | |
| %86 = OpInBoundsAccessChain %36 %15 %30 %85 | |
| %87 = OpLoad %11 %86 | |
| %88 = OpCompositeExtract %5 %87 0 | |
| %89 = OpCompositeExtract %5 %87 1 | |
| %90 = OpCompositeExtract %5 %87 2 | |
| %91 = OpCompositeExtract %5 %87 3 | |
| %92 = OpFMul %5 %88 %81 | |
| %93 = OpFMul %5 %89 %82 | |
| %94 = OpFMul %5 %90 %83 | |
| %95 = OpFMul %5 %91 %84 | |
| %45 = OpFAdd %5 %92 %59 | |
| %47 = OpFAdd %5 %93 %60 | |
| %49 = OpFAdd %5 %94 %61 | |
| %51 = OpFAdd %5 %95 %62 | |
| %64 = OpIAdd %9 %63 %33 | |
| %96 = OpInBoundsAccessChain %36 %15 %30 %33 | |
| %97 = OpLoad %11 %96 | |
| %98 = OpBitcast %39 %97 | |
| %99 = OpCompositeExtract %9 %98 0 | |
| %100 = OpSLessThan %42 %64 %99 | |
| OpLoopMerge %104 %103 None | |
| OpBranchConditional %100 %103 %104 | |
| %104 = OpLabel | |
| OpBranch %105 | |
| %105 = OpLabel | |
| %43 = OpPhi %5 %44 %101 %45 %104 | |
| %46 = OpPhi %5 %44 %101 %47 %104 | |
| %48 = OpPhi %5 %44 %101 %49 %104 | |
| %50 = OpPhi %5 %44 %101 %51 %104 | |
| %52 = OpInBoundsAccessChain %53 %25 %30 | |
| OpStore %52 %43 | |
| %54 = OpInBoundsAccessChain %53 %25 %33 | |
| OpStore %54 %46 | |
| %55 = OpInBoundsAccessChain %53 %25 %56 | |
| OpStore %55 %48 | |
| %57 = OpInBoundsAccessChain %53 %25 %58 | |
| OpStore %57 %50 | |
| OpReturn | |
| OpFunctionEnd | |
| // GLSL | |
| #version 460 | |
| layout(set = 0, binding = 1, std140) uniform Buf | |
| { | |
| vec4 _m0[18]; | |
| } Buf_1; | |
| layout(set = 1, binding = 2) uniform texture2D Tex; | |
| layout(set = 3, binding = 1) uniform sampler Samp; | |
| layout(location = 0) in vec2 TEXCOORD; | |
| layout(location = 1) in vec4 COLOR; | |
| layout(location = 0) out vec4 SV_Target; | |
| void main() | |
| { | |
| float _43; | |
| float _46; | |
| float _48; | |
| float _50; | |
| if (int(floatBitsToUint(Buf_1._m0[1u]).x) > int(0u)) | |
| { | |
| float _59; | |
| float _60; | |
| float _61; | |
| float _62; | |
| uint _63; | |
| _59 = 0.0; | |
| _60 = 0.0; | |
| _61 = 0.0; | |
| _62 = 0.0; | |
| _63 = 0u; | |
| float _45; | |
| float _47; | |
| float _49; | |
| float _51; | |
| for (;;) | |
| { | |
| float _69 = float(int(_63)); | |
| vec4 _79 = texture(sampler2D(Tex, Samp), vec2((Buf_1._m0[0u].x * _69) + TEXCOORD.x, (Buf_1._m0[0u].y * _69) + TEXCOORD.y)); | |
| uint _85 = _63 + 2u; | |
| _45 = (Buf_1._m0[_85].x * _79.x) + _59; | |
| _47 = (Buf_1._m0[_85].y * _79.y) + _60; | |
| _49 = (Buf_1._m0[_85].z * _79.z) + _61; | |
| _51 = (Buf_1._m0[_85].w * _79.w) + _62; | |
| uint _64 = _63 + 1u; | |
| if (int(_64) < int(floatBitsToUint(Buf_1._m0[1u]).x)) | |
| { | |
| _59 = _45; | |
| _60 = _47; | |
| _61 = _49; | |
| _62 = _51; | |
| _63 = _64; | |
| } | |
| else | |
| { | |
| break; | |
| } | |
| } | |
| _43 = _45; | |
| _46 = _47; | |
| _48 = _49; | |
| _50 = _51; | |
| } | |
| else | |
| { | |
| _43 = 0.0; | |
| _46 = 0.0; | |
| _48 = 0.0; | |
| _50 = 0.0; | |
| } | |
| SV_Target.x = _43; | |
| SV_Target.y = _46; | |
| SV_Target.z = _48; | |
| SV_Target.w = _50; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment