~mmach/netext73/mesa_2004

« back to all changes in this revision

Viewing changes to src/mesa/main/glthread_shaderobj.c

  • Committer: mmach
  • Date: 2021-03-12 20:48:59 UTC
  • Revision ID: netbit73@gmail.com-20210312204859-i194ujlcu82pq61p
21

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "glthread_marshal.h"
25
25
#include "dispatch.h"
 
26
#include "uniforms.h"
26
27
 
27
28
struct marshal_cmd_ShaderSource
28
29
{
113
114
   }
114
115
   free(length_tmp);
115
116
}
 
117
 
 
118
void
 
119
_mesa_glthread_ProgramChanged(struct gl_context *ctx)
 
120
{
 
121
   struct glthread_state *glthread = &ctx->GLThread;
 
122
 
 
123
   /* Track the last change. */
 
124
   p_atomic_set(&glthread->LastProgramChangeBatch, glthread->next);
 
125
   _mesa_glthread_flush_batch(ctx);
 
126
}
 
127
 
 
128
void
 
129
_mesa_unmarshal_GetActiveUniform(struct gl_context *ctx,
 
130
                                 const struct marshal_cmd_GetActiveUniform *cmd)
 
131
{
 
132
   unreachable("never executed");
 
133
}
 
134
 
 
135
void GLAPIENTRY
 
136
_mesa_marshal_GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize,
 
137
                               GLsizei *length, GLint *size, GLenum *type,
 
138
                               GLchar * name)
 
139
{
 
140
   GET_CURRENT_CONTEXT(ctx);
 
141
 
 
142
   /* Wait for the last glLinkProgram call. */
 
143
   int batch = p_atomic_read(&ctx->GLThread.LastProgramChangeBatch);
 
144
   if (batch != -1) {
 
145
      util_queue_fence_wait(&ctx->GLThread.batches[batch].fence);
 
146
      assert(p_atomic_read(&ctx->GLThread.LastProgramChangeBatch) == -1);
 
147
   }
 
148
 
 
149
   /* We can execute glGetActiveUniform without syncing if we are sync'd to
 
150
    * the last calls of glLinkProgram and glDeleteProgram because shader
 
151
    * object IDs and their contents are immutable after those calls and
 
152
    * also thread-safe because they are shared between contexts.
 
153
    * glCreateShaderProgram calls glLinkProgram internally and it always
 
154
    * syncs, so it doesn't need any handling.
 
155
    */
 
156
   _mesa_GetActiveUniform_impl(program, index, bufSize, length, size, type,
 
157
                               name, true);
 
158
}