Exemplo n.º 1
0
static int
vp_get_vector_const(realityVertexProgram *vp, const char *name)
{
  int v = realityVertexProgramGetConstant(vp, name);
  if(v == -1)
    return -1;
  realityProgramConst *c = realityVertexProgramGetConstants(vp);
  return c[v].index;
}
Exemplo n.º 2
0
int realityVertexProgramGetConstant(realityVertexProgram *vertexprogram,const char *name)
{
	int i;
	realityVertexProgramConstant *constants = realityVertexProgramGetConstants(vertexprogram);
	for(i=0;i<vertexprogram->NumConstants;++i)
	{
		char *namePtr;
		if(constants[i].NameOffset==0)
			continue;
		namePtr=((char*)vertexprogram)+constants[i].NameOffset;
		if(strcasecmp(name,namePtr)==0)
			return constants[i].Index;
	}

	return -1;
}
Exemplo n.º 3
0
s32 realityVertexProgramGetConstant(realityVertexProgram *vertexprogram,const char *name)
{
	s32 i;
	realityProgramConst *constants = realityVertexProgramGetConstants(vertexprogram);

	for(i=0;i<vertexprogram->num_const;++i)
	{
		char *namePtr;
		if(constants[i].name_off==0)
			continue;
		namePtr=((char*)vertexprogram)+constants[i].name_off;
		if(strcasecmp(name,namePtr)==0)
			return i;
	}

	return -1;
}
Exemplo n.º 4
0
static rsx_vp_t *
load_vp(const char *url)
{
  char errmsg[100];
  realityVertexProgram *vp;
  int i;
  const char *name;

  if((vp = fa_load(url, NULL, NULL, errmsg, sizeof(errmsg), NULL)) == NULL) {
    TRACE(TRACE_ERROR, "glw", "Unable to load shader %s -- %s\n",
	  url, log);
    return NULL;
  }

  TRACE(TRACE_INFO, "glw", "Loaded Vertex program %s", url);
  TRACE(TRACE_INFO, "glw", "    input mask: %x", 
	realityVertexProgramGetInputMask(vp));
  TRACE(TRACE_INFO, "glw", "   output mask: %x", 
	realityVertexProgramGetOutputMask(vp));

  realityProgramConst *constants;
  constants = realityVertexProgramGetConstants(vp);
  for(i = 0; i < vp->num_const; i++) {
    if(constants[i].name_off)
      name = ((char*)vp)+constants[i].name_off;
    else
      name = "<anon>";

    TRACE(TRACE_INFO, "glw", "  Constant %s @ 0x%x [%f, %f, %f, %f]",
	  name,
	  constants[i].index,
	  constants[i].values[0].f,
	  constants[i].values[1].f,
	  constants[i].values[2].f,
	  constants[i].values[3].f);
  }

  realityProgramAttrib *attributes;
  attributes = realityVertexProgramGetAttributes(vp);
  for(i = 0; i < vp->num_attrib; i++) {
    if(attributes[i].name_off)
      name = ((char*)vp)+attributes[i].name_off;
    else
      name = "<anon>";

    TRACE(TRACE_INFO, "glw", "  Attribute %s @ 0x%x",
	  name, attributes[i].index);
  }

  rsx_vp_t *rvp = calloc(1, sizeof(rsx_vp_t));
  rvp->rvp_binary = vp;

  rvp->rvp_u_modelview = realityVertexProgramGetConstant(vp, "u_modelview");
  rvp->rvp_u_color     = vp_get_vector_const(vp, "u_color");
  rvp->rvp_u_color_offset = vp_get_vector_const(vp, "u_color_offset");
  rvp->rvp_u_blur_amount = vp_get_vector_const(vp, "u_blur_amount");
  TRACE(TRACE_INFO, "glw", "%d %d", rvp->rvp_u_modelview, rvp->rvp_u_color);

  rvp->rvp_a_position = realityVertexProgramGetAttribute(vp, "a_position");
  rvp->rvp_a_color    = realityVertexProgramGetAttribute(vp, "a_color");
  rvp->rvp_a_texcoord = realityVertexProgramGetAttribute(vp, "a_texcoord");
  TRACE(TRACE_INFO, "glw", "%d %d %d",
	rvp->rvp_a_position, rvp->rvp_a_color, rvp->rvp_a_texcoord);

  return rvp;
}
Exemplo n.º 5
0
static rsx_vp_t *
load_vp(const char *filename)
{
  char errmsg[100];
  buf_t *b;
  int i;
  const char *name;
  char url[512];

  snprintf(url, sizeof(url), "%s/src/ui/glw/rsx/%s", 
	   app_dataroot(), filename);

  if((b = fa_load(url, FA_LOAD_ERRBUF(errmsg, sizeof(errmsg)),
                   NULL)) == NULL) {
    TRACE(TRACE_ERROR, "glw", "Unable to load shader %s -- %s\n",
	  url, log);
    return NULL;
  }

  realityVertexProgram *vp = b->b_ptr;

  RSX_TRACE("Loaded Vertex program %s", url);
  RSX_TRACE("    input mask: %x", 
	realityVertexProgramGetInputMask(vp));
  RSX_TRACE("   output mask: %x", 
	realityVertexProgramGetOutputMask(vp));

  realityProgramConst *constants;
  constants = realityVertexProgramGetConstants(vp);
  for(i = 0; i < vp->num_const; i++) {
    if(constants[i].name_off)
      name = ((char*)vp)+constants[i].name_off;
    else
      name = "<anon>";

    RSX_TRACE("  Constant %s @ 0x%x [%f, %f, %f, %f]",
	  name,
	  constants[i].index,
	  constants[i].values[0].f,
	  constants[i].values[1].f,
	  constants[i].values[2].f,
	  constants[i].values[3].f);
  }

  realityProgramAttrib *attributes;
  attributes = realityVertexProgramGetAttributes(vp);
  for(i = 0; i < vp->num_attrib; i++) {
    if(attributes[i].name_off)
      name = ((char*)vp)+attributes[i].name_off;
    else
      name = "<anon>";

    RSX_TRACE("  Attribute %s @ 0x%x",
	  name, attributes[i].index);
  }

  rsx_vp_t *rvp = calloc(1, sizeof(rsx_vp_t));
  rvp->rvp_binary = vp;

  rvp->rvp_u_modelview = realityVertexProgramGetConstant(vp, "u_modelview");
  rvp->rvp_u_color     = vp_get_vector_const(vp, "u_color");
  rvp->rvp_u_color_offset = vp_get_vector_const(vp, "u_color_offset");
  rvp->rvp_u_blur = vp_get_vector_const(vp, "u_blur");

  RSX_TRACE("%d %d", rvp->rvp_u_modelview, rvp->rvp_u_color);

  rvp->rvp_a_position = realityVertexProgramGetAttribute(vp, "a_position");
  rvp->rvp_a_color    = realityVertexProgramGetAttribute(vp, "a_color");
  rvp->rvp_a_texcoord = realityVertexProgramGetAttribute(vp, "a_texcoord");
  RSX_TRACE("%d %d %d",
	rvp->rvp_a_position, rvp->rvp_a_color, rvp->rvp_a_texcoord);

  return rvp;
}