I am a beginner in OpenGL. I am learning about textures in OpenGL. What I don't understand is how to determine how many texture units are in the GPU. I heard someone said that you can see how many texture units by writing the following code.
int total_units;
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &total_units);
std::cout << total_units << '\n'; // the result is 192
Is there 192 texture units in my GPU? In documentation, it says:
GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS params returns one value, the maximum supported texture image units that can be used to access texture maps from the vertex shader and the fragment processor combined. If both the vertex shader and the fragment processing stage access the same texture image unit, then that counts as using two texture image units against this limit. The value must be at least 48. See glActiveTexture.
So I wanted to know how many texture units can be used to access texture maps from the vertex and fragment shaders. So I wrote and run the following code.
int vertex_units, fragment_units;
glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &vertex_units);
std::cout << vertex_units << "\n"; // the result is 32
glGetInteferv(GL_MAX_TEXTURE_IMAGE_UNITS, &fragment_units);
std::cout << fragment_units << "\n"; // the result is also 32
So 32+32=64. But why does GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
shows me the result of 192? I think I am missing something. What do I need to calculate to get 192?
And also, in OpenGL, why are there only GL_TEXTURE0
to GL_TEXTURE31
macros? I think these macros are for each shaders. Am I right?