An oft requested feature since OpenGL 2.1. Right now, OpenGL treats sampler state as part of the texture object. This is *not* how the hardware works and makes specific algorithms inefficient (those that require different sampling states for the same texture).
Code :// Preferred glSamplerParameter(GL_SAMPLER0, GL_SAMPLER_MAG_FILTER, ...); glSamplerTexture(GL_SAMPLER0, tex_id); glGetSamplerParameter(GL_SAMPLER0, ...); // following current bind-to-edit semantics (worse): glBindSampler(GL_SAMPLER0); glSamplerParameter(...); glSamplerTexture(tex_id); glGetSamplerParamater(GL_SAMPLER_MAG_FILTER, ...); glBindSampler(0);
Alternatively, replace Sampler by TexUnit and SAMPLERi by the existing TEXTURE_UNITi tokens:
Code :// Following current OpenGL naming conventions: glTexUnitParameter(GL_TEXTURE_UNIT0, GL_TEXTURE_MAG_FILTER, ...); glTexUnitTexture(GL_TEXTURE_UNIT0, tex_id); glGetTexUnitParameter(GL_TEXTURE_UNIT0, ...);
glActiveTexture and glTexParameter tokens that set sampler state will be deprecated.
Backwards compatibility can be maintained:
1. using a new version profile
2. specifying that glTexParameter will be ignored when the relevant texture is bound to a sampler with glSamplerTexture. Old applications (using glActiveTexture) will continue to use glTexParameter and ignore glSamplerParameter.
1. "Sampler" or "TexUnit"? My personal preference is the latter, as it follows existing OpenGL naming conventions.
2. Use bind-to-edit semantics? ActiveTexture is not bind-to-edit, so it would be best to define the new API to *not* use bind-to-edit.
3. "TexUnitTexture" function - the name is ugly. We could reuse the ActiveTexture entry point but this is going to be nasty both for driver developers and users (backwards compatibility).
Other thoughts, questions, ideas? Any chance we will see something like this in OpenGL 3.3?