| 794 | } |
| 795 | |
| 796 | void GLSLReflection::ReflectSubroutineUniforms(GLenum programInterface, |
| 797 | std::vector<SubroutineUniform>& subUniforms) |
| 798 | { |
| 799 | GLint numResources = 0; |
| 800 | glGetProgramInterfaceiv(mHandle, programInterface, GL_ACTIVE_RESOURCES, &numResources); |
| 801 | |
| 802 | if (numResources > 0) |
| 803 | { |
| 804 | subUniforms.resize(numResources); |
| 805 | |
| 806 | enum |
| 807 | { |
| 808 | IDX_NAME_LENGTH, |
| 809 | IDX_LOCATION, |
| 810 | IDX_ARRAY_SIZE, |
| 811 | IDX_NUM_ACTIVE_VARIABLES |
| 812 | }; |
| 813 | |
| 814 | std::vector<GLenum> const properties = |
| 815 | { |
| 816 | GL_NAME_LENGTH, |
| 817 | GL_LOCATION, |
| 818 | GL_ARRAY_SIZE, |
| 819 | GL_NUM_ACTIVE_VARIABLES |
| 820 | }; |
| 821 | |
| 822 | GLsizei const numProperties = static_cast<GLsizei>(properties.size()); |
| 823 | |
| 824 | std::vector<GLint> results(properties.size(), 0); |
| 825 | for (int32_t i = 0; i < numResources; ++i) |
| 826 | { |
| 827 | glGetProgramResourceiv(mHandle, programInterface, i, numProperties, |
| 828 | properties.data(), numProperties, nullptr, results.data()); |
| 829 | |
| 830 | GLsizei const numBytes = static_cast<GLsizei>(results[IDX_NAME_LENGTH] + 1); |
| 831 | std::vector<GLchar> name(numBytes); |
| 832 | glGetProgramResourceName(mHandle, programInterface, i, numBytes, |
| 833 | nullptr, name.data()); |
| 834 | |
| 835 | SubroutineUniform& info = subUniforms[i]; |
| 836 | info.name = std::string(name.data()); |
| 837 | info.location = results[IDX_NAME_LENGTH]; |
| 838 | info.arraySize = results[IDX_ARRAY_SIZE]; |
| 839 | |
| 840 | GLint numCompatibleSubroutines = results[IDX_NUM_ACTIVE_VARIABLES]; |
| 841 | if (numCompatibleSubroutines > 0) |
| 842 | { |
| 843 | info.compatibleSubroutines.resize(numCompatibleSubroutines); |
| 844 | std::fill(info.compatibleSubroutines.begin(), info.compatibleSubroutines.end(), 0); |
| 845 | GLenum subProperty = GL_COMPATIBLE_SUBROUTINES; |
| 846 | glGetProgramResourceiv(mHandle, programInterface, i, 1, &subProperty, |
| 847 | numCompatibleSubroutines, nullptr, &info.compatibleSubroutines[0]); |
| 848 | } |
| 849 | } |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | void GLSLReflection::ReflectBufferVariables() |
nothing calls this directly
no test coverage detected