vk/compiler: Fix up the binding hack and make it work in NIR
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 25 May 2015 19:42:59 +0000 (12:42 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 25 May 2015 19:57:32 +0000 (12:57 -0700)
src/glsl/link_uniform_blocks.cpp
src/mesa/drivers/dri/i965/brw_fs_nir.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp
src/mesa/main/mtypes.h

index ca87bf0df719d18f63407617635e56a009f10ad6..c0d73076aa8f335c363555b6763d0bd98582a240 100644 (file)
@@ -294,7 +294,7 @@ link_uniform_blocks(void *mem_ctx,
                (unsigned)(ptrdiff_t)(&variables[parcel.index] - blocks[i].Uniforms);
 
             blocks[i].Set = b->set;
-            blocks[i].Index = b->index;
+            blocks[i].Binding = b->binding;
 
             i++;
          }
@@ -315,7 +315,7 @@ link_uniform_blocks(void *mem_ctx,
             (unsigned)(ptrdiff_t)(&variables[parcel.index] - blocks[i].Uniforms);
 
          blocks[i].Set = b->set;
-         blocks[i].Index = b->index;
+         blocks[i].Binding = b->binding;
 
          i++;
       }
index 9cfd0e792a2b917961fbb851ed43e1bee27781a4..82dbca3cf43df90b8584eded93f71b28f9811739 100644 (file)
@@ -1399,9 +1399,13 @@ fs_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
       fs_reg surf_index;
 
       if (const_index) {
-         surf_index = fs_reg(stage_prog_data->binding_table.ubo_start +
-                             const_index->u[0]);
+         uint32_t index = const_index->u[0];
+         uint32_t set = shader->base.UniformBlocks[index].Set;
+         uint32_t binding = shader->base.UniformBlocks[index].Binding;
+
+         surf_index = fs_reg(stage_prog_data->bind_map[set][binding]);
       } else {
+         assert(0 && "need more info from the ir for this.");
          /* The block index is not a constant. Evaluate the index expression
           * per-channel and add the base UBO index; we have to select a value
           * from any live channel.
index d6bb1178f7cc5908a665dc499cef19686a062740..07853c0d0d6f44286e3da7d56e208ae40e78629d 100644 (file)
@@ -1206,7 +1206,7 @@ fs_visitor::visit(ir_expression *ir)
           */
          index = const_uniform_block->value.u[0];
          set = shader->base.UniformBlocks[index].Set;
-         set_index = shader->base.UniformBlocks[index].Index;
+         set_index = shader->base.UniformBlocks[index].Binding;
          binding = stage_prog_data->bind_map[set][set_index];
          surf_index = fs_reg(binding);
       } else {
index 895103470ee597591259db85ff527d295d092e53..bd84113ea919e5ee16a215c5f2aecd862288ad0a 100644 (file)
@@ -2571,10 +2571,9 @@ struct gl_uniform_block
    GLuint Binding;
 
    /**
-    * Vulkan descriptor set and index qualifiers for this block.
+    * Vulkan descriptor set qualifier for this block.
     */
    GLuint Set;
-   GLuint Index;
 
    /**
     * Minimum size (in bytes) of a buffer object to back this uniform buffer