adding branching and conversions
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
[nzsl_version("1.1")]
|
||||
module;
|
||||
[nzsl_version("1.1")]
|
||||
[feature(float64)]
|
||||
module;
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
|
||||
struct FragOut
|
||||
{
|
||||
[location(0)] color: vec4[f32]
|
||||
}
|
||||
[entry(frag)]
|
||||
fn main() -> FragOut
|
||||
{
|
||||
let op1: f64 = 0.0;
|
||||
let op2: f64 = 9.0;
|
||||
let color: f32;
|
||||
if (op1 == op2)
|
||||
color = f32(op1);
|
||||
else
|
||||
color = f32(op2);
|
||||
|
||||
[entry(frag)]
|
||||
fn main() -> FragOut
|
||||
{
|
||||
let ratio = vec4[f32](2.0, 2.0, 8.0, 0.25);
|
||||
|
||||
let output: FragOut;
|
||||
output.color = vec4[f32](4.0, 3.0, 2.0, 1.0) * ratio;
|
||||
return output;
|
||||
}
|
||||
let output: FragOut;
|
||||
output.color = vec4[f32](color, color, color, color);
|
||||
return output;
|
||||
}
|
||||
|
||||
Binary file not shown.
70
example/shader.spv.txt
git.filemode.normal_file
70
example/shader.spv.txt
git.filemode.normal_file
@@ -0,0 +1,70 @@
|
||||
Version 1.0
|
||||
Generator: 2560130
|
||||
Bound: 42
|
||||
Schema: 0
|
||||
OpCapability Capability(Shader)
|
||||
OpCapability Capability(Float64)
|
||||
OpMemoryModel AddressingModel(Logical) MemoryModel(GLSL450)
|
||||
OpEntryPoint ExecutionModel(Fragment) %17 "main" %6
|
||||
OpExecutionMode %17 ExecutionMode(OriginUpperLeft)
|
||||
OpSource SourceLanguage(NZSL) 4198400
|
||||
OpSourceExtension "Version: 1.1"
|
||||
OpName %7 "FragOut"
|
||||
OpMemberName %7 0 "color"
|
||||
OpName %6 "color"
|
||||
OpName %17 "main"
|
||||
OpDecorate %6 Decoration(Location) 0
|
||||
OpMemberDecorate %7 0 Decoration(Offset) 0
|
||||
%1 = OpTypeVoid
|
||||
%2 = OpTypeFunction %1
|
||||
%3 = OpTypeFloat 32
|
||||
%4 = OpTypeVector %3 4
|
||||
%5 = OpTypePointer StorageClass(Output) %4
|
||||
%7 = OpTypeStruct %4
|
||||
%8 = OpTypeFloat 64
|
||||
%9 = OpConstant %8 f64(0)
|
||||
%10 = OpTypePointer StorageClass(Function) %8
|
||||
%11 = OpConstant %8 f64(9)
|
||||
%12 = OpTypePointer StorageClass(Function) %3
|
||||
%13 = OpTypeBool
|
||||
%14 = OpTypePointer StorageClass(Function) %7
|
||||
%15 = OpTypeInt 32 1
|
||||
%16 = OpConstant %15 i32(0)
|
||||
%39 = OpTypePointer StorageClass(Function) %4
|
||||
%6 = OpVariable %5 StorageClass(Output)
|
||||
%17 = OpFunction %1 FunctionControl(0) %2
|
||||
%18 = OpLabel
|
||||
%19 = OpVariable %10 StorageClass(Function)
|
||||
%20 = OpVariable %10 StorageClass(Function)
|
||||
%21 = OpVariable %12 StorageClass(Function)
|
||||
%22 = OpVariable %14 StorageClass(Function)
|
||||
OpStore %19 %9
|
||||
OpStore %20 %11
|
||||
%26 = OpLoad %8 %19
|
||||
%27 = OpLoad %8 %20
|
||||
%28 = OpFOrdEqual %13 %26 %27
|
||||
OpSelectionMerge %23 SelectionControl(0)
|
||||
OpBranchConditional %28 %24 %25
|
||||
%24 = OpLabel
|
||||
%29 = OpLoad %8 %19
|
||||
%30 = OpFConvert %3 %29
|
||||
OpStore %21 %30
|
||||
OpBranch %23
|
||||
%25 = OpLabel
|
||||
%31 = OpLoad %8 %20
|
||||
%32 = OpFConvert %3 %31
|
||||
OpStore %21 %32
|
||||
OpBranch %23
|
||||
%23 = OpLabel
|
||||
%33 = OpLoad %3 %21
|
||||
%34 = OpLoad %3 %21
|
||||
%35 = OpLoad %3 %21
|
||||
%36 = OpLoad %3 %21
|
||||
%37 = OpCompositeConstruct %4 %33 %34 %35 %36
|
||||
%38 = OpAccessChain %39 %22 %16
|
||||
OpStore %38 %37
|
||||
%40 = OpLoad %7 %22
|
||||
%41 = OpCompositeExtract %4 %40 0
|
||||
OpStore %6 %41
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
@@ -1,50 +0,0 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: SirLynix Nazara ShaderLang Compiler; 4226
|
||||
; Bound: 29
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Fragment %main "main" %color
|
||||
OpExecutionMode %main OriginUpperLeft
|
||||
OpSource NZSL 4198400
|
||||
OpSourceExtension "Version: 1.1"
|
||||
OpName %FragOut "FragOut"
|
||||
OpMemberName %FragOut 0 "color"
|
||||
OpName %color "color"
|
||||
OpName %main "main"
|
||||
OpDecorate %color Location 0
|
||||
OpMemberDecorate %FragOut 0 Offset 0
|
||||
%void = OpTypeVoid
|
||||
%2 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%FragOut = OpTypeStruct %v4float
|
||||
%float_2 = OpConstant %float 2
|
||||
%float_8 = OpConstant %float 8
|
||||
%float_0_25 = OpConstant %float 0.25
|
||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||
%_ptr_Function_FragOut = OpTypePointer Function %FragOut
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%float_4 = OpConstant %float 4
|
||||
%float_3 = OpConstant %float 3
|
||||
%float_1 = OpConstant %float 1
|
||||
%color = OpVariable %_ptr_Output_v4float Output
|
||||
%main = OpFunction %void None %2
|
||||
%19 = OpLabel
|
||||
%20 = OpVariable %_ptr_Function_v4float Function
|
||||
%21 = OpVariable %_ptr_Function_FragOut Function
|
||||
%22 = OpCompositeConstruct %v4float %float_2 %float_2 %float_8 %float_0_25
|
||||
OpStore %20 %22
|
||||
%23 = OpCompositeConstruct %v4float %float_4 %float_3 %float_2 %float_1
|
||||
%24 = OpLoad %v4float %20
|
||||
%25 = OpFMul %v4float %23 %24
|
||||
%26 = OpAccessChain %_ptr_Function_v4float %21 %int_0
|
||||
OpStore %26 %25
|
||||
%27 = OpLoad %FragOut %21
|
||||
%28 = OpCompositeExtract %v4float %27 0
|
||||
OpStore %color %28
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
Reference in New Issue
Block a user