Home | History | Annotate | Download | only in pixelflinger2

Lines Matching full:program

31 #include "src/mesa/program/prog_parameter.h"
32 #include "src/mesa/program/prog_uniform.h"
206 gl_shader_program * program = hieralloc_zero(NULL, struct gl_shader_program);
207 if (!program)
209 program->Attributes = hieralloc_zero(program, gl_program_parameter_list);
210 if (!program->Attributes) {
211 hieralloc_free(program);
214 program->Varying = hieralloc_zero(program, gl_program_parameter_list);
215 if (!program->Varying) {
216 hieralloc_free(program);
219 return program;
225 gl_shader_program * program = GGLShaderProgramCreate();
226 if (!program)
228 return program;
231 unsigned GGLShaderAttach(gl_shader_program * program, gl_shader * shader)
233 for (unsigned i = 0; i < program->NumShaders; i++)
234 if (program->Shaders[i]->Type == shader->Type || program->Shaders[i] == shader)
237 program->Shaders = (gl_shader **)hieralloc_realloc
238 (program, program->Shaders, gl_shader *, program->NumShaders + 1);
239 if (!program->Shaders) {
243 program->Shaders[program->NumShaders] = shader;
244 program->NumShaders++;
249 static void ShaderAttach(const GGLInterface * iface, gl_shader_program * program,
252 unsigned error = GGLShaderAttach(program, shader);
257 GLboolean GGLShaderProgramLink(gl_shader_program * program, const char ** infoLog)
259 link_shaders(glContext.ctx, program);
261 *infoLog = program->InfoLog;
262 if (!program->LinkStatus)
263 return program->LinkStatus;
264 LOGD("slots: attribute=%d varying=%d uniforms=%d \n", program->AttributeSlots, program->VaryingSlots, program->Uniforms->Slots);
265 // for (unsigned i = 0; i < program->Attributes->NumParameters; i++) {
266 // const gl_program_parameter & attribute = program->Attributes->Parameters[i];
269 // for (unsigned i = 0; i < program->Varying->NumParameters; i++) {
270 // const gl_program_parameter & varying = program->Varying->Parameters[i];
273 for (unsigned i = 0; i < program->Uniforms->NumUniforms; i++) {
274 const gl_uniform & uniform = program->Uniforms->Uniforms[i];
277 return program->LinkStatus;
280 static GLboolean ShaderProgramLink(gl_shader_program * program, const char ** infoLog)
282 return GGLShaderProgramLink(program, infoLog);
361 const gl_shader_program * program;
387 gl_shader_program * program, const GGLState * gglCtx)
389 SymbolLookupContext ctx = {gglCtx, program, shader};
420 void GenerateScanLine(const GGLState * gglCtx, const gl_shader_program * program, llvm::Module * mod,
423 void GGLShaderUse(void * llvmCtx, const GGLState * gglState, gl_shader_program * program)
425 // LOGD("%s", program->Shaders[MESA_SHADER_FRAGMENT]->Source);
427 if (!program->_LinkedShaders[i])
429 gl_shader * shader = program->_LinkedShaders[i];
482 // if (strstr(program->Shaders[MESA_SHADER_FRAGMENT]->Source,
485 // for (unsigned i = 0; i < program->Attributes->NumParameters; i++) {
486 // const gl_program_parameter & attribute = program->Attributes->Parameters[i];
489 // for (unsigned i = 0; i < program->Varying->NumParameters; i++) {
490 // const gl_program_parameter & varying = program->Varying->Parameters[i];
493 // LOGD("%s", program->Shaders[MESA_SHADER_VERTEX]->Source);
521 GenerateScanLine(gglState, program, module, mainName, scanlineName);
522 CodeGen(instance, scanlineName, shader, program, gglState);
525 CodeGen(instance, mainName, shader, program, gglState);
540 static void ShaderUse(GGLInterface * iface, gl_shader_program * program)
543 // so drawing calls will do nothing until ShaderUse with a program
545 if (!program) {
550 GGLShaderUse(ctx->llvmCtx, &ctx->state, program);
552 if (!program->_LinkedShaders[i])
554 if (!program->_LinkedShaders[i]->function)
556 if (GL_VERTEX_SHADER == program->_LinkedShaders[i]->Type)
558 else if (GL_FRAGMENT_SHADER == program->_LinkedShaders[i]->Type)
563 ctx->CurrentProgram = program;
566 unsigned GGLShaderDetach(gl_shader_program * program, gl_shader * shader)
568 for (unsigned i = 0; i < program->NumShaders; i++)
569 if (program->Shaders[i] == shader) {
570 program->NumShaders--;
572 program->Shaders[i] = program->Shaders[program->NumShaders];
581 static void ShaderDetach(const GGLInterface * iface, gl_shader_program * program,
584 unsigned error = GGLShaderDetach(program, shader);
589 void GGLShaderProgramDelete(gl_shader_program * program)
591 for (unsigned i = 0; i < program->NumShaders; i++) {
592 GGLShaderDelete(program->Shaders[i]); // actually just mark for delete
593 GGLShaderDetach(program, program->Shaders[i]); // detach will delete if ref == 1
598 GGLShaderDelete(program->_LinkedShaders[i]);
600 hieralloc_free(program);
603 static void ShaderProgramDelete(GGLInterface * iface, gl_shader_program * program)
606 if (ctx->CurrentProgram == program) {
610 GGLShaderProgramDelete(program);
651 void GGLShaderProgramGetiv(const gl_shader_program_t * program, const GLenum pname, GLint * params)
655 *params = program->DeletePending;
658 *params = program->LinkStatus;
661 *params = program->LinkStatus;
664 *params = program->InfoLog ? strlen(program->InfoLog) + 1 : 0;
667 *params = program->NumShaders;
670 *params = program->AttributeSlots;
673 *params = program->Uniforms->Slots;
684 void GGLShaderProgramGetInfoLog(const gl_shader_program_t * program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
688 if (program->InfoLog)
690 len = strlen(program->InfoLog);
691 strncpy(infolog, program->InfoLog, bufsize);
698 void GGLShaderAttributeBind(const gl_shader_program * program, GLuint index, const GLchar * name)
700 int i = _mesa_add_parameter(program->Attributes, name);
701 program->Attributes->Parameters[i].BindLocation = index;
704 GLint GGLShaderAttributeLocation(const gl_shader_program * program, const char * name)
706 int i = _mesa_get_parameter(program->Attributes, name);
708 return program->Attributes->Parameters[i].Location;
712 GLint GGLShaderVaryingLocation(const gl_shader_program_t * program,
715 for (unsigned int i = 0; i < program->Varying->NumParameters; i++)
716 if (!strcmp(program->Varying->Parameters[i].Name, name)) {
718 *vertexOutputLocation = program->Varying->Parameters[i].BindLocation;
719 return program->Varying->Parameters[i].Location;
724 GLint GGLShaderUniformLocation(const gl_shader_program * program,
727 for (unsigned i = 0; i < program->Uniforms->NumUniforms; i++)
728 if (!strcmp(program->Uniforms->Uniforms[i].Name, name))
733 void GGLShaderUniformGetfv(gl_shader_program * program, GLint location, GLfloat * params)
735 assert(0 <= location && program->Uniforms->NumUniforms > location);
736 int index = program->Uniforms->Uniforms[location].Pos;
737 assert(0 <= index && program->Uniforms->Slots > index);
738 memcpy(params, program->ValuesUniform + index, sizeof(*program->ValuesUniform));
741 void GGLShaderUniformGetiv(gl_shader_program * program, GLint location, GLint * params)
743 assert(0 <= location && program->Uniforms->NumUniforms > location);
744 int index = program->Uniforms->Uniforms[location].Pos;
745 assert(0 <= index && program->Uniforms->Slots > index);
746 const float * uniform = program->ValuesUniform[index];
753 void GGLShaderUniformGetSamplers(const gl_shader_program_t * program,
756 // LOGD("%s", program->Shaders[MESA_SHADER_FRAGMENT]->Source);
757 // for (unsigned i = 0; i < program->Uniforms->Slots + program->Uniforms->SamplerSlots; i++)
758 // LOGD("%d: %.2f \t %.2f \t %.2f \t %.2f", i, program->ValuesUniform[i][0], program->ValuesUniform[i][1],
759 // program->ValuesUniform[i][2], program->ValuesUniform[i][3]);
762 for (unsigned i = 0; i < program->Uniforms->NumUniforms; i++) {
763 const gl_uniform & uniform = program->Uniforms->Uniforms[i];
765 // LOGD("%d uniform.Pos=%d tmu=%d", program->Uniforms->Slots, uniform.Pos, (int)program->ValuesUniform[program->Uniforms->Slots + uniform.Pos][0]);
766 sampler2tmu[uniform.Pos] = program->ValuesUniform[program->Uniforms->Slots + uniform.Pos][0];
772 GLint GGLShaderUniform(gl_shader_program * program, GLint location, GLsizei count,
777 if (!program) {
783 assert(0 <= location && program->Uniforms->NumUniforms > location);
784 const gl_uniform & uniform = program->Uniforms->Uniforms[location];
788 start = uniform.Pos + program->Uniforms->Slots;
790 program->ValuesUniform[start][0] = *(float *)values;
829 if (start + slots > program->Uniforms->Slots)
832 memcpy(program->ValuesUniform + start + i, values, elems * sizeof(float));
837 void GGLShaderUniformMatrix(gl_shader_program * program, GLint cols, GLint rows,
844 assert(0 <= location && program->Uniforms->NumUniforms > location);
845 int start = program->Uniforms->Uniforms[location].Pos;
847 if (start < 0 || start + slots > program->Uniforms->Slots)
850 float * column = program->ValuesUniform[start + i];
855 // if (!strstr(program->Shaders[MESA_SHADER_FRAGMENT]->Source,