invalid_stream_id(0),
invalid_stream_id_from_emit_vertex(false),
end_primitive_found(false),
- uses_non_zero_stream(false)
+ used_streams(0)
{
/* empty */
}
return visit_stop;
}
- if (stream_id != 0)
- uses_non_zero_stream = true;
+ used_streams |= 1 << stream_id;
return visit_continue;
}
return visit_stop;
}
- if (stream_id != 0)
- uses_non_zero_stream = true;
+ used_streams |= 1 << stream_id;
return visit_continue;
}
return invalid_stream_id;
}
- bool uses_streams()
+ unsigned active_stream_mask()
{
- return uses_non_zero_stream;
+ return used_streams;
}
bool uses_end_primitive()
int invalid_stream_id;
bool invalid_stream_id_from_emit_vertex;
bool end_primitive_found;
- bool uses_non_zero_stream;
+ unsigned used_streams;
};
/* Class that finds array derefs and check if indexes are dynamic. */
emit_vertex.error_stream(),
ctx->Const.MaxVertexStreams - 1);
}
- prog->Geom.UsesStreams = emit_vertex.uses_streams();
+ prog->Geom.ActiveStreamMask = emit_vertex.active_stream_mask();
prog->Geom.UsesEndPrimitive = emit_vertex.uses_end_primitive();
/* From the ARB_gpu_shader5 spec:
* Since we can call EmitVertex() and EndPrimitive() when we output
* primitives other than points, calling EmitStreamVertex(0) or
* EmitEndPrimitive(0) should not produce errors. This it also what Nvidia
- * does. Currently we only set prog->Geom.UsesStreams to TRUE when
- * EmitStreamVertex() or EmitEndPrimitive() are called with a non-zero
+ * does. We can use prog->Geom.ActiveStreamMask to check whether only the
+ * first (zero) stream is active.
* stream.
*/
- if (prog->Geom.UsesStreams &&
+ if (prog->Geom.ActiveStreamMask & ~(1 << 0) &&
sh->Program->info.gs.output_primitive != GL_POINTS) {
linker_error(prog, "EmitStreamVertex(n) and EndStreamPrimitive(n) "
"with n>0 requires point output\n");
* no vendor actually implemented that behavior. The 4.20
* behavior matches the implemented behavior of at least one other
* vendor, so we'll implement that for all GLSL versions.
+ * If (at least) one of these constant expressions is implicit,
+ * because it was added by glsl_zero_init, we skip the verification.
*/
if (var->constant_initializer != NULL) {
- if (existing->constant_initializer != NULL) {
+ if (existing->constant_initializer != NULL &&
+ !existing->data.is_implicit_initializer &&
+ !var->data.is_implicit_initializer) {
if (!var->constant_initializer->has_value(existing->constant_initializer)) {
linker_error(prog, "initializers for %s "
"`%s' have differing values\n",
* not have an initializer but a later instance does,
* replace the former with the later.
*/
- variables->replace_variable(existing->name, var);
+ if (!var->data.is_implicit_initializer)
+ variables->replace_variable(existing->name, var);
}
}
/* Create program and attach it to the linked shader */
struct gl_program *gl_prog =
- ctx->Driver.NewProgram(ctx,
- _mesa_shader_stage_to_program(shader_list[0]->Stage),
- prog->Name, false);
+ ctx->Driver.NewProgram(ctx, shader_list[0]->Stage, prog->Name, false);
if (!gl_prog) {
prog->data->LinkStatus = LINKING_FAILURE;
_mesa_delete_linked_shader(ctx, linked);
for (unsigned i = 0; i < num_ubo_blocks; i++) {
linked->Program->sh.UniformBlocks[i] = &ubo_blocks[i];
}
+ linked->Program->sh.NumUniformBlocks = num_ubo_blocks;
linked->Program->info.num_ubos = num_ubo_blocks;
/* Copy ssbo blocks to linked shader list */
link_and_validate_uniforms(struct gl_context *ctx,
struct gl_shader_program *prog)
{
- update_array_sizes(prog);
+ assert(!ctx->Const.UseNIRGLSLLinker);
- if (!ctx->Const.UseNIRGLSLLinker) {
- link_assign_uniform_locations(prog, ctx);
+ update_array_sizes(prog);
+ link_assign_uniform_locations(prog, ctx);
- if (prog->data->LinkStatus == LINKING_FAILURE)
- return;
+ if (prog->data->LinkStatus == LINKING_FAILURE)
+ return;
- link_util_calculate_subroutine_compat(prog);
- link_util_check_uniform_resources(ctx, prog);
- link_util_check_subroutine_resources(prog);
- check_image_resources(ctx, prog);
- link_assign_atomic_counter_resources(ctx, prog);
- link_check_atomic_counter_resources(ctx, prog);
- }
+ link_util_calculate_subroutine_compat(prog);
+ link_util_check_uniform_resources(ctx, prog);
+ link_util_check_subroutine_resources(prog);
+ check_image_resources(ctx, prog);
+ link_assign_atomic_counter_resources(ctx, prog);
+ link_check_atomic_counter_resources(ctx, prog);
}
static bool
if (!link_varyings(prog, first, last, ctx, mem_ctx))
return false;
- link_and_validate_uniforms(ctx, prog);
+ if (!ctx->Const.UseNIRGLSLLinker)
+ link_and_validate_uniforms(ctx, prog);
if (!prog->data->LinkStatus)
return false;