glDrawElements GL_INVALID_OPERATION on AMD GPU

Started by
6 comments, last by congard 4 years, 5 months ago
Advertisement

Solved! The problem was that AMD required array of samplers to be filled. I had implemented workaround earlier, but because of the typo that I made when renaming macros, everything broke. Code for workaround:

#define pointLampsCount 1
#define dirLampsCount 1
#define pointLightsLimit 8
#define dirLightsLimit 8
// point light texture start id
#define POINT_LIGHT_TSID 6
// dir light texture start id
#define DIR_LIGHT_TSID POINT_LIGHT_TSID + pointLightsLimit // HERE was typo: instead of pointLightsLimit was pointLampsCount!

void fillArraysOfSamplers() {
  colorShader->use();

  for (int i = 0; i < pointLightsLimit; i++) {
    ShaderProgram::set(lightDataSetter.getLocation(LightDataSetter::ShadowMap, Light::TypePointLight, i), POINT_LIGHT_TSID + i);
		glActiveTexture(GL_TEXTURE0 + POINT_LIGHT_TSID + i);
		glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
  }
  
  for (int i = 0; i < dirLightsLimit; i++) {
    ShaderProgram::set(lightDataSetter.getLocation(LightDataSetter::ShadowMap, Light::TypeDirLight, i), DIR_LIGHT_TSID + i);
		glActiveTexture(GL_TEXTURE0 + DIR_LIGHT_TSID + i);
		glBindTexture(GL_TEXTURE_2D, 0);
  }
  
  glUseProgram(0);
}

This topic is closed to new replies.

Advertisement