From 510b5c3bedced1fe4cda0f5d459c45b83914b622 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Mon, 1 Jun 2015 10:01:23 -0700 Subject: [PATCH] vk/HACK: Plumb real descriptor set/index into textures --- src/glsl/nir/glsl_to_nir.cpp | 1 + src/glsl/nir/nir.h | 4 ++++ src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 4 +++- src/mesa/drivers/dri/i965/brw_nir.c | 2 +- src/vulkan/compiler.cpp | 2 -- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 7a20e1a36f5..7c30be3fa72 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -321,6 +321,7 @@ nir_visitor::visit(ir_variable *ir) } var->data.index = ir->data.index; + var->data.descriptor_set = ir->data.set; var->data.binding = ir->data.binding; /* XXX Get rid of buffer_index */ var->data.atomic.buffer_index = ir->data.binding; diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h index 38dbe13ac03..c666d93e66b 100644 --- a/src/glsl/nir/nir.h +++ b/src/glsl/nir/nir.h @@ -300,6 +300,7 @@ typedef struct { * * For array types, this represents the binding point for the first element. */ + int descriptor_set; int binding; /** @@ -985,6 +986,9 @@ typedef struct { /* gather component selector */ unsigned component : 2; + /* The descriptor set containing this texture */ + unsigned sampler_set; + /** The sampler index * * If this texture instruction has a nir_tex_src_sampler_offset source, diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 82dbca3cf43..2623241a056 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -1622,7 +1622,9 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr) void fs_visitor::nir_emit_texture(nir_tex_instr *instr) { - unsigned sampler = instr->sampler_index; + uint32_t set = instr->sampler_set; + uint32_t index = instr->sampler_index; + unsigned sampler = stage_prog_data->bind_map[set][index]; fs_reg sampler_reg(sampler); /* FINISHME: We're failing to recompile our programs when the sampler is diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index de4d7aafd44..e4119b1aa3f 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -144,7 +144,7 @@ brw_create_nir(struct brw_context *brw, nir_validate_shader(nir); if (shader_prog) { - nir_lower_samplers(nir, shader_prog, stage); + nir_lower_samplers_for_vk(nir); nir_validate_shader(nir); } diff --git a/src/vulkan/compiler.cpp b/src/vulkan/compiler.cpp index 2bd197e352b..42c54fbe8d3 100644 --- a/src/vulkan/compiler.cpp +++ b/src/vulkan/compiler.cpp @@ -71,8 +71,6 @@ set_binding_table_layout(struct brw_stage_prog_data *prog_data, else bias = 0; - prog_data->binding_table.texture_start = bias; - count = layout->stage[stage].surface_count; prog_data->map_entries = (uint32_t *) malloc(count * sizeof(prog_data->map_entries[0])); -- 2.30.2