From: Cody Northrop Date: Wed, 22 Oct 2014 22:14:47 +0000 (-0600) Subject: compiler: Allow texture unit bindings to also set sampler index X-Git-Tag: khronos-master-20141209~128 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c33ac9267a70115c29f97eb20966de4c9aed6938;p=platform%2Fupstream%2FVulkan-LoaderAndValidationLayers.git compiler: Allow texture unit bindings to also set sampler index --- diff --git a/icd/intel/compiler/shader/link_uniforms.cpp b/icd/intel/compiler/shader/link_uniforms.cpp index 9371347..3a78f3d 100644 --- a/icd/intel/compiler/shader/link_uniforms.cpp +++ b/icd/intel/compiler/shader/link_uniforms.cpp @@ -368,8 +368,9 @@ class parcel_out_uniform_storage : public program_resource_visitor { public: parcel_out_uniform_storage(struct string_to_uint_map *map, struct gl_uniform_storage *uniforms, - union gl_constant_value *values) - : map(map), uniforms(uniforms), values(values) + union gl_constant_value *values, + bool xgl) + : map(map), uniforms(uniforms), values(values), isXGL(xgl) { } @@ -440,14 +441,27 @@ public: var->get_interface_type()->name); else process(var); - } else + } else { + + // Allow uniform binding to set sampler index for XGL + // This means both the texture unit and sampler unit will + // be bound based on the binding. For instance: + // layout (binding = 2) uniform sampler2D surface; + // will read from: + // XGL_SLOT_SHADER_SAMPLER 2 + // XGL_SLOT_SHADER_RESOURCE 2 + if (isXGL && var->type->is_sampler()) + this->next_sampler = var->data.binding; + process(var); + } } int ubo_block_index; int ubo_byte_offset; bool ubo_row_major; gl_shader_stage shader_type; + bool isXGL; private: void handle_samplers(const glsl_type *base_type, @@ -794,7 +808,7 @@ link_set_image_access_qualifiers(struct gl_shader_program *prog) } void -link_assign_uniform_locations(struct gl_shader_program *prog) +link_assign_uniform_locations(struct gl_shader_program *prog, bool isXGL) { ralloc_free(prog->UniformStorage); prog->UniformStorage = NULL; @@ -886,7 +900,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog) union gl_constant_value *data_end = &data[num_data_slots]; #endif - parcel_out_uniform_storage parcel(prog->UniformHash, uniforms, data); + parcel_out_uniform_storage parcel(prog->UniformHash, uniforms, data, isXGL); for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) diff --git a/icd/intel/compiler/shader/linker.cpp b/icd/intel/compiler/shader/linker.cpp index a55c7c6..fd23997 100644 --- a/icd/intel/compiler/shader/linker.cpp +++ b/icd/intel/compiler/shader/linker.cpp @@ -2590,7 +2590,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) goto done; update_array_sizes(prog); - link_assign_uniform_locations(prog); + link_assign_uniform_locations(prog, ctx->API == API_XGL); link_assign_atomic_counter_resources(ctx, prog); store_fragdepth_layout(prog); diff --git a/icd/intel/compiler/shader/linker.h b/icd/intel/compiler/shader/linker.h index f0a947b..28b0ba9 100644 --- a/icd/intel/compiler/shader/linker.h +++ b/icd/intel/compiler/shader/linker.h @@ -37,7 +37,7 @@ extern void link_invalidate_variable_locations(exec_list *ir); extern void -link_assign_uniform_locations(struct gl_shader_program *prog); +link_assign_uniform_locations(struct gl_shader_program *prog, bool isXGL); extern void link_set_uniform_initializers(struct gl_shader_program *prog);