skia2/tests/sksl/intrinsics/MatrixCompMult.asm.frag
Ethan Nicholas 9e476b798f Refactored SPIR-V RelaxedPrecision handling
The RelaxedPrecision decoration is now handled by nextId(), to make it
easier to see all spots where a RelaxedPrecision decoration might be
necessary. The goal of this initial refactor is not to actually fix the
issues with RelaxedPrecision decorations, but rather to lay the
groundwork for doing so in followup CLs.

The initial intent of this change was to not affect the SPIR-V at all,
saving modifications for followups, but there ended up being three kinds
of changes to the output:

1. Doing things at nextId() time rather than later means some
decorations move to an earlier spot in the output. This results in
diffs, but should not cause any behavioral changes.
2. We were incorrectly tagging bools as RelaxedPrecision in some
situations. By funneling things through fewer code paths, the refactor
would have caused this to happen in even more situations, and the code
responsible for the bug was being rewritten in this CL anyway, so it
seemed worth just fixing the issue as part of this change.
3. Funneling things through fewer code paths ended up adding
(correct) RelaxedPrecision modifiers to binary operations that had
previously been missing them. It seemed better to just let it happen
than to try to maintain bug-for-bug compatibility with the previous
approach.

Change-Id: Ia9654d6b5754e2c797e02226660cb618c9189b36
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/384318
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-03-15 20:45:26 +00:00

90 lines
3.2 KiB
JavaScript

OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise
OpExecutionMode %main OriginUpperLeft
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %a "a"
OpName %b "b"
OpName %c "c"
OpName %d "d"
OpName %main "main"
OpDecorate %sk_FragColor RelaxedPrecision
OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %a RelaxedPrecision
OpDecorate %b RelaxedPrecision
OpDecorate %25 RelaxedPrecision
OpDecorate %26 RelaxedPrecision
OpDecorate %41 RelaxedPrecision
OpDecorate %43 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%sk_FragColor = OpVariable %_ptr_Output_v4float Output
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
%_ptr_Private_mat3v3float = OpTypePointer Private %mat3v3float
%a = OpVariable %_ptr_Private_mat3v3float Private
%b = OpVariable %_ptr_Private_mat3v3float Private
%mat4v4float = OpTypeMatrix %v4float 4
%_ptr_Private_mat4v4float = OpTypePointer Private %mat4v4float
%c = OpVariable %_ptr_Private_mat4v4float Private
%d = OpVariable %_ptr_Private_mat4v4float Private
%void = OpTypeVoid
%20 = OpTypeFunction %void
%_ptr_Function_mat3v3float = OpTypePointer Function %mat3v3float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Function_v3float = OpTypePointer Function %v3float
%_ptr_Function_mat4v4float = OpTypePointer Function %mat4v4float
%_ptr_Function_v4float = OpTypePointer Function %v4float
%main = OpFunction %void None %20
%21 = OpLabel
%22 = OpVariable %_ptr_Function_mat3v3float Function
%44 = OpVariable %_ptr_Function_mat4v4float Function
%25 = OpLoad %mat3v3float %a
%26 = OpLoad %mat3v3float %b
%27 = OpCompositeExtract %v3float %25 0
%28 = OpCompositeExtract %v3float %26 0
%29 = OpFMul %v3float %27 %28
%30 = OpCompositeExtract %v3float %25 1
%31 = OpCompositeExtract %v3float %26 1
%32 = OpFMul %v3float %30 %31
%33 = OpCompositeExtract %v3float %25 2
%34 = OpCompositeExtract %v3float %26 2
%35 = OpFMul %v3float %33 %34
%36 = OpCompositeConstruct %mat3v3float %29 %32 %35
OpStore %22 %36
%39 = OpAccessChain %_ptr_Function_v3float %22 %int_0
%41 = OpLoad %v3float %39
%42 = OpLoad %v4float %sk_FragColor
%43 = OpVectorShuffle %v4float %42 %41 4 5 6 3
OpStore %sk_FragColor %43
%47 = OpLoad %mat4v4float %c
%48 = OpLoad %mat4v4float %d
%49 = OpCompositeExtract %v4float %47 0
%50 = OpCompositeExtract %v4float %48 0
%51 = OpFMul %v4float %49 %50
%52 = OpCompositeExtract %v4float %47 1
%53 = OpCompositeExtract %v4float %48 1
%54 = OpFMul %v4float %52 %53
%55 = OpCompositeExtract %v4float %47 2
%56 = OpCompositeExtract %v4float %48 2
%57 = OpFMul %v4float %55 %56
%58 = OpCompositeExtract %v4float %47 3
%59 = OpCompositeExtract %v4float %48 3
%60 = OpFMul %v4float %58 %59
%61 = OpCompositeConstruct %mat4v4float %51 %54 %57 %60
OpStore %44 %61
%62 = OpAccessChain %_ptr_Function_v4float %44 %int_0
%64 = OpLoad %v4float %62
OpStore %sk_FragColor %64
OpReturn
OpFunctionEnd