Changeset 23403 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Timestamp:
- Sep 29, 2009 9:55:43 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c
r23402 r23403 738 738 } 739 739 pProgram->pUniforms[i].data = NULL; 740 pProgram->pUniforms[i].location = ((GL uint*)pCurrent)[0];741 pCurrent += sizeof(GL uint);740 pProgram->pUniforms[i].location = ((GLint*)pCurrent)[0]; 741 pCurrent += sizeof(GLint); 742 742 cbName = ((GLsizei*)pCurrent)[0]; 743 743 pCurrent += sizeof(GLsizei); … … 762 762 } 763 763 #else 764 static GLboolean crStateGLSLProgramCacheOneUniform(GLuint location, GLsizei cbName, GLchar *pName, 765 char **pCurrent, GLsizei *pcbWritten, GLsizei maxcbData) 766 { 767 *pcbWritten += sizeof(GLint)+sizeof(GLsizei)+cbName; 768 if (*pcbWritten>maxcbData) 769 { 770 crWarning("crStateGLSLProgramCacheUniforms: buffer too small"); 771 crFree(pName); 772 return GL_FALSE; 773 } 774 775 crDebug("crStateGLSLProgramCacheUniforms: uniform[%i]=%s.", location, pName); 776 777 ((GLint*)*pCurrent)[0] = location; 778 *pCurrent += sizeof(GLint); 779 ((GLsizei*)*pCurrent)[0] = cbName; 780 *pCurrent += sizeof(GLsizei); 781 crMemcpy(*pCurrent, pName, cbName); 782 *pCurrent += cbName; 783 784 return GL_TRUE; 785 } 786 764 787 DECLEXPORT(void) STATE_APIENTRY 765 788 crStateGLSLProgramCacheUniforms(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData) … … 795 818 if (activeUniforms>0) 796 819 { 797 /*+8 to make sure our array uniforms with higher indices will fit in as well*/820 /*+8 to make sure our array uniforms with higher indices and [] will fit in as well*/ 798 821 GLchar *name = (GLchar *) crAlloc(maxUniformLen+8); 799 822 GLenum type; 800 823 GLint size; 801 824 GLsizei cbName; 802 GL uint location;825 GLint location; 803 826 804 827 if (!name) … … 813 836 location = diff_api.GetUniformLocation(pProgram->hwid, name); 814 837 815 cbWritten += sizeof(GLuint)+sizeof(GLsizei)+cbName; 816 if (cbWritten>maxcbData) 817 { 818 crWarning("crStateGLSLProgramCacheUniforms: buffer too small"); 819 crFree(name); 838 if (!crStateGLSLProgramCacheOneUniform(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) 820 839 return; 821 }822 823 crDebug("crStateGLSLProgramCacheUniforms: uniform[%i]=%d, %s. size=%i", i, location, name, size);824 825 ((GLuint*)pCurrent)[0] = location;826 pCurrent += sizeof(GLuint);827 ((GLsizei*)pCurrent)[0] = cbName;828 pCurrent += sizeof(GLsizei);829 crMemcpy(pCurrent, name, cbName);830 pCurrent += cbName;831 840 832 841 /* Only one active uniform variable will be reported for a uniform array by glGetActiveUniform, … … 836 845 { 837 846 char *pIndexStr = crStrchr(name, '['); 838 fakeUniformsCount += size-1; 839 840 847 GLint firstIndex=1; 848 fakeUniformsCount += size; 849 850 crDebug("crStateGLSLProgramCacheUniforms: expanding array uniform, size=%i", size); 851 852 /*For array uniforms it's valid to query location of 1st element as both uniform and uniform[0]. 853 *The name returned by glGetActiveUniform is driver dependant, 854 *atleast it's with [0] on win/ati and without [0] on linux/nvidia. 855 */ 841 856 if (!pIndexStr) 842 857 { 843 crWarning("Array uniform name %s doesn't contain [!?", name); 858 pIndexStr = name+cbName; 859 firstIndex=0; 844 860 } 845 861 else 846 862 { 847 for (j=1; j<size; ++j) 848 { 849 sprintf(pIndexStr, "[%i]", j); 850 cbName = crStrlen(name); 851 852 location = diff_api.GetUniformLocation(pProgram->hwid, name); 853 crDebug("crStateGLSLProgramCacheUniforms: uniform[%i].[%i]=%d, %s", i, j, location, name); 854 855 cbWritten += sizeof(GLuint)+sizeof(GLsizei)+cbName; 856 if (cbWritten>maxcbData) 857 { 858 crWarning("crStateGLSLProgramCacheUniforms: buffer too small"); 859 crFree(name); 860 return; 861 } 862 863 ((GLuint*)pCurrent)[0] = location; 864 pCurrent += sizeof(GLuint); 865 ((GLsizei*)pCurrent)[0] = cbName; 866 pCurrent += sizeof(GLsizei); 867 crMemcpy(pCurrent, name, cbName); 868 pCurrent += cbName; 869 } 863 cbName = pIndexStr-name; 864 if (!crStateGLSLProgramCacheOneUniform(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) 865 return; 866 } 867 868 for (j=firstIndex; j<size; ++j) 869 { 870 sprintf(pIndexStr, "[%i]", j); 871 cbName = crStrlen(name); 872 873 location = diff_api.GetUniformLocation(pProgram->hwid, name); 874 875 if (!crStateGLSLProgramCacheOneUniform(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) 876 return; 870 877 } 871 878 }
Note:
See TracChangeset
for help on using the changeset viewer.