julia --project=. -e "using Pkg; pkg"add RadeonProRender#sd/moah GeometryBasics [email protected]"
executed with:
julia --project=. --check-bounds=(yes|no) rpr_mwe.jl
Diff of the llvm code: https://www.diffchecker.com/chE5Jtim
julia --project=. -e "using Pkg; pkg"add RadeonProRender#sd/moah GeometryBasics [email protected]"
executed with:
julia --project=. --check-bounds=(yes|no) rpr_mwe.jl
Diff of the llvm code: https://www.diffchecker.com/chE5Jtim
define nonnull {}* @japi1_shape_299({}* %0, {}** %1, i32 %2) #0 { | |
top: | |
%3 = alloca [3 x {}*], align 8 | |
%gcframe29 = alloca [4 x {}*], align 16 | |
%gcframe29.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe29, i64 0, i64 0 | |
%.sub = getelementptr inbounds [3 x {}*], [3 x {}*]* %3, i64 0, i64 0 | |
%4 = bitcast [4 x {}*]* %gcframe29 to i8* | |
call void @llvm.memset.p0i8.i32(i8* nonnull align 16 dereferenceable(32) %4, i8 0, i32 32, i1 false) | |
%5 = alloca {}**, align 8 | |
store volatile {}** %1, {}*** %5, align 8 | |
%6 = call {}*** inttoptr (i64 33937920 to {}*** ()*)() #3 | |
%7 = bitcast [4 x {}*]* %gcframe29 to i64* | |
store i64 8, i64* %7, align 16 | |
%8 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe29, i64 0, i64 1 | |
%9 = bitcast {}** %8 to {}*** | |
%10 = load {}**, {}*** %6, align 8 | |
store {}** %10, {}*** %9, align 8 | |
%11 = bitcast {}*** %6 to {}*** | |
store {}** %gcframe29.sub, {}*** %11, align 8 | |
%12 = load {}*, {}** %1, align 8 | |
%13 = getelementptr inbounds {}*, {}** %1, i64 1 | |
%14 = load {}*, {}** %13, align 8 | |
%15 = getelementptr inbounds {}*, {}** %1, i64 2 | |
%16 = load {}*, {}** %15, align 8 | |
%17 = getelementptr inbounds {}*, {}** %1, i64 3 | |
%18 = load {}*, {}** %17, align 8 | |
%19 = getelementptr inbounds {}*, {}** %1, i64 4 | |
%20 = load {}*, {}** %19, align 8 | |
%21 = bitcast {}* %18 to { i8*, i64, i16, i16, i32 }* | |
%22 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %21, i64 0, i32 1 | |
%23 = load i64, i64* %22, align 8 | |
%24 = udiv i64 %23, 3 | |
%25 = call nonnull {}* inttoptr (i64 33762272 to {}* ({}*, i64)*)({}* inttoptr (i64 292740160 to {}*), i64 %24) | |
%26 = bitcast {}* %25 to {}** | |
%27 = getelementptr inbounds {}*, {}** %26, i64 3 | |
%28 = bitcast {}** %27 to i64* | |
%29 = load i64, i64* %28, align 8 | |
%.not.not = icmp eq i64 %29, 0 | |
br i1 %.not.not, label %L35, label %L17.preheader | |
L17.preheader: ; preds = %top | |
%30 = bitcast {}* %25 to i32** | |
%31 = load i32*, i32** %30, align 8 | |
%min.iters.check = icmp ult i64 %29, 32 | |
br i1 %min.iters.check, label %L17, label %vector.ph | |
vector.ph: ; preds = %L17.preheader | |
%n.vec = and i64 %29, 9223372036854775776 | |
%ind.end = or i64 %n.vec, 1 | |
br label %vector.body | |
vector.body: ; preds = %vector.body, %vector.ph | |
%index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ] | |
%32 = getelementptr inbounds i32, i32* %31, i64 %index | |
%33 = bitcast i32* %32 to <8 x i32>* | |
store <8 x i32> <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>, <8 x i32>* %33, align 4 | |
%34 = getelementptr inbounds i32, i32* %32, i64 8 | |
%35 = bitcast i32* %34 to <8 x i32>* | |
store <8 x i32> <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>, <8 x i32>* %35, align 4 | |
%36 = getelementptr inbounds i32, i32* %32, i64 16 | |
%37 = bitcast i32* %36 to <8 x i32>* | |
store <8 x i32> <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>, <8 x i32>* %37, align 4 | |
%38 = getelementptr inbounds i32, i32* %32, i64 24 | |
%39 = bitcast i32* %38 to <8 x i32>* | |
store <8 x i32> <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>, <8 x i32>* %39, align 4 | |
%index.next = add i64 %index, 32 | |
%40 = icmp eq i64 %index.next, %n.vec | |
br i1 %40, label %middle.block, label %vector.body | |
middle.block: ; preds = %vector.body | |
%cmp.n = icmp eq i64 %29, %n.vec | |
br i1 %cmp.n, label %L35, label %L17 | |
L17: ; preds = %L17, %middle.block, %L17.preheader | |
%value_phi3 = phi i64 [ %43, %L17 ], [ %ind.end, %middle.block ], [ 1, %L17.preheader ] | |
%41 = add nsw i64 %value_phi3, -1 | |
%42 = getelementptr inbounds i32, i32* %31, i64 %41 | |
store i32 3, i32* %42, align 4 | |
%.not = icmp eq i64 %value_phi3, %29 | |
%43 = add nuw nsw i64 %value_phi3, 1 | |
br i1 %.not, label %L35, label %L17 | |
L35: ; preds = %L17, %middle.block, %top | |
%44 = bitcast {}* %14 to { i8*, i64, i16, i16, i32 }* | |
%45 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %44, i64 0, i32 1 | |
%46 = load i64, i64* %45, align 8 | |
%47 = bitcast {}* %16 to { i8*, i64, i16, i16, i32 }* | |
%48 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %47, i64 0, i32 1 | |
%49 = load i64, i64* %48, align 8 | |
%50 = bitcast {}* %20 to { i8*, i64, i16, i16, i32 }* | |
%51 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %50, i64 0, i32 1 | |
%52 = load i64, i64* %51, align 8 | |
%53 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe29, i64 0, i64 2 | |
store {}* %25, {}** %53, align 16 | |
%54 = call i64 @j_rprContextCreateMesh_300({}* nonnull %12, {}* nonnull %14, i64 signext %46, i64 signext 12, {}* nonnull %16, i64 signext %49, i64 signext 12, {}* nonnull %20, i64 signext %52, i64 signext 8, {}* nonnull %18, i64 signext 4, {}* nonnull %18, i64 signext 4, {}* nonnull %18, i64 signext 4, {}* nonnull %25, i64 signext %24) #4 | |
%ptls_field13 = getelementptr inbounds {}**, {}*** %6, i64 2305843009213693954 | |
%55 = bitcast {}*** %ptls_field13 to i8** | |
%ptls_load1415 = load i8*, i8** %55, align 8 | |
%56 = call noalias nonnull {}* @jl_gc_pool_alloc(i8* %ptls_load1415, i32 1416, i32 32) #5 | |
%57 = bitcast {}* %56 to i64* | |
%58 = getelementptr inbounds i64, i64* %57, i64 -1 | |
store atomic i64 224290912, i64* %58 unordered, align 8 | |
%59 = bitcast {}* %56 to {}** | |
%60 = getelementptr inbounds {}*, {}** %59, i64 1 | |
store {}* null, {}** %60, align 8 | |
store i64 %54, i64* %57, align 8 | |
%61 = bitcast {}* %56 to i8* | |
%62 = getelementptr inbounds i8, i8* %61, i64 8 | |
%ptls_load111819 = load i8*, i8** %55, align 8 | |
%63 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe29, i64 0, i64 3 | |
store {}* %56, {}** %63, align 8 | |
%64 = call noalias nonnull {}* @jl_gc_pool_alloc(i8* %ptls_load111819, i32 | |
1440, i32 48) #5 | |
%65 = bitcast {}* %64 to i64* | |
%66 = getelementptr inbounds i64, i64* %65, i64 -1 | |
store atomic i64 1967728656, i64* %66 unordered, align 8 | |
%67 = bitcast {}* %64 to [5 x {}*]* | |
%.repack = bitcast {}* %64 to {}** | |
store {}* %14, {}** %.repack, align 8 | |
%.repack20 = getelementptr inbounds [5 x {}*], [5 x {}*]* %67, i64 0, i64 1 | |
store {}* %16, {}** %.repack20, align 8 | |
%.repack22 = getelementptr inbounds [5 x {}*], [5 x {}*]* %67, i64 0, i64 2 | |
store {}* %20, {}** %.repack22, align 8 | |
%.repack24 = getelementptr inbounds [5 x {}*], [5 x {}*]* %67, i64 0, i64 3 | |
store {}* %18, {}** %.repack24, align 8 | |
%.repack26 = getelementptr inbounds [5 x {}*], [5 x {}*]* %67, i64 0, i64 4 | |
store {}* %25, {}** %.repack26, align 8 | |
%68 = bitcast i8* %62 to {}** | |
store {}* %64, {}** %68, align 8 | |
%69 = load atomic i64, i64* %58 unordered, align 8 | |
%70 = and i64 %69, 3 | |
%71 = icmp eq i64 %70, 3 | |
br i1 %71, label %72, label %73 | |
72: ; preds = %L35 | |
call void @jl_gc_queue_root({}* nonnull %56) | |
br label %73 | |
73: ; preds = %72, %L35 | |
%74 = bitcast {}* %12 to i8* | |
%75 = getelementptr inbounds i8, i8* %74, i64 8 | |
%76 = bitcast i8* %75 to {}*** | |
%77 = load atomic {}**, {}*** %76 unordered, align 8 | |
%78 = load atomic {}*, {}** %77 unordered, align 8 | |
store {}* %78, {}** %53, align 16 | |
store {}* %78, {}** %.sub, align 8 | |
%79 = getelementptr inbounds [3 x {}*], [3 x {}*]* %3, i64 0, i64 1 | |
store {}* inttoptr (i64 182976520 to {}*), {}** %79, align 8 | |
%80 = getelementptr inbounds [3 x {}*], [3 x {}*]* %3, i64 0, i64 2 | |
store {}* %56, {}** %80, align 8 | |
%81 = call nonnull {}* @"j1_setindex!_301"({}* inttoptr (i64 346054560 to {}*), {}** nonnull %.sub, i32 3) | |
%82 = load {}*, {}** %8, align 8 | |
%83 = bitcast {}*** %6 to {}** | |
store {}* %82, {}** %83, align 8 | |
ret {}* %56 | |
} |
define nonnull {}* @japi1_shape_299({}* %0, {}** %1, i32 %2) #0 { | |
top: | |
%3 = alloca [3 x {}*], align 8 | |
%gcframe31 = alloca [4 x {}*], align 16 | |
%gcframe31.sub = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe31, i64 0, i64 0 | |
%.sub = getelementptr inbounds [3 x {}*], [3 x {}*]* %3, i64 0, i64 0 | |
%4 = bitcast [4 x {}*]* %gcframe31 to i8* | |
call void @llvm.memset.p0i8.i32(i8* nonnull align 16 dereferenceable(32) %4, i8 0, i32 32, i1 false) | |
%5 = alloca {}**, align 8 | |
store volatile {}** %1, {}*** %5, align 8 | |
%6 = call {}*** inttoptr (i64 41867776 to {}*** ()*)() #3 | |
%7 = bitcast [4 x {}*]* %gcframe31 to i64* | |
store i64 8, i64* %7, align 16 | |
%8 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe31, i64 0, i64 1 | |
%9 = bitcast {}** %8 to {}*** | |
%10 = load {}**, {}*** %6, align 8 | |
store {}** %10, {}*** %9, align 8 | |
%11 = bitcast {}*** %6 to {}*** | |
store {}** %gcframe31.sub, {}*** %11, align 8 | |
%12 = load {}*, {}** %1, align 8 | |
%13 = getelementptr inbounds {}*, {}** %1, i64 1 | |
%14 = load {}*, {}** %13, align 8 | |
%15 = getelementptr inbounds {}*, {}** %1, i64 2 | |
%16 = load {}*, {}** %15, align 8 | |
%17 = getelementptr inbounds {}*, {}** %1, i64 3 | |
%18 = load {}*, {}** %17, align 8 | |
%19 = getelementptr inbounds {}*, {}** %1, i64 4 | |
%20 = load {}*, {}** %19, align 8 | |
%21 = bitcast {}* %18 to { i8*, i64, i16, i16, i32 }* | |
%22 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %21, i64 0, i32 1 | |
%23 = load i64, i64* %22, align 8 | |
%24 = udiv i64 %23, 3 | |
%25 = call nonnull {}* inttoptr (i64 41692128 to {}* ({}*, i64)*)({}* inttoptr (i64 292150336 to {}*), i64 %24) | |
%26 = bitcast {}* %25 to {}** | |
%27 = getelementptr inbounds {}*, {}** %26, i64 3 | |
%28 = bitcast {}** %27 to i64* | |
%29 = load i64, i64* %28, align 8 | |
%.not.not = icmp eq i64 %29, 0 | |
br i1 %.not.not, label %L35, label %L17.preheader | |
L17.preheader: ; preds = %top | |
%30 = bitcast {}* %25 to { i8*, i64, i16, i16, i32 }* | |
%31 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %30, i64 0, i32 1 | |
%32 = load i64, i64* %31, align 8 | |
%33 = bitcast {}* %25 to i32** | |
%34 = add nuw nsw i64 %32, 1 | |
br label %L17 | |
L17: ; preds = %idxend, %L17.preheader | |
%value_phi3 = phi i64 [ %79, %idxend ], [ 1, %L17.preheader ] | |
%exitcond.not = icmp eq i64 %value_phi3, %34 | |
br i1 %exitcond.not, label %oob, label %idxend | |
L35: ; preds = %idxend, %top | |
%35 = bitcast {}* %14 to { i8*, i64, i16, i16, i32 }* | |
%36 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %35, i64 0, i32 1 | |
%37 = load i64, i64* %36, align 8 | |
%38 = bitcast {}* %16 to { i8*, i64, i16, i16, i32 }* | |
%39 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %38, i64 0, i32 1 | |
%40 = load i64, i64* %39, align 8 | |
%41 = bitcast {}* %20 to { i8*, i64, i16, i16, i32 }* | |
%42 = getelementptr inbounds { i8*, i64, i16, i16, i32 }, { i8*, i64, i16, | |
i16, i32 }* %41, i64 0, i32 1 | |
%43 = load i64, i64* %42, align 8 | |
%44 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe31, i64 0, i64 2 | |
store {}* %25, {}** %44, align 16 | |
%45 = call i64 @j_rprContextCreateMesh_300({}* nonnull %12, {}* nonnull %14, i64 signext %37, i64 signext 12, {}* nonnull %16, i64 signext %40, i64 signext 12, {}* nonnull %20, i64 signext %43, i64 signext 8, {}* nonnull %18, i64 signext 4, {}* nonnull %18, i64 signext 4, {}* nonnull %18, i64 signext 4, {}* nonnull %25, i64 signext %24) #4 | |
%ptls_field13 = getelementptr inbounds {}**, {}*** %6, i64 2305843009213693954 | |
%46 = bitcast {}*** %ptls_field13 to i8** | |
%ptls_load1415 = load i8*, i8** %46, align 8 | |
%47 = call noalias nonnull {}* @jl_gc_pool_alloc(i8* %ptls_load1415, i32 1416, i32 32) #5 | |
%48 = bitcast {}* %47 to i64* | |
%49 = getelementptr inbounds i64, i64* %48, i64 -1 | |
store atomic i64 229992544, i64* %49 unordered, align 8 | |
%50 = bitcast {}* %47 to {}** | |
%51 = getelementptr inbounds {}*, {}** %50, i64 1 | |
store {}* null, {}** %51, align 8 | |
store i64 %45, i64* %48, align 8 | |
%52 = bitcast {}* %47 to i8* | |
%53 = getelementptr inbounds i8, i8* %52, i64 8 | |
%ptls_load111819 = load i8*, i8** %46, align 8 | |
%54 = getelementptr inbounds [4 x {}*], [4 x {}*]* %gcframe31, i64 0, i64 3 | |
store {}* %47, {}** %54, align 8 | |
%55 = call noalias nonnull {}* @jl_gc_pool_alloc(i8* %ptls_load111819, i32 | |
1440, i32 48) #5 | |
%56 = bitcast {}* %55 to i64* | |
%57 = getelementptr inbounds i64, i64* %56, i64 -1 | |
store atomic i64 1967630592, i64* %57 unordered, align 8 | |
%58 = bitcast {}* %55 to [5 x {}*]* | |
%.repack = bitcast {}* %55 to {}** | |
store {}* %14, {}** %.repack, align 8 | |
%.repack20 = getelementptr inbounds [5 x {}*], [5 x {}*]* %58, i64 0, i64 1 | |
store {}* %16, {}** %.repack20, align 8 | |
%.repack22 = getelementptr inbounds [5 x {}*], [5 x {}*]* %58, i64 0, i64 2 | |
store {}* %20, {}** %.repack22, align 8 | |
%.repack24 = getelementptr inbounds [5 x {}*], [5 x {}*]* %58, i64 0, i64 3 | |
store {}* %18, {}** %.repack24, align 8 | |
%.repack26 = getelementptr inbounds [5 x {}*], [5 x {}*]* %58, i64 0, i64 4 | |
store {}* %25, {}** %.repack26, align 8 | |
%59 = bitcast i8* %53 to {}** | |
store {}* %55, {}** %59, align 8 | |
%60 = load atomic i64, i64* %49 unordered, align 8 | |
%61 = and i64 %60, 3 | |
%62 = icmp eq i64 %61, 3 | |
br i1 %62, label %63, label %64 | |
63: ; preds = %L35 | |
call void @jl_gc_queue_root({}* nonnull %47) | |
br label %64 | |
64: ; preds = %63, %L35 | |
%65 = bitcast {}* %12 to i8* | |
%66 = getelementptr inbounds i8, i8* %65, i64 8 | |
%67 = bitcast i8* %66 to {}*** | |
%68 = load atomic {}**, {}*** %67 unordered, align 8 | |
%69 = load atomic {}*, {}** %68 unordered, align 8 | |
store {}* %69, {}** %44, align 16 | |
store {}* %69, {}** %.sub, align 8 | |
%70 = getelementptr inbounds [3 x {}*], [3 x {}*]* %3, i64 0, i64 1 | |
store {}* inttoptr (i64 181338120 to {}*), {}** %70, align 8 | |
%71 = getelementptr inbounds [3 x {}*], [3 x {}*]* %3, i64 0, i64 2 | |
store {}* %47, {}** %71, align 8 | |
%72 = call nonnull {}* @"j1_setindex!_301"({}* inttoptr (i64 345464736 to {}*), {}** nonnull %.sub, i32 3) | |
%73 = load {}*, {}** %8, align 8 | |
%74 = bitcast {}*** %6 to {}** | |
store {}* %73, {}** %74, align 8 | |
ret {}* %47 | |
oob: ; preds = %L17 | |
%75 = alloca i64, align 8 | |
store i64 %34, i64* %75, align 8 | |
call void @jl_bounds_error_ints({}* %25, i64* nonnull %75, i64 1) | |
unreachable | |
idxend: ; preds = %L17 | |
%76 = add nsw i64 %value_phi3, -1 | |
%77 = load i32*, i32** %33, align 8 | |
%78 = getelementptr inbounds i32, i32* %77, i64 %76 | |
store i32 3, i32* %78, align 4 | |
%.not = icmp eq i64 %value_phi3, %29 | |
%79 = add nuw nsw i64 %value_phi3, 1 | |
br i1 %.not, label %L35, label %L17 | |
} |
using RadeonProRender, GeometryBasics | |
const RPR = RadeonProRender | |
using InteractiveUtils | |
using RadeonProRender: Shape, rpr_int | |
function shape(context::RPR.Context, vraw::Vector{Point3f}, nraw::Vector{Vec3f}, iraw::Vector{RPR.rpr_int}, | |
uvraw::Vector{Vec2f}) | |
nfaces = length(iraw) ÷ 3 | |
facelens = fill(rpr_int(3), nfaces) | |
rpr_mesh = RPR.RPR.rprContextCreateMesh(context, vraw, length(vraw), sizeof(Point3f), nraw, length(nraw), | |
sizeof(Vec3f), uvraw, length(uvraw), sizeof(Vec2f), iraw, | |
sizeof(rpr_int), iraw, sizeof(rpr_int), iraw, sizeof(rpr_int), | |
facelens, nfaces) | |
jl_references = (vraw, nraw, uvraw, iraw, facelens) | |
shape = Shape(rpr_mesh, jl_references) | |
push!(context.objects, shape) | |
return shape | |
end | |
let | |
context = RPR.Context(; resource=RPR.RPR_CREATION_FLAGS_ENABLE_CPU) | |
scene = RPR.Scene(context) | |
m = uv_normal_mesh(Tesselation(Sphere(Point3f(2, 0, 2), 1.0f0), 100)) | |
v, n, fs, uv = decompose(Point3f, m), normals(m), faces(m), texturecoordinates(m) | |
uvraw = map(uv -> Vec2f(1 - uv[2], 1 - uv[1]), uv) | |
f = decompose(TriangleFace{OffsetInteger{-1,rpr_int}}, fs) | |
iraw = collect(reinterpret(rpr_int, f)) | |
@code_llvm debuginfo = :none shape(context, v, n, iraw, uvraw) | |
shape(context, v, n, iraw, uvraw) | |
end |