ref: a66be92f63ec59c1811403eb7b95fa72588beee6
parent: 10954ee4177af81e1892b833d8b33140629f68a4
author: sirjofri <[email protected]>
date: Fri Feb 16 07:59:31 EST 2024
adds object commands (compile)
--- a/gpufs.c
+++ b/gpufs.c
@@ -57,6 +57,14 @@
#define OBJECTID(c) (((Gpufid*)(c))->id)
+char fserr[512];
+
+static void
+responderr(Req *r) {
+ snprint(fserr, 512, "%r");
+ respond(r, fserr);
+}
+
String *fsqueue = nil;
int debug = 0;
@@ -326,11 +334,14 @@
}
static void
-procrootcommand(Req *r, int argc, char **argv)
+rootcommand(Req *r, int argc, char **argv)
{
// n(ew) s(hader)
// n(ew) b(uffer) <len>
+ if (argc <= 0)
+ return;
+
if (strcmp(argv[0], "n") == 0) {
switch (argc) {
case 2:
@@ -358,8 +369,39 @@
}
static void
-rootcommand(Req *r, char *cmd)
+objectcommand(Req *r, int argc, char **argv)
{
+ // c(ompile)
+ // r(un)
+ Gpufid* f;
+
+ f = r->fid->aux;
+
+ if (argc <= 0)
+ return;
+
+ switch (getobjecttype(f->id)) {
+ case SHADER:
+ if (strcmp(argv[0], "c") == 0) {
+ if (!compileshader(f->id)) {
+ responderr(r);
+ return;
+ }
+ }
+ if (strcmp(argv[0], "r") == 0) {
+ respond(r, "not implemented");
+ return;
+ }
+ break;
+ case BUFFER:
+ break;
+ }
+ respond(r, nil);
+}
+
+static void
+parsecommand(Req *r, char *cmd, void (*f)(Req*,int,char**))
+{
char *lines[10];
int linec;
@@ -368,7 +410,7 @@
for (int i = 0; i < linec; i++) {
char *c[10];
int num = getfields(lines[i], c, 10, 1, " \t");
- procrootcommand(r, num, c);
+ f(r, num, c);
}
}
@@ -386,7 +428,7 @@
n = r->ofcall.count = r->ifcall.count;
s = emalloc(n+1);
memmove(s, r->ifcall.data, n);
- rootcommand(r, s);
+ parsecommand(r, s, rootcommand);
return;
case Qshader:
r->ofcall.count = writeshader(OBJECTID(f), r->ifcall.data, r->ifcall.count, r->ifcall.offset);
@@ -405,6 +447,12 @@
}
snprint(err, 256, "%r");
respond(r, err);
+ return;
+ case Qctl:
+ n = r->ofcall.count = r->ifcall.count;
+ s = emalloc(n+1);
+ memmove(s, r->ifcall.data, n);
+ parsecommand(r, s, objectcommand);
return;
}
respond(r, "not implemented");
--- a/vm.c
+++ b/vm.c
@@ -232,7 +232,8 @@
int
compileshader(vlong id)
{
- return -1;
+ werrstr("not implemented!");
+ return 0;
}
int