i965: add support for ARB_shader_subroutine
authorDave Airlie <airlied@redhat.com>
Tue, 21 Jul 2015 04:22:11 +0000 (14:22 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 24 Jul 2015 00:25:08 +0000 (10:25 +1000)
This just adds some missing pieces to nir/i965,
it is lightly tested on my Haswell.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
docs/GL3.txt
docs/relnotes/10.7.0.html
src/glsl/glsl_types.cpp
src/glsl/nir/glsl_to_nir.cpp
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
src/mesa/drivers/dri/i965/brw_shader.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
src/mesa/drivers/dri/i965/intel_extensions.c

index 5200737bae70646d6791764497abae95119f64e1..bcc3424a17f02e2f9675270942337ca076420d8f 100644 (file)
@@ -111,7 +111,7 @@ GL 4.0, GLSL 4.00:
   - New overload resolution rules                      DONE
   GL_ARB_gpu_shader_fp64                               DONE (nvc0, radeonsi, llvmpipe, softpipe)
   GL_ARB_sample_shading                                DONE (i965, nv50, nvc0, r600, radeonsi)
-  GL_ARB_shader_subroutine                             DONE (nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
+  GL_ARB_shader_subroutine                             DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
   GL_ARB_tessellation_shader                           DONE (nvc0, radeonsi)
   GL_ARB_texture_buffer_object_rgb32                   DONE (i965, nvc0, r600, radeonsi, llvmpipe, softpipe)
   GL_ARB_texture_cube_map_array                        DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
index a2e7c02e7b232fba9d4452315bd62d29fb11befd..26615a8381401cc6fdeeafdac84ff94f935cc25f 100644 (file)
@@ -50,7 +50,7 @@ Note: some of the new features are only available with certain drivers.
 <li>GL_ARB_get_texture_sub_image for all drivers</li>
 <li>GL_ARB_gpu_shader_fp64 on llvmpipe, radeonsi</li>
 <li>GL_ARB_shader_stencil_export on llvmpipe</li>
-<li>GL_ARB_shader_subroutine on core profile gallium drivers</li>
+<li>GL_ARB_shader_subroutine on core profile all drivers</li>
 <li>GL_ARB_tessellation_shader on nvc0, radeonsi</li>
 <li>GL_ARB_vertex_attrib_64bit on llvmpipe, radeonsi</li>
 <li>GL_ARB_viewport_array on radeonsi</li>
index 8510671d2f32c7d096830200150153a0fae58bdc..755618ac28b10b51f4a727a8f22503200cedcbec 100644 (file)
@@ -1027,11 +1027,11 @@ glsl_type::component_slots() const
 
    case GLSL_TYPE_IMAGE:
       return 1;
-
+   case GLSL_TYPE_SUBROUTINE:
+     return 1;
    case GLSL_TYPE_SAMPLER:
    case GLSL_TYPE_ATOMIC_UINT:
    case GLSL_TYPE_VOID:
-   case GLSL_TYPE_SUBROUTINE:
    case GLSL_TYPE_ERROR:
       break;
    }
index 66430f39995c3ced759e89ecfc513fd21eb2595d..77327b6c74f133b59d9164d788412447b8cb5387 100644 (file)
@@ -1171,6 +1171,7 @@ nir_visitor::visit(ir_expression *ir)
    case ir_unop_bitcast_f2i:
    case ir_unop_bitcast_u2f:
    case ir_unop_bitcast_f2u:
+   case ir_unop_subroutine_to_int:
       /* no-op */
       emit(nir_op_imov, dest_size, srcs);
       break;
index 9af153773610a04c6f5dd8bbceedca98f8df3688..7f25a21f0d14a941b01cde6c139938b2874e80d3 100644 (file)
@@ -481,6 +481,8 @@ fs_visitor::type_size(const struct glsl_type *type)
       return 0;
    case GLSL_TYPE_ATOMIC_UINT:
       return 0;
+   case GLSL_TYPE_SUBROUTINE:
+      return 1;
    case GLSL_TYPE_IMAGE:
    case GLSL_TYPE_VOID:
    case GLSL_TYPE_ERROR:
index d0f61222e5a90a904377635672680b12cd945f8e..a8883a35ef296f38ff11c9e9ac2f332b81de9a5b 100644 (file)
@@ -243,6 +243,7 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
    case ir_unop_find_msb:
    case ir_unop_find_lsb:
    case ir_unop_saturate:
+   case ir_unop_subroutine_to_int:
       for (i = 0; i < vector_elements; i++) {
         ir_rvalue *op0 = get_element(op_var[0], i);
 
index 9d60543c1674f76d401b168cd87021a2dcffeaca..703e9aa913e77087680a61361dff17bf5aeb2e9f 100644 (file)
@@ -430,6 +430,7 @@ brw_type_for_base_type(const struct glsl_type *type)
       return BRW_REGISTER_TYPE_F;
    case GLSL_TYPE_INT:
    case GLSL_TYPE_BOOL:
+   case GLSL_TYPE_SUBROUTINE:
       return BRW_REGISTER_TYPE_D;
    case GLSL_TYPE_UINT:
       return BRW_REGISTER_TYPE_UD;
index a6eee47fcb0c00ee2ae2e48c15b4db8e3f6f4102..6fee798038c4e44c57eb8311dd67b78af61fb8dd 100644 (file)
@@ -603,6 +603,9 @@ type_size(const struct glsl_type *type)
         size += type_size(type->fields.structure[i].type);
       }
       return size;
+   case GLSL_TYPE_SUBROUTINE:
+      return 1;
+
    case GLSL_TYPE_SAMPLER:
       /* Samplers take up no register space, since they're baked in at
        * link time.
@@ -1558,6 +1561,10 @@ vec4_visitor::visit(ir_expression *ir)
    case ir_unop_noise:
       unreachable("not reached: should be handled by lower_noise");
 
+   case ir_unop_subroutine_to_int:
+      emit(MOV(result_dst, op[0]));
+      break;
+
    case ir_binop_add:
       emit(ADD(result_dst, op[0], op[1]));
       break;
index 6b3bd12ff54d43ec894c00fb985077111f8a2b9c..4a0ffffe59e3a7b501851beefd0d59cca9e335a8 100644 (file)
@@ -311,6 +311,7 @@ intelInitExtensions(struct gl_context *ctx)
        * slightly differently when the extension is enabled.
        */
       if (ctx->API == API_OPENGL_CORE) {
+         ctx->Extensions.ARB_shader_subroutine = true;
          ctx->Extensions.ARB_viewport_array = true;
          ctx->Extensions.AMD_vertex_shader_viewport_index = true;
       }
@@ -343,6 +344,7 @@ intelInitExtensions(struct gl_context *ctx)
       if (ctx->API == API_OPENGL_CORE) {
          ctx->Extensions.ARB_viewport_array = true;
          ctx->Extensions.AMD_vertex_shader_viewport_index = true;
+         ctx->Extensions.ARB_shader_subroutine = true;
       }
    }