[Mesa-dev] [PATCH v2 07/82] glsl: Add ir_binop_ssbo_load expression operation.

Iago Toral Quiroga itoral at igalia.com
Wed Jun 3 00:00:57 PDT 2015


From: Kristian Høgsberg <krh at bitplanet.net>

This will be used to load the value of a buffer variable from an SSBO,
like ir_binop_ubo_load for UBOs.
---
 src/glsl/ir.cpp                                          | 1 +
 src/glsl/ir.h                                            | 8 ++++++++
 src/glsl/ir_validate.cpp                                 | 5 +++++
 src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp | 1 +
 src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp           | 4 ++++
 src/mesa/program/ir_to_mesa.cpp                          | 1 +
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp               | 4 ++++
 7 files changed, 24 insertions(+)

diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
index 9a25bf4..5a02523 100644
--- a/src/glsl/ir.cpp
+++ b/src/glsl/ir.cpp
@@ -600,6 +600,7 @@ static const char *const operator_strs[] = {
    "packHalf2x16_split",
    "bfm",
    "ubo_load",
+   "ssbo_load",
    "ldexp",
    "vector_extract",
    "interpolate_at_offset",
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index dd10298..1118732 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -1496,6 +1496,14 @@ enum ir_expression_operation {
    ir_binop_ubo_load,
 
    /**
+    * Load a value the size of a given GLSL type from a buffer block.
+    *
+    * operand0 is the ir_constant buffer block index in the linked shader.
+    * operand1 is a byte offset within the uniform block.
+    */
+   ir_binop_ssbo_load,
+
+   /**
     * \name Multiplies a number by two to a power, part of ARB_gpu_shader5.
     */
    /*@{*/
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
index cfe0df3..b292ce4 100644
--- a/src/glsl/ir_validate.cpp
+++ b/src/glsl/ir_validate.cpp
@@ -573,6 +573,11 @@ ir_validate::visit_leave(ir_expression *ir)
       assert(ir->operands[1]->type == glsl_type::uint_type);
       break;
 
+   case ir_binop_ssbo_load:
+      assert(ir->operands[0]->type == glsl_type::uint_type);
+      assert(ir->operands[1]->type == glsl_type::uint_type);
+      break;
+
    case ir_binop_ldexp:
       assert(ir->operands[0]->type == ir->type);
       assert(ir->operands[0]->type->is_float() ||
diff --git a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
index d0f6122..b8ed6b6 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_channel_expressions.cpp
@@ -378,6 +378,7 @@ ir_channel_expressions_visitor::visit_leave(ir_assignment *ir)
    }
 
    case ir_binop_ubo_load:
+   case ir_binop_ssbo_load:
       unreachable("not yet supported");
 
    case ir_triop_fma:
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
index 3164d26..bf8c6b4 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp
@@ -1810,6 +1810,10 @@ vec4_visitor::visit(ir_expression *ir)
       emit(BFI1(result_dst, op[0], op[1]));
       break;
 
+   case ir_binop_ssbo_load:
+      assert(!"Not implemented");
+      break;
+
    case ir_binop_ubo_load: {
       ir_constant *const_uniform_block = ir->operands[0]->as_constant();
       ir_constant *const_offset_ir = ir->operands[1]->as_constant();
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 3dcb537..b86718c 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -1341,6 +1341,7 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
    case ir_unop_dFdx_fine:
    case ir_unop_dFdy_coarse:
    case ir_unop_dFdy_fine:
+   case ir_binop_ssbo_load:
       assert(!"not supported");
       break;
 
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index db190c9..95b2d52 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -2022,6 +2022,10 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
       assert(!"GLSL 1.30 features unsupported");
       break;
 
+   case ir_binop_ssbo_load:
+      assert(!"Not implemented");
+      break;
+
    case ir_binop_ubo_load: {
       ir_constant *const_uniform_block = ir->operands[0]->as_constant();
       ir_constant *const_offset_ir = ir->operands[1]->as_constant();
-- 
1.9.1



More information about the mesa-dev mailing list