Changeset 23433 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
- Timestamp:
- Sep 30, 2009 11:38:45 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c
r23399 r23433 26 26 #include "cr_mem.h" 27 27 #include "cr_string.h" 28 #include <stdio.h> 28 29 29 30 #include <iprt/assert.h> … … 689 690 int32_t rc; 690 691 uint32_t ui32; 691 GLint maxUniformLen, activeUniforms=0, i; 692 GLint maxUniformLen, activeUniforms=0, uniformsCount=0, i, j; 693 GLchar *name; 694 GLenum type; 695 GLint size, location; 692 696 693 697 rc = SSMR3PutMem(pSSM, &key, sizeof(key)); … … 717 721 diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_UNIFORMS, &activeUniforms); 718 722 719 rc = SSMR3PutS32(pSSM, activeUniforms);720 CRASSERT(rc == VINF_SUCCESS);721 722 723 if (activeUniforms>0) 723 724 { 724 GLchar *name = (GLchar *) crAlloc(maxUniformLen*sizeof(GLchar)); 725 name = (GLchar *) crAlloc((maxUniformLen+8)*sizeof(GLchar)); 726 727 if (!name) 728 { 729 crWarning("crStateSaveGLSLProgramCB: out of memory"); 730 return; 731 } 732 } 733 734 for (i=0; i<activeUniforms; ++i) 735 { 736 diff_api.GetActiveUniform(pProgram->hwid, i, maxUniformLen, NULL, &size, &type, name); 737 uniformsCount += size; 738 } 739 CRASSERT(uniformsCount>=activeUniforms); 740 741 rc = SSMR3PutS32(pSSM, uniformsCount); 742 CRASSERT(rc == VINF_SUCCESS); 743 744 if (activeUniforms>0) 745 { 725 746 GLfloat fdata[16]; 726 747 GLint idata[16]; 727 GLenum type; 728 GLint size; 748 char *pIndexStr=NULL; 729 749 730 750 for (i=0; i<activeUniforms; ++i) … … 732 752 diff_api.GetActiveUniform(pProgram->hwid, i, maxUniformLen, NULL, &size, &type, name); 733 753 734 /*@todo check if we'd reference all array elements or not*/ 735 /*crap it fails as expected*/ 736 if (size!=1) crWarning("@todo"); 737 738 rc = SSMR3PutMem(pSSM, &type, sizeof(type)); 739 CRASSERT(rc == VINF_SUCCESS); 740 741 crStateSaveString(name, pSSM); 754 if (size>1) 755 { 756 pIndexStr = crStrchr(name, '['); 757 if (!pIndexStr) 758 { 759 pIndexStr = name+crStrlen(name); 760 } 761 } 762 763 for (j=0; j<size; ++j) 764 { 765 if (size>1) 766 { 767 sprintf(pIndexStr, "[%i]", j); 768 location = diff_api.GetUniformLocation(pProgram->hwid, name); 769 } 770 else 771 { 772 location = i; 773 } 774 775 rc = SSMR3PutMem(pSSM, &type, sizeof(type)); 776 CRASSERT(rc == VINF_SUCCESS); 777 778 crStateSaveString(name, pSSM); 742 779 743 if (GL_INT==type 744 || GL_INT_VEC2==type 745 || GL_INT_VEC3==type 746 || GL_INT_VEC4==type 747 || GL_BOOL==type 748 || GL_BOOL_VEC2==type 749 || GL_BOOL_VEC3==type 750 || GL_BOOL_VEC4==type 751 || GL_SAMPLER_1D==type 752 || GL_SAMPLER_2D==type 753 || GL_SAMPLER_3D==type 754 || GL_SAMPLER_CUBE==type 755 || GL_SAMPLER_1D_SHADOW==type 756 || GL_SAMPLER_2D_SHADOW==type) 757 { 758 diff_api.GetUniformiv(pProgram->hwid, i, &idata[0]); 759 rc = SSMR3PutMem(pSSM, &idata[0], crStateGetUniformSize(type)*sizeof(idata[0])); 760 CRASSERT(rc == VINF_SUCCESS); 761 } 762 else 763 { 764 diff_api.GetUniformfv(pProgram->hwid, i, &fdata[0]); 765 rc = SSMR3PutMem(pSSM, &fdata[0], crStateGetUniformSize(type)*sizeof(fdata[0])); 766 CRASSERT(rc == VINF_SUCCESS); 780 if (crStateIsIntUniform(type)) 781 { 782 diff_api.GetUniformiv(pProgram->hwid, location, &idata[0]); 783 rc = SSMR3PutMem(pSSM, &idata[0], crStateGetUniformSize(type)*sizeof(idata[0])); 784 CRASSERT(rc == VINF_SUCCESS); 785 } 786 else 787 { 788 diff_api.GetUniformfv(pProgram->hwid, location, &fdata[0]); 789 rc = SSMR3PutMem(pSSM, &fdata[0], crStateGetUniformSize(type)*sizeof(fdata[0])); 790 CRASSERT(rc == VINF_SUCCESS); 791 } 767 792 } 768 793 } … … 1633 1658 pProgram->pUniforms[k].name = crStateLoadString(pSSM); 1634 1659 1635 if (GL_INT==pProgram->pUniforms[k].type 1636 || GL_INT_VEC2==pProgram->pUniforms[k].type 1637 || GL_INT_VEC3==pProgram->pUniforms[k].type 1638 || GL_INT_VEC4==pProgram->pUniforms[k].type 1639 || GL_BOOL==pProgram->pUniforms[k].type 1640 || GL_BOOL_VEC2==pProgram->pUniforms[k].type 1641 || GL_BOOL_VEC3==pProgram->pUniforms[k].type 1642 || GL_BOOL_VEC4==pProgram->pUniforms[k].type 1643 || GL_SAMPLER_1D==pProgram->pUniforms[k].type 1644 || GL_SAMPLER_2D==pProgram->pUniforms[k].type 1645 || GL_SAMPLER_3D==pProgram->pUniforms[k].type 1646 || GL_SAMPLER_CUBE==pProgram->pUniforms[k].type 1647 || GL_SAMPLER_1D_SHADOW==pProgram->pUniforms[k].type 1648 || GL_SAMPLER_2D_SHADOW==pProgram->pUniforms[k].type) 1660 if (crStateIsIntUniform(pProgram->pUniforms[k].type)) 1649 1661 { 1650 1662 itemsize = sizeof(GLint);
Note:
See TracChangeset
for help on using the changeset viewer.