st/mesa: program struct comments
[mesa.git] / src / mesa / state_tracker / st_atom_constbuf.c
index 6f9d71e845b2909ba6b36bc9e76e4414812da1ae..f1d08a3e1665e5cdb118eec3c6828193a686e971 100644 (file)
@@ -66,6 +66,11 @@ void st_upload_constants( struct st_context *st,
    if (params && params->NumParameters) {
       const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4;
 
+      /* Update the constants which come from fixed-function state, such as
+       * transformation matrices, fog factors, etc.  The rest of the values in
+       * the parameters list are explicitly set by the user with glUniform,
+       * glProgramParameter(), etc.
+       */
       _mesa_load_state_parameters(st->ctx, params);
 
       /* We always need to get a new buffer, to keep the drivers simple and
@@ -90,8 +95,11 @@ void st_upload_constants( struct st_context *st,
 
       st->pipe->set_constant_buffer(st->pipe, shader_type, 0, *cbuf);
    }
-   else {
+   else if (*cbuf) {
       st->constants.tracked_state[shader_type].dirty.mesa = 0x0;
+
+      pipe_resource_reference(cbuf, NULL);
+      st->pipe->set_constant_buffer(st->pipe, shader_type, 0, NULL);
    }
 }