ztellman / penumbra

not under active development - idiomatic opengl bindings for clojure
354 stars 43 forks source link

create-program fails when validating a shader with samplers of different types #32

Closed snoury closed 8 years ago

snoury commented 14 years ago

The create-program method calls gl-validate-program after shader compilation but fails when a shader is defined with samplers of different types because no texture units have been assigned to them before validation (in src/penumbra/opengl/shader.clj, line 183).

According to the OpenGL documentation for glValidateProgram, this is considered as an error:

This function mimics the validation operation that OpenGL implementations must perform when rendering commands are issued while programmable shaders are part of current state. The error GL_INVALID_OPERATION will be generated by glBegin, glRasterPos, or any command that performs an implicit call to glBegin if: any two active samplers in the current program object are of different types, but refer to the same texture image unit, any active sampler in the current program object refers to a texture image unit where fixed-function fragment processing accesses a texture target that does not match the sampler type [...]

The behavior of glValidateProgram seems to be varying between OS and driver vendors. It doesn't report any errors using Nvidia's driver for Linux but fails with Apple's Mac OS X driver:

*\ Error validating program: Validation Failed: Sampler error: Samplers of different types use the same texture image unit.

  • or - A sampler's texture unit is out of range (greater than max allowed or negative).

An optional list of textures could be passed when calling create-program in order to bind them just before the validation, in the same fashion as the uniform method.

ztellman commented 14 years ago

It seems like gl-validate-program should just be delayed until the program is about to be executed (though only the first time). I'll take a look at it.

giantchen2012 commented 9 years ago

you video/graphic card is not support the feature you used in OpenGL,you can switch to a graphic card that supports the feature you use in system settings,or change a graphic card to support it,hope to be helpful.