diff options
author | Dan Gudmundsson <[email protected]> | 2016-11-22 09:57:09 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2016-11-22 09:57:09 +0100 |
commit | 9cacf4faa47f87a063af6baa52a017ea9a4989e3 (patch) | |
tree | e14bc5803c8cef0d1a6a97c11e1fc35ec5d3159f /lib/wx/api_gen | |
parent | 4b6b406a75116f651213a307f6873940d35b5199 (diff) | |
download | otp-9cacf4faa47f87a063af6baa52a017ea9a4989e3.tar.gz otp-9cacf4faa47f87a063af6baa52a017ea9a4989e3.tar.bz2 otp-9cacf4faa47f87a063af6baa52a017ea9a4989e3.zip |
Add option to send prebuilt binaries to multiDrawArrays
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r-- | lib/wx/api_gen/gl_gen.erl | 33 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen_c.erl | 29 | ||||
-rw-r--r-- | lib/wx/api_gen/gl_gen_erl.erl | 15 | ||||
-rw-r--r-- | lib/wx/api_gen/glapi.conf | 6 |
4 files changed, 53 insertions, 30 deletions
diff --git a/lib/wx/api_gen/gl_gen.erl b/lib/wx/api_gen/gl_gen.erl index 54635bdd2e..7e3766a43b 100644 --- a/lib/wx/api_gen/gl_gen.erl +++ b/lib/wx/api_gen/gl_gen.erl @@ -354,6 +354,7 @@ handle_arg_opt({single,Opt},P=#arg{type=T}) -> P#arg{type=T#type{single=Opt}}; handle_arg_opt({base,{Opt, Sz}}, P=#arg{type=T}) -> P#arg{type=T#type{base=Opt, size=Sz}}; handle_arg_opt({base,Opt}, P=#arg{type=T}) -> P#arg{type=T#type{base=Opt}}; handle_arg_opt({c_only,Opt},P) -> P#arg{where=c, alt=Opt}; +handle_arg_opt(list_binary, P) -> P#arg{alt=list_binary}; handle_arg_opt(string, P=#arg{type=T}) -> P#arg{type=T#type{base=string}}; handle_arg_opt({string,Max,Sz}, P=#arg{type=T}) -> P#arg{type=T#type{base=string, size={Max,Sz}}}. @@ -588,7 +589,7 @@ lookup(Name,[_|R],Def) -> lookup(Name,R,Def); lookup(_,[], Def) -> Def. -setup_idx_binary(Name,Ext,_Opts) -> +setup_idx_binary(Name,Ext, Opts) -> FuncName = Name ++ Ext, Func = #func{params=Args} = get(FuncName), Id = next_id(function), @@ -607,8 +608,7 @@ setup_idx_binary(Name,Ext,_Opts) -> ok; (_) -> ok end, Args), - - case setup_idx_binary(Args, []) of + case setup_idx_binary_1(Args, []) of ignore -> put(FuncName, Func#func{id=Id}), Name++Ext; @@ -624,30 +624,41 @@ setup_idx_binary(Name,Ext,_Opts) -> [FuncName,Extra] end. -setup_idx_binary([A=#arg{in=true,type=T=#type{base=idx_binary}}|R], Acc) -> +setup_idx_binary_1([A=#arg{in=true,type=T=#type{base=idx_binary}}|R], Acc) -> A1 = A#arg{type=T#type{base=guard_int,size=4}}, A2 = A#arg{type=T#type{base=binary}}, Head = reverse(Acc), - case setup_idx_binary(R, []) of + case setup_idx_binary_1(R, []) of ignore -> {bin, Head ++ [A1|R], Head ++ [A2|R]}; {bin, R1,R2} -> {bin, Head ++ [A1|R1], Head ++ [A2|R2]} end; -setup_idx_binary([A=#arg{in=true,type=T=#type{single={tuple,matrix}}}|R], Acc) -> +setup_idx_binary_1([A=#arg{in=true,type=T=#type{base=int,size=4},alt=list_binary}|R], Acc) -> + A1 = A#arg{type=T#type{base=guard_int}}, + A2 = A#arg{type=T#type{base=binary}}, + Head = reverse(Acc), + case setup_idx_binary_1(R, []) of + ignore -> + {bin, Head ++ [A1|R], Head ++ [A2|R]}; + {bin, R1,R2} -> + {bin, Head ++ [A1|R1], Head ++ [A2|R2]} + end; + +setup_idx_binary_1([A=#arg{in=true,type=T=#type{single={tuple,matrix}}}|R], Acc) -> A1 = A#arg{type=T#type{single={tuple, matrix12}}}, A2 = A#arg{type=T#type{single={tuple, 16}}}, Head = reverse(Acc), - case setup_idx_binary(R, []) of + case setup_idx_binary_1(R, []) of ignore -> {matrix, Head ++ [A1|R], Head ++ [A2|R]}; {matrix, R1,R2} -> {matrix, Head ++ [A1|R1], Head ++ [A2|R2]} end; -setup_idx_binary([H|R],Acc) -> - setup_idx_binary(R,[H|Acc]); -setup_idx_binary([],_) -> ignore. - +setup_idx_binary_1([H|R],Acc) -> + setup_idx_binary_1(R,[H|Acc]); +setup_idx_binary_1([],_) -> ignore. + is_equal(F1=#func{type=T1,params=A1},F2=#func{type=T2,params=A2}) -> Equal = is_equal_type(T1,T2) andalso is_equal_args(A1,A2), case Equal of diff --git a/lib/wx/api_gen/gl_gen_c.erl b/lib/wx/api_gen/gl_gen_c.erl index 2edad9c4e2..53c194a315 100644 --- a/lib/wx/api_gen/gl_gen_c.erl +++ b/lib/wx/api_gen/gl_gen_c.erl @@ -123,20 +123,14 @@ declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=B,single={list,Sz}}}) when is_number(Sz) -> w(" ~s ~s[~p] = {~s};~n", [T,N,Sz,args(fun zero/1,",",lists:duplicate(Sz,B))]), A; -declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=string,size={Max,_}, single=Single}}) -> +declare_var(A=#arg{name=N,in=false,type=#type{name=T,base=string,size={Max,_}}}) -> case is_integer(Max) of - true -> + true -> w(" ~s ~s[~p];~n", [T,N,Max]); false -> - %% w(" ~s ~s[*~s];~n", [T,N,Max]), - w(" ~s *~s;~n", [T,N]), + w(" ~s *~s;~n", [T,N]), w(" ~s = (~s *) driver_alloc(sizeof(~s) * *~s);~n", [N,T,T,Max]), - store_free(N) - %% case Single of - %% {list, _, _} -> - %% w(" ~s *~s_p = ~s;~n", [T,N,N]); - %% _ -> ok - %% end + store_free(N) end, A; declare_var(A=#arg{name=N,in=false,type=#type{base=binary,size={MaxSz, _}}}) -> @@ -163,9 +157,9 @@ declare_var(A=#arg{name=N,in=false, type=#type{name=T,base=B,by_val=false,single=true}}) -> w(" ~s ~s[1] = {~s};~n", [T,N,zero(B)]), A; -declare_var(A=#arg{where=c, type=#type{name=T}, alt={size,Var}}) -> +declare_var(A=#arg{where=c, type=#type{name=T}, alt={size,Var}}) -> w(" ~s ~s_size = bins_sz[~p];~n", [T, Var, get(bin_count)]), - A; + A; declare_var(A=#arg{where=_}) -> A. @@ -194,9 +188,16 @@ decode_arg(P=#arg{where=erl},A) -> {P,A}; decode_arg(P=#arg{where=c},A) -> {P,A}; decode_arg(P=#arg{in=false},A) -> {P,A}; -decode_arg(P=#arg{name=Name,type=#type{name=Type,base=binary}},A0) -> +decode_arg(P=#arg{name=Name,alt=Alt,type=#type{name=Type,base=binary}},A0) -> w(" ~s *~s = (~s *) bins[~p];~n", [Type,Name,Type,next_id(bin_count)]), - {P, A0}; + case Alt of + list_binary -> + A = align(4, A0), + w(" int * ~sLen = (int *) bp; bp += 4; (void) ~sLen;~n", [Name, Name]), + {P, A}; + _ -> + {P, A0} + end; decode_arg(P=#arg{name=Name,type=#type{name=Type,base=memory}},A0) -> w(" ~s *~s = (~s *) bins[~p];~n", [Type,Name,Type,next_id(bin_count)]), {P, A0}; diff --git a/lib/wx/api_gen/gl_gen_erl.erl b/lib/wx/api_gen/gl_gen_erl.erl index 1f9407525d..4bb80662e1 100644 --- a/lib/wx/api_gen/gl_gen_erl.erl +++ b/lib/wx/api_gen/gl_gen_erl.erl @@ -496,6 +496,8 @@ doc_arg_type2(#type{base=string, single=list}) -> "iolist()"; doc_arg_type2(T=#type{single={tuple,Sz}}) -> "{" ++ args(fun doc_arg_type3/1, ",", lists:duplicate(Sz,T)) ++ "}"; +doc_arg_type2(#type{base=guard_int, single=list}) -> + "[integer()]|mem()"; doc_arg_type2(T=#type{single=list}) -> "[" ++ doc_arg_type3(T) ++ "]"; doc_arg_type2(T=#type{single={list, _Max}}) -> @@ -516,7 +518,9 @@ doc_arg_type3(#type{base=binary}) -> "binary()"; doc_arg_type3(#type{base=memory}) -> "mem()". guard_test(As) -> - Str = args(fun(#arg{name=N,type=#type{base=guard_int}}) -> + Str = args(fun(#arg{name=N,type=#type{base=guard_int, single=list}}) -> + " is_list("++erl_arg_name(N)++")"; + (#arg{name=N,type=#type{base=guard_int}}) -> " is_integer("++erl_arg_name(N)++")"; (_) -> skip @@ -526,6 +530,13 @@ guard_test(As) -> Other -> " when " ++ Other end. +pre_marshal([#arg{name=N,in=true, type=#type{base=binary, single=list}=T, alt=list_binary}=A|R]) -> + w(" send_bin(~s),~n", [erl_arg_name(N)]), + w(" ~sLen = byte_size(if is_binary(~s) -> ~s; is_tuple(~s) -> element(2, ~s) end) div 4,~n", + [erl_arg_name(N),erl_arg_name(N), erl_arg_name(N), erl_arg_name(N), erl_arg_name(N)]), + Type = T#type{base=int, by_val=true, single=true, ref=undefined}, + Arg=A#arg{name=N++"Len", where=both, type=Type}, + [Arg|pre_marshal(R)]; pre_marshal([#arg{name=N,in=true,type=#type{base=binary}}|R]) -> w(" send_bin(~s),~n", [erl_arg_name(N)]), pre_marshal(R); @@ -587,7 +598,7 @@ marshal_arg(#type{size=BSz,name=Type,single={tuple,matrix12}},Name,A0) -> align(BSz,16,A0,All); marshal_arg(#type{size=Sz,name=Type,base=Base,single=list},Name,A0) - when Base =:= float; Base =:= int -> + when Base =:= float; Base =:= int; Base =:= guard_int -> KeepA = case Sz of 8 -> "0:32,"; _ -> "" end, Str0 = "(length("++Name++")):?GLuint,"++KeepA++"\n" " (<< <<C:?"++Type++">> || C <- "++Name++">>)/binary", diff --git a/lib/wx/api_gen/glapi.conf b/lib/wx/api_gen/glapi.conf index 59fa8f7727..57f30a3f7e 100644 --- a/lib/wx/api_gen/glapi.conf +++ b/lib/wx/api_gen/glapi.conf @@ -181,9 +181,9 @@ {"glLoadTransposeMatrix", {"m", {single,{tuple,matrix}}}}. {"glMultTransposeMatrix", {"m",{single,{tuple,matrix}}}}. -{"glMultiDrawArrays", [{"first", [in,{single,list}]}, - {"count", [in,{single,list}]}, - {"primcount", {c_only, {length,"first"}}}]}. +{"glMultiDrawArrays", [{"first", [in,{single,list}, list_binary]}, + {"count", [in,{single,list}, list_binary]}, + {"primcount", {c_only, {length,"count"}}}]}. {"glGenQueries", {"ids", {single,{list, "n", "n"}}}}. {"glGetQueryiv", {"params", {single, true}}}. |