summaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-10-01 20:21:13 +0000
committerrodri <rgl@antares-labs.eu>2024-10-01 20:21:13 +0000
commitb6a336aff26fbc94e7803719a8aeb8fa29eddb9b (patch)
treeee3049837fc0edf7e3d2133aa711457bbf9b8859 /render.c
parent453d100ac7734cd64652aa4d3a0685e3494428f7 (diff)
downloadlibgraphics-b6a336aff26fbc94e7803719a8aeb8fa29eddb9b.tar.gz
libgraphics-b6a336aff26fbc94e7803719a8aeb8fa29eddb9b.tar.bz2
libgraphics-b6a336aff26fbc94e7803719a8aeb8fa29eddb9b.zip
implement a uniforms interface through Shadertab.
Diffstat (limited to 'render.c')
-rw-r--r--render.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/render.c b/render.c
index cc5a201..672b4b5 100644
--- a/render.c
+++ b/render.c
@@ -12,8 +12,13 @@ Rectangle UR = {0,0,1,1};
static Vertexattr *
sparams_getuniform(Shaderparams *sp, char *id)
{
- USED(sp, id);
- return nil;
+ return getvattr(sp->su->stab, id);
+}
+
+void
+setuniform(Shadertab *st, char *id, int type, void *val)
+{
+ addvattr(st, id, type, val);
}
static Vertexattr *
@@ -202,7 +207,7 @@ rasterize(Rastertask *task)
fsp.v = &prim->v[0];
fsp.p = p;
- c = params->fshader(&fsp);
+ c = params->stab->fshader(&fsp);
if(c.a == 0) /* discard non-colors */
break;
if(ropts & RODepth)
@@ -268,7 +273,7 @@ rasterize(Rastertask *task)
lerpvertex(fsp.v, &prim->v[0], &prim->v[1], perc);
fsp.p = p;
- c = params->fshader(&fsp);
+ c = params->stab->fshader(&fsp);
if(c.a == 0) /* discard non-colors */
goto discard;
if(ropts & RODepth)
@@ -322,7 +327,7 @@ discard:
berpvertex(fsp.v, &prim->v[0], &prim->v[1], &prim->v[2], bc);
fsp.p = p;
- c = params->fshader(&fsp);
+ c = params->stab->fshader(&fsp);
if(c.a == 0) /* discard non-colors */
continue;
if(ropts & RODepth)
@@ -477,7 +482,7 @@ tiler(void *arg)
vsp.v = &p->v[0];
vsp.idx = 0;
- p->v[0].p = params->vshader(&vsp);
+ p->v[0].p = params->stab->vshader(&vsp);
if(!isvisible(p->v[0].p))
break;
@@ -512,7 +517,7 @@ tiler(void *arg)
vsp.v = &p->v[i];
vsp.idx = i;
- p->v[i].p = params->vshader(&vsp);
+ p->v[i].p = params->stab->vshader(&vsp);
}
if(!isvisible(p->v[0].p) || !isvisible(p->v[1].p)){
@@ -558,7 +563,7 @@ tiler(void *arg)
vsp.v = &p->v[i];
vsp.idx = i;
- p->v[i].p = params->vshader(&vsp);
+ p->v[i].p = params->stab->vshader(&vsp);
}
if(!isvisible(p->v[0].p) || !isvisible(p->v[1].p) || !isvisible(p->v[2].p)){
@@ -751,12 +756,10 @@ renderer(void *arg)
params = emalloc(sizeof *params);
memset(params, 0, sizeof *params);
params->fb = job->fb;
+ params->stab = job->shaders;
params->job = job;
params->camera = job->camera;
params->entity = ent;
- params->uni_time = time;
- params->vshader = job->shaders->vshader;
- params->fshader = job->shaders->fshader;
sendp(ep->paramsc, params);
}
/* mark end of job */