Changeset 23162 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Sep 20, 2009 10:02:28 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 52579
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp
r22953 r23162 933 933 } 934 934 935 class VBoxVHWAGlShader 935 class VBoxVHWAGlShaderComponent 936 936 { 937 937 public: 938 VBoxVHWAGlShader(const char *aRcName, GLenum aType) : 939 mShader(0), 938 VBoxVHWAGlShaderComponent(const char *aRcName, GLenum aType) : 940 939 mRcName(aRcName), 941 mType(aType) 940 mType(aType), 941 mInitialized(false) 942 942 {} 943 943 944 // virtual ~VBoxVHWAGlShader(); 944 // virtual ~VBoxVHWAGlShaderComponent(); 945 945 946 946 947 int init(); 947 948 // virtual int initUniforms(class VBoxVHWAGlProgram * pProgram){} 948 void uninit(); 949 bool isInitialized() { return mShader; } 950 GLuint shader() {return mShader;} 949 // void uninit(); 950 951 const char * contents() { return mSource.constData(); } 952 bool isInitialized() { return mInitialized; } 951 953 private: 952 GLuint mShader;953 954 const char *mRcName; 954 955 GLenum mType; 956 QByteArray mSource; 957 bool mInitialized; 955 958 }; 956 959 957 int VBoxVHWAGlShader ::init()960 int VBoxVHWAGlShaderComponent::init() 958 961 { 959 962 // Assert(!isInitialized()); … … 971 974 QString program = is.readAll(); 972 975 976 mSource = program.toAscii(); 977 978 mInitialized = true; 979 return VINF_SUCCESS; 980 } 981 982 class VBoxVHWAGlShader 983 { 984 public: 985 VBoxVHWAGlShader() : 986 mType(GL_FRAGMENT_SHADER), 987 mcComponents(0) 988 {} 989 990 VBoxVHWAGlShader & operator= (const VBoxVHWAGlShader & other) 991 { 992 mcComponents = other.mcComponents; 993 mType = other.mType; 994 if(mcComponents) 995 { 996 maComponents = new VBoxVHWAGlShaderComponent*[mcComponents]; 997 memcpy(maComponents, other.maComponents, mcComponents * sizeof(maComponents[0])); 998 } 999 return *this; 1000 } 1001 1002 VBoxVHWAGlShader(const VBoxVHWAGlShader & other) 1003 { 1004 mcComponents = other.mcComponents; 1005 mType = other.mType; 1006 if(mcComponents) 1007 { 1008 maComponents = new VBoxVHWAGlShaderComponent*[mcComponents]; 1009 memcpy(maComponents, other.maComponents, mcComponents * sizeof(maComponents[0])); 1010 } 1011 } 1012 1013 VBoxVHWAGlShader(GLenum aType, VBoxVHWAGlShaderComponent ** aComponents, int cComponents) 1014 : mType(aType) 1015 { 1016 maComponents = new VBoxVHWAGlShaderComponent*[cComponents]; 1017 mcComponents = cComponents; 1018 memcpy(maComponents, aComponents, cComponents * sizeof(maComponents[0])); 1019 } 1020 1021 ~VBoxVHWAGlShader() {delete[] maComponents;} 1022 int init(); 1023 GLenum type() { return mType; } 1024 GLuint shader() { return mShader; } 1025 private: 1026 GLenum mType; 1027 GLuint mShader; 1028 VBoxVHWAGlShaderComponent ** maComponents; 1029 int mcComponents; 1030 }; 1031 1032 int VBoxVHWAGlShader::init() 1033 { 1034 int rc; 1035 int *length; 1036 const char **sources; 1037 length = new int[mcComponents]; 1038 sources = new const char*[mcComponents]; 1039 for(int i = 0; i < mcComponents; i++) 1040 { 1041 length[i] = -1; 1042 rc = maComponents[i]->init(); 1043 Assert(RT_SUCCESS(rc)); 1044 if(RT_FAILURE(rc)) 1045 return rc; 1046 sources[i] = maComponents[i]->contents(); 1047 } 1048 1049 #ifdef DEBUG 1050 VBOXQGLLOG(("\ncompiling shaders:\n------------\n")); 1051 for(int i = 0; i < mcComponents; i++) 1052 { 1053 VBOXQGLLOG(("**********\n%s\n***********\n", sources[i])); 1054 } 1055 VBOXQGLLOG(("------------\n")); 1056 #endif 973 1057 mShader = vboxglCreateShader(mType); 974 Assert(mShader);975 if(!mShader)976 return VERR_GENERAL_FAILURE;977 978 // int length = program.length();979 QByteArray asciiStr = program.toAscii();980 const char * contents = asciiStr.constData();981 GLint length = -1;982 1058 983 1059 VBOXQGL_CHECKERR( 984 vboxglShaderSource(mShader, 1, &contents, &length);1060 vboxglShaderSource(mShader, mcComponents, sources, length); 985 1061 ); 986 1062 … … 997 1073 GLchar * pBuf = new GLchar[16300]; 998 1074 vboxglGetShaderInfoLog(mShader, 16300, NULL, pBuf); 999 VBOXQGLLOG(("compile log for shader:\n-----------\n%s\n---------\n", contents)); 1000 VBOXQGLLOG(("%s\n**********\n", pBuf)); 1075 VBOXQGLLOG(("\ncompile log:\n-----------\n%s\n---------\n", pBuf)); 1001 1076 delete pBuf; 1002 1077 #endif … … 1007 1082 return VINF_SUCCESS; 1008 1083 } 1009 1010 1084 1011 1085 … … 1014 1088 ); 1015 1089 mShader = 0; 1090 1091 delete[] length; 1092 delete[] sources; 1016 1093 return VERR_GENERAL_FAILURE; 1017 }1018 1019 void VBoxVHWAGlShader::uninit()1020 {1021 if(!isInitialized())1022 return;1023 1024 VBOXQGL_CHECKERR(1025 vboxglDeleteShader(mShader);1026 );1027 mShader = 0;1028 1094 } 1029 1095 … … 1043 1109 private: 1044 1110 GLuint mProgram; 1045 VBoxVHWAGlShader * * mpShaders;1111 VBoxVHWAGlShader *mShaders; 1046 1112 int mcShaders; 1047 1113 }; … … 1049 1115 VBoxVHWAGlProgram::VBoxVHWAGlProgram(VBoxVHWAGlShader ** apShaders, int acShaders) : 1050 1116 mProgram(0), 1051 mpShaders(NULL),1052 1117 mcShaders(0) 1053 1118 { … … 1055 1120 if(acShaders) 1056 1121 { 1057 mpShaders = (VBoxVHWAGlShader **)malloc(sizeof(VBoxVHWAGlShader *) * acShaders); 1058 memcpy(mpShaders, apShaders, sizeof(VBoxVHWAGlShader *) * acShaders); 1122 mShaders = new VBoxVHWAGlShader[acShaders]; 1123 for(int i = 0; i < acShaders; i++) 1124 { 1125 mShaders[i] = *apShaders[i]; 1126 } 1059 1127 mcShaders = acShaders; 1060 1128 } … … 1065 1133 uninit(); 1066 1134 1067 if(m pShaders)1068 { 1069 free(mpShaders);1135 if(mShaders) 1136 { 1137 delete[] mShaders; 1070 1138 } 1071 1139 } … … 1084 1152 for(int i = 0; i < mcShaders; i++) 1085 1153 { 1086 int rc = m pShaders[i]->init();1154 int rc = mShaders[i].init(); 1087 1155 Assert(RT_SUCCESS(rc)); 1088 1156 if(RT_FAILURE(rc)) … … 1103 1171 { 1104 1172 VBOXQGL_CHECKERR( 1105 vboxglAttachShader(mProgram, m pShaders[i]->shader());1173 vboxglAttachShader(mProgram, mShaders[i].shader()); 1106 1174 ); 1107 1175 } … … 1476 1544 ProgramList mPrograms; 1477 1545 1478 VBoxVHWAGlShader mShaderCConvApplyAYUV;1479 1480 VBoxVHWAGlShader mShaderCConvAYUV;1481 // VBoxVHWAGlShader mShaderCConvAYUVVoid;1482 VBoxVHWAGlShader mShaderCConvBGR;1483 // VBoxVHWAGlShader mShaderCConvBGRVoid;1484 VBoxVHWAGlShader mShaderCConvUYVY;1485 // VBoxVHWAGlShader mShaderCConvUYVYVoid;1486 VBoxVHWAGlShader mShaderCConvYUY2;1487 // VBoxVHWAGlShader mShaderCConvYUY2Void;1488 VBoxVHWAGlShader mShaderCConvYV12;1489 // VBoxVHWAGlShader mShaderCConvYV12Void;1490 VBoxVHWAGlShader mShaderSplitBGRA;1546 VBoxVHWAGlShaderComponent mShaderCConvApplyAYUV; 1547 1548 VBoxVHWAGlShaderComponent mShaderCConvAYUV; 1549 // VBoxVHWAGlShaderComponent mShaderCConvAYUVVoid; 1550 VBoxVHWAGlShaderComponent mShaderCConvBGR; 1551 // VBoxVHWAGlShaderComponent mShaderCConvBGRVoid; 1552 VBoxVHWAGlShaderComponent mShaderCConvUYVY; 1553 // VBoxVHWAGlShaderComponent mShaderCConvUYVYVoid; 1554 VBoxVHWAGlShaderComponent mShaderCConvYUY2; 1555 // VBoxVHWAGlShaderComponent mShaderCConvYUY2Void; 1556 VBoxVHWAGlShaderComponent mShaderCConvYV12; 1557 // VBoxVHWAGlShaderComponent mShaderCConvYV12Void; 1558 VBoxVHWAGlShaderComponent mShaderSplitBGRA; 1491 1559 1492 1560 /* expected the dst surface texture to be bound to the 1-st tex unit */ 1493 VBoxVHWAGlShader mShaderCKeyDst;1561 VBoxVHWAGlShaderComponent mShaderCKeyDst; 1494 1562 /* expected the dst surface texture to be bound to the 2-nd tex unit */ 1495 VBoxVHWAGlShader mShaderCKeyDst2;1496 // VBoxVHWAGlShader mShaderCKeyDstVoid;1497 // VBoxVHWAGlShader mShaderCKeySrc;1498 // VBoxVHWAGlShader mShaderCKeySrcVoid;1499 1500 VBoxVHWAGlShader mShaderMainOverlay;1501 VBoxVHWAGlShader mShaderMainOverlayNoCKey;1563 VBoxVHWAGlShaderComponent mShaderCKeyDst2; 1564 // VBoxVHWAGlShaderComponent mShaderCKeyDstVoid; 1565 // VBoxVHWAGlShaderComponent mShaderCKeySrc; 1566 // VBoxVHWAGlShaderComponent mShaderCKeySrcVoid; 1567 1568 VBoxVHWAGlShaderComponent mShaderMainOverlay; 1569 VBoxVHWAGlShaderComponent mShaderMainOverlayNoCKey; 1502 1570 1503 1571 friend class VBoxVHWAGlProgramVHWA; … … 1506 1574 VBoxVHWAGlProgramVHWA * VBoxVHWAGlProgramMngr::createProgram(uint32_t type, uint32_t fourcc) 1507 1575 { 1508 VBoxVHWAGlShader * apShaders[16];1576 VBoxVHWAGlShaderComponent * apShaders[16]; 1509 1577 uint32_t cShaders = 0; 1510 1578 … … 1587 1655 Assert(cShaders <= RT_ELEMENTS(apShaders)); 1588 1656 1589 VBoxVHWAGlProgramVHWA *pProgram = new VBoxVHWAGlProgramVHWA(/*this, */type, fourcc, apShaders, cShaders); 1657 VBoxVHWAGlShader shader(GL_FRAGMENT_SHADER, apShaders, cShaders); 1658 VBoxVHWAGlShader *pShader = &shader; 1659 1660 VBoxVHWAGlProgramVHWA *pProgram = new VBoxVHWAGlProgramVHWA(/*this, */type, fourcc, &pShader, 1); 1590 1661 pProgram->init(); 1591 1662
Note:
See TracChangeset
for help on using the changeset viewer.