#include "util/u_string.h"
#include "util/u_math.h"
-#include "util/imports.h"
+
#include "main/shaderobj.h"
#include "main/enums.h"
#include "main/mtypes.h"
}
}
+/**
+ * Check for conflicting viewport_relative settings across shaders, and sets
+ * the value for the linked shader.
+ */
+static void
+link_layer_viewport_relative_qualifier(struct gl_shader_program *prog,
+ struct gl_program *gl_prog,
+ struct gl_shader **shader_list,
+ unsigned num_shaders)
+{
+ unsigned i;
+
+ /* Find first shader with explicit layer declaration */
+ for (i = 0; i < num_shaders; i++) {
+ if (shader_list[i]->redeclares_gl_layer) {
+ gl_prog->info.layer_viewport_relative =
+ shader_list[i]->layer_viewport_relative;
+ break;
+ }
+ }
+
+ /* Now make sure that each subsequent shader's explicit layer declaration
+ * matches the first one's.
+ */
+ for (; i < num_shaders; i++) {
+ if (shader_list[i]->redeclares_gl_layer &&
+ shader_list[i]->layer_viewport_relative !=
+ gl_prog->info.layer_viewport_relative) {
+ linker_error(prog, "all gl_Layer redeclarations must have identical "
+ "viewport_relative settings");
+ }
+ }
+}
+
/**
* Performs the cross-validation of tessellation control shader vertices and
* layout qualifiers for the attached tessellation control shaders,
/* 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);
link_bindless_layout_qualifiers(prog, shader_list, num_shaders);
+ link_layer_viewport_relative_qualifier(prog, gl_prog, shader_list, num_shaders);
+
populate_symbol_table(linked, shader_list[0]->symbols);
/* The pointer to the main function in the final linked shader (i.e., the
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 */
struct gl_shader_program *prog)
{
update_array_sizes(prog);
- link_assign_uniform_locations(prog, ctx);
-
- if (prog->data->LinkStatus == LINKING_FAILURE)
- return;
if (!ctx->Const.UseNIRGLSLLinker) {
+ link_assign_uniform_locations(prog, ctx);
+
+ 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);