Lines Matching refs:f
24 void printFileHeader(FILE *f) { in printFileHeader() argument
25 fprintf(f, "/*\n"); in printFileHeader()
26 fprintf(f, " * Copyright (C) 2015 The Android Open Source Project\n"); in printFileHeader()
27 fprintf(f, " *\n"); in printFileHeader()
28 fprintf(f, " * Licensed under the Apache License, Version 2.0 (the \"License\");\n"); in printFileHeader()
29 fprintf(f, " * you may not use this file except in compliance with the License.\n"); in printFileHeader()
30 fprintf(f, " * You may obtain a copy of the License at\n"); in printFileHeader()
31 fprintf(f, " *\n"); in printFileHeader()
32 fprintf(f, " * http://www.apache.org/licenses/LICENSE-2.0\n"); in printFileHeader()
33 fprintf(f, " *\n"); in printFileHeader()
34 fprintf(f, " * Unless required by applicable law or agreed to in writing, software\n"); in printFileHeader()
35 fprintf(f, " * distributed under the License is distributed on an \"AS IS\" BASIS,\n"); in printFileHeader()
36 fprintf(f, " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"); in printFileHeader()
37 fprintf(f, " * See the License for the specific language governing permissions and\n"); in printFileHeader()
38 fprintf(f, " * limitations under the License.\n"); in printFileHeader()
39 fprintf(f, " */\n\n"); in printFileHeader()
42 void printVarType(FILE *f, const VarType *vt) { in printVarType() argument
45 fprintf(f, "const "); in printVarType()
50 fprintf(f, "void"); in printVarType()
53 fprintf(f, "int%i_t", vt->bits); in printVarType()
56 fprintf(f, "uint%i_t", vt->bits); in printVarType()
60 fprintf(f, "float"); in printVarType()
62 fprintf(f, "double"); in printVarType()
65 fprintf(f, "%s", vt->typeName); in printVarType()
70 fprintf(f, " "); in printVarType()
72 fprintf(f, "*"); in printVarType()
77 void printVarTypeAndName(FILE *f, const VarType *vt) { in printVarTypeAndName() argument
78 printVarType(f, vt); in printVarTypeAndName()
81 fprintf(f, " %s", vt->name); in printVarTypeAndName()
85 void printArgList(FILE *f, const ApiEntry * api, int assumePrevious) { in printArgList() argument
89 fprintf(f, ", "); in printArgList()
91 printVarTypeAndName(f, &api->params[ct]); in printArgList()
95 void printStructures(FILE *f) { in printStructures() argument
100 fprintf(f, "typedef struct RS_CMD_%s_rec RS_CMD_%s;\n", apis[ct].name, apis[ct].name); in printStructures()
102 fprintf(f, "\n"); in printStructures()
106 fprintf(f, "#define RS_CMD_ID_%s %i\n", api->name, ct+1); in printStructures()
107 fprintf(f, "struct __attribute__((packed)) RS_CMD_%s_rec {\n", api->name); in printStructures()
111 fprintf(f, " "); in printStructures()
112 printVarTypeAndName(f, &api->params[ct2]); in printStructures()
113 fprintf(f, ";\n"); in printStructures()
115 fprintf(f, "};\n\n"); in printStructures()
119 void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext, int isFnPtr) { in printFuncDecl() argument
120 printVarTypeAndName(f, &api->ret); in printFuncDecl()
130 fprintf(f, " (* %s%s) (", prefix, api->name); in printFuncDecl()
132 fprintf(f, " %s%s (", prefix, api->name); in printFuncDecl()
136 fprintf(f, "Context *"); in printFuncDecl()
138 fprintf(f, "RsContext rsc"); in printFuncDecl()
141 printArgList(f, api, !api->nocontext); in printFuncDecl()
142 fprintf(f, ")"); in printFuncDecl()
145 void printFuncDecls(FILE *f, const char *prefix, int addContext, int externC) { in printFuncDecls() argument
149 fprintf(f, "extern \"C\" "); in printFuncDecls()
151 printFuncDecl(f, &apis[ct], prefix, addContext, 0); in printFuncDecls()
152 fprintf(f, ";\n"); in printFuncDecls()
154 fprintf(f, "\n\n"); in printFuncDecls()
157 void printPlaybackFuncs(FILE *f, const char *prefix) { in printPlaybackFuncs() argument
164 fprintf(f, "void %s%s (Context *, const void *);\n", prefix, apis[ct].name); in printPlaybackFuncs()
194 void printApiCpp(FILE *f) { in printApiCpp() argument
198 fprintf(f, RSG_API_CPP_DOC); in printApiCpp()
200 fprintf(f, "#include \"rsDevice.h\"\n"); in printApiCpp()
201 fprintf(f, "#include \"rsContext.h\"\n"); in printApiCpp()
202 fprintf(f, "#include \"rsThreadIO.h\"\n"); in printApiCpp()
203 fprintf(f, "#include \"rsgApiStructs.h\"\n"); in printApiCpp()
204 fprintf(f, "#include \"rsgApiFuncDecl.h\"\n"); in printApiCpp()
205 fprintf(f, "#include \"rsFifo.h\"\n"); in printApiCpp()
206 fprintf(f, "\n"); in printApiCpp()
207 fprintf(f, "using namespace android; // NOLINT\n"); in printApiCpp()
208 fprintf(f, "using namespace android::renderscript; // NOLINT\n"); in printApiCpp()
209 fprintf(f, "\n"); in printApiCpp()
216 fprintf(f, "static "); in printApiCpp()
217 printFuncDecl(f, api, LOCAL_FIFO_PREFIX, 0, 0); in printApiCpp()
218 fprintf(f, "\n{\n"); in printApiCpp()
220 fprintf(f, " "); in printApiCpp()
222 fprintf(f, "return "); in printApiCpp()
224 fprintf(f, RS_INTERNAL_PREFIX "%s(", api->name); in printApiCpp()
226 fprintf(f, "(Context *)rsc"); in printApiCpp()
231 fprintf(f, ", "); in printApiCpp()
233 fprintf(f, "%s", vt->name); in printApiCpp()
235 fprintf(f, ");\n"); in printApiCpp()
238 fprintf(f, " " LOCAL_FIFO_PREFIX "%s_handcode(", api->name); in printApiCpp()
240 fprintf(f, "(Context *)rsc"); in printApiCpp()
245 fprintf(f, ", "); in printApiCpp()
247 fprintf(f, "%s", vt->name); in printApiCpp()
249 fprintf(f, ");\n"); in printApiCpp()
253 fprintf(f, " if (((Context *)rsc)->isSynchronous()) {\n"); in printApiCpp()
254 fprintf(f, " "); in printApiCpp()
256 fprintf(f, "return "); in printApiCpp()
258 fprintf(f, RS_INTERNAL_PREFIX "%s(", api->name); in printApiCpp()
260 fprintf(f, "(Context *)rsc"); in printApiCpp()
265 fprintf(f, ", "); in printApiCpp()
267 fprintf(f, "%s", vt->name); in printApiCpp()
269 fprintf(f, ");\n"); in printApiCpp()
271 fprintf(f, " return;"); in printApiCpp()
273 fprintf(f, " }\n\n"); in printApiCpp()
275 fprintf(f, " ThreadIO *io = &((Context *)rsc)->mIO;\n"); in printApiCpp()
276 fprintf(f, " const size_t size = sizeof(RS_CMD_%s);\n", api->name); in printApiCpp()
278 fprintf(f, " size_t dataSize = 0;\n"); in printApiCpp()
282 fprintf(f, " dataSize += %s_length;\n", vt->name); in printApiCpp()
289 fprintf(f, " RS_CMD_%s *cmd = NULL;\n", api->name); in printApiCpp()
290 fprintf(f, " if (dataSize < io->getMaxInlineSize()) {;\n"); in printApiCpp()
291 …fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, dataSize + size));… in printApiCpp()
292 fprintf(f, " } else {\n"); in printApiCpp()
293 …fprintf(f, " cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n", api->n… in printApiCpp()
294 fprintf(f, " }\n"); in printApiCpp()
295 fprintf(f, " uint8_t *payload = (uint8_t *)&cmd[1];\n"); in printApiCpp()
297 …fprintf(f, " RS_CMD_%s *cmd = static_cast<RS_CMD_%s *>(io->coreHeader(RS_CMD_ID_%s, size));\n",… in printApiCpp()
304 fprintf(f, " if (%s_length == 0) {\n", vt->name); in printApiCpp()
305 fprintf(f, " cmd->%s = NULL;\n", vt->name); in printApiCpp()
306 fprintf(f, " } else if (dataSize < io->getMaxInlineSize()) {\n"); in printApiCpp()
307 fprintf(f, " memcpy(payload, %s, %s_length);\n", vt->name, vt->name); in printApiCpp()
308 fprintf(f, " cmd->%s = (", vt->name); in printApiCpp()
309 printVarType(f, vt); in printApiCpp()
310 fprintf(f, ")(payload - ((uint8_t *)&cmd[1]));\n"); in printApiCpp()
311 fprintf(f, " payload += %s_length;\n", vt->name); in printApiCpp()
312 fprintf(f, " } else {\n"); in printApiCpp()
313 fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name); in printApiCpp()
314 fprintf(f, " }\n"); in printApiCpp()
317 fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name); in printApiCpp()
324 fprintf(f, " io->coreCommit();\n"); in printApiCpp()
326 fprintf(f, " if (dataSize >= io->getMaxInlineSize()) {\n"); in printApiCpp()
327 fprintf(f, " io->coreGetReturn(NULL, 0);\n"); in printApiCpp()
328 fprintf(f, " }\n"); in printApiCpp()
330 fprintf(f, "\n "); in printApiCpp()
331 printVarType(f, &api->ret); in printApiCpp()
332 fprintf(f, " ret;\n"); in printApiCpp()
333 fprintf(f, " io->coreGetReturn(&ret, sizeof(ret));\n"); in printApiCpp()
334 fprintf(f, " return ret;\n"); in printApiCpp()
336 fprintf(f, " io->coreGetReturn(NULL, 0);\n"); in printApiCpp()
339 fprintf(f, "};\n\n"); in printApiCpp()
342 fprintf(f, "\n"); in printApiCpp()
348 fprintf(f, "extern \"C\" "); in printApiCpp()
350 printFuncDecl(f, api, "rs", 0, 0); in printApiCpp()
351 fprintf(f, "\n{\n"); in printApiCpp()
352 fprintf(f, " "); in printApiCpp()
354 fprintf(f, "return "); in printApiCpp()
356 fprintf(f, LOCAL_FIFO_PREFIX "%s(", api->name); in printApiCpp()
359 fprintf(f, "(Context *)rsc"); in printApiCpp()
365 fprintf(f, ", "); in printApiCpp()
367 fprintf(f, "%s", vt->name); in printApiCpp()
369 fprintf(f, ");\n"); in printApiCpp()
370 fprintf(f, "}\n\n"); in printApiCpp()
375 void printPlaybackCpp(FILE *f) { in printPlaybackCpp() argument
379 fprintf(f, RSG_API_REPLAY_CPP_DOC); in printPlaybackCpp()
381 fprintf(f, "#include \"rsDevice.h\"\n"); in printPlaybackCpp()
382 fprintf(f, "#include \"rsContext.h\"\n"); in printPlaybackCpp()
383 fprintf(f, "#include \"rsThreadIO.h\"\n"); in printPlaybackCpp()
384 fprintf(f, "#include \"rsgApiStructs.h\"\n"); in printPlaybackCpp()
385 fprintf(f, "#include \"rsgApiFuncDecl.h\"\n"); in printPlaybackCpp()
386 fprintf(f, "\n"); in printPlaybackCpp()
387 fprintf(f, "namespace android {\n"); in printPlaybackCpp()
388 fprintf(f, "namespace renderscript {\n"); in printPlaybackCpp()
389 fprintf(f, "\n"); in printPlaybackCpp()
400 …fprintf(f, "void " RS_PLAYBACK_PREFIX "%s(Context *con, const void *vp, size_t cmdSizeBytes) {\n",… in printPlaybackCpp()
401 …fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->nam… in printPlaybackCpp()
404 fprintf(f, " const uint8_t *baseData = 0;\n"); in printPlaybackCpp()
405 fprintf(f, " if (cmdSizeBytes != sizeof(RS_CMD_%s)) {\n", api->name); in printPlaybackCpp()
406 fprintf(f, " baseData = &((const uint8_t *)vp)[sizeof(*cmd)];\n"); in printPlaybackCpp()
407 fprintf(f, " }\n"); in printPlaybackCpp()
410 fprintf(f, " "); in printPlaybackCpp()
412 fprintf(f, "\n "); in printPlaybackCpp()
413 printVarType(f, &api->ret); in printPlaybackCpp()
414 fprintf(f, " ret = "); in printPlaybackCpp()
416 fprintf(f, RS_INTERNAL_PREFIX "%s(con", api->name); in printPlaybackCpp()
422 … fprintf(f, ",\n cmd->%s_length == 0 ? NULL : (const %s *)&baseData[(intptr_t)cmd->%s]", in printPlaybackCpp()
425 fprintf(f, ",\n cmd->%s", vt->name); in printPlaybackCpp()
428 fprintf(f, ");\n"); in printPlaybackCpp()
431 fprintf(f, " size_t totalSize = 0;\n"); in printPlaybackCpp()
434 fprintf(f, " totalSize += cmd->%s_length;\n", api->params[ct2].name); in printPlaybackCpp()
438 … fprintf(f, " if ((totalSize != 0) && (cmdSizeBytes == sizeof(RS_CMD_%s))) {\n", api->name); in printPlaybackCpp()
439 fprintf(f, " con->mIO.coreSetReturn(NULL, 0);\n"); in printPlaybackCpp()
440 fprintf(f, " }\n"); in printPlaybackCpp()
442 fprintf(f, " con->mIO.coreSetReturn(&ret, sizeof(ret));\n"); in printPlaybackCpp()
444 fprintf(f, " con->mIO.coreSetReturn(NULL, 0);\n"); in printPlaybackCpp()
447 fprintf(f, "};\n\n"); in printPlaybackCpp()
451 fprintf(f, "RsPlaybackLocalFunc gPlaybackFuncs[%i] = {\n", apiCount + 1); in printPlaybackCpp()
452 fprintf(f, " NULL,\n"); in printPlaybackCpp()
455 fprintf(f, " NULL,\n"); in printPlaybackCpp()
457 fprintf(f, " %s%s,\n", RS_PLAYBACK_PREFIX, apis[ct].name); in printPlaybackCpp()
460 fprintf(f, "};\n"); in printPlaybackCpp()
462 fprintf(f, "};\n"); in printPlaybackCpp()
463 fprintf(f, "};\n"); in printPlaybackCpp()
488 FILE *f = fopen(outFile, "w"); in main() local
490 printFileHeader(f); in main()
494 fprintf(f, "\n"); in main()
495 fprintf(f, "#include \"rsContext.h\"\n"); in main()
496 fprintf(f, "#include \"rsFifo.h\"\n"); in main()
497 fprintf(f, "\n"); in main()
498 fprintf(f, "namespace android {\n"); in main()
499 fprintf(f, "namespace renderscript {\n"); in main()
500 printStructures(f); in main()
501 printFuncDecls(f, RS_INTERNAL_PREFIX, 1, 0); in main()
502 printPlaybackFuncs(f, RS_PLAYBACK_PREFIX); in main()
503 … fprintf(f, "typedef void (*RsPlaybackLocalFunc)(Context *, const void *, size_t sizeBytes);\n"); in main()
504 fprintf(f, "extern RsPlaybackLocalFunc gPlaybackFuncs[%i];\n", apiCount + 1); in main()
506 fprintf(f, "}\n"); in main()
507 fprintf(f, "}\n"); in main()
513 printFuncDecls(f, "rs", 0, 1); in main()
519 printApiCpp(f); in main()
525 printPlaybackCpp(f); in main()
529 fclose(f); in main()